org.vishia.gral.base

## Class GralTable.GraphicImplAccess

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

- All Implemented Interfaces:
    GralWidgImpl_ifc, Removeable
  Direct Known Subclasses:
    SwtTable
  Enclosing class:
    GralTable<UserData>

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

  This is the super class for all implementers. It has protected access to all elements in the environment class. Via access methods the implementor class has protected access to all of it.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `bFocused` Set true if the focus is gained by mouse click.
    `protected boolean` | `bFocusLost` Sets temporary between focus lost and redraw.
    `protected boolean` | `bRedrawPending` Set to true while `#table`.
    `protected boolean` | `bVscrollbarChanged`
    `protected GralTable.CellData[][]` | `cells`
    `static int` | `chgEditableColumn`
    `protected int[]` | `columnPixel` Deprecated. only used in org.vishia.gral.swt.SwtTable#initSwtTable(...)
    `protected int` | `ixColorScrollbar` New and last index of the sliderColor.
    `protected int` | `ixColorScrollbarLast` New and last index of the sliderColor.
    `protected int` | `linePixel` Pixel per line.
    `private GralTable.LinePresentation` | `linePresentation` Only used on invocation of `drawCellContent(int, org.vishia.gral.base.GralTable.CellData[], org.vishia.gral.base.GralTable<?>.TableLineData, org.vishia.gral.base.GralTable.LinePresentation)`
    `protected long` | `mousect`
    `private boolean` | `mouseDoubleClick`
    `protected long` | `mousetime`
    `protected int` | `nrofColumnTreeShift` number of columns which should be shift to rigth on tree indent. 0. don't shift.
    `protected GralTable<UserData>` | `outer`
    `protected long` | `redrawct`
    `protected long` | `redrawtime`
    `protected int[]` | `xpixelCell` Column position for the cells in pixel from 0 (left) calculated from the pixel size of the table.
    `protected int` | `xPixelUnit`
    `protected boolean` | `XXXhasFocus` Set to true if the table has the focus in window.
    `protected GralRectangle` | `xyVscrollbar` Pixel position of the vertical scroll bar.
    `protected int` | `y1Scrollbar` Position of vScrollBar calculated from `GralTable.rootLine`.
    `protected int` | `y2Scrollbar` Position of vScrollBar calculated from `GralTable.rootLine`.

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

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `GraphicImplAccess(GralTable<UserData> outer, GralMng mng)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `bChangedLinesForCell()`
    `protected void` | `bChangedLinesForCell(boolean val)`
    `protected boolean` | `bColumnEditable(int ix)`
    `protected void` | `checkAndUpdateText(java.lang.String sText, GralTable.CellData celldata)`
    `protected GralColor` | `colorBackTable()`
    `protected GralColor` | `colorBackVscrollbar()`
    `protected GralColor` | `colorLineVscrollbar()`
    `protected GralColor` | `colorSelectChars()`
    `protected GralColor` | `colorSelectCharsBack()`
    `protected int[]` | `columnWidthsGral()`
    `protected abstract GralMenu` | `createColumnMenu(int column)` Should be implemented by the implementation class.
    `protected void` | `determineSizeAndPositionScrollbar(int yPixel)` This method have to be called before the vertical scroll bar is painted in the `GralWidgImpl_ifc.repaintGthread()` routine..
    `protected abstract void` | `drawCellContent(int iCellLine, GralTable.CellData[] cellData, GralTable.TableLineData line, GralTable.LinePresentation linePresentationP)`
    `protected abstract GralTable.CellData` | `drawCellInvisible(int iCellLine, int iCellCol)`
    `void` | `focusGainedTable()` This routine is invoked if any cell of the table gets the focus.
    `protected void` | `focusLostTable()` Invoked if any cell has lost the focus.
    `protected abstract java.lang.String` | `getCellText(GralTable.CellData cell)` Gets the current text of the given cell from the graphic implementation.
    `protected abstract java.lang.String` | `getCellTextFocus()` Gets the cell text from the focused cell in the implementation.
    `protected abstract int` | `getVisibleLinesTableImpl()`
    `protected GralMng` | `itsMng()`
    `protected int` | `ixColumn()`
    `protected void` | `mouseDoubleGral(int key, GralTable.CellData cell)`
    `protected void` | `mouseDownGral(int key, GralTable.CellData cell)`
    `protected void` | `mouseUpGral(int key, GralTable.CellData cell)`
    `protected boolean` | `processKeys(int keyCode)` Handle all standard keys of table.
    `protected boolean` | `redrawTableWithFocusedCell(GralTable.CellData data)` Sets the current cell as focused with the focus color.
    `boolean` | `remove()` Removes all referenced data, close all opened resources, removes all graphical widgets etc.
    `protected void` | `resizeTable(GralRectangle pixTable)` This routine will be called inside a resize listener of the implementation graphic.
    `protected java.lang.StringBuilder` | `searchChars()`
    `protected abstract void` | `setBoundsCells(int treeDepthBase, int zLineVisible)` Invoked in `resizeTable(GralRectangle)` as action which should be implemented in the implementation layer.
    `protected void` | `setCellText(GralTable.CellData cell, java.lang.String text)` Invoked on editing a text field
    `protected void` | `setFocusCellMousePressed()`
    `private void` | `setLinePresentation(GralTable.TableLineData line)`
    `protected void` | `updateGraphicCellContent()` Updates the cell text fields which presents the content of the table.
    `protected int` | `zColumn()`

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

- - ### Field Detail

    - #### chgEditableColumn

          public static final int chgEditableColumn

      See Also:
        Constant Field Values

    - #### linePresentation

          private final GralTable.LinePresentation linePresentation

      Only used on invocation of `drawCellContent(int, org.vishia.gral.base.GralTable.CellData[], org.vishia.gral.base.GralTable<?>.TableLineData, org.vishia.gral.base.GralTable.LinePresentation)`

    - #### outer

          protected final GralTable<UserData> outer

    - #### cells

          protected GralTable.CellData[][] cells

    - #### bRedrawPending

          protected boolean bRedrawPending

      Set to true while `#table`.`Table#redrawGthread()` is running. It prevents recursive invocation of redraw() while setFocus() is invoked.

    - #### linePixel

          protected int linePixel

      Pixel per line.

    - #### xpixelCell

          protected final int[] xpixelCell

      Column position for the cells in pixel from 0 (left) calculated from the pixel size of the table. This values are calculated on setToPanel and after resize with `resizeTable(GralRectangle)`.

    - #### xyVscrollbar

          protected final GralRectangle xyVscrollbar

      Pixel position of the vertical scroll bar.

    - #### y1Scrollbar

          protected int y1Scrollbar

      Position of vScrollBar calculated from `GralTable.rootLine`. `GralTable.NodeTableLine.zLineUnfolded` and `GralTable#nLineCurr` written in `#determineSizeAndPosition()` used for painting vScrollBar.

    - #### y2Scrollbar

          protected int y2Scrollbar

      Position of vScrollBar calculated from `GralTable.rootLine`. `GralTable.NodeTableLine.zLineUnfolded` and `GralTable#nLineCurr` written in `#determineSizeAndPosition()` used for painting vScrollBar.

    - #### bVscrollbarChanged

          protected boolean bVscrollbarChanged

    - #### ixColorScrollbar

          protected int ixColorScrollbar

      New and last index of the sliderColor. The last index is stored by the implementation and compared with the new one to desire whether a new implementation color should be gotten.

    - #### ixColorScrollbarLast

          protected int ixColorScrollbarLast

      New and last index of the sliderColor. The last index is stored by the implementation and compared with the new one to desire whether a new implementation color should be gotten.

    - #### columnPixel

          protected int[] columnPixel

      Deprecated. only used in org.vishia.gral.swt.SwtTable#initSwtTable(...)
      Start position of each column in pixel.

    - #### xPixelUnit

          protected final int xPixelUnit

    - #### nrofColumnTreeShift

          protected int nrofColumnTreeShift

      number of columns which should be shift to rigth on tree indent. 0. don't shift. Usual 1

    - #### bFocused

          protected boolean bFocused

      Set true if the focus is gained by mouse click. It causes color set and invocation of `#actionOnLineSelected(GralTableLine_ifc)`.

    - #### bFocusLost

          protected boolean bFocusLost

      Sets temporary between focus lost and redraw. It is reset if the focus is gained for another cell of the same table.

    - #### XXXhasFocus

          protected boolean XXXhasFocus

      Set to true if the table has the focus in window.

    - #### mousetime

          protected long mousetime

    - #### redrawtime

          protected long redrawtime

    - #### mousect

          protected long mousect

    - #### redrawct

          protected long redrawct

    - #### mouseDoubleClick

          private boolean mouseDoubleClick

  - ### Constructor Detail

    - #### GraphicImplAccess

          protected GraphicImplAccess(GralTable<UserData> outer,
                                      GralMng mng)

  - ### Method Detail

    - #### itsMng

          protected GralMng itsMng()

    - #### bColumnEditable

          protected boolean bColumnEditable(int ix)

    - #### checkAndUpdateText

          protected void checkAndUpdateText(java.lang.String sText,
                                            GralTable.CellData celldata)

    - #### ixColumn

          protected int ixColumn()

    - #### columnWidthsGral

          protected int[] columnWidthsGral()

    - #### zColumn

          protected int zColumn()

    - #### colorSelectCharsBack

          protected GralColor colorSelectCharsBack()

    - #### bChangedLinesForCell

          protected boolean bChangedLinesForCell()

    - #### bChangedLinesForCell

          protected void bChangedLinesForCell(boolean val)

    - #### colorSelectChars

          protected GralColor colorSelectChars()

    - #### colorBackTable

          protected GralColor colorBackTable()

    - #### colorBackVscrollbar

          protected GralColor colorBackVscrollbar()

    - #### colorLineVscrollbar

          protected GralColor colorLineVscrollbar()

    - #### searchChars

          protected java.lang.StringBuilder searchChars()

    - #### processKeys

          protected boolean processKeys(int keyCode)

      Handle all standard keys of table. It should call in the key event handler from the implementation class.
      Keys:
      - pgup:
      - up
      - dn
      - pgdn
      - `GralTable.keyMarkUp`
      - `GralTable.keyMarkDn`
      - calls `GralMng.getRegisteredUserAction(String what)` with what="KeyAction" and invokes the returned action method. With them all standard key actions of this application may be done if a `GralUserAction` is registered for that.
      Parameters:
        `keyCode` - Encoding see `KeyCode`.
      Returns:
        true if the key is processed, false if the key is not processed here. Maybe processed after them.

    - #### setFocusCellMousePressed

          protected void setFocusCellMousePressed()

    - #### setCellText

          protected void setCellText(GralTable.CellData cell,
                                     java.lang.String text)

      Invoked on editing a text field
      Parameters:
        `cell` -
        `text` -

    - #### getCellText

          protected abstract java.lang.String getCellText(GralTable.CellData cell)

      Gets the current text of the given cell from the graphic implementation.
      Parameters:
        `cell` -
      Returns:

    - #### getCellTextFocus

          protected abstract java.lang.String getCellTextFocus()

      Gets the cell text from the focused cell in the implementation.

    - #### updateGraphicCellContent

          protected void updateGraphicCellContent()

      Updates the cell text fields which presents the content of the table. After them update() of the graphic level should be called. To execute the update of the cells in the graphic layer the `#drawCellContent(int, CellData[], TableLineData, LinePresentation)` is called inside for any cell. This method is implemented in the implementation layer.

    - #### setLinePresentation

          private void setLinePresentation(GralTable.TableLineData line)

    - #### determineSizeAndPositionScrollbar

          protected void determineSizeAndPositionScrollbar(int yPixel)

      This method have to be called before the vertical scroll bar is painted in the `GralWidgImpl_ifc.repaintGthread()` routine.. It checks whether the `GralTable#nLineCurr` and the shown number of lines in `GralTable.rootLine`. `GralTable.NodeTableLine.zLineUnfolded` is given, e.g. >=0. If one of them is <0 or lines are countered calling `GralTable.NodeTableLine.countChildren(boolean, int)`. Therewith the `GralTable#nLineCurr` is set too. Anytime if the situation is not specified the `GralTable#nLineCurr` can be set to -1. This forces new calculation.

    - #### resizeTable

          protected void resizeTable(GralRectangle pixTable)

      This routine will be called inside a resize listener of the implementation graphic. It calculates the width of the columns with the given width of the table's canvas. Then `#setBoundsCells()` will be called. That is implemented in the underlying graphic layer and sets the bounds for each cell.
      Parameters:
        `pixTable` - Size of the table area.

    - #### setBoundsCells

          protected abstract void setBoundsCells(int treeDepthBase,
                                                 int zLineVisible)

      Invoked in `resizeTable(GralRectangle)` as action which should be implemented in the implementation layer. The `xpixelCell` was set before.
      Parameters:
        `treeDepthBase` -

    - #### 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!
      Specified by:
        `remove` in interface `Removeable`
      Returns:
        true if successfully. If false it is a hint for the application that the instance itself should not be removed.

    - #### redrawTableWithFocusedCell

          protected boolean redrawTableWithFocusedCell(GralTable.CellData data)

      Sets the current cell as focused with the focus color. It causes a redraw of the whole table because the cell may be shifted in table position. TODO this method must call in the graphic thread yet, queue it with `GralMng#setInfo(GralWidget, int, int, Object, Object)`.
      Parameters:
        `cell` - The cell

    - #### focusGainedTable

          public void focusGainedTable()

      This routine is invoked if any cell of the table gets the focus. It is if the window gets the focus from view of the whole operation system, if the mouse is landing on a cell Text-field with click or if setFocus() for the graphic presentation layer was called.
      - If `bFocusLost` is true, another cell of this table has lost the focus in the last 50 ms before the repaint() was invoked. Then the super.`GralWidget.setFocus()` will not be called.
      - If `bRedrawPending` is set, it means that the focus gained is invoked by a setFocus()-call of the graphic representation layer. Then the `GralWidget.setFocus()` will not be called.
      - If both conditions are false, it is a focusGained either by mouse click, whereby this table has not have the focus before, or by any other action of focusing. Then `GralWidget.setFocus()` is called to designate, that the table is focused.

    - #### focusLostTable

          protected void focusLostTable()

      Invoked if any cell has lost the focus. If the table has lost the focus, the repaint will established this state after 50 milliseconds because the flag `bFocused` = false. But if another cell of the table has gotten the focus in this time, the bFocus = true is set.

    - #### mouseDownGral

          protected void mouseDownGral(int key,
                                       GralTable.CellData cell)

    - #### mouseUpGral

          protected void mouseUpGral(int key,
                                     GralTable.CellData cell)

    - #### mouseDoubleGral

          protected void mouseDoubleGral(int key,
                                         GralTable.CellData cell)

    - #### drawCellContent

          protected abstract void drawCellContent(int iCellLine,
                                                  GralTable.CellData[] cellData,
                                                  GralTable.TableLineData line,
                                                  GralTable.LinePresentation linePresentationP)

    - #### drawCellInvisible

          protected abstract GralTable.CellData drawCellInvisible(int iCellLine,
                                                                  int iCellCol)

    - #### getVisibleLinesTableImpl

          protected abstract int getVisibleLinesTableImpl()

    - #### createColumnMenu

          protected abstract GralMenu createColumnMenu(int column)

      Should be implemented by the implementation class.
      Parameters:
        `column` - The column
      Returns:
        The menu.