Class Axis
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
-
- org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
-
- org.eclipse.nebula.visualization.xygraph.figures.Axis
-
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure
,IScaleProvider
- Direct Known Subclasses:
DAxis
public class Axis extends LinearScale
The axis figure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
Axis.AxisMouseListener
Listener to mouse events, performs panning and some zooms Is very similar to the PlotMouseListener, but unclear how easy/useful it would be to base them on the same code.-
Nested classes/interfaces inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
LinearScale.Orientation
-
Nested classes/interfaces inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
AbstractScale.LabelSide
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
armed
private boolean
autoScale
private double
autoScaleThreshold
private org.eclipse.swt.graphics.RGB
colorRGB
private boolean
dashGridLine
private org.eclipse.draw2d.geometry.Point
end
private org.eclipse.swt.graphics.Cursor
grabbing
private Grid
grid
private static double
HIGHEST_LOG_10
private boolean
isInverted
protected java.util.List<IAxisListener>
listeners
private static double
LOWEST_LOG_10
private org.eclipse.swt.graphics.Color
majorGridColor
private org.eclipse.swt.graphics.RGB
majorGridColorRGB
private org.eclipse.swt.graphics.Color
minorGridColor
private ZoomType
previousZoomType
Field used to remember the previous zoom type usedprivate org.eclipse.swt.graphics.Color
revertBackColor
private org.eclipse.swt.graphics.FontData
scaleFontData
private boolean
showMajorGrid
private boolean
showMinorGrid
private org.eclipse.draw2d.geometry.Point
start
private Range
startRange
private java.lang.String
title
private org.eclipse.swt.graphics.Font
titleFont
private org.eclipse.swt.graphics.FontData
titleFontData
private java.util.List<Trace>
traceList
private IXYGraph
xyGraph
(package private) static double
ZOOM_RATIO
The ratio of the shrink/expand area for one zoom.(package private) static int
ZOOM_SPEED
The auto zoom interval in ms.private ZoomType
zoomType
-
Fields inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
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 Axis(java.lang.String title, boolean yAxis)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(IAxisListener listener)
void
addTrace(Trace trace)
Add a trace to the axis.void
dataChanged(IDataProvider dataProvider)
private void
fireAxisAutoScaleChanged(boolean oldAutoScale, boolean newAutoScale)
private void
fireAxisForegroundColorChanged(org.eclipse.swt.graphics.Color oldColor, org.eclipse.swt.graphics.Color newColor)
private void
fireAxisLogScaleChanged(boolean old, boolean logScale)
protected void
fireAxisRangeChanged(Range old_range, Range new_range)
private void
fireAxisTitleChanged(java.lang.String oldTitle, java.lang.String newTitle)
protected void
fireRevalidated()
boolean
getAutoScale()
double
getAutoScaleThreshold()
org.eclipse.swt.graphics.RGB
getForegroundColorRGB()
Grid
getGrid()
org.eclipse.swt.graphics.Color
getMajorGridColor()
org.eclipse.swt.graphics.RGB
getMajorGridColorRGB()
org.eclipse.swt.graphics.Color
getMinorGridColor()
org.eclipse.draw2d.geometry.Dimension
getPreferredSize(int wHint, int hHint)
org.eclipse.swt.graphics.FontData
getScaleFontData()
java.lang.String
getTitle()
org.eclipse.swt.graphics.Font
getTitleFont()
org.eclipse.swt.graphics.FontData
getTitleFontData()
Range
getTraceDataRange()
protected java.util.List<Trace>
getTraceList()
IXYGraph
getXYGraph()
boolean
isAutoScale()
boolean
isDashGridLine()
boolean
isInverted()
Returns True if axis is inverted, False otherwiseboolean
isOnPrimarySide()
boolean
isShowMajorGrid()
boolean
isShowMinorGrid()
private boolean
isValidZoomType(ZoomType zoom)
boolean
isYAxis()
protected void
layout()
protected void
paintClientArea(org.eclipse.draw2d.Graphics graphics)
private void
pan()
Pan axis according to start/end from mouse listenerprotected void
pan(Range temp, double t1, double t2)
Pan the axisprotected boolean
panChecked(Range temp, double t1, double t2)
Pan the axis and check if new range is okayboolean
performAutoScale(boolean force)
Perform an auto-scale: Axis limits are set to the value range of the traces on this axis.boolean
removeListener(IAxisListener listener)
boolean
removeTrace(Trace trace)
Remove a trace from the axis.void
setAutoScale(boolean autoScale)
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.void
setBackgroundColor(org.eclipse.swt.graphics.Color bg)
void
setDashGridLine(boolean dashGridLine)
void
setFont(org.eclipse.swt.graphics.Font font)
void
setForegroundColor(org.eclipse.swt.graphics.Color color)
void
setGrid(Grid grid)
void
setInverted(boolean isInverted)
Inverts the axis if set to Truevoid
setLogScale(boolean enabled)
void
setMajorGridColor(org.eclipse.swt.graphics.Color majorGridColor)
void
setMinorGridColor(org.eclipse.swt.graphics.Color minorGridColor)
void
setMinorTicksVisible(boolean minorTicksVisible)
void
setPrimarySide(boolean onPrimarySide)
Set the axis on primary side (Bottom/Left) or secondary side (Top/Right).void
setRange(double lower, double upper)
set the scale rangevoid
setShowMajorGrid(boolean showMajorGrid)
void
setShowMinorGrid(boolean showMinorGrid)
void
setTitle(java.lang.String title)
void
setTitleFont(org.eclipse.swt.graphics.Font titleFont)
void
setVisible(boolean visible)
void
setXYGraph(IXYGraph xyGraph)
void
setYAxis(boolean isYAxis)
Set this axis as Y-Axis or X-Axis.void
setZoomType(ZoomType zoomType)
java.lang.String
toString()
void
zoomInOut(double center, double factor)
Zoom axis-
Methods inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
createLinearScaleTickLabels, createLinearScaleTickMarks, figureLayout, getDimension, getLabel, getLength, getLocalRange, getMargin, getMargin, getOrientation, getPositionValue, getPositionValue, getScaleRange, getScaleTickLabels, getScaleTickMarks, getTickLength, getTicksProvider, getValuePosition, getValuePrecisePosition, hasTicksAtEnds, isHorizontal, isLabelCustomised, isPrimary, isShowMaxLabel, isShowMinLabel, setBounds, setLength, setLocalRange, setMargin, setOrientation, setShowMaxLabel, setShowMinLabel, updateTick, useLocalCoordinates
-
Methods inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
format, format, getFormatPattern, getMajorGridStep, getMajorTickMarkStepHint, getMinorTickMarkStepHint, getRange, getTickLabelSide, getTickLablesSide, getTimeUnit, internalSetAutoFormat, internalSetFormatPattern, internalSetLogScaleEnabled, internalSetRange, isAutoFormat, isDateEnabled, isDirty, isLogScaleEnabled, isMinorTicksVisible, isScaleLineVisible, setAutoFormat, setDateEnabled, setDirty, setFormatPattern, setMajorGridStep, setMajorTickMarkStepHint, setMinorTickMarkStepHint, 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, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBorder, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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 Detail
-
ZOOM_RATIO
static final double ZOOM_RATIO
The ratio of the shrink/expand area for one zoom.- See Also:
- Constant Field Values
-
ZOOM_SPEED
static final int ZOOM_SPEED
The auto zoom interval in ms.- See Also:
- Constant Field Values
-
title
private java.lang.String title
-
traceList
private final java.util.List<Trace> traceList
-
xyGraph
private IXYGraph xyGraph
-
grid
private Grid grid
-
titleFont
private org.eclipse.swt.graphics.Font titleFont
-
titleFontData
private org.eclipse.swt.graphics.FontData titleFontData
-
scaleFontData
private org.eclipse.swt.graphics.FontData scaleFontData
-
autoScale
private boolean autoScale
-
showMajorGrid
private boolean showMajorGrid
-
showMinorGrid
private boolean showMinorGrid
-
isInverted
private boolean isInverted
-
majorGridColor
private org.eclipse.swt.graphics.Color majorGridColor
-
minorGridColor
private org.eclipse.swt.graphics.Color minorGridColor
-
dashGridLine
private boolean dashGridLine
-
autoScaleThreshold
private double autoScaleThreshold
-
listeners
protected final java.util.List<IAxisListener> listeners
-
zoomType
private ZoomType zoomType
-
start
private org.eclipse.draw2d.geometry.Point start
-
end
private org.eclipse.draw2d.geometry.Point end
-
armed
private boolean armed
-
startRange
private Range startRange
-
grabbing
private final org.eclipse.swt.graphics.Cursor grabbing
-
revertBackColor
private org.eclipse.swt.graphics.Color revertBackColor
-
colorRGB
private org.eclipse.swt.graphics.RGB colorRGB
-
majorGridColorRGB
private org.eclipse.swt.graphics.RGB majorGridColorRGB
-
LOWEST_LOG_10
private static final double LOWEST_LOG_10
- See Also:
- Constant Field Values
-
HIGHEST_LOG_10
private static final double HIGHEST_LOG_10
- See Also:
- Constant Field Values
-
previousZoomType
private ZoomType previousZoomType
Field used to remember the previous zoom type used
-
-
Method Detail
-
setFont
public void setFont(org.eclipse.swt.graphics.Font font)
- Specified by:
setFont
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setFont
in classLinearScale
-
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()
-
setRange
public void setRange(double lower, double upper)
Description copied from class:AbstractScale
set the scale range- Overrides:
setRange
in classAbstractScale
- Parameters:
lower
- the lower limitupper
- 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 classLinearScale
-
setVisible
public void setVisible(boolean visible)
- Specified by:
setVisible
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setVisible
in classorg.eclipse.draw2d.Figure
-
setForegroundColor
public void setForegroundColor(org.eclipse.swt.graphics.Color color)
- Specified by:
setForegroundColor
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setForegroundColor
in classLinearScale
-
setMinorTicksVisible
public void setMinorTicksVisible(boolean minorTicksVisible)
- Overrides:
setMinorTicksVisible
in classAbstractScale
- Parameters:
minorTicksVisible
- the minorTicksVisible to set
-
getForegroundColorRGB
public org.eclipse.swt.graphics.RGB getForegroundColorRGB()
-
fireAxisForegroundColorChanged
private void fireAxisForegroundColorChanged(org.eclipse.swt.graphics.Color oldColor, org.eclipse.swt.graphics.Color newColor)
-
setBackgroundColor
public void setBackgroundColor(org.eclipse.swt.graphics.Color bg)
- Specified by:
setBackgroundColor
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setBackgroundColor
in classorg.eclipse.draw2d.Figure
-
getPreferredSize
public org.eclipse.draw2d.geometry.Dimension getPreferredSize(int wHint, int hHint)
- Specified by:
getPreferredSize
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
getPreferredSize
in classLinearScale
-
paintClientArea
protected void paintClientArea(org.eclipse.draw2d.Graphics graphics)
- Overrides:
paintClientArea
in classorg.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
-
fireAxisTitleChanged
private void fireAxisTitleChanged(java.lang.String oldTitle, java.lang.String newTitle)
-
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
-
fireAxisAutoScaleChanged
private void fireAxisAutoScaleChanged(boolean oldAutoScale, boolean newAutoScale)
-
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 classjava.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
-
isValidZoomType
private boolean isValidZoomType(ZoomType zoom)
- Parameters:
zoom
- Zoom Type- Returns:
true
if the zoom type is applicable to this axis
-
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
private void pan()
Pan axis according to start/end from mouse listener
-
pan
protected void pan(Range temp, double t1, double t2)
Pan the axis- Parameters:
temp
- Original axis range before the panning startedt1
- Start of the panning movet2
- 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 startedt1
- Start of the panning movet2
- 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 zoomfactor
- 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 classAbstractScale
- Parameters:
enabled
- true if enabling log scales- Throws:
java.lang.IllegalStateException
-
fireAxisLogScaleChanged
private void fireAxisLogScaleChanged(boolean old, boolean logScale)
-
-