org.vishia.gral.base

## Class GralCurveView.GraphicImplAccess

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

- All Implemented Interfaces:
    GralWidgImpl_ifc, Removeable
  Direct Known Subclasses:
    SwtCurveView
  Enclosing class:
    GralCurveView

      public abstract static class GralCurveView.GraphicImplAccess
      extends GralWidget.ImplAccess
      implements GralWidgImpl_ifc, Removeable

  All tracks to return for filling. It has the same members in the same order like `GralCurveView.listTracks`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `bMouseDownCursor1` During mouse move, internal use.
    `protected boolean` | `bMouseDownCursor2` During mouse move, internal use.
    `protected boolean` | `bPaintAllCmd` Set to true to force a paint all.
    `protected boolean` | `bRedrawAll`
    `protected static int` | `cmdSetCursor`
    `protected GralColor` | `colorBackGral` Origin point from 0.0 to 1.0 for the zoomed area.
    `private int` | `ctLastSelected`
    `protected boolean` | `focusChanged`
    `protected GralColor` | `gridColorGral`
    `protected GralColor` | `gridColorGralStrong`
    `protected float` | `gridDistanceX` Distance of percent of y-view for one vertical grid line (strong or not strong).
    `protected int` | `gridDistanceY` Distance of nrofValues for one vertical grid line (strong or not strong).
    `protected int` | `gridStrongPeriodX` period of strong lines.
    `protected int` | `gridStrongPeriodY` period of strong lines.
    `protected int` | `ixDataCursor1` Position of cursor in the data.
    `protected int` | `ixDataCursor2` Position of cursor in the data.
    `protected int` | `ixDataDraw` Index of the last drawn values.
    `protected int[]` | `ixDataShown` The index in data for each shown pixel, from right to left int-wrapping
    `protected int` | `ixDataShowRight` The index to show values, it increments with ixWrValues if bFreeze is false
    `protected int[]` | `lastPositionX` last x-positions for paint.
    `protected java.util.concurrent.atomic.AtomicInteger` | `nrofDataShift` Number of iData-indices, which are shifted in the `#values`.
    `protected float` | `nrofDataShiftFracPart`
    `protected int[]` | `nrofPixel4data` The number of pixel for the current data point from the current pixel to left
    `protected int` | `nrofValuesLessViewPart` The actual number of values which are not shown because its time difference is too small to show in graphic as new point.
    `protected GralCurveView.PixelOrganisation` | `pixelOrg`
    `protected boolean` | `redrawBecauseNewData` Set true if `#redrawData()` is called.
    `protected int` | `timeCaryOverNewValue` The cary over of time which is not used for the current point.
    `protected GralCurveView.Track` | `trackSelected` The track which is selected by the last setCursor.
    `protected GralCurveView` | `widgg`
    `protected int` | `xpCursor1` Pixel from right for the cursor1 and cursor2.
    `protected int` | `xpCursor1New` New Pixel position for a cursor1 and cursor2.
    `protected int` | `xpCursor2` Pixel from right for the cursor1 and cursor2.
    `protected int` | `xpCursor2New` New Pixel position for a cursor1 and cursor2.
    `protected float` | `xViewLastF` last point in x where values were drawn.
    `protected int` | `XXXnrofValuesShow` Number of values to show in graphic.

    - ### 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
    Modifier | Constructor and Description
    --- | ---
    `protected` | `GraphicImplAccess(GralCurveView outer)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `cursorUnzoom()` Unzooms between the given vertical cursors.
    `protected int` | `getIxDataFromPixelRight(int ixPixelFromRight)` Gets the index in data with given pixel position in the graphic.
    `protected void` | `mouseSelectCursur(int xMousePixel, int yMousePixel)`
    `protected void` | `moveCursor(int xMousePixel)`
    `protected int` | `prepareIndicesDataForDrawing(int ixDataRight, int xViewPart, int timePart, boolean bPaintAll)` prepares indices of data.
    `protected boolean` | `selectTrack(int xpos, int ypos, int xsize, int ysize)` Determines and switches a curve to select by mouse click.
    `protected void` | `setCursors(int xPos)`
    `protected void` | `setPaintAllCmd()` Forces that the next repaint paints the whole graphic.
    `protected void` | `stopAndViewToPast()` Shifts the curve presentation to the past.
    `protected void` | `viewToPresentOrGoIrRefresh()` Shifts the curve presentation to the present (actual values).
    `protected void` | `zoomBetweenCursors()` Zooms between the given vertical cursors.
    `protected void` | `zoomToPast()` Zooms the curve presentation with same index right with a greater time spread.
    `protected void` | `zoomToPresent()` Zooms the curve presentation with same index right with a lesser time spread.

    - ### 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`

    - ### Methods inherited from interface org.vishia.gral.base.GralWidgImpl_ifc

      `getPixelPositionSize, getWidgetImplementation, removeWidgetImplementation, repaintGthread, setBoundsPixel, setFocusGThread, setVisibleGThread`

    - ### Methods inherited from interface org.vishia.util.Removeable

      `remove`

- - ### Field Detail

    - #### widgg

          protected final GralCurveView widgg

    - #### pixelOrg

          protected final GralCurveView.PixelOrganisation pixelOrg

    - #### trackSelected

          protected GralCurveView.Track trackSelected

      The track which is selected by the last setCursor.

    - #### nrofPixel4data

          protected final int[] nrofPixel4data

      The number of pixel for the current data point from the current pixel to left. [0] is the number of pixel for the right point. This array is parallel to `ixDataShown`.

    - #### ixDataShown

          protected final int[] ixDataShown

      The index in data for each shown pixel, from right to left int-wrapping. [0] is right. Use `(ixData >> shIxiData) & mIxiData` to calculate the real data index. the used length is the number of pixel. 2000 are enough for a large representation. This array is filled newly whenever any draw or paint action is done. It is prepared in the routine The field contains old indices if the size of drawing is less then the size of window. `#prepareIndicesDataForDrawing(int, int, int)` and used in the drawTrack routine of the implementation level.

    - #### ixDataShowRight

          protected int ixDataShowRight

      The index to show values, it increments with ixWrValues if bFreeze is false

    - #### lastPositionX

          protected final int[] lastPositionX

      last x-positions for paint. The lastPositionX[0] is used to repaint the last curve peace while shifting draw content. Where, xShift (number of shifted pixel) is considered by subtraction.

    - #### XXXnrofValuesShow

          protected int XXXnrofValuesShow

      Number of values to show in graphic.

    - #### timeCaryOverNewValue

          protected int timeCaryOverNewValue

      The cary over of time which is not used for the current point.

    - #### ixDataDraw

          protected int ixDataDraw

      Index of the last drawn values. The index refers to the last drawn value.

    - #### nrofValuesLessViewPart

          protected int nrofValuesLessViewPart

      The actual number of values which are not shown because its time difference is too small to show in graphic as new point. It is counted only for debugging.

    - #### xpCursor1

          protected int xpCursor1

      Pixel from right for the cursor1 and cursor2. If -1 then the cursor is unused yet.

    - #### xpCursor2

          protected int xpCursor2

      Pixel from right for the cursor1 and cursor2. If -1 then the cursor is unused yet.

    - #### xpCursor1New

          protected int xpCursor1New

      New Pixel position for a cursor1 and cursor2. If >=0 then a new position is given.

    - #### xpCursor2New

          protected int xpCursor2New

      New Pixel position for a cursor1 and cursor2. If >=0 then a new position is given.

    - #### bMouseDownCursor1

          protected boolean bMouseDownCursor1

      During mouse move, internal use.

    - #### bMouseDownCursor2

          protected boolean bMouseDownCursor2

      During mouse move, internal use.

    - #### cmdSetCursor

          protected static final int cmdSetCursor

      See Also:
        Constant Field Values

    - #### ixDataCursor1

          protected int ixDataCursor1

      Position of cursor in the data.

    - #### ixDataCursor2

          protected int ixDataCursor2

      Position of cursor in the data.

    - #### gridDistanceY

          protected int gridDistanceY

      Distance of nrofValues for one vertical grid line (strong or not strong).

    - #### gridDistanceX

          protected float gridDistanceX

      Distance of percent of y-view for one vertical grid line (strong or not strong).

    - #### gridStrongPeriodX

          protected int gridStrongPeriodX

      period of strong lines.

    - #### gridStrongPeriodY

          protected int gridStrongPeriodY

      period of strong lines.

    - #### gridColorGral

          protected GralColor gridColorGral

    - #### gridColorGralStrong

          protected GralColor gridColorGralStrong

    - #### colorBackGral

          protected GralColor colorBackGral

      Origin point from 0.0 to 1.0 for the zoomed area.

    - #### focusChanged

          protected boolean focusChanged

    - #### xViewLastF

          protected float xViewLastF

      last point in x where values were drawn.

    - #### nrofDataShift

          protected java.util.concurrent.atomic.AtomicInteger nrofDataShift

      Number of iData-indices, which are shifted in the `#values`. This number have to be shifted in the pixel area if a draw-all is not requested. This field is set to 0 if the draw action is done.

    - #### nrofDataShiftFracPart

          protected float nrofDataShiftFracPart

    - #### redrawBecauseNewData

          protected boolean redrawBecauseNewData

      Set true if `#redrawData()` is called. Then only the area for new data is drawn in the `#drawBackground(GC, int, int, int, int)`-routine.

    - #### bRedrawAll

          protected boolean bRedrawAll

    - #### ctLastSelected

          private int ctLastSelected

    - #### bPaintAllCmd

          protected boolean bPaintAllCmd

      Set to true to force a paint all.

  - ### Constructor Detail

    - #### GraphicImplAccess

          protected GraphicImplAccess(GralCurveView outer)

  - ### Method Detail

    - #### setPaintAllCmd

          protected void setPaintAllCmd()

      Forces that the next repaint paints the whole graphic. This method should be invoked if the conditions for the graphic are changed, for example changed colors for lines.

    - #### getIxDataFromPixelRight

          protected int getIxDataFromPixelRight(int ixPixelFromRight)

      Gets the index in data with given pixel position in the graphic. The wrapping index in the data is contained in `ixDataShown`.
      Parameters:
        `ixw` - pixel position countered from right side.
      Returns:

    - #### selectTrack

          protected boolean selectTrack(int xpos,
                                        int ypos,
                                        int xsize,
                                        int ysize)

      Determines and switches a curve to select by mouse click. The curve should be at least 10 pixel near the mouse position.
      Algorithm: From mouse position the index in the data are calculated: `getIxDataFromPixelRight(int)`. Any track is checked: The value (float) is read, the scaling is used to calculate the y-Position. Then the distance between mouse and track is calculated.
      Parameters:
        `xpos` - Mouse position on click in pixel
        `ypos` -
        `xsize` - size of the curve view widget.
        `ysize` -
      Returns:
        true if a track is selected. false if the position is more as 10 pixels far of any track.

    - #### setCursors

          protected void setCursors(int xPos)

    - #### moveCursor

          protected void moveCursor(int xMousePixel)

    - #### zoomToPresent

          protected void zoomToPresent()

      Zooms the curve presentation with same index right with a lesser time spread. If the curve presentation is running yet, a finer solution in the present is given. Note that in this case the right index is the actual write index.

    - #### zoomToPast

          protected void zoomToPast()

      Zooms the curve presentation with same index right with a greater time spread. If the curve presentation is running yet, a broader solution in the present is given. Note that in this case the right index is the actual write index.

    - #### zoomBetweenCursors

          protected void zoomBetweenCursors()

      Zooms between the given vertical cursors. The time spread is calculated so that the cursors are places on the same data indices at 1/10 and 9/10 of the presentation range.

    - #### cursorUnzoom

          protected void cursorUnzoom()

      Unzooms between the given vertical cursors. The cursors will be set newly in graphic at the same data indices. The middle value of both cursors will be at the same position. The time spread is multiplied by the value 5. If the right border of presentation will be in the future, the `ixDataShowRight` will be greater than `GralCurveView.ixDataWr`, then the presentation will be adjusted to the current right `GralCurveView.ixDataWr` and the cursor positions are changed adequate.

    - #### viewToPresentOrGoIrRefresh

          protected void viewToPresentOrGoIrRefresh()

      Shifts the curve presentation to the present (actual values). If the TODO

    - #### stopAndViewToPast

          protected void stopAndViewToPast()

      Shifts the curve presentation to the past. If the presentation is running, it is stopped firstly. If it is stopped, the data index on 20% of current presentation will be adjusted to the right border. It means 20% are presented overlapping. The time spread is not changed.

    - #### mouseSelectCursur

          protected void mouseSelectCursur(int xMousePixel,
                                           int yMousePixel)

    - #### prepareIndicesDataForDrawing

          protected int prepareIndicesDataForDrawing(int ixDataRight,
                                                     int xViewPart,
                                                     int timePart,
                                                     boolean bPaintAll)

      prepares indices of data. All data have a timestamp. the xpixel-values are calculated from the timestamp. The `ixDataShown` array will be filled with the indices to the data for each x pixel from right to left. If there are more as one data record for one pixel, the step width of ixData is >1, If there are more as one x-pixel for one data record, the same index is written for that pixel
      It uses the `timeValues` to get the timestamp of the values starting from param ixDataRight for the right pixel of view. The ixDataRight will be decremented. It is a wrapping index with step width of `GralCurveView.adIxData`. If the timestamp of any next index is greater than the last one, it is a indication that any newer data are reached after wrapping. Then the preparation stops.
      It fills `ixDataShown` with indices to data per x pixel point. If there are the same data for more as one pixel (zoomed near), then `ixDataShown` will contain the same index. The presentation can decide whether it should be shown with the same level (stepwise) or with any linear approximation
      Parameters:
        `ixDataRight` - Index in data array for the right point. It is a index which wraps around full integer range, see `GralCurveView.adIxData`.
        `xViewPart` - width of the spread to prepare in pixel
      Returns:
        nrof pixel to draw. It is xViewPart if enough data are available, elsewhere less. TODO move to ImplAccess