public abstract class Axis<T> extends Region
Some examples of concrete subclasses include NumberAxis
whose axis plots data
in numbers and CategoryAxis
whose values / ticks represent string
categories along its axis.
Modifier and Type | Class and Description |
---|---|
private static class |
Axis.StyleableProperties |
static class |
Axis.TickMark<T>
TickMark represents the label text, its associated properties for each tick
along the Axis.
|
Modifier and Type | Field and Description |
---|---|
private BooleanProperty |
animated
When true any changes to the axis and its range will be animated.
|
private BooleanProperty |
autoRanging
This is true when the axis determines its range from the data automatically
|
private Label |
axisLabel |
private static PseudoClass |
BOTTOM_PSEUDOCLASS_STATE
pseudo-class indicating this is a vertical Bottom side Axis.
|
private Orientation |
effectiveOrientation |
private double |
effectiveTickLabelRotation |
private ObjectProperty<java.lang.String> |
label
The axis label
|
private java.util.BitSet |
labelsToSkip |
private static PseudoClass |
LEFT_PSEUDOCLASS_STATE
pseudo-class indicating this is a vertical Left side Axis.
|
(package private) Text |
measure |
(package private) boolean |
measureInvalid |
private double |
oldLength |
(package private) boolean |
rangeValid
True when the current range invalid and all dependent calculations need to be updated
|
private static PseudoClass |
RIGHT_PSEUDOCLASS_STATE
pseudo-class indicating this is a vertical Right side Axis.
|
private ObjectProperty<Side> |
side
The side of the plot which this axis is being drawn on
|
private ObjectProperty<Paint> |
tickLabelFill
The fill for all tick labels
|
private ObjectProperty<Font> |
tickLabelFont
The font for all tick labels
|
private DoubleProperty |
tickLabelGap
The gap between tick labels and the tick mark lines
|
private DoubleProperty |
tickLabelRotation
Rotation in degrees of tick mark labels from their normal horizontal.
|
private BooleanProperty |
tickLabelsVisible
true if tick mark labels should be displayed
|
(package private) boolean |
tickLabelsVisibleInvalid |
private DoubleProperty |
tickLength
The length of tick mark lines
|
private Path |
tickMarkPath |
private ObservableList<Axis.TickMark<T>> |
tickMarks |
private BooleanProperty |
tickMarkVisible
true if tick marks should be displayed
|
private static PseudoClass |
TOP_PSEUDOCLASS_STATE
pseudo-class indicating this is a vertical Top side Axis.
|
private ObservableList<Axis.TickMark<T>> |
unmodifiableTickMarks |
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Constructor and Description |
---|
Axis()
Creates and initializes a new instance of the Axis class.
|
Modifier and Type | Method and Description |
---|---|
BooleanProperty |
animatedProperty() |
protected abstract java.lang.Object |
autoRange(double length)
This calculates the upper and lower bound based on the data provided to invalidateRange() method.
|
BooleanProperty |
autoRangingProperty() |
protected abstract java.util.List<T> |
calculateTickValues(double length,
java.lang.Object range)
Calculate a list of all the data values for each tick mark in range
|
protected 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.
|
boolean |
getAnimated()
Indicates whether the changes to axis range will be animated or not.
|
static java.util.List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
java.util.List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
This method should delegate to
Node.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.
|
(package private) Side |
getEffectiveSide() |
(package private) double |
getEffectiveTickLabelRotation() |
java.lang.String |
getLabel() |
protected abstract java.lang.Object |
getRange()
Called to get the current axis range.
|
Side |
getSide() |
Paint |
getTickLabelFill() |
Font |
getTickLabelFont() |
double |
getTickLabelGap() |
double |
getTickLabelRotation() |
double |
getTickLength() |
protected abstract java.lang.String |
getTickMarkLabel(T value)
Get the string label name for a tick mark with the given value
|
ObservableList<Axis.TickMark<T>> |
getTickMarks()
Unmodifiable 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 |
getZeroPosition()
Get the display position of the zero line along this axis.
|
protected void |
invalidateRange()
Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the
next layout.
|
void |
invalidateRange(java.util.List<T> data)
Called when data has changed and the range may not be valid any more.
|
boolean |
isAutoRanging() |
protected boolean |
isRangeValid()
See if the current range is valid, if it is not then any range dependent calulcations need to redone on the next layout pass
|
private boolean |
isTickLabelsOverlap(Side side,
Axis.TickMark<T> m1,
Axis.TickMark<T> m2,
double gap)
Checks if two consecutive tick mark labels overlaps.
|
boolean |
isTickLabelsVisible() |
boolean |
isTickMarkVisible() |
abstract boolean |
isValueOnAxis(T value)
Checks if the given value is plottable on this axis
|
ObjectProperty<java.lang.String> |
labelProperty() |
protected void |
layoutChildren()
Invoked during the layout pass to layout this axis and all its content.
|
protected Dimension2D |
measureTickMarkLabelSize(java.lang.String labelText,
double rotation)
Measure the size of the label for given tick mark value.
|
protected Dimension2D |
measureTickMarkSize(T value,
double rotation)
Measure the size of the label for given tick mark value.
|
protected Dimension2D |
measureTickMarkSize(T value,
java.lang.Object range)
Measure the size of the label for given tick mark value.
|
private double |
measureTickMarkSize(T value,
Side side)
Measure the size of the label for given tick mark value.
|
private void |
positionTextNode(Text node,
double posX,
double posY,
double angle,
Side side)
Positions a text node to one side of the given point, it X height is vertically centered on point if LEFT or
RIGHT and its centered horizontally if TOP ot BOTTOM.
|
void |
requestAxisLayout()
Request that the axis is laid out in the next layout pass.
|
void |
requestLayout()
We suppress requestLayout() calls here by doing nothing as we don't want changes to our children to cause
layout.
|
void |
setAnimated(boolean value) |
void |
setAutoRanging(boolean value) |
(package private) void |
setEffectiveOrientation(Orientation orientation) |
(package private) void |
setEffectiveTickLabelRotation(double rotation) |
void |
setLabel(java.lang.String value) |
protected abstract void |
setRange(java.lang.Object range,
boolean animate)
Called to set the current axis range to the given range.
|
void |
setSide(Side value) |
void |
setTickLabelFill(Paint value) |
void |
setTickLabelFont(Font value) |
void |
setTickLabelGap(double value) |
void |
setTickLabelRotation(double value) |
void |
setTickLabelsVisible(boolean value) |
void |
setTickLength(double value) |
void |
setTickMarkVisible(boolean value) |
protected boolean |
shouldAnimate()
This is used to check if any given animation should run.
|
ObjectProperty<Side> |
sideProperty() |
ObjectProperty<Paint> |
tickLabelFillProperty() |
ObjectProperty<Font> |
tickLabelFontProperty() |
DoubleProperty |
tickLabelGapProperty() |
DoubleProperty |
tickLabelRotationProperty() |
BooleanProperty |
tickLabelsVisibleProperty() |
DoubleProperty |
tickLengthProperty() |
protected void |
tickMarksUpdated()
Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to
in reaction.
|
BooleanProperty |
tickMarkVisibleProperty() |
abstract 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.
|
private void |
updateTickMark(Axis.TickMark<T> tick,
double length,
double startX,
double startY,
double endX,
double endY)
Updates visibility of the text node and adds the tick mark to the path
|
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, 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, snapSize, snapSpace, snapToPixelProperty, widthProperty
getBaselineOffset, getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processCSS, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, 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_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_cssGetFocusTraversableInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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, 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, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
Text measure
private Orientation effectiveOrientation
private double effectiveTickLabelRotation
private Label axisLabel
private final Path tickMarkPath
private double oldLength
boolean rangeValid
boolean measureInvalid
boolean tickLabelsVisibleInvalid
private java.util.BitSet labelsToSkip
private final ObservableList<Axis.TickMark<T>> tickMarks
private final ObservableList<Axis.TickMark<T>> unmodifiableTickMarks
private ObjectProperty<Side> side
private ObjectProperty<java.lang.String> label
private BooleanProperty tickMarkVisible
private BooleanProperty tickLabelsVisible
private DoubleProperty tickLength
private BooleanProperty autoRanging
private ObjectProperty<Font> tickLabelFont
private ObjectProperty<Paint> tickLabelFill
private DoubleProperty tickLabelGap
private BooleanProperty animated
private DoubleProperty tickLabelRotation
private static final PseudoClass TOP_PSEUDOCLASS_STATE
private static final PseudoClass BOTTOM_PSEUDOCLASS_STATE
private static final PseudoClass LEFT_PSEUDOCLASS_STATE
private static final PseudoClass RIGHT_PSEUDOCLASS_STATE
public ObservableList<Axis.TickMark<T>> getTickMarks()
public final Side getSide()
public final void setSide(Side value)
public final ObjectProperty<Side> sideProperty()
final void setEffectiveOrientation(Orientation orientation)
final Side getEffectiveSide()
public final java.lang.String getLabel()
public final void setLabel(java.lang.String value)
public final ObjectProperty<java.lang.String> labelProperty()
public final boolean isTickMarkVisible()
public final void setTickMarkVisible(boolean value)
public final BooleanProperty tickMarkVisibleProperty()
public final boolean isTickLabelsVisible()
public final void setTickLabelsVisible(boolean value)
public final BooleanProperty tickLabelsVisibleProperty()
public final double getTickLength()
public final void setTickLength(double value)
public final DoubleProperty tickLengthProperty()
public final boolean isAutoRanging()
public final void setAutoRanging(boolean value)
public final BooleanProperty autoRangingProperty()
public final Font getTickLabelFont()
public final void setTickLabelFont(Font value)
public final ObjectProperty<Font> tickLabelFontProperty()
public final Paint getTickLabelFill()
public final void setTickLabelFill(Paint value)
public final ObjectProperty<Paint> tickLabelFillProperty()
public final double getTickLabelGap()
public final void setTickLabelGap(double value)
public final DoubleProperty tickLabelGapProperty()
public final boolean getAnimated()
public final void setAnimated(boolean value)
public final BooleanProperty animatedProperty()
public final double getTickLabelRotation()
public final void setTickLabelRotation(double value)
public final DoubleProperty tickLabelRotationProperty()
protected final boolean isRangeValid()
protected final void invalidateRange()
protected final boolean shouldAnimate()
public void requestLayout()
requestLayout
in class Parent
public void requestAxisLayout()
public void invalidateRange(java.util.List<T> data)
data
- The current set of all data that needs to be plotted on this axisprotected abstract java.lang.Object autoRange(double length)
length
- The length of the axis in screen coordinatesprotected abstract void setRange(java.lang.Object range, boolean animate)
range
- A range object returned from autoRange()animate
- If true animate the change in rangeprotected abstract java.lang.Object getRange()
public abstract double getZeroPosition()
public abstract double getDisplayPosition(T value)
value
- The data value to work out display position forpublic abstract T getValueForDisplay(double displayPosition)
displayPosition
- A pixel position on this axispublic abstract boolean isValueOnAxis(T value)
value
- The value to check if its on axispublic abstract double toNumericValue(T value)
value
- The data value to convertpublic abstract T toRealValue(double value)
value
- The numeric value to convertprotected abstract java.util.List<T> calculateTickValues(double length, java.lang.Object range)
length
- The length of the axis in display unitsrange
- A range object returned from autoRange()protected double computePrefHeight(double width)
computePrefHeight
in class Region
width
- the width that should be used if preferred height depends
on itprotected double computePrefWidth(double height)
computePrefWidth
in class Region
height
- the height that should be used if preferred width depends
on itprotected void tickMarksUpdated()
protected void layoutChildren()
layoutChildren
in class Parent
private boolean isTickLabelsOverlap(Side side, Axis.TickMark<T> m1, Axis.TickMark<T> m2, double gap)
side
- side of the Axism1
- first tick markm2
- second tick markgap
- minimum space between labelsprivate void positionTextNode(Text node, double posX, double posY, double angle, Side side)
node
- The text node to positionposX
- The x position, to place text next toposY
- The y position, to place text next toangle
- The text rotationside
- The side to place text next to position x,y atprivate void updateTickMark(Axis.TickMark<T> tick, double length, double startX, double startY, double endX, double endY)
protected abstract java.lang.String getTickMarkLabel(T value)
value
- The value to format into a tick label stringprotected final Dimension2D measureTickMarkLabelSize(java.lang.String labelText, double rotation)
labelText
- tick mark label textrotation
- The text rotationprotected final Dimension2D measureTickMarkSize(T value, double rotation)
value
- tick mark valuerotation
- The text rotationprotected Dimension2D measureTickMarkSize(T value, java.lang.Object range)
value
- tick mark valuerange
- range to use during calculationsprivate double measureTickMarkSize(T value, Side side)
value
- tick mark valueside
- side of this AxismeasureTickMarkSize(Object, Object)
final double getEffectiveTickLabelRotation()
final void setEffectiveTickLabelRotation(double rotation)
rotation
- NaN for using the tickLabelRotationProperty()public static java.util.List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public java.util.List<CssMetaData<? extends Styleable,?>> getCssMetaData()
Node.getClassCssMetaData()
so that
a Node's CssMetaData can be accessed without the need for reflection.getCssMetaData
in interface Styleable
getCssMetaData
in class Region