https://github.com/ptitnoony/fxtreemap
An JavaFx implementation of a treemap
https://github.com/ptitnoony/fxtreemap
java-17 java-8 javafx treemap
Last synced: 30 days ago
JSON representation
An JavaFx implementation of a treemap
- Host: GitHub
- URL: https://github.com/ptitnoony/fxtreemap
- Owner: PtitNoony
- License: mit
- Created: 2017-07-23T22:35:22.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-03T15:54:41.000Z (over 1 year ago)
- Last Synced: 2025-04-10T00:41:54.037Z (30 days ago)
- Topics: java-17, java-8, javafx, treemap
- Language: Java
- Homepage:
- Size: 121 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FxTreeMap
An JavaFx implementation of a treemap[](https://opensource.org/licenses/MIT)
[](https://www.codacy.com/gh/PtitNoony/FxTreeMap/dashboard?utm_source=github.com&utm_medium=referral&utm_content=PtitNoony/FxTreeMap&utm_campaign=Badge_Grade)
[](https://www.versioneye.com/user/projects/597d42850fb24f005e87c771)The original algorithm for the core code is derived from [javafx-chart-treemap](https://github.com/tasubo/javafx-chart-treemap).
## Java Version
This version is for Java 17.
## Disclaimer
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...## Usage
If using maven, one can add the following dependency:
```xml
com.github.ptitnoony.components
fxtreemap
0.5```
## Available tree maps components
### FxTreeMap (most complete at the moment)
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.
### CanvasTreeMap
This component uses a `javafx.scene.canvas.Canvas` to draw the treemap.

## How to
The main examples are available in the `main` class. Here is an extract of the code
### Create the data set
```java
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);
```### Create the treemap component
```java
FxTreeMap fxTreeMap = new FxTreeMap(data);
```### Style the treemap (optional)
```java
fxTreeMap.setBackgroundColor(Color.LIGHTGRAY);
fxTreeMap.setStoke(Color.WHITESMOKE);
fxTreeMap.setBorderRadius(10.0);
fxTreeMap.setPadding(5);
```### Add the treemap to the scene
```java
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);
```## Control view (for illustration)
The library provides a small example to illustrate the controls over the TreeMap component.

## Next steps
- ~~update UI when data model is changed~~
- use css styles
- draw recursively in canvas example
- ~~draw names for each data item~~