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 protected java.util.List<IAxisListener>
listeners
(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.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
Modifier and Type Method Description void
addListener(IAxisListener listener)
void
addTrace(Trace trace)
Add a trace to the axis.void
dataChanged(IDataProvider dataProvider)
protected void
fireAxisRangeChanged(Range old_range, Range new_range)
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()
boolean
isYAxis()
protected void
layout()
protected void
paintClientArea(org.eclipse.draw2d.Graphics graphics)
protected 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 axisMethods 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 Details
-
ZOOM_RATIO
static final double ZOOM_RATIOThe ratio of the shrink/expand area for one zoom.- See Also:
- Constant Field Values
-
ZOOM_SPEED
static final int ZOOM_SPEEDThe auto zoom interval in ms.- See Also:
- Constant Field Values
-
listeners
-
-
Constructor Details
-
Axis
public Axis(java.lang.String title, boolean yAxis)Constructor- Parameters:
title
- title of the axisyAxis
- true if this is the Y-Axis, false if this is the X-Axis.
-
-
Method Details
-
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
-
removeListener
-
fireRevalidated
protected void fireRevalidated() -
fireAxisRangeChanged
-
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() -
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
- 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
Add a trace to the axis.- Parameters:
trace
- the trace to be added.
-
removeTrace
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
-
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
-
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
- Parameters:
xyGraph
- the xyGraph to set
-
getXYGraph
- Returns:
- the graph
-
getTraceList
- Returns:
- traceList
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
dataChanged
-
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
-
setZoomType
- 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
Pan the axis- Parameters:
temp
- Original axis range before the panning startedt1
- Start of the panning movet2
- End of the panning move
-
panChecked
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
- Parameters:
grid
- the grid to set
-
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
-