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 int BASE_CENTER
    The base of the line is positioned at the center of the widget.
    static int CURSOR_START_DEFAULT
    The default cursor starting position.
    static int DEFAULT_HEIGHT
    The default comfortable widget height.
    static int DEFAULT_WIDTH
    The default comfortable widget width.
    static int LINE_WIDTH_DEFAULT
    The default line width.
    static int PROGRESSION_DEFAULT
    The default tail fade percentage
    static int STEADYPOSITION_75PERCENT
    Steady position @ 75% of graph.
    static int TAILFADE_DEFAULT
    The default amount of tail fading in percentages (25).
    static int TAILFADE_NONE
    No tailfade.
    static int TAILFADE_PERCENTAGE
    The default tail fade percentage
    static int TAILSIZE_DEFAULT
    The default tail size is 75% of the width.
    static int TAILSIZE_FILL
    Will draw a tail from the left border but is only valid if the boolean in #setSteady(boolean, int) was set to true, will default to TAILSIZE_MAX otherwise.
    static int TAILSIZE_MAX
    Will draw a maximum tail.

    Fields inherited from class org.eclipse.swt.widgets.Control

    handle
  • Constructor Summary

    Constructors 
    Constructor Description
    Plotter​(int channels, org.eclipse.swt.widgets.Composite parent, int style)
    Creates a new plotter with channels channels.
    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 with channels channels
  • Method Summary

    Modifier and Type Method Description
    protected void controlMoved​(org.eclipse.swt.widgets.Event e)  
    protected void controlResized​(org.eclipse.swt.widgets.Event e)  
    protected int ConvertValueToScreenPosition​(int Value, int ScreenHeight)  
    int getBase​(int channel)
    This method can be called outside of the UI thread.
    int getBaseOffset​(int channel)
    Gets the relative location where the line is drawn in the widget.
    java.lang.String getChannelName​(int channel)
    get the descriptive name of the channel
    int getChannels()
    Returns the number of channels on the plotter This method can be called outside of the UI thread.
    java.lang.String getData​(boolean addHeader)
    Returns the data in CSV format using the semicolon (;) as separator and delegating to getData(boolean, String).
    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.
    org.eclipse.swt.graphics.Color getForeground​(int channel)
    This method can be called outside of the UI thread.
    int getLineWidth​(int channel)
    This method can be called outside of the UI thread.
    int getRangeHighValue()  
    int getRangeLowValue()  
    int getTailFade​(int channel)
    Gets the percentage of tail that must be faded out.
    int getTailSize​(int channel)
    Returns the size of the tail.
    boolean isAntiAlias​(int channel)
    This method can be called outside of the UI thread.
    boolean isConnect​(int channel)
    This method can be called outside of the UI thread.
    boolean isFade​(int channel)
    This method can be called outside of the UI thread.
    boolean isPercentage​(int channel)
    This method can be called outside of the UI thread.
    boolean isSteady​(int channel)
    This method can be called outside of the UI thread.
    protected void paintControl​(org.eclipse.swt.widgets.Event e)  
    protected void PositionPolyLine​(int[] l1)  
    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.
    void setBaseOffset​(int channel, int newBaseOffset)
    Gets the relative location where the line is drawn in the widget, the default is BASE_CENTER which is in the middle of the plotter.
    void SetChannelName​(int channel, java.lang.String name)
    Set the descriptive name of the channel
    void setConnect​(int channel, boolean connectHeadAndTail)
    Connects head and tail only if tail size is TAILSIZE_MAX and no fading.
    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").
    void setForeground​(int channel, org.eclipse.swt.graphics.Color color)
    Sets the foreground color for the supplied channel.
    void setLineWidth​(int channel, int lineWidth)
    Sets the line width.
    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.
    void setRange​(int lowValue, int highValue)  
    void setSteady​(int channel, boolean steady, int steadyPosition)
    If steady is true the graph will draw on a steady position instead of advancing.
    void setTailFade​(int channel, int newTailFade)
    Sets the percentage of tail that must be faded out.
    void setTailSize​(int channel, int newSize)
    The tail size defaults to TAILSIZE_DEFAULT which is 75% of the width.
    void setValue​(int channel, int value)
    Sets a value to be drawn relative to the center of the channel.
    protected void widgetDisposed​(org.eclipse.swt.widgets.Event e)  

    Methods inherited from class org.eclipse.swt.widgets.Canvas

    drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME

    Methods 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, toString

    Methods inherited from class org.eclipse.swt.widgets.Scrollable

    computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar

    Methods 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, update

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.swt.graphics.Drawable

    isAutoScalable
  • Field Details

  • Constructor Details

    • Plotter

      public Plotter​(int channels, org.eclipse.swt.widgets.Composite parent, int style)
      Creates a new plotter with channels channels.
      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 with channels channels
      Parameters:
      channels -
      parent -
      style -
      backgroundColor - if null use default background
      foregroundColor - 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 to getData(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. Use SetChannelName(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 for
      name - 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_MAX no 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 elegant GC.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 is BASE_CENTER which 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 is TAILSIZE_MAX and 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 -