org.vishia.gral.base

## Class GralGridProperties

- java.lang.Object
- - org.vishia.gral.base.GralGridProperties

- Direct Known Subclasses:
    AwtProperties, SwtProperties

      public class GralGridProperties
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `GralColor` | `colorBackground_` A common background color for all widgets which are paint at the background.
    `GralFont[]` | `fontMonospacedSansSerif`
    `protected static int[][]` | `pixelFrac` Number of pixel for fractional part and for the grid size.
    `protected int` | `size` The size of this propety set.
    `protected static int[]` | `smallPromptFontSize`
    `protected static int[]` | `stdButtonFontSize`
    `protected static int[]` | `stdInputFontSize`
    `protected static int[][]` | `stdTextFontSize` This are the font sizes for some heights of fields in the given sizes of presentation.
    `GralFont[]` | `textFont` Up to 10 font sizes for following hight of lettes: ..1.2..1.4..1.6..1.8..2.0..2.4..2.8..3.1..3.93.9...
    `static int` | `version` Version, history and license.
    `protected int` | `xPixelUnit`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GralGridProperties(char sizeC)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `GralColor` | `color(int colorValue)` Returns a color with given numeric color value.
    `int` | `getColorValue(java.lang.String sColorName)`
    `GralFont` | `getTextFont(float size)`
    `GralFont` | `getTextFont(float fontHeight, char type, char style)` The type: m: monospaced small The style: not supported yet.
    `int` | `xPixelFrac(int frac)`
    `int` | `xPixelUnit()` Gets the number of pixel for one unit of x-direction.
    `int` | `yPixelFrac(int frac)`
    `int` | `yPixelUnit()`

    - ### 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.
      - 2015-10-24 Hartmut chg: Size C is now 10 pixel per grid unit, size D is the older size C.
      - 2015-10-11 Hartmut chg: The text font should be lesser because g, q, y are not proper able to read. TODO think about finer steps between A..C, but don't change existing sizes because some graphics are tuned with them.
      - 2010-00-00 Hartmut created. The idea of a grid layout with different sizes as basic.
      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 don'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 are indent to use this sources without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### stdTextFontSize

          protected static final int[][] stdTextFontSize

      This are the font sizes for some heights of fields in the given sizes of presentation. First index is the height of field, second is the size of presentation.

    - #### smallPromptFontSize

          protected static final int[] smallPromptFontSize

    - #### stdInputFontSize

          protected static final int[] stdInputFontSize

    - #### stdButtonFontSize

          protected static final int[] stdButtonFontSize

    - #### pixelFrac

          protected static final int[][] pixelFrac

      Number of pixel for fractional part and for the grid size. The array is organized in a 2-dimensional array `[frac][size]`.
      - The first column contains 0 for frac = 0.
      - The last column: `pixelFrac[size] [10]` contains the pixel size of the grid.
      - The fractional part is given in even numbers (1, 3, 5, 7, 9) to divide in part of 1/6: 1 = 1/6, 3 = 1/3, 5 = 1/2, 7 = 2/3, 9 = 5/6. It is decimal 0.166, 0.333, 0.5, 0.666, 0.833.
      - The fractional part is given in odd numbers (2, 4, 6, 8) to divide in part of 1/5 or decimal 2/10: 2 = 1/5 = 0.2, 4 = 2/5 = 0.4, 6 = 3/5 = 0.6, 8 = 4/5 = 0.8.
      Typical usage for grid units and associated pixel units in size C:

      Type | units | pixel
      Label normal text size | 2 | 16
      Button normal text size | 3 | 24
      TextField | 2 | 16
      Large InputField | 4 | 32

      Number of Grid Units for full display sizes. An application which needs about 40 lines of text or text fields needs 80 grid unit in vertical, it is about 80x120. It runs in a small window with 640 x 480 pixel on size A only. In full display mode on a standard display it can use the size C or D.

      size | A | B | C | D | E | F | G
      pixel/grid | 6 | 7 | 8 | 9 | 10 | 12 | 15
      640 x 480 | 106 x 80 | 91 x 68 | 80 x 60 | todo | todo | todo
      800 x 600 | 133 x 100 | 114 x 85 | 100 x 75 | todo | todo | todo
      1024 x 768 | 170 x 128 | 146 x 109 | 128 x 96 | 113 x 85 | 102 x 76 | 85 x 64 | 68 x 51
      1200 x 800 | 200 x 133 | 171 x 114 | 150 x 100 | 133 x 88 | 120 x 80 | 100 x 66 | 80 x 53
      1680 x 1024 | 280 x 170 | 240 x 146 | 210 x 128 | 186 x 113 | 168 x 102 | 140 x 85 | 112 x 68

      Type | unit | pixel
      JLabel normal text size | 2 | 0+6
      JButton normal text size | 3 | 26
      InputField | 4 | 34

    - #### xPixelUnit

          protected final int xPixelUnit

    - #### colorBackground_

          public GralColor colorBackground_

      A common background color for all widgets which are paint at the background.

    - #### textFont

          public final GralFont[] textFont

      Up to 10 font sizes for following hight of lettes:

      ..1.2 | ..1.4 | ..1.6 | ..1.8 | ..2.0 | ..2.4 | ..2.8 | ..3.1 | ..3.9 | 3.9...
      0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |

      This table will be filled depending of the Grid size, see `stdTextFontSize`.

    - #### fontMonospacedSansSerif

          public final GralFont[] fontMonospacedSansSerif

    - #### size

          protected final int size

      The size of this propety set.

  - ### Constructor Detail

    - #### GralGridProperties

          public GralGridProperties(char sizeC)

  - ### Method Detail

    - #### getColorValue

          public int getColorValue(java.lang.String sColorName)

    - #### getTextFont

          public GralFont getTextFont(float size)

    - #### getTextFont

          public GralFont getTextFont(float fontHeight,
                                      char type,
                                      char style)

      The type:
      - m: monospaced small
      The style: not supported yet. TODO i, b for italic, bold,...
      Parameters:
        `fontHeight` - height of the text line in GralPos. 2.0f is standard.
        `type` -
        `style` -
      Returns:

    - #### color

          public GralColor color(int colorValue)

      Returns a color with given numeric color value. The color instance is taken from a pool if the color is used already. Elsewhere it is created newly and put into the pool.
      Parameters:
        `colorValue` - red, green and blue
      Returns:
        An instance of color

    - #### yPixelFrac

          public int yPixelFrac(int frac)

    - #### xPixelUnit

          public int xPixelUnit()

      Gets the number of pixel for one unit of x-direction. It is approximately the half width of the letter 'm' for the standard input field font. To support visibility of a dedicated number of chars, you should use 2 * nrofChars units for a text field. In opposite, the Constructor for the javax.swing.TextField(int) sets the size of the text-field to the given number of 'm'-width. Here you should use factor 2. NOTE: A possibility to derive the xPixelUnit() from the font wasn't found. The cohesion between the font-widht for 'm' and the returned number of pixels is tested manually. It may be different if another font is used.
      Returns:
        Number of pixel for 1 unit in x-direction.

    - #### yPixelUnit

          public int yPixelUnit()

    - #### xPixelFrac

          public int xPixelFrac(int frac)