Class RoundScale

java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
org.eclipse.nebula.visualization.widgets.figureparts.RoundScale
All Implemented Interfaces:
org.eclipse.draw2d.IFigure

public class RoundScale
extends AbstractScale
Round scale has the tick labels and tick marks on a circle. It can be used for any round scale based widget, such meter, gauge, knob etc.
A round scale is comprised of Scale line, tick labels and tick marks which include minor ticks and major ticks.
The endAngle is on the clockwise side of startAngle. Regardless the startAngle and endAngle, the scale will always be drawn in a square. The bounds will be automatically cropped to the square with the max possible size.
  • Field Details

  • Constructor Details

  • Method Details

    • getLengthInPixels

      public int getLengthInPixels()
      Returns:
      the length of the whole scale in pixels
    • getLengthInDegrees

      public double getLengthInDegrees()
      Returns:
      the length of the whole scale in degrees
    • convertPixelToRadians

      public double convertPixelToRadians​(int pixels)
      Parameters:
      pixels - the pixels to be converted
      Returns:
      the corresponding length in radians
    • getEstimatedDonutWidth

      public int getEstimatedDonutWidth()
      Returns:
      the estimated donut width, which is used to calculate the radius
    • 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 org.eclipse.draw2d.Figure
    • getScaleTickLabels

      public RoundScaleTickLabels getScaleTickLabels()
      Gets the scale tick labels.
      Returns:
      the scale tick labels
    • getScaleTickMarks

      public RoundScaleTickMarks getScaleTickMarks()
      Gets the scale tick marks.
      Returns:
      the scale tick marks
    • getCoercedValuePosition

      public double getCoercedValuePosition​(double value, boolean relative)
    • getValuePosition

      public double getValuePosition​(double value, boolean relative)
      Get the position of the value in degrees. Which is the angular coordinate in the polar coordinate system, whose pole(the origin) is the center of the bounds, whose polar axis is from left to right on horizontal if relative is false.
      Parameters:
      value - the value to find its position. It can be value out of range.
      relative - the polar axs would be counterclockwisely rotated to the endAngle if true.
      Returns:
      position in degrees
    • layout

      protected void layout()
      Overrides:
      layout in class org.eclipse.draw2d.Figure
    • setBounds

      public void setBounds​(org.eclipse.draw2d.geometry.Rectangle rect)
      Specified by:
      setBounds in interface org.eclipse.draw2d.IFigure
      Overrides:
      setBounds in class org.eclipse.draw2d.Figure
    • setFont

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

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

      public void updateTick()
      Updates the tick, recalculate all parameters, such as margin, length...
      Specified by:
      updateTick in class AbstractScale
    • useLocalCoordinates

      protected boolean useLocalCoordinates()
      Updates the tick layout. protected void updateLayoutData() { axisTickLabels.updateLayoutData(); axisTickMarks.updateLayoutData(); }
      Overrides:
      useLocalCoordinates in class org.eclipse.draw2d.Figure
    • setStartAngle

      public void setStartAngle​(double startAngle)
      Parameters:
      startAngle - the startAngle to set
    • getStartAngle

      public double getStartAngle()
      Returns:
      the startAngle
    • setEndAngle

      public void setEndAngle​(double endAngle)
      Parameters:
      endAngle - the endAngle to set
    • getEndAngle

      public double getEndAngle()
      Returns:
      the endAngle
    • setRadius

      public void setRadius​(int radius)
      Parameters:
      radius - the radius to set
    • getRadius

      public int getRadius()
      Returns:
      the radius
    • getInnerRadius

      public int getInnerRadius()
      Returns:
      the inner radius for a primary tick label side scale.