org.vishia.gral.swt

## Class SwtCurveView

- java.lang.Object
- - org.vishia.gral.base.GralWidget.ImplAccess
  - - org.vishia.gral.base.GralCurveView.GraphicImplAccess
    - - org.vishia.gral.swt.SwtCurveView

- All Implemented Interfaces:
    GralWidgImpl_ifc, Removeable

      public class SwtCurveView
      extends GralCurveView.GraphicImplAccess

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `private class` | `SwtCurveView.CurveView`
    `private static class` | `SwtCurveView.TestHelp` This class is only used to store values to inspect.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.eclipse.swt.graphics.Color` | `colorBack`
    `protected org.eclipse.swt.graphics.Color` | `colorCursor`
    `private org.eclipse.swt.graphics.Image` | `cursorStore1`
    `private org.eclipse.swt.graphics.Image` | `cursorStore2`
    `private SwtCurveView.CurveView` | `curveSwt`
    `protected org.eclipse.swt.graphics.Color` | `gridColor`
    `protected org.eclipse.swt.graphics.Color` | `gridColorStrong`
    `(package private) SwtGralMouseListener.MouseListenerGralAction` | `mouseListenerCurve`
    `(package private) SwtCurveView.TestHelp` | `testHelp`
    `static int` | `version` Version, history and license.

    - ### Fields inherited from class org.vishia.gral.base.GralCurveView.GraphicImplAccess

      `bMouseDownCursor1, bMouseDownCursor2, bPaintAllCmd, bRedrawAll, cmdSetCursor, colorBackGral, focusChanged, gridColorGral, gridColorGralStrong, gridDistanceX, gridDistanceY, gridStrongPeriodX, gridStrongPeriodY, ixDataCursor1, ixDataCursor2, ixDataDraw, ixDataShown, ixDataShowRight, lastPositionX, nrofDataShift, nrofDataShiftFracPart, nrofPixel4data, nrofValuesLessViewPart, pixelOrg, redrawBecauseNewData, timeCaryOverNewValue, trackSelected, widgg, xpCursor1, xpCursor1New, xpCursor2, xpCursor2New, xViewLastF, XXXnrofValuesShow`

    - ### Fields inherited from class org.vishia.gral.base.GralWidget.ImplAccess

      `chgBitsDerived, chgColorBack, chgColorLine, chgColorText, chgEditable, chgFloat, chgFocus, chgFont, chgIntg, chgInvisible, chgObjects, chgPos, chgText, chgVisible, chgVisibleInfo, pixBounds, wdgimpl`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SwtCurveView(GralCurveView widgg, SwtMng mng)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `drawBackground(org.eclipse.swt.graphics.GC g, org.eclipse.swt.graphics.Point size, int xView, int yView, int dxView, int dyView)` This routine overrides
    `private void` | `drawRightOrAll(org.eclipse.swt.graphics.GC g, org.eclipse.swt.graphics.Point size, int xView, int dxView, int yView, int dyView, int ixDataRight, int xViewPart, int timeDiff, int xp0, boolean bPaintAll)` Draws the curves.
    `private int` | `drawShiftAreaToLeft(org.eclipse.swt.graphics.GC g, org.eclipse.swt.graphics.Point size, int xView, int dxView, int yView, int dyView, int xViewPart, int timeDiff)` Shifts the left draw area to left because only a right part of the curve should be drawn.
    `private void` | `drawTrack(org.eclipse.swt.graphics.GC g, org.eclipse.swt.graphics.Point size, GralCurveView.Track track, int iTrack, int ixixDataLast)` Draws one track using the `ixDataShown` indices to the data.
    `GralRectangle` | `getPixelPositionSize()`
    `java.lang.Object` | `getWidgetImplementation()` Returns the implementation class of the widget.
    `boolean` | `remove()` Removes all referenced data, close all opened resources, removes all graphical widgets etc.
    `void` | `removeWidgetImplementation()` Removes the graphical widget in the graphic.
    `void` | `repaintGthread()` This method should be implemented in all Widget implementations of the adapter for the underlying graphic system.
    `void` | `setBoundsPixel(int x, int y, int dx, int dy)`
    `boolean` | `setFocusGThread()` Sets the focus to the widget.
    `void` | `setVisibleGThread(boolean bVisible)` Sets the implementation widget(s) visible state.
    `(package private) void` | `stop()`

    - ### Methods inherited from class org.vishia.gral.base.GralCurveView.GraphicImplAccess

      `cursorUnzoom, getIxDataFromPixelRight, mouseSelectCursur, moveCursor, prepareIndicesDataForDrawing, selectTrack, setCursors, setPaintAllCmd, stopAndViewToPast, viewToPresentOrGoIrRefresh, zoomBetweenCursors, zoomToPast, zoomToPresent`

    - ### Methods inherited from class org.vishia.gral.base.GralWidget.ImplAccess

      `acknChanged, actionShow, dyda, getActionChange, getChanged, gralWidgetFromImplData, setDragEnable, setDropEnable, setFocused, setTextChanged, setVisibleState, XXXfocusGained`

    - ### Methods inherited from class java.lang.Object

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

- - ### Field Detail

    - #### version

          public static final int version

      Version, history and license.
      - 2016-07-03 Hartmut chg: Now derived from `GralCurveView.GraphicImplAccess` adequate to the new concept: An implementing widget is derived from its derived class of `GralWidget.ImplAccess`. Therefore only that base class implements the GralWidgetImpl_ifc.
      - 2014-02-03 Hartmut new: `CommonCurve#bFreeze`: freeze as common property of more as one GralCurveView. Constructor argument.
      - 2013-05-19 Hartmut new: Usage of the common `SwtGralMouseListener` and implementation of the special functionality in the superclass `GralCurveView.GralCurveViewMouseAction`.
      - 2012-08-11 Hartmut now grid with timestamps
      - 2012-03-25 Hartmut improved zoom
      - 2012-03-17 Hartmut some improvements in paint routine.
      - 2012-02-26 Hartmut A lot of details, see `GralCurveView`
      - 2012-02-21 Hartmut Now the CurveView works in the new environment. Some adjustments necessary yet.
      - 2011-06-00 Hartmut New concept of GralWidget etc and new Configuration concept with `GralCfgBuilder`. The old GuiDialogZbnfControlled.class was not use nevermore. But the CurveView was not adapted for that.
      - 2010-03-00 Hartmut The curve view was development as basic feature.
      Copyright/Copyleft: For this source the LGPL Lesser General Public License, published by the Free Software Foundation is valid. It means:
      1. You can use this source without any restriction for any desired purpose.
      2. You can redistribute copies of this source to everybody.
      3. Every user of this source, also the user of redistribute copies with or without payment, must accept this license for further using.
      4. But the LPGL is not appropriate for a whole software product, if this source is only a part of them. It means, the user must publish this part of source, but doesn't need to publish the whole source of the own product.
      5. You can study and modify (improve) this source for own using or for redistribution, but you have to license the modified sources likewise under this LGPL Lesser General Public License. You mustn't delete this Copyright/Copyleft inscription in this source file.
      If you intent to use this source without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### curveSwt

          private final SwtCurveView.CurveView curveSwt

    - #### cursorStore1

          private final org.eclipse.swt.graphics.Image cursorStore1

    - #### cursorStore2

          private final org.eclipse.swt.graphics.Image cursorStore2

    - #### gridColor

          protected org.eclipse.swt.graphics.Color gridColor

    - #### gridColorStrong

          protected org.eclipse.swt.graphics.Color gridColorStrong

    - #### colorCursor

          protected final org.eclipse.swt.graphics.Color colorCursor

    - #### colorBack

          protected final org.eclipse.swt.graphics.Color colorBack

    - #### testHelp

          SwtCurveView.TestHelp testHelp

    - #### mouseListenerCurve

          final SwtGralMouseListener.MouseListenerGralAction mouseListenerCurve

  - ### Constructor Detail

    - #### SwtCurveView

          public SwtCurveView(GralCurveView widgg,
                              SwtMng mng)

  - ### Method Detail

    - #### repaintGthread

          public void repaintGthread()

      Description copied from interface: `GralWidgImpl_ifc`
      This method should be implemented in all Widget implementations of the adapter for the underlying graphic system.
      Implementation hints: In SWT it should call redraw().
      It is possible that the widget consists of more as one graphical widget, then all of it should be redrawn. It is possible that some data are set in another thread, they should be applied to the widgets firstly. It is possible that the widget is removed though a repaintGthread-order is pending from the time before deleting, for example if the graphic layout is changed.
      See `#repaintRequ`

    - #### drawTrack

          private void drawTrack(org.eclipse.swt.graphics.GC g,
                                 org.eclipse.swt.graphics.Point size,
                                 GralCurveView.Track track,
                                 int iTrack,
                                 int ixixDataLast)

      Draws one track using the `ixDataShown` indices to the data.
      Parameters:
        `g` - graphic context from SWT
        `size` - of the panel in pixel
        `track` - data
        `iTrack` - Index of track, only used for debugging or test outputs.
        `ixixDataLast` - The end index in `ixDataShown` for this presentation.

    - #### drawShiftAreaToLeft

          private int drawShiftAreaToLeft(org.eclipse.swt.graphics.GC g,
                                          org.eclipse.swt.graphics.Point size,
                                          int xView,
                                          int dxView,
                                          int yView,
                                          int dyView,
                                          int xViewPart,
                                          int timeDiff)

      Shifts the left draw area to left because only a right part of the curve should be drawn. It is to save calculation time

    - #### drawRightOrAll

          private void drawRightOrAll(org.eclipse.swt.graphics.GC g,
                                      org.eclipse.swt.graphics.Point size,
                                      int xView,
                                      int dxView,
                                      int yView,
                                      int dyView,
                                      int ixDataRight,
                                      int xViewPart,
                                      int timeDiff,
                                      int xp0,
                                      boolean bPaintAll)

      Draws the curves.
      Parameters:
        `g` -
        `size` -
        `xView` -
        `dxView` -
        `yView` -
        `dyView` -
        `ixDataRight` -
        `xViewPart` -
        `timeDiff` -
        `xp0` -

    - #### drawBackground

          protected void drawBackground(org.eclipse.swt.graphics.GC g,
                                        org.eclipse.swt.graphics.Point size,
                                        int xView,
                                        int yView,
                                        int dxView,
                                        int dyView)

      This routine overrides
      See Also:
        `It is called in this class in {@link #paintListener} in the {@link PaintListener#paintControl(PaintEvent)} method. It draws the whole content.
        Because of saving calculation time there will be drawn only a small peace on right side of the area with the new data normally. The rest inclusive grid lines, curves, text is moved to left. But if the whole window should be refreshed, the whole widget is drawn newly.`

    - #### stop

          void stop()

    - #### setFocusGThread

          public boolean setFocusGThread()

      Description copied from interface: `GralWidgImpl_ifc`
      Sets the focus to the widget. See `GralMng_ifc#setFocus(GralWidget)`.
      Returns:
        true if it has the focus after this operation. false on any error.

    - #### setVisibleGThread

          public void setVisibleGThread(boolean bVisible)

      Description copied from interface: `GralWidgImpl_ifc`
      Sets the implementation widget(s) visible state. The widgets are really invisible, or they are visible in principle, but they can be covered by other windows or clipping. This method should set the `GralWidget.bVisibleState` too. Therewith it is able to quest `GralWidget.isVisible()` in any thread.
      Parameters:
        `bVisible` - true then the widget should be visible, false it is set to invisible.

    - #### removeWidgetImplementation

          public void removeWidgetImplementation()

      Description copied from interface: `GralWidgImpl_ifc`
      Removes the graphical widget in the graphic.

    - #### getWidgetImplementation

          public java.lang.Object getWidgetImplementation()

      Description copied from interface: `GralWidgImpl_ifc`
      Returns the implementation class of the widget. If the widget has more as one implementation widgets, this method returns one of the widgets, usual the first important one respectively that widget which represents the implementation layer. A widget of the implementation layer is a SWT.control or a `Component`.
      If more as one widget are part of the GralWidget, use the special `GralWidget._wdgImpl` class which should contain the references to that implementation widgets.

    - #### setBoundsPixel

          public void setBoundsPixel(int x,
                                     int y,
                                     int dx,
                                     int dy)

    - #### getPixelPositionSize

          public GralRectangle getPixelPositionSize()

    - #### remove

          public boolean remove()

      Description copied from interface: `org.vishia.util.Removeable`
      Removes all referenced data, close all opened resources, removes all graphical widgets etc. This method prepares a dereferencing of the instance. It is similar to the concept of Object.finalize(). But finalize() is designed for the last clearing before the garbage collector deletes an instance. In opposite remove cleans and closes on active run time. It may be proper to call remove inside the finalize() implementation. The remove() implementation should check whether some instances are removed already to support a second call of remove() after a first one!
      Returns:
        true if successfully. If false it is a hint for the application that the instance itself should not be removed.