Class NumericAxis

  • All Implemented Interfaces:
    Axis, de.gsi.dataset.AxisDescription, de.gsi.dataset.event.EventSource, java.io.Serializable, javafx.css.Styleable, javafx.event.EventTarget

    public final class NumericAxis
    extends AbstractAxis
    A axis class that plots a range of numbers with major tick marks every "tickUnit". You can use any Number type with this axis, Long, Double, BigDecimal etc.

    Compared to the NumberAxis, this one has a few additional features:

    See Also:
    Serialized Form
    • Constructor Detail

      • NumericAxis

        public NumericAxis()
        Creates an auto-ranging Axis.
      • NumericAxis

        public NumericAxis​(double lowerBound,
                           double upperBound,
                           double tickUnit)
        Creates a non-auto-ranging Axis with the given upper bound, lower bound and tick unit.
        Parameters:
        lowerBound - the lower bound of the axis
        upperBound - the upper bound of the axis
        tickUnit - the tick unit, i.e. space between tick marks
      • NumericAxis

        public NumericAxis​(java.lang.String axisLabel,
                           double lowerBound,
                           double upperBound,
                           double tickUnit)
        Create a non-auto-ranging Axis with the given upper bound, lower bound and tick unit.
        Parameters:
        axisLabel - the axis label
        lowerBound - the lower bound of the axis
        upperBound - the upper bound of the axis
        tickUnit - the tick unit, i.e. space between tick marks
    • Method Detail

      • autoRangePaddingProperty

        public javafx.beans.property.DoubleProperty autoRangePaddingProperty()
        Fraction of the range to be applied as padding on both sides of the axis range. E.g. if set to 0.1 (10%) on axis with data range [10, 20], the new automatically calculated range will be [9, 21].
        Overrides:
        autoRangePaddingProperty in class AbstractAxisParameter
        Returns:
        autoRangePadding property
      • computePreferredTickUnit

        public double computePreferredTickUnit​(double axisLength)
        Computes the preferred tick unit based on the upper/lower bounds and the length of the axis in screen coordinates.
        Specified by:
        computePreferredTickUnit in class AbstractAxis
        Parameters:
        axisLength - the length in screen coordinates
        Returns:
        the tick unit
      • forceZeroInRangeProperty

        public javafx.beans.property.BooleanProperty forceZeroInRangeProperty()
        When true zero is always included in the visible range. This only has effect if auto-ranging is on.
        Returns:
        forceZeroInRange property
      • getCssMetaData

        public java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaData()
        Specified by:
        getCssMetaData in interface javafx.css.Styleable
        Overrides:
        getCssMetaData in class AbstractAxisParameter
      • getDisplayPosition

        public double getDisplayPosition​(double value)
        Get the display position along this axis for a given value. If the value is not in the current range, the returned value will be an extrapolation of the display position. -- cached double optimised version (shaves of 50% on delays)
        Specified by:
        getDisplayPosition in interface Axis
        Overrides:
        getDisplayPosition in class AbstractAxis
        Parameters:
        value - The data value to work out display position for
        Returns:
        display position
      • getLogAxisType

        public LogAxisType getLogAxisType()
        Returns:
        given linear and/or logarithmic (+ sub-type, e.g. log10, dB20, ...) axis types
      • getValueForDisplay

        public double getValueForDisplay​(double displayPosition)
        Get the data value for the given display position on this axis. If the axis is a CategoryAxis this will be the nearest value. -- cached double optimised version (shaves of 50% on delays)
        Parameters:
        displayPosition - A pixel position on this axis
        Returns:
        the nearest data value to the given pixel position or null if not on axis;
      • getZeroPosition

        public double getZeroPosition()
        Get the display position of the zero line along this axis.
        Specified by:
        getZeroPosition in interface Axis
        Overrides:
        getZeroPosition in class AbstractAxis
        Returns:
        display position or Double.NaN if zero is not in current range;
      • isForceZeroInRange

        public boolean isForceZeroInRange()
        Returns the value of the forceZeroInRangeProperty().
        Returns:
        value of the forceZeroInRange property
      • isLogAxis

        public boolean isLogAxis()
        Description copied from interface: Axis
        This is true when the axis implements a log scale
        Returns:
        true if axis is log scale
      • isValueOnAxis

        public boolean isValueOnAxis​(double value)
        Checks if the given value is plottable on this axis
        Specified by:
        isValueOnAxis in interface Axis
        Overrides:
        isValueOnAxis in class AbstractAxis
        Parameters:
        value - The value to check if its on axis
        Returns:
        true if the given value is plottable on this axis
      • setForceZeroInRange

        public void setForceZeroInRange​(boolean value)
        Sets the value of the forceZeroInRangeProperty().
        Parameters:
        value - if true, zero is always included in the visible range
      • setTickUnitSupplier

        public void setTickUnitSupplier​(TickUnitSupplier supplier)
        Sets the value of the tickUnitSupplierProperty().
        Parameters:
        supplier - the tick unit supplier. If null, the default one will be used
      • tickUnitProperty

        public javafx.beans.property.DoubleProperty tickUnitProperty()
        The value between each major tick mark in data units. This is automatically set if we are auto-ranging.
        Specified by:
        tickUnitProperty in interface Axis
        Overrides:
        tickUnitProperty in class AbstractAxisParameter
        Returns:
        tickUnit property
      • tickUnitSupplierProperty

        public javafx.beans.property.ObjectProperty<TickUnitSupplier> tickUnitSupplierProperty()
        Strategy to compute major tick unit when auto-range is on or when axis bounds change. By default initialized to DefaultTickUnitSupplier.

        See TickUnitSupplier for more information about the expected behavior of the strategy.

        Returns:
        tickUnitSupplier property
      • autoRange

        protected AxisRange autoRange​(double minValue,
                                      double maxValue,
                                      double length,
                                      double labelSize)
        Overrides:
        autoRange in class AbstractAxis
      • calculateMajorTickValues

        protected java.util.List<java.lang.Double> calculateMajorTickValues​(double axisLength,
                                                                            AxisRange range)
        Description copied from class: AbstractAxis
        Calculate a list of all the data values for each tick mark in range
        Specified by:
        calculateMajorTickValues in class AbstractAxis
        Parameters:
        axisLength - 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
      • calculateMinorTickValues

        protected java.util.List<java.lang.Double> calculateMinorTickValues()
        Description copied from class: AbstractAxis
        Calculate a list of the data values for every minor tick mark
        Specified by:
        calculateMinorTickValues in class AbstractAxis
        Returns:
        List of data values where to draw minor tick marks
      • getClassCssMetaData

        public static java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getClassCssMetaData()