guicomponents

## Class G4P

- java.lang.Object
- - guicomponents.G4P

- All Implemented Interfaces:
    GConstants, PConstants

      public class G4P
      extends Object
      implements PConstants, GConstants

  This class has only static methods. It keeps track of all GComponents created. Its primary role is encapsulated in the draw() method which can override the default Processing drawing mechanism.
  Author:
    Peter Lager

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `cursorChangeEnabled`
    `static String[]` | `fontFamilies` An array of names representing all the available fonts.
    `static PStyle` | `g4pStyle`
    `static PApplet` | `mainWinApp`
    `static boolean` | `messages`
    `static int` | `mouseOff`
    `static int` | `mouseOver`
    `static boolean` | `overControl`

    - ### Fields inherited from interface processing.core.PConstants

      `ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_2D, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_STROKE_PERSPECTIVE, DISABLE_TEXTURE_CACHE, DISABLE_TEXTURE_MIPMAPS, DISABLE_TRANSFORM_CACHE, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ACCURATE_2D, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_STROKE_PERSPECTIVE, ENABLE_TEXTURE_CACHE, ENABLE_TEXTURE_MIPMAPS, ENABLE_TRANSFORM_CACHE, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z`

    - ### Fields inherited from interface guicomponents.GConstants

      `ADD_DUPLICATE, BACKGROUND, CHANGED, CLICKED, CLOSE_WINDOW, COLLAPSED, CTRL_ANGULAR, CTRL_HORIZONTAL, CTRL_VERTICAL, DESELECTED, DISABLE_AUTO_DRAW, DRAGGED, ENTERED, EXCP_IN_HANDLER, EXIT_APP, EXPANDED, FAMILY, FOREGROUND, HUD_UNSUPPORTED, INVALID_STATUS, JUSTIFICATION, JUSTIFICATION_FULL, JUSTIFICATION_NONE, KEEP_OPEN, MISSING, NONEXISTANT, NOT_PEASYCAM, POSTURE, POSTURE_OBLIQUE, POSTURE_REGULAR, PRESSED, RELEASED, RUNTIME_ERROR, SCROLL_DOWN, SCROLL_LEFT, SCROLL_RIGHT, SCROLL_UP, SCROLLBAR_HORIZONTAL, SCROLLBAR_VERTICAL, SCROLLBARS_AUTOHIDE, SCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY, SELECTED, SET, SIZE, STRIKETHROUGH, STRIKETHROUGH_OFF, STRIKETHROUGH_ON, SUPERSCRIPT, SUPERSCRIPT_SUB, SUPERSCRIPT_SUPER, USER_COL_SCHEME, WEIGHT, WEIGHT_BOLD, WEIGHT_DEMIBOLD, WEIGHT_DEMILIGHT, WEIGHT_EXTRA_LIGHT, WEIGHT_EXTRABOLD, WEIGHT_HEAVY, WEIGHT_LIGHT, WEIGHT_MEDIUM, WEIGHT_REGULAR, WEIGHT_SEMIBOLD, WEIGHT_ULTRABOLD, WIDTH, WIDTH_CONDENSED, WIDTH_EXTENDED, WIDTH_REGULAR, WIDTH_SEMI_CONDENSED, WIDTH_SEMI_EXTENDED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `G4P()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addComponent(PApplet app, GComponent c)` INTERNAL USE ONLY This should be called by all ctors in GComponent and since all GUI components inherit from GComponent and are required to call a GComponent ctor then all GUI components will automatically be registered in the set.
    `static void` | `addWindow(GWindow window)` Add the window's PApplet object to G4P if not already there.
    `static guicomponents.G4P.AppletInfo` | `addWindow(PApplet app)` Add a PApplet object to G4P if not already there.
    `static void` | `cursor(int cursorOver)` Inform G4P which cursor to use for mouse over.
    `static void` | `cursor(int cursorOff, int cursorOver)` Inform G4P which cursor shapes will be used.
    `static void` | `draw(PApplet app)` When you first use G4P(app) it switches off auto draw for the PApplet app.
    `static void` | `dumpComponent(GComponent c)` INTERNAL USE ONLY Remove a component so that it is permanently unavailable.
    `static String` | `getFamily(String family)` See if this font family is available on this user's computer system and return the family name if found.
    `static boolean` | `isAutoDrawOn(PApplet app)` Is autodraw on for the PApplet app?
    `static boolean` | `isWindowActive(GWindow window)` Determines whether a window is still open or has been closed
    `static void` | `messagesEnabled(boolean enable)` G4P has a range of support messages eg if you create a GUI component without an event handler or, a slider where the visible size of the slider is less than the difference between min and max values.
    `static void` | `moveToFrontForDraw(GComponent comp)` INTERNAL USE ONLY Used to bring a panel to the front of the display.
    `static void` | `moveToFrontForMouse(GComponent comp)` INTERNAL USE ONLY Used to ensure the panel is the last component to be tested for mouse events.
    `static void` | `refresh()`
    `static void` | `removeWindow(GWindow window)` INTERNAL USE ONLY Remove control window - called when a ControlWindow is closed for good.
    `static void` | `setColorScheme(PApplet theApplet, int schemeNo)` Set the color scheme to be used by G4P Only reqd if different from the default blue scheme to be global specify before creating GUI components Available schemes: BLUE_SCHEME, GREEN_SCHEME, RED_SCHEME, PURPLE_SCHEME YELLOW_SCHEME, CYAN_SCHEME, GREY_SCHEME
    `static void` | `setDrawOrder(GWindow window)` This will sort the GUI controls in a secondary window.
    `static void` | `setDrawOrder(PApplet app)` If you are using GPanel or GCombo it would be useful to call this method in setup or customGUI (if using GUI builder tool).
    `static void` | `setFont(Font font)` Set the global font to be used by all controls.
    `static void` | `setFont(PApplet theApplet, String fontName, int fontSize)` Deprecated.
    `static void` | `setFont(String fontName, int fontSize)` Set the global font to be used by all controls.
    `static void` | `setFont(String fontName, int fontSize, int style)` Set the global font to be used by all controls.
    `static void` | `setMouseOverEnabled(boolean enable)` Enables or disables cursor over component change.

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

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

- - ### Field Detail

    - #### mainWinApp

          public static PApplet mainWinApp

    - #### g4pStyle

          public static PStyle g4pStyle

    - #### messages

          public static boolean messages

    - #### fontFamilies

          public static final String[] fontFamilies

      An array of names representing all the available fonts.

    - #### overControl

          public static boolean overControl

    - #### cursorChangeEnabled

          public static boolean cursorChangeEnabled

    - #### mouseOff

          public static int mouseOff

    - #### mouseOver

          public static int mouseOver

  - ### Constructor Detail

    - #### G4P

          public G4P()

  - ### Method Detail

    - #### getFamily

          public static String getFamily(String family)

      See if this font family is available on this user's computer system and return the family name if found. If the font family is unavailable then it returns the name "Dialog"
      Parameters:
        `family` -
      Returns:

    - #### setMouseOverEnabled

          public static void setMouseOverEnabled(boolean enable)

      Enables or disables cursor over component change.
      This method is ignore if an applet or window has not been registered with G4P or the mouse over state is not being changed. This is ignored if no G4P components have been created yet
      Parameters:
        `enable` -

    - #### refresh

          public static void refresh()

    - #### cursor

          public static void cursor(int cursorOff,
                    int cursorOver)

      Inform G4P which cursor shapes will be used. Initial values are ARROW (off) and HAND (over)
      Parameters:
        `cursorOff` -
        `cursorOver` -

    - #### cursor

          public static void cursor(int cursorOver)

      Inform G4P which cursor to use for mouse over.
      Parameters:
        `cursorOver` -

    - #### addComponent

          public static void addComponent(PApplet app,
                          GComponent c)

      INTERNAL USE ONLY
      This should be called by all ctors in GComponent and since all GUI components inherit from GComponent and are required to call a GComponent ctor then all GUI components will automatically be registered in the set.
      Parameters:
        `theApplet` -
        `c` - the component that has been created.

    - #### dumpComponent

          public static void dumpComponent(GComponent c)

      INTERNAL USE ONLY
      Remove a component so that it is permanently unavailable.
      Do not call this method directly otherwise your program will crash.
      Use the components dispose method instead.
      Parameters:
        `c` - the component to remove

    - #### addWindow

          public static void addWindow(GWindow window)

      Add the window's PApplet object to G4P if not already there.
      Parameters:
        `window` -

    - #### addWindow

          public static guicomponents.G4P.AppletInfo addWindow(PApplet app)

      Add a PApplet object to G4P if not already there.
      The only time you might want to use this is when you are mixing G4P and OpenGL. In which case call this method from setup() immediately after the call to size() and before any statements that might alter the initial drawing matrix e.g.

          void setup(){

            size(480, 320);

            G4P.addWindow(this);

      Parameters:
        `app` - the PApplet object to add

    - #### removeWindow

          public static void removeWindow(GWindow window)

      INTERNAL USE ONLY
      Remove control window - called when a ControlWindow is closed for good.
      Parameters:
        `window` -

    - #### isWindowActive

          public static boolean isWindowActive(GWindow window)

      Determines whether a window is still open or has been closed
      Parameters:
        `window` -
      Returns:
        true if the window is still open

    - #### setColorScheme

          public static void setColorScheme(PApplet theApplet,
                            int schemeNo)

      Set the color scheme to be used by G4P
      Only reqd if different from the default blue scheme to be global specify before creating GUI components Available schemes: BLUE_SCHEME, GREEN_SCHEME, RED_SCHEME, PURPLE_SCHEME YELLOW_SCHEME, CYAN_SCHEME, GREY_SCHEME
      Parameters:
        `theApplet` -
        `schemeNo` - GCScheme.GREEN_SCHEME

    - #### setFont

          public static void setFont(PApplet theApplet,
                     String fontName,
                     int fontSize)

      Deprecated.
      Set the font type and size to be used by G4P
      Only reqd if different from the default "Serif" 11
      to be global specify before creating GUI components
      Parameters:
        `theApplet` -
        `fontName` - name of font
        `fontSize` - font size

    - #### setFont

          public static void setFont(String fontName,
                     int fontSize)

      Set the global font to be used by all controls.
      You can override the font used by individual controls with the equivalent setFont method for the control.
      Parameters:
        `fontName` - font family name
        `fontSize` - font size

    - #### setFont

          public static void setFont(String fontName,
                     int fontSize,
                     int style)

      Set the global font to be used by all controls.
      You can override the font used by individual controls with the equivalent setFont method for the control.
      The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC). If the style is unrecognised it will default to PLAIN.
      Parameters:
        `fontName` - font family name
        `fontSize` - font size
        `style` - style e.g. Font.PLAIN

    - #### setFont

          public static void setFont(Font font)

      Set the global font to be used by all controls.
      You can override the font used by individual controls with the equivalent setFont method for the control.
      Parameters:
        `font` - the java.awt.Font to use

    - #### draw

          public static void draw(PApplet app)

      When you first use G4P(app) it switches off auto draw for the PApplet app.

    - #### isAutoDrawOn

          public static boolean isAutoDrawOn(PApplet app)

      Is autodraw on for the PApplet app?

    - #### messagesEnabled

          public static void messagesEnabled(boolean enable)

      G4P has a range of support messages eg
      if you create a GUI component without an event handler or,
      a slider where the visible size of the slider is less than the difference between min and max values. This method allows the user to enable (default) or disable this option. If disable then it should be called before any GUI components are created.
      Parameters:
        `enable` -

    - #### setDrawOrder

          public static void setDrawOrder(GWindow window)

      This will sort the GUI controls in a secondary window.
      Parameters:
        `window` - the GWindow object

    - #### setDrawOrder

          public static void setDrawOrder(PApplet app)

      If you are using GPanel or GCombo it would be useful to call this method in setup or customGUI (if using GUI builder tool).
      DO NOT CALL this method from inside the draw() method.
      This will sort the draw order for GUI controls based on their z attribute - note that a control will be drawn before a control with a higher z. If two controls have the same z value, then the controls are ordered by their vertical screen position. This means that controls near the bottom of the display will be drawn before those nearer the top.
      Parameters:
        `windowApp` - the PApplet object

    - #### moveToFrontForDraw

          public static void moveToFrontForDraw(GComponent comp)

      INTERNAL USE ONLY
      Used to bring a panel to the front of the display.
      Do not use this method directly.

    - #### moveToFrontForMouse

          public static void moveToFrontForMouse(GComponent comp)

      INTERNAL USE ONLY
      Used to ensure the panel is the last component to be tested for mouse events.
      Do not use this method.

Processing library guicomponents by Peter Lager. (C) 2012