Class Annotation
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.nebula.visualization.xygraph.figures.Annotation
-
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure,IDataProviderListener,IAxisListener
- Direct Known Subclasses:
CircleAnnotation,CrossAnnotation
public class Annotation extends org.eclipse.draw2d.Figure implements IAxisListener, IDataProviderListener
Annotation Figure. Annotation could be used to indicate the information for a particular point.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAnnotation.AnnotationDraggerstatic classAnnotation.CursorLineStyle(package private) classAnnotation.InfoLabelDragger(package private) classAnnotation.Pointer
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.swt.graphics.ColorannotationColorprivate org.eclipse.swt.graphics.RGBannotationColorRGBprivate static intARROW_LINE_LENGTHprivate org.eclipse.draw2d.geometry.PointcurrentPositionprotected ISamplecurrentSnappedSampleprivate static intCURSOR_LINE_LENGTHprivate Annotation.CursorLineStylecursorLineStyleprivate doubledxprivate doubledyprivate org.eclipse.swt.graphics.FontDatafontDataprivate org.eclipse.draw2d.PolylinehLineprivate org.eclipse.draw2d.LabelinfoLabelprivate booleaninfoLabelArmedprivate booleanknowX0Y0private IAnnotationLabelProviderlabelProviderprivate java.util.List<IAnnotationListener>listenersprivate java.lang.Stringnameprivate static intPOINT_SIZEprivate Annotation.Pointerpointerprotected booleanpointerDraggedprivate booleanshowNameprivate booleanshowPositionprivate booleanshowSampleInfoprotected Tracetraceprivate org.eclipse.draw2d.PolylinevLineprivate doublex0protected AxisxAxisprotected doublexValueprivate IXYGraphxyGraphprivate doubley0protected AxisyAxisprotected doubleyValue
-
Constructor Summary
Constructors Constructor Description Annotation(java.lang.String name, Axis xAxis, Axis yAxis)Construct a free annotation.Annotation(java.lang.String name, Trace trace)Construct an annotation on a trace.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotationListener(IAnnotationListener listener)voidaxisAutoScaleChanged(Axis axis, boolean oldAutoScale, boolean newAutoScale)voidaxisForegroundColorChanged(Axis axis, org.eclipse.swt.graphics.Color oldColor, org.eclipse.swt.graphics.Color newColor)voidaxisLogScaleChanged(Axis axis, boolean old, boolean logScale)voidaxisRangeChanged(Axis axis, Range old_range, Range new_range)This event indicates a change in the axis' value rangevoidaxisRevalidated(Axis axis)This method will be notified by axis whenever the axis is revalidated.voidaxisTitleChanged(Axis axis, java.lang.String oldTitle, java.lang.String newTitle)booleancontainsPoint(int x, int y)voiddataChanged(IDataProvider dataProvider)This method will be notified by data provider whenever the data changed in data providerprivate voidfireAnnotationMoved(double oldX, double oldY, double newX, double newY)org.eclipse.swt.graphics.ColorgetAnnotationColor()org.eclipse.swt.graphics.RGBgetAnnotationColorRGB()org.eclipse.swt.graphics.FontgetAnnotationFont()Annotation.CursorLineStylegetCursorLineStyle()org.eclipse.swt.graphics.FontDatagetFontData()IAnnotationLabelProvidergetLabelProvider()java.lang.StringgetName()TracegetTrace()AxisgetXAxis()doublegetXValue()AxisgetYAxis()doublegetYValue()booleanisFree()booleanisShowName()booleanisShowPosition()booleanisShowSampleInfo()protected voidlayout()protected voidpaintFigure(org.eclipse.draw2d.Graphics graphics)voidremove()voidsetAnnotationColor(org.eclipse.swt.graphics.Color annotationColor)voidsetAnnotationFont(org.eclipse.swt.graphics.Font annotationFont)voidsetCurrentPosition(org.eclipse.draw2d.geometry.Point currentPosition, boolean keepLabelPosition)voidsetCurrentPosition(org.eclipse.draw2d.geometry.Point currentPosition, boolean keepLabelPosition, boolean calcValueFromPosition)voidsetCurrentSnappedSample(ISample currentSnappedSample, boolean keepLabelPosition)voidsetCursorLineStyle(Annotation.CursorLineStyle cursorLineStyle)voidsetdxdy(double dx, double dy)voidsetFont(org.eclipse.swt.graphics.Font f)voidsetFree(Axis xAxis, Axis yAxis)Make the annotation free.voidsetLabelProvider(IAnnotationLabelProvider labelProvider)voidsetLocation(double x, double y)Sets x an y location.voidsetName(java.lang.String name)voidsetShowName(boolean showName)voidsetShowPosition(boolean showPosition)voidsetShowSampleInfo(boolean showSampleInfo)voidsetTrace(Trace trace)voidsetValues(double x, double y)Set the position of the annotation based on plot valuesvoidsetXAxis(Axis axis)voidsetXYGraph(IXYGraph xyGraph)voidsetYAxis(Axis axis)voidtoFront()Sets annotation order to frontprivate voidupdatedxdyFromX0Y0()update (dx, dy) if (x0, y0) has been updated by dragging.private voidupdateInfoLabelText()private voidupdateInfoLabelText(boolean updateX0Y0)protected voidupdateToDefaultPosition()move the annotation to the center of the plot area or trace.voidupdateX0Y0Fromdxdy(org.eclipse.draw2d.geometry.Dimension size)update (x0, y0) if it is unknown.-
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, 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, paint, paintBorder, paintChildren, paintClientArea, 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, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
-
-
-
-
Field Detail
-
labelProvider
private IAnnotationLabelProvider labelProvider
-
xAxis
protected Axis xAxis
-
yAxis
protected Axis yAxis
-
name
private java.lang.String name
-
fontData
private org.eclipse.swt.graphics.FontData fontData
-
cursorLineStyle
private Annotation.CursorLineStyle cursorLineStyle
-
currentPosition
private org.eclipse.draw2d.geometry.Point currentPosition
-
xValue
protected double xValue
-
yValue
protected double yValue
-
trace
protected Trace trace
-
currentSnappedSample
protected ISample currentSnappedSample
-
showName
private boolean showName
-
showSampleInfo
private boolean showSampleInfo
-
showPosition
private boolean showPosition
-
annotationColor
private org.eclipse.swt.graphics.Color annotationColor
-
annotationColorRGB
private org.eclipse.swt.graphics.RGB annotationColorRGB
-
infoLabel
private org.eclipse.draw2d.Label infoLabel
-
dx
private double dx
-
dy
private double dy
-
x0
private double x0
-
y0
private double y0
-
knowX0Y0
private boolean knowX0Y0
-
infoLabelArmed
private boolean infoLabelArmed
-
pointer
private Annotation.Pointer pointer
-
vLine
private org.eclipse.draw2d.Polyline vLine
-
hLine
private org.eclipse.draw2d.Polyline hLine
-
xyGraph
private IXYGraph xyGraph
-
POINT_SIZE
private static final int POINT_SIZE
- See Also:
- Constant Field Values
-
CURSOR_LINE_LENGTH
private static final int CURSOR_LINE_LENGTH
- See Also:
- Constant Field Values
-
ARROW_LINE_LENGTH
private static final int ARROW_LINE_LENGTH
- See Also:
- Constant Field Values
-
pointerDragged
protected boolean pointerDragged
-
listeners
private java.util.List<IAnnotationListener> listeners
-
-
Constructor Detail
-
Annotation
public Annotation(java.lang.String name, Trace trace)Construct an annotation on a trace.- Parameters:
name- the name of the annotation.trace- the trace which the annotation will snap to.
-
-
Method Detail
-
remove
public void remove()
-
addAnnotationListener
public void addAnnotationListener(IAnnotationListener listener)
-
fireAnnotationMoved
private void fireAnnotationMoved(double oldX, double oldY, double newX, double newY)
-
containsPoint
public boolean containsPoint(int x, int y)- Specified by:
containsPointin interfaceorg.eclipse.draw2d.IFigure- Overrides:
containsPointin classorg.eclipse.draw2d.Figure
-
layout
protected void layout()
- Overrides:
layoutin classorg.eclipse.draw2d.Figure
-
paintFigure
protected void paintFigure(org.eclipse.draw2d.Graphics graphics)
- Overrides:
paintFigurein classorg.eclipse.draw2d.Figure
-
updateX0Y0Fromdxdy
public void updateX0Y0Fromdxdy(org.eclipse.draw2d.geometry.Dimension size)
update (x0, y0) if it is unknown.- Parameters:
size- the label size
-
updatedxdyFromX0Y0
private void updatedxdyFromX0Y0()
update (dx, dy) if (x0, y0) has been updated by dragging.- Parameters:
size- the label size
-
updateToDefaultPosition
protected void updateToDefaultPosition()
move the annotation to the center of the plot area or trace.
-
setValues
public void setValues(double x, double y)Set the position of the annotation based on plot values- Parameters:
x- Position as value on the X axisy- Position as value on the Y axis- See Also:
for setting the position based on screen coordinates
-
updateInfoLabelText
private void updateInfoLabelText(boolean updateX0Y0)
-
updateInfoLabelText
private void updateInfoLabelText()
-
setXAxis
public void setXAxis(Axis axis)
- Parameters:
axis- the xAxis to set
-
setYAxis
public void setYAxis(Axis axis)
- Parameters:
axis- the yAxis to set
-
setName
public void setName(java.lang.String name)
- Parameters:
name- the name to set
-
setFont
public void setFont(org.eclipse.swt.graphics.Font f)
- Specified by:
setFontin interfaceorg.eclipse.draw2d.IFigure- Overrides:
setFontin classorg.eclipse.draw2d.Figure
-
getFontData
public org.eclipse.swt.graphics.FontData getFontData()
-
setTrace
public void setTrace(Trace trace)
- Parameters:
trace- the trace to set
-
setFree
public void setFree(Axis xAxis, Axis yAxis)
Make the annotation free.- Parameters:
xAxis-yAxis-
-
isFree
public boolean isFree()
- Returns:
- true if the annotation is free.
-
setShowName
public void setShowName(boolean showName)
- Parameters:
showName- the showName to set
-
setShowSampleInfo
public void setShowSampleInfo(boolean showSampleInfo)
- Parameters:
showSampleInfo- the showSampleInfo to set
-
setShowPosition
public void setShowPosition(boolean showPosition)
- Parameters:
showPosition- the showPosition to set
-
setAnnotationColor
public void setAnnotationColor(org.eclipse.swt.graphics.Color annotationColor)
- Parameters:
annotationColor- the annotationColor to set
-
setAnnotationFont
public void setAnnotationFont(org.eclipse.swt.graphics.Font annotationFont)
- Parameters:
annotationFont- the annotationFont to set
-
getAnnotationFont
public org.eclipse.swt.graphics.Font getAnnotationFont()
- Returns:
- annotation font
-
setCursorLineStyle
public void setCursorLineStyle(Annotation.CursorLineStyle cursorLineStyle)
- Parameters:
cursorLineStyle- the cursorLineStyle to set
-
setCurrentPosition
public void setCurrentPosition(org.eclipse.draw2d.geometry.Point currentPosition, boolean keepLabelPosition, boolean calcValueFromPosition)- Parameters:
currentPosition- the currentPosition to set
-
setCurrentPosition
public void setCurrentPosition(org.eclipse.draw2d.geometry.Point currentPosition, boolean keepLabelPosition)
-
setCurrentSnappedSample
public void setCurrentSnappedSample(ISample currentSnappedSample, boolean keepLabelPosition)
- Parameters:
currentSnappedSample- the currentSnappedSample to setkeepLabelPosition-
-
axisRevalidated
public void axisRevalidated(Axis axis)
Description copied from interface:IAxisListenerThis method will be notified by axis whenever the axis is revalidated.- Specified by:
axisRevalidatedin interfaceIAxisListener
-
axisRangeChanged
public void axisRangeChanged(Axis axis, Range old_range, Range new_range)
Description copied from interface:IAxisListenerThis event indicates a change in the axis' value range- Specified by:
axisRangeChangedin interfaceIAxisListener
-
dataChanged
public void dataChanged(IDataProvider dataProvider)
Description copied from interface:IDataProviderListenerThis method will be notified by data provider whenever the data changed in data provider- Specified by:
dataChangedin interfaceIDataProviderListener
-
setXYGraph
public void setXYGraph(IXYGraph xyGraph)
- Parameters:
xyGraph- the xyGraph to set
-
setdxdy
public void setdxdy(double dx, double dy)
-
setLocation
public void setLocation(double x, double y)Sets x an y location.- Parameters:
x-y-
-
getXAxis
public Axis getXAxis()
- Returns:
- the xAxis
-
getYAxis
public Axis getYAxis()
- Returns:
- the yAxis
-
getName
public java.lang.String getName()
- Returns:
- the name
-
getXValue
public double getXValue()
- Returns:
- X value, i.e. value of this annotation on the X Axis
-
getYValue
public double getYValue()
- Returns:
- Y value, i.e. value of this annotation on the Y Axis
-
getCursorLineStyle
public Annotation.CursorLineStyle getCursorLineStyle()
- Returns:
- the cursorLineStyle
-
getTrace
public Trace getTrace()
- Returns:
- the trace
-
isShowName
public boolean isShowName()
- Returns:
- the showName
-
isShowSampleInfo
public boolean isShowSampleInfo()
- Returns:
- the showSampleInfo
-
isShowPosition
public boolean isShowPosition()
- Returns:
- the showPosition
-
getAnnotationColor
public org.eclipse.swt.graphics.Color getAnnotationColor()
- Returns:
- the annotationColor
-
getLabelProvider
public IAnnotationLabelProvider getLabelProvider()
-
setLabelProvider
public void setLabelProvider(IAnnotationLabelProvider labelProvider)
-
axisForegroundColorChanged
public void axisForegroundColorChanged(Axis axis, org.eclipse.swt.graphics.Color oldColor, org.eclipse.swt.graphics.Color newColor)
- Specified by:
axisForegroundColorChangedin interfaceIAxisListener
-
axisTitleChanged
public void axisTitleChanged(Axis axis, java.lang.String oldTitle, java.lang.String newTitle)
- Specified by:
axisTitleChangedin interfaceIAxisListener
-
axisAutoScaleChanged
public void axisAutoScaleChanged(Axis axis, boolean oldAutoScale, boolean newAutoScale)
- Specified by:
axisAutoScaleChangedin interfaceIAxisListener
-
axisLogScaleChanged
public void axisLogScaleChanged(Axis axis, boolean old, boolean logScale)
- Specified by:
axisLogScaleChangedin interfaceIAxisListener
-
getAnnotationColorRGB
public org.eclipse.swt.graphics.RGB getAnnotationColorRGB()
-
toFront
public void toFront()
Sets annotation order to front
-
-