Class LinearScale
java.lang.Object
org.eclipse.draw2d.Figure
org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure
,IScaleProvider
- Direct Known Subclasses:
Axis
public class LinearScale extends AbstractScale implements IScaleProvider
Linear(straight) scale has the tick labels and tick marks on a straight line.
It can be used for any scale based widget, such as 2D plot, chart, graph,
thermometer or tank etc.
A scale is comprised of Margins, Scale line, tick labels and tick marks which include minor ticks and major ticks.
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 must be set before you can get the correct margin.
|Margin|______|______|______|______|______|______|Margin|
A scale is comprised of Margins, Scale line, tick labels and tick marks which include minor ticks and major ticks.
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 must be set before you can get the correct margin.
|Margin|______|______|______|______|______|______|Margin|
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LinearScale.Orientation
scale directionNested classes/interfaces inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
AbstractScale.LabelSide
-
Field Summary
Fields Modifier and Type Field Description protected static int
SPACE_BTW_MARK_LABEL
Fields inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
DEFAULT_DATE_FORMAT, default_decimal_format, DEFAULT_ENGINEERING_FORMAT, DEFAULT_LOG_SCALE_MAX, DEFAULT_MAX, DEFAULT_MIN, dirty, ENGINEERING_LIMIT, max, min
-
Constructor Summary
Constructors Constructor Description LinearScale()
Constructor. -
Method Summary
Modifier and Type Method Description protected LinearScaleTickLabels
createLinearScaleTickLabels()
Creates the linearScaleTickLabel.protected LinearScaleTickMarks
createLinearScaleTickMarks()
Creates the LinearScaleTickMarks.void
figureLayout()
Simple call oforg.eclipse.draw2d.Figure.layout()
org.eclipse.draw2d.geometry.Dimension
getDimension(java.lang.Object obj)
Calculate dimension of a textual form of objectdouble
getLabel(double value)
Override to provide custom axis labels.int
getLength()
Range
getLocalRange()
int
getMargin()
Margin is half of the label's length(Horizontal Scale) or height(Vertical scale), so that the label can be displayed correctly.int
getMargin(boolean updateTick)
If updateTick is True,getMargin()
is used where the tick are updated, if not, the method returnsmargin
.LinearScale.Orientation
getOrientation()
double
getPositionValue(double position, boolean relative)
Get the corresponding value on the position of the scale.double
getPositionValue(int position, boolean relative)
Get the corresponding value on the position of the scale.org.eclipse.draw2d.geometry.Dimension
getPreferredSize(int wHint, int hHint)
Range
getScaleRange()
LinearScaleTickLabels
getScaleTickLabels()
Gets the scale tick labels.LinearScaleTickMarks
getScaleTickMarks()
Gets the scale tick marks.int
getTickLength()
ITicksProvider
getTicksProvider()
Gets the ticks providerint
getValuePosition(double value, boolean relative)
Get the position of the value based on scale.double
getValuePrecisePosition(double value, boolean relative)
Get the position of the value based on scale.boolean
hasTicksAtEnds()
boolean
isHorizontal()
boolean
isLabelCustomised()
boolean
isPrimary()
boolean
isShowMaxLabel()
shows the maximum value of the range as a labelboolean
isShowMinLabel()
shows the minimum value of the range as a labelprotected void
layout()
void
setBounds(org.eclipse.draw2d.geometry.Rectangle rect)
void
setFont(org.eclipse.swt.graphics.Font font)
void
setForegroundColor(org.eclipse.swt.graphics.Color color)
void
setLength(int length)
void
setLocalRange(Range localRange)
void
setMargin(int margin)
void
setOrientation(LinearScale.Orientation orientation)
sets the orientationvoid
setShowMaxLabel(boolean b)
sets the visibility of the maximum labelvoid
setShowMinLabel(boolean b)
sets the visibility of the minimum labelvoid
updateTick()
Updates the tick, recalculate all parameters, such as margin, length...protected boolean
useLocalCoordinates()
Methods inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
createDefaultDecimalFormat, format, format, getFormatPattern, getMajorGridStep, getMajorTickMarkStepHint, getMinorTickMarkStepHint, getRange, getTickLabelSide, getTickLablesSide, getTimeUnit, internalSetAutoFormat, internalSetFormatPattern, internalSetLogScaleEnabled, internalSetRange, isAutoFormat, isDateEnabled, isDirty, isLogScaleEnabled, isMinorTicksVisible, isScaleLineVisible, setAutoFormat, setDateEnabled, setDirty, setFormatPattern, setLogScale, setMajorGridStep, setMajorTickMarkStepHint, setMinorTickMarkStepHint, setMinorTicksVisible, setRange, setRange, setRange, setScaleLineVisible, setTickLabelSide, setTickLableSide, setTimeUnit
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, 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, paint, paintBorder, paintChildren, paintClientArea, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.nebula.visualization.xygraph.linearscale.IScaleProvider
format, format, getFont, getForegroundColor, getFormatPattern, getMajorGridStep, getMajorTickMarkStepHint, getMinorTickMarkStepHint, getTimeUnit, isAutoFormat, isDateEnabled, isLogScaleEnabled, setAutoFormat
-
Field Details
-
SPACE_BTW_MARK_LABEL
protected static final int SPACE_BTW_MARK_LABEL- See Also:
- Constant Field Values
-
-
Constructor Details
-
LinearScale
public LinearScale()Constructor.
-
-
Method Details
-
createLinearScaleTickLabels
Creates the linearScaleTickLabel. To be overridden if necessary if another Axis implementation is used. -
createLinearScaleTickMarks
Creates the LinearScaleTickMarks. To be overridden if necessary if another Axis implementation is used. -
getLength
public int getLength()- Specified by:
getLength
in interfaceIScaleProvider
- Returns:
- the length of the whole scale (include margin)
-
setLength
public void setLength(int length)- Parameters:
length
-
-
getMargin
public int getMargin(boolean updateTick)If updateTick is True,getMargin()
is used where the tick are updated, if not, the method returnsmargin
.- Parameters:
updateTick
-- Returns:
-
getMargin
public int getMargin()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 interfaceIScaleProvider
- Returns:
- the margin
-
setMargin
public void setMargin(int margin)- Parameters:
margin
-
-
getOrientation
- Returns:
- the orientation
-
getPreferredSize
public org.eclipse.draw2d.geometry.Dimension getPreferredSize(int wHint, int hHint)- Specified by:
getPreferredSize
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
getPreferredSize
in classorg.eclipse.draw2d.Figure
-
getTicksProvider
Description copied from interface:IScaleProvider
Gets the ticks provider- Specified by:
getTicksProvider
in interfaceIScaleProvider
- Returns:
- tick provider
-
getScaleTickLabels
Gets the scale tick labels.- Returns:
- the scale tick labels
-
getScaleTickMarks
Gets the scale tick marks.- Returns:
- the scale tick marks
-
getTickLength
public int getTickLength()- Returns:
- the length of the tick part (without margin)
-
getValuePosition
public int getValuePosition(double value, boolean relative)Get the position of the value based on scale.- Parameters:
value
- the value to find its position. Support value out of range.relative
- return the position relative to the left/bottom bound of the scale if true. If false, return the absolute position which has the scale bounds counted.- Returns:
- position in pixels
-
getValuePrecisePosition
public double getValuePrecisePosition(double value, boolean relative)Get the position of the value based on scale.- Parameters:
value
- the value to find its position. Support value out of range.relative
- return the position relative to the left/bottom bound of the scale if true. If false, return the absolute position which has the scale bounds counted.- Returns:
- position in pixels
-
getPositionValue
public double getPositionValue(int position, boolean relative)Get the corresponding value on the position of the scale.- Parameters:
position
-relative
- if true the position is relative to the left/bottom bound of the scale; if false it is the absolute position.- Returns:
- the value corresponding to the position.
-
getPositionValue
public double getPositionValue(double position, boolean relative)Get the corresponding value on the position of the scale.- Parameters:
position
-relative
- if true the position is relative to the left/bottom bound of the scale; if false it is the absolute position.- Returns:
- the value corresponding to the position.
-
isHorizontal
public boolean isHorizontal()- Specified by:
isHorizontal
in interfaceIScaleProvider
- Returns:
- True if scale is horizontal
-
isShowMaxLabel
public boolean isShowMaxLabel()shows the maximum value of the range as a label- Returns:
- true (default) if shown
-
isShowMinLabel
public boolean isShowMinLabel()shows the minimum value of the range as a label- Returns:
- true (default) if shown
-
layout
protected void layout()- Overrides:
layout
in classorg.eclipse.draw2d.Figure
-
figureLayout
public void figureLayout()Simple call oforg.eclipse.draw2d.Figure.layout()
-
setBounds
public void setBounds(org.eclipse.draw2d.geometry.Rectangle rect)- Specified by:
setBounds
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setBounds
in classorg.eclipse.draw2d.Figure
-
setFont
public void setFont(org.eclipse.swt.graphics.Font font)- Specified by:
setFont
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setFont
in classAbstractScale
-
setForegroundColor
public void setForegroundColor(org.eclipse.swt.graphics.Color color)- Specified by:
setForegroundColor
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setForegroundColor
in classorg.eclipse.draw2d.Figure
-
setOrientation
sets the orientation- Parameters:
orientation
- the orientation to set
-
setShowMaxLabel
public void setShowMaxLabel(boolean b)sets the visibility of the maximum label- Parameters:
b
- show maximal value as a label
-
setShowMinLabel
public void setShowMinLabel(boolean b)sets the visibility of the minimum label- Parameters:
b
- show minimum value as a label
-
getLocalRange
- Returns:
- range used for axis (not range given by data)
-
setLocalRange
- Parameters:
localRange
-
-
updateTick
public void updateTick()Updates the tick, recalculate all parameters, such as margin, length...- Specified by:
updateTick
in classAbstractScale
-
useLocalCoordinates
protected boolean useLocalCoordinates()- Overrides:
useLocalCoordinates
in classorg.eclipse.draw2d.Figure
-
getScaleRange
- Specified by:
getScaleRange
in interfaceIScaleProvider
- Returns:
- scale range
-
getDimension
public org.eclipse.draw2d.geometry.Dimension getDimension(java.lang.Object obj)Calculate dimension of a textual form of object- Specified by:
getDimension
in interfaceIScaleProvider
- Parameters:
obj
- object- Returns:
- dimension
-
isPrimary
public boolean isPrimary()- Specified by:
isPrimary
in interfaceIScaleProvider
- Returns:
- true if axis is a primary one (i.e. left for y and bottom for x)
-
getLabel
public double getLabel(double value)Override to provide custom axis labels.- Specified by:
getLabel
in interfaceIScaleProvider
- Returns:
- double value of label
-
isLabelCustomised
public boolean isLabelCustomised()- Specified by:
isLabelCustomised
in interfaceIScaleProvider
- Returns:
- true if axis labels are customised
-
hasTicksAtEnds
public boolean hasTicksAtEnds()- Specified by:
hasTicksAtEnds
in interfaceIScaleProvider
- Returns:
- true if ticks at end of axis are shown
-