An JavaFx implementation of a treemap
The original algorithm for the core code is derived from javafx-chart-treemap.
This version is for Java 17.
This small project is in its very early days and features may not be stable.
SO, feel free to request changes!! I welcome ideas for missing features/architectures...
If using maven, one can add the following dependency:
<dependency>
<groupId>com.github.ptitnoony.components</groupId>
<artifactId>fxtreemap</artifactId>
<version>0.5</version>
</dependency>
This version uses a set a javafx.scene.shape.Rectangle
to draw the treemap.
It also allows more flexibility (on the implementation side) to add new features.
This component uses a javafx.scene.canvas.Canvas
to draw the treemap.
The main examples are available in the main
class. Here is an extract of the code
ConcreteMapData data1 = new ConcreteMapData("data1", 6.0);
...
ConcreteMapData data7 = new ConcreteMapData("data7", 1.0);
ConcreteMapData data = new ConcreteMapData("data-set1", data1, data2, data3, data4, data5, data6, data7);
FxTreeMap fxTreeMap = new FxTreeMap(data);
fxTreeMap.setBackgroundColor(Color.LIGHTGRAY);
fxTreeMap.setStoke(Color.WHITESMOKE);
fxTreeMap.setBorderRadius(10.0);
fxTreeMap.setPadding(5);
Node fxTreeMapNode = fxTreeMap.getNode();
rectAnchorPane.getChildren().add(fxTreeMapNode);
AnchorPane.setBottomAnchor(fxTreeMapNode, 4.0);
AnchorPane.setLeftAnchor(fxTreeMapNode, 4.0);
AnchorPane.setRightAnchor(fxTreeMapNode, 4.0);
AnchorPane.setTopAnchor(fxTreeMapNode, 4.0);
The library provides a small example to illustrate the controls over the TreeMap component.
update UI when data model is changed- use css styles
- draw recursively in canvas example
draw names for each data item