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.
Type | Property and Description |
---|---|
BooleanProperty |
animated
When true any changes to the axis and its range will be animated.
|
BooleanProperty |
autoRanging
This is true when the axis determines its range from the data automatically
|
<any> |
label
The axis label
|
<any> |
side
The side of the plot which this axis is being drawn on
|
<any> |
tickLabelFill
The fill for all tick labels
|
<any> |
tickLabelFont
The font for all tick labels
|
DoubleProperty |
tickLabelGap
The gap between tick labels and the tick mark lines
|
DoubleProperty |
tickLabelRotation
Rotation in degrees of tick mark labels from their normal horizontal.
|
BooleanProperty |
tickLabelsVisible
true if tick mark labels should be displayed
|
DoubleProperty |
tickLength
The length of tick mark lines
|
BooleanProperty |
tickMarkVisible
true if tick marks should be displayed
|
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 <any> |
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 <any> |
side
The side of the plot which this axis is being drawn on
|
private <any> |
tickLabelFill
The fill for all tick labels
|
private <any> |
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 <any> |
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 <any> |
unmodifiableTickMarks |
Constructor and Description |
---|
Axis()
Creates and initializes a new instance of the Axis class.
|
Modifier and Type | Method and Description |
---|---|
BooleanProperty |
animatedProperty()
When true any changes to the axis and its range will be animated.
|
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()
This is true when the axis determines its range from the data automatically
|
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<<any>> |
getClassCssMetaData() |
java.util.List<<any>> |
getCssMetaData() |
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()
Gets the value of the property label.
|
protected abstract java.lang.Object |
getRange()
Called to get the current axis range.
|
Side |
getSide()
Gets the value of the property side.
|
Paint |
getTickLabelFill()
Gets the value of the property tickLabelFill.
|
Font |
getTickLabelFont()
Gets the value of the property tickLabelFont.
|
double |
getTickLabelGap()
Gets the value of the property tickLabelGap.
|
double |
getTickLabelRotation()
Gets the value of the property tickLabelRotation.
|
double |
getTickLength()
Gets the value of the property tickLength.
|
protected abstract java.lang.String |
getTickMarkLabel(T value)
Get the string label name for a tick mark with the given value
|
<any> |
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()
Gets the value of the property autoRanging.
|
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()
Gets the value of the property tickLabelsVisible.
|
boolean |
isTickMarkVisible()
Gets the value of the property tickMarkVisible.
|
abstract boolean |
isValueOnAxis(T value)
Checks if the given value is plottable on this axis
|
<any> |
labelProperty()
The axis label
|
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)
Sets the value of the property animated.
|
void |
setAutoRanging(boolean value)
Sets the value of the property autoRanging.
|
(package private) void |
setEffectiveOrientation(Orientation orientation) |
(package private) void |
setEffectiveTickLabelRotation(double rotation) |
void |
setLabel(java.lang.String value)
Sets the value of the property label.
|
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)
Sets the value of the property side.
|
void |
setTickLabelFill(Paint value)
Sets the value of the property tickLabelFill.
|
void |
setTickLabelFont(Font value)
Sets the value of the property tickLabelFont.
|
void |
setTickLabelGap(double value)
Sets the value of the property tickLabelGap.
|
void |
setTickLabelRotation(double value)
Sets the value of the property tickLabelRotation.
|
void |
setTickLabelsVisible(boolean value)
Sets the value of the property tickLabelsVisible.
|
void |
setTickLength(double value)
Sets the value of the property tickLength.
|
void |
setTickMarkVisible(boolean value)
Sets the value of the property tickMarkVisible.
|
protected boolean |
shouldAnimate()
This is used to check if any given animation should run.
|
<any> |
sideProperty()
The side of the plot which this axis is being drawn on
|
<any> |
tickLabelFillProperty()
The fill for all tick labels
|
<any> |
tickLabelFontProperty()
The font for all tick labels
|
DoubleProperty |
tickLabelGapProperty()
The gap between tick labels and the tick mark lines
|
DoubleProperty |
tickLabelRotationProperty()
Rotation in degrees of tick mark labels from their normal horizontal.
|
BooleanProperty |
tickLabelsVisibleProperty()
true if tick mark labels should be displayed
|
DoubleProperty |
tickLengthProperty()
The length of tick mark lines
|
protected void |
tickMarksUpdated()
Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to
in reaction.
|
BooleanProperty |
tickMarkVisibleProperty()
true if tick marks should be displayed
|
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
|
private void |
updateTickMarks(Side side,
double length) |
public final <any> sideProperty
getSide()
,
setSide(Side)
public final <any> labelProperty
getLabel()
,
setLabel(String)
public final BooleanProperty tickMarkVisibleProperty
isTickMarkVisible()
,
setTickMarkVisible(boolean)
public final BooleanProperty tickLabelsVisibleProperty
public final DoubleProperty tickLengthProperty
getTickLength()
,
setTickLength(double)
public final BooleanProperty autoRangingProperty
isAutoRanging()
,
setAutoRanging(boolean)
public final <any> tickLabelFontProperty
getTickLabelFont()
,
setTickLabelFont(Font)
public final <any> tickLabelFillProperty
getTickLabelFill()
,
setTickLabelFill(Paint)
public final DoubleProperty tickLabelGapProperty
getTickLabelGap()
,
setTickLabelGap(double)
public final BooleanProperty animatedProperty
getAnimated()
,
setAnimated(boolean)
public final DoubleProperty tickLabelRotationProperty
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 <any> tickMarks
private final <any> unmodifiableTickMarks
private <any> side
private <any> label
private BooleanProperty tickMarkVisible
private BooleanProperty tickLabelsVisible
private DoubleProperty tickLength
private BooleanProperty autoRanging
private <any> tickLabelFont
private <any> 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 <any> getTickMarks()
public final Side getSide()
public final void setSide(Side value)
public final <any> sideProperty()
getSide()
,
setSide(Side)
final void setEffectiveOrientation(Orientation orientation)
final Side getEffectiveSide()
public final java.lang.String getLabel()
public final void setLabel(java.lang.String value)
public final <any> labelProperty()
getLabel()
,
setLabel(String)
public final boolean isTickMarkVisible()
public final void setTickMarkVisible(boolean value)
public final BooleanProperty tickMarkVisibleProperty()
isTickMarkVisible()
,
setTickMarkVisible(boolean)
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()
getTickLength()
,
setTickLength(double)
public final boolean isAutoRanging()
public final void setAutoRanging(boolean value)
public final BooleanProperty autoRangingProperty()
isAutoRanging()
,
setAutoRanging(boolean)
public final Font getTickLabelFont()
public final void setTickLabelFont(Font value)
public final <any> tickLabelFontProperty()
getTickLabelFont()
,
setTickLabelFont(Font)
public final Paint getTickLabelFill()
public final void setTickLabelFill(Paint value)
public final <any> tickLabelFillProperty()
getTickLabelFill()
,
setTickLabelFill(Paint)
public final double getTickLabelGap()
public final void setTickLabelGap(double value)
public final DoubleProperty tickLabelGapProperty()
getTickLabelGap()
,
setTickLabelGap(double)
public final boolean getAnimated()
public final void setAnimated(boolean value)
public final BooleanProperty animatedProperty()
getAnimated()
,
setAnimated(boolean)
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()
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)
protected double computePrefWidth(double height)
protected void tickMarksUpdated()
protected void layoutChildren()
private void updateTickMarks(Side side, double length)
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<<any>> getClassCssMetaData()
public java.util.List<<any>> getCssMetaData()