Documentation of 'org.jfree.chart.fx.ChartCanvas' Java class
ChartCanvas
org.jfree.chart.fx

Class ChartCanvas

  • All Implemented Interfaces:
    java.util.EventListener, javafx.css.Styleable, javafx.event.EventTarget, ChartChangeListener


    public class ChartCanvas
    extends javafx.scene.canvas.Canvas
    implements ChartChangeListener
    A canvas for displaying a JFreeChart in JavaFX. You can use the canvas directly to display charts, but usually the ChartViewer class (which embeds a canvas) is a better option.

    The canvas installs several default mouse handlers, if you don't like the behaviour provided by these you can retrieve the handler by ID and disable or remove it (the IDs are "tooltip", "scroll", "anchor", "pan" and "dispatch").

    THE API FOR THIS CLASS IS SUBJECT TO CHANGE IN FUTURE RELEASES. This is so that we can incorporate feedback on the (new) JavaFX support in JFreeChart.

    Since:
    1.0.18
    • Property Summary

      • Properties inherited from class javafx.scene.canvas.Canvas

        heightProperty, widthProperty
      • Properties inherited from class javafx.scene.Node

        accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, 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, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
    • Field Summary

      • Fields inherited from class javafx.scene.Node

        BASELINE_OFFSET_SAME_AS_HEIGHT
    • Constructor Summary

      Constructors 
      Constructor and Description
      ChartCanvas(JFreeChart chart)
      Creates a new canvas to display the supplied chart in JavaFX.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addChartMouseListener(ChartMouseListenerFX listener)
      Registers a listener to receive ChartMouseEvent notifications.
      void addMouseHandler(MouseHandlerFX handler)
      Adds a mouse handler to the list of available handlers (handlers that are candidates to take the position of live handler).
      void chartChanged(ChartChangeEvent event)
      Receives a notification from the chart that it has been changed and responds by redrawing the chart entirely.
      void clearLiveHandler()
      Clears the current live handler.
      void dispatchMouseClickedEvent(java.awt.geom.Point2D point, javafx.scene.input.MouseEvent e) 
      void dispatchMouseMovedEvent(java.awt.geom.Point2D point, javafx.scene.input.MouseEvent e) 
      void draw()
      Draws the content of the canvas and updates the renderingInfo attribute with the latest rendering information.
      java.awt.geom.Rectangle2D findDataArea(java.awt.geom.Point2D point)
      Returns the data area (the area inside the axes) for the plot or subplot.
      JFreeChart getChart()
      Returns the chart that is being displayed by this node.
      MouseHandlerFX getMouseHandler(java.lang.String id)
      Returns the mouse handler with the specified ID, or null if there is no handler with that ID.
      ChartRenderingInfo getRenderingInfo()
      Returns the rendering info from the most recent drawing of the chart.
      boolean isResizable()
      Return true to indicate the canvas is resizable.
      boolean isTooltipEnabled()
      Returns the flag that controls whether or not tooltips are enabled.
      void removeChartMouseListener(ChartMouseListenerFX listener)
      Removes a listener from the list of objects listening for chart mouse events.
      void removeMouseHandler(MouseHandlerFX handler)
      Removes a handler from the list of available handlers.
      void setAnchor(java.awt.geom.Point2D anchor)
      Set the anchor point and forces a redraw of the chart (the anchor point is used to determine the position of the crosshairs on the chart, if they are visible).
      void setChart(JFreeChart chart)
      Sets the chart to be displayed by this node.
      void setTooltip(java.lang.String text, double x, double y)
      Sets the tooltip text, with the (x, y) location being used for the anchor.
      void setTooltipEnabled(boolean tooltipEnabled)
      Sets the flag that controls whether or not tooltips are enabled.
      • Methods inherited from class javafx.scene.canvas.Canvas

        getGraphicsContext2D, getHeight, getWidth, heightProperty, impl_computeGeomBounds, impl_processMXNode, impl_updatePeer, setHeight, setWidth, widthProperty
      • 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, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBaselineOffset, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClassCssMetaData, getClip, getContentBias, getCssMetaData, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, 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, hasProperties, hoverProperty, idProperty, impl_findStyles, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_isShowMnemonics, impl_isTreeVisible, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, 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, lookup, lookupAll, managedProperty, maxHeight, maxWidth, minHeight, minWidth, 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, prefHeight, prefWidth, pressedProperty, pseudoClassStateChanged, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, resize, 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, setEffect, setEventDispatcher, setFocusTraversable, 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, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ChartCanvas

        public ChartCanvas(JFreeChart chart)
        Creates a new canvas to display the supplied chart in JavaFX.
        Parameters:
        chart - the chart (null not permitted).
    • Method Detail

      • getChart

        public JFreeChart getChart()
        Returns the chart that is being displayed by this node.
        Returns:
        The chart (never null).
      • setChart

        public void setChart(JFreeChart chart)
        Sets the chart to be displayed by this node.
        Parameters:
        chart - the chart (null not permitted).
      • getRenderingInfo

        public ChartRenderingInfo getRenderingInfo()
        Returns the rendering info from the most recent drawing of the chart.
        Returns:
        The rendering info (possibly null).
      • isTooltipEnabled

        public boolean isTooltipEnabled()
        Returns the flag that controls whether or not tooltips are enabled. The default value is true. The TooltipHandlerFX class will only update the tooltip if this flag is set to true.
        Returns:
        The flag.
      • setTooltipEnabled

        public void setTooltipEnabled(boolean tooltipEnabled)
        Sets the flag that controls whether or not tooltips are enabled.
        Parameters:
        tooltipEnabled - the new flag value.
      • setAnchor

        public void setAnchor(java.awt.geom.Point2D anchor)
        Set the anchor point and forces a redraw of the chart (the anchor point is used to determine the position of the crosshairs on the chart, if they are visible).
        Parameters:
        anchor - the anchor (null permitted).
      • addChartMouseListener

        public void addChartMouseListener(ChartMouseListenerFX listener)
        Registers a listener to receive ChartMouseEvent notifications.
        Parameters:
        listener - the listener (null not permitted).
      • removeChartMouseListener

        public void removeChartMouseListener(ChartMouseListenerFX listener)
        Removes a listener from the list of objects listening for chart mouse events.
        Parameters:
        listener - the listener.
      • getMouseHandler

        public MouseHandlerFX getMouseHandler(java.lang.String id)
        Returns the mouse handler with the specified ID, or null if there is no handler with that ID. This method will look for handlers in both the regular and auxiliary handler lists.
        Parameters:
        id - the ID (null not permitted).
        Returns:
        The handler with the specified ID
      • addMouseHandler

        public void addMouseHandler(MouseHandlerFX handler)
        Adds a mouse handler to the list of available handlers (handlers that are candidates to take the position of live handler). The handler must have an ID that uniquely identifies it amongst the handlers registered with this canvas.
        Parameters:
        handler - the handler (null not permitted).
      • removeMouseHandler

        public void removeMouseHandler(MouseHandlerFX handler)
        Removes a handler from the list of available handlers.
        Parameters:
        handler - the handler (null not permitted).
      • clearLiveHandler

        public void clearLiveHandler()
        Clears the current live handler. This method is intended for use by the handlers themselves, you should not call it directly.
      • draw

        public final void draw()
        Draws the content of the canvas and updates the renderingInfo attribute with the latest rendering information.
      • findDataArea

        public java.awt.geom.Rectangle2D findDataArea(java.awt.geom.Point2D point)
        Returns the data area (the area inside the axes) for the plot or subplot.
        Parameters:
        point - the selection point (for subplot selection).
        Returns:
        The data area.
      • isResizable

        public boolean isResizable()
        Return true to indicate the canvas is resizable.
        Overrides:
        isResizable in class javafx.scene.Node
        Returns:
        true.
      • setTooltip

        public void setTooltip(java.lang.String text,
                               double x,
                               double y)
        Sets the tooltip text, with the (x, y) location being used for the anchor. If the text is null, no tooltip will be displayed. This method is intended for calling by the TooltipHandlerFX class, you won't normally call it directly.
        Parameters:
        text - the text (null permitted).
        x - the x-coordinate of the mouse pointer.
        y - the y-coordinate of the mouse pointer.
      • chartChanged

        public void chartChanged(ChartChangeEvent event)
        Receives a notification from the chart that it has been changed and responds by redrawing the chart entirely.
        Specified by:
        chartChanged in interface ChartChangeListener
        Parameters:
        event - event information.
      • dispatchMouseMovedEvent

        public void dispatchMouseMovedEvent(java.awt.geom.Point2D point,
                                            javafx.scene.input.MouseEvent e)
      • dispatchMouseClickedEvent

        public void dispatchMouseClickedEvent(java.awt.geom.Point2D point,
                                              javafx.scene.input.MouseEvent e)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.