Class NumberAxis

All Implemented Interfaces:
Styleable, EventTarget

public final class NumberAxis extends ValueAxis<Number>
An axis class that plots a range of numbers with major tick marks every tickUnit. You can use any Number type with this axis.
Since:
JavaFX 2.0
  • Property Details

  • Constructor Details

    • NumberAxis

      public NumberAxis()
      Creates an auto-ranging NumberAxis.
    • NumberAxis

      public NumberAxis(double lowerBound, double upperBound, double tickUnit)
      Creates a non-auto-ranging NumberAxis with the given upper bound, lower bound and tick unit.
      Parameters:
      lowerBound - The lower bound for this axis, i.e. min plottable value
      upperBound - The upper bound for this axis, i.e. max plottable value
      tickUnit - The tick unit, i.e. space between tickmarks
    • NumberAxis

      public NumberAxis(String axisLabel, double lowerBound, double upperBound, double tickUnit)
      Creates a non-auto-ranging NumberAxis with the given lower bound, upper bound and tick unit.
      Parameters:
      axisLabel - The name to display for this axis
      lowerBound - The lower bound for this axis, i.e. min plottable value
      upperBound - The upper bound for this axis, i.e. max plottable value
      tickUnit - The tick unit, i.e. space between tickmarks
  • Method Details

    • isForceZeroInRange

      public final boolean isForceZeroInRange()
      Gets the value of the property forceZeroInRange.
      Property description:
      When true zero is always included in the visible range. This only has effect if auto-ranging is on.
    • setForceZeroInRange

      public final void setForceZeroInRange(boolean value)
      Sets the value of the property forceZeroInRange.
      Property description:
      When true zero is always included in the visible range. This only has effect if auto-ranging is on.
    • forceZeroInRangeProperty

      public final BooleanProperty forceZeroInRangeProperty()
      When true zero is always included in the visible range. This only has effect if auto-ranging is on.
      See Also:
    • getTickUnit

      public final double getTickUnit()
      Gets the value of the property tickUnit.
      Property description:
      The value between each major tick mark in data units. This is automatically set if we are auto-ranging.
    • setTickUnit

      public final void setTickUnit(double value)
      Sets the value of the property tickUnit.
      Property description:
      The value between each major tick mark in data units. This is automatically set if we are auto-ranging.
    • tickUnitProperty

      public final DoubleProperty tickUnitProperty()
      The value between each major tick mark in data units. This is automatically set if we are auto-ranging.
      See Also:
    • getTickMarkLabel

      protected String getTickMarkLabel(Number value)
      Get the string label name for a tick mark with the given value.
      Specified by:
      getTickMarkLabel in class Axis<Number>
      Parameters:
      value - The value to format into a tick label string
      Returns:
      A formatted string for the given value
    • getRange

      protected Object getRange()
      Called to get the current axis range.
      Specified by:
      getRange in class Axis<Number>
      Returns:
      A range object that can be passed to setRange() and calculateTickValues()
    • setRange

      protected void setRange(Object range, boolean animate)
      Called to set the current axis range to the given range. If isAnimating() is true then this method should animate the range to the new range.
      Specified by:
      setRange in class Axis<Number>
      Parameters:
      range - A range object returned from autoRange()
      animate - If true animate the change in range
    • calculateTickValues

      protected List<Number> calculateTickValues(double length, Object range)
      Calculates a list of all the data values for each tick mark in range
      Specified by:
      calculateTickValues in class Axis<Number>
      Parameters:
      length - The length of the axis in display units
      range - A range object returned from autoRange()
      Returns:
      A list of tick marks that fit along the axis if it was the given length
    • calculateMinorTickMarks

      protected List<Number> calculateMinorTickMarks()
      Calculates a list of the data values for every minor tick mark
      Specified by:
      calculateMinorTickMarks in class ValueAxis<Number>
      Returns:
      List of data values where to draw minor tick marks
    • measureTickMarkSize

      protected Dimension2D measureTickMarkSize(Number value, Object range)
      Measures the size of the label for a given tick mark value. This uses the font that is set for the tick marks.
      Overrides:
      measureTickMarkSize in class Axis<Number>
      Parameters:
      value - tick mark value
      range - range to use during calculations
      Returns:
      size of tick mark label for given value
    • autoRange

      protected Object autoRange(double minValue, double maxValue, double length, double labelSize)
      Called to set the upper and lower bound and anything else that needs to be auto-ranged.
      Overrides:
      autoRange in class ValueAxis<Number>
      Parameters:
      minValue - The min data value that needs to be plotted on this axis
      maxValue - The max data value that needs to be plotted on this axis
      length - The length of the axis in display coordinates
      labelSize - The approximate average size a label takes along the axis
      Returns:
      The calculated range
    • getClassCssMetaData

      public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
      Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
      Returns:
      the CssMetaData
      Since:
      JavaFX 8.0
    • getCssMetaData

      public 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.
      Specified by:
      getCssMetaData in interface Styleable
      Overrides:
      getCssMetaData in class ValueAxis<Number>
      Returns:
      The CssMetaData associated with this node, which may include the CssMetaData of its superclasses.
      Since:
      JavaFX 8.0