Class DAxis

  • All Implemented Interfaces:
    org.eclipse.draw2d.IFigure, IScaleProvider

    public class DAxis
    extends Axis
    The Diamond Light Source implementation of the axis figure.
    • Field Detail

      • ticksIndexBased

        private boolean ticksIndexBased
        if true, then ticks are based on axis dataset indexes
      • cachedFormats

        private java.util.Map<java.lang.Integer,​java.text.Format> cachedFormats
      • ticksAtEnds

        private boolean ticksAtEnds
      • userDefinedFormat

        protected boolean userDefinedFormat
        the user format
      • axisAutoscaleTight

        private boolean axisAutoscaleTight
      • DEFAULT_LOG_SCALE_MIN

        private static final double DEFAULT_LOG_SCALE_MIN
        the default minimum value of log scale range
        See Also:
        Constant Field Values
      • ZERO_RANGE_LOWEST_FRACTION

        private static final double ZERO_RANGE_LOWEST_FRACTION
    • Constructor Detail

      • DAxis

        public DAxis()
        Constructor that creates a DAxis with no title
      • DAxis

        public DAxis​(java.lang.String title,
                     boolean yAxis)
        Constructor
        Parameters:
        title - title of the axis
        yAxis - true if this is the Y-Axis, false if this is the X-Axis.
    • Method Detail

      • calculateSpan

        public int calculateSpan​(java.lang.Object obj)
        Calculate span of a textual form of object in scale's orientation
        Parameters:
        obj - object
        Returns:
        span in pixel
      • getMargin

        public int getMargin()
        Description copied from class: LinearScale
        Margin is half of the label's length(Horizontal Scale) or height(Vertical scale), so that the label can be displayed correctly. So the range and format pattern must be set correctly before you can get the correct margin.
        Specified by:
        getMargin in interface IScaleProvider
        Overrides:
        getMargin in class LinearScale
        Returns:
        the margin
      • getScaling

        public double getScaling()
        Get scaling for axis in terms of pixels/unit
        Returns:
        scaling
      • layout

        protected void layout()
        Overrides:
        layout in class Axis
      • layoutTicks

        protected void layoutTicks()
      • setTicksIndexBased

        public void setTicksIndexBased​(boolean isTicksIndexBased)
        Parameters:
        isTicksIndexBased - if true, make ticks based on axis dataset indexes
      • isTicksIndexBased

        public boolean isTicksIndexBased()
        Returns:
        True if ticks are index based
      • format

        public java.lang.String format​(java.lang.Object obj)
        Description copied from class: AbstractScale
        Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat. This is based on an internal format pattern given the object in parameter.
        Specified by:
        format in interface IScaleProvider
        Overrides:
        format in class AbstractScale
        Parameters:
        obj - the object
        Returns:
        the formatted string
      • updateTick

        public void updateTick()
        Description copied from class: LinearScale
        Updates the tick, recalculate all parameters, such as margin, length...
        Overrides:
        updateTick in class LinearScale
      • format

        public java.lang.String format​(java.lang.Object obj,
                                       int extraDP)
        Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat. This is based on an internal format pattern given the object in parameter. When formatting a date, if minOrMaxDate is true as well as autoFormat, then the SimpleDateFormat us used to format the object.
        Parameters:
        obj - the object
        extraDP - must be non-negative
        Returns:
        the formatted string
      • getAutoFormat

        protected java.lang.String getAutoFormat​(double min,
                                                 double max)
      • setDateEnabled

        public void setDateEnabled​(boolean dateEnabled)
        Overrides:
        setDateEnabled in class AbstractScale
        Parameters:
        dateEnabled - the dateEnabled to set
      • setFormatPattern

        public void setFormatPattern​(java.lang.String formatPattern)
        Description copied from class: AbstractScale
        Sets the format pattern for axis tick label. see Format

        If null is set, default format will be used.

        Overrides:
        setFormatPattern in class AbstractScale
      • setFormat

        private void setFormat​(java.lang.String formatPattern)
      • setRange

        public void setRange​(double lower,
                             double upper)
        Description copied from class: AbstractScale
        set the scale range
        Overrides:
        setRange in class Axis
        Parameters:
        lower - the lower limit
        upper - the upper limit
      • internalSetRange

        private void internalSetRange​(double lower,
                                      double upper,
                                      boolean ticksAtEnd)
      • setLogScale

        public void setLogScale​(boolean enabled)
                         throws java.lang.IllegalStateException
        Overrides:
        setLogScale in class Axis
        Parameters:
        enabled - true if enabling log scales
        Throws:
        java.lang.IllegalStateException
      • performAutoScale

        public boolean performAutoScale​(boolean force)
        Description copied from class: Axis
        Perform an auto-scale: Axis limits are set to the value range of the traces on this axis. Includes some optimization: Axis range is set a little wider than exact trace data range. When auto-scale would only perform a minor axis adjustment, axis is left unchanged.
        Overrides:
        performAutoScale in class Axis
        Parameters:
        force - If true, the axis will be auto-scaled by force regardless the autoScale field. Otherwise, it will use the autoScale field to judge whether an auto-scale will be performed.
        Returns:
        true if the axis is repainted due to range change.
        See Also:
        Axis.autoScaleThreshold
      • rangeIsUnchanged

        private boolean rangeIsUnchanged​(double dataMin,
                                         double dataMax,
                                         double axisMin,
                                         double axisMax)
        Determines if upper or lower data has changed from current axis limits
        Parameters:
        dataMin - - min of data in buffer
        dataMax - - max of data in buffer
        axisMin - - current axis min
        axisMax - - current axis max
        Returns:
        TRUE if data and axis max and min values are equal
      • clear

        public void clear()
      • setAxisAutoscaleTight

        public void setAxisAutoscaleTight​(boolean axisTight)
        Parameters:
        axisTight - set whether autoscale sets axis range tight to the data or the end of axis is set to the nearest tickmark
      • isAxisAutoscaleTight

        public boolean isAxisAutoscaleTight()
        Returns:
        true if autoscaling axis is tight to displayed data
      • setTicksAtEnds

        public void setTicksAtEnds​(boolean ticksAtEnds)
        Sets whether ticks at ends of axis are shown
        Parameters:
        ticksAtEnds -
      • setHasUserDefinedFormat

        public void setHasUserDefinedFormat​(boolean hasUserDefinedFormat)
        Sets whether there is a user defined format or not
        Parameters:
        hasUserDefinedFormat -
      • hasUserDefinedFormat

        public boolean hasUserDefinedFormat()
        Returns:
        true if user format is defined