Class RoundScaleTickLabels
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.nebula.visualization.widgets.figureparts.RoundScaleTickLabels
-
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure
public class RoundScaleTickLabels extends org.eclipse.draw2d.Figure
Round Scale tick labels.
-
-
Field Summary
Fields Modifier and Type Field Description private double
gridStepInRadians
private RoundScale
scale
private java.util.ArrayList<org.eclipse.draw2d.geometry.Rectangle>
tickLabelAreas
the array of tick label areaprivate int
tickLabelMaxOutLength
the maximum height of tick labelsprivate java.util.ArrayList<java.lang.Double>
tickLabelPositions
the array of tick label position in radiansprivate java.util.ArrayList<java.lang.String>
tickLabels
the array of tick labelprivate java.util.ArrayList<java.lang.Double>
tickLabelValues
the array of tick label valesprivate java.util.ArrayList<java.lang.Boolean>
tickLabelVisibilities
the array of visibility state of tick label
-
Constructor Summary
Constructors Modifier Constructor Description protected
RoundScaleTickLabels(RoundScale scale)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
drawTickLabels(org.eclipse.draw2d.Graphics graphics)
Draw the tick labels.private double
getGridStep(int lengthInPixels, double minR, double maxR)
Gets the grid step.double
getGridStepInRadians()
int
getTickLabelMaxOutLength()
java.util.ArrayList<java.lang.Double>
getTickLabelPositions()
Gets the tick label positions.java.util.ArrayList<java.lang.Boolean>
getTickVisibilities()
private boolean
hasSpaceToDraw(org.eclipse.draw2d.geometry.Rectangle previousLabelArea, org.eclipse.draw2d.geometry.Rectangle labelArea)
Returns the state indicating if there is a space to draw tick label.private boolean
isMajorTick(double tickValue)
Checks if the tick label is major tick.protected void
paintClientArea(org.eclipse.draw2d.Graphics graphics)
private java.math.BigDecimal
pow(double base, int exponent)
Calculates the value of the first argument raised to the power of the second argument.protected void
update(double lengthInDegrees, int lengthInPixels)
Updates the tick labels.private void
updateTickLabelAreas()
Updates the the draw area of each label.private void
updateTickLabelForLinearScale(double lengthInDegrees, int lengthInPixels)
Updates tick label for normal scale.private void
updateTickLabelForLogScale(double lengthInDegrees)
Updates tick label for log scale.private void
updateTickLabelMaxOutLength()
Gets max out length of tick label.private void
updateTickLabelVisibility()
-
Methods inherited from class org.eclipse.draw2d.Figure
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintBorder, paintChildren, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
-
-
-
-
Field Detail
-
tickLabelValues
private java.util.ArrayList<java.lang.Double> tickLabelValues
the array of tick label vales
-
tickLabels
private java.util.ArrayList<java.lang.String> tickLabels
the array of tick label
-
tickLabelPositions
private java.util.ArrayList<java.lang.Double> tickLabelPositions
the array of tick label position in radians
-
tickLabelVisibilities
private java.util.ArrayList<java.lang.Boolean> tickLabelVisibilities
the array of visibility state of tick label
-
tickLabelAreas
private java.util.ArrayList<org.eclipse.draw2d.geometry.Rectangle> tickLabelAreas
the array of tick label area
-
tickLabelMaxOutLength
private int tickLabelMaxOutLength
the maximum height of tick labels
-
gridStepInRadians
private double gridStepInRadians
-
scale
private RoundScale scale
-
-
Constructor Detail
-
RoundScaleTickLabels
protected RoundScaleTickLabels(RoundScale scale)
Constructor.- Parameters:
scale
- the round scale has this tick labels.
-
-
Method Detail
-
getGridStepInRadians
public double getGridStepInRadians()
- Returns:
- the gridStepInPixel
-
getTickLabelMaxOutLength
public int getTickLabelMaxOutLength()
- Returns:
- if the tick label is draw outside scale's bounds, this is the max length of the outside part
-
getTickLabelPositions
public java.util.ArrayList<java.lang.Double> getTickLabelPositions()
Gets the tick label positions.- Returns:
- the tick label positions
-
getTickVisibilities
public java.util.ArrayList<java.lang.Boolean> getTickVisibilities()
- Returns:
- the tickVisibilities
-
drawTickLabels
private void drawTickLabels(org.eclipse.draw2d.Graphics graphics)
Draw the tick labels.- Parameters:
grahics
- the graphics context
-
getGridStep
private double getGridStep(int lengthInPixels, double minR, double maxR)
Gets the grid step.- Parameters:
lengthInPixels
- scale length in pixelsmin
- minimum valuemax
- maximum value- Returns:
- rounded value.
-
hasSpaceToDraw
private boolean hasSpaceToDraw(org.eclipse.draw2d.geometry.Rectangle previousLabelArea, org.eclipse.draw2d.geometry.Rectangle labelArea)
Returns the state indicating if there is a space to draw tick label.- Parameters:
previousLabelArea
- the previously drawn tick label area.labelArea
- the tick label's area- Returns:
- true if there is a space to draw tick label
-
isMajorTick
private boolean isMajorTick(double tickValue)
Checks if the tick label is major tick. For example: 0.001, 0.01, 0.1, 1, 10, 100...
-
pow
private java.math.BigDecimal pow(double base, int exponent)
Calculates the value of the first argument raised to the power of the second argument.- Parameters:
base
- the baseexponent
- the exponent- Returns:
- the value ab in BigDecimal
-
updateTickLabelAreas
private void updateTickLabelAreas()
Updates the the draw area of each label.
-
updateTickLabelForLinearScale
private void updateTickLabelForLinearScale(double lengthInDegrees, int lengthInPixels)
Updates tick label for normal scale.- Parameters:
lengthInDegrees
- scale length in degreeslengthInPixels
- scale length in pixels
-
updateTickLabelForLogScale
private void updateTickLabelForLogScale(double lengthInDegrees)
Updates tick label for log scale.- Parameters:
lengthInDegrees
- scale length in degrees
-
updateTickLabelMaxOutLength
private void updateTickLabelMaxOutLength()
Gets max out length of tick label.
-
updateTickLabelVisibility
private void updateTickLabelVisibility()
-
paintClientArea
protected void paintClientArea(org.eclipse.draw2d.Graphics graphics)
- Overrides:
paintClientArea
in classorg.eclipse.draw2d.Figure
-
update
protected void update(double lengthInDegrees, int lengthInPixels)
Updates the tick labels.- Parameters:
lengthInDegrees
- scale length in degrees
-
-