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) classAxis.AxisMouseListenerListener 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 booleanarmedprivate booleanautoScaleprivate doubleautoScaleThresholdprivate org.eclipse.swt.graphics.RGBcolorRGBprivate booleandashGridLineprivate org.eclipse.draw2d.geometry.Pointendprivate org.eclipse.swt.graphics.Cursorgrabbingprivate Gridgridprivate static doubleHIGHEST_LOG_10private booleanisInvertedprotected java.util.List<IAxisListener>listenersprivate static doubleLOWEST_LOG_10private org.eclipse.swt.graphics.ColormajorGridColorprivate org.eclipse.swt.graphics.RGBmajorGridColorRGBprivate org.eclipse.swt.graphics.ColorminorGridColorprivate ZoomTypepreviousZoomTypeField used to remember the previous zoom type usedprivate org.eclipse.swt.graphics.ColorrevertBackColorprivate org.eclipse.swt.graphics.FontDatascaleFontDataprivate booleanshowMajorGridprivate booleanshowMinorGridprivate org.eclipse.draw2d.geometry.Pointstartprivate RangestartRangeprivate java.lang.Stringtitleprivate org.eclipse.swt.graphics.FonttitleFontprivate org.eclipse.swt.graphics.FontDatatitleFontDataprivate java.util.List<Trace>traceListprivate IXYGraphxyGraph(package private) static doubleZOOM_RATIOThe ratio of the shrink/expand area for one zoom.(package private) static intZOOM_SPEEDThe auto zoom interval in ms.private ZoomTypezoomType-
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 voidaddListener(IAxisListener listener)voidaddTrace(Trace trace)Add a trace to the axis.voiddataChanged(IDataProvider dataProvider)private voidfireAxisAutoScaleChanged(boolean oldAutoScale, boolean newAutoScale)private voidfireAxisForegroundColorChanged(org.eclipse.swt.graphics.Color oldColor, org.eclipse.swt.graphics.Color newColor)private voidfireAxisLogScaleChanged(boolean old, boolean logScale)protected voidfireAxisRangeChanged(Range old_range, Range new_range)private voidfireAxisTitleChanged(java.lang.String oldTitle, java.lang.String newTitle)protected voidfireRevalidated()booleangetAutoScale()doublegetAutoScaleThreshold()org.eclipse.swt.graphics.RGBgetForegroundColorRGB()GridgetGrid()org.eclipse.swt.graphics.ColorgetMajorGridColor()org.eclipse.swt.graphics.RGBgetMajorGridColorRGB()org.eclipse.swt.graphics.ColorgetMinorGridColor()org.eclipse.draw2d.geometry.DimensiongetPreferredSize(int wHint, int hHint)org.eclipse.swt.graphics.FontDatagetScaleFontData()java.lang.StringgetTitle()org.eclipse.swt.graphics.FontgetTitleFont()org.eclipse.swt.graphics.FontDatagetTitleFontData()RangegetTraceDataRange()protected java.util.List<Trace>getTraceList()IXYGraphgetXYGraph()booleanisAutoScale()booleanisDashGridLine()booleanisInverted()Returns True if axis is inverted, False otherwisebooleanisOnPrimarySide()booleanisShowMajorGrid()booleanisShowMinorGrid()private booleanisValidZoomType(ZoomType zoom)booleanisYAxis()protected voidlayout()protected voidpaintClientArea(org.eclipse.draw2d.Graphics graphics)private voidpan()Pan axis according to start/end from mouse listenerprotected voidpan(Range temp, double t1, double t2)Pan the axisprotected booleanpanChecked(Range temp, double t1, double t2)Pan the axis and check if new range is okaybooleanperformAutoScale(boolean force)Perform an auto-scale: Axis limits are set to the value range of the traces on this axis.booleanremoveListener(IAxisListener listener)booleanremoveTrace(Trace trace)Remove a trace from the axis.voidsetAutoScale(boolean autoScale)voidsetAutoScaleThreshold(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.voidsetBackgroundColor(org.eclipse.swt.graphics.Color bg)voidsetDashGridLine(boolean dashGridLine)voidsetFont(org.eclipse.swt.graphics.Font font)voidsetForegroundColor(org.eclipse.swt.graphics.Color color)voidsetGrid(Grid grid)voidsetInverted(boolean isInverted)Inverts the axis if set to TruevoidsetLogScale(boolean enabled)voidsetMajorGridColor(org.eclipse.swt.graphics.Color majorGridColor)voidsetMinorGridColor(org.eclipse.swt.graphics.Color minorGridColor)voidsetMinorTicksVisible(boolean minorTicksVisible)voidsetPrimarySide(boolean onPrimarySide)Set the axis on primary side (Bottom/Left) or secondary side (Top/Right).voidsetRange(double lower, double upper)set the scale rangevoidsetShowMajorGrid(boolean showMajorGrid)voidsetShowMinorGrid(boolean showMinorGrid)voidsetTitle(java.lang.String title)voidsetTitleFont(org.eclipse.swt.graphics.Font titleFont)voidsetVisible(boolean visible)voidsetXYGraph(IXYGraph xyGraph)voidsetYAxis(boolean isYAxis)Set this axis as Y-Axis or X-Axis.voidsetZoomType(ZoomType zoomType)java.lang.StringtoString()voidzoomInOut(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:
setFontin interfaceorg.eclipse.draw2d.IFigure- Overrides:
setFontin 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:AbstractScaleset the scale range- Overrides:
setRangein 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:
layoutin classLinearScale
-
setVisible
public void setVisible(boolean visible)
- Specified by:
setVisiblein interfaceorg.eclipse.draw2d.IFigure- Overrides:
setVisiblein classorg.eclipse.draw2d.Figure
-
setForegroundColor
public void setForegroundColor(org.eclipse.swt.graphics.Color color)
- Specified by:
setForegroundColorin interfaceorg.eclipse.draw2d.IFigure- Overrides:
setForegroundColorin classLinearScale
-
setMinorTicksVisible
public void setMinorTicksVisible(boolean minorTicksVisible)
- Overrides:
setMinorTicksVisiblein 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:
setBackgroundColorin interfaceorg.eclipse.draw2d.IFigure- Overrides:
setBackgroundColorin classorg.eclipse.draw2d.Figure
-
getPreferredSize
public org.eclipse.draw2d.geometry.Dimension getPreferredSize(int wHint, int hHint)- Specified by:
getPreferredSizein interfaceorg.eclipse.draw2d.IFigure- Overrides:
getPreferredSizein classLinearScale
-
paintClientArea
protected void paintClientArea(org.eclipse.draw2d.Graphics graphics)
- Overrides:
paintClientAreain classorg.eclipse.draw2d.Figure
-
getTraceDataRange
public Range getTraceDataRange()
- Returns:
- Range that reflects the minimum and maximum value of all traces
on this axis. Returns
nullif 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:
toStringin 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:
trueif 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:
setLogScalein classAbstractScale- Parameters:
enabled- true if enabling log scales- Throws:
java.lang.IllegalStateException
-
fireAxisLogScaleChanged
private void fireAxisLogScaleChanged(boolean old, boolean logScale)
-
-