Class AbstractAxis

    • Field Detail

      • MIN_NARROW_FONT_SCALE

        protected static final double MIN_NARROW_FONT_SCALE
        See Also:
        Constant Field Values
      • MAX_NARROW_FONT_SCALE

        protected static final double MAX_NARROW_FONT_SCALE
        See Also:
        Constant Field Values
      • RANGE_ANIMATION_DURATION_MS

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

        protected boolean labelOverlap
      • scaleFont

        protected double scaleFont
      • lock

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

        protected double maxLabelHeight
      • maxLabelWidth

        protected double maxLabelWidth
      • tickMarkStringCache

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

        protected final transient 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()
      • 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
      • 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)
      • 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
      • 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
      • getCanvas

        public javafx.scene.canvas.Canvas getCanvas()
        Specified by:
        getCanvas in interface Axis
        Returns:
        the canvas of the axis
      • getDisplayPosition

        public double getDisplayPosition​(double value)
        Description copied from interface: Axis
        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. If the value is not valid for this Axis and the axis cannot display such value in any range, Double.NaN is returned
        Specified by:
        getDisplayPosition in interface Axis
        Parameters:
        value - The data value to work out display position for
        Returns:
        display position or Double.NaN if value not valid
      • getGraphicsContext

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

        public TickMark getNewTickMark​(java.lang.Double tickValue,
                                       double tickPosition,
                                       java.lang.String tickMarkLabel)
      • 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
      • 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;
      • invalidateCaches

        public void invalidateCaches()
      • 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
      • isLabelOverlapping

        public boolean isLabelOverlapping()
      • 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
      • recomputeTickMarks

        public void recomputeTickMarks()
      • 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
      • setMax

        public boolean setMax​(double value)
        Specified by:
        setMax in interface de.gsi.dataset.AxisDescription
        Overrides:
        setMax in class AbstractAxisParameter
      • setMin

        public boolean setMin​(double value)
        Specified by:
        setMin in interface de.gsi.dataset.AxisDescription
        Overrides:
        setMin in class AbstractAxisParameter
      • 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 set(Range) 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
      • autoRange

        protected AxisRange autoRange​(double minValue,
                                      double maxValue,
                                      double length,
                                      double labelSize)
      • 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
      • 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
      • 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
      • clearAxisCanvas

        protected void clearAxisCanvas​(javafx.scene.canvas.GraphicsContext gc,
                                       double width,
                                       double height)
      • 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
      • 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)
      • computeTickMarks

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

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

        protected void drawAxisLine​(javafx.scene.canvas.GraphicsContext gc,
                                    double axisLength,
                                    double axisWidth,
                                    double axisHeight)
      • 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)
      • 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
      • drawTickLabels

        protected void drawTickLabels​(javafx.scene.canvas.GraphicsContext gc,
                                      double axisWidth,
                                      double axisHeight,
                                      javafx.collections.ObservableList<TickMark> tickMarks,
                                      double tickLength)
      • 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)
      • getAxisRange

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

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

        protected double measureTickMarkLength​(java.lang.Double major)
      • recomputeTickMarks

        protected void recomputeTickMarks​(AxisRange range)
      • 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
      • tickMarksUpdated

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

        protected void updateCSS()
      • drawAxisLabel

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

        protected static void drawTickMarkLabel​(javafx.scene.canvas.GraphicsContext gc,
                                                double x,
                                                double y,
                                                double scaleFont,
                                                TickMark tickMark)
      • snap

        protected static double snap​(double coordinate)
        Parameters:
        coordinate - double coordinate to snapped to actual pixel index
        Returns:
        coordinate that is snapped to pixel (for a 'crisper' display)