Class AbstractAxis

    • Field Detail

      • RANGE_ANIMATION_DURATION_MS

        protected static final int RANGE_ANIMATION_DURATION_MS
        See Also:
        Constant Field Values
      • tickMarkSizeCache

        protected java.util.WeakHashMap<java.lang.Number,​javafx.geometry.Dimension2D> tickMarkSizeCache
      • animator

        protected final javafx.animation.Timeline animator
      • labelOverlap

        protected boolean labelOverlap
      • cachedOffset

        protected double cachedOffset
      • listeners

        protected final java.util.List<javafx.beans.InvalidationListener> listeners
      • lock

        protected final java.util.concurrent.locks.ReentrantLock lock
      • autoNotification

        protected boolean autoNotification
      • maxLabelHeight

        protected double maxLabelHeight
      • maxLabelWidth

        protected double maxLabelWidth
      • currentLowerBound

        protected final javafx.beans.property.DoubleProperty currentLowerBound
        The current value for the lowerBound of this axis, ie min value. This may be the same as lowerBound or different. It is used by NumberAxis to animate the lowerBound from the old value to the new value.
      • tickMarkStringCache

        protected java.util.WeakHashMap<java.lang.String,​TickMark> tickMarkStringCache
      • tickMarkDoubleCache

        protected java.util.WeakHashMap<java.lang.Double,​TickMark> tickMarkDoubleCache
    • Constructor Detail

      • AbstractAxis

        public AbstractAxis()
      • AbstractAxis

        public AbstractAxis​(double lowerBound,
                            double upperBound)
    • Method Detail

      • axisLabelFormatterProperty

        public javafx.beans.property.ObjectProperty<AxisLabelFormatter> axisLabelFormatterProperty()
      • computeRange

        protected abstract AxisRange computeRange​(double minValue,
                                                  double maxValue,
                                                  double axisLength,
                                                  double labelSize)
        Computes range of this axis, similarly to autoRange(double, double, double, double). The major difference is that this method is called when auto-range is off.
        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
        axisLength - The length of the axis in display coordinates
        labelSize - The approximate average size a label takes along the axis
        Returns:
        The calculated range
        See Also:
        autoRange(double, double, double, double)
      • autoRange

        protected AxisRange autoRange​(double minValue,
                                      double maxValue,
                                      double length,
                                      double labelSize)
      • autoRange

        protected AxisRange autoRange​(double length)
        This calculates the upper and lower bound based on the data provided to invalidateRange() method. This must not effect the state of the axis, changing any properties of the axis. Any results of the auto-ranging should be returned in the range object. This will we passed to setRange() if it has been decided to adopt this range for this axis.
        Parameters:
        length - The length of the axis in screen coordinates
        Returns:
        Range information, this is implementation dependent
      • calculateNewScale

        protected double calculateNewScale​(double length,
                                           double lowerBound,
                                           double upperBound)
        Calculate a new scale for this axis. This should not effect any state(properties) of this axis.
        Parameters:
        length - The display length of the axis
        lowerBound - The lower bound value
        upperBound - The upper bound value
        Returns:
        new scale to fit the range from lower bound to upper bound in the given display length
      • calculateMinorTickValues

        protected abstract java.util.List<java.lang.Double> calculateMinorTickValues()
        Calculate a list of the data values for every minor tick mark
        Returns:
        List of data values where to draw minor tick marks
      • getNewTickMark

        public TickMark getNewTickMark​(java.lang.Double tickValue,
                                       java.lang.Double tickPosition,
                                       java.lang.String tickMarkLabel)
      • computeTickMarks

        protected java.util.List<TickMark> computeTickMarks​(AxisRange range,
                                                            boolean majorTickMark)
      • recomputeTickMarks

        public void recomputeTickMarks()
      • recomputeTickMarks

        protected void recomputeTickMarks​(AxisRange range)
      • drawAxis

        public void drawAxis​(javafx.scene.canvas.GraphicsContext gc,
                             double axisWidth,
                             double axisHeight)
        Description copied from interface: Axis
        Function allows custom drawing of axes outside the Axis environment (ie. on another canvas)
        Specified by:
        drawAxis in interface Axis
        Parameters:
        gc - the graphic context on which the axis is to be drawn
        axisWidth - the axis width in pixel (N.B. padding is being added)
        axisHeight - the axis height in pixel (N.B. padding is being added)
      • drawAxisPre

        protected void drawAxisPre()
        function to be executed prior to drawing axis can be used to execute user-specific code (e.g. modifying tick-marks) prior to drawing
      • drawAxisPost

        protected void drawAxisPost()
        function to be executed after the axis has been drawn can be used to execute user-specific code (e.g. update of other classes/properties)
      • updateCachedVariables

        protected void updateCachedVariables()
        to be overwritten by derived class that want to cache variables for efficiency reasons
      • forceRedraw

        public void forceRedraw()
        Description copied from interface: Axis
        forces redrawing of axis (via layoutChildren()). This is used to force an update while the main chart area is being updated (a requestLayout()) would be executed only during the next pulse. This is used explicitly in the Chart class. Outside use of this context should be limited to a minimum... handle with care
        Specified by:
        forceRedraw in interface Axis
      • layoutChildren

        protected void layoutChildren()
        Invoked during the layout pass to layout this axis and all its content.
        Overrides:
        layoutChildren in class javafx.scene.Parent
      • invalidateRange

        public void invalidateRange​(java.util.List<java.lang.Number> data)
        Called when data has changed and the range may not be valid any more. This is only called by the chart if isAutoRanging() returns true. If we are auto ranging it will cause layout to be requested and auto ranging to happen on next layout pass.
        Specified by:
        invalidateRange in interface Axis
        Parameters:
        data - The current set of all data that needs to be plotted on this axis
      • isValueOnAxis

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

        public javafx.scene.canvas.Canvas getCanvas()
      • isLabelOverlapping

        public boolean isLabelOverlapping()
      • getGraphicsContext

        public javafx.scene.canvas.GraphicsContext getGraphicsContext()
      • isRangeValid

        protected boolean isRangeValid()
        See if the current range is valid, if it is not then any range dependent calculations need to redone on the next layout pass
        Returns:
        true if current range calculations are valid
      • invalidateRange

        protected void invalidateRange()
        Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the next layout.
        Overrides:
        invalidateRange in class AbstractAxisParameter
      • shouldAnimate

        protected boolean shouldAnimate()
        This is used to check if any given animation should run. It returns true if animation is enabled and the node is visible and in a scene.
        Returns:
        true if animations should happen
      • requestAxisLayout

        public void requestAxisLayout()
        Request that the axis is laid out in the next layout pass. This replaces requestLayout() as it has been overridden to do nothing so that changes to children's bounds etc do not cause a layout. This was done as a optimisation as the Axis knows the exact minimal set of changes that really need layout to be updated. So we only want to request layout then, not on any child change.
        Specified by:
        requestAxisLayout in interface Axis
        Specified by:
        requestAxisLayout in class AbstractAxisParameter
      • calculateMajorTickValues

        protected abstract java.util.List<java.lang.Double> calculateMajorTickValues​(double length,
                                                                                     AxisRange range)
        Calculate a list of all the data values for each tick mark in range
        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
      • computePrefHeight

        protected double computePrefHeight​(double width)
        Computes the preferred height of this axis for the given width. If axis orientation is horizontal, it takes into account the tick mark length, tick label gap and label height.
        Overrides:
        computePrefHeight in class javafx.scene.layout.Region
        Returns:
        the computed preferred width for this axis
      • computePrefWidth

        protected double computePrefWidth​(double height)
        Computes the preferred width of this axis for the given height. If axis orientation is vertical, it takes into account the tick mark length, tick label gap and label height.
        Overrides:
        computePrefWidth in class javafx.scene.layout.Region
        Returns:
        the computed preferred width for this axis
      • tickMarksUpdated

        protected void tickMarksUpdated()
        Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to in reaction.
      • getAxisRange

        protected AxisRange getAxisRange()
        Returns:
        axsis range that is supposed to be shown
      • setRange

        protected void setRange​(AxisRange rangeObj,
                                boolean animate)
      • clearAxisCanvas

        protected void clearAxisCanvas​(javafx.scene.canvas.GraphicsContext gc,
                                       double width,
                                       double height)
      • drawAxisLine

        protected void drawAxisLine​(javafx.scene.canvas.GraphicsContext gc,
                                    double axisLength,
                                    double axisWidth,
                                    double axisHeight)
      • drawTickMarks

        protected void drawTickMarks​(javafx.scene.canvas.GraphicsContext gc,
                                     double axisLength,
                                     double axisWidth,
                                     double axisHeight,
                                     javafx.collections.ObservableList<TickMark> tickMarks,
                                     double tickLength,
                                     javafx.scene.shape.Path tickStyle)
      • drawTickMarkLabel

        protected void drawTickMarkLabel​(javafx.scene.canvas.GraphicsContext gc,
                                         double x,
                                         double y,
                                         double rotation,
                                         TickMark tickMark)
      • drawTickLabels

        protected void drawTickLabels​(javafx.scene.canvas.GraphicsContext gc,
                                      double axisWidth,
                                      double axisHeight,
                                      javafx.collections.ObservableList<TickMark> tickMarks,
                                      double tickLength)
      • drawAxisLabel

        protected void drawAxisLabel​(javafx.scene.canvas.GraphicsContext gc,
                                     double x,
                                     double y,
                                     javafx.scene.text.Text label)
      • measureTickMarkLength

        protected double measureTickMarkLength​(double major)
      • computePreferredTickUnit

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

        protected double getMaxTickLabelWidth​(java.util.List<TickMark> tickMarks)
      • getMaxTickLabelHeight

        protected double getMaxTickLabelHeight​(java.util.List<TickMark> tickMarks)
      • drawAxisLabel

        protected void drawAxisLabel​(javafx.scene.canvas.GraphicsContext gc,
                                     double axisLength,
                                     double axisWidth,
                                     double axisHeight,
                                     javafx.scene.text.Text axisLabel,
                                     javafx.collections.ObservableList<TickMark> tickMarks,
                                     double tickLength)
      • getTickMarkLabel

        public java.lang.String getTickMarkLabel​(double value)
        Get the string label name for a tick mark with the given value
        Specified by:
        getTickMarkLabel in interface Axis
        Parameters:
        value - The value to format into a tick label string
        Returns:
        A formatted string for the given value
      • addListener

        public void addListener​(javafx.beans.InvalidationListener listener)
        Specified by:
        addListener in interface javafx.beans.Observable
      • removeListener

        public void removeListener​(javafx.beans.InvalidationListener listener)
        Specified by:
        removeListener in interface javafx.beans.Observable
      • setAutoNotifaction

        public void setAutoNotifaction​(boolean flag)
        Description copied from interface: Axis
        Set the automatic notification of invalidation listeners. In general, axes should notify registered invalidation listeners, if the axes range or style parameters have changed.
        Specified by:
        setAutoNotifaction in interface Axis
        Parameters:
        flag - true for automatic notification
      • isAutoNotification

        public boolean isAutoNotification()
        Description copied from interface: Axis
        Checks it automatic notification is enabled.
        Specified by:
        isAutoNotification in interface Axis
        Returns:
        true if automatic notification is enabled
      • fireInvalidated

        public void fireInvalidated()
        Notifies listeners that the data has been invalidated. If the data is added to the chart, it triggers repaint.
        Specified by:
        fireInvalidated in class AbstractAxisParameter
      • executeFireInvalidated

        protected void executeFireInvalidated()
      • 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.
        Specified by:
        getDisplayPosition in interface Axis
        Parameters:
        value - The data value to work out display position for
        Returns:
        display position
      • getZeroPosition

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