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 Details

  • Constructor Details

    • 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 Details

    • createLinearScaleTickLabels

      protected LinearScaleTickLabels createLinearScaleTickLabels()
      Description copied from class: LinearScale
      Creates the linearScaleTickLabel. To be overridden if necessary if another Axis implementation is used.
      Overrides:
      createLinearScaleTickLabels in class LinearScale
    • createLinearScaleTickMarks

      protected LinearScaleTickMarks createLinearScaleTickMarks()
      Description copied from class: LinearScale
      Creates the LinearScaleTickMarks. To be overridden if necessary if another Axis implementation is used.
      Overrides:
      createLinearScaleTickMarks in class LinearScale
    • 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
    • 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
    • setAutoFormat

      public void setAutoFormat​(boolean autoFormat)
      Specified by:
      setAutoFormat in interface IScaleProvider
      Overrides:
      setAutoFormat in class AbstractScale
      Parameters:
      autoFormat - the autoFormat to set
    • 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
    • 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 -
    • hasTicksAtEnds

      public boolean hasTicksAtEnds()
      Returns true if ticks at end of axis are shown
      Specified by:
      hasTicksAtEnds in interface IScaleProvider
      Overrides:
      hasTicksAtEnds in class LinearScale
      Returns:
      true if ticks at end of axis are shown
    • 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