Class Plotter
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.nebula.widgets.oscilloscope.multichannel.Plotter
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class Plotter
extends org.eclipse.swt.widgets.Canvas
-
Field Summary
Fields Modifier and Type Field Description static intBASE_CENTERThe base of the line is positioned at the center of the widget.static intCURSOR_START_DEFAULTThe default cursor starting position.static intDEFAULT_HEIGHTThe default comfortable widget height.static intDEFAULT_WIDTHThe default comfortable widget width.static intLINE_WIDTH_DEFAULTThe default line width.static intPROGRESSION_DEFAULTThe default tail fade percentagestatic intSTEADYPOSITION_75PERCENTSteady position @ 75% of graph.static intTAILFADE_DEFAULTThe default amount of tail fading in percentages (25).static intTAILFADE_NONENo tailfade.static intTAILFADE_PERCENTAGEThe default tail fade percentagestatic intTAILSIZE_DEFAULTThe default tail size is 75% of the width.static intTAILSIZE_FILLWill draw a tail from the left border but is only valid if the boolean in#setSteady(boolean, int)was set to true, will default toTAILSIZE_MAXotherwise.static intTAILSIZE_MAXWill draw a maximum tail. -
Constructor Summary
Constructors Constructor Description Plotter(int channels, org.eclipse.swt.widgets.Composite parent, int style)Creates a new plotter withchannelschannels.Plotter(int channels, org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.swt.graphics.Color backgroundColor, org.eclipse.swt.graphics.Color foregroundColor)Creates a new plotter withchannelschannels -
Method Summary
Modifier and Type Method Description protected voidcontrolMoved(org.eclipse.swt.widgets.Event e)protected voidcontrolResized(org.eclipse.swt.widgets.Event e)protected intConvertValueToScreenPosition(int Value, int ScreenHeight)intgetBase(int channel)This method can be called outside of the UI thread.intgetBaseOffset(int channel)Gets the relative location where the line is drawn in the widget.java.lang.StringgetChannelName(int channel)get the descriptive name of the channelintgetChannels()Returns the number of channels on the plotter This method can be called outside of the UI thread.java.lang.StringgetData(boolean addHeader)Returns the data in CSV format using the semicolon (;) as separator and delegating togetData(boolean, String).java.lang.StringgetData(boolean addHeader, java.lang.String separator)This method returns the data in csv format using the passed separator as field separator. if addHeader is true a header is added based on the names of the channels.org.eclipse.swt.graphics.ColorgetForeground(int channel)This method can be called outside of the UI thread.intgetLineWidth(int channel)This method can be called outside of the UI thread.intgetRangeHighValue()intgetRangeLowValue()intgetTailFade(int channel)Gets the percentage of tail that must be faded out.intgetTailSize(int channel)Returns the size of the tail.booleanisAntiAlias(int channel)This method can be called outside of the UI thread.booleanisConnect(int channel)This method can be called outside of the UI thread.booleanisFade(int channel)This method can be called outside of the UI thread.booleanisPercentage(int channel)This method can be called outside of the UI thread.booleanisSteady(int channel)This method can be called outside of the UI thread.protected voidpaintControl(org.eclipse.swt.widgets.Event e)protected voidPositionPolyLine(int[] l1)voidsetAntialias(int channel, boolean antialias)Sets if the line must be anti-aliased which uses more processing power in return of a smoother image.voidsetBaseOffset(int channel, int newBaseOffset)Gets the relative location where the line is drawn in the widget, the default isBASE_CENTERwhich is in the middle of the plotter.voidSetChannelName(int channel, java.lang.String name)Set the descriptive name of the channelvoidsetConnect(int channel, boolean connectHeadAndTail)Connects head and tail only if tail size isTAILSIZE_MAXand no fading.voidsetFade(int channel, boolean fade)Sets fade mode so that a percentage of the tail will be faded out at the costs of extra CPU utilization (no beauty without pain or as the Dutch say: "Wie mooi wil gaan moet pijn doorstaan").voidsetForeground(int channel, org.eclipse.swt.graphics.Color color)Sets the foreground color for the supplied channel.voidsetLineWidth(int channel, int lineWidth)Sets the line width.voidsetPercentage(int channel, boolean percentage)If set to true then the values are treated as percentages of the available space rather than absolute values.voidsetRange(int lowValue, int highValue)voidsetSteady(int channel, boolean steady, int steadyPosition)If steady is true the graph will draw on a steady position instead of advancing.voidsetTailFade(int channel, int newTailFade)Sets the percentage of tail that must be faded out.voidsetTailSize(int channel, int newSize)The tail size defaults to TAILSIZE_DEFAULT which is 75% of the width.voidsetValue(int channel, int value)Sets a value to be drawn relative to the center of the channel.protected voidwidgetDisposed(org.eclipse.swt.widgets.Event e)Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIMEMethods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateMethods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
BASE_CENTER
public static final int BASE_CENTERThe base of the line is positioned at the center of the widget.- See Also:
#setBaseOffset(int), Constant Field Values
-
CURSOR_START_DEFAULT
public static final int CURSOR_START_DEFAULTThe default cursor starting position.- See Also:
- Constant Field Values
-
DEFAULT_HEIGHT
public static final int DEFAULT_HEIGHTThe default comfortable widget height.- See Also:
- Constant Field Values
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTHThe default comfortable widget width.- See Also:
- Constant Field Values
-
LINE_WIDTH_DEFAULT
public static final int LINE_WIDTH_DEFAULTThe default line width.- See Also:
- Constant Field Values
-
PROGRESSION_DEFAULT
public static final int PROGRESSION_DEFAULTThe default tail fade percentage- See Also:
- Constant Field Values
-
STEADYPOSITION_75PERCENT
public static final int STEADYPOSITION_75PERCENTSteady position @ 75% of graph.- See Also:
- Constant Field Values
-
TAILFADE_DEFAULT
public static final int TAILFADE_DEFAULTThe default amount of tail fading in percentages (25).- See Also:
- Constant Field Values
-
TAILFADE_NONE
public static final int TAILFADE_NONENo tailfade.- See Also:
- Constant Field Values
-
TAILFADE_PERCENTAGE
public static final int TAILFADE_PERCENTAGEThe default tail fade percentage- See Also:
- Constant Field Values
-
TAILSIZE_DEFAULT
public static final int TAILSIZE_DEFAULTThe default tail size is 75% of the width.- See Also:
- Constant Field Values
-
TAILSIZE_FILL
public static final int TAILSIZE_FILLWill draw a tail from the left border but is only valid if the boolean in#setSteady(boolean, int)was set to true, will default toTAILSIZE_MAXotherwise.- See Also:
- Constant Field Values
-
TAILSIZE_MAX
public static final int TAILSIZE_MAXWill draw a maximum tail.- See Also:
- Constant Field Values
-
-
Constructor Details
-
Plotter
public Plotter(int channels, org.eclipse.swt.widgets.Composite parent, int style)Creates a new plotter withchannelschannels.- Parameters:
channels-parent-style-
-
Plotter
public Plotter(int channels, org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.swt.graphics.Color backgroundColor, org.eclipse.swt.graphics.Color foregroundColor)Creates a new plotter withchannelschannels- Parameters:
channels-parent-style-backgroundColor- if null use default backgroundforegroundColor- if null use default foreground
-
-
Method Details
-
paintControl
protected void paintControl(org.eclipse.swt.widgets.Event e) -
setValue
public void setValue(int channel, int value)Sets a value to be drawn relative to the center of the channel. Supply a positive or negative value. This method will only accept values if the width of the plotter > 0. The values will be stored in a stack and popped once a value is needed. The size of the stack is the width of the widget. If you resize the widget, the old stack will be copied into a new stack with the new capacity. This method can be called outside of the UI thread.- Parameters:
channel-value- which is an absolute value or a percentage- See Also:
isPercentage(int),setBaseOffset(int, int)
-
getRangeLowValue
public int getRangeLowValue()- Returns:
- the value represented by the bottom of the plotter
-
getRangeHighValue
public int getRangeHighValue()- Returns:
- the value represented by the top of the plotter
-
PositionPolyLine
protected void PositionPolyLine(int[] l1) -
ConvertValueToScreenPosition
protected int ConvertValueToScreenPosition(int Value, int ScreenHeight) -
setRange
public void setRange(int lowValue, int highValue) -
getData
public java.lang.String getData(boolean addHeader)Returns the data in CSV format using the semicolon (;) as separator and delegating togetData(boolean, String).- Parameters:
addHeader- true to add the header- Returns:
- the CSV string.
- See Also:
getData(boolean, String)
-
getData
public java.lang.String getData(boolean addHeader, java.lang.String separator)This method returns the data in csv format using the passed separator as field separator. if addHeader is true a header is added based on the names of the channels. UseSetChannelName(int, String)to set the names. -
SetChannelName
public void SetChannelName(int channel, java.lang.String name)Set the descriptive name of the channel- Parameters:
channel- the channel to set the name forname- the descriptive name
-
getChannelName
public java.lang.String getChannelName(int channel)get the descriptive name of the channel- Parameters:
channel- the channel to get the name from returns the descriptive name
-
setSteady
public void setSteady(int channel, boolean steady, int steadyPosition)If steady is true the graph will draw on a steady position instead of advancing. This method can be called outside of the UI thread.- Parameters:
steady-steadyPosition-
-
isSteady
public boolean isSteady(int channel)This method can be called outside of the UI thread.- Returns:
- boolean steady indicator
- See Also:
Oscilloscope#setSteady(boolean, int)
-
getBase
public int getBase(int channel)This method can be called outside of the UI thread.- Returns:
- the base of the line.
-
getBaseOffset
public int getBaseOffset(int channel)Gets the relative location where the line is drawn in the widget. This method can be called outside of the UI thread.- Returns:
- baseOffset
-
getChannels
public int getChannels()Returns the number of channels on the plotter This method can be called outside of the UI thread.- Returns:
- int, number of channels.
-
getForeground
public org.eclipse.swt.graphics.Color getForeground(int channel)This method can be called outside of the UI thread.- Parameters:
channel-- Returns:
- the foreground color associated with the supplied channel.
-
getLineWidth
public int getLineWidth(int channel)This method can be called outside of the UI thread.- Returns:
- int, the width of the line.
- See Also:
#setLineWidth(int)
-
getTailFade
public int getTailFade(int channel)Gets the percentage of tail that must be faded out. This method can be called outside of the UI thread.- Returns:
- int percentage
- See Also:
#setFade(boolean)
-
getTailSize
public int getTailSize(int channel)Returns the size of the tail. This method can be called outside of the UI thread.- Returns:
- int
- See Also:
#setTailSize(int),TAILSIZE_DEFAULT,TAILSIZE_FILL,TAILSIZE_MAX
-
isConnect
public boolean isConnect(int channel)This method can be called outside of the UI thread.- Returns:
- boolean, true if the tail and the head of the graph must be connected
if tail size is
TAILSIZE_MAXno fading graph.
-
isFade
public boolean isFade(int channel)This method can be called outside of the UI thread.- Returns:
- boolean fade
- See Also:
#setFade(boolean)
-
isPercentage
public boolean isPercentage(int channel)This method can be called outside of the UI thread.- Returns:
- boolean
- See Also:
#setPercentage(boolean)
-
isAntiAlias
public boolean isAntiAlias(int channel)This method can be called outside of the UI thread.- Returns:
- boolean anti-alias indicator
- See Also:
Oscilloscope.setAntialias(int, boolean)
-
setTailSize
public void setTailSize(int channel, int newSize)The tail size defaults to TAILSIZE_DEFAULT which is 75% of the width. Setting it with TAILSIZE_MAX will leave one pixel between the tail and the head. All values are absolute except TAILSIZE*. If the width is smaller then the tail size then the tail size will behave like TAILSIZE_MAX.- Parameters:
size- the size of the tail- See Also:
#getTailSize(),TAILSIZE_DEFAULT,TAILSIZE_FILL,TAILSIZE_MAX
-
widgetDisposed
protected void widgetDisposed(org.eclipse.swt.widgets.Event e) -
controlMoved
protected void controlMoved(org.eclipse.swt.widgets.Event e) -
controlResized
protected void controlResized(org.eclipse.swt.widgets.Event e) -
setTailFade
public void setTailFade(int channel, int newTailFade)Sets the percentage of tail that must be faded out. If you supply 100 then the tail is faded out all the way to the top. The effect will become increasingly less obvious. This method can be called outside of the UI thread.- Parameters:
tailFade-
-
setFade
public void setFade(int channel, boolean fade)Sets fade mode so that a percentage of the tail will be faded out at the costs of extra CPU utilization (no beauty without pain or as the Dutch say: "Wie mooi wil gaan moet pijn doorstaan"). The reason for this is that each pixel must be drawn separately with alpha faded in instead of the elegantGC.drawPolygon(int[])routine which does not support alpha blending.In addition to this, set the percentage of tail that must be faded out
#setTailFade(int).This method can be called outside of the UI thread.
- Parameters:
fade- true or false- See Also:
#setTailFade(int)
-
setForeground
public void setForeground(int channel, org.eclipse.swt.graphics.Color color)Sets the foreground color for the supplied channel. This method can be called outside of the UI thread.- Parameters:
channel-color-
-
setLineWidth
public void setLineWidth(int channel, int lineWidth)Sets the line width. A value equal or below zero is ignored. The default width is 1. This method can be called outside of the UI thread.- Parameters:
lineWidth-
-
setPercentage
public void setPercentage(int channel, boolean percentage)If set to true then the values are treated as percentages of the available space rather than absolute values. This will scale the amplitudes if the control is resized. Default is false. This method can be called outside of the UI thread.- Parameters:
percentage- true if percentages
-
setBaseOffset
public void setBaseOffset(int channel, int newBaseOffset)Gets the relative location where the line is drawn in the widget, the default isBASE_CENTERwhich is in the middle of the plotter. This method can be called outside of the UI thread.- Parameters:
baseOffset- must be between 100 and -100, exceeding values are rounded to the closest allowable value.
-
setConnect
public void setConnect(int channel, boolean connectHeadAndTail)Connects head and tail only if tail size isTAILSIZE_MAXand no fading. This method can be called outside of the UI thread.- Parameters:
connectHeadAndTail-
-
setAntialias
public void setAntialias(int channel, boolean antialias)Sets if the line must be anti-aliased which uses more processing power in return of a smoother image. The default value is false. This method can be called outside of the UI thread.- Parameters:
channel-antialias-
-