G4P (GUI for Processing)  4.3.6
A set of GUI controls for your Processing sketch.
 All Classes Functions Variables Pages
g4p_controls.G4P Class Reference
Inheritance diagram for g4p_controls.G4P:

Classes

class  G4Pstyle
 

Static Public Member Functions

static GControlMode getCtrlMode ()
 
static int getCursor ()
 
static int getCursorOff ()
 
static GWindow[] getOpenWindowsAsArray ()
 
static ArrayList< GWindowgetOpenWindowsAsList (ArrayList< GWindow > list)
 
static String getPrettyVersion ()
 
static String getVersion ()
 
static boolean isWindowOpen (GWindow window)
 
static void messagesEnabled (boolean enable)
 
static void mouseWheelScrollbarDirection (int dir)
 
static void mouseWheelSliderDirection (int dir)
 
static void mouseWheelSpinnerDirection (int dir)
 
static void registerSketch (PApplet app)
 
static int selectColor ()
 
static int selectColor (Color color)
 
static int selectColor (int color)
 
static int selectColor (int red, int green, int blue)
 
static String selectFolder (String prompt)
 
static String selectInput (String prompt)
 
static String selectInput (String prompt, String startFolder)
 
static String selectInput (String prompt, String types, String typeDesc)
 
static String selectInput (String prompt, String types, String typeDesc, String startFolder)
 
static int selectOption (PApplet owner, String message, String title, int messageType, int optionType)
 
static String selectOutput (String prompt)
 
static String selectOutput (String prompt, String startFolder)
 
static String selectOutput (String prompt, String types, String typeDesc)
 
static String selectOutput (String prompt, String types, String typeDesc, String startFolder)
 
static void setCtrlMode (GControlMode mode)
 
static void setCursor (int cursorOff)
 
static void setCursorOff (int cursorOff)
 
static void setDisplayFont (String familyName, int style, int size)
 
static void setGlobalAlpha (int alpha)
 
static void setGlobalColorScheme (int cs)
 
static void setInputFont (String familyName, int style, int size)
 
static void setMouseOverEnabled (boolean enable)
 
static void setSliderFont (String familyName, int style, int size)
 
static void setWindowAlpha (PApplet app, int alpha)
 
static void setWindowColorScheme (PApplet app, int cs)
 
static void showMessage (PApplet owner, String message, String title, int messageType)
 
static void usePre35Fonts ()
 

Static Protected Member Functions

static int selectColorImpl (Color color)
 

Additional Inherited Members

- Public Attributes inherited from g4p_controls.GConstants
int ALPHA_BLOCK = 128
 
int ALPHA_PICK = 48
 
TextAttribute BACKGROUND = TextAttribute.BACKGROUND
 
int BLUE_SCHEME = 6
 
int BOLD = Font.BOLD
 
int CANCEL = JOptionPane.CANCEL_OPTION
 
int CLOSE_WINDOW = 0x00000f02
 
int CLOSED = JOptionPane.CLOSED_OPTION
 
int CTRL_ANGULAR = 0x00000501
 
int CTRL_HORIZONTAL = 0x00000502
 
int CTRL_VERTICAL = 0x00000503
 
int CYAN_SCHEME = 5
 
int DECIMAL = 1
 
char END = java.awt.event.KeyEvent.VK_END
 
int ERROR_MESSAGE = JOptionPane.ERROR_MESSAGE
 
int EXIT_APP = 0x00000f01
 
int EXPONENT = 2
 
TextAttribute FAMILY = TextAttribute.FAMILY
 
TextAttribute FOREGROUND = TextAttribute.FOREGROUND
 
int FORWARD = 1
 
int GOLD_SCHEME = 7
 
int GREEN_SCHEME = 1
 
int HIDE_WINDOW = 0x00000f04
 
char HOME = java.awt.event.KeyEvent.VK_HOME
 
int INFO_MESSAGE = JOptionPane.INFORMATION_MESSAGE
 
int INTEGER = 0
 
int ITALIC = Font.ITALIC
 
int KEEP_OPEN = 0x00000f03
 
int NO = JOptionPane.NO_OPTION
 
int OK = JOptionPane.OK_OPTION
 
int OK_CANCEL = JOptionPane.OK_CANCEL_OPTION
 
int ORANGE_SCHEME = 4
 
int ORIENT_LEFT = -1
 
int ORIENT_RIGHT = 1
 
int ORIENT_TRACK = 0
 
int PLAIN = Font.PLAIN
 
int PLAIN_MESSAGE = JOptionPane.PLAIN_MESSAGE
 
TextAttribute POSTURE = TextAttribute.POSTURE
 
Float POSTURE_OBLIQUE = new Float(0.20f)
 
Float POSTURE_REGULAR = new Float(0.0f)
 
int PURPLE_SCHEME = 3
 
int QUERY_MESSAGE = JOptionPane.QUESTION_MESSAGE
 
int RED_SCHEME = 0
 
int REVERSE = -1
 
int SCHEME_10 = 10
 
int SCHEME_11 = 11
 
int SCHEME_12 = 12
 
int SCHEME_13 = 13
 
int SCHEME_14 = 14
 
int SCHEME_15 = 15
 
int SCHEME_8 = 8
 
int SCHEME_9 = 9
 
int SCROLLBARS_AUTOHIDE = 0x1000
 
int SCROLLBARS_BOTH = 0x0003
 
int SCROLLBARS_HORIZONTAL_ONLY = 0x0002
 
int SCROLLBARS_NONE = 0x0000
 
int SCROLLBARS_VERTICAL_ONLY = 0x0001
 
TextAttribute SIZE = TextAttribute.SIZE
 
TextAttribute STRIKETHROUGH = TextAttribute.STRIKETHROUGH
 
Boolean STRIKETHROUGH_OFF = new Boolean(false)
 
Boolean STRIKETHROUGH_ON = new Boolean(true)
 
TextAttribute SUPERSCRIPT = TextAttribute.SUPERSCRIPT
 
Integer SUPERSCRIPT_OFF = new Integer(0)
 
Integer SUPERSCRIPT_SUB = new Integer(-1)
 
Integer SUPERSCRIPT_SUPER = new Integer(1)
 
int UNDEFINED = Integer.MAX_VALUE
 
int USER_COL_SCHEME = 0x00010102
 
int WARN_MESSAGE = JOptionPane.WARNING_MESSAGE
 
TextAttribute WEIGHT = TextAttribute.WEIGHT
 
Float WEIGHT_BOLD = new Float(2.0f)
 
Float WEIGHT_DEMIBOLD = new Float(1.75f)
 
Float WEIGHT_DEMILIGHT = new Float(0.875f)
 
Float WEIGHT_EXTRA_LIGHT = new Float(0.5f)
 
Float WEIGHT_EXTRABOLD = new Float(2.5f)
 
Float WEIGHT_HEAVY = new Float(2.25f)
 
Float WEIGHT_LIGHT = new Float(0.75f)
 
Float WEIGHT_MEDIUM = new Float(1.5f)
 
Float WEIGHT_REGULAR = new Float(1.0f)
 
Float WEIGHT_SEMIBOLD = new Float(1.25f)
 
Float WEIGHT_ULTRABOLD = new Float(2.75f)
 
TextAttribute WIDTH = TextAttribute.WIDTH
 
Float WIDTH_CONDENSED = new Float(0.75f)
 
Float WIDTH_EXTENDED = new Float(1.5f)
 
Float WIDTH_REGULAR = new Float(1.0f)
 
Float WIDTH_SEMI_CONDENSED = new Float(0.875f)
 
Float WIDTH_SEMI_EXTENDED = new Float(1.25f)
 
int X4 = 1
 
int X8 = 2
 
int YELLOW_SCHEME = 2
 
int YES = JOptionPane.YES_OPTION
 
int YES_NO = JOptionPane.YES_NO_OPTION
 
int YES_NO_CANCEL = JOptionPane.YES_NO_CANCEL_OPTION
 

Detailed Description

The core class for the global manipulation and execution of G4P.
All the methods and constants are static so to call a method or reference a constant prefix it's name with 'G4P.' for example

G4P.method_name(parameters);
G4P.name_of_constant;


Please note that the methods

selectColor(...)
selectFolder(...)
selectInput(...)
selectOutput(...)

are provided modal alternatives to those provided in Processing 3 and only work in JAVA2D mode.
They are provided as-is and have not been tested on all platforms. If they don't work for you then use those provided by Processing.

Author
Peter Lager

Member Function Documentation

static GControlMode g4p_controls.G4P.getCtrlMode ( )
static

Get the control creation mode

See Also
ctrlMode(int mode)
Returns
the current control mode
static int g4p_controls.G4P.getCursor ( )
static

Get the cursor shape used when the mouse is not over a G4P control'

Returns
the cursor not-over shape id
static int g4p_controls.G4P.getCursorOff ( )
static
Returns
the cursor not-over shape id
Deprecated:
use getCursor()
static GWindow [] g4p_controls.G4P.getOpenWindowsAsArray ( )
static

Get an array of GWindow objects even if minimised or invisible.
This method never returns null, if there are no open windows the array will be of length zero.

Returns
an array of references to all open GWindow objects.
static ArrayList<GWindow> g4p_controls.G4P.getOpenWindowsAsList ( ArrayList< GWindow list)
static

Get a list of all open GWindow objects even if minimised or invisible.
If an ArrayList is provided then its contents are cleared before adding references to all open GWindow objects. If an ArrayList is not provided then a new ArrayList will be created.
This method never returns null, if there are no open windows the list will be of size zero.

Parameters
listan optional ArrayList to use. In null will create a new ArrayList.
Returns
an ArrayList of references to all open GWindow objects.
static String g4p_controls.G4P.getPrettyVersion ( )
static
Returns
the pretty version of the library. This will be shown in Processing
static String g4p_controls.G4P.getVersion ( )
static
Returns
the version of the library.
static boolean g4p_controls.G4P.isWindowOpen ( GWindow  window)
static

Use this to check whether a GWindow window is still open (as far as G4P is concerned).

Parameters
windowthe window we are interested in
Returns
true if G4P still thinks it is open
static void g4p_controls.G4P.messagesEnabled ( boolean  enable)
static

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.

If you are adding your own event handlers then I suggest that you disable messages.

Parameters
enablewhether to enable messages or not
static void g4p_controls.G4P.mouseWheelScrollbarDirection ( int  dir)
static

Determines how the direction of the mouse wheel rotation is interpreted for sliders. This value applies to all sliders.
The default value is FORWARD

Parameters
dirFORWARD or REVERSE, illegal values are ignored
static void g4p_controls.G4P.mouseWheelSliderDirection ( int  dir)
static

Determines how the direction of the mouse wheel rotation is interpreted for sliders and knobs. This value applies to all sliders and knobs.
The default value is FORWARD

Parameters
dirFORWARD or REVERSE, illegal values are ignored
static void g4p_controls.G4P.mouseWheelSpinnerDirection ( int  dir)
static

Determines how the direction of the mouse wheel rotation is interpreted for spinners. This value applies to all spinners.
The default value is FORWARD

Parameters
dirFORWARD or REVERSE, illegal values are ignored
static void g4p_controls.G4P.registerSketch ( PApplet  app)
static

Used to register the main sketch window with G4P. This is ignored if any G4P controls or windows have already been created because the act of creating a control will do this for you.

Some libraries such as PeasyCam change the transformation matrix when initiated. In which case either a G4P control should be created or this method called before creating a PeasyCam object.

Parameters
appthe main sketch PApplet usually 'this'
static int g4p_controls.G4P.selectColor ( )
static

This will open a version of the Java Swing color chooser dialog. The dialog's UI is dependent on the OS and JVM implementation running.

If you click on Cancel then it returns the last color previously selected.

Returns
the RGB color as a 32 bit integer (as used in Processing).
static int g4p_controls.G4P.selectColor ( Color  color)
static

This will open a version of the Java Swing color chooser dialog. The dialog's UI is dependent on the OS and JVM implementation running.

If you click on Cancel then it returns the last color previously selected.

Parameters
colorthe color to start the dialog
Returns
the RGB color as a 32 bit integer (as used in Processing).
static int g4p_controls.G4P.selectColor ( int  color)
static

This will open a version of the Java Swing color chooser dialog. The dialog's UI is dependent on the OS and JVM implementation running.

If you click on Cancel then it returns the last color previously selected.

Parameters
colorthe color to start the dialog. RGB color
Returns
the RGB color as a 32 bit integer (as used in Processing).
static int g4p_controls.G4P.selectColor ( int  red,
int  green,
int  blue 
)
static

This will open a version of the Java Swing color chooser dialog. The dialog's UI is dependent on the OS and JVM implementation running.

If you click on Cancel then it returns the last color previously selected.

Parameters
redred channel value (0-255)
greengreen channel value (0-255)
bluered channel value (0-255)
Returns
the RGB color as a 32 bit integer (as used in Processing).
static int g4p_controls.G4P.selectColorImpl ( Color  color)
staticprotected

This will open a version of the Java Swing color chooser dialog. The dialog's UI is dependent on the OS and JVM implementation running.

If you click on Cancel then it returns the last color previously selected.

Returns
the RGB color as a 32 bit integer (as used in Processing).
static String g4p_controls.G4P.selectFolder ( String  prompt)
static

Select a folder from the local file system.

Parameters
promptthe frame text for the chooser
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String g4p_controls.G4P.selectInput ( String  prompt)
static

Select a file for input from the local file system.

Parameters
promptthe frame text for the chooser
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String g4p_controls.G4P.selectInput ( String  prompt,
String  startFolder 
)
static

Select a file for input from the local file system.

Parameters
promptthe frame text for the chooser
startFolderthe location to start the dialog box
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String g4p_controls.G4P.selectInput ( String  prompt,
String  types,
String  typeDesc 
)
static

Select a file for input from the local file system.

This version allows the dialog window to filter the output based on file extensions. This is not available on all platforms, if not then it is ignored.

It is definitely available on Linux systems because it uses the standard Swing JFileFinder component.

Parameters
promptthe frame text for the chooser
typesa comma separated list of file extensions e.g. "png,gif,jpg,jpeg"
typeDescsimple textual description of the file types e.g. "Image files"
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String g4p_controls.G4P.selectInput ( String  prompt,
String  types,
String  typeDesc,
String  startFolder 
)
static

Select a file for input from the local file system.

This version allows the dialog window to filter the output based on file extensions. This is not available on all platforms, if not then it is ignored.

It is definitely available on Linux systems because it uses the standard Swing JFileFinder component.

Parameters
promptthe frame text for the chooser
typesa comma separated list of file extensions e.g. "png,gif,jpg,jpeg"
typeDescsimple textual description of the file types e.g. "Image files"
startFolderthe folder where the dialog starts (uses default if null or not a folder)
Returns
the absolute path name for the selected folder, or null if action cancelled.
static int g4p_controls.G4P.selectOption ( PApplet  owner,
String  message,
String  title,
int  messageType,
int  optionType 
)
static

Display a simple message dialog window.

The actual UI will depend on the platform your application is running on.

The message type should be one of the following
G4P.PLAIN_MESSAGE, G4P.ERROR_MESSAGE, G4P.INFO_MESSAGE, G4P.WARN_MESSAGE, G4P.QUERY_MESSAGE

The option type should be one of the following
G4P.YES_NO, G4P.YES_NO_CANCEL, G4P.OK_CANCEL

This method returns a value to indicate which button was clicked. It will be one of the following
G4P.OK, G4P.YES, G4P.NO, G4P.CANCEL, G4P.CLOSED

Some comments on the returned value:

  • G4P.OK and G4P.YES have the same integer value so can be used interchangeably.
  • G4P.CLOSED maybe returned if the dialog box is closed although on some systems G4P.NO or G4P.CANCEL may be returned instead.
  • It is better to test for a positive response because they have the same value.
  • If you must test for a negative response use !G4P.OK or !G4P.YES
Parameters
ownerthe control responsible for this dialog.
messagethe text to be displayed in the main area of the dialog
titlethe text to appear in the dialog's title bar.
messageTypethe message type
optionTypean integer designating the options available on the dialog DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION, or OK_CANCEL_OPTION
Returns
which button was clicked
static String g4p_controls.G4P.selectOutput ( String  prompt)
static

Select a file for output from the local file system.

Parameters
promptthe frame text for the chooser
Returns
the absolute path name for the selected folder, or null if action is cancelled.
static String g4p_controls.G4P.selectOutput ( String  prompt,
String  startFolder 
)
static

Select a file for output from the local file system.

Parameters
promptthe frame text for the chooser
startFolderthe folder where the dialog starts (uses default if null or not a folder)
Returns
the absolute path name for the selected folder, or null if action is cancelled.
static String g4p_controls.G4P.selectOutput ( String  prompt,
String  types,
String  typeDesc 
)
static

Select a file for output from the local file system.

This version allows the dialog window to filter the output based on file extensions. This is not available on all platforms, if not then it is ignored.

It is definitely available on Linux systems because it uses the standard swing JFileFinder component.

Parameters
promptthe frame text for the chooser
typesa comma separated list of file extensions e.g. "png,jpf,tiff"
typeDescsimple textual description of the file types e.g. "Image files"
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String g4p_controls.G4P.selectOutput ( String  prompt,
String  types,
String  typeDesc,
String  startFolder 
)
static

Select a file for output from the local file system.

This version allows the dialog window to filter the output based on file extensions. This is not available on all platforms, if not then it is ignored.

It is definitely available on Linux systems because it uses the standard swing JFileFinder component.

Parameters
promptthe frame text for the chooser
typesa comma separated list of file extensions e.g. "png,jpf,tiff"
typeDescsimple textual description of the file types e.g. "Image files"
startFolderthe folder where the dialog starts (uses default if null or not a folder)
Returns
the absolute path name for the selected folder, or null if action cancelled.
static void g4p_controls.G4P.setCtrlMode ( GControlMode  mode)
static

Change the way position and size parameters are interpreted when a control is created. or added to another control e.g. GPanel.
There are 3 modes.

GCtrlMode.CORNER     (x, y, w, h) 
GCtrlMode.CORNERS (x0, y0, x1, y1)
GCtrlMode.CENTER (cx, cy, w, h)


Parameters
modeillegal values are ignored leaving the mode unchanged
static void g4p_controls.G4P.setCursor ( int  cursorOff)
static

Set the cursor shape to be used when the mouse is not over a G4P control for the entire application including secondary windows.

Parameters
cursorOffthe cursor shape.
static void g4p_controls.G4P.setCursorOff ( int  cursorOff)
static
Parameters
cursorOffthe cursor shape.
Deprecated:
use setCursor(int)
static void g4p_controls.G4P.setDisplayFont ( String  familyName,
int  style,
int  size 
)
static

Set the display font to be used with Buttons, labels, droplists panels etc. It only effects controls created after this method is called.

If it can't find the font on your system it will use [Arial, PLAIN, 12]

Parameters
familyNamefont family name e.g. "Arial", "Trebuchet MS", "Tahoma", "Helvetica", "Verdana"
stylesome combination of G4P.PLAIN, G4P.BOLD and G4P.ITALIC
sizethe font size (constrained to >= 6 point)
static void g4p_controls.G4P.setGlobalAlpha ( int  alpha)
static

Set the transparency of all controls. If the alpha level for a control falls below G4P.ALPHA_BLOCK then it will no longer respond to mouse and keyboard events.

Parameters
alphavalue in the range 0 (transparent) to 255 (opaque)
static void g4p_controls.G4P.setGlobalColorScheme ( int  cs)
static

Set the global colour scheme. This will change the local colour scheme for every control.

Parameters
cscolour scheme to use (0-15)
static void g4p_controls.G4P.setInputFont ( String  familyName,
int  style,
int  size 
)
static

Set the text font to be used for keyboard input into GTexField, GTextArea and GPassword controls. It only effects input controls created after this method is called.

If it can't find the font on your system it will use [Arial, PLAIN, 12]

Parameters
familyNamefont family name e.g. "Arial", "Trebuchet MS", "Tahoma", "Helvetica", "Verdana"
stylesome combination of G4P.PLAIN, G4P.BOLD and G4P.ITALIC
sizethe font size (constrained to >= 6 point)
static void g4p_controls.G4P.setMouseOverEnabled ( boolean  enable)
static

Enables or disables cursor over component change.

Calls to this method are ignored if no G4P controls have been created.

Parameters
enabletrue to enable cursor change over components.
static void g4p_controls.G4P.setSliderFont ( String  familyName,
int  style,
int  size 
)
static

Set the font to be used with sliders. It only effects sliders created after this method is called.
If it can't find the font on your system it will use [Arial, BOLD, 11]

Parameters
familyNamefont family name e.g. "Arial", "Trebuchet MS", "Tahoma", "Helvetica", "Verdana"
stylesome combination of G4P.PLAIN, G4P.BOLD and G4P.ITALIC
sizethe font size (constrained to >= 6 point)
static void g4p_controls.G4P.setWindowAlpha ( PApplet  app,
int  alpha 
)
static

Set the transparency level for all controls drawn by the given PApplet. If the alpha level for a control falls below G4P.ALPHA_BLOCK then it will no longer respond to mouse and keyboard events.

Parameters
appthe main sketch window or GWindow instance
alphavalue in the range 0 (transparent) to 255 (opaque)
static void g4p_controls.G4P.setWindowColorScheme ( PApplet  app,
int  cs 
)
static

Set the colour scheme for all the controls drawn by the given PApplet. This will override any previous colour scheme for these controls.

Parameters
appeither the main sketch PApplet or GWindo
cscolour scheme number
static void g4p_controls.G4P.showMessage ( PApplet  owner,
String  message,
String  title,
int  messageType 
)
static

Display a simple message dialog window.

The actual UI will depend on the platform your application is running on.

The message type should be one of the following
G4P.PLAIN_MESSAGE, G4P.ERROR_MESSAGE, G4P.INFO_MESSAGE, G4P.WARN_MESSAGE, G4P.QUERY_MESSAGE

Parameters
ownerthe control responsible for this dialog.
messagethe text to be displayed in the main area of the dialog
titlethe text to appear in the dialog's title bar.
messageTypethe message type
static void g4p_controls.G4P.usePre35Fonts ( )
static

Versions of G4P prior to 3.5 used logical fonts for the controls. So if you have old sketches then the text may look different with this and later versions of G4P.
If this is causing a problem then call this method before creating any controls.