Class TreeMapPane<T>

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.layout.Pane
software.coley.treemap.TreeMapPane<T>
Type Parameters:
T - Type of content.
All Implemented Interfaces:
javafx.css.Styleable, javafx.event.EventTarget

public class TreeMapPane<T> extends javafx.scene.layout.Pane
Tree map pane to render weighted values in different sized rectangles.

To add content to the pane, you need to provide two things:

  1. A conversion of 'T' to double for calculating 'T' items "value"
  2. A conversion of 'T' to nodes for visualizing 'T' items
The nodes supplied by the node factory are sized according to their "value" relative to all other items. More valuable items are given larger nodes.

Should you wish to change the sizeFunctionProperty() or nodeFactoryProperty() you must do so on the FX thread.

Author:
Matt Coley
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.property.ObjectProperty<Function<T,javafx.scene.Node>>
     
    javafx.beans.property.ObjectProperty<ToDoubleFunction<T>>
     
    javafx.beans.property.ListProperty<T>
     
    javafx.collections.ObservableMap<T,javafx.scene.Node>
     

    Properties inherited from class javafx.scene.layout.Region

    background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width

    Properties inherited from class javafx.scene.Parent

    needsLayout

    Properties inherited from class javafx.scene.Node

    accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, focusVisible, focusWithin, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final javafx.beans.property.ObjectProperty<Function<T,javafx.scene.Node>>
     
    protected final javafx.beans.property.ObjectProperty<ToDoubleFunction<T>>
     
    protected final javafx.beans.property.ListProperty<T>
     
    protected final javafx.beans.property.MapProperty<T,javafx.scene.Node>
     

    Fields inherited from class javafx.scene.layout.Region

    USE_COMPUTED_SIZE, USE_PREF_SIZE

    Fields inherited from class javafx.scene.Node

    BASELINE_OFFSET_SAME_AS_HEIGHT
  • Constructor Summary

    Constructors
    Constructor
    Description
    TreeMapPane(ToDoubleFunction<T> sizeFunction, Function<T,javafx.scene.Node> nodeFactory)
    New tree-map pane.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected List<Rectangle<T>>
    computeRectangles(double canvasX, double canvasY, double canvasWidth, double canvasHeight)
     
    static <C extends TreeContent>
    TreeMapPane<C>
    Creates a new tree-map pane modeling some TreeContent data type.
    protected javafx.beans.Observable[]
     
    protected void
    layoutChild(Rectangle<T> rectangle, javafx.scene.Node node)
     
    protected void
     
    javafx.beans.property.ObjectProperty<Function<T,javafx.scene.Node>>
     
    protected void
    setupChangeBindings(javafx.beans.binding.ObjectBinding<?> multiSourceBindings)
    Configures UI updates through bindings.
    javafx.beans.property.ObjectProperty<ToDoubleFunction<T>>
     
    javafx.beans.property.ListProperty<T>
     
    javafx.collections.ObservableMap<T,javafx.scene.Node>
     

    Methods inherited from class javafx.scene.layout.Pane

    getChildren

    Methods inherited from class javafx.scene.layout.Region

    backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty

    Methods inherited from class javafx.scene.Parent

    getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds

    Methods inherited from class javafx.scene.Node

    accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, focusVisibleProperty, focusWithinProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isFocusVisible, isFocusWithin, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface javafx.css.Styleable

    getStyleableNode
  • Property Details

    • valueList

      @Nonnull public javafx.beans.property.ListProperty<T> valueListProperty
    • valueToNode

      @Nonnull public javafx.collections.ObservableMap<T,javafx.scene.Node> valueToNodeProperty
    • nodeFactory

      @Nonnull public javafx.beans.property.ObjectProperty<Function<T,javafx.scene.Node>> nodeFactoryProperty
    • sizeFunction

      @Nonnull public javafx.beans.property.ObjectProperty<ToDoubleFunction<T>> sizeFunctionProperty
  • Field Details

    • valueToNode

      protected final javafx.beans.property.MapProperty<T,javafx.scene.Node> valueToNode
    • valueList

      protected final javafx.beans.property.ListProperty<T> valueList
    • sizeFunction

      protected final javafx.beans.property.ObjectProperty<ToDoubleFunction<T>> sizeFunction
    • nodeFactory

      protected final javafx.beans.property.ObjectProperty<Function<T,javafx.scene.Node>> nodeFactory
  • Constructor Details

    • TreeMapPane

      public TreeMapPane(@Nonnull ToDoubleFunction<T> sizeFunction, @Nonnull Function<T,javafx.scene.Node> nodeFactory)
      New tree-map pane.
      Parameters:
      sizeFunction - Size computation function for T values.
      nodeFactory - Node providing function for T values.
  • Method Details

    • forTreeContent

      @Nonnull public static <C extends TreeContent> TreeMapPane<C> forTreeContent()
      Creates a new tree-map pane modeling some TreeContent data type.
      Type Parameters:
      C - Tree content implementation type.
      Returns:
      New tree-map pane for TreeContent data.
    • setupChangeBindings

      protected void setupChangeBindings(@Nonnull javafx.beans.binding.ObjectBinding<?> multiSourceBindings)
      Configures UI updates through bindings.
      Parameters:
      multiSourceBindings - Binding that wraps properties of this pane. Any change in one property is forwarded to this wrapper property.
    • getTreeMapProperties

      @Nonnull protected javafx.beans.Observable[] getTreeMapProperties()
      Returns:
      Array of properties to consider for triggering recalculation of the tree-map display.
    • valueListProperty

      @Nonnull public javafx.beans.property.ListProperty<T> valueListProperty()
    • valueToNodeProperty

      @Nonnull public javafx.collections.ObservableMap<T,javafx.scene.Node> valueToNodeProperty()
    • nodeFactoryProperty

      @Nonnull public javafx.beans.property.ObjectProperty<Function<T,javafx.scene.Node>> nodeFactoryProperty()
    • sizeFunctionProperty

      @Nonnull public javafx.beans.property.ObjectProperty<ToDoubleFunction<T>> sizeFunctionProperty()
    • computeRectangles

      @Nonnull protected List<Rectangle<T>> computeRectangles(double canvasX, double canvasY, double canvasWidth, double canvasHeight)
      Parameters:
      canvasX - X coordinate of rectangle to fill.
      canvasY - Y coordinate of rectangle to fill.
      canvasWidth - Width of the rectangle to fill.
      canvasHeight - Height of the rectangle to fill.
      Returns:
      Rectangles of the values filling the given space.
    • layoutChildren

      protected void layoutChildren()
      Overrides:
      layoutChildren in class javafx.scene.Parent
    • layoutChild

      protected void layoutChild(@Nonnull Rectangle<T> rectangle, @Nonnull javafx.scene.Node node)
      Parameters:
      rectangle - Space to fill.
      node - Node to assign position/size of to match the rectangle.