Class Axis

java.lang.Object
All Implemented Interfaces:
org.eclipse.draw2d.IFigure, IScaleProvider
Direct Known Subclasses:
DAxis

public class Axis
extends LinearScale
The axis figure.
  • Field Details

  • Constructor Details

    • Axis

      public Axis​(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

    • setFont

      public void setFont​(org.eclipse.swt.graphics.Font font)
      Specified by:
      setFont in interface org.eclipse.draw2d.IFigure
      Overrides:
      setFont in class LinearScale
    • getTitleFontData

      public org.eclipse.swt.graphics.FontData getTitleFontData()
    • getScaleFontData

      public org.eclipse.swt.graphics.FontData getScaleFontData()
    • addListener

      public void addListener​(IAxisListener listener)
    • removeListener

      public boolean removeListener​(IAxisListener listener)
    • fireRevalidated

      protected void fireRevalidated()
    • fireAxisRangeChanged

      protected void fireAxisRangeChanged​(Range old_range, Range new_range)
    • setRange

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

      public void setInverted​(boolean isInverted)
      Inverts the axis if set to True
      Parameters:
      isInverted -
    • isInverted

      public boolean isInverted()
      Returns True if axis is inverted, False otherwise
      Returns:
    • layout

      protected void layout()
      Overrides:
      layout in class LinearScale
    • setVisible

      public void setVisible​(boolean visible)
      Specified by:
      setVisible in interface org.eclipse.draw2d.IFigure
      Overrides:
      setVisible in class org.eclipse.draw2d.Figure
    • setForegroundColor

      public void setForegroundColor​(org.eclipse.swt.graphics.Color color)
      Specified by:
      setForegroundColor in interface org.eclipse.draw2d.IFigure
      Overrides:
      setForegroundColor in class LinearScale
    • setMinorTicksVisible

      public void setMinorTicksVisible​(boolean minorTicksVisible)
      Overrides:
      setMinorTicksVisible in class AbstractScale
      Parameters:
      minorTicksVisible - the minorTicksVisible to set
    • getForegroundColorRGB

      public org.eclipse.swt.graphics.RGB getForegroundColorRGB()
    • setBackgroundColor

      public void setBackgroundColor​(org.eclipse.swt.graphics.Color bg)
      Specified by:
      setBackgroundColor in interface org.eclipse.draw2d.IFigure
      Overrides:
      setBackgroundColor in class org.eclipse.draw2d.Figure
    • getPreferredSize

      public org.eclipse.draw2d.geometry.Dimension getPreferredSize​(int wHint, int hHint)
      Specified by:
      getPreferredSize in interface org.eclipse.draw2d.IFigure
      Overrides:
      getPreferredSize in class LinearScale
    • paintClientArea

      protected void paintClientArea​(org.eclipse.draw2d.Graphics graphics)
      Overrides:
      paintClientArea in class org.eclipse.draw2d.Figure
    • getTraceDataRange

      public Range getTraceDataRange()
      Returns:
      Range that reflects the minimum and maximum value of all traces on this axis. Returns null if there is no trace data.
    • performAutoScale

      public boolean performAutoScale​(boolean force)
      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.
      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:
      autoScaleThreshold
    • addTrace

      public void addTrace​(Trace trace)
      Add a trace to the axis.
      Parameters:
      trace - the trace to be added.
    • removeTrace

      public boolean removeTrace​(Trace trace)
      Remove a trace from the axis.
      Parameters:
      trace -
      Returns:
      true if this axis contained the specified trace
    • setTitle

      public void setTitle​(java.lang.String title)
      Parameters:
      title - the title to set
    • getTitle

      public java.lang.String getTitle()
      Returns:
      the title
    • isAutoScale

      public boolean isAutoScale()
      Returns:
      the autoScale
    • setAutoScale

      public void setAutoScale​(boolean autoScale)
      Parameters:
      autoScale - the autoScale to set
    • isShowMajorGrid

      public boolean isShowMajorGrid()
      Returns:
      the showMajorGrid
    • setShowMajorGrid

      public void setShowMajorGrid​(boolean showMajorGrid)
      Parameters:
      showMajorGrid - the showMajorGrid to set
    • isShowMinorGrid

      public boolean isShowMinorGrid()
      Returns:
      the showMinorGrid
    • setShowMinorGrid

      public void setShowMinorGrid​(boolean showMinorGrid)
      Parameters:
      showMinorGrid - the showMinorGrid to set
    • getMajorGridColor

      public org.eclipse.swt.graphics.Color getMajorGridColor()
      Returns:
      the majorGridColor
    • setMajorGridColor

      public void setMajorGridColor​(org.eclipse.swt.graphics.Color majorGridColor)
      Parameters:
      majorGridColor - the majorGridColor to set
    • getMajorGridColorRGB

      public org.eclipse.swt.graphics.RGB getMajorGridColorRGB()
    • getMinorGridColor

      public org.eclipse.swt.graphics.Color getMinorGridColor()
      Returns:
      the minorGridColor
    • setMinorGridColor

      public void setMinorGridColor​(org.eclipse.swt.graphics.Color minorGridColor)
      Parameters:
      minorGridColor - the minorGridColor to set
    • setTitleFont

      public void setTitleFont​(org.eclipse.swt.graphics.Font titleFont)
      Parameters:
      titleFont - the titleFont to set
    • isDashGridLine

      public boolean isDashGridLine()
      Returns:
      the dashGridLine
    • setDashGridLine

      public void setDashGridLine​(boolean dashGridLine)
      Parameters:
      dashGridLine - the dashGridLine to set
    • setXYGraph

      public void setXYGraph​(IXYGraph xyGraph)
      Parameters:
      xyGraph - the xyGraph to set
    • getXYGraph

      public IXYGraph getXYGraph()
      Returns:
      the graph
    • getTraceList

      protected java.util.List<Trace> getTraceList()
      Returns:
      traceList
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • dataChanged

      public void dataChanged​(IDataProvider dataProvider)
    • setAutoScaleThreshold

      public void setAutoScaleThreshold​(double autoScaleThreshold)
      The autoScaleThreshold must be a value in range [0,1], which represents a percentage of the plot area for the threshold when autoScale is performed.The autoScale will performed only if the spare space exceeds this threshold. So it can reduce the CPU usage by increasing the threshold.
      Parameters:
      autoScaleThreshold - the autoScaleThreshold to set
    • setZoomType

      public void setZoomType​(ZoomType zoomType)
      Parameters:
      zoomType - the zoomType to set
    • getTitleFont

      public org.eclipse.swt.graphics.Font getTitleFont()
      Returns:
      the titleFont
    • getAutoScaleThreshold

      public double getAutoScaleThreshold()
      Returns:
      the autoScaleThreshold
    • getAutoScale

      public boolean getAutoScale()
      Returns:
      autoScale
    • setYAxis

      public void setYAxis​(boolean isYAxis)
      Set this axis as Y-Axis or X-Axis.
      Parameters:
      isYAxis - set true if the axis is Y-Axis; false if it is X-Axis.
    • setPrimarySide

      public void setPrimarySide​(boolean onPrimarySide)
      Set the axis on primary side (Bottom/Left) or secondary side (Top/Right).
      Parameters:
      onPrimarySide - set true if the axis on primary side(Bottom/Left); false if it is not on the primary side of xy graph(Top/Right).
    • isYAxis

      public boolean isYAxis()
      Returns:
      true if the axis is Y-Axis; false if it is X-Axis;
    • isOnPrimarySide

      public boolean isOnPrimarySide()
      Returns:
      true if the axis is on the primary side of xy graph(Bottom/Left); false if it is on the secondary side(Top/Right).
    • pan

      protected void pan​(Range temp, double t1, double t2)
      Pan the axis
      Parameters:
      temp - Original axis range before the panning started
      t1 - Start of the panning move
      t2 - End of the panning move
    • panChecked

      protected boolean panChecked​(Range temp, double t1, double t2)
      Pan the axis and check if new range is okay
      Parameters:
      temp - Original axis range before the panning started
      t1 - Start of the panning move
      t2 - End of the panning move
      Returns:
      true if pan ends up out-of-bounds
    • zoomInOut

      public void zoomInOut​(double center, double factor)
      Zoom axis
      Parameters:
      center - Axis position at the 'center' of the zoom
      factor - Zoom factor. Positive to zoom 'in', negative 'out'.
    • setGrid

      public void setGrid​(Grid grid)
      Parameters:
      grid - the grid to set
    • getGrid

      public Grid getGrid()
      Returns:
      the grid
    • setLogScale

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