Class Axis<T>
java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
javafx.scene.chart.Axis<T>
- Type Parameters:
T
- the axis data type
- All Implemented Interfaces:
Styleable
,EventTarget
- Direct Known Subclasses:
CategoryAxis
,ValueAxis
Base class for all axes in JavaFX that represents an axis drawn on a chart area.
It holds properties for axis auto ranging, ticks and labels along the axis.
Some examples of concrete subclasses include NumberAxis
whose axis plots data
in numbers and CategoryAxis
whose values / ticks represent string
categories along its axis.
- Since:
- JavaFX 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
TickMark represents the label text, its associated properties for each tick along the Axis. -
Property Summary
PropertiesTypePropertyDescriptionfinal BooleanProperty
When true any changes to the axis and its range will be animated.final BooleanProperty
This is true when the axis determines its range from the data automaticallyfinal ObjectProperty
<String> The axis labelfinal ObjectProperty
<Side> The side of the plot which this axis is being drawn onfinal ObjectProperty
<Paint> The fill for all tick labelsfinal ObjectProperty
<Font> The font for all tick labelsfinal DoubleProperty
The gap between tick labels and the tick mark linesfinal DoubleProperty
Rotation in degrees of tick mark labels from their normal horizontal.final BooleanProperty
true if tick mark labels should be displayedfinal DoubleProperty
The length of tick mark linesfinal BooleanProperty
true if tick marks should be displayedProperties declared in class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
Properties declared in class javafx.scene.Parent
needsLayout
Properties declared in 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 declared in class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
Fields declared in class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal BooleanProperty
When true any changes to the axis and its range will be animated.protected abstract Object
autoRange
(double length) This calculates the upper and lower bound based on the data provided to invalidateRange() method.final BooleanProperty
This is true when the axis determines its range from the data automaticallycalculateTickValues
(double length, Object range) Calculate a list of all the data values for each tick mark in rangeprotected double
computePrefHeight
(double width) Computes the preferred height of this axis for the given width.protected double
computePrefWidth
(double height) Computes the preferred width of this axis for the given height.final boolean
Indicates whether the changes to axis range will be animated or not.static List
<CssMetaData<? extends Styleable, ?>> Gets theCssMetaData
associated with this class, which may include theCssMetaData
of its superclasses.List
<CssMetaData<? extends Styleable, ?>> This method should delegate toNode.getClassCssMetaData()
so that a Node's CssMetaData can be accessed without the need for reflection.abstract double
getDisplayPosition
(T value) Get the display position along this axis for a given value.final String
getLabel()
Gets the value of thelabel
property.protected abstract Object
getRange()
Called to get the current axis range.final Side
getSide()
Gets the value of theside
property.final Paint
Gets the value of thetickLabelFill
property.final Font
Gets the value of thetickLabelFont
property.final double
Gets the value of thetickLabelGap
property.final double
Gets the value of thetickLabelRotation
property.final double
Gets the value of thetickLength
property.protected abstract String
getTickMarkLabel
(T value) Get the string label name for a tick mark with the given valueUnmodifiable observable list of tickmarks, each TickMark directly representing a tickmark on this axis.abstract T
getValueForDisplay
(double displayPosition) Get the data value for the given display position on this axis.abstract double
Get the display position of the zero line along this axis.protected final void
Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the next layout.void
invalidateRange
(List<T> data) Called when data has changed and the range may not be valid any more.final boolean
Gets the value of theautoRanging
property.protected final boolean
See if the current range is valid, if it is not then any range dependent calculations need to redone on the next layout passfinal boolean
Gets the value of thetickLabelsVisible
property.final boolean
Gets the value of thetickMarkVisible
property.abstract boolean
isValueOnAxis
(T value) Checks if the given value is plottable on this axisfinal ObjectProperty
<String> The axis labelprotected void
Invoked during the layout pass to layout this axis and all its content.protected final Dimension2D
measureTickMarkLabelSize
(String labelText, double rotation) Measure the size of the label for given tick mark value.protected final Dimension2D
measureTickMarkSize
(T value, double rotation) Measure the size of the label for given tick mark value.protected Dimension2D
measureTickMarkSize
(T value, Object range) Measure the size of the label for given tick mark value.void
Request that the axis is laid out in the next layout pass.void
We suppress requestLayout() calls here by doing nothing as we don't want changes to our children to cause layout.final void
setAnimated
(boolean value) Sets the value of theanimated
property.final void
setAutoRanging
(boolean value) Sets the value of theautoRanging
property.final void
Sets the value of thelabel
property.protected abstract void
Called to set the current axis range to the given range.final void
Sets the value of theside
property.final void
setTickLabelFill
(Paint value) Sets the value of thetickLabelFill
property.final void
setTickLabelFont
(Font value) Sets the value of thetickLabelFont
property.final void
setTickLabelGap
(double value) Sets the value of thetickLabelGap
property.final void
setTickLabelRotation
(double value) Sets the value of thetickLabelRotation
property.final void
setTickLabelsVisible
(boolean value) Sets the value of thetickLabelsVisible
property.final void
setTickLength
(double value) Sets the value of thetickLength
property.final void
setTickMarkVisible
(boolean value) Sets the value of thetickMarkVisible
property.protected final boolean
This is used to check if any given animation should run.final ObjectProperty
<Side> The side of the plot which this axis is being drawn onfinal ObjectProperty
<Paint> The fill for all tick labelsfinal ObjectProperty
<Font> The font for all tick labelsfinal DoubleProperty
The gap between tick labels and the tick mark linesfinal DoubleProperty
Rotation in degrees of tick mark labels from their normal horizontal.final BooleanProperty
true if tick mark labels should be displayedfinal DoubleProperty
The length of tick mark linesprotected void
Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to in reaction.final BooleanProperty
true if tick marks should be displayedabstract double
toNumericValue
(T value) All axis values must be representable by some numeric value.abstract T
toRealValue
(double value) All axis values must be representable by some numeric value.Methods declared in class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, getBackground, getBorder, 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 declared in class javafx.scene.Parent
getBaselineOffset, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, needsLayoutProperty, requestParentLayout, setNeedsLayout, updateBounds
Methods declared in 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, lookup, 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, queryAccessibleAttribute, relocate, removeEventFilter, removeEventHandler, requestFocus, requestFocusTraversal, 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 declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods declared in interface javafx.css.Styleable
getStyleableNode
-
Property Details
-
side
The side of the plot which this axis is being drawn on- See Also:
-
label
-
tickMarkVisible
true if tick marks should be displayed- See Also:
-
tickLabelsVisible
true if tick mark labels should be displayed- See Also:
-
tickLength
-
autoRanging
This is true when the axis determines its range from the data automatically- See Also:
-
tickLabelFont
-
tickLabelFill
-
tickLabelGap
The gap between tick labels and the tick mark lines- See Also:
-
animated
When true any changes to the axis and its range will be animated.- See Also:
-
tickLabelRotation
Rotation in degrees of tick mark labels from their normal horizontal.- See Also:
-
-
Constructor Details
-
Axis
public Axis()Creates and initializes a new instance of the Axis class.
-
-
Method Details
-
getTickMarks
Unmodifiable observable list of tickmarks, each TickMark directly representing a tickmark on this axis. This is updated whenever the displayed tickmarks changes.- Returns:
- Unmodifiable observable list of TickMarks on this axis
-
getSide
Gets the value of theside
property.- Property description:
- The side of the plot which this axis is being drawn on
- Returns:
- the value of the
side
property - See Also:
-
setSide
Sets the value of theside
property.- Property description:
- The side of the plot which this axis is being drawn on
- Parameters:
value
- the value for theside
property- See Also:
-
sideProperty
The side of the plot which this axis is being drawn on- Returns:
- the
side
property - See Also:
-
getLabel
Gets the value of thelabel
property.- Property description:
- The axis label
- Returns:
- the value of the
label
property - See Also:
-
setLabel
Sets the value of thelabel
property.- Property description:
- The axis label
- Parameters:
value
- the value for thelabel
property- See Also:
-
labelProperty
The axis label- Returns:
- the
label
property - See Also:
-
isTickMarkVisible
public final boolean isTickMarkVisible()Gets the value of thetickMarkVisible
property.- Property description:
- true if tick marks should be displayed
- Returns:
- the value of the
tickMarkVisible
property - See Also:
-
setTickMarkVisible
public final void setTickMarkVisible(boolean value) Sets the value of thetickMarkVisible
property.- Property description:
- true if tick marks should be displayed
- Parameters:
value
- the value for thetickMarkVisible
property- See Also:
-
tickMarkVisibleProperty
true if tick marks should be displayed- Returns:
- the
tickMarkVisible
property - See Also:
-
isTickLabelsVisible
public final boolean isTickLabelsVisible()Gets the value of thetickLabelsVisible
property.- Property description:
- true if tick mark labels should be displayed
- Returns:
- the value of the
tickLabelsVisible
property - See Also:
-
setTickLabelsVisible
public final void setTickLabelsVisible(boolean value) Sets the value of thetickLabelsVisible
property.- Property description:
- true if tick mark labels should be displayed
- Parameters:
value
- the value for thetickLabelsVisible
property- See Also:
-
tickLabelsVisibleProperty
true if tick mark labels should be displayed- Returns:
- the
tickLabelsVisible
property - See Also:
-
getTickLength
public final double getTickLength()Gets the value of thetickLength
property.- Property description:
- The length of tick mark lines
- Returns:
- the value of the
tickLength
property - See Also:
-
setTickLength
public final void setTickLength(double value) Sets the value of thetickLength
property.- Property description:
- The length of tick mark lines
- Parameters:
value
- the value for thetickLength
property- See Also:
-
tickLengthProperty
The length of tick mark lines- Returns:
- the
tickLength
property - See Also:
-
isAutoRanging
public final boolean isAutoRanging()Gets the value of theautoRanging
property.- Property description:
- This is true when the axis determines its range from the data automatically
- Returns:
- the value of the
autoRanging
property - See Also:
-
setAutoRanging
public final void setAutoRanging(boolean value) Sets the value of theautoRanging
property.- Property description:
- This is true when the axis determines its range from the data automatically
- Parameters:
value
- the value for theautoRanging
property- See Also:
-
autoRangingProperty
This is true when the axis determines its range from the data automatically- Returns:
- the
autoRanging
property - See Also:
-
getTickLabelFont
Gets the value of thetickLabelFont
property.- Property description:
- The font for all tick labels
- Returns:
- the value of the
tickLabelFont
property - See Also:
-
setTickLabelFont
Sets the value of thetickLabelFont
property.- Property description:
- The font for all tick labels
- Parameters:
value
- the value for thetickLabelFont
property- See Also:
-
tickLabelFontProperty
The font for all tick labels- Returns:
- the
tickLabelFont
property - See Also:
-
getTickLabelFill
Gets the value of thetickLabelFill
property.- Property description:
- The fill for all tick labels
- Returns:
- the value of the
tickLabelFill
property - See Also:
-
setTickLabelFill
Sets the value of thetickLabelFill
property.- Property description:
- The fill for all tick labels
- Parameters:
value
- the value for thetickLabelFill
property- See Also:
-