public static Font getPriorityFont(String[] familyFontNamnes,
- int style,
- int size)
-
Get a system font that matches one the font family names with the style and size. If
- it can't find a suitable system font from the font family it returns a logical
- font (Dialog) of the specified style and size.
-
Parameters:
familyFontNamnes - user defined list of family font names or null to use default list
public class G4P
-extends Object
-implements GConstants, processing.core.PConstants
-
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
-
-
- Prior to version 3.5 G4P used logical fonts to be cross-platform,
- unfortunately logical fonts do not use uniform metrics so it caused
- serious errors when formatting the text layout. In version 3.5 G4P
- will attempt to use a system fonts selected from this list
- "Arial", "Trebuchet MS", "Tahoma", "Helvetica", "Verdana"
-
- Arial is the preferred font (since most systems will have it installed)
- but if not found it will attempt to use the next one in the list. If
- the list is exhausted and no matching system font found it will use
- a logical font.
- If this causes a problem with older sketches simple call
-
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.
public static void registerSketch(processing.core.PApplet app)
-
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 controls are created without passing a reference to the sketch applet
- but still need to know it. An example is the GColorChooser control which
- cannot be used until this method is called or some other G4P control has
- been created.
-
- Also some other libraries such as PeasyCam change the transformation matrix.
- In which case either a G4P control should be created or this method called
- before creating a PeasyCam object.
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.
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:
alpha - value in the range 0 (transparent) to 255 (opaque)
public static void setWindowAlpha(processing.core.PApplet app,
- int alpha)
-
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:
app -
alpha - value in the range 0 (transparent) to 255 (opaque)
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.
-
- If you are adding your own event handlers then I suggest that you disable
- messages.
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:
dir - FORWARD or REVERSE, illegal values are ignored
public static void mouseWheelForScrollbar(int dir)
-
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:
dir - FORWARD or REVERSE, illegal values are ignored
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:
list - an optional ArrayList to use. In null will create a new ArrayList.
-
Returns:
an ArrayList of references to all open GWindow objects.
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.
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 ARGB colour as a 32 bit integer (as used in Processing).
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:
prompt - the frame text for the chooser
types - a comma separated list of file extensions e.g. "png,gif,jpg,jpeg"
typeDesc - simple textual description of the file types e.g. "Image files"
-
Returns:
the absolute path name for the selected folder, or null if action
- cancelled.
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:
prompt - the frame text for the chooser
types - a comma separated list of file extensions e.g. "png,jpf,tiff"
typeDesc - simple textual description of the file types e.g. "Image files"
-
Returns:
the absolute path name for the selected folder, or null if action
- cancelled.
public static void showMessage(processing.core.PApplet owner,
- String message,
- String title,
- int messageType)
-
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, G4P.ERROR, G4P.INFO, G4P.WARNING, G4P.QUERY
-
Parameters:
owner - the control responsible for this dialog.
message - the text to be displayed in the main area of the dialog
title - the text to appear in the dialog's title bar.
public static int selectOption(processing.core.PApplet owner,
- String message,
- String title,
- int messageType,
- int optionType)
-
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, G4P.ERROR, G4P.INFO, G4P.WARNING, G4P.QUERY
-
- 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:
owner - the control responsible for this dialog.
message - the text to be displayed in the main area of the dialog
title - the text to appear in the dialog's title bar.
This is for emergency use only!!!!
- In this version of the library a visual controls is drawn to off-screen buffer
- and then drawn to the screen by copying the buffer.
Enable or disable the ability of the component to generate mouse events.
- GTextField - it also controls key press events
- GPanel - controls whether the panel can be moved/collapsed/expanded
public GAbstractControl(processing.core.PApplet theApplet)
-
Base constructor for ALL control ctors that do not have a visible UI but require
- access to a PApplet object.
- As of V3.5 the only class using this constructor is GGroup
public GAbstractControl(processing.core.PApplet theApplet,
- float p0,
- float p1)
-
Base constructor for ALL control ctors that have a visible UI but whose width and height
- are determined elsewhere e.g. the size of an image. It will set the
- position of the control based on controlMode.
This will remove all references to this control in the library.
- The user is responsible for nullifying all references to this control
- in their sketch code.
- Once this method is called the control cannot be reused but resources
- used by the control remain until all references to the control are
- set to null.
This is for emergency use only!!!!
- In this version of the library a visual controls is drawn to off-screen buffer
- and then drawn to the screen by copying the buffer. This means that the
- computationally expensive routines needed to draw the control (especially text
- controls) are only done when a change has been noted. This means that single
- changes need not trigger a full redraw to buffer.
- It does mean that an error in the library code could result in the buffer not
- being updated after changes. If this happens then in draw() call this method
- on the affected control, and report it as an issue
- here
- Thanks
public void setLocalColor(int colorNo,
- int color)
-
Change a specific colour within the scheme.
- Most controls used a shared colour palette but calling this method
- will create a new palette specific for this control.
public void setAlpha(int alpha,
- boolean includeChildren)
-
Set the transparency of the component and make it unavailable to
- mouse and keyboard events if below the threshold. Child controls
- are ignored?
- If required include the children and their children.
-
Parameters:
alpha - value in the range 0 (transparent) to 255 (opaque)
includeChildren - if do do the same for all descendants
public void addEventHandler(Object obj,
- String methodName)
-
Attempt to create the default event handler for the component class.
- The default event handler is a method that returns void and has a single
- parameter of the same type as the component class generating the
- event and a method name specific for that class.
-
Parameters:
obj - the object to handle the event
methodName - the method to execute in the object handler class
Move the control to the given position based on the mode.
-
- The position is not constrained to the screen area.
-
- The current control mode determines whether we move the
- corner or the center of the control to px,py
public void moveTo(float px,
- float py,
- GControlMode mode)
-
Move the control to the given position based on the mode.
-
- Unlike when dragged the position is not constrained to the
- screen area.
-
- The mode determines whether we move the corner or the center
- of the control to px,py
Get the left position of the control.
- If the control is on a panel then the value returned is relative to the
- top-left corner of the panel otherwise it is relative to the sketch
- window display.
Get the top position of the control.
- If the control is on a panel then the value returned is relative to the
- top-left corner of the panel otherwise it is relative to the sketch
- window display.
Get the centre x position of the control.
- If the control is on a panel then the value returned is relative to the
- top-left corner of the panel otherwise it is relative to the sketch
- window display.
Get the centre y position of the control.
- If the control is on a panel then the value returned is relative to the
- top-left corner of the panel otherwise it is relative to the sketch
- window display.
Enable or disable the ability of the component to generate mouse events.
- GTextField - it also controls key press events
- GPanel - controls whether the panel can be moved/collapsed/expanded
public void addControl(GAbstractControl c,
- float x,
- float y,
- float angle)
-
This will set the rotation of the control to angle overwriting
- any previous rotation set. Then it calculates the centre position
- so that the original top left corner of the control will be the
- position indicated by x,y with respect to the top left corner of
- parent.
-
- The added control will have its position calculated relative to the
- centre of the parent control.
-
- All overloaded methods call this one.
-
Parameters:
c - the control to add.
x - the leftmost or centre position depending on controlMode
y - the topmost or centre position depending on controlMode
angle - the rotation angle (replaces any the angle specified in control)
If the control is permanently no longer required then call
- this method to remove it and free up resources.
- The variable identifier used to create this control should
- be set to null.
- For example if you want to dispose of a button called
-
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (GAlign c : GAlign.values())
- System.out.println(c);
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
Parameters:
name - the name of the enum constant to be returned.
This class is the Button component.
-
- The button face can have either text or an image or both just
- pick the right constructor.
-
- Three types of event can be generated :-
- PRESSED RELEASED CLICKED
-
- To simplify event handling the button only fires off CLICKED events
- if the mouse button is pressed and released over the button face
- (the default behaviour).
-
- Using
button1.fireAllEvents(true);
enables the other 2 events
- for button button1. A PRESSED event is created if the mouse button
- is pressed down over the button face, the CLICKED event is then generated
- if the mouse button is released over the button face. Releasing the
- button off the button face creates a RELEASED event.
-
- The image file can either be a single image which is used for
- all button states, or be a composite of 3 images (tiled horizontally)
- which are used for the different button states OFF, OVER and DOWN
- in which case the image width should be divisible by 3.
- A number of setImages(...) methods exist to set button state images, these
- can be used once the button is created.
Enable or disable the ability of the component to generate mouse events.
- If the control is to be disabled when it is clicked then this will force the
- mouse off button image is used.
Enable or disable the ability of the component to generate mouse events.
- If the control is to be disabled when it is clicked then this will force the
- mouse off button image is used.
public void mouseEvent(processing.event.MouseEvent event)
-
When a mouse button is clicked on a GButton it generates the GEvent.CLICKED event. If
- you also want the button to generate GEvent.PRESSED and GEvent.RELEASED events
- then you need the following statement.
-
public class GCScheme
-extends Object
-implements GConstants, processing.core.PConstants
-
Defines a number of color schemes for the GUI components.
- G4P supports 16 colour schemes and each scheme has a palette of 16 colours.
-
- When G4P is used it loads an image file with all the colors used by the various colour schemes.
- First it will search for a file containing a user defined scheme (user_gui_palette.png) and
- if it can't find it, will use the library default scheme (default_gui_palette.png).
Set the color scheme to one of the preset schemes
- BLUE / GREEN / RED / PURPLE / YELLOW / CYAN / BROWN
- or if you have created your own schemes following the instructions
- at gui4processing.lagers.org.uk/colorscheme.html then you can enter
- the appropriate numeric value of the scheme.
Set the color scheme to one of the preset schemes
- BLUE / GREEN / RED / PURPLE / YELLOW / CYAN / BROWN
- or if you have created your own schemes following the instructions
- at gui4processing.lagers.org.uk/colorscheme.html then you can enter
- the appropriate numeric value of the scheme.
public static void changePalette(int schemeNbr,
- int[] colors)
-
Change a colour scheme to use the colours passed in the third parameter.
- Colour scheme numbers 0-7 inclusive are the default colour schemes and
- schemes 8-15 inclusive are undefined by G4P.
- This method will override the previous scheme and will affect all controls
- using the scheme.
A two-state toggle control.
-
- GCheckbox objects (also known as tick boxes) are two-state toggle switches that are
- used independently of other tick boxes.
Clipboard functionaliy for plain text
-
- This provides clipboard functionality for text and is currently only used by the
- GTextField and GTextArea classes.
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (GControlMode c : GControlMode.values())
- System.out.println(c);
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
Parameters:
name - the name of the enum constant to be returned.
Slider that can be customised with user provided graphics.
-
- This class replaces the GWSlider provided in pre v3 editions of this library.
-
- The main difference to the GSlider class is the ability to skin the slider with user provided graphics.
- The library provides a number of skins ready for use. You specify the skin to use when the slider is created
- and if the library is unable to load the skin it will print a warning and load the default skin instead.
-
Library skins available
-
-
grey_blue (default skin)
-
green_red20px
-
red_yellow18px
-
blue18px
-
purple18px
-
- A skin requires 5 image files for different parts of the slider which must be stored in their own
- folder (the folder name is also used as the skin name) and this folder should be place inside the
- sketch's data folder.
-
The image files have specific names.
-
-
Left end cap of the slider(end_left.???)
-
Right end cap of the slider(end_right.???)
-
An extendible centre segment(centre.???)
-
Draggable thumb (handle.??? and handle_mouseover.???)
-
- Where ??? is the image type file extension. The image type can be any that Processing can handle, the
- most common types will be png, jpg or gif but tga is also permitted
-
-
There are very few restrictions about the images you use but when designing the images you should consider
- the following facts:
-
-
the slider will be created to fit the control size (specified in the constructor)
-
the horizontal space allocated for the end-caps will be the same for each end (uses the width or the larger end cap image)
-
the track width will be the height of the centre image
-
the centre image will be tiled along the track length
-
the track will be placed in the horizontal and vertical centre of the control.
-
the end cap images will be placed in the vertical centre of the control and butted against the track.
A drop down list component.
-
- This replaces the GCombo control in pre V3 editions of this library.
-
- The number of items in the list is not restricted but the user can define
- the maximum number of items to be displayed in the drop list. If there are
- too many items to display a vertical scroll bar is provide to scroll through
- all the items.
-
- The vertical size of an individual item is calculated from the overall height
- specified when creating the control.
public void setItems(String[] array,
- int selected)
-
Use this to set or change the list of items to appear in the list. If
- you enter an invalid selection index then it is forced into
- the valid range.
- Null and empty values in the list will be ignored.
- If the list is null then or empty then then no changes are made.
Remove an item from the list.
- If idx is not a valid position in the list then the list is unchanged.
- If idx points to the selected item or an item below it then the
- selected index value is reduced by 1 but the selected text remains the
- same.
- If idx points to an item above the selected item then the selected
- item is unchanged.
- No event is fired even if the selected index changes.
Insert an item at the specified position in the list.
- If idx is <0 then the list is unchanged.
- If idx is >= the number of items in the list, it is added to the end.
- If idx points to the selected item or an item below it then the
- selected index value is incremented by 1 but the selected text remains
- the same.
- If idx points to an item above the selected item then the selected
- item is unchanged.
- No event is fired even if the selected index changes.
-
Parameters:
idx - index of the item to remove
name - text of the item to insert (null values ignored)
public void addStyle(TextAttribute attr,
- Object value,
- int charStart,
- int charEnd)
-
Adds the text attribute to a range of characters on a particular line. If charEnd
- is past the EOL then the attribute will be applied to the end-of-line.
-
Parameters:
attr - the text attribute to add
value - value of the text attribute
charStart - the position of the first character to apply the attribute
charEnd - the position after the last character to apply the attribute
Adds the text attribute to a range of characters on a particular line. If charEnd
- is past the EOL then the attribute will be applied to the end-of-line.
public void setTextEditEnabled(boolean enableTextEdit)
-
Determines whether the text can be edited using the keyboard or mouse. It
- still allows the text to be modified by the sketch code.
- If text editing is being disabled and the control has focus then it is forced
- to give up that focus.
- This might be useful if you want to use a GTextArea control to display large
- amounts of text that needs scrolling (so cannot use a GLabel) but must not
- change e.g. a user instruction guide.
Enumeration of events that can be fired by G4P.
-
- GTextField and GTextArea events
- CHANGED Text has changed
- SELECTION_CHANGED Text selection has changed
- ENTERED Enter/return key typed
- LOST_FOCUS TextField/Area lost focus
- GETS_FOCUS TextField/Area got focus
-
- GPanel events
- COLLAPSED Control was collapsed
- EXPANDED Control was expanded
- DRAGGED Control is being dragged
-
- Button control events (PRESSED and RELEASED are not fired by default)
- CLICKED Mouse button was clicked
- PRESSED Mouse button was pressed
- RELEASED Mouse button was released
-
- Slider control events events
- VALUE_CHANGING Value is changing
- VALUE_STEADY Value has reached a steady state
- DRAGGING The mouse is being dragged over a component
-
- GCheckbox & GOption events
- SELECTED ( "Option selected
- DESELECTED ( "Option de-selected
Returns an array containing the constants of this enum type, in
-the order they are declared. This method may be used to iterate
-over the constants as follows:
-
-for (GEvent c : GEvent.values())
- System.out.println(c);
-
-
Returns:
an array containing the constants of this enum type, in
-the order they are declared
Returns the enum constant of this type with the specified name.
-The string must match exactly an identifier used to declare an
-enum constant in this type. (Extraneous whitespace characters are
-not permitted.)
-
Parameters:
name - the name of the enum constant to be returned.
This class allows you to group GUI controls so that they can be treated as a single
- entity for common GUI actions.
- Once grouped a single statement change the enabled status, visibility status, colour
- scheme and transparency for all the controls in the group. It is possible to
- specify a delay before the action is executed, and in the case of transparency, specify
- the amount of time the fade occurs.
- This is particularly useful if your sketch has a number of 'modes' and each mode has its
- own set of G4P controls. Simply create a GGroup object for each mode then as the mode
- changes it is easy to display the controls for the current mode and hide the others.
- A GGroup is associated with a window (or GWindow) and can only be used with controls
- displayed on that window.
Create a control group for the indicated PApplet. Only controls
- created with this PApplet can be added to this group.
-
- All controls added will be initialised as fully opaque.
public GGroup(processing.core.PApplet theApplet,
- int startAlpha)
-
Create a control group for the indicated PApplet. Only controls
- created with this PApplet can be added to this group.
-
- All controls added will be initialised as fully opaque.
-
Parameters:
theApplet - the associated PApplet
startAlpha - the starting alpha level (must 0-255 incl)
Create a control group for the indicated GWindow. Only controls
- displayed in this GWindow can be added to this group.
-
- All controls added will be initialised as fully opaque.
Make the control visible or invisible with immediate effect.
- If you simply want to change the controls' visibility status then
- use this in preference to fadeIn/fadeOut
Add one or more G4P controls to this group.
- If a control is not a valid type for group control, or if the control and group are for different
- windows then the control is not added and a warning message is displayed.
A single G4P control to add to this group.
- If a control is not a valid type for group control, or if the control and group are for different
- windows then the control is not added and a warning message is displayed.
Buttons create from this class use a number of images to represent it's
- state. This means that buttons can have an irregular and/or discontinuous
- shape.
-
Determining the control size
- If when creating the button you specify a particular width and height then
- any images that are not the same size will be scaled to fit without regard
- to the original size or aspect ratio.
-
- If when creating the button you do not specify the width and height then it
- will use the width and height of the 'off-button' image and assume that all the
- other images are the same size.
-
-
The images
- The image button needs 1 to 3 image files to represent the button states
- OFF mouse is not over button
- OVER mouse is over the button
- DOWN the mouse is over the button and a mouse button is being pressed.
-
- If you only provide one image then this will be used for all states, if you
- provide two then the second image is used for both OVER and DOWN states.
-
- If you don't provide a mask file then the button 'hotspot' is represented by any
- non-transparent pixels in the OFF image. If you do provide a mask file then the
- hotspot is defined by any black pixels in the mask image.
-
-
- Three types of event can be generated :-
- GEvent.PRESSED GEvent.RELEASED GEvent.CLICKED
-
- To simplify event handling the button only fires off CLICKED events
- when the mouse button is pressed and released over the button face
- (the default behaviour).
-
- Using
button1.fireAllEvents(true);
enables the other 2 events
- for button button1. A PRESSED event is created if the mouse button
- is pressed down over the button face, the CLICKED event is then generated
- if the mouse button is released over the button face. Releasing the
- button off the button face creates a RELEASED event.
Enable or disable the ability of the component to generate mouse events.
- If the control is to be disabled when it is clicked then this will force the
- mouse off button image is used.
public void mouseEvent(processing.event.MouseEvent event)
-
When a mouse button is clicked on a GImageButton it generates the GEvent.CLICKED event. If
- you also want the button to generate GEvent.PRESSED and GEvent.RELEASED events
- then you need the following statement.
-
Enable or disable the ability of the component to generate mouse events.
- If the control is to be disabled when it is clicked then this will force the
- mouse off button image is used.
Buttons created from this class have 2 or more toggle states. If the number of states
- is N then the button's value will be in the range 0 to N-1. Most toggle buttons will
- have just two states and these have values 0 and 1.
- Clicking on the button advances the state by one, restarting at zero after the last
- state.
- Each state must have its own 'picture' and the user must supply these as a tiled image
- where the pictures are tiled in 1D or 2D arrangement without 'empty space' around the
- tiles.
- If for any reason the library is unable to use the specified graphics then it will
- provide a default two state toggle switch.
- It is also possible to provide an over-button image set for when the mouse moves
- over the button - this is optional.
- The button control will always be resized to suit the state picture size (tile size).
- The mouse is considered to be over the button it its position is over an opaque pixel
- in the state picture. Since transparent pixels are not included then the button shape
- can be different for each state.
-
-
-
- Three types of event can be generated :-
- GEvent.PRESSED GEvent.RELEASED GEvent.CLICKED
-
- To simplify event handling the button only fires off CLICKED events
- when the mouse button is pressed and released over the button face
- (the default behaviour).
-
- Using
button1.fireAllEvents(true);
enables the other 2 events
- for button button1. A PRESSED event is created if the mouse button
- is pressed down over the button face, the CLICKED event is then generated
- if the mouse button is released over the button face. Releasing the
- button off the button face creates a RELEASED event. This is included for
- completeness since it is unlikely you will need to detect these events
- for this type of control.
public void mouseEvent(processing.event.MouseEvent event)
-
When a mouse button is clicked on a GImageToggleButton it generates the GEvent.CLICKED event. If
- you also want the button to generate GEvent.PRESSED and GEvent.RELEASED events
- then you need the following statement.
-
If the parameter is true all 3 event types are generated, if false
- only CLICKED events are generated (default behaviour).
- For this toggle control I can't see the need for anything but
- CLICKED events
The provides an extremely configurable GUI knob controller. GKnob
- inherits from GValueControl so you should read the documentation
- for that class as it also applies to GKnob.
-
- Configurable options
- Knob size but it must be circular
- Start and end of rotation arc.
- Bezel width with tick marks
- User defined value limits (i.e. the range of values returned
-
- Range of values associated with rotating the knob
- Rotation is controlled by mouse movement - 3 modes available
- (a) angular - drag round knob center
- (b) horizontal - drag left or right
- (c) vertical - drag up or down
- User can specify mouse sensitivity for modes (b) and (c)
- Use can specify easing to give smoother rotation
-
- Note: Angles are measured clockwise starting in the positive x direction i.e.
-
This gets the sensitivity to be used in modes CTRL_HORIZONTAL and CTRL_VERTICAL
- A value of 1 is 1 degree per pixel and a value of 2 is 2 degrees per pixel.
Set the mouse control mode to use, acceptable values are
- GKnob.CTRL_ANGULAR or GKnob.CTRL_HORIZONTAL) orGKnob.CTRL_VERTICAL any
- other value will be ignored.
Will create the a circular knob control that fits the rectangle define by
- the values passed as parameters.
- The knob has two zones the outer bezel and the inner gripper. The radius of
- the outer bezel is calculated from
-
bezel radius = min(width, height)/2 - 2
- The radius of the inner griper radius is calculated from the bezel radius
- and the last parameter.
-
grip radius = bezel radiius * gripAmount
- The gripAmount should be in te range 0.0 to 1.0 inclusive. The actual value
- will be constrained to that range.
Decides when the knob will respond to the mouse buttons. If set to true
- it will only respond when ver the arc made by the start and end angles. If
- false it will be the full circle.
Set the mouse control mode to use, acceptable values are
- GKnob.CTRL_ANGULAR or GKnob.CTRL_HORIZONTAL) orGKnob.CTRL_VERTICAL any
- other value will be ignored.
This gets the sensitivity to be used in modes CTRL_HORIZONTAL and CTRL_VERTICAL
- A value of 1 is 1 degree per pixel and a value of 2 is 2 degrees per pixel.
public abstract class GLinearTrackControl
-extends GValueControl
-
Base class for linear sliders.
-
- This class provides the ability to control the orientation
- the text should be displayed. It also enables the use of labels
- for each tick mark.
Set the text orientation for the display of the limits and value if appropriate.
- Acceptable values are G4P.ORIENT_LEFT, G4P.ORIENT_RIGHT or G4P.ORIENT_TRACK
- If an invalid value is passed the ORIENT_TRACK is used.
This method is used to set the text to appear alongside the tick marks.
- The array passed must have a minimum of 2 elements and each label (element)
- must have at least 1 character. If these two conditions are not met then
- the call to this method will be ignored and no changes are made.
A two-state toggle control.
-
- GOption objects (also known as radio buttons) are two-state toggle switches that can either
- be used independently or if added to a GToggleGroup control part of a single selection
- option group.
A component that can be used to group GUI components that can be
- dragged, collapsed (leaves title tab only) and un-collapsed.
-
- When created the Panel is collapsed by default. To open the panel
- use setCollapsed(true); after creating it.
-
- Once a component has been added the x/y coordinates of the control are
- calculated to be the centre of the panel to the centre of the control. This
- is to facilitate rotating of controls on panels
Create a Panel that comprises of 2 parts the tab which is used to
- select and move the panel and the container window below the tab which
- is used to hold other components.
Create a Panel that comprises of 2 parts the tab which is used to
- select and move the panel and the container window below the tab which
- is used to hold other components.
Provided the panel is physically small enough this method will set the area
- within which the panel can be dragged and move the panel inside the area if
- not already inside.
Create a Panel that comprises of 2 parts the tab which is used to
- select and move the panel and the container window below the tab which
- is used to hold other components.
- If the panel fits inside the display window then its position will be
- constrained so that it can't be dragged outside the viewable area.
- Otherwise no constraint is applied.
Create a Panel that comprises of 2 parts the tab which is used to
- select and move the panel and the container window below the tab which
- is used to hold other components.
- If the panel fits inside the display window then its position will be
- constrained so that it can't be dragged outside the viewable area.
- Otherwise no constraint is applied.
Determines whether to show the tab and panel back colour. If the
- parameter is the same as the current state then no changes will
- be made.
- If the parameter is false then the panel will be
-
-
expanded
-
made non-collasible
-
made unavailable to mouse control (so can't be dragged)
-
- If the parameter is true then the panel will remain non-collapsible
- and the user must change this if required.
Determine whether the panel can be collapsed when the title bar is clicked.
-
- If this is set to false then the panel will be expanded and it will
- not be possible to collapse it until set back to true.
Provided the panel is physically small enough this method will set the area
- within which the panel can be dragged and move the panel inside the area if
- not already inside.
-
Parameters:
xMin -
yMin -
xMax -
yMax -
-
Returns:
true if the constraint was applied successfully else false
The password field component.
-
- This control allows the user to secretly enter a password and supports an
- optional horizontal scrollbar.
-
- Each key typed will display a # character, but the user can specify another character.
-
- Unlike a text field it does not support text selection or the copying and pasting of
- text via the clipboard.
-
- Fires CHANGED, ENTERED, LOST_FOCUS, GETS_FOCUS events.
- The focus events are only fired if the control is added to a GTabManager object.
Display area for user generated graphics.
-
- This control will display a PGraphics object created and updated by the user.
- If the size of the users graphic is different from the control the output will be
- rescaled to fit the control size irrespective of the aspect ratio.
A simple graphical slider.
-
- Either drag the thumb or click on the track to change the slider value.
-
- Supports
- user defined limits (ascending or descending values)
- numeric display for limits and current value
- track ticks and stick to ticks
Enable or disable the ability of the component to generate mouse events.
- GTextField - it also controls key press events
- GPanel - controls whether the panel can be moved/collapsed/expanded
Enable or disable the ability of the component to generate mouse events.
- GTextField - it also controls key press events
- GPanel - controls whether the panel can be moved/collapsed/expanded
This slider is used to control 2 variables by dragging the thumb over
- a 2D surface. It has all the features of the standard slider (GSlider)
- except that it does not have ticks or stick-to-ticks functionality.
-
- If no limits are set then the control will return a value in the range
- 0.0 to 1.0 for both the x and the y axis. The setXlimits and setYlimits
- can be used to set a different range for each axis independently.
-
- The minimum size for this control is 40x40 pixels and this is enforced
- when the control is created. If necessary the width and/or height the
- rectangle will be increased to 40pixels.
Set the amount of easing to be used when a value is changing. The default value
- is 1 (no easing) values > 1 will cause the value to rush from its starting value
- and decelerate towards its final values. In other words it smoothes the movement
- of the slider thumb or knob rotation.
public void setLimitsX(int initValue,
- int start,
- int end)
-
X (horz) limits
- Sets the initial value and the range of values to be returned. This
- method will assume that you want to set the valueType to INTEGER.
public void setLimitsX(float initValue,
- float start,
- float end)
-
X (horz) limits
- Sets the initial value and the range of values to be returned. This
- method will assume that you want to set the valueType to DECIMAL.
public void setLimitsY(int initValue,
- int start,
- int end)
-
Y (vert) limits
- Sets the initial value and the range of values to be returned. This
- method will assume that you want to set the valueType to INTEGER.
public void setLimitsY(float initValue,
- float start,
- float end)
-
Y (vert) limits
- Sets the initial value and the range of values to be returned. This
- method will assume that you want to set the valueType to DECIMAL.
public void setNumberFormat(int numberFormat,
- int precision)
-
Set the numberFormat and precision in one go.
- Valid number formats are INTEGER, DECIMAL, EXPONENT
- Precision must be >= 1 and is ignored for INTEGER.
Set the numberFormat and precision in one go.
- Valid number formats are INTEGER, DECIMAL, EXPONENT
- Precision must be >= 1 and is ignored for INTEGER.
-
Parameters:
numberFormat - G4P.INTEGER, G4P.DECIMAL or G4P.EXPONENT
This control simulates a digital joystick and is designed to give more
- intuitive control in game scenarios where you might use the keyboard
- e.g. WASD keys for movement.
-
- The joystick has two modes - in the default mode the joystick just
- responds to movement in 4 directions (left,right, up and down) the
- second mode allows for diagonals so recognises 8 directions.
-
- As in a real joystick you have a dead zone near the centre which
- does not generate signals, thus avoiding jitter. This area is shown
- graphically.
-
- The direction of the joystick is represented by an integer in the
- range 0-7 and -1 when in the dead zone.
-
- 5 6 7
- \ | /
- \ | /
- 4 --- + --- 0 + is the dea zone so -1
- / | \
- / | \
- 3 2 1
-
- As well as the direction there are two useful methods to decode these
- into X and Y directions -
- The stick will auto-center when released.
-
- The minimum size for this control is 40x40 pixels and this is enforced
- when the control is created. If necessary the width and/or height the
- rectangle will be increased to 40pixels.
Allows TABBING between text controls.
- A tab manager allows the user to use the TAB key to move from one text control
- (GTextField or GTextArea) to the another. This is useful when creating a 'form'
- made from several text controls.
- The tab order is decided by the order the text controls are added to the tab
- manager. The TAB key move the focus forwards and SHIFT+TAB moves it backwards.
- Note that tabbing is not cyclic so pressing TAB on the last control does not
- set the focus on the first control, in fact it will be ignored. Similar
- logic applies to SHIFT_TAB on the first control
- At least 2 controls must be added to the tab manager.
The text area component.
-
- This control allows the user to enter and edit multiple lines of text. The control
- also allows default text, horizontal and vertical scrollbars.
-
- Enables user to enter text at runtime. Text can be selected using the mouse
- or keyboard shortcuts and then copied or cut to the clipboard. Text
- can also be pasted in.
-
- There are some methods to add and clear text attributes to all or some of the
- text in the control. If a method is expecting a line number, you should specify
- the actual line number for the entire text (lines numbers start at 0). It is
- not the line number in the visible display because this can change if the text
- has been scrolled vertically.
-
-
- Fires SELECTION_CHANGED, CHANGED, ENTERED, LOST_FOCUS, GETS_FOCUS events.
- The focus events are only fired if the control is added to a GTabManager object.
public void addStyle(TextAttribute attr,
- Object value,
- int lineNo,
- int charStart,
- int charEnd)
-
Adds the text attribute to a range of characters on a particular display line. If charEnd
- is past the EOL then the attribute will be applied to the end-of-line.
-
Parameters:
attr - the text attribute to add
value - value of the text attribute
lineNo - the display line number (starts at 0)
charStart - the position of the first character to apply the attribute
charEnd - the position after the last character to apply the attribute
public void clearStyles(int lineNo,
- int charStart,
- int charEnd)
-
Clears all text attribute from a range of characters on a particular display line.
- If charEnd is past the EOL then the attributes will be cleared to the
- end-of-line.
-
Parameters:
lineNo - the display line number (starts at 0)
charStart - the position of the first character to apply the attribute
charEnd - the position after the last character to apply the attribute
Add text to the end of the current text. This is useful for a logging' type activity.
-
- No events will be generated and the caret will be moved to the end of any appended text.
public boolean insertText(String text,
- int lineNo,
- int charNo)
-
Insert text at the display position specified.
-
- The area line number starts at 0 and includes any lines scrolled off the top. So if
- three lines have been scrolled off the top the first visible line is number 3.
-
- No events will be generated and the caret will be moved to the end of any inserted text.
-
Parameters:
text - the text to insert
lineNo - the area line number
charNo - the character position to insert text in display line
public boolean insertText(String text,
- int lineNo,
- int charNo,
- boolean startWithEOL,
- boolean endWithEOL)
-
Insert text at the display position specified.
-
- The area line number starts at 0 and includes any lines scrolled off the top. So if
- three lines have been scrolled off the top the first visible line is number 3.
-
- No events will be generated and the caret will be moved to the end of any inserted text.
-
Parameters:
text - the text to insert
lineNo - the area line number
charNo - the character position to insert text in display line
startWithEOL - if true,inserted text will start on newline
endWithEOL - if true, text after inserted text will start on new line
public boolean insertText(String text,
- boolean startWithEOL,
- boolean endWithEOL)
-
Insert text at the current caret position. If the current caret position is undefined
- the text will be inserted at the beginning of the text.
-
- No events will be generated and the caret will be moved to the end of any inserted text.
-
Parameters:
text - the text to insert
startWithEOL - if true,inserted text will start on newline
endWithEOL - if true, text after inserted text will start on new line
Insert text at the current caret position. If the current caret position is undefined
- the text will be inserted at the beginning of the text.
-
- No events will be generated and the caret will be moved to the end of any inserted text.
Get the text on a particular line in the text area.
- The line does not need to be visible and the line numbers
- always start at 0.
- The result is not dependent on what is visible at any
- particular time but on the overall position in text area
- control.
- If the line number is invalid then an empty string is returned.
- Trailing EOL characters are removed.
public int getTextLength(int lineNo,
- boolean ignoreEOL)
-
Get the length of text on a particular line in the text area.
- The line does not need to be visible and the line numbers
- always start at 0.
- The result is not dependent on what is visible at any
- particular time but on the overall position in text area
- control.
- If ignoreEOL is true then EOL characters are not included in the count.
-
Parameters:
lineNo - the text area line number we want
ignoreEOL - if true do not include trailing end=of-line characters
-
Returns:
the length of the line, or <) if the line number is invalid
Move the insertion point (caret) to the specified line and character. If the position is invalid
- then the caret is not moved. The text will be scrolled so that the caret position is visible.
-
Parameters:
lineNo - the line number (starts at 0)
charNo - the character position on the line (starts at 0)
Get the current caret position.
-
- The method will always return a 2 element array with the current caret position
- { line no, char no }
-
- If the current caret position is undefined then it will return the array { -1, -1 }
-
Returns:
a two element int array holding the caret position.
Get the current caret position.
-
- If the parameter is a 2 element int array then it will be populated with the line number [0]
- and character no [1] of the caret's current position.
-
- The method will always return a 2 element array with the current caret position
- { line no, char no }
-
- If the current caret position is undefined then it will return the array { -1, -1 }
-
Parameters:
cpos - array to be populated with caret position
-
Returns:
a two element int array holding the caret position.
This is for emergency use only!!!!
- In this version of the library a visual controls is drawn to off-screen buffer
- and then drawn to the screen by copying the buffer.
This is for emergency use only!!!!
- In this version of the library a visual controls is drawn to off-screen buffer
- and then drawn to the screen by copying the buffer. This means that the
- computationally expensive routines needed to draw the control (especially text
- controls) are only done when a change has been noted. This means that single
- changes need not trigger a full redraw to buffer.
- It does mean that an error in the library code could result in the buffer not
- being updated after changes. If this happens then in draw() call this method
- on the affected control, and report it as an issue
- here
- Thanks
The text field component.
-
- This control allows the user to enter and edit a single line of text. The control
- also allows default text and a horizontal scrollbar.
-
- can be created to manage either a single line of text or
- multiple lines of text.
-
- Enables user text input at runtime. Text can be selected using the mouse
- or keyboard shortcuts and then copied or cut to the clipboard. Text
- can also be pasted in.
-
- Fires SELECTION_CHANGED, CHANGED, ENTERED, LOST_FOCUS, GETS_FOCUS events.
- The focus events are only fired if the control is added to a GTabManager object.
public abstract class GTextIconAlignBase
-extends GTextAlign
-
Base class for controls with text and/or icon.
-
- This class forms the basis for any control that has text and/or an icon.
- Use the setIcon, setIconAlign, setText and setTextAlign to control
- horizontal and vertical alignment of the icon and text within the control face.
This class is used to trigger events at user defined intervals. The event will
- call a user defined method/function. The only restriction is that the method
- used has a single parameter of type GTimer and returns void eg
-
- void fireBall(GTimer timer){ ... }
-
-
- Each timer object must have its own handler
-
- It has no visible GUI representation so will not appear in the GUI.
public GTimer(processing.core.PApplet theApplet,
- Object obj,
- String methodName,
- int delay)
-
Create the GTimer object with this ctor.
-
- 'methodName' is the method/function to be called every 'interval'
- milliseconds. 'obj' is the object that contains the method/function
- 'methodName'
-
- For most users 'methodName' will be in their main sketch so this
- parameter has the same value as 'theApplet'
-
Parameters:
theApplet - a reference to the PApplet object (invariably this)
obj - the object that has the method to be executed (likely to be this)
methodName - the name of the method to be called by the timer
delay - the initial delay and the time (in millisecs) between function calls
public GTimer(processing.core.PApplet theApplet,
- Object obj,
- String methodName,
- int delay,
- int initDelay)
-
Create the GTimer object with this ctor.
-
- 'methodName' is the method/function to be called every 'interval'
- milliseconds. 'obj' is the object that contains the method/function
- 'methodName'
-
- For most users 'methodName' will be in their main sketch so this
- parameter has the same value as 'theApplet'
-
Parameters:
theApplet - a reference to the PApplet object (invariably this)
obj - the object that has the method to be executed (likely to be this)
methodName - the name of the method to be called by the timer
delay - the time (in millisecs) between function calls
This class forms the basis for any two-state type control (toggle switch).
- A toggle control can be in one of 2 states selected or not selected
- and is the base class for the GOption and GCheckbox controls.
Use this class to create a single selection collection of options.
-
- To use create an object of this class and then add GOption objects to it with
- the addControl method.
-
- You cannot add GCheckbox objects because they are designed to work independently.
Base class for all slider and knob type controls.
-
- This class enables the creation of tick marks and constraining values to
- the tick mark values.
-
- It also controls how the values are to be displayed INTEGER, DECIMAL or EXPONENT
The units to be displayed with the current and limit values e.g.
- kg, m, ($), fps etc.
- Do not use long labels such as 'miles per hour' as these take a
- lot of space and can look messy.
public void setNumberFormat(int numberFormat,
- int precision,
- String unit)
-
Set the numberFormat, precision and units in one go.
- Valid number formats are INTEGER, DECIMAL, EXPONENT
- Precision must be >= 1 and is ignored for INTEGER.
public void setNumberFormat(int numberFormat,
- int precision)
-
Set the numberFormat and precision in one go.
- Valid number formats are INTEGER, DECIMAL, EXPONENT
- Precision must be >= 1 and is ignored for INTEGER.
Set the numberFormat and precision in one go.
- Valid number formats are INTEGER, DECIMAL, EXPONENT
- Precision must be >= 1 and is ignored for INTEGER.
-
Parameters:
numberFormat - G4P.INTEGER, G4P.DECIMAL or G4P.EXPONENT
Set the amount of easing to be used when a value is changing. The default value
- is 1 (no easing) values > 1 will cause the value to rush from its starting value
- and decelerate towards its final values. In other words it smoothes the movement
- of the slider thumb or knob rotation.
This class is used to hold the data associated with a GWindow object.
-
- You should extend this class to provide the data to be processed by
- the window
public abstract class GWindow
-extends processing.core.PApplet
-implements GConstants
-
Base class for independent windows using JAVA2D, P2D or P3D renderers. These
- can be used to hold G4P GUI components or used for drawing or both combined.
-
- A number of examples are included in the library and more info can be found
- at www.lagers.org.uk
-
- Updated for Processing V3
To provide a unique fields for this window create a class that inherits
- from GWinData with public access fields. Then use this method to associate
- the data with this window.
Sets whether this window should always be above other windows. If there are
- multiple always-on-top windows, their relative order is unspecified and
- platform dependent.
Execute any post handler associated with this window and its controls.
- Add/remove any controls request by user, this is done here outside the drawing
- phase to prevent crashes.
public void addMouseHandler(Object obj,
- String methodName)
-
Attempt to add the 'mouse' handler method.
- The default event handler is a method that returns void and has three
- parameters GWinApplet, GWinData and a MouseEvent
-
Parameters:
obj - the object to handle the event
methodName - the method to execute in the object handler class
public void addKeyHandler(Object obj,
- String methodName)
-
Attempt to add the 'key' handler method.
- The default event handler is a method that returns void and has three
- parameters GWinApplet, GWinData and a KeyEvent
-
Parameters:
obj - the object to handle the event
methodName - the method to execute in the object handler class
public void addOnCloseHandler(Object obj,
- String methodName)
-
Attempt to create the on-close-window event handler for this GWindow.
- The default event handler is a method that returns void and has a single
- parameter of type GWindow (this will be a reference to the window that is
- closing)
-
- The handler will not be called> if the setActionOnClose flag is set
- to EXIT_APP
- If the flag is set to CLOSE_WINDOW then the handler is called when the window
- is closed by clicking on the window-close-icon or using either the close or
- forceClose methods.
- If the flag is set to KEEP_OPEN the window can only be closed using the
- forceClose method. In this case the handler will be called.
-
Parameters:
obj - the object to handle the on-close-window event
methodName - the method to execute in the object handler class
This sets what happens when the users attempts to close the window.
- There are 3 possible actions depending on the value passed.
- G4P.KEEP_OPEN - ignore attempt to close window (default action),
- G4P.CLOSE_WINDOW - close this window,
- G4P.EXIT_APP - exit the app, this will cause all windows to close.
This sets what happens when the users attempts to close the window.
- There are 3 possible actions depending on the value passed.
- G4P.KEEP_OPEN - ignore attempt to close window (default action),
- G4P.CLOSE_WINDOW - close this window,
- G4P.EXIT_APP - exit the app, this will cause all windows to close.
This class calls the appropriate methods for G4P controls for the main applet window.
-
- This will be created when the first control is added to the main window.
This sets what happens when the users attempts to close the window.
- There are 3 possible actions depending on the value passed.
- G4P.KEEP_OPEN - ignore attempt to close window (default action),
- G4P.CLOSE_WINDOW - close this window,
- G4P.EXIT_APP - exit the app, this will cause all windows to close.
This class is used to load bitmap files and create images.
-
- Although there maybe multiple requests for a particular bitmap file only
- one PImage is created for each file.
public final class StyledString
-extends Object
-implements Serializable
-
This class is used to represent text with attributes.
- It means that you don't have to have the same style of font
- or even the same font face over the whole length of the text.
-
- Most font features can be modified all except the text background
- which is transparent. There is a feature to highlight part of the string
- by having a different background colour but this is used for highlighting
- selected text in GTextField and GTextArea components.
-
- It is also used for all controls that use text.
public int insertCharacters(String chars,
- int insertPos)
-
Insert 1 or more characters into the string. The inserted text will first be made
- safe by removing any inappropriate EOL characters.
- Do not use this method to insert EOL characters, use the
insertEOL(int)
- method instead.
-
Parameters:
insertPos - position in string to insert characters
public int insertCharacters(String chars,
- int insertPos,
- boolean startNewLine,
- boolean endNewLine)
-
Insert 1 or more characters into the string. The inserted text will first be made
- safe by removing any inappropriate EOL characters.
- Do not use this method to insert EOL characters, use the
insertEOL(int)
- method instead.
-
Parameters:
insertPos - position in string to insert characters
Clipboard functionaliy for plain text
-
- This provides clipboard functionality for text and is currently only used by the
- GTextField and GTextArea classes.
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
-
-
-
-
-
Package
-
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
-
-
Interfaces (italic)
-
Classes
-
Enums
-
Exceptions
-
Errors
-
Annotation Types
-
-
-
-
Class/Interface
-
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
-
-
Class inheritance diagram
-
Direct Subclasses
-
All Known Subinterfaces
-
All Known Implementing Classes
-
Class/interface declaration
-
Class/interface description
-
-
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
-
-
-
Field Detail
-
Constructor Detail
-
Method Detail
-
-
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-
-
-
Annotation Type
-
Each annotation type has its own separate page with the following sections:
-
-
Annotation Type declaration
-
Annotation Type description
-
Required Element Summary
-
Optional Element Summary
-
Element Detail
-
-
-
-
Enum
-
Each enum has its own separate page with the following sections:
-
-
Enum declaration
-
Enum description
-
Enum Constant Summary
-
Enum Constant Detail
-
-
-
-
Tree (Class Hierarchy)
-
There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
-
-
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
-
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-
-
-
Deprecated API
-
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-
-
-
Index
-
The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-
-
-
Prev/Next
-
These links take you to the next or previous class, interface, package, or related page.
-
-
-
Frames/No Frames
-
These links show and hide the HTML frames. All pages are available with or without frames.
-
-
-
All Classes
-
The All Classes link shows all classes and interfaces except non-static nested types.
-
-
-
Serialized Form
-
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
This is for emergency use only!!!!
- In this version of the library a visual controls is drawn to off-screen buffer
- and then drawn to the screen by copying the buffer.
Clipboard functionaliy for plain text
-
- This provides clipboard functionality for text and is currently only used by the
- GTextField and GTextArea classes.
Set the color scheme to one of the preset schemes
- BLUE / GREEN / RED / PURPLE / YELLOW / CYAN / BROWN
- or if you have created your own schemes following the instructions
- at gui4processing.lagers.org.uk/colorscheme.html then you can enter
- the appropriate numeric value of the scheme.
Create a Panel that comprises of 2 parts the tab which is used to
- select and move the panel and the container window below the tab which
- is used to hold other components.
Create a Panel that comprises of 2 parts the tab which is used to
- select and move the panel and the container window below the tab which
- is used to hold other components.
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.
Provided the panel is physically small enough this method will set the area
- within which the panel can be dragged and move the panel inside the area if
- not already inside.
Enable or disable the ability of the component to generate mouse events.
- GTextField - it also controls key press events
- GPanel - controls whether the panel can be moved/collapsed/expanded
Enable or disable the ability of the component to generate mouse events.
- If the control is to be disabled when it is clicked then this will force the
- mouse off button image is used.
Enable or disable the ability of the component to generate mouse events.
- If the control is to be disabled when it is clicked then this will force the
- mouse off button image is used.
Enable or disable the ability of the component to generate mouse events.
- GTextField - it also controls key press events
- GPanel - controls whether the panel can be moved/collapsed/expanded
This gets the sensitivity to be used in modes CTRL_HORIZONTAL and CTRL_VERTICAL
- A value of 1 is 1 degree per pixel and a value of 2 is 2 degrees per pixel.
Set the mouse control mode to use, acceptable values are
- GKnob.CTRL_ANGULAR or GKnob.CTRL_HORIZONTAL) orGKnob.CTRL_VERTICAL any
- other value will be ignored.
-
-
diff --git a/Processing/libraries/G4P/reference/stylesheet.css b/Processing/libraries/G4P/reference/stylesheet.css
deleted file mode 100644
index 54998c2..0000000
--- a/Processing/libraries/G4P/reference/stylesheet.css
+++ /dev/null
@@ -1,310 +0,0 @@
-/* Javadoc style sheet */
-/* Define colors, fonts and other style attributes here to override the defaults */
-/* processingLibs style by andreas schlegel, sojamo */
-
-
-body {
- margin : 0;
- padding : 0;
- padding-left : 10px;
- padding-right : 8px;
- background-color : #FFFFFF;
- font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
- font-size : 100%;
- font-size : 0.7em;
- font-weight : normal;
- line-height : normal;
- margin-bottom:30px;
-}
-
-
-
-
-/* Headings */
-h1, h2, h3, h4, h5, th {
- font-family :Arial, Helvetica, sans-serif;
- font-size:1.2em;
-}
-
-
-p {
- font-size : 1em;
- width:80%;
-}
-
-pre, code {
- font-family : "Courier New", Courier, monospace;
- font-size : 12px;
- line-height : normal;
-}
-
-
-
-table {
- border:0;
- margin-bottom:10px;
- margin-top:10px;
-}
-
-
-tr, td {
- border-top: 0px solid;
- border-left: 0px solid;
- padding-top:8px;
- padding-bottom:8px;
-}
-
-
-
-hr {
- border:0;
- height:1px;
- padding:0;
- margin:0;
- margin-bottom:4px;
-
-}
-
-
-
-dd, th, td, font {
- font-size:1.0em;
- line-height:1.0em;
-}
-
-
-
-dt {
- margin-bottom:0px;
-}
-
-
-
-dd {
- margin-top:2px;
- margin-bottom:4px;
-}
-
-
-
-a {
- text-decoration: underline;
- font-weight: normal;
-}
-
-a:hover,
-a:active {
- text-decoration: underline;
- font-weight: normal;
-}
-
-a:visited,
-a:link:visited {
- text-decoration: underline;
- font-weight: normal;
-}
-
-
-img {
- border: 0px solid #000000;
-}
-
-
-
-/* Navigation bar fonts */
-.NavBarCell1 {
- border:0;
-}
-
-.NavBarCell1Rev {
- border:0;
-}
-
-.NavBarFont1 {
- font-family: Arial, Helvetica, sans-serif;
- font-size:1.1em;
-}
-
-
-.NavBarFont1 b {
- font-weight:normal;
-}
-
-
-
-.NavBarFont1:after, .NavBarFont1Rev:after {
- font-weight:normal;
- content: " \\";
-}
-
-
-.NavBarFont1Rev {
- font-family: Arial, Helvetica, sans-serif;
- font-size:1.1em;
-}
-
-.NavBarFont1Rev b {
- font-family: Arial, Helvetica, sans-serif;
- font-size:1.1em;
- font-weight:normal;
-}
-
-.NavBarCell2 {
- font-family: Arial, Helvetica, sans-serif;
-}
-
-.NavBarCell3 {
- font-family: Arial, Helvetica, sans-serif;
-}
-
-
-
-font.FrameItemFont {
- font-family: Helvetica, Arial, sans-serif;
- font-size:1.1em;
- line-height:1.1em;
-}
-
-font.FrameHeadingFont {
- font-family: Helvetica, Arial, sans-serif;
- line-height:32px;
-}
-
-/* Font used in left-hand frame lists */
-.FrameTitleFont {
- font-family: Helvetica, Arial, sans-serif
-}
-
-
-.toggleList {
- padding:0;
- margin:0;
- margin-top:12px;
-}
-
-.toggleList dt {
- font-weight:bold;
- font-size:12px;
- font-family:arial,sans-serif;
- padding:0px;
- margin:10px 0px 10px 0px;
-}
-
-.toggleList dt span {
- font-family: monospace;
- padding:0;
- margin:0;
-}
-
-
-.toggleList dd {
- margin:0;
- padding:0;
-}
-
-html.isjs .toggleList dd {
- display: none;
-}
-
-.toggleList pre {
- padding: 4px 4px 4px 4px;
-}
-
-
-
-
-
-/* COLORS */
-
-pre, code {
- color: #000000;
-}
-
-
-body {
- color : #333333;
- background-color :#FFFFFF;
-}
-
-
-h1, h2, h3, h4, h5, h6 {
- color:#555;
-}
-
-a,
-.toggleList dt {
- color: #1a7eb0;
-}
-
-a:hover,
-a:active {
- color: #1a7eb0;
-}
-
-a:visited,
-a:link:visited {
- color: #1a7eb0;
-}
-
-td,tr {
- border-color: #999999;
-}
-
-hr {
- color:#999999;
- background:#999999;
-}
-
-
-.TableHeadingColor {
- background: #dcdcdc;
- color: #555;
-}
-
-
-.TableSubHeadingColor {
- background: #EEEEFF
-}
-
-.TableRowColor {
- background: #FFFFFF
-}
-
-
-.NavBarCell1 {
- background-color:#dcdcdc;
- color:#000;
-}
-
-.NavBarCell1 a {
- color:#333;
-}
-
-
-.NavBarCell1Rev {
- background-color:transparent;
-}
-
-.NavBarFont1 {
- color:#333;
-}
-
-
-.NavBarFont1Rev {
- color:#fff;
-}
-
-.NavBarCell2 {
- background-color:#999;
-}
-
-.NavBarCell2 a {
- color:#fff;
-}
-
-
-
-.NavBarCell3 {
- background-color:#dcdcdc;
-}
-
diff --git a/Processing/libraries/G4P/src/data/blue18px/centre.png b/Processing/libraries/G4P/src/data/blue18px/centre.png
deleted file mode 100644
index 6b11682..0000000
Binary files a/Processing/libraries/G4P/src/data/blue18px/centre.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/blue18px/end_left.png b/Processing/libraries/G4P/src/data/blue18px/end_left.png
deleted file mode 100644
index d794461..0000000
Binary files a/Processing/libraries/G4P/src/data/blue18px/end_left.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/blue18px/end_right.png b/Processing/libraries/G4P/src/data/blue18px/end_right.png
deleted file mode 100644
index 569f43a..0000000
Binary files a/Processing/libraries/G4P/src/data/blue18px/end_right.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/blue18px/handle.png b/Processing/libraries/G4P/src/data/blue18px/handle.png
deleted file mode 100644
index 6d9ced6..0000000
Binary files a/Processing/libraries/G4P/src/data/blue18px/handle.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/blue18px/handle_mouseover.png b/Processing/libraries/G4P/src/data/blue18px/handle_mouseover.png
deleted file mode 100644
index 0c3be66..0000000
Binary files a/Processing/libraries/G4P/src/data/blue18px/handle_mouseover.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/combo0.png b/Processing/libraries/G4P/src/data/combo0.png
deleted file mode 100644
index b9cbf23..0000000
Binary files a/Processing/libraries/G4P/src/data/combo0.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/default_gui_palette.png b/Processing/libraries/G4P/src/data/default_gui_palette.png
deleted file mode 100644
index 01204e5..0000000
Binary files a/Processing/libraries/G4P/src/data/default_gui_palette.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/err0.png b/Processing/libraries/G4P/src/data/err0.png
deleted file mode 100644
index 91ef9ae..0000000
Binary files a/Processing/libraries/G4P/src/data/err0.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/err1.png b/Processing/libraries/G4P/src/data/err1.png
deleted file mode 100644
index 3f17af5..0000000
Binary files a/Processing/libraries/G4P/src/data/err1.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/err2.png b/Processing/libraries/G4P/src/data/err2.png
deleted file mode 100644
index dc3cfcc..0000000
Binary files a/Processing/libraries/G4P/src/data/err2.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/green_red20px/centre.png b/Processing/libraries/G4P/src/data/green_red20px/centre.png
deleted file mode 100644
index eab6bd0..0000000
Binary files a/Processing/libraries/G4P/src/data/green_red20px/centre.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/green_red20px/end_left.png b/Processing/libraries/G4P/src/data/green_red20px/end_left.png
deleted file mode 100644
index 3e730dc..0000000
Binary files a/Processing/libraries/G4P/src/data/green_red20px/end_left.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/green_red20px/end_right.png b/Processing/libraries/G4P/src/data/green_red20px/end_right.png
deleted file mode 100644
index 1b4ff65..0000000
Binary files a/Processing/libraries/G4P/src/data/green_red20px/end_right.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/green_red20px/handle.png b/Processing/libraries/G4P/src/data/green_red20px/handle.png
deleted file mode 100644
index 3a00333..0000000
Binary files a/Processing/libraries/G4P/src/data/green_red20px/handle.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/green_red20px/handle_mouseover.png b/Processing/libraries/G4P/src/data/green_red20px/handle_mouseover.png
deleted file mode 100644
index 40b5a3e..0000000
Binary files a/Processing/libraries/G4P/src/data/green_red20px/handle_mouseover.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/grey_blue/centre.png b/Processing/libraries/G4P/src/data/grey_blue/centre.png
deleted file mode 100644
index 8c0c09f..0000000
Binary files a/Processing/libraries/G4P/src/data/grey_blue/centre.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/grey_blue/end_left.png b/Processing/libraries/G4P/src/data/grey_blue/end_left.png
deleted file mode 100644
index 5424edf..0000000
Binary files a/Processing/libraries/G4P/src/data/grey_blue/end_left.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/grey_blue/end_right.png b/Processing/libraries/G4P/src/data/grey_blue/end_right.png
deleted file mode 100644
index 273d188..0000000
Binary files a/Processing/libraries/G4P/src/data/grey_blue/end_right.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/grey_blue/full_back.png b/Processing/libraries/G4P/src/data/grey_blue/full_back.png
deleted file mode 100644
index 34b8684..0000000
Binary files a/Processing/libraries/G4P/src/data/grey_blue/full_back.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/grey_blue/handle.png b/Processing/libraries/G4P/src/data/grey_blue/handle.png
deleted file mode 100644
index 02c219d..0000000
Binary files a/Processing/libraries/G4P/src/data/grey_blue/handle.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/grey_blue/handle_mouseover.png b/Processing/libraries/G4P/src/data/grey_blue/handle_mouseover.png
deleted file mode 100644
index 53e423a..0000000
Binary files a/Processing/libraries/G4P/src/data/grey_blue/handle_mouseover.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/noimage3.png b/Processing/libraries/G4P/src/data/noimage3.png
deleted file mode 100644
index beef91e..0000000
Binary files a/Processing/libraries/G4P/src/data/noimage3.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/pinhead.png b/Processing/libraries/G4P/src/data/pinhead.png
deleted file mode 100644
index 4d50bd5..0000000
Binary files a/Processing/libraries/G4P/src/data/pinhead.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/purple18px/centre.png b/Processing/libraries/G4P/src/data/purple18px/centre.png
deleted file mode 100644
index 6b11682..0000000
Binary files a/Processing/libraries/G4P/src/data/purple18px/centre.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/purple18px/end_left.png b/Processing/libraries/G4P/src/data/purple18px/end_left.png
deleted file mode 100644
index d794461..0000000
Binary files a/Processing/libraries/G4P/src/data/purple18px/end_left.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/purple18px/end_right.png b/Processing/libraries/G4P/src/data/purple18px/end_right.png
deleted file mode 100644
index 569f43a..0000000
Binary files a/Processing/libraries/G4P/src/data/purple18px/end_right.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/purple18px/handle.png b/Processing/libraries/G4P/src/data/purple18px/handle.png
deleted file mode 100644
index 4cfece5..0000000
Binary files a/Processing/libraries/G4P/src/data/purple18px/handle.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/purple18px/handle_mouseover.png b/Processing/libraries/G4P/src/data/purple18px/handle_mouseover.png
deleted file mode 100644
index 2ef2286..0000000
Binary files a/Processing/libraries/G4P/src/data/purple18px/handle_mouseover.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/red_yellow18px/centre.png b/Processing/libraries/G4P/src/data/red_yellow18px/centre.png
deleted file mode 100644
index 6b11682..0000000
Binary files a/Processing/libraries/G4P/src/data/red_yellow18px/centre.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/red_yellow18px/end_left.png b/Processing/libraries/G4P/src/data/red_yellow18px/end_left.png
deleted file mode 100644
index d794461..0000000
Binary files a/Processing/libraries/G4P/src/data/red_yellow18px/end_left.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/red_yellow18px/end_right.png b/Processing/libraries/G4P/src/data/red_yellow18px/end_right.png
deleted file mode 100644
index 569f43a..0000000
Binary files a/Processing/libraries/G4P/src/data/red_yellow18px/end_right.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/red_yellow18px/handle.png b/Processing/libraries/G4P/src/data/red_yellow18px/handle.png
deleted file mode 100644
index ecb3784..0000000
Binary files a/Processing/libraries/G4P/src/data/red_yellow18px/handle.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/red_yellow18px/handle_mouseover.png b/Processing/libraries/G4P/src/data/red_yellow18px/handle_mouseover.png
deleted file mode 100644
index fc153a7..0000000
Binary files a/Processing/libraries/G4P/src/data/red_yellow18px/handle_mouseover.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/tick.png b/Processing/libraries/G4P/src/data/tick.png
deleted file mode 100644
index 22118e8..0000000
Binary files a/Processing/libraries/G4P/src/data/tick.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/data/toggle.png b/Processing/libraries/G4P/src/data/toggle.png
deleted file mode 100644
index c71a49e..0000000
Binary files a/Processing/libraries/G4P/src/data/toggle.png and /dev/null differ
diff --git a/Processing/libraries/G4P/src/g4p_controls/ColorPreviewPanel.java b/Processing/libraries/G4P/src/g4p_controls/ColorPreviewPanel.java
deleted file mode 100644
index a98c3a0..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/ColorPreviewPanel.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2013 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Color;
-import java.awt.FlowLayout;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.colorchooser.ColorSelectionModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-/**
- * The preview panel class for the color selector.
- *
- * @author Peter Lager
- *
- */
-@SuppressWarnings("serial")
-class ColorPreviewPanel extends JPanel implements ChangeListener {
- JLabel lblPrev, lblCurr;
- JLabel lblPrevColor, lblCurrColor;
-
-
- public ColorPreviewPanel(Color c){
- setLayout(new FlowLayout());
- lblPrev = new JLabel("Initial Color");
- lblCurr = new JLabel("Current Color");
- lblPrevColor = new JLabel(" ");
- lblPrevColor.setOpaque(true);
- lblPrevColor.setBackground(c);
- lblCurrColor = new JLabel(" ");
- lblCurrColor.setOpaque(true);
- lblCurrColor.setBackground(c);
- add(lblCurr);
- add(lblCurrColor);
- add(lblPrevColor);
- add(lblPrev);
- }
-
-
- public void stateChanged(ChangeEvent e) {
- ColorSelectionModel csm = (ColorSelectionModel)e.getSource();
- lblCurrColor.setBackground(csm.getSelectedColor());
- }
-
- public void setPrevColor(Color pcol){
- lblPrevColor.setBackground(pcol);
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/FileChooserFilter.java b/Processing/libraries/G4P/src/g4p_controls/FileChooserFilter.java
deleted file mode 100644
index 431dcac..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/FileChooserFilter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.io.File;
-import javax.swing.filechooser.FileFilter;
-import processing.core.PApplet;
-
-class FileChooserFilter extends FileFilter {
-
- private final String[] ftypes;
- private String description = null;
-
- public FileChooserFilter(String types){
- this(types, null);
- }
-
- public FileChooserFilter(String types, String desc){
- ftypes = PApplet.split(types.toLowerCase(), ',');
- for(String e : ftypes)
- e = e.trim();
- description = desc;
- }
-
- @Override
- public boolean accept(File f) {
- String fext = getExtension(f);
- if(fext != null){
- for(String e : ftypes)
- if(fext.equals(e))
- return true;
- }
- return false;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- public String getExtension(File f) {
- String ext = null;
- String s = f.getName();
- int i = s.lastIndexOf('.');
-
- if (i > 0 && i < s.length() - 1)
- ext = s.substring(i+1).toLowerCase();
- return ext;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/FilenameChooserFilter.java b/Processing/libraries/G4P/src/g4p_controls/FilenameChooserFilter.java
deleted file mode 100644
index 8a754a1..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/FilenameChooserFilter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import processing.core.PApplet;
-
-class FilenameChooserFilter implements FilenameFilter {
-
- private final String[] ftypes;
-
- public FilenameChooserFilter(String types){
- ftypes = PApplet.split(types.toLowerCase(), ',');
- for(String e : ftypes)
- e = e.trim();
- }
-
- public boolean accept(File dir, String name) {
- String fext = null;
- int i = name.lastIndexOf('.');
- if (i > 0 && i < name.length() - 1)
- fext = name.substring(i+1).toLowerCase();
- if(fext != null){
- for(String e : ftypes)
- if(fext.equals(e))
- return true;
- }
- return false;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/Focusable.java b/Processing/libraries/G4P/src/g4p_controls/Focusable.java
deleted file mode 100644
index 3a6ac42..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/Focusable.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2014 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-/**
- * Any text input control that can receive or lose focus when the tab key is typed must
- * implement this interface.
- *
- * @author Peter Lager
- *
- */
-public interface Focusable {
-
- void setTabManager(GTabManager tm);
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/FontManager.java b/Processing/libraries/G4P/src/g4p_controls/FontManager.java
deleted file mode 100644
index 0218524..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/FontManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2014 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Font;
-
-/**
- *
- * This class is used to access system fonts.
- *
- * Only basic functionality is available in 3.5 but will be extended hopefully :)
- *
- * Introduced v3.5
- *
- *
- * @author Peter Lager
- *
- */
-public class FontManager {
-
-
- /** Default list of font family names in priority order */
- private static String[] pfnames = {"Arial", "Trebuchet MS", "Tahoma", "Helvetica", "Verdana" };
-
-
- /**
- * Get a system font that matches one the font family names with the style and size. If
- * it can't find a suitable system font from the font family it returns a logical
- * font (Dialog) of the specified style and size.
- *
- * @param familyFontNamnes user defined list of family font names or null to use default list
- * @param style Font.PLAIN, Font.BOLD, Font.Italic
- * @param size font size
- * @return a system font, or if none found a logical font
- */
- public static Font getPriorityFont(String[] familyFontNamnes, int style, int size){
- Font font = null;
- String[] names = (familyFontNamnes == null || familyFontNamnes.length == 0)
- ? pfnames : familyFontNamnes;
- for(String name : names){
- font = getFont(name, style, size);
- if(font != null) return font;
- }
- return getFont("Dialog", style, size);
- }
-
- /**
- * Get a system font that matches the font family name, style and size. If
- * it can't find a system font from the font family it returns null.
- *
- * @param familyName font family name e.g. "Arial", "Trebuchet MS" ...
- * @param style Font.PLAIN, Font.BOLD, Font.Italic
- * @param size font size
- * @return a system font from the specified family name, if not found returns null
- */
- public static Font getFont(String familyName, int style, int size){
- Font font = new Font(familyName, style, size);
- if(familyName.equalsIgnoreCase(font.getFamily()))
- return font;
- return null;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/G4P.java b/Processing/libraries/G4P/src/g4p_controls/G4P.java
deleted file mode 100644
index c3e81a4..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/G4P.java
+++ /dev/null
@@ -1,863 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2008-13 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-
-import java.awt.Color;
-import java.awt.FileDialog;
-import java.awt.Font;
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.swing.JColorChooser;
-import javax.swing.JDialog;
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.colorchooser.AbstractColorChooserPanel;
-import javax.swing.filechooser.FileFilter;
-
-import processing.core.PApplet;
-import processing.core.PConstants;
-
-/**
- * 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
- *
- *
- * Prior to version 3.5 G4P used logical fonts to be cross-platform,
- * unfortunately logical fonts do not use uniform metrics so it caused
- * serious errors when formatting the text layout. In version 3.5 G4P
- * will attempt to use a system fonts selected from this list
- * "Arial", "Trebuchet MS", "Tahoma", "Helvetica", "Verdana"
- *
- * Arial is the preferred font (since most systems will have it installed)
- * but if not found it will attempt to use the next one in the list. If
- * the list is exhausted and no matching system font found it will use
- * a logical font.
- * If this causes a problem with older sketches simple call
- *
- * G4P.usePre35Fonts();
- *
- * before you create any GUI controls.
- *
- *
- * @author Peter Lager
- *
- */
-public class G4P implements GConstants, PConstants {
-
- static PApplet sketchWindow = null;
- // Relays events to main sketch window
- static GWindowImpl sketchWindowImpl = null;
-
- // List of all GWindows currently open
- static List allWindows = new LinkedList();
- // List of all GWindows marked for closure
- static List windowsForClosing = new LinkedList();
-
- static boolean announced = false;
-
- /**
- * return the pretty version of the library.
- */
- public static String getPrettyVersion() {
- return "4.0.4";
- }
-
- /**
- * return the version of the library used by Processing
- */
- public static String getVersion() {
- return "27";
- }
-
- static int globalColorScheme = GCScheme.BLUE_SCHEME;
- static int globalAlpha = 255;
-
- // Font used for all text controls
- static Font globalFont = FontManager.getPriorityFont(null, Font.PLAIN, 12);
- // Font used for slider numbers
- static Font numericLabelFont = FontManager.getPriorityFont(null, Font.BOLD, 11);;
-
- // Used to order controls
- static GAbstractControl.Z_Order zorder = new GAbstractControl.Z_Order();
-
- /* INTERNAL USE ONLY Mouse over changer */
- static boolean cursorChangeEnabled = true;
- static int mouseOff = ARROW;
-
- static boolean showMessages = true;
-
- // Determines how position and size parameters are interpreted when
- // a control is created. Introduced G4P V3.0
- static GControlMode control_mode = GControlMode.CORNER;
-
- // Used to create a stack of styles with pushStyle and popStyle
- static LinkedList styles = new LinkedList();
-
- // Colour chooser
- static JColorChooser chooser = null;
- static Color lastColor = Color.white; // White
-
- // Mouse wheel direction
- static int wheelForSlider = FORWARD;
- static int wheelForScrollbar = FORWARD;
-
- /**
- * Register a GWindow so we can keep track of all GWindows in the application.
- * This will be needed for global transformations e.g. setGlobalAlpha(...)
- * This is called from the controls constructor, and also when a GWindow is created.
- * @param window
- */
- static void registerWindow(GWindow window){
- if(!allWindows.contains(window)){
- allWindows.add(window);
- }
- }
-
- /**
- * De-register a window , this is done when a window is closed
- * @param window
- */
- static void deregisterWindow(GWindow window){
- allWindows.remove(window);
- }
-
- /**
- * Used internally to register a control with its window.
- * It will replace the addControl method in the controls constructors
- * @param control
- */
- static void registerControl(GAbstractControl control){
- PApplet app = control.getPApplet();
- if(app == sketchWindow)
- sketchWindowImpl.addToWindow(control);
- else if(app instanceof GWindow)
- ((GWindow)app).addToWindow(control);
- }
-
- /**
- * 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 controls are created without passing a reference to the sketch applet
- * but still need to know it. An example is the GColorChooser control which
- * cannot be used until this method is called or some other G4P control has
- * been created.
- *
- * Also some other libraries such as PeasyCam change the transformation matrix.
- * In which case either a G4P control should be created or this method called
- * before creating a PeasyCam object.
- *
- * @param app
- */
- public static void registerSketch(PApplet app){
- if(sketchWindow == null && app != null) {
- sketchWindow = app;
- sketchWindowImpl = new GWindowImpl(sketchWindow);
- announceG4P();
- }
- }
-
- /**
- * Set the global colour scheme. This will change the local
- * colour scheme for every control.
- * @param cs colour scheme to use (0-15)
- */
- static void invalidateBuffers(){
- for(GWindow window : allWindows)
- window.invalidateBuffers();
- if(sketchWindowImpl != null)
- sketchWindowImpl.invalidateBuffers();
- }
-
- /**
- * Set the global colour scheme. This will change the local
- * colour scheme for every control.
- * @param cs colour scheme to use (0-15)
- */
- public static void setGlobalColorScheme(int cs){
- cs = Math.abs(cs) % 16; // Force into valid range
- if(globalColorScheme != cs){
- globalColorScheme = cs;
- for(GWindow window : allWindows)
- window.setColorScheme(globalColorScheme);
- if(sketchWindowImpl != null)
- sketchWindowImpl.setColorScheme(globalColorScheme);
- }
- }
-
- /**
- * 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.
- */
- public static void usePre35Fonts(){
- globalFont = new Font("Dialog", Font.PLAIN, 10);
- numericLabelFont = new Font("DialogInput", Font.BOLD, 12);
- }
-
- /**
- * Set the colour scheme for all the controls drawn by the given
- * PApplet. This will override any previous colour scheme for
- * these controls.
- * @param app
- * @param cs
- */
- public static void setWindowColorScheme(PApplet app, int cs){
- cs = Math.abs(cs) % 16; // Force into valid range
- if(app == sketchWindow){
- if(sketchWindowImpl != null)
- sketchWindowImpl.setColorScheme(cs);
- }
- else if(app instanceof GWindow)
- ((GWindow)app).setColorScheme(cs);
- }
-
- /**
- * 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.
- *
- * @param alpha value in the range 0 (transparent) to 255 (opaque)
- */
- public static void setGlobalAlpha(int alpha){
- alpha = Math.abs(alpha) % 256; // Force into valid range
- if(globalAlpha != alpha){
- globalAlpha = alpha;
- for(GWindow window : allWindows)
- window.setAlpha(globalAlpha);
- if(sketchWindowImpl != null)
- sketchWindowImpl.setAlpha(globalAlpha);
- }
- }
-
- /**
- * 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.
- *
- * @param app
- * @param alpha value in the range 0 (transparent) to 255 (opaque)
- */
- public static void setWindowAlpha(PApplet app, int alpha){
- alpha = Math.abs(alpha) % 256; // Force into valid range
- if(app == sketchWindow){
- if(sketchWindowImpl != null)
- sketchWindowImpl.setAlpha(alpha);
- }
- else if(app instanceof GWindow)
- ((GWindow)app).setAlpha(alpha);
- }
-
- /**
- * Display the library version in the ProcessingIDE
- */
- static void announceG4P(){
- if(!announced){
- System.out.println("===================================================");
- System.out.println(" G4P V4.0.4 created by Peter Lager");
- System.out.println("===================================================");
- announced = true;
- }
- }
-
- /**
- * Remove a control from the window. This is used in preparation
- * for disposing of a control.
- * @param control
- * @return true if control was remove else false
- */
- static boolean removeControl(GAbstractControl control){
- PApplet app = control.getPApplet();
- if(app == sketchWindow){
- if(sketchWindowImpl != null){
- sketchWindowImpl.removeFromWindow(control);
- return true;
- }
- return false;
- }
- if(app instanceof GWindow){
- ((GWindow)app).removeFromWindow(control);
- return true;
- }
- return false;
- }
-
- /**
- * 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.
- *
- * @param mode illegal values are ignored leaving the mode unchanged
- */
- public static void setCtrlMode(GControlMode mode){
- if(mode != null)
- control_mode = mode;
- }
-
- /**
- * Get the control creation mode @see ctrlMode(int mode)
- * @return the current control mode
- */
- public static GControlMode getCtrlMode(){
- return control_mode;
- }
-
- /**
- * 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.
- *
- * @param enable
- */
- public static void messagesEnabled(boolean enable){
- showMessages = enable;
- }
-
- /**
- * Enables or disables cursor over component change.
- *
- * Calls to this method are ignored if no G4P controls have been created.
- *
- * @param enable true to enable cursor change over components.
- */
- public static void setMouseOverEnabled(boolean enable){
- cursorChangeEnabled = enable;
- }
-
- /**
- * Determines how the direction of the mouse wheel rotation is interpreted
- * for sliders. This value applies to all sliders.
- * The default value is FORWARD
- * @param dir FORWARD or REVERSE, illegal values are ignored
- */
- public static void mouseWheelForSlider(int dir){
- if(dir == FORWARD || dir == REVERSE)
- wheelForSlider = dir;
- }
-
- /**
- * Determines how the direction of the mouse wheel rotation is interpreted
- * for sliders. This value applies to all sliders.
- * The default value is FORWARD
- * @param dir FORWARD or REVERSE, illegal values are ignored
- */
- public static void mouseWheelForScrollbar(int dir){
- if(dir == FORWARD || dir == REVERSE)
- wheelForScrollbar = dir;
- }
-
- /**
- * @deprecated use setCursor(int)
- */
- @Deprecated
- public static void setCursorOff(int cursorOff){
- mouseOff = cursorOff;
- }
-
- /**
- * Set the cursor shape to be used when the mouse is not over a
- * G4P control for the entire application including secondary
- * windows.
- * @param cursorOff the cursor shape.
- */
- public static void setCursor(int cursorOff){
- mouseOff = cursorOff;
- for(GWindow window : allWindows)
- window.cursor(cursorOff);
- if(sketchWindow != null)
- sketchWindow.cursor(cursorOff);
- }
-
- /**
- * Get the cursor shape used when the mouse is not over a G4P
- * control
- * set for the
- *
- */
- public static int getCursor(){
- return mouseOff;
- }
-
- /**
- * @deprecated use getCursor()
- */
- @Deprecated
- public static int getCursorOff(){
- return mouseOff;
- }
-
- /**
- * Save the current style on a stack.
- * There should be a matching popStyle otherwise the program it will
- * cause a memory leakage.
- */
- static void pushStyle(){
- G4Pstyle s = new G4Pstyle();
- s.ctrlMode = control_mode;
- s.showMessages = showMessages;
- // Now save the style for later
- styles.addLast(s);
- }
-
- /**
- * Remove and restore the current style from the stack.
- * There should be a matching pushStyle otherwise the program will crash.
- */
- static void popStyle(){
- G4Pstyle s = styles.removeLast();
- control_mode = s.ctrlMode;
- showMessages = s.showMessages;
- }
-
- /**
- * This class represents the current style used by G4P.
- * It can be extended to add other attributes but these should be
- * included in the pushStyle and popStyle.
- * @author Peter
- *
- */
- static class G4Pstyle {
- GControlMode ctrlMode;
- boolean showMessages;
- }
-
- /**
- * 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.
- *
- * @param list an optional ArrayList to use. In null will create a new ArrayList.
- * @return an ArrayList of references to all open GWindow objects.
- */
- public static ArrayList getOpenWindowsAsList(ArrayList list){
- if(list == null)
- list = new ArrayList();
- else
- list.clear();
- for(GWindow window : allWindows)
- list.add(window);
- return list;
- }
-
- /**
- * 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.
- * @return an array of references to all open GWindow objects.
- */
- public static GWindow[] getOpenWindowsAsArray(){
- ArrayList list = getOpenWindowsAsList(null);
- return list.toArray(new GWindow[list.size()]);
- }
-
- /**
- * Use this to check whether a GWindow window is still open (as far as G4P is concerned).
- * @param window the window we are interested in
- * @return true if G4P still thinks it is open
- */
- public static boolean isWindowOpen(GWindow window){
- return (window != null && allWindows.contains(window));
- }
-
- /**
- * 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.
- *
- * @return the ARGB colour as a 32 bit integer (as used in Processing).
- */
- public static int selectColor(){
- Frame frame = getFrame(sketchWindow);
- if(chooser == null){
- chooser = new JColorChooser();
- AbstractColorChooserPanel[] oldPanels = chooser.getChooserPanels();
- // Do not assume what panels are present
- LinkedList panels = new LinkedList();
- for(AbstractColorChooserPanel p : oldPanels){
- String displayName = p.getDisplayName().toLowerCase();
- if(displayName.equals("swatches"))
- panels.addLast(p);
- else if(displayName.equals("rgb"))
- panels.addFirst(p);
- else if(displayName.startsWith("hs"))
- panels.addFirst(p);
- }
- AbstractColorChooserPanel[] newPanels;
- newPanels = panels.toArray(new AbstractColorChooserPanel[panels.size()]);
- chooser.setChooserPanels(newPanels);
- ColorPreviewPanel pp = new ColorPreviewPanel(lastColor);
- chooser.getSelectionModel().addChangeListener(pp);
- chooser.setPreviewPanel(pp);
- }
- // Set the preview color
- ((ColorPreviewPanel)chooser.getPreviewPanel()).setPrevColor(lastColor);
- // Use the last color selected to start it off
- chooser.setColor(lastColor);
- JDialog dialog = JColorChooser.createDialog(frame,
- "Color picker",
- true,
- chooser,
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- lastColor = chooser.getColor();
- }
- },
- null);
- dialog.setVisible(true);
- return lastColor.getRGB();
- }
-
- /**
- * Select a folder from the local file system.
- *
- * @param prompt the frame text for the chooser
- * @return the absolute path name for the selected folder, or null if action
- * cancelled.
- */
- public static String selectFolder(String prompt){
- String selectedFolder = null;
- Frame frame = getFrame(sketchWindow);
- //Frame frame = (sketchWindow == null) ? null : sketchWindow.frame;
- if (PApplet.platform == MACOSX && PApplet.useNativeSelect != false) {
- FileDialog fileDialog =
- new FileDialog(frame, prompt, FileDialog.LOAD);
- System.setProperty("apple.awt.fileDialogForDirectories", "true");
- fileDialog.setVisible(true);
- System.setProperty("apple.awt.fileDialogForDirectories", "false");
- String filename = fileDialog.getFile();
- if (filename != null) {
- try {
- selectedFolder = (new File(fileDialog.getDirectory(), fileDialog.getFile())).getCanonicalPath();
- } catch (IOException e) {
- selectedFolder = null;
- }
- }
- } else {
- JFileChooser fileChooser = new JFileChooser();
- fileChooser.setDialogTitle(prompt);
- fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- int result = fileChooser.showOpenDialog(frame);
- if (result == JFileChooser.APPROVE_OPTION) {
- try {
- selectedFolder = fileChooser.getSelectedFile().getCanonicalPath();
- } catch (IOException e) {
- selectedFolder = null;
- }
- }
- }
- return selectedFolder;
- }
-
- /**
- * Select a file for input from the local file system.
- *
- *
- * @param prompt the frame text for the chooser
- * @return the absolute path name for the selected folder, or null if action
- * cancelled.
- */
- public static String selectInput(String prompt){
- return selectInput(prompt, null, null);
- }
-
- /**
- * 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.
- *
- * @param prompt the frame text for the chooser
- * @param types a comma separated list of file extensions e.g. "png,gif,jpg,jpeg"
- * @param typeDesc simple textual description of the file types e.g. "Image files"
- * @return the absolute path name for the selected folder, or null if action
- * cancelled.
- */
- public static String selectInput(String prompt, String types, String typeDesc){
- return selectImpl(prompt, FileDialog.LOAD, types, typeDesc);
- }
-
- /**
- * Select a file for output from the local file system.
- *
- * @param prompt the frame text for the chooser
- * @return the absolute path name for the selected folder, or null if action is cancelled.
- */
- public static String selectOutput(String prompt){
- return selectOutput(prompt, null, null);
- }
-
- /**
- * 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.
- *
- * @param prompt the frame text for the chooser
- * @param types a comma separated list of file extensions e.g. "png,jpf,tiff"
- * @param typeDesc simple textual description of the file types e.g. "Image files"
- * @return the absolute path name for the selected folder, or null if action
- * cancelled.
- */
- public static String selectOutput(String prompt, String types, String typeDesc){
- return selectImpl(prompt, FileDialog.SAVE, types, typeDesc);
- }
-
- /**
- * The implementation of the select input and output methods.
- * @param prompt
- * @param mode
- * @param types
- * @param typeDesc
- * @return the absolute path name for the selected folder, or null if action
- * cancelled.
- */
- private static String selectImpl(String prompt, int mode, String types, String typeDesc) {
- // If no initial selection made then use last selection
- // Assume that a file will not be selected
- String selectedFile = null;
- // Get the owner
- Frame frame = getFrame(sketchWindow);
- // Create a file filter
- if (PApplet.useNativeSelect) {
- FileDialog dialog = new FileDialog(frame, prompt, mode);
- FilenameFilter filter = null;
- if(types != null && types.length() > 0){
- filter = new FilenameChooserFilter(types);
- dialog.setFilenameFilter(filter);
- }
- dialog.setVisible(true);
- String directory = dialog.getDirectory();
- if(directory != null){
- selectedFile = dialog.getFile();
- if(selectedFile != null){
- try {
- selectedFile = (new File(directory, selectedFile)).getCanonicalPath();
- } catch (IOException e) {
- selectedFile = null;
- }
- }
- }
- } else {
- JFileChooser chooser = new JFileChooser();
- chooser.setDialogTitle(prompt);
- FileFilter filter = null;
- if(types != null && types.length() > 0){
- filter = new FileChooserFilter(types, typeDesc);
- chooser.setFileFilter(filter);
- }
- int result = JFileChooser.ERROR_OPTION;
- if (mode == FileDialog.SAVE) {
- result = chooser.showSaveDialog(frame);
- } else if (mode == FileDialog.LOAD) {
- result = chooser.showOpenDialog(frame);
- }
- if (result == JFileChooser.APPROVE_OPTION) {
- try {
- selectedFile = chooser.getSelectedFile().getCanonicalPath();
- } catch (IOException e) {
- selectedFile = null;
- }
- }
- }
- return selectedFile;
- }
-
- /*
- Component parentComponent
- The first argument to each showXxxDialog method is always the parent component, which must be a
- Frame, a component inside a Frame, or null. If you specify a Frame or Dialog, then the Dialog
- will appear over the center of the Frame and follow the focus behavior of that Frame. If you
- specify a component inside a Frame, then the Dialog will appear over the center of that component
- and will follow the focus behavior of that component's Frame. If you specify null, then the look
- and feel will pick an appropriate position for the dialog generally the center of the screen and
- the Dialog will not necessarily follow the focus behavior of any visible Frame or Dialog.
-
- The JOptionPane constructors do not include this argument. Instead, you specify the parent frame
- when you create the JDialog that contains the JOptionPane, and you use the JDialog
- setLocationRelativeTo method to set the dialog position.
- Object message
- This required argument specifies what the dialog should display in its main area. Generally, you
- specify a string, which results in the dialog displaying a label with the specified text. You can
- split the message over several lines by putting newline (\n) characters inside the message string.
- For example:
-
- "Complete the sentence:\n \"Green eggs and...\""
-
- String title
- The title of the dialog.
- int optionType
- Specifies the set of buttons that appear at the bottom of the dialog. Choose from one of the
- following standard sets: DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION, OK_CANCEL_OPTION.
- int messageType
- This argument determines the icon displayed in the dialog. Choose from one of the following
- values: PLAIN_MESSAGE (no icon), ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE.
- Icon icon
- The icon to display in the dialog.
- Object[] options
- Generally used to specify the string displayed by each button at the bottom of the dialog. See
- Customizing Button Text in a Standard Dialog for more information. Can also be used to specify
- icons to be displayed by the buttons or non-button components to be added to the button row.
- Object initialValue
- Specifies the default value to be selected.
-
- You can either let the option pane display its default icon or specify the icon using the message
- type or icon argument. By default, an option pane created with showMessageDialog displays the
- information icon, one created with showConfirmDialog or showInputDialog displays the question
- icon, and one created with a JOptionPane constructor displays no icon. To specify that the dialog
- display a standard icon or no icon, specify the message type corresponding to the icon you desire.
- To specify a custom icon, use the icon argument. The icon argument takes precedence over the
- message type; as long as the icon argument has a non-null value, the dialog displays the
- specified icon.
- */
-
- private static String PANE_TEXT_STYLE_MACOS = " @@TITLE@@
@@MESSAGE@@
";
-
- private static String PANE_TEXT_STYLE_OTHER = " @@MESSAGE@@ ";
-
- /**
- * 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, G4P.ERROR, G4P.INFO, G4P.WARNING, G4P.QUERY
- *
- * @param owner the control responsible for this dialog.
- * @param message the text to be displayed in the main area of the dialog
- * @param title the text to appear in the dialog's title bar.
- * @param messageType the message type
- */
- public static void showMessage(PApplet owner, String message, String title, int messageType){
- Frame frame = getFrame(owner);
- String m;
- if(PApplet.platform == PApplet.MACOSX){
- m = PANE_TEXT_STYLE_MACOS.replaceAll("@@TITLE@@", title);
- title = "";
- m = m.replaceAll("@@MESSAGE@@", message);
- }
- else {
- m = PANE_TEXT_STYLE_OTHER.replaceAll("@@MESSAGE@@", message);
- }
- JOptionPane.showMessageDialog(frame, m, title, messageType);
- }
-
- /**
- * 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, G4P.ERROR, G4P.INFO, G4P.WARNING, G4P.QUERY
- *
- * 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
- *
- * @param owner the control responsible for this dialog.
- * @param message the text to be displayed in the main area of the dialog
- * @param title the text to appear in the dialog's title bar.
- * @param messageType the message type
- * @param optionType
- * @return which button was clicked
- */
- public static int selectOption(PApplet owner, String message, String title, int messageType, int optionType){
- Frame frame = getFrame(owner);
- String m;
- if(PApplet.platform == PApplet.MACOSX){
- m = PANE_TEXT_STYLE_MACOS.replaceAll("@@TITLE@@", title);
- title = "";
- m = m.replaceAll("@@MESSAGE@@", message);
- }
- else {
- m = PANE_TEXT_STYLE_OTHER.replaceAll("@@MESSAGE@@", message);
- }
- return JOptionPane.showOptionDialog(frame, m, title, optionType, messageType, null, null, null);
- }
-
- /**
- * Find the Frame associated with this object.
- *
- * @param owner the object that is responsible for this message
- * @return the frame (if any) that owns this object else return null
- */
- private static Frame getFrame(PApplet owner){
- Frame frame = null;
- try {
- frame = (Frame) ((processing.awt.PSurfaceAWT.SmoothCanvas) owner.getSurface().getNative()).getFrame();
- }
- catch(Exception e){
- }
- return frame;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GAbstractControl.java b/Processing/libraries/G4P/src/g4p_controls/GAbstractControl.java
deleted file mode 100644
index 93b004c..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GAbstractControl.java
+++ /dev/null
@@ -1,1183 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2008-12 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.NoninvertibleTransformException;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.LinkedList;
-
-import processing.awt.PGraphicsJava2D;
-import processing.core.PApplet;
-import processing.core.PConstants;
-import processing.core.PGraphics;
-import processing.event.KeyEvent;
-import processing.event.MouseEvent;
-
-/**
- * Abstract base class for all GUI controls.
- *
- * @author Peter Lager
- *
- */
-public abstract class GAbstractControl implements PConstants, GConstants, GConstantsInternal {
-
- /*
- * INTERNAL USE ONLY
- * This holds a reference to the GComponent that currently has the
- * focus.
- * A component loses focus when another component takes focus with the
- * takeFocus() method. The takeFocus method should use focusIsWith.loseFocus()
- * before setting its value to the new component.
- */
- static GAbstractControl focusIsWith = null;
-
- /*
- * INTERNAL USE ONLY
- * Use by the tab manager to move focus between controls
- *
- */
- static GAbstractControl controlToTakeFocus = null;
-
- /*
- * INTERNAL USE ONLY
- * Keeps track of the component the mouse is over so the mouse
- * cursor can be changed if we wish.
- */
- static GAbstractControl cursorIsOver;
-
- // Reference to the PApplet object that owns this control
- protected PApplet winApp;
-
- /* Used to when components overlap */
- protected int z = Z_STICKY;
-
- // Set to true when mouse is dragging : set false on button released
- protected boolean dragging = false;
-
- protected static float epsilon = 0.001f;
-
- /** Link to the parent panel (if null then it is on main window) */
- protected GAbstractControl parent = null;
-
- /*
- * A list of child GComponents added to this component
- * Created and used by GPanel and GDropList classes
- */
- protected LinkedList children = null;
-
- protected int localColorScheme = G4P.globalColorScheme;
- protected Color[] palette = null;
- protected int alphaLevel = G4P.globalAlpha;
-
- /** Top left position of component in pixels (relative to parent or absolute if parent is null)
- * (changed form int data type in V3*/
- protected float x, y;
- /** Width and height of component in pixels for drawing background (changed form int data type in V3*/
- protected float width, height;
- /** Half sizes reduces programming complexity later */
- protected float halfWidth, halfHeight;
- /** The centre of the control */
- protected float cx, cy;
- /** The angle to control is rotated (radians) */
- protected float rotAngle;
- /** Introduced V3 to speed up AffineTransform operations */
- protected double[] temp = new double[2];
-
- // New to V3 components have an image buffer which is only redrawn if
- // it has been invalidated
- protected PGraphicsJava2D buffer = null;
- protected boolean bufferInvalid = true;
-
- /** Whether to show background or not */
- protected boolean opaque = false;
-
- // The cursor image when over a control
- // This should be set in the controls constructor
- protected int cursorOver = HAND;
-
- /*
- * Position over control corrected for any transformation.
- * [0,0] is top left corner of the control.
- * This is used to determine the mouse position over any
- * particular control or part of a control.
- */
- protected float ox, oy;
-
- /** Simple tag that can be used by the user */
- public String tag;
-
- /** Allows user to specify a number for this component */
- public int tagNo;
-
- /* Is the component visible or not */
- boolean visible = true;
-
- /* Is the component enabled to generate mouse and keyboard events */
- boolean enabled = true;
-
- /*
- * Is the component available for mouse and keyboard events.
- * This is only used internally to prevent user input being
- * processed during animation.
- * It will preserve enabled and visible flags
- */
- boolean available = true;
-
- /* The object to handle the event */
- protected Object eventHandlerObject = null;
- /* The method in eventHandlerObject to execute */
- protected Method eventHandlerMethod = null;
- /* the name of the method to handle the event */
- protected String eventHandlerMethodName;
-
- protected int registeredMethods = 0;
-
- /*
- * Specify the PImage that contains the image{s} to be used for the button's state.
- * This image may be a composite of 1 to 3 images tiled horizontally.
- * @param img
- * @param nbrImages in the range 1 - 3
- */
- // static PImage[] loadImages(PImage img, int nbrImages){
- // if(img == null || nbrImages <= 0 || nbrImages > 3)
- // return null;
- // PImage[] bimage = new PImage[3];
- // int iw = img.width / nbrImages;
- // for(int i = 0; i < nbrImages; i++){
- // bimage[i] = new PImage(iw, img.height, ARGB);
- // bimage[i].copy(img,
- // i * iw, 0, iw, img.height,
- // 0, 0, iw, img.height);
- // }
- // // If less than 3 images reuse last image in set
- // for(int i = nbrImages; i < 3; i++)
- // bimage[i] = bimage[nbrImages - 1];
- // return bimage;
- // }
-
- // public static String getFocusName(){
- // if(focusIsWith == null)
- // return "null";
- // else
- // return focusIsWith.toString();
- // }
-
- /**
- * Base constructor for ALL control ctors that do not have a visible UI but require
- * access to a PApplet object.
- * As of V3.5 the only class using this constructor is GGroup
- *
- * @param theApplet
- */
- public GAbstractControl(PApplet theApplet) {
- G4P.registerSketch(theApplet);;
- winApp = theApplet;
- GCScheme.makeColorSchemes(winApp);
- rotAngle = 0;
- z = 0;
- palette = GCScheme.getJavaColor(localColorScheme);
- }
-
- /**
- * Base constructor for ALL control ctors that have a visible UI but whose width and height
- * are determined elsewhere e.g. the size of an image. It will set the
- * position of the control based on controlMode.
- *
- */
- public GAbstractControl(PApplet theApplet, float p0, float p1) {
- this(theApplet);
- switch(G4P.control_mode){
- case CORNER: // (x,y,w,h)
- case CORNERS: // (x0,y0,x1,y1)
- x = p0; y = p1;
- break;
- case CENTER: // (cx,cy,w,h)
- cx = p0; cy = p1;
- break;
- }
- }
-
-
- /**
- * Base constructor for ALL control ctors that have a visible UI. It will set the
- * position and size of the control based on controlMode.
- *
- */
- public GAbstractControl(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet);
- setPositionAndSize(p0, p1, p2, p3);
- // Create the buffer (only created with this ctor)
- buffer = (PGraphicsJava2D) winApp.createGraphics((int)width, (int)height, PApplet.JAVA2D);
- buffer.rectMode(PApplet.CORNER);
- buffer.beginDraw();
- buffer.endDraw();
- }
-
- // May not need this method needs to be caled in updateBuffer
- protected void setTextRenderingHints(Graphics2D g2d){
- // Attempt to fix antialiasing
-
- // MIGHT NEED THESE
- // If so they have to be done in update method
- g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
-
-
- // buffer.g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
- // RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
- // buffer.g2.setRenderingHint(
- // RenderingHints.KEY_TEXT_ANTIALIASING,
- // RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
-
- }
-
- /**
- * Calculate all the variables that determine the position and size of the
- * control. This depends on
control_mode
- *
- */
- private void setPositionAndSize(float n0, float n1, float n2, float n3){
- switch(G4P.control_mode){
- case CORNER: // (x,y,w,h)
- x = n0; y = n1; width = n2; height = n3;
- halfWidth = width/2; halfHeight = height/2;
- cx = x + halfWidth; cy = y + halfHeight;
- break;
- case CORNERS: // (x0,y0,x1,y1)
- x = n0; y = n1; width = n2 - n0; height = n3 - n1;
- halfWidth = width/2; halfHeight = height/2;
- cx = x + halfWidth; cy = y + halfHeight;
- break;
- case CENTER: // (cx,cy,w,h)
- cx = n0; cy = n1; width = n2; height = n3;
- halfWidth = width/2; halfHeight = height/2;
- x = cx - halfWidth; y = cy - halfHeight;
- break;
- }
- }
-
- /**
- * Used internally to enforce minimum size constraints
- *
- * @param w the new width
- * @param h the new height
- */
- protected void resize(int w, int h){
- width = w;
- height = h;
- halfWidth = width/2;
- halfHeight = height/2;
- switch(G4P.control_mode){
- case CORNER: // (x,y,w,h)
- case CORNERS: // (x0,y0,x1,y1)
- cx = x + halfWidth; cy = y + halfHeight;
- break;
- case CENTER: // (cx,cy,w,h)
- x = cx - halfWidth; y = cy - halfHeight;
- break;
- }
- buffer = (PGraphicsJava2D) winApp.createGraphics(w, h, PApplet.JAVA2D);
- buffer.rectMode(PApplet.CORNER);
- }
-
- /**
- * If the component responds to key or mouse input or has a visual representation
- * this it can be part of a group controller.
- * @param control the G4P control we are interested in
- * @return true if it can be added to a group controller
- */
- protected boolean isSuitableForGroupControl(GAbstractControl control){
- return (GROUP_CONTROL_METHOD & registeredMethods) != 0;
- }
-
-
- /*
- * These are empty methods to enable polymorphism
- */
- public void draw(){}
- public void mouseEvent(MouseEvent event){ }
- public void keyEvent(KeyEvent e) { }
- public void pre(){ }
- public void post(){ }
-
- /**
- * This will remove all references to this control in the library.
- * The user is responsible for nullifying all references to this control
- * in their sketch code.
- * Once this method is called the control cannot be reused but resources
- * used by the control remain until all references to the control are
- * set to null.
- *
- */
- public void dispose(){
- G4P.removeControl(this);
- }
-
- /**
- * This is for emergency use only!!!!
- * In this version of the library a visual controls is drawn to off-screen buffer
- * and then drawn to the screen by copying the buffer. This means that the
- * computationally expensive routines needed to draw the control (especially text
- * controls) are only done when a change has been noted. This means that single
- * changes need not trigger a full redraw to buffer.
- * It does mean that an error in the library code could result in the buffer not
- * being updated after changes. If this happens then in draw() call this method
- * on the affected control, and report it as an issue
- * here
- * Thanks
- */
- public void forceBufferUpdate(){
- bufferInvalid = true;
- }
-
- protected HotSpot[] hotspots = null;
- protected int currSpot = -1;
-
- /**
- * Stop when we are over a hotspot.
- * Hotspots should be listed in order of importance.
- *
- * @param px
- * @param py
- * @return the index for the first hotspot containing px,py else return -1
- */
- protected int whichHotSpot(float px, float py){
- if(hotspots == null) return -1;
- int hs = -1;
- for(int i = 0; i < hotspots.length; i++){
- if(hotspots[i].contains(px, py)){
- hs = hotspots[i].id;
- break;
- }
- }
- return hs;
- }
-
- protected int getCurrHotSpot(){
- return currSpot;
- }
-
- /**
- * Determines if a particular pixel position is over the panel.
- *
- * @return true if the position is over.
- */
- public boolean isOver(float x, float y){
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- return (currSpot >= 0);
- }
-
- /**
- * Change a specific colour within the scheme.
- * Most controls used a shared colour palette but calling this method
- * will create a new palette specific for this control.
- *
- * @param colorNo the colour index value (0-15 inlc)
- * @param color ARGB color value
- */
- public void setLocalColor(int colorNo, int color){
- //If necessary make a duplicate of the current color scheme
- if(localColorScheme >= 0){
- int[] colors = GCScheme.getPalette(localColorScheme);
- palette = new Color[16];
- for(int i = 0; i < 16; i++)
- palette[i] = new Color(colors[i], true); // keep alpha
- localColorScheme = -1;
- }
- colorNo = Math.abs(colorNo) % 16;
- palette[colorNo] = new Color(color, true); // keep alpha;
- bufferInvalid = true;
- }
-
- /**
- * Set the local colour scheme for this control. Children are ignored.
- *
- * @param cs the colour scheme to use (0-15 incl.)
- */
- public void setLocalColorScheme(int cs){
- setLocalColorScheme(cs, false);
- }
-
- /**
- * Set the local colour scheme for this control.
- * If required include the children and their children.
- *
- * @param cs the colour scheme to use (0-15 incl.)
- * @param includeChildren if do do the same for all descendants
- */
- public void setLocalColorScheme(int cs, boolean includeChildren){
- cs = Math.abs(cs) % 16; // Force into valid range
- if(localColorScheme != cs || palette == null){
- localColorScheme = cs;
- palette = GCScheme.getJavaColor(localColorScheme);
- bufferInvalid = true;
- if(includeChildren && children != null){
- for(GAbstractControl c : children)
- c.setLocalColorScheme(cs, true);
- }
- }
- }
-
- /**
- * Get the local color scheme ID number. If it returns a value <0 then
- * it is using a control specific palette.
- *
- */
- public int getLocalColorScheme(){
- return localColorScheme;
- }
-
- /**
- * Set the transparency of the component and make it unavailable to
- * mouse and keyboard events if below the threshold. Child controls
- * are ignored?
- *
- * @param alpha value in the range 0 (transparent) to 255 (opaque)
- */
- public void setAlpha(int alpha){
- alpha = Math.abs(alpha) % 256;
- if(alphaLevel != alpha){
- alphaLevel = alpha;
- available = (alphaLevel >= ALPHA_BLOCK);
- bufferInvalid = true;
- }
- }
-
- /**
- * Set the transparency of the component and make it unavailable to
- * mouse and keyboard events if below the threshold. Child controls
- * are ignored?
- * If required include the children and their children.
- *
- * @param alpha value in the range 0 (transparent) to 255 (opaque)
- * @param includeChildren if do do the same for all descendants
- */
- public void setAlpha(int alpha, boolean includeChildren){
- setAlpha(alpha);
- if(includeChildren && children != null){
- for(GAbstractControl c : children)
- c.setAlpha(alpha, true);
- }
- }
-
- /**
- * Get the parent control. If null then this is a top-level component
- */
- public GAbstractControl getParent() {
- return parent;
- }
-
- /**
- * Get the PApplet that manages this component
- */
- public PApplet getPApplet() {
- return winApp;
- }
-
- // Used by composite control i.e. ones that have scrollbars, buttons etc. but not
- // GWindow and GPanel
- protected PGraphics getBuffer(){
- return buffer;
- }
-
- /**
- * Support UTF8 encoding
- * @param ascii UTF8 code
- * @return true if the character can be displayed
- */
- protected boolean isDisplayable(int ascii){
- return !(ascii < 32 || ascii == 127);
- }
-
- /**
- * This method should be used sparingly since it is heavy on resources.
- *
- * @return a PGraphics object showing current state of the control (ignoring rotation)
- */
- public PGraphics getSnapshot(){
- if(buffer != null){
- updateBuffer();
- PGraphics snap = winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
- snap.beginDraw();
- snap.image(buffer,0,0);
- snap.endDraw();
- return snap;
- }
- return null;
- }
-
- /**
- * Save a snapshot of the control using class name and sketch runtime as the filename
- * @return true if the snapshot was saved else return false
- */
- public boolean saveSnapshot(){
- String filename = getClass().getSimpleName().toLowerCase() + "_" + System.currentTimeMillis() + ".png";
- return saveSnapshot(filename);
- }
-
- /**
- * Save a snapshot of the control using the specified filename
- * @return true if the snapshot was saved else return false
- */
- public boolean saveSnapshot(String filename){
- PGraphics snapshot = getSnapshot();
- if(snapshot != null){
- snapshot.save(filename);
- return true;
- }
- return false;
- }
-
- /*
- * Empty method at the moment make abstract
- * in final version
- */
- protected void updateBuffer() {}
-
-
- /**
- * Attempt to create the default event handler for the component class.
- * The default event handler is a method that returns void and has a single
- * parameter of the same type as the component class generating the
- * event and a method name specific for that class.
- *
- * @param handlerObj the object to handle the event
- * @param methodName the method to execute in the object handler class
- * @param param_classes the parameter classes.
- * @param param_names that names of the parameters (used for error messages only)
- */
- @SuppressWarnings("rawtypes")
- protected void createEventHandler(Object handlerObj, String methodName, Class[] param_classes, String[] param_names){
- try{
- eventHandlerMethod = handlerObj.getClass().getMethod(methodName, param_classes );
- eventHandlerObject = handlerObj;
- eventHandlerMethodName = methodName;
- } catch (Exception e) {
- GMessenger.message(MISSING, new Object[] {this, methodName, param_classes, param_names});
- eventHandlerObject = null;
- }
- }
-
- /**
- * Attempt to create the default event handler for the component class.
- * The default event handler is a method that returns void and has a single
- * parameter of the same type as the component class generating the
- * event and a method name specific for that class.
- *
- * @param obj the object to handle the event
- * @param methodName the method to execute in the object handler class
- */
- public void addEventHandler(Object obj, String methodName){
- try{
- eventHandlerObject = obj;
- eventHandlerMethodName = methodName;
- eventHandlerMethod = obj.getClass().getMethod(methodName, new Class>[] {this.getClass(), GEvent.class } );
- } catch (Exception e) {
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { this.getClass(), GEvent.class } } );
- eventHandlerObject = null;
- eventHandlerMethodName = "";
- }
- }
-
- /**
- * Attempt to fire an event for this component.
- *
- * The method called must have a single parameter which is the object
- * firing the event.
- * If the method to be called is to have different parameters then it should
- * be overridden in the child class
- * The method
- */
- protected void fireEvent(Object... objects){
- if(eventHandlerMethod != null){
- try {
- eventHandlerMethod.invoke(eventHandlerObject, objects);
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {eventHandlerObject, eventHandlerMethodName, e } );
- }
- }
- }
-
- /**
- * Set the rotation to apply when displaying this control. The center of
- * rotation is determined by the control_mode attribute.
- *
- * @param angle clockwise angle in radians
- */
- public void setRotation(float angle){
- setRotation(angle, G4P.control_mode);
- }
-
- /**
- * Set the rotation to apply when displaying this control. The center of
- * rotation is determined by the mode parameter parameter.
- *
- * @param angle clockwise angle in radians
- * @param mode PApplet.CORNER / CORNERS / CENTER
- */
- public void setRotation(float angle, GControlMode mode){
- rotAngle = angle;
- AffineTransform aff = new AffineTransform();
- aff.setToRotation(angle);
- switch(mode){
- case CORNER:
- case CORNERS:
- // Rotate about top corner
- temp[0] = halfWidth;
- temp[1] = halfHeight;
- aff.transform(temp, 0, temp, 0, 1);
- cx = (float)temp[0] + x;// - halfWidth;
- cy = (float)temp[1] + y;// - halfHeight;
- break;
- case CENTER:
- default:
- // Rotate about centre
- temp[0] = -halfWidth;
- temp[1] = -halfHeight;
- aff.transform(temp, 0, temp, 0, 1);
- x = cx + (float)temp[0];
- y = cy + (float)temp[1]; // should this be minus?? I don't think so
- break;
- }
- }
-
- /**
- * Move the control to the given position based on the mode.
- *
- * The position is not constrained to the screen area.
- *
- * The current control mode determines whether we move the
- * corner or the center of the control to px,py
- *
- * @param px the horizontal position to move to
- * @param py the vertical position to move to
- */
- public void moveTo(float px, float py){
- moveTo(px, py, G4P.control_mode);
- }
-
- /**
- * Move the control to the given position based on the mode.
- *
- * Unlike when dragged the position is not constrained to the
- * screen area.
- *
- * The mode determines whether we move the corner or the center
- * of the control to px,py
- *
- * @param px the horizontal position to move to
- * @param py the vertical position to move to
- * @param mode the control mode
- */
- public void moveTo(float px, float py, GControlMode mode){
- GAbstractControl p = parent;
- if(p != null){
- px -= p.width/2.0f;
- py -= p.height/2.0f;
- }
- switch(mode){
- case CORNER:
- case CORNERS:
- cx += (px - x);
- cy += (py - y);
- x = cx - width/2.0f;
- y = cy - height/2.0f;
- break;
- case CENTER:
- cx = px;
- cy = py;
- x = cx - width/2.0f;
- y = cy - height/2.0f;
- break;
- }
- }
-
- /**
- * Get the left position of the control.
- * If the control is on a panel then the value returned is relative to the
- * top-left corner of the panel otherwise it is relative to the sketch
- * window display.
- *
- */
- public float getX() {
- if(parent != null)
- return x + parent.width/2.0f;
- else
- return x;
- }
-
- /**
- * Get the top position of the control.
- * If the control is on a panel then the value returned is relative to the
- * top-left corner of the panel otherwise it is relative to the sketch
- * window display.
- *
- */
- public float getY() {
- if(parent != null)
- return y + parent.height/2.0f;
- else
- return y;
- }
-
- /**
- * Get the centre x position of the control.
- * If the control is on a panel then the value returned is relative to the
- * top-left corner of the panel otherwise it is relative to the sketch
- * window display.
- */
- public float getCX() {
- if(parent != null)
- return x + (parent.width + width)/2.0f;
- else
- return cx;
- }
-
- /**
- * Get the centre y position of the control.
- * If the control is on a panel then the value returned is relative to the
- * top-left corner of the panel otherwise it is relative to the sketch
- * window display.
- *
- */
- public float getCY() {
- if(parent != null)
- return x + (parent.width + width)/2.0f;
- else
- return cy;
- }
-
- /**
- * @return the width
- */
- public float getWidth() {
- return width;
- }
-
- /**
- * @return the height
- */
- public float getHeight() {
- return height;
- }
-
- /**
- *
- * @param visible the visibility to set
- */
- public void setVisible(boolean visible) {
- // If we are making it invisible and it has focus give up the focus
- if(!visible && focusIsWith == this)
- loseFocus(null);
- this.visible = visible;
- // Only available if alpha level is high enough
- if(visible)
- available = (alphaLevel > ALPHA_BLOCK);
- else
- available = false;
- // If this control has children than make them available if this control
- // is visible and unavailable if invisible
- if(children != null){
- for(GAbstractControl c : children)
- c.setAvailable(this.visible);
- }
- }
-
-
- /**
- * @return the component's visibility
- */
- public boolean isVisible() {
- return visible;
- }
-
- /**
- * The availability flag is used by the library code to determine whether
- * a control should be considered for drawing and mouse/key input.
- * It perits an internal control that does not affect the visible
- * and enabled state of the control, which are set by the programmer.
- *
- * If a control and its children are made unavailable it will still be drawn
- * but it not respond to user input.
- *
- * @param avail
- */
- protected void setAvailable(boolean avail){
- available = avail;
- if(children != null){
- for(GAbstractControl c : children)
- c.setAvailable(avail);
- }
- }
-
- /**
- * Is this control available?
- */
- protected boolean isAvailable(){
- return available;
- }
-
- /**
- * Determines whether to show the back colour or not.
- * Only applies to some components
- * @param opaque
- */
- public void setOpaque(boolean opaque){
- // Ensure that we dont't go from true >> false otherwise
- // it will validate an invalid buffer
- bufferInvalid |= (opaque != this.opaque);
- this.opaque = opaque;
- }
-
- /**
- * Find out if the component is opaque
- * @return true if the background is visible
- */
- public boolean isOpaque(){
- return opaque;
- }
-
- public boolean isDragging(){
- return dragging;
- }
-
- /**
- * Enable or disable the ability of the component to generate mouse events.
- * GTextField - it also controls key press events
- * GPanel - controls whether the panel can be moved/collapsed/expanded
- * @param enable true to enable else false
- */
- public void setEnabled(boolean enable){
- enabled = enable;
- if(children != null){
- for(GAbstractControl c : children)
- c.setEnabled(enable);
- }
- }
-
- /**
- * Is this component enabled
- * @return true if the component is enabled
- */
- public boolean isEnabled(){
- return enabled;
- }
-
- /**
- * Give the focus to this component but only after allowing the
- * current component with focus to release it gracefully.
- * Always cancel the keyFocusIsWith irrespective of the component
- * type. If the component needs to retain keyFocus then override this
- * method in that class e.g. GCombo
- */
- protected void takeFocus(){
- if(focusIsWith != null && focusIsWith != this)
- focusIsWith.loseFocus(this);
- focusIsWith = this;
- }
-
- /**
- * For most components there is nothing to do when they loose focus.
- * Override this method in classes that need to do something when
- * they loose focus eg TextField
- */
- protected void loseFocus(GAbstractControl grabber){
- if(cursorIsOver == this)
- cursorIsOver = null;
- focusIsWith = grabber;
- bufferInvalid = true;
- }
-
- /**
- * Determines whether this component is to have focus or not
- * @param focus
- */
- public void setFocus(boolean focus){
- if(focus)
- takeFocus();
- else
- loseFocus(null);
- }
-
- /**
- * Does this component have focus
- * @return true if this component has focus else false
- */
- public boolean hasFocus(){
- return (this == focusIsWith);
- }
-
- /**
- * Get the Z order value for the object with focus.
- */
- protected static int focusObjectZ(){
- return (focusIsWith == null) ? -1 : focusIsWith.z;
- }
-
- /**
- * This will set the rotation of the control to angle overwriting
- * any previous rotation set. Then it calculates the centre position
- * so that the original top left corner of the control will be the
- * position indicated by x,y with respect to the top left corner of
- * parent.
- *
- * The added control will have its position calculated relative to the
- * centre of the parent control.
- *
- * All overloaded methods call this one.
- *
- * @param c the control to add.
- * @param x the leftmost or centre position depending on controlMode
- * @param y the topmost or centre position depending on controlMode
- * @param angle the rotation angle (replaces any the angle specified in control)
- */
- public void addControl(GAbstractControl c, float x, float y, float angle){
- // Ignore if children are not allowed.
- if(children == null) return;
- c.rotAngle = angle;
- // In child control reset the control so it centred about the origin
- AffineTransform aff = new AffineTransform();
- aff.setToRotation(angle);
- /*
- * The following code should result in the x,y and cx,cy coordinates of
- * the added control (c) added being measured relative to the centre of
- * this control.
- */
- switch(G4P.control_mode){
- case CORNER:
- case CORNERS:
- // Rotate about top corner
- c.x = x; c.y = y;
- c.temp[0] = c.halfWidth;
- c.temp[1] = c.halfHeight;
- aff.transform(c.temp, 0, c.temp, 0, 1);
- c.cx = (float)c.temp[0] + x - halfWidth;
- c.cy = (float)c.temp[1] + y - halfHeight;
- c.x = c.cx - c.halfWidth;
- c.y = c.cy - c.halfHeight;
- break;
- case CENTER:
- // Rotate about centre
- c.cx = x; c.cy = y;
- c.temp[0] = -c.halfWidth;
- c.temp[1] = -c.halfHeight;
- aff.transform(c.temp, 0, c.temp, 0, 1);
- c.x = c.cx + (float)c.temp[0] - halfWidth;
- c.y = c.cy - (float)c.temp[1] - halfHeight;
- c.cx -= halfWidth;
- c.cy -= halfHeight;
- break;
- }
- c.rotAngle = angle;
- // Add to parent
- c.parent = this;
- c.setZ(z);
- // Parent will now be responsible for drawing
- c.registeredMethods &= (ALL_METHOD - DRAW_METHOD);
- if(children == null)
- children = new LinkedList();
- children.addLast(c);
- Collections.sort(children, new Z_Order());
- // Does the control being added have to do anything extra
- c.addToParent(this);
- }
-
- /**
- * Add a control at the given position with zero rotation angle.
- *
- * @param c the control to add.
- * @param x the leftmost or centre position depending on controlMode
- * @param y the topmost or centre position depending on controlMode
- */
- public void addControl(GAbstractControl c, float x, float y){
- // Ignore if children are not allowed.
- if(children == null) return;
- addControl(c, x, y, 0);
- }
-
- /**
- * Add a control at the position and rotation specified in the control.
- *
- * @param c the control to add
- */
- public void addControl(GAbstractControl c){
- // Ignore if children are not allowed.
- if(children == null) return;
- switch(G4P.control_mode){
- case CORNER:
- case CORNERS:
- addControl(c, c.x, c.y, c.rotAngle);
- break;
- case CENTER:
- addControl(c, c.cx, c.cy, c.rotAngle);
- break;
- }
- }
-
- /**
- * Add several control at the position and rotation specified in each control.
- *
- * @param controls comma separated list of controls
- */
- public void addControls(GAbstractControl... controls){
- // Ignore if children are not allowed.
- if(children == null) return;
- for(GAbstractControl c : controls){
- switch(G4P.control_mode){
- case CORNER:
- case CORNERS:
- addControl(c, c.x, c.y, c.rotAngle);
- break;
- case CENTER:
- addControl(c, c.cx, c.cy, c.rotAngle);
- break;
- }
- }
- }
-
- /**
- * Changes that need to be made to child when added.
- * Override where needed e.g. GPanel
- *
- * @param p the parent
- */
- protected void addToParent(GAbstractControl p){
- }
-
- /**
- * Get the shape type when the cursor is over a control
- * @return shape type
- */
- public int getCursorOver() {
- return cursorOver;
- }
-
- /**
- * Set the shape type to use when the cursor is over a control
- * @param cursorOver the shape type to use
- */
- public void setCursorOver(int cursorOver) {
- this.cursorOver = cursorOver;
- }
-
- /**
- * Get an affine transformation that is the compound of all
- * transformations including parents
- * @param aff
- */
- protected AffineTransform getTransform(AffineTransform aff){
- if(parent != null)
- aff = parent.getTransform(aff);
- aff.translate(cx, cy);
- aff.rotate(rotAngle);
- return aff;
- }
-
- /**
- * This method takes a position px, py and calculates the equivalent
- * position [ox,oy] as if no transformations have taken place and
- * the origin is the top-left corner of the control.
- * @param px
- * @param py
- */
- protected void calcTransformedOrigin(float px, float py){
- AffineTransform aff = new AffineTransform();
- aff = getTransform(aff);
- temp[0] = px; temp[1] = py;
- try {
- aff.inverseTransform(temp, 0, temp, 0, 1);
- ox = (float) temp[0] + halfWidth;
- oy = (float) temp[1] + halfHeight;
- } catch (NoninvertibleTransformException e) {
- }
- }
-
-
- /**
- * Recursive function to set the priority of a component. This
- * is used to determine who gets focus when components overlap
- * on the screen e.g. when a combobo expands it might cover a button.
- * It is used where components have childen e.g. GCombo and
- * GPaneln
- * It is used when a child component is added.
- * @param component
- * @param parentZ
- */
- protected void setZ(int parentZ){
- z += parentZ;
- if(children != null){
- for(GAbstractControl c : children){
- c.setZ(parentZ);
- }
- }
- }
-
- /**
- * If the control is permanently no longer required then call
- * this method to remove it and free up resources.
- * The variable identifier used to create this control should
- * be set to null.
- * For example if you want to dispose of a button called
- *
btnDoThis
then to remove the button use the
- * statements
- * btnDoThis.dispose();
- * btnDoThis = null;
- */
- public void markForDisposal(){
- G4P.removeControl(this);
- }
-
-
- public String toString(){
- if(tag == null)
- return this.getClass().getSimpleName();
- else
- return tag;
- }
-
- /**
- * Comparator used for controlling the order components are drawn
- * @author Peter Lager
- */
- public static class Z_Order implements Comparator {
-
- public int compare(GAbstractControl c1, GAbstractControl c2) {
- if(c1.z != c2.z)
- return new Integer(c1.z).compareTo( new Integer(c2.z));
- else
- return new Integer((int) -c1.y).compareTo(new Integer((int) -c2.y));
- }
-
- } // end of comparator class
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GAlign.java b/Processing/libraries/G4P/src/g4p_controls/GAlign.java
deleted file mode 100644
index 9a36ce7..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GAlign.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2008-12 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-/**
- * This class provides an enumeration that is used to control the alignment
- * of text and images.
- *
- * @author Peter Lager
- *
- */
-public enum GAlign {
-
- INVALID ( -1, "INVALID", "Invalid alignment" ),
-
- // Horizontal alignment constants
- LEFT ( 0, "LEFT", "Align left" ),
- CENTER ( 1, "CENTER", "Align centre horizontally" ),
- RIGHT ( 2, "RIGHT", "Align right" ),
- JUSTIFY ( 3, "JUSTIFY", "Justify text" ),
-
- // Vertical alignment constants
- TOP ( 16, "TOP", "Align top" ),
- MIDDLE ( 17, "MIDDLE", "Align middle vertically" ),
- BOTTOM ( 18, "BOTTOM", "Align bottom" );
-
-
- /**
- * Get an alignment based on its ID number.
- *
- * @param id the id number for this alignment.
- * @return the alignment or INVALID if not found
- */
- public static GAlign getFromID(int id){
- switch(id){
- case 0:
- return LEFT;
- case 1:
- return CENTER;
- case 2:
- return RIGHT;
- case 3:
- return JUSTIFY;
- case 16:
- return TOP;
- case 17:
- return MIDDLE;
- case 18:
- return BOTTOM;
- }
- return INVALID;
- }
-
- /**
- * Get an alignment based on its alignment text.
- *
- * @param text the alignment text.
- * @return the alignment or INVALID if not found
- */
- public static GAlign getFromText(String text){
- text = text.toUpperCase();
- if(text.equals("LEFT"))
- return LEFT;
- if(text.equals("CENTER"))
- return CENTER;
- if(text.equals("RIGHT"))
- return RIGHT;
- if(text.equals("JUSTIFY"))
- return JUSTIFY;
- if(text.equals("TOP"))
- return TOP;
- if(text.equals("MIDDLE"))
- return MIDDLE;
- if(text.equals("BOTTOM"))
- return BOTTOM;
- return INVALID;
- }
-
- private int alignID;
- private String alignText;
- private String description;
-
- /**
- * A private constructor to prevent alignments being create outside this class.
- *
- * @param id
- * @param text
- * @param desc
- */
- private GAlign(int id, String text, String desc ){
- alignID = id;
- alignText = text;
- description = desc;
- }
-
- /**
- * Get the id number associated with this alignment
- * @return the ID associated with this alignment
- */
- public int getID(){
- return alignID;
- }
-
- /**
- * Get the text ID associated with this alignment.
- *
- * @return alignment text e.g. "RIGHT"
- */
- public String getTextID(){
- return alignText;
- }
-
- /**
- * Get the description of this alignment
- *
- * @return e.g. "Align top"
- */
- public String getDesc(){
- return description;
- }
-
- /**
- * Is this a horizontal alignment constant?
- */
- public boolean isHorzAlign(){
- return alignID >= 0 && alignID <= 8;
- }
-
- /**
- * Is this a vertical alignment constant?
- */
- public boolean isVertAlign(){
- return alignID >= 16;
- }
-
- /**
- * Get the alignment text.
- */
- public String toString(){
- return alignText;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GButton.java b/Processing/libraries/G4P/src/g4p_controls/GButton.java
deleted file mode 100644
index 148dfd5..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GButton.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2008 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSmask;
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Graphics2D;
-import java.awt.font.TextLayout;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-import processing.event.MouseEvent;
-
-/**
- * This class is the Button component.
- *
- * The button face can have either text or an image or both just
- * pick the right constructor.
- *
- * Three types of event can be generated :-
- * PRESSED RELEASED CLICKED
- *
- * To simplify event handling the button only fires off CLICKED events
- * if the mouse button is pressed and released over the button face
- * (the default behaviour).
- *
- * Using
button1.fireAllEvents(true);
enables the other 2 events
- * for button button1. A PRESSED event is created if the mouse button
- * is pressed down over the button face, the CLICKED event is then generated
- * if the mouse button is released over the button face. Releasing the
- * button off the button face creates a RELEASED event.
- *
- * The image file can either be a single image which is used for
- * all button states, or be a composite of 3 images (tiled horizontally)
- * which are used for the different button states OFF, OVER and DOWN
- * in which case the image width should be divisible by 3.
- * A number of setImages(...) methods exist to set button state images, these
- * can be used once the button is created.
- *
- *
- * @author Peter Lager
- *
- */
-public class GButton extends GTextIconAlignBase {
-
- private static boolean roundCorners = true;
- private static float CORNER_RADIUS = 6;
-
- public static void useRoundCorners(boolean useRoundCorners){
- roundCorners = useRoundCorners;
- }
-
- // Mouse over status
- protected int status = 0;
-
- // Only report CLICKED events
- protected boolean reportAllButtonEvents = false;
-
- public GButton(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, "");
- }
-
- public GButton(PApplet theApplet, float p0, float p1, float p2, float p3, String text) {
- super(theApplet, p0, p1, p2, p3);
- PGraphics mask = winApp.createGraphics((int) width, (int) height, JAVA2D);
- mask.beginDraw();
- mask.background(255);
- mask.fill(0);
- mask.stroke(0);
- mask.strokeWeight(1);
- if(roundCorners)
- mask.rect(0, 0, width-2, height-2, CORNER_RADIUS);
- else
- mask.rect(0, 0, width-2, height-2);
- mask.endDraw();
-
- hotspots = new HotSpot[]{
- new HSmask(1, mask) // control surface
- };
-
- setText(text);
- z = Z_SLIPPY;
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleButtonEvents",
- new Class>[]{ GButton.class, GEvent.class },
- new String[]{ "button", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- // Must register control
- G4P.registerControl(this);
- }
-
- /**
- * If the parameter is true all 3 event types are generated, if false
- * only CLICKED events are generated (default behaviour).
- * @param all
- */
- public void fireAllEvents(boolean all){
- reportAllButtonEvents = all;
- }
-
- /**
- * Enable or disable the ability of the component to generate mouse events.
- * If the control is to be disabled when it is clicked then this will force the
- * mouse off button image is used.
- * @param enable true to enable else false
- */
- public void setEnabled(boolean enable){
- super.setEnabled(enable);
- if(!enable)
- status = OFF_CONTROL;
- }
-
- /**
- *
- * When a mouse button is clicked on a GButton it generates the GEvent.CLICKED event. If
- * you also want the button to generate GEvent.PRESSED and GEvent.RELEASED events
- * then you need the following statement.
- *
- *
- */
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
-
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot >= 0 && z > focusObjectZ()){
- dragging = false;
- status = PRESS_CONTROL;
- takeFocus();
- if(reportAllButtonEvents)
- fireEvent(this, GEvent.PRESSED);
- bufferInvalid = true;
- }
- break;
- case MouseEvent.CLICK:
- // No need to test for isOver() since if the component has focus
- // and the mouse has not moved since MOUSE_PRESSED otherwise we
- // would not get the Java MouseEvent.MOUSE_CLICKED event
- if(focusIsWith == this){
- status = OFF_CONTROL;
- bufferInvalid = true;
- loseFocus(null);
- dragging = false;
- fireEvent(this, GEvent.CLICKED);
- }
- break;
- case MouseEvent.RELEASE:
- // if the mouse has moved then release focus otherwise
- // MOUSE_CLICKED will handle it
- if(focusIsWith == this && dragging){
- if(reportAllButtonEvents)
- fireEvent(this, GEvent.RELEASED);
- dragging = false;
- loseFocus(null);
- status = OFF_CONTROL;
- bufferInvalid = true;
- }
- break;
- case MouseEvent.MOVE:
- int currStatus = status;
- // If dragged state will stay as PRESSED
- if(currSpot >= 0)
- status = OVER_CONTROL;
- else
- status = OFF_CONTROL;
- if(currStatus != status)
- bufferInvalid = true;
- break;
- case MouseEvent.DRAG:
- dragging = (focusIsWith == this);
- break;
- }
- }
-
- public void draw(){
- if(!visible) return;
-
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- // Set the font and read the latest test
- Graphics2D g2d = (Graphics2D) buffer.g2;
- g2d.setFont(localFont);
- LinkedList lines = stext.getLines(g2d);
- // Draw the button head
- buffer.clear();
- buffer.stroke(palette[3].getRGB());
- buffer.strokeWeight(1);
- switch(status){
- case OVER_CONTROL:
- buffer.fill(palette[6].getRGB());
- break;
- case PRESS_CONTROL:
- buffer.fill(palette[14].getRGB());
- break;
- default:
- buffer.fill(palette[4].getRGB());
- }
- if(roundCorners)
- buffer.rect(0, 0, width-2, height-2, CORNER_RADIUS);
- else
- buffer.rect(0, 0, width-2, height-2);
-
- // Calculate text and icon placement
- calcAlignment();
- // If there is an icon draw it
- if(iconW != 0)
- buffer.image(bicon[status], siX, siY);
- float wrapWidth = stext.getWrapWidth();
- float sx = 0, tw = 0;
- buffer.translate(stX, stY);
- for(TextLayoutInfo lineInfo : lines){
- TextLayout layout = lineInfo.layout;
- buffer.translate(0, layout.getAscent());
- //System.out.println(layout.toString());
- switch(textAlignH){
- case CENTER:
- tw = layout.getVisibleAdvance();
- tw = (tw > wrapWidth) ? tw - wrapWidth : tw;
- sx = (wrapWidth - tw)/2;
- break;
- case RIGHT:
- tw = layout.getVisibleAdvance();
- tw = (tw > wrapWidth) ? tw - wrapWidth : tw;
- sx = wrapWidth - tw;
- break;
- case LEFT:
- case JUSTIFY:
- default:
- sx = 0;
- }
- // display text
- g2d.setColor(palette[2]);
- layout.draw(g2d, sx, 0);
- buffer.translate(0, layout.getDescent() + layout.getLeading());
- }
- buffer.endDraw();
- }
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GCScheme.java b/Processing/libraries/G4P/src/g4p_controls/GCScheme.java
deleted file mode 100644
index e8f151b..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GCScheme.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Color;
-import java.io.IOException;
-import java.io.InputStream;
-
-import processing.core.PApplet;
-import processing.core.PConstants;
-import processing.core.PGraphics;
-import processing.core.PImage;
-
-/**
- * Defines a number of color schemes for the GUI components.
- * G4P supports 16 colour schemes and each scheme has a palette of 16 colours.
- *
- * When G4P is used it loads an image file with all the colors used by the various colour schemes.
- * First it will search for a file containing a user defined scheme (user_gui_palette.png) and
- * if it can't find it, will use the library default scheme (default_gui_palette.png).
- *
- * @author Peter Lager
- *
- */
-public class GCScheme implements GConstants, PConstants {
-
- private static Color[][] palettes = null;
-
- /**
- * Set the color scheme to one of the preset schemes
- * BLUE / GREEN / RED / PURPLE / YELLOW / CYAN / BROWN
- * or if you have created your own schemes following the instructions
- * at gui4processing.lagers.org.uk/colorscheme.html then you can enter
- * the appropriate numeric value of the scheme.
- *
- * @param schemeNbr scheme number (0-15)
- * @return the color scheme based on the scheme number
- */
- public static int[] getPalette(int schemeNbr){
- schemeNbr = Math.abs(schemeNbr) % 16;
- Color[] colScheme = palettes[schemeNbr];
- int[] colSchemeI = new int[16];
- for(int i = 0; i < 16; i++)
- colSchemeI[i] = colScheme[i].getRGB();
- return colSchemeI;
- }
-
- /**
- * Change a colour scheme to use the colours passed in the third parameter.
- * Colour scheme numbers 0-7 inclusive are the default colour schemes and
- * schemes 8-15 inclusive are undefined by G4P.
- * This method will override the previous scheme and will affect all controls
- * using the scheme.
- *
- * @param schemeNbr the scheme number
- * @param colors the colours to use in this palette.
- */
- public static void changePalette(int schemeNbr, int[] colors){
- schemeNbr = Math.abs(schemeNbr) % 16;
- for(int i = 0; i < Math.min(16, colors.length); i++)
- palettes[schemeNbr][i] = new Color(colors[i], true); // keep alpha
- G4P.invalidateBuffers();
- }
-
- /**
- * Copies the colours from the source scheme to the destination scheme.
- *
- * @param srcSchemeNbr source scheme number (0-15)
- * @param dstSchemeNbr destination scheme number (0-15)
- */
- public static void copyPalette(int srcSchemeNbr, int dstSchemeNbr){
- srcSchemeNbr = Math.abs(srcSchemeNbr) % 16;
- dstSchemeNbr = Math.abs(dstSchemeNbr) % 16;
- if(srcSchemeNbr != dstSchemeNbr){
- int[] palette = getPalette(srcSchemeNbr);
- changePalette(dstSchemeNbr, palette);
- }
- }
-
- /**
- * Change a single colour within an existing scheme
- *
- * @param schemeNbr the scheme number
- * @param colorNbr the palette index number for the colour
- * @param color ARGB colour value
- */
- public static void changePaletteColor(int schemeNbr, int colorNbr, int color){
- schemeNbr = Math.abs(schemeNbr) % 16;
- colorNbr = Math.abs(colorNbr) % 16;
- palettes[schemeNbr][colorNbr] = new Color(color, true); // keep alpha
- G4P.invalidateBuffers();
- }
-
- /**
- * Save the current colour schemes as an image in the sketch's data folder. The file will be
- * called
"user_gui_palette.png"
- *
- * @param app the PApplet object
- */
- public static void savePalettes(PApplet app){
- savePalettes(app, "user_gui_palette.png");
- }
-
- /**
- * Save the current colour schemes as an image in the sketch's data folder.
- *
- * @param app the PApplet object
- * @param filename the name of the image file to use
- */
- public static void savePalettes(PApplet app, String filename){
- PGraphics pg = app.createGraphics(256, 256, JAVA2D);
- pg.beginDraw();
- pg.clear();
- pg.noStroke();
- for(int scheme = 0; scheme < 16; scheme++){
- for(int idx = 0; idx < 16; idx++){
- pg.fill(palettes[scheme][idx].getRGB());
- pg.rect(idx * 16, scheme * 16, 16,16);
- }
- }
- pg.noFill();
- pg.strokeWeight(2);
- pg.stroke(0);
- for(int i = 0; i <= 16; i++){
- int m = i * 16;
- pg.line(0, m, 256, m);
- pg.line(m, 0, m, 256);
- }
- pg.endDraw();
- filename = app.dataPath("") + "/" + filename;
- System.out.println(filename);
- pg.save(filename);
- }
-
-
- /**
- * Called every time we create a control. The palettes will be made when
- * the first control is created.
- *
- * This method is called by
- * @param app the PApplet using this scheme
- */
- public static void makeColorSchemes(PApplet app) {
- // If the palettes have not been created then create them
- // otherwise do nothing
- if(palettes != null)
- return;
- // Load the image
- PImage image = null;;
- InputStream is = app.createInput("user_gui_palette.png");
- if(is != null){
- try {
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- image = app.loadImage("user_gui_palette.png");
- GMessenger.message(USER_COL_SCHEME, null);
- }
- else {
- // User image not provided
- image = app.loadImage("default_gui_palette.png");
- // Added to 3.4 to hopefully fix problem with OpenProcessing
- if(image == null)
- image = new PImage((new javax.swing.ImageIcon(new GCScheme().getClass().getResource("/data/default_gui_palette.png"))).getImage());
- }
- // Now make the palette
- palettes = new Color[16][16];
- for(int p = 0; p < 16; p++)
- for(int c = 0; c < 16; c++){
- int col = image.get(c * 16 + 8, p * 16 + 8);
- palettes[p][c] = new Color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
- }
- }
-
- /*
- * The following methods are ONLY called by GUI Builder do not change their names.
- */
-
- /**
- * DO NOT CALL THIS METHOD
- *
- * This method is only to be used by GUI Builder.
- */
- public static Color[] getJavaColor(int schemeNo){
- schemeNo = Math.abs(schemeNo) % 16;
- return palettes[schemeNo];
- }
-
-
- /**
- * DO NOT CALL THIS METHOD
- *
- * This method is only to be used by GUI Builder.
- */
- public static void makeColorSchemes() {
- // If the palettes have not been created then create them
- // otherwise do nothing
- if(palettes != null)
- return;
- // Load the image
- PImage image = new PImage((new javax.swing.ImageIcon(new GCScheme().getClass().getResource("/data/default_gui_palette.png"))).getImage());
- // Now make the palette
- palettes = new Color[16][16];
- for(int p = 0; p < 16; p++)
- for(int c = 0; c < 16; c++){
- int col = image.get(c * 16 + 8, p * 16 + 8);
- palettes[p][c] = new Color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
- }
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GCheckbox.java b/Processing/libraries/G4P/src/g4p_controls/GCheckbox.java
deleted file mode 100644
index 45c5f1c..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GCheckbox.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2008 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-
-/**
- * A two-state toggle control.
- *
- * GCheckbox objects (also known as tick boxes) are two-state toggle switches that are
- * used independently of other tick boxes.
- *
- * @author Peter Lager
- *
- */
-public class GCheckbox extends GToggleControl {
-
- /**
- * Create an option button without text.
- *
- * @param theApplet that will display the control
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GCheckbox(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, "");
- }
-
- /**
- * Create an option button with text.
- *
- * @param theApplet that will display the control
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param text text to be displayed
- */
- public GCheckbox(PApplet theApplet, float p0, float p1, float p2, float p3, String text) {
- super(theApplet, p0, p1, p2, p3);
- opaque = false;
- setText(text);
- setIcon("tick.png", 2, GAlign.LEFT, null);
- setTextAlign(GAlign.LEFT, null);
- z = Z_SLIPPY;
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleToggleControlEvents",
- new Class>[]{ GToggleControl.class, GEvent.class },
- new String[]{ "checkbox", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- /**
- * This enforces independent action because this control cannot be added
- * to a toggle group
- */
- @Override
- protected void setToggleGroup(GToggleGroup tg) {}
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GClip.java b/Processing/libraries/G4P/src/g4p_controls/GClip.java
deleted file mode 100644
index f5174d9..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GClip.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2008 Peter Lager
-
- The actual code to create the clipbaord, copy and paste were
- taken taken from a similar GUI library Interfascia ALPHA 002 --
- http://superstable.net/interfascia/ produced by Brenden Berg
- The main change is to provide static copy and paste methods to
- separate the clipboard logic from the component logic and provide
- global access.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.ClipboardOwner;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.StringSelection;
-import java.awt.datatransfer.Transferable;
-
-/*
- * I wanted to implement copying and pasting to the clipboard using static
- * methods to simplify the sharing of a single clipboard over all classes.
- * The need to implement the ClipboardOwner interface requires an object so
- * this class creates an object the first time an attempt to copy or paste
- * is used.
- *
- * All methods are private except copy() and paste() - lostOwnership()
- * has to be public because of the Clipboard owner interface.
- *
- * @author Peter Lager
- *
- */
-
-/**
- * Clipboard functionaliy for plain text
- *
- * This provides clipboard functionality for text and is currently only used by the
- * GTextField and GTextArea classes.
- *
- * @author Peter Lager
- *
- */
-public class GClip implements ClipboardOwner {
-
- /**
- * Static reference to enforce singleton pattern
- */
- private static GClip gclip = null;
-
- /**
- * Class attribute to reference the programs clipboard
- */
- private Clipboard clipboard = null;
-
-
- /**
- * Copy a string to the clipboard
- * @param chars
- */
- public static boolean copy(String chars){
- if(gclip == null)
- gclip = new GClip();
- return gclip.copyString(chars);
- }
-
- /**
- * Get a string from the clipboard
- * @return the string on the clipboard
- */
- public static String paste(){
- if(gclip == null)
- gclip = new GClip();
- return gclip.pasteString();
- }
-
- /**
- * Ctor is private so clipboard is only created when a copy or paste is
- * attempted and one does not exist already.
- */
- private GClip(){
- if(clipboard == null){
- makeClipboardObject();
- }
- }
-
- /**
- * If security permits use the system clipboard otherwise create
- * our own application clipboard.
- */
- private void makeClipboardObject(){
- SecurityManager security = System.getSecurityManager();
- if (security != null) {
- try {
- security.checkSystemClipboardAccess();
- clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- } catch (SecurityException e) {
- clipboard = new Clipboard("Application Clipboard");
- }
- } else {
- try {
- clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- } catch (Exception e) {
- // THIS IS DUMB - true but is there another way - I think not
- }
- }
- }
-
- /**
- * Copy a string to the clipboard. If the Clipboard has not been created
- * then create it.
- * @return true for a successful copy to clipboard
- */
- private boolean copyString(String chars){
- if(clipboard == null)
- makeClipboardObject();
- if(clipboard != null){
- StringSelection fieldContent = new StringSelection (chars);
- clipboard.setContents (fieldContent, this);
- return true;
- }
- return false;
- }
-
- /**
- * Gets a string from the clipboard. If there is no Clipboard
- * then create it.
- * @return if possible the string on the clipboard else an empty string
- */
- private String pasteString(){
- // If there is no clipboard then there is nothing to paste
- if(clipboard == null){
- makeClipboardObject();
- return "";
- }
- // We have a clipboard so get the string if we can
- Transferable clipboardContent = clipboard.getContents(this);
-
- if ((clipboardContent != null) &&
- (clipboardContent.isDataFlavorSupported(DataFlavor.stringFlavor))) {
- try {
- String tempString;
- tempString = (String) clipboardContent.getTransferData(DataFlavor.stringFlavor);
- return tempString;
- }
- catch (Exception e) {
- e.printStackTrace ();
- }
- }
- return "";
- }
-
- /**
- * Reqd by ClipboardOwner interface
- */
- public void lostOwnership(Clipboard clipboard, Transferable contents) {
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GConstants.java b/Processing/libraries/G4P/src/g4p_controls/GConstants.java
deleted file mode 100644
index 5953582..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GConstants.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- Part of the GUI for Processing library
- http://www.lagers.org.uk/g4p/index.html
- http://gui4processing.googlecode.com/svn/trunk/
-
- Copyright (c) 2008-09 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.font.TextAttribute;
-
-import javax.swing.JOptionPane;
-
-/**
- *
- * These constants can all be available to the Processor.
- *
- * @author Peter Lager
- *
- */
-public interface GConstants {
-
- int RED_SCHEME = 0;
- int GREEN_SCHEME = 1;
- int YELLOW_SCHEME = 2;
- int PURPLE_SCHEME = 3;
- int ORANGE_SCHEME = 4;
- int CYAN_SCHEME = 5;
- int BLUE_SCHEME = 6;
- int GOLD_SCHEME = 7;
- int SCHEME_8 = 8;
- int SCHEME_9 = 9;
- int SCHEME_10 = 10;
- int SCHEME_11 = 11;
- int SCHEME_12 = 12;
- int SCHEME_13 = 13;
- int SCHEME_14 = 14;
- int SCHEME_15 = 15;
-
- // Keyboard values not covered by Processing
- char HOME = java.awt.event.KeyEvent.VK_HOME;
- char END = java.awt.event.KeyEvent.VK_END;
-
-
- // Configuration constants
- // GRoundControl
- int CTRL_ANGULAR = 0x00000501;
- int CTRL_HORIZONTAL = 0x00000502;
- int CTRL_VERTICAL = 0x00000503;
-
- // GWindow
- int EXIT_APP = 0x00000f01;
- int CLOSE_WINDOW = 0x00000f02;
- int KEEP_OPEN = 0x00000f03;
-
- // ### GUI build constants ###
- int USER_COL_SCHEME = 0x00010102;
-
- // The min alpha level for a control to respond to mouse and keyboard
- int ALPHA_BLOCK = 128;
- // The min alpha before a pixel is considered for a hot spot
- int ALPHA_PICK = 48;
-
- // ### Scroll bar policy constants ###
- /** Do not create or display any scrollbars for the text control. */
- int SCROLLBARS_NONE = 0x0000;
- /** Create and display vertical scrollbar only. */
- int SCROLLBARS_VERTICAL_ONLY = 0x0001;
- /** Create and display horizontal scrollbar only. */
- int SCROLLBARS_HORIZONTAL_ONLY = 0x0002;
- /** Create and display both vertical and horizontal scrollbars. */
- int SCROLLBARS_BOTH = 0x0003;
- /** whether to hide when not required */
- int SCROLLBARS_AUTOHIDE = 0x1000;
-
- // Slider / numeric display types
- int INTEGER = 0;
- int DECIMAL = 1;
- int EXPONENT = 2;
-
- // Text orientation for sliders
- int ORIENT_LEFT = -1;
- int ORIENT_TRACK = 0;
- int ORIENT_RIGHT = 1;
-
- // Mouse wheel direction constants. FORWARD is default
- // Do not change these values as they are used directly
- int FORWARD = 1; // Default value
- int REVERSE = -1;
-
- // Stick mode
- int X4 = 1;
- int X8 = 2;
-
- // Modal dialog messages
- // Message types
- int PLAIN = JOptionPane.PLAIN_MESSAGE;
- int ERROR = JOptionPane.ERROR_MESSAGE;
- int INFO = JOptionPane.INFORMATION_MESSAGE;
- int WARNING = JOptionPane.WARNING_MESSAGE;
- int QUERY = JOptionPane.QUESTION_MESSAGE;
-
- // Option types
- int YES_NO = JOptionPane.YES_NO_OPTION;
- int YES_NO_CANCEL = JOptionPane.YES_NO_CANCEL_OPTION;
- int OK_CANCEL = JOptionPane.OK_CANCEL_OPTION;
-
- // Replies to option types
- int OK = JOptionPane.OK_OPTION;
- int YES = JOptionPane.YES_OPTION; // Has same int value as OK
- int NO = JOptionPane.NO_OPTION;
- int CANCEL = JOptionPane.CANCEL_OPTION;
- int CLOSED = JOptionPane.CLOSED_OPTION;
-
- // Attribute:- fontface Value Type:- String font family name e.g. "Times New Roman"
- TextAttribute FAMILY = TextAttribute.FAMILY;
-
- // Attribute:- font weight Value Type:- Float in range (0.5 to 2.75)
- TextAttribute WEIGHT = TextAttribute.WEIGHT;
- // Predefined constants for font weight
- Float WEIGHT_EXTRA_LIGHT = new Float(0.5f);
- Float WEIGHT_LIGHT = new Float(0.75f);
- Float WEIGHT_DEMILIGHT = new Float(0.875f);
- Float WEIGHT_REGULAR = new Float(1.0f);
- Float WEIGHT_SEMIBOLD = new Float(1.25f);
- Float WEIGHT_MEDIUM = new Float(1.5f);
- Float WEIGHT_DEMIBOLD = new Float(1.75f);
- Float WEIGHT_BOLD = new Float(2.0f);
- Float WEIGHT_HEAVY = new Float(2.25f);
- Float WEIGHT_EXTRABOLD = new Float(2.5f);
- Float WEIGHT_ULTRABOLD = new Float(2.75f);
-
- // Attribute:- font width Value Type:- Float in range (0.75 to 1.5)
- TextAttribute WIDTH = TextAttribute.WIDTH;
- // Predefined constants for font width
- Float WIDTH_CONDENSED = new Float(0.75f);
- Float WIDTH_SEMI_CONDENSED = new Float(0.875f);
- Float WIDTH_REGULAR = new Float(1.0f);
- Float WIDTH_SEMI_EXTENDED = new Float(1.25f);
- Float WIDTH_EXTENDED = new Float(1.5f);
-
- // Attribute:- font posture Value Type:- Float in range (0.0 to 0.20)
- TextAttribute POSTURE = TextAttribute.POSTURE;
- // Predefined constants for font posture (plain or italic)
- Float POSTURE_REGULAR = new Float(0.0f);
- Float POSTURE_OBLIQUE = new Float(0.20f);
-
- // Attribute:- font size Value Type:- Float
- TextAttribute SIZE = TextAttribute.SIZE;
-
- // Attribute:- font superscript Value Type:- Integer (1 : super or -1 subscript)
- TextAttribute SUPERSCRIPT = TextAttribute.SUPERSCRIPT;
- // Predefined constants for font super/subscript
- Integer SUPERSCRIPT_SUPER = new Integer(1);
- Integer SUPERSCRIPT_SUB = new Integer(-1);
- Integer SUPERSCRIPT_OFF = new Integer(0);
-
- // Attribute:- font foreground snd bsckground colour Value Type:- Color
- TextAttribute FOREGROUND = TextAttribute.FOREGROUND;
- TextAttribute BACKGROUND = TextAttribute.BACKGROUND;
-
- // Attribute:- font strike through Value:- Boolean
- TextAttribute STRIKETHROUGH = TextAttribute.STRIKETHROUGH;
- // Predefined constants for font strike through on/off
- Boolean STRIKETHROUGH_ON = new Boolean(true);
- Boolean STRIKETHROUGH_OFF = new Boolean(false);
-
- // TextAttribute JUSTIFICATION = TextAttribute.JUSTIFICATION;
- // Float JUSTIFICATION_FULL = new Float(1.0f);
- // Float JUSTIFICATION_NONE = new Float(0.0f);
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GConstantsInternal.java b/Processing/libraries/G4P/src/g4p_controls/GConstantsInternal.java
deleted file mode 100644
index 6e2fb91..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GConstantsInternal.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- Part of the GUI for Processing library
- http://www.lagers.org.uk/g4p/index.html
- http://gui4processing.googlecode.com/svn/trunk/
-
- Copyright (c) 2008-12 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.BasicStroke;
-
-/**
- * Constants that are used internally by the library.
- *
- * @author Peter Lager
- *
- */
-interface GConstantsInternal {
-
- // Constants for GCustomSlider styles
- String SLIDER_STYLES = "|grey_blue|blue18px|green_red20px|purple18px|red_yellow18px|";
- String DEFAULT_SLIDER_STYLE = "grey_blue";
-
- // Constants for the control methods
- int DRAW_METHOD = 0x00000001;
- int MOUSE_METHOD = 0x00000002;
- int PRE_METHOD = 0x00000004;
- int KEY_METHOD = 0x00000008;
- int POST_METHOD = 0x00000010;
- int ALL_METHOD = 0x0000001f;
- int GROUP_CONTROL_METHOD = DRAW_METHOD | MOUSE_METHOD | KEY_METHOD;
-
- // Event method handler errors
- int MISSING = 0xff000001; // Can't find standard handler
- int NONEXISTANT = 0xff000002;
- int INVALID_TYPE = 0xff000003;
- int INVALID_PAPPLET = 0xff000004;
- int EXCP_IN_HANDLER = 0xff000005; // Exception in event handler
-
- // Button/slider status values
- int OFF_CONTROL = 0;
- int OVER_CONTROL = 1;
- int PRESS_CONTROL = 2;
- int DRAG_CONTROL = 3;
-
- // The tint color used when controls are drawn with transparency
- int TINT_FOR_ALPHA = 255;
-
- // Constants for merging attribute runs
- int I_NONE = 0;
- int I_TL = 1;
- int I_TR = 2;
- int I_CL = 4;
- int I_CR = 8;
- int I_INSIDE = 16;
- int I_COVERED = 32;
- int I_MODES = 63;
-
- // Merger action
- int MERGE_RUNS = 256;
- int CLIP_RUN = 512;
- int COMBI_MODES = 768;
-
- // merger decision grid
- int[][] grid = new int[][] {
- { I_NONE, I_TL, I_CL, I_COVERED, I_COVERED },
- { I_NONE, I_NONE, I_INSIDE, I_INSIDE, I_COVERED },
- { I_NONE, I_NONE, I_INSIDE, I_INSIDE, I_CR },
- { I_NONE, I_NONE, I_NONE, I_NONE, I_TR },
- { I_NONE, I_NONE, I_NONE, I_NONE, I_NONE }
- };
-
- // Basic strokes needed when using the Graphics2D object for drawing on the buffer
- BasicStroke pen_1_0 = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
- BasicStroke pen_2_0 = new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
- BasicStroke pen_3_0 = new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
- BasicStroke pen_4_0 = new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
-
- // Padding for text controls
- int TPAD2 = 2;
- int TPAD6 = 6;
-
- int TPAD4 = 4;
- int TPAD8 = 8;
-
- // ### Scroll bar type constants ###
- int SCROLLBAR_VERTICAL = GConstants.SCROLLBARS_VERTICAL_ONLY; // 1
- int SCROLLBAR_HORIZONTAL = GConstants.SCROLLBARS_HORIZONTAL_ONLY; // 2
-
- float HORZ_SCROLL_RATE = 4;
- float VERT_SCROLL_RATE = 8;
-
- float WHEEL_DELTA = 0.01f;
- float WHEEL_STICK_FACTOR = 0.51f;
-
- char EOL = '\n';
-
- // Z order used to control transfer of focus between controls
- int Z_STICKY = 0; // Components that don't release focus automatically i.e. GTextField
- int Z_SLIPPY = 24; // Components that automatically releases focus when appropriate e.g. GButton
- int Z_SLIPPY_EXPANDS = 48; // Components that expand e.g. GDropList
- int Z_PANEL = 1024; // Increment to be used if on a GPanel
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GControlMode.java b/Processing/libraries/G4P/src/g4p_controls/GControlMode.java
deleted file mode 100644
index be17253..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GControlMode.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-package g4p_controls;
-
-import processing.core.PApplet;
-import processing.core.PConstants;
-
-public enum GControlMode implements PConstants{
-
- CORNER ( "X Y W H coordinates", "CORNER", PApplet.CORNER ),
- CORNERS ( "X0 Y0 X1 Y1 coordinates", "CORNERS", PApplet.CORNERS ),
- CENTER ( "X Y W H coordinates", "CENTER", PApplet.CENTER );
-
-
- public final String description;
- public final String ps_name;
- public final int mode;
-
- private GControlMode(String desc, String name, int ctrl_mode ){
- description = desc;
- ps_name = name;
- mode = ctrl_mode;
- }
-
- public String toString(){
- return description;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GCustomSlider.java b/Processing/libraries/G4P/src/g4p_controls/GCustomSlider.java
deleted file mode 100644
index ced449d..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GCustomSlider.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSalpha;
-import g4p_controls.HotSpot.HSrect;
-
-import java.awt.Graphics2D;
-import java.io.File;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-import processing.core.PImage;
-
-/**
- * Slider that can be customised with user provided graphics.
- *
- * This class replaces the GWSlider provided in pre v3 editions of this library.
- *
- * The main difference to the GSlider class is the ability to skin the slider with user provided graphics.
- * The library provides a number of skins ready for use. You specify the skin to use when the slider is created
- * and if the library is unable to load the skin it will print a warning and load the default skin instead.
- *
Library skins available
- *
- *
grey_blue (default skin)
- *
green_red20px
- *
red_yellow18px
- *
blue18px
- *
purple18px
- *
- * A skin requires 5 image files for different parts of the slider which must be stored in their own
- * folder (the folder name is also used as the skin name) and this folder should be place inside the
- * sketch's data folder.
- *
The image files have specific names.
- *
- *
Left end cap of the slider(end_left.???)
- *
Right end cap of the slider(end_right.???)
- *
An extendible centre segment(centre.???)
- *
Draggable thumb (handle.??? and handle_mouseover.???)
- *
- * Where ??? is the image type file extension. The image type can be any that Processing can handle, the
- * most common types will be png, jpg or gif but tga is also permitted
- *
- *
There are very few restrictions about the images you use but when designing the images you should consider
- * the following facts:
- *
- *
the slider will be created to fit the control size (specified in the constructor)
- *
the horizontal space allocated for the end-caps will be the same for each end (uses the width or the larger end cap image)
- *
the track width will be the height of the centre image
- *
the centre image will be tiled along the track length
- *
the track will be placed in the horizontal and vertical centre of the control.
- *
the end cap images will be placed in the vertical centre of the control and butted against the track.
- *
- *
- *
- * @author Peter Lager
- *
- */
-public class GCustomSlider extends GLinearTrackControl {
-
- protected PImage leftEnd;
- protected PImage thumb;
- protected PImage thumb_mouseover;
- protected PImage rightEnd;
- protected PImage centre;
-
- /**
- * Create a custom slider using the default skin.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GCustomSlider(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, null);
- }
-
- /**
- * Create a custom slider using the skin specified.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param skin the name of the skin (this is also the name of the folder holding the images)
- */
- public GCustomSlider(PApplet theApplet, float p0, float p1, float p2, float p3, String skin) {
- super(theApplet, p0, p1, p2, p3);
- skin = (skin == null) ? "grey_blue" : skin.trim();
- setStyle(skin);
-
- // Customise buffer for this control
- buffer.imageMode(PApplet.CENTER);
-
- hotspots = new HotSpot[]{
- new HSalpha(THUMB_SPOT, width/2 + (parametricPos - 0.5f) * trackLength, height/2, thumb, PApplet.CENTER), // thumb
- new HSrect(TRACK_SPOT, (width-trackLength)/2, (height-trackWidth)/2, trackLength, trackWidth), // track
- };
- opaque = false;
- z = Z_SLIPPY;
-
- epsilon = 0.98f / trackLength;
- ssStartLimit = new StyledString("0.00");
- ssEndLimit = new StyledString("1.00");
- ssValue = new StyledString("0.50");
-
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleSliderEvents",
- new Class>[]{ GValueControl.class, GEvent.class },
- new String[]{ "slider", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- /**
- * Change the skin used for the slider.
- * @param skin the name of the folder holding the graphics for this slider
- */
- public void setStyle(String skin){
- loadSkin(skin);
- float maxEndLength = Math.max(leftEnd.width, rightEnd.width);
- maxEndLength = Math.max(maxEndLength, 10); // make sure we have enough to show limits value
- trackLength = Math.round(width - 2 * maxEndLength - TINSET);
- trackDisplayLength = trackLength + 2 * Math.min(leftEnd.width, rightEnd.width);
- trackWidth = centre.height;
- trackOffset = calcTrackOffset();
- extendCentreImage();
- bufferInvalid = true;
- }
-
- /**
- * Calculates the amount of offset for the labels
- */
- protected float calcTrackOffset(){
- float adjustedTrackOffset = (showTicks) ? trackWidth: trackWidth/2;
- adjustedTrackOffset = Math.max(adjustedTrackOffset, thumb.height/2) + 2;
- if(adjustedTrackOffset != trackOffset){
- bufferInvalid = true;
- }
- return adjustedTrackOffset;
- }
-
-
- protected void updateDueToValueChanging(){
- hotspots[0].x = (width/2 + (parametricPos - 0.5f) * trackLength);
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
-
- // Back ground colour
- buffer.background(opaque ? palette[6].getRGB() : palette[2].getRGB() & 0xFFFFFF);
- // Draw track, thumb, ticks etc.
- buffer.pushMatrix();
- buffer.translate(width/2, height/2);
- // draw ticks
- if(showTicks){
- float delta = 1.0f / (nbrTicks - 1);
- for(int i = 0; i < nbrTicks; i++){
- float tickx = Math.round((i * delta - 0.5f) * trackLength);
- buffer.strokeWeight(2);
- buffer.stroke(255);
- buffer.line(tickx+1, -trackWidth, tickx+1, trackWidth);
- buffer.strokeWeight(1.0f);
- buffer.stroke(0);
- buffer.line(tickx, -trackWidth, tickx, trackWidth);
- }
- }
- buffer.image(centre,0,0);
- buffer.image(leftEnd, -(trackLength + leftEnd.width)/2, 0);
- buffer.image(rightEnd, (trackLength + rightEnd.width)/2, 0);
- switch(status){
- case OFF_CONTROL:
- buffer.image(thumb,(parametricPos - 0.5f) * trackLength, 0);
- break;
- case OVER_CONTROL:
- case PRESS_CONTROL:
- case DRAG_CONTROL:
- buffer.image(thumb_mouseover,(parametricPos - 0.5f) * trackLength, 0);
- break;
- }
- // Display slider values
- g2d.setColor(palette[2]);
- if(labels != null){
- drawLabels(g2d);
- }
- else {
-
- if(showLimits)
- drawLimits(g2d);
- if(showValue)
- drawValue(g2d);
- }
- buffer.popMatrix();
- buffer.endDraw();
- }
- }
-
- private void extendCentreImage(){
- int tl = (int)trackLength;
- PGraphics pg = winApp.createGraphics(tl, centre.height, JAVA2D);
- int rem = tl % centre.width;
- int n = tl / centre.width;
- n = (rem == 0) ? n : n + 1;
- int px = (tl - centre.width * n)/2;
- pg.beginDraw();
- pg.background(winApp.color(255,0));
- pg.imageMode(CORNER);
-
- while(px < tl){
- pg.image(centre, px, 0);
- px += centre.width;
- }
-
- pg.endDraw();
- centre = pg;
- }
-
- /**
- * Load a skin
- * @param style
- */
- private void loadSkin(String style){
- // Remember the skin we want to use
- String style_used = style;
- boolean found = false;
- // First check for user defined skin
- // See if we are running in a browser or running locally
- if(winApp.sketchPath("").length() == 0)
- found = loadSkin_AppletInBrowser(style); // browser
- else
- found = loadStyle_FromSketch(style); // local
- // If not found load it from the library
- if(!found)
- style_used = loadStyle_FromG4P(style);
- // See if we have had to use a different skin. If true then
- // the original skin could not be found so say so
- if(!style.equalsIgnoreCase(style_used))
- System.out.println("Unable to load the skin " + style + " using default '" + DEFAULT_SLIDER_STYLE + "' style instead");
- }
-
- /**
- * If no user defined skin has been specified then load a style from the G4P library.
- * If the style does not exist it will use the default style.
- * @param style
- */
- private String loadStyle_FromG4P(String style) {
- boolean found = (SLIDER_STYLES.indexOf("|"+style+"|") >= 0);
- // If not found use the default grey_blue
- if(!found)
- style = DEFAULT_SLIDER_STYLE;
-
- // All the library styles use png graphics
- leftEnd = winApp.loadImage(style + "/end_left.png");
- rightEnd = winApp.loadImage(style + "/end_right.png");
- thumb = winApp.loadImage(style +"/handle.png");
- thumb_mouseover = winApp.loadImage(style +"/handle_mouseover.png");
- // will be stretched before use
- centre = winApp.loadImage(style + "/centre.png");
-
- return style;
- }
-
- /**
- * Load a skin when run as an application or run locally.
- *
- * @param styleFolder
- * @param style
- * @return true if the style loaded successfully
- */
- private boolean loadStyle_FromSketch(String style) {
- // First attempt to locate the style inside the sketch or sketch data folders
- File styleFolder = new File(winApp.dataPath(style));
- if(!styleFolder.exists())
- styleFolder = new File(winApp.sketchPath(style));
- // If the style is in the sketch then attempt to load the style
- // and if successful we are done
- if(!styleFolder.exists())
- return false;
-
- int fcount = 0;
- String[] names = new String[] { "centre.", "end_left.", "end_right.", "handle.", "handle_mouseover." };
- PImage[] images = new PImage[names.length];
- File[] fileList = styleFolder.listFiles();
- for(int i = 0; i < names.length; i++){
- for(File f : fileList){
- String filename = f.getName();
- if(filename.startsWith(names[i])){
- images[i] = winApp.loadImage(style + "/" + filename);
- fcount ++;
- }
- }
- }
- if(fcount != names.length)
- return false;
-
- centre = images[0];
- leftEnd = images[1];
- rightEnd = images[2];
- thumb = images[3];
- thumb_mouseover = images[4];
- return true;
- }
-
- /**
- * Load a skin when run as an applet inside a browser.
- *
- * Note: sketchPath() is null when inside a browswer.
- *
- * @param style
- * @return true if the style loaded successfully
- */
- private boolean loadSkin_AppletInBrowser(String style){
- leftEnd = winApp.loadImage(style + "/end_left.png");
- if(leftEnd == null)
- leftEnd = winApp.loadImage(style + "/end_left.jpg");
- rightEnd = winApp.loadImage(style + "/end_right.png");
- if(rightEnd == null)
- rightEnd = winApp.loadImage(style + "/end_right.jpg");
- thumb = winApp.loadImage(style +"/handle.png");
- if(thumb == null)
- thumb = winApp.loadImage(style +"/handle.jpg");
- thumb_mouseover = winApp.loadImage(style +"/handle_mouseover.png");
- if(thumb_mouseover == null)
- thumb_mouseover = winApp.loadImage(style +"/handle_mouseover.jpg");
- // will be stretched before use
- centre = winApp.loadImage(style + "/centre.png");
- if(centre == null)
- centre = winApp.loadImage(style + "/centre.jpg");
-
- boolean found = !(leftEnd == null || rightEnd == null || thumb == null || thumb_mouseover == null || centre == null);
-
- // See if we have problems with the skin files
- if(!found){
- System.out.println("Unable to load the skin " + style + " check the ");
- System.out.println("skin name used and ensure all the image files are present.");
- System.out.println("Reverting to default 'grey_blue' style");
- loadSkin("grey_blue");
- }
- return found;
- }
-
-
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GDropList.java b/Processing/libraries/G4P/src/g4p_controls/GDropList.java
deleted file mode 100644
index e2da9c2..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GDropList.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-
-import java.awt.Graphics2D;
-import java.awt.font.TextLayout;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-import processing.event.MouseEvent;
-
-/**
- * A drop down list component.
- *
- * This replaces the GCombo control in pre V3 editions of this library.
- *
- * The number of items in the list is not restricted but the user can define
- * the maximum number of items to be displayed in the drop list. If there are
- * too many items to display a vertical scroll bar is provide to scroll through
- * all the items.
- *
- * The vertical size of an individual item is calculated from the overall height
- * specified when creating the control.
- *
- * @author Peter Lager
- *
- */
-public class GDropList extends GTextBase {
-
- static protected int LIST_SURFACE = 1;
- static protected int CLOSED_SURFACE = 2;
-
- protected static final int FORE_COLOR = 2;
- protected static final int BACK_COLOR = 5;
- protected static final int ITEM_FORE_COLOR = 3;
- protected static final int ITEM_BACK_COLOR = 6;
- protected static final int OVER_ITEM_FORE_COLOR = 15;
-
-
- private GScrollbar vsb;
- private GButton showList;
-
- protected LinkedList itemlist = new LinkedList();
- protected StyledString[] sitems;
- protected StyledString selText;
-
- protected int selItem = 0;
- protected int startItem = 0;
- protected int lastOverItem = -1;
- protected int currOverItem = lastOverItem;
-
-
- protected int dropListMaxSize = 4;
- protected int dropListActualSize = 4;
-
- protected float itemHeight, buttonWidth;
-
- protected boolean expanded = false; // make false in release version
-
- /**
- * Create a drop down list component with a list size of 4.
- *
- * After creating the control use setItems to initialise the list.
- *
- * @param theApplet the applet that will display this component.
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GDropList(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, 4);
- }
-
- /**
- * Create a drop down list component with a specified list size.
- *
- * After creating the control use setItems to initialise the list.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param dropListMaxSize the maximum number of element to appear in the drop down list
- */
- public GDropList(PApplet theApplet, float p0, float p1, float p2, float p3, int dropListMaxSize) {
- super(theApplet, p0, p1, p2, p3);
- children = new LinkedList();
- this.dropListMaxSize = Math.max(dropListMaxSize, 3);
- itemHeight = height / (dropListMaxSize + 1); // make allowance for selected text at top
-
- G4P.pushStyle();
- G4P.showMessages = false;
-
- vsb = new GScrollbar(theApplet, 0, 0, height - itemHeight-2, 10);
- vsb.addEventHandler(this, "vsbEventHandler");
- vsb.setAutoHide(true);
- vsb.setVisible(false);
-
- buttonWidth = 10;
- showList = new GButton(theApplet, 0, 0, buttonWidth, itemHeight, ":");
- showList.addEventHandler(this, "buttonShowListHandler");
-
- // Do this before we add the button and scrollbar
- z = Z_SLIPPY_EXPANDS;
-
- // Add the button and scrollbar
- G4P.control_mode = GControlMode.CORNER;
- addControl(vsb, width, itemHeight + 1, PI/2);
- addControl(showList, width - buttonWidth, 0, 0);
-
- G4P.popStyle();
-
- hotspots = new HotSpot[]{
- new HSrect(LIST_SURFACE, 0, itemHeight+1, width - 11, height - itemHeight - 1), // text list area
- new HSrect(CLOSED_SURFACE, 0, 0, width - buttonWidth, itemHeight) // selected text display area
- };
-
- createEventHandler(G4P.sketchWindow, "handleDropListEvents",
- new Class>[]{ GDropList.class, GEvent.class },
- new String[]{ "list", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- /**
- * Use this to set or change the list of items to appear in the list. If
- * you enter an invalid selection index then it is forced into
- * the valid range.
- * Null and empty values in the list will be ignored.
- * If the list is null then or empty then then no changes are made.
- * @param array
- * @param selected
- */
- public void setItems(String[] array, int selected){
- if(array == null)
- return;
- // Get rid of null or empty strings
- ArrayList strings = new ArrayList();
- for(String s : array)
- strings.add(s);
- if(cleanupList(strings))
- setItemsImpl(selected);
- }
-
- public void setItems(List list, int selected){
- if(list == null)
- return;
- if(cleanupList(list))
- setItemsImpl(selected);
- }
-
- private boolean cleanupList(List list){
- // Get rid of null or empty strings
- Iterator iter = list.iterator();
- while(iter.hasNext()){
- String s = iter.next();
- if(s == null || s.length() == 0)
- iter.remove();
- }
- if(list.size() > 0){
- // We have at least one item for the droplist
- itemlist.clear();
- itemlist.addAll(list);
- return true;
- }
- return false;
- }
-
- private void setItemsImpl(int selected){
- sitems = new StyledString[itemlist.size()];
- // Create styled strings for display
- for(int i = 0; i < sitems.length; i++)
- sitems[i] = new StyledString(itemlist.get(i));
- // Force selected value into valid range
- selItem = PApplet.constrain(selected, 0, sitems.length - 1);
- startItem = (selItem >= dropListMaxSize) ? selItem - dropListMaxSize + 1 : 0;
- // Make selected item bold
- sitems[selItem].addAttribute(WEIGHT, WEIGHT_BOLD);
- // Create separate styled string for display area
- selText = new StyledString(sitems[selItem].getPlainText());
- dropListActualSize = Math.min(sitems.length, dropListMaxSize);
- if((sitems.length > dropListActualSize)){
- float filler = ((float)dropListMaxSize)/sitems.length;
- float value = ((float)startItem)/sitems.length;
- vsb.setValue(value, filler);
- vsb.setVisible(false); // make it false
- }
- bufferInvalid = true;
- }
-
- /**
- * Remove an item from the list.
- * If idx is not a valid position in the list then the list is unchanged.
- * If idx points to the selected item or an item below it then the
- * selected index value is reduced by 1 but the selected text remains the
- * same.
- * If idx points to an item above the selected item then the selected
- * item is unchanged.
- * No event is fired even if the selected index changes.
- *
- * @param idx index of the item to remove
- * @return true if item is successfully removed else false
- */
- public boolean removeItem(int idx){
- if(itemlist.size() <= 1 || idx < 0 || idx >= itemlist.size() )
- return false;
- int sel = (idx > selItem) ? selItem : selItem - 1;
- itemlist.remove(idx);
- setItemsImpl(sel);
- return true;
- }
-
- /**
- * Insert an item at the specified position in the list.
- * If idx is <0 then the list is unchanged.
- * If idx is >= the number of items in the list, it is added to the end.
- * If idx points to the selected item or an item below it then the
- * selected index value is incremented by 1 but the selected text remains
- * the same.
- * If idx points to an item above the selected item then the selected
- * item is unchanged.
- * No event is fired even if the selected index changes.
- *
- * @param idx index of the item to remove
- * @param name text of the item to insert (null values ignored)
- * @return true if item is successfully inserted else false
- */
-
- public boolean insertItem(int idx, String name){
- if(idx < 0 || name == null || name.length() > 0)
- return false;
- if(idx >= itemlist.size()){
- itemlist.addLast(name);
- }
- else {
- itemlist.add(idx, name);
- }
- int sel = (idx <= selItem) ? selItem + 1: selItem;
- setItemsImpl(sel);
- return true;
- }
-
- /**
- * Add an item to the end of the list.
- * No event is fired.
- *
- * @param name text of the item to add (null values ignored)
- * @return true if add is successfully added else false
- */
- public boolean addItem(String name){
- if(name == null)
- return false;
- itemlist.addLast(name);
- return true;
- }
-
- /**
- * Set the currently selected item from the droplist by index position.
- * Invalid values are ignored.
- *
- * @param selected
- */
- public void setSelected(int selected){
- if(selected >=0 && selected < sitems.length){
- selItem = selected;
- startItem = (selItem >= dropListMaxSize) ? selItem - dropListMaxSize + 1 : 0;
- for(StyledString s : sitems)
- s.clearAttributes();
- sitems[selItem].addAttribute(WEIGHT, WEIGHT_BOLD);
- selText = new StyledString(sitems[selItem].getPlainText());
- bufferInvalid = true;
- }
- }
-
- /**
- * Get the index position of the selected item
- */
- public int getSelectedIndex(){
- return selItem;
- }
-
- /**
- * Get the text for the selected item
- */
- public String getSelectedText(){
- return sitems[selItem].getPlainText();
- }
-
- /**
- * Sets the local colour scheme for this control
- */
- public void setLocalColorScheme(int cs){
- super.setLocalColorScheme(cs);
- if(showList != null)
- showList.setLocalColorScheme(localColorScheme);
- if(vsb != null)
- vsb.setLocalColorScheme(localColorScheme);
- }
-
- /**
- * Determines if a particular pixel position is over this control taking
- * into account whether it is collapsed or not.
- */
- public boolean isOver(float x, float y){
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- return (!expanded)? currSpot == CLOSED_SURFACE : currSpot == CLOSED_SURFACE | currSpot == LIST_SURFACE;
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
-
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.CLICK:
- // No need to test for isOver() since if the component has focus
- // and the mouse has not moved since MOUSE_PRESSED otherwise we
- // would not get the Java MouseEvent.MOUSE_CLICKED event
- if(focusIsWith == this ){
- loseFocus(null);
- vsb.setVisible(false);
- expanded = false;
- bufferInvalid = true;
- // Make sure that we have selected a valid item and that
- // it is not the same as before;
- if(currOverItem >= 0 && currOverItem != selItem){
- setSelected(currOverItem);
- fireEvent(this, GEvent.SELECTED);
- }
- currOverItem = lastOverItem = -1;
- }
- break;
- case MouseEvent.MOVE:
- if(focusIsWith == this){
- if(currSpot == LIST_SURFACE)
- currOverItem = startItem + (int)(oy / itemHeight)-1;
- //currOverItem = startItem + Math.round(oy / itemHeight) - 1;
- else
- currOverItem = -1;
- // Only invalidate the buffer if the over item has changed
- if(currOverItem != lastOverItem){
- lastOverItem = currOverItem;
- bufferInvalid = true;
- }
- }
- break;
- }
- }
-
- public void draw(){
- if(!visible) return;
- updateBuffer();
-
- winApp.pushStyle();
- winApp.pushMatrix();
-
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
-
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
-
- winApp.popMatrix();
-
- if(children != null){
- for(GAbstractControl c : children)
- c.draw();
- }
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- public PGraphics getSnapshot(){
- updateBuffer();
- PGraphics snap = winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
- snap.beginDraw();
- snap.image(buffer,0,0);
- snap.pushMatrix();
- // showList
- snap.image(showList.getBuffer(), width - showList.getWidth() - 1, 1);
- snap.translate(width, itemHeight + 1);
- snap.rotate(PApplet.PI/2);
- snap.image(vsb.getBuffer(), 0, 0);
- snap.popMatrix();
- snap.endDraw();
- return snap;
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
-
- buffer.clear();
- buffer.noStroke();
- buffer.fill(palette[BACK_COLOR].getRGB());
- buffer.rect(0, 0, width, itemHeight);
-
- if(expanded){
- buffer.fill(palette[ITEM_BACK_COLOR].getRGB());
- buffer.rect(0,itemHeight, width, itemHeight * dropListActualSize);
- }
-
- float px = TPAD2, py;
- TextLayout line;
- // Get selected text for display
- line = selText.getLines(g2d).getFirst().layout;
- py = (itemHeight + line.getAscent() - line.getDescent())/2;
-
- g2d.setColor(palette[FORE_COLOR]);
- line.draw(g2d, px, py);
-
- if(expanded){
- // g2d.setColor(palette[ITEM_FORE_COLOR]); // REDUNDANT CODE ????
- for(int i = 0; i < dropListActualSize; i++){
- py += itemHeight;
- if(currOverItem == startItem + i)
- g2d.setColor(palette[OVER_ITEM_FORE_COLOR]);
- else
- g2d.setColor(palette[ITEM_FORE_COLOR]);
-
- line = sitems[startItem + i].getLines(g2d).getFirst().layout;
- line.draw(g2d, px, py);
- }
- }
- buffer.endDraw();
- }
- }
-
- /**
- * For most components there is nothing to do when they loose focus.
- * Override this method in classes that need to do something when
- * they loose focus eg TextField
- */
- protected void loseFocus(GAbstractControl grabber){
- if(grabber != vsb){
- expanded = false;
- vsb.setVisible(false);
- bufferInvalid = true;
- }
- if(cursorIsOver == this)
- cursorIsOver = null;
- focusIsWith = grabber;
- }
-
-
- /**
- * This method should not be called by the user. It
- * is for internal library use only.
- */
- public void vsbEventHandler(GScrollbar scrollbar, GEvent event){
- int newStartItem = Math.round(vsb.getValue() * sitems.length);
- startItem = newStartItem;
- bufferInvalid = true;
- }
-
- /**
- * This method should not be called by the user. It
- * is for internal library use only.
- */
- public void buttonShowListHandler(GButton button, GEvent event){
- if(expanded){
- loseFocus(null);
- vsb.setVisible(false);
- expanded = false;
- }
- else {
- takeFocus();
- vsb.setVisible(sitems.length > dropListActualSize);
- expanded = true;
- }
- bufferInvalid = true;
- }
-
-}
\ No newline at end of file
diff --git a/Processing/libraries/G4P/src/g4p_controls/GEditableTextControl.java b/Processing/libraries/G4P/src/g4p_controls/GEditableTextControl.java
deleted file mode 100644
index 2b1c399..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GEditableTextControl.java
+++ /dev/null
@@ -1,723 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2013 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.StyledString.TextLayoutHitInfo;
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Font;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextHitInfo;
-import java.awt.geom.GeneralPath;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.event.KeyEvent;
-
-/**
- *
- * This class is the basis for the GTextField and GTextArea classes.
- *
- * @author Peter Lager
- *
- */
-public abstract class GEditableTextControl extends GTextBase implements Focusable {
-
- GTabManager tabManager = null;
-
- protected StyledString promptText = null;
- // The width to break a line
- protected int wrapWidth = Integer.MAX_VALUE;
-
- // The typing area
- protected float tx,ty,th,tw;
- // Offset to display area
- protected float ptx, pty;
- // Caret position
- protected float caretX, caretY;
-
- protected boolean keepCursorInView = false;
-
- protected GeneralPath gpTextDisplayArea;
-
- // Used for identifying selection and cursor position
- protected TextLayoutHitInfo startTLHI = new TextLayoutHitInfo();
- protected TextLayoutHitInfo endTLHI = new TextLayoutHitInfo();
-
- // The scrollbars available
- protected final int scrollbarPolicy;
- protected boolean autoHide = false;
- protected GScrollbar hsb, vsb;
-
- protected GTimer caretFlasher;
- protected boolean showCaret = false;
-
- // Stuff to manage text selections
- protected int endChar = -1, startChar = -1, pos = endChar, nbr = 0, adjust = 0;
- protected boolean textChanged = false, selectionChanged = false;
-
- /* Is the component enabled to generate mouse and keyboard events */
- boolean textEditEnabled = true;
-
- public GEditableTextControl(PApplet theApplet, float p0, float p1, float p2, float p3, int scrollbars) {
- super(theApplet, p0, p1, p2, p3);
- scrollbarPolicy = scrollbars;
- autoHide = ((scrollbars & SCROLLBARS_AUTOHIDE) == SCROLLBARS_AUTOHIDE);
- caretFlasher = new GTimer(theApplet, this, "flashCaret", 400);
- caretFlasher.start();
- opaque = true;
- cursorOver = TEXT;
- }
-
- public void setTabManager(GTabManager tm){
- tabManager = tm;
- }
-
- /**
- * Give up focus but if the text is only made from spaces
- * then set it to null text.
- * Fire focus events for the GTextField and GTextArea controls
- */
- protected void loseFocus(GAbstractControl grabber){
- // If this control has focus then Fire a lost focus event
- if(focusIsWith == this)
- fireEvent(this, GEvent.LOST_FOCUS);
- // Process mouse-over cursor
- if(cursorIsOver == this)
- cursorIsOver = null;
- focusIsWith = grabber;
- // If only blank text clear it out allowing default text (if any) to be displayed
-// if(stext.length() > 0){
-// int tl = stext.getPlainText().trim().length();
-// if(tl == 0)
-// stext.setText("", wrapWidth);
-// }
- keepCursorInView = true;
- bufferInvalid = true;
- }
-
- /**
- * Give the focus to this component but only after allowing the
- * current component with focus to release it gracefully.
- * Always cancel the keyFocusIsWith irrespective of the component
- * type.
- * Fire focus events for the GTextField and GTextArea controls
- */
- protected void takeFocus(){
- // If focus is not yet with this control fire a gets focus event
- if(focusIsWith != this){
- // If the focus is with another control then tell
- // that control to lose focus
- if(focusIsWith != null)
- focusIsWith.loseFocus(this);
- fireEvent(this, GEvent.GETS_FOCUS);
- }
- focusIsWith = this;
- }
-
- /**
- * Determines whether this component is to have focus or not.
- */
- public void setFocus(boolean focus){
- if(!focus){
- loseFocus(null);
- return;
- }
- // Make sure we have some text
- if(focusIsWith != this){
- dragging = false;
- if(stext == null || stext.length() == 0)
- stext.setText(" ", wrapWidth);
- LinkedList lines = stext.getLines(buffer.g2);
- startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-
- endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
- int lastChar = endTLHI.tli.layout.getCharacterCount();
- endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
-
- calculateCaretPos(endTLHI);
- bufferInvalid = true;
- }
- keepCursorInView = true;
- takeFocus();
- }
-
- /**
- * Set the prompt text for this control. When the text control is empty
- * the prompt text (italic) is displayed instead.
- * .
- * @param ptext prompt text
- */
- public void setPromptText(String ptext){
- if(ptext == null || ptext.length() == 0)
- promptText = null;
- else {
- promptText = new StyledString(ptext, wrapWidth);
- promptText.addAttribute(G4P.POSTURE, G4P.POSTURE_OBLIQUE);
- }
- bufferInvalid = true;
- }
-
- /**
- * @return the wrapWidth
- */
- public int getWrapWidth() {
- return wrapWidth;
- }
-
- /**
- * @param wrapWidth the wrapWidth to set
- */
- public void setWrapWidth(int wrapWidth) {
- this.wrapWidth = wrapWidth;
- }
-
- /**
- * Get the prompt text used in this control.
- * @return the prompt text without styling
- */
- public String getPromptText(){
- return promptText.getPlainText();
- }
-
- /**
- * Get the text in the control
- * @return the text without styling
- */
- public String getText(){
- return stext.getPlainText();
- }
-
- /**
- * Get the styled text in the control
- * @return the text with styling
- */
- public StyledString getStyledText(){
- return stext;
- }
-
- /**
- * Adds the text attribute to a range of characters on a particular line. If charEnd
- * is past the EOL then the attribute will be applied to the end-of-line.
- *
- * @param attr the text attribute to add
- * @param value value of the text attribute
- * @param charStart the position of the first character to apply the attribute
- * @param charEnd the position after the last character to apply the attribute
- */
- public void addStyle(TextAttribute attr, Object value, int charStart, int charEnd){
- if(stext != null){
- stext.addAttribute(attr, value, charStart, charEnd);
- bufferInvalid = true;
- }
- }
-
- /**
- * Adds the text attribute to a range of characters on a particular line. If charEnd
- * is past the EOL then the attribute will be applied to the end-of-line.
- *
- * @param attr the text attribute to add
- * @param value value of the text attribute
- */
- public void addStyle(TextAttribute attr, Object value){
- if(stext != null){
- stext.addAttribute(attr, value);
- bufferInvalid = true;
- }
- }
-
- /**
- * Clears all text attribute from a range of characters starting at position
- * charStart and ending with the character preceding charEnd.
- *
- *
- * @param charStart the position of the first character to apply the attribute
- * @param charEnd the position after the last character to apply the attribute
- */
- public void clearStyles(int charStart, int charEnd){
- if(stext != null) {
- stext.clearAttributes(charStart, charEnd);
- bufferInvalid = true;
- }
- }
-
- /**
- * Clear all styles from the entire text.
- */
- public void clearStyles(){
- if(stext != null){
- stext.clearAttributes();
- bufferInvalid = true;
- }
- }
-
- /**
- * Set the font for this control.
- * @param font
- */
- public void setFont(Font font) {
- if(font != null && font != localFont && buffer != null){
- localFont = font;
- ptx = pty = 0;
- setScrollbarValues(ptx, pty);
- bufferInvalid = true;
- }
- }
-
- // SELECTED / HIGHLIGHTED TEXT
-
- /**
- * Get the text that has been selected (highlighted) by the user.
- * @return the selected text without styling
- */
- public String getSelectedText(){
- if(!hasSelection())
- return "";
- TextLayoutHitInfo startSelTLHI;
- TextLayoutHitInfo endSelTLHI;
- if(endTLHI.compareTo(startTLHI) == -1){
- startSelTLHI = endTLHI;
- endSelTLHI = startTLHI;
- }
- else {
- startSelTLHI = startTLHI;
- endSelTLHI = endTLHI;
- }
- int ss = startSelTLHI.tli.startCharIndex + startSelTLHI.thi.getInsertionIndex();
- int ee = endSelTLHI.tli.startCharIndex + endSelTLHI.thi.getInsertionIndex();
- String s = stext.getPlainText().substring(ss, ee);
- return s;
- }
-
- /**
- * If some text has been selected then set the style. If there is no selection then
- * the text is unchanged.
- *
- *
- * @param style
- */
- public void setSelectedTextStyle(TextAttribute style, Object value){
- if(!hasSelection())
- return;
- TextLayoutHitInfo startSelTLHI;
- TextLayoutHitInfo endSelTLHI;
- if(endTLHI.compareTo(startTLHI) == -1){
- startSelTLHI = endTLHI;
- endSelTLHI = startTLHI;
- }
- else {
- startSelTLHI = startTLHI;
- endSelTLHI = endTLHI;
- }
- int ss = startSelTLHI.tli.startCharIndex + startSelTLHI.thi.getInsertionIndex();
- int ee = endSelTLHI.tli.startCharIndex + endSelTLHI.thi.getInsertionIndex();
- stext.addAttribute(style, value, ss, ee);
-
- // We have modified the text style so the end of the selection may have
- // moved, so it needs to be recalculated. The start will be unaffected.
- stext.getLines(buffer.g2);
- endSelTLHI.tli = stext.getTLIforCharNo(ee);
- int cn = ee - endSelTLHI.tli.startCharIndex;
- if(cn == 0) // start of line
- endSelTLHI.thi = endSelTLHI.tli.layout.getNextLeftHit(1);
- else
- endSelTLHI.thi = endSelTLHI.tli.layout.getNextRightHit(cn-1);
- bufferInvalid = true;
- }
-
- /**
- * Clear any styles applied to the selected text.
- */
- public void clearSelectionStyle(){
- if(!hasSelection())
- return;
- TextLayoutHitInfo startSelTLHI;
- TextLayoutHitInfo endSelTLHI;
- if(endTLHI.compareTo(startTLHI) == -1){
- startSelTLHI = endTLHI;
- endSelTLHI = startTLHI;
- }
- else {
- startSelTLHI = startTLHI;
- endSelTLHI = endTLHI;
- }
- int ss = startSelTLHI.tli.startCharIndex + startSelTLHI.thi.getInsertionIndex();
- int ee = endSelTLHI.tli.startCharIndex + endSelTLHI.thi.getInsertionIndex();
- stext.clearAttributes(ss, ee);
-
- // We have modified the text style so the end of the selection may have
- // moved, so it needs to be recalculated. The start will be unaffected.
- stext.getLines(buffer.g2);
- endSelTLHI.tli = stext.getTLIforCharNo(ee);
- int cn = ee - endSelTLHI.tli.startCharIndex;
- if(cn == 0) // start of line
- endSelTLHI.thi = endSelTLHI.tli.layout.getNextLeftHit(1);
- else
- endSelTLHI.thi = endSelTLHI.tli.layout.getNextRightHit(cn-1);
- bufferInvalid = true;
- }
-
-
- /**
- * Used internally to set the scrollbar values as the text changes.
- *
- * @param sx
- * @param sy
- */
- void setScrollbarValues(float sx, float sy){
- if(vsb != null){
- float sTextHeight = stext.getTextAreaHeight();
- if(sTextHeight < th)
- vsb.setValue(0.0f, 1.0f);
- else
- vsb.setValue(sy/sTextHeight, th/sTextHeight);
- }
- // If needed update the horizontal scrollbar
- if(hsb != null){
- float sTextWidth = stext.getMaxLineLength();
- if(stext.getMaxLineLength() < tw)
- hsb.setValue(0,1);
- else
- hsb.setValue(sx/sTextWidth, tw/sTextWidth);
- }
- }
-
- /**
- * Move caret to home position
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretStartOfLine(TextLayoutHitInfo currPos){
- if(currPos.thi.getCharIndex() == 0)
- return false; // already at start of line
- currPos.thi = currPos.tli.layout.getNextLeftHit(1);
- return true;
- }
-
- /**
- * Move caret to the end of the line that has the current caret position
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretEndOfLine(TextLayoutHitInfo currPos){
- if(currPos.thi.getCharIndex() == currPos.tli.nbrChars - 1)
- return false; // already at end of line
- currPos.thi = currPos.tli.layout.getNextRightHit(currPos.tli.nbrChars - 1);
- return true;
- }
-
- /**
- * Move caret left by one character.
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretLeft(TextLayoutHitInfo currPos){
- TextHitInfo nthi = currPos.tli.layout.getNextLeftHit(currPos.thi);
- if(nthi == null){
- return false;
- }
- else {
- // Move the caret to the left of current position
- currPos.thi = nthi;
- }
- return true;
- }
-
- /**
- * Move caret right by one character.
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretRight(TextLayoutHitInfo currPos){
- TextHitInfo nthi = currPos.tli.layout.getNextRightHit(currPos.thi);
- if(nthi == null){
- return false;
- }
- else {
- currPos.thi = nthi;
- }
- return true;
- }
-
- public void setJustify(boolean justify){
- stext.setJustify(justify);
- bufferInvalid = true;
- }
-
- /**
- * Sets the local colour scheme for this control
- */
- public void setLocalColorScheme(int cs){
- super.setLocalColorScheme(cs);
- if(hsb != null)
- hsb.setLocalColorScheme(localColorScheme);
- if(vsb != null)
- vsb.setLocalColorScheme(localColorScheme);
- }
-
- /**
- * Find out if some text is selected (highlighted)
- * @return true if some text is selected else false
- */
- public boolean hasSelection(){
- return (startTLHI.tli != null && endTLHI.tli != null && startTLHI.compareTo(endTLHI) != 0);
- }
-
- /**
- * Calculate the caret (text insertion point)
- *
- * @param tlhi
- */
- protected void calculateCaretPos(TextLayoutHitInfo tlhi){
- float temp[] = tlhi.tli.layout.getCaretInfo(tlhi.thi);
- caretX = temp[0];
- caretY = tlhi.tli.yPosInPara;
- }
-
- /**
- * Determines whether the text can be edited using the keyboard or mouse. It
- * still allows the text to be modified by the sketch code.
- * If text editing is being disabled and the control has focus then it is forced
- * to give up that focus.
- * This might be useful if you want to use a GTextArea control to display large
- * amounts of text that needs scrolling (so cannot use a GLabel) but must not
- * change e.g. a user instruction guide.
- *
- * @param enableTextEdit false to disable keyboard input
- */
- public void setTextEditEnabled(boolean enableTextEdit){
- // If we are disabling this then make sure it does not have focus
- if(enableTextEdit == false && focusIsWith == this){
- loseFocus(null);
- }
- enabled = enableTextEdit;
- textEditEnabled = enableTextEdit;
- }
-
- /**
- * Is this control keyboard enabled
- */
- public boolean isTextEditEnabled(){
- return textEditEnabled;
- }
-
- public void keyEvent(KeyEvent e) {
- if(!visible || !enabled || !textEditEnabled || !available) return;
- if(focusIsWith == this && endTLHI != null){
- char keyChar = e.getKey();
- int keyCode = e.getKeyCode();
- int keyID = e.getAction();
- boolean shiftDown = e.isShiftDown();
- boolean ctrlDown = e.isControlDown();
-
- textChanged = false;
- keepCursorInView = true;
-
- int startPos = pos, startNbr = nbr;
-
- // Get selection details
- endChar = endTLHI.tli.startCharIndex + endTLHI.thi.getInsertionIndex();
- startChar = (startTLHI != null) ? startTLHI.tli.startCharIndex + startTLHI.thi.getInsertionIndex() : endChar;
- pos = endChar;
- nbr = 0;
- adjust = 0;
- if(endChar != startChar){ // Have we some text selected?
- if(startChar < endChar){ // Forward selection
- pos = startChar; nbr = endChar - pos;
- }
- else if(startChar > endChar){ // Backward selection
- pos = endChar; nbr = startChar - pos;
- }
- }
- if(startPos >= 0){
- if(startPos != pos || startNbr != nbr)
- fireEvent(this, GEvent.SELECTION_CHANGED);
- }
- // Select either keyPressedProcess or keyTypeProcess. These two methods are overridden in child classes
- if(keyID == KeyEvent.PRESS) {
- keyPressedProcess(keyCode, keyChar, shiftDown, ctrlDown);
- setScrollbarValues(ptx, pty);
- }
- else if(keyID == KeyEvent.TYPE ){ // && e.getKey() != KeyEvent.CHAR_UNDEFINED && !ctrlDown){
- keyTypedProcess(keyCode, keyChar, shiftDown, ctrlDown);
- setScrollbarValues(ptx, pty);
- }
- if(textChanged){
- changeText();
- fireEvent(this, GEvent.CHANGED);
- }
- }
- }
-
- // Enable polymorphism.
- protected void keyPressedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown) { }
-
- protected void keyTypedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown){ }
-
-
- // Only executed if text has changed
- protected boolean changeText(){
- TextLayoutInfo tli;
- TextHitInfo thi = null, thiRight = null;
-
- pos += adjust;
- // Force layouts to be updated
- stext.getLines(buffer.g2);
-
- // Try to get text layout info for the current position
- tli = stext.getTLIforCharNo(pos);
- if(tli == null){
- // If unable to get a layout for pos then reset everything
- endTLHI = null;
- startTLHI = null;
- ptx = pty = 0;
- caretX = caretY = 0;
- return false;
- }
- // We have a text layout so we can do something
- // First find the position in line
- int posInLine = pos - tli.startCharIndex;
-
- // Get some hit info so we can see what is happening
- try{
- thiRight = tli.layout.getNextRightHit(posInLine);
- }
- catch(Exception excp){
- thiRight = null;
- }
-
- if(posInLine <= 0){ // At start of line
- thi = tli.layout.getNextLeftHit(thiRight);
- }
- else if(posInLine >= tli.nbrChars){ // End of line
- thi = tli.layout.getNextRightHit(tli.nbrChars - 1);
- }
- else { // Character in line;
- thi = tli.layout.getNextLeftHit(thiRight);
- }
-
- endTLHI.setInfo(tli, thi);
- // Cursor at end of paragraph graphic
- calculateCaretPos(endTLHI);
-
- bufferInvalid = true;
- return true;
- }
-
- /**
- * Do not call this directly. A timer calls this method as and when required.
- */
- public void flashCaret(GTimer timer){
- showCaret = !showCaret;
- }
-
- /**
- * Do not call this method directly, G4P uses it to handle input from
- * the horizontal scrollbar.
- */
- public void hsbEventHandler(GScrollbar scrollbar, GEvent event){
- keepCursorInView = false;
- ptx = hsb.getValue() * (stext.getMaxLineLength() + 4);
- bufferInvalid = true;
- }
-
- /**
- * Do not call this method directly, G4P uses it to handle input from
- * the vertical scrollbar.
- */
- public void vsbEventHandler(GScrollbar scrollbar, GEvent event){
- keepCursorInView = false;
- pty = vsb.getValue() * (stext.getTextAreaHeight() + 1.5f * stext.getMaxLineHeight());
- bufferInvalid = true;
- }
-
- /**
- * Permanently dispose of this control.
- */
- public void markForDisposal(){
- if(tabManager != null)
- tabManager.removeControl(this);
- super.markForDisposal();
- }
-
- /**
- * Save the styled text used by this control to file.
- * It will also save the start and end position of any text selection.
- *
- * @param fname the name of the file to use
- * @return true if saved successfully else false
- */
- public boolean saveText(String fname){
- if(stext == null)
- return false;
- if(hasSelection()){
- stext.startIdx = startTLHI.tli.startCharIndex + startTLHI.thi.getInsertionIndex();
- stext.endIdx = endTLHI.tli.startCharIndex + endTLHI.thi.getInsertionIndex();
- }
- else {
- stext.startIdx = stext.endIdx = -1;
- }
- StyledString.save(winApp, stext, fname);
- return true;
- }
-
- /**
- * Load the styled string to be used by this control.
- * It will also restore any text selection saved with the text.
- *
- * @param fname the name of the file to use
- * @return true if loaded successfully else false
- */
- public boolean loadText(String fname){
- StyledString ss = StyledString.load(winApp, fname);
- if(ss == null)
- return false;
- setStyledText(ss);
- // Now restore any text selection
- if(stext.startIdx >=0){ // we have a selection
- // Selection starts at ...
- startTLHI = new TextLayoutHitInfo();
- startTLHI.tli = stext.getTLIforCharNo(stext.startIdx);
- int pInLayout = stext.startIdx - startTLHI.tli.startCharIndex;
- if(pInLayout == 0)
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
- else
- startTLHI.thi = startTLHI.tli.layout.getNextRightHit(pInLayout - 1);
- // Selection ends at ...
- endTLHI = new TextLayoutHitInfo();
- endTLHI.tli = stext.getTLIforCharNo(stext.endIdx);
- pInLayout = stext.endIdx - endTLHI.tli.startCharIndex;
-
- if(pInLayout == 0)
- endTLHI.thi = endTLHI.tli.layout.getNextLeftHit(1);
- else
- endTLHI.thi = endTLHI.tli.layout.getNextRightHit(pInLayout - 1);
- calculateCaretPos(endTLHI);
- }
- bufferInvalid = true;
- return true;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GEvent.java b/Processing/libraries/G4P/src/g4p_controls/GEvent.java
deleted file mode 100644
index d3ad3d3..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GEvent.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-/**
- * Enumeration of events that can be fired by G4P.
- *
- * GTextField and GTextArea events
- * CHANGED Text has changed
- * SELECTION_CHANGED Text selection has changed
- * ENTERED Enter/return key typed
- * LOST_FOCUS TextField/Area lost focus
- * GETS_FOCUS TextField/Area got focus
- *
- * GPanel events
- * COLLAPSED Control was collapsed
- * EXPANDED Control was expanded
- * DRAGGED Control is being dragged
- *
- * Button control events (PRESSED and RELEASED are not fired by default)
- * CLICKED Mouse button was clicked
- * PRESSED Mouse button was pressed
- * RELEASED Mouse button was released
- *
- * Slider control events events
- * VALUE_CHANGING Value is changing
- * VALUE_STEADY Value has reached a steady state
- * DRAGGING The mouse is being dragged over a component
- *
- * GCheckbox & GOption events
- * SELECTED ( "Option selected
- * DESELECTED ( "Option de-selected
- *
- * @author Peter Lager
- *
- */
-public enum GEvent {
- // GTextField and GTextArea events
- CHANGED ( "CHANGED", "Text has changed" ),
- SELECTION_CHANGED ( "SELECTION_CHANGED", "Text selection has changed" ),
- ENTERED ( "ENTERED", "Enter/return key typed" ),
- LOST_FOCUS ( "LOST_FOCUS", "TextField/Area lost focus" ),
- GETS_FOCUS ( "GETS_FOCUS", "TextField/Area got focus" ),
-
-
- // GPanel events
- COLLAPSED ( "COLLAPSED", "Control was collapsed" ),
- EXPANDED ( "EXPANDED", "Control was expanded" ),
- DRAGGED ( "DRAGGED", "Control is being dragged" ),
-
- // Button control events (PRESSED and RELEASED are not fired by default)
- CLICKED ( "CLICKED", "Mouse button was clicked" ),
- PRESSED ( "PRESSED", "Mouse button was pressed" ),
- RELEASED ( "RELEASED", "Mouse button was released" ),
-
- // Slider control events events
- VALUE_CHANGING ( "VALUE_CHANGING", "Value is changing" ),
- VALUE_STEADY ( "VALUE_STEADY", "Value has reached a steady state" ),
- DRAGGING ( "DRAGGING", "The mouse is being dragged over a component"),
-
- /// GCheckbox & GOption events
- SELECTED ( "SELECTED", "Option selected" ),
- DESELECTED ( "DESELECTED", "Option de-selected" );
-
-
- private String type;
- private String description;
-
- private GEvent(String type, String desc ){
- this.type = type;
- description = desc;
- }
-
- /**
- * Get a textual description of this event
- */
- public String getDesc(){
- return description;
- }
-
- /**
- * Get the error identifier.
- */
- public String getType(){
- return type;
- }
-
- public String toString(){
- return type;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GGroup.java b/Processing/libraries/G4P/src/g4p_controls/GGroup.java
deleted file mode 100644
index 6755291..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GGroup.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2014 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import processing.core.PApplet;
-
-/**
- * This class allows you to group GUI controls so that they can be treated as a single
- * entity for common GUI actions.
- * Once grouped a single statement change the enabled status, visibility status, colour
- * scheme and transparency for all the controls in the group. It is possible to
- * specify a delay before the action is executed, and in the case of transparency, specify
- * the amount of time the fade occurs.
- * This is particularly useful if your sketch has a number of 'modes' and each mode has its
- * own set of G4P controls. Simply create a GGroup object for each mode then as the mode
- * changes it is easy to display the controls for the current mode and hide the others.
- * A GGroup is associated with a window (or GWindow) and can only be used with controls
- * displayed on that window.
- *
- * @author Peter Lager
- *
- */
-public final class GGroup extends GAbstractControl {
- // The possible group action types
- private static final int INVALID_ACTION = 0;
- private static final int ALPHA_TO = 1;
- private static final int ENABLE = 2;
- private static final int VISIBLE = 3;
- private static final int COLOR_SCHEME = 4;
-
- // Actions still to be processed.
- private List actions = new LinkedList();
-
- private int cTime, lTime, eTime;
-
- private int currentAlpha = 255;
- private int targetAlpha = 255;
- private float alpha = 255;
- private float speed = 255;
-
- /**
- * Create a control group for the indicated PApplet. Only controls
- * created with this PApplet can be added to this group.
- *
- * All controls added will be initialised as fully opaque.
- *
- * @param theApplet the associated PApplet
- */
- public GGroup(PApplet theApplet) {
- this(theApplet, 255);
- }
-
- /**
- * Create a control group for the indicated PApplet. Only controls
- * created with this PApplet can be added to this group.
- *
- * All controls added will be initialised as fully opaque.
- *
- * @param theApplet the associated PApplet
- * @param startAlpha the starting alpha level (must 0-255 incl)
- */
- public GGroup(PApplet theApplet, int startAlpha) {
- super(theApplet);
- startAlpha &= 0xFF;
- currentAlpha = targetAlpha = startAlpha;
- children = new LinkedList();
- registeredMethods = PRE_METHOD;
- cTime = lTime = eTime = 0;
- G4P.registerControl(this);
- }
-
- /**
- * Create a control group for the indicated GWindow. Only controls
- * displayed in this GWindow can be added to this group.
- *
- * All controls added will be initialised as fully opaque.
- *
- * @param theWindow the associated GWindow
- */
- public GGroup(GWindow theWindow) {
- this(theWindow, 255);
- }
-
- /**
- * Fade to invisible. (alpha = 0)
- *
- * @param delay time before starting fade (milli-seconds)
- * @param duration time to fade over (milli-seconds)
- */
- public void fadeOut(int delay, int duration){
- actions.add(new Action(ALPHA_TO, delay, new Object[] { 0, duration }));
- }
-
- /**
- * Fade to fully opaque. (alpha = 255)
- *
- * @param delay time before starting fade (milli-seconds)
- * @param duration time to fade over (milli-seconds)
- */
- public void fadeIn(int delay, int duration){
- actions.add(new Action(ALPHA_TO, delay, new Object[] { 255, duration }));
- }
-
- /**
- * Fade to an alpha value
- *
- * @param delay time before starting fade (milli-seconds)
- * @param duration time to fade over (milli-seconds)
- * @param alpha the target alpha value
- */
- public void fadeTo(int delay, int duration, int alpha){
- alpha &= 0xFF;
- actions.add(new Action(ALPHA_TO, delay, new Object[] { alpha, duration }));
- }
-
- /**
- * Enable / disable the controls.
- * @param delay delay time before action is performed (milli-seconds)
- */
- public void setEnabled(int delay, boolean enable){
- actions.add(new Action(ENABLE, delay, new Object[] { enable }));
- }
-
- public boolean isFading(){
- return currentAlpha != targetAlpha;
- }
-
- public int timeLeftFading(){
- if(currentAlpha == targetAlpha)
- return 0;
- // calculate approximate time left
- return Math.round((targetAlpha - currentAlpha)/speed);
- }
-
- /**
- * Enable / disable the controls immediately.
- */
- public void setEnabled(boolean enable){
- setEnabled(0, enable);
- }
-
- /**
- * Make the control visible or invisible.
- * If you simply want to change the controls' visibility status then
- * use this in preference to fadeIn/fadeOut
- * @param delay delay time before action is performed (milli-seconds)
- */
- public void setVisible(int delay, boolean visible){
- actions.add(new Action(VISIBLE, delay, new Object[] { visible }));
- }
-
- /**
- * Make the control visible or invisible with immediate effect.
- * If you simply want to change the controls' visibility status then
- * use this in preference to fadeIn/fadeOut
- */
- public void setVisible(boolean visible){
- setEnabled(0, visible);
- }
-
- /**
- * Set the color scheme used by these controls with immediate effect.
- * @see GConstants for colour constants (e.g. BLUE_SCHEME) to use.
- *
- * @param colScheme the colour scheme (0-15) to be used.
- */
- public void setLocalColorScheme(int colScheme){
- setLocalColorScheme(0, colScheme);
- }
-
- /**
- * Set the color scheme used by these controls after a delay.
- * @see GConstants for colour constants (e.g. BLUE_SCHEME) to use.
- *
- * @param delay time before colour change (milli-seconds)
- * @param colScheme the colour scheme (0-15) to be used.
- */
- public void setLocalColorScheme(int delay, int colScheme){
- colScheme &= 0xf; // constrain to 0-15
- actions.add(new Action(COLOR_SCHEME, delay, new Object[] { colScheme }));
- }
-
- public void pre(){
- if(lTime == 0){ // First call to method
- cTime = lTime = (int) System.currentTimeMillis();
- return;
- }
- // Get elapsed time in millis
- lTime = cTime;
- cTime = (int) System.currentTimeMillis();
- eTime = cTime - lTime;
-
- if(currentAlpha != targetAlpha)
- peformFading();
- if(!actions.isEmpty())
- processActions();
- }
-
- /**
- * Executed
- */
- private void peformFading(){
- // Calculate the next alpha and constrain to 0-255 incl.
- float nextAlpha = alpha + eTime * speed;
- nextAlpha = (nextAlpha < 0) ? 0 : nextAlpha;
- nextAlpha = (nextAlpha >255) ? 255 : nextAlpha;
- // See if alpha and nextAlpha stradles target
- if((alpha - targetAlpha)*(nextAlpha - targetAlpha) <= 0)
- currentAlpha = targetAlpha;
- else
- currentAlpha = (int)nextAlpha;
- alphaImpl(currentAlpha);
- alpha = nextAlpha;
- }
-
- /*
- * Loop through all the actions waiting to be processed reducing the time
- * before they need to be implemented. If the action is ready remove it
- * from the list and implement it.
- */
- private void processActions(){
- Iterator iter = actions.iterator();
- while(iter.hasNext()){
- Action a = iter.next();
- a.delay -= eTime;
- if(a.delay <= 0){
- iter.remove();
- switch(a.type){
- case VISIBLE:
- visibleImpl(a.bool);
- break;
- case ENABLE:
- enableImpl(a.bool);
- break;
- case COLOR_SCHEME:
- colorImpl(a.target);
- break;
- case ALPHA_TO:
- if(a.duration <= 0)
- alphaImpl(a.target);
- else {
- speed = ((float)(a.target - currentAlpha))/(float) a.duration;
- alpha = currentAlpha;
- targetAlpha = a.target;
- }
- break;
- }
- }
- }
- }
-
- private void alphaImpl(int alpha){
- for(GAbstractControl control : children)
- control.setAlpha(alpha, true);
- }
-
- private void colorImpl(int col){
- col &= 0xff; // make 0 -15
- for(GAbstractControl control : children)
- control.setLocalColorScheme(col, true);
- }
-
- private void enableImpl(boolean enable){
- for(GAbstractControl control : children)
- control.setEnabled(enable);
- }
-
- private void visibleImpl(boolean visible){
- for(GAbstractControl control : children)
- control.setVisible(visible);
- }
-
-
- /**
- * Add one or more G4P controls to this group.
- * If a control is not a valid type for group control, or if the control and group are for different
- * windows then the control is not added and a warning message is displayed.
- *
- * @param controls comma separated list of G4P controls to add to this group
- */
- public void addControls(GAbstractControl... controls){
- if(controls != null)
- for(GAbstractControl control : controls)
- addControl(control);
- }
-
- /**
- * A single G4P control to add to this group.
- * If a control is not a valid type for group control, or if the control and group are for different
- * windows then the control is not added and a warning message is displayed.
- *
- * @param control a G4P control to add to this group
- */
- public void addControl(GAbstractControl control){
- if(control != null){
- if(!control.isSuitableForGroupControl(control)){
- GMessenger.message(INVALID_TYPE, new Object[] { this, control } );
- return;
- }
- if(this.winApp != control.winApp){
- GMessenger.message(INVALID_PAPPLET, new Object[] { this, control } );
- return;
- }
- control.setAlpha(currentAlpha, true);
- children.add(control);
- }
- }
-
- /**
- * Remove one or more G4P controls from this group.
- *
- * @param controls comma separated list of G4P controls to remove from this group
- */
- public void removeControls(GAbstractControl... controls){
- if(controls != null)
- for(GAbstractControl control : controls)
- removeControl(control);
- }
-
- /**
- * Remove a single G4P control from this group.
- *
- * @param control a G4P control to remove from this group
- */
- public void removeControl(GAbstractControl control){
- if(control != null)
- children.remove(control);
- }
-
-
- private class Action {
- int type;
- long delay = 0;
- // Extras
- int duration = 0;
- boolean bool = false;
- int target = 0;
-
- /**
- * Create an action
- *
- * @param type
- * @param delay
- * @param extra
- */
- public Action(int type, long delay, Object... extra) {
- super();
- this.type = type;
- this.delay = delay;
- switch(type){
- case VISIBLE:
- case ENABLE:
- bool = (Boolean)extra[0];
- break;
- case COLOR_SCHEME:
- target = (Integer)extra[0];
- break;
- case ALPHA_TO:
- target = (Integer)extra[0];
- duration = (Integer)extra[1];
- break;
- default:
- this.type = INVALID_ACTION;
- }
- }
-
- public String toString(){
- StringBuilder sb = new StringBuilder();
- switch(type){
- case VISIBLE:
- sb.append("VISIBLE ");
- break;
- case ENABLE:
- sb.append("ENABLE ");
- break;
- case COLOR_SCHEME:
- sb.append("COLOR_SCHEME ");
- break;
- case ALPHA_TO:
- sb.append("ALPHA_TO over ");
- sb.append(duration + " millis ");
- break;
- default:
- sb.append("INVALID ");
- break;
- }
- return sb.toString();
- }
- }
-
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GImageButton.java b/Processing/libraries/G4P/src/g4p_controls/GImageButton.java
deleted file mode 100644
index 39e975a..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GImageButton.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSalpha;
-import g4p_controls.HotSpot.HSmask;
-import processing.core.PApplet;
-import processing.core.PImage;
-import processing.event.MouseEvent;
-
-/**
- * Buttons create from this class use a number of images to represent it's
- * state. This means that buttons can have an irregular and/or discontinuous
- * shape.
- *
Determining the control size
- * If when creating the button you specify a particular width and height then
- * any images that are not the same size will be scaled to fit without regard
- * to the original size or aspect ratio.
- *
- * If when creating the button you do not specify the width and height then it
- * will use the width and height of the 'off-button' image and assume that all the
- * other images are the same size.
- *
- *
The images
- * The image button needs 1 to 3 image files to represent the button states
- * OFF mouse is not over button
- * OVER mouse is over the button
- * DOWN the mouse is over the button and a mouse button is being pressed.
- *
- * If you only provide one image then this will be used for all states, if you
- * provide two then the second image is used for both OVER and DOWN states.
- *
- * If you don't provide a mask file then the button 'hotspot' is represented by any
- * non-transparent pixels in the OFF image. If you do provide a mask file then the
- * hotspot is defined by any black pixels in the mask image.
- *
- *
- * Three types of event can be generated :-
- * GEvent.PRESSED GEvent.RELEASED GEvent.CLICKED
- *
- * To simplify event handling the button only fires off CLICKED events
- * when the mouse button is pressed and released over the button face
- * (the default behaviour).
- *
- * Using
button1.fireAllEvents(true);
enables the other 2 events
- * for button button1. A PRESSED event is created if the mouse button
- * is pressed down over the button face, the CLICKED event is then generated
- * if the mouse button is released over the button face. Releasing the
- * button off the button face creates a RELEASED event.
- *
- *
- * @author Peter Lager
- *
- */
-public class GImageButton extends GAbstractControl {
-
- private static PImage[] errImage = null;
-
- protected PImage[] bimage = null;
- protected PImage mask = null;
-
- protected int status;
- protected boolean reportAllButtonEvents = false;
-
-
- /**
- * The control size will be set to the size of the image file used for the button OFF state.
- * There is no alpha mask file..
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param fnames an array of up to 3 image filenames to represent the off/over/down state of the button.
- */
- public GImageButton(PApplet theApplet, float p0, float p1, String[] fnames) {
- this(theApplet, p0, p1, fnames, null);
- }
-
- /**
- * The control size will be set to the size of the image file used for the button OFF state.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param fnames an array of up to 3 image filenames to represent the off/over/down state of the button.
- * @param fnameMask the alpha mask filename or null if no mask
- */
- public GImageButton(PApplet theApplet, float p0, float p1, String[] fnames, String fnameMask) {
- super(theApplet, p0, p1);
- if(errImage == null)
- errImage = ImageManager.loadImage(winApp, new String[] { "err0.png", "err1.png", "err2.png" });
-
- //========================================================================
- // First of all load images
- // Make sure we have an array of filenames
- if(fnames == null || fnames.length == 0)
- fnames = new String[] { "err0.png", "err1.png", "err2.png" };
- bimage = ImageManager.loadImage(winApp, fnames);
- // There should be 3 images if not use as many as possible,
- // duplicating the last one if neccessary
- if(bimage.length != 3){
- PImage[] temp = new PImage[3];
- for(int i = 0; i < 3; i++)
- temp[i] = bimage[Math.min(i, bimage.length - 1)];
- bimage = temp;
- }
- // Get mask image if available
- if(fnameMask != null)
- mask = winApp.loadImage(fnameMask);
- //========================================================================
-
-
- //========================================================================
- // Now decide whether to resize either the images or the button
- if(width > 0 && height > 0){ // Resize images
- for(int i = 0; i < bimage.length; i++){
- if(bimage[i].width != width || bimage[i].height != height)
- bimage[i].resize((int)width, (int)height);
- }
- if(mask != null && (mask.width != width || mask.height != height))
- mask.resize((int)width, (int)height);
- }
- else { // resize button
- resize(bimage[0].width, bimage[0].height);
- }
- //========================================================================
-
- //========================================================================
- // Setup the hotspaots
- if(mask != null){ // if we have a mask use it for the hot spot
- hotspots = new HotSpot[]{
- new HSmask(1, mask)
- };
- }
- else { // no mask then use alpha channel of the OFF image
- hotspots = new HotSpot[]{
- new HSalpha(1, 0, 0, bimage[0], PApplet.CORNER)
- };
- }
- //========================================================================
-
- z = Z_SLIPPY;
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleButtonEvents",
- new Class>[]{ GImageButton.class, GEvent.class },
- new String[]{ "button", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
-
- /**
- * Create an image button of the size specified by the parameters.
- * The images will be resized to fit and there is no alpha mask file.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param fnames an array of up to 3 image filenames to represent the off/over/down state of the button.
- */
- public GImageButton(PApplet theApplet, float p0, float p1, float p2, float p3, String[] fnames) {
- this(theApplet, p0, p1, p2, p3, fnames, null);
- }
-
- /**
- * Create an image button of the size specified by the parameters.
- * The images will be resized to fit.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param fnames an array of up to 3 image filenames to represent the off/over/down state of the button.
- * @param fnameMask the alpha mask filename or null if no mask
- */
- public GImageButton(PApplet theApplet, float p0, float p1, float p2, float p3, String[] fnames, String fnameMask) {
- super(theApplet, p0, p1, p2, p3);
- if(errImage == null)
- errImage = ImageManager.loadImage(winApp, new String[] { "err0.png", "err1.png", "err2.png" });
-
- //========================================================================
- // First of all load images
- // Make sure we have an array of filenames
- if(fnames == null || fnames.length == 0)
- fnames = new String[] { "err0.png", "err1.png", "err2.png" };
- bimage = ImageManager.loadImage(winApp, fnames);
- // There should be 3 images if not use as many as possible,
- // duplicating the last one if neccessary
- if(bimage.length != 3){
- PImage[] temp = new PImage[3];
- for(int i = 0; i < 3; i++)
- temp[i] = bimage[Math.min(i, bimage.length - 1)];
- bimage = temp;
- }
- // Get mask image if available
- if(fnameMask != null)
- mask = winApp.loadImage(fnameMask);
- //========================================================================
-
-
- //========================================================================
- // Now decide whether to resize either the images or the button
- if(width > 0 && height > 0){ // Resize images
- for(int i = 0; i < bimage.length; i++){
- if(bimage[i].width != width || bimage[i].height != height)
- bimage[i].resize((int)width, (int)height);
- }
- if(mask != null && (mask.width != width || mask.height != height))
- mask.resize((int)width, (int)height);
- }
- else { // resize button
- resize(bimage[0].width, bimage[0].height);
- }
- //========================================================================
-
- //========================================================================
- // Setup the hotspaots
- if(mask != null){ // if we have a mask use it for the hot spot
- hotspots = new HotSpot[]{
- new HSmask(1, mask)
- };
- }
- else { // no mask then use alpha channel of the OFF image
- hotspots = new HotSpot[]{
- new HSalpha(1, 0, 0, bimage[0], PApplet.CORNER)
- };
- }
- //========================================================================
-
- z = Z_SLIPPY;
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleButtonEvents",
- new Class>[]{ GImageButton.class, GEvent.class },
- new String[]{ "button", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
-
- public void draw(){
- if(!visible) return;
-
- // Update buffer if invalid
- //updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(bimage[status], 0, 0);
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- /**
- *
- * When a mouse button is clicked on a GImageButton it generates the GEvent.CLICKED event. If
- * you also want the button to generate GEvent.PRESSED and GEvent.RELEASED events
- * then you need the following statement.
- *
- *
- */
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot >= 0 && z > focusObjectZ()){
- dragging = false;
- status = PRESS_CONTROL;
- takeFocus();
- if(reportAllButtonEvents)
- fireEvent(this, GEvent.PRESSED);
- }
- break;
- case MouseEvent.CLICK:
- // No need to test for isOver() since if the component has focus
- // and the mouse has not moved since MOUSE_PRESSED otherwise we
- // would not get the Java MouseEvent.MOUSE_CLICKED event
- if(focusIsWith == this){
- status = OFF_CONTROL;
- loseFocus(null);
- dragging = false;
- fireEvent(this, GEvent.CLICKED);
- }
- break;
- case MouseEvent.RELEASE:
- // if the mouse has moved then release focus otherwise
- // MOUSE_CLICKED will handle it
- if(focusIsWith == this && dragging){
- if(currSpot >= 0)
- fireEvent(this, GEvent.CLICKED);
- else {
- if(reportAllButtonEvents){
- fireEvent(this, GEvent.RELEASED);
- }
- }
- dragging = false;
- loseFocus(null);
- status = OFF_CONTROL;
- }
- break;
- case MouseEvent.MOVE:
- // If dragged state will stay as PRESSED
- if(currSpot >= 0)
- status = OVER_CONTROL;
- else
- status = OFF_CONTROL;
- break;
- case MouseEvent.DRAG:
- dragging = (focusIsWith == this);
- break;
- }
- }
-
- /**
- * If the parameter is true all 3 event types are generated, if false
- * only CLICKED events are generated (default behaviour).
- * @param all
- */
- public void fireAllEvents(boolean all){
- reportAllButtonEvents = all;
- }
-
- /**
- * Enable or disable the ability of the component to generate mouse events.
- * If the control is to be disabled when it is clicked then this will force the
- * mouse off button image is used.
- * @param enable true to enable else false
- */
- public void setEnabled(boolean enable){
- super.setEnabled(enable);
- if(!enable)
- status = OFF_CONTROL;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GImageToggleButton.java b/Processing/libraries/G4P/src/g4p_controls/GImageToggleButton.java
deleted file mode 100644
index 764eb62..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GImageToggleButton.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSalpha;
-import processing.core.PApplet;
-import processing.core.PImage;
-import processing.event.MouseEvent;
-
-/**
- * Buttons created from this class have 2 or more toggle states. If the number of states
- * is N then the button's value will be in the range 0 to N-1. Most toggle buttons will
- * have just two states and these have values 0 and 1.
- * Clicking on the button advances the state by one, restarting at zero after the last
- * state.
- * Each state must have its own 'picture' and the user must supply these as a tiled image
- * where the pictures are tiled in 1D or 2D arrangement without 'empty space' around the
- * tiles.
- * If for any reason the library is unable to use the specified graphics then it will
- * provide a default two state toggle switch.
- * It is also possible to provide an over-button image set for when the mouse moves
- * over the button - this is optional.
- * The button control will always be resized to suit the state picture size (tile size).
- * The mouse is considered to be over the button it its position is over an opaque pixel
- * in the state picture. Since transparent pixels are not included then the button shape
- * can be different for each state.
- *
- *
- *
- * Three types of event can be generated :-
- * GEvent.PRESSED GEvent.RELEASED GEvent.CLICKED
- *
- * To simplify event handling the button only fires off CLICKED events
- * when the mouse button is pressed and released over the button face
- * (the default behaviour).
- *
- * Using
button1.fireAllEvents(true);
enables the other 2 events
- * for button button1. A PRESSED event is created if the mouse button
- * is pressed down over the button face, the CLICKED event is then generated
- * if the mouse button is released over the button face. Releasing the
- * button off the button face creates a RELEASED event. This is included for
- * completeness since it is unlikely you will need to detect these events
- * for this type of control.
- *
- *
- * @author Peter Lager
- *
- */
-public class GImageToggleButton extends GAbstractControl {
-
- private static PImage toggle = null;
- private static final String TOGGLE = "toggle.png";
-
- protected int nbrStates = 2;
- protected int stateValue = 0;
-
- protected PImage[] offImage;
- protected PImage[] overImage;
-
- protected int status;
- protected boolean reportAllButtonEvents = false;
-
-
- /**
- * Create the library default image-toggle-button at the stated position.
- *
- * @param theApplet
- * @param p0 horizontal position of the control
- * @param p1 vertical position of the control
- */
- public GImageToggleButton(PApplet theApplet, float p0, float p1){
- this(theApplet, p0, p1, null, null, 1, 1);
- }
-
- /**
- * Create an image-toggle-button.
- * Single row of tiles.
- *
- * @param theApplet
- * @param p0 horizontal position of the control
- * @param p1 vertical position of the control
- * @param offPicture the filename of bitmap containing toggle state pictures
- * @param nbrCols number of tiles horizontally
- */
- public GImageToggleButton(PApplet theApplet, float p0, float p1, String offPicture, int nbrCols){
- this(theApplet, p0, p1, offPicture, null, nbrCols, 1);
- }
-
- /**
- * Create an image-toggle-button.
- *
- * @param theApplet
- * @param p0 horizontal position of the control
- * @param p1 vertical position of the control
- * @param offPicture the filename of bitmap containing toggle state pictures
- * @param nbrCols number of tiles horizontally
- * @param nbrRows number of tiles vertically
- */
- public GImageToggleButton(PApplet theApplet, float p0, float p1, String offPicture, int nbrCols, int nbrRows){
- this(theApplet, p0, p1, offPicture, null, nbrCols, nbrRows);
- }
-
- /**
- * Create an image-toggle-button.
- * Single row of tiles.
- *
- * @param theApplet
- * @param p0 horizontal position of the control
- * @param p1 vertical position of the control
- * @param offPicture the filename of bitmap containing toggle state pictures
- * @param overPicture the filename of bitmap containing mouse-over button toggle state pictures
- * @param nbrCols number of tiles horizontally
- */
- public GImageToggleButton(PApplet theApplet, float p0, float p1, String offPicture, String overPicture, int nbrCols){
- this(theApplet, p0, p1, offPicture, overPicture, nbrCols, 1);
- }
-
- /**
- * Create an image-toggle-button.
- *
- * @param theApplet
- * @param p0 horizontal position of the control
- * @param p1 vertical position of the control
- * @param offPicture the filename of bitmap containing toggle state pictures
- * @param overPicture the filename of bitmap containing mouse-over button toggle state pictures
- * @param nbrCols number of tiles horizontally
- * @param nbrRows number of tiles vertically
- */
- public GImageToggleButton(PApplet theApplet, float p0, float p1, String offPicture, String overPicture, int nbrCols, int nbrRows){
- super(theApplet, p0, p1);
- // Attempt to get off-control image data
- PImage temp = null;
- if(nbrCols < 1 || nbrRows < 1 || offPicture == null || null == (temp = ImageManager.loadImage(winApp, offPicture))){
- // Invalid data use default
- nbrStates = 2;
- if(toggle == null)
- toggle = ImageManager.loadImage(winApp, TOGGLE);
- offImage = ImageManager.makeTiles1D(winApp, toggle, 2, 1);
- }
- else {
- // Off-control image data valid
- nbrStates = nbrCols * nbrRows;
- offImage = ImageManager.makeTiles1D(winApp, temp, nbrCols, nbrRows);
- // Now check for over-control image data
- if(overPicture != null && null != (temp = ImageManager.loadImage(winApp, overPicture))){
- overImage = ImageManager.makeTiles1D(winApp, temp, nbrCols, nbrRows);
- }
- }
- // The control will always be resized to match the image size
- resize(offImage[0].width, offImage[0].height);
-
- //========================================================================
- // Setup the hotspots
- hotspots = new HotSpot[]{
- new HSalpha(1, 0, 0, offImage[stateValue], PApplet.CORNER)
- };
-
- //========================================================================
-
- z = Z_SLIPPY;
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleToggleButtonEvents",
- new Class>[]{ GImageToggleButton.class, GEvent.class },
- new String[]{ "button", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- public void draw(){
- if(!visible) return;
-
- winApp.pushStyle();
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- if(status == OVER_CONTROL && overImage != null)
- winApp.image(overImage[stateValue], 0, 0);
- else
- winApp.image(offImage[stateValue], 0, 0);
-
- winApp.popMatrix();
- winApp.popStyle();
- }
-
-
- /**
- *
- * When a mouse button is clicked on a GImageToggleButton it generates the GEvent.CLICKED event. If
- * you also want the button to generate GEvent.PRESSED and GEvent.RELEASED events
- * then you need the following statement.
- *
is the GImageToggleButton identifier (variable name)
- *
- */
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot >= 0 && z > focusObjectZ()){
- dragging = false;
- status = PRESS_CONTROL;
- takeFocus();
- if(reportAllButtonEvents)
- fireEvent(this, GEvent.PRESSED);
- }
- break;
- case MouseEvent.CLICK:
- // No need to test for isOver() since if the component has focus
- // and the mouse has not moved since MOUSE_PRESSED otherwise we
- // would not get the Java MouseEvent.MOUSE_CLICKED event
- if(focusIsWith == this){
- status = OFF_CONTROL;
- loseFocus(null);
- dragging = false;
- nextState();
- fireEvent(this, GEvent.CLICKED);
- }
- break;
- case MouseEvent.RELEASE:
- // if the mouse has moved then release focus otherwise
- // MOUSE_CLICKED will handle it
- if(focusIsWith == this && dragging){
- if(currSpot >= 0){
- nextState();
- fireEvent(this, GEvent.CLICKED);
- }
- else {
- if(reportAllButtonEvents){
- fireEvent(this, GEvent.RELEASED);
- }
- }
- dragging = false;
- loseFocus(null);
- status = OFF_CONTROL;
- }
- break;
- case MouseEvent.MOVE:
- // If dragged state will stay as PRESSED
- if(currSpot >= 0)
- status = OVER_CONTROL;
- else
- status = OFF_CONTROL;
- break;
- case MouseEvent.DRAG:
- dragging = (focusIsWith == this);
- break;
- }
- }
-
- /**
- * Advance to the next state and adjust the hotspot to use the current image
- */
- private void nextState(){
- stateValue++;
- stateValue %= nbrStates;
- hotspots[0].adjust(0,0,offImage[stateValue]);
- }
-
- /**
- * Get the current state value of the button.
- * @deprecated use getState()
- */
- @Deprecated
- public int stateValue(){
- return stateValue;
- }
-
- /**
- * Get the current state value of the button.
- */
- public int getState(){
- return stateValue;
- }
-
- /**
- * Change the current toggle state.
- * If the parameter is not a valid toggle state value then it
- * is ignored and the button's state value is unchanged.
- * @deprecated use setState(int)
- * @param newState
- */
- @Deprecated
- public void stateValue(int newState){
- if(newState >= 0 && newState < nbrStates && newState != stateValue){
- stateValue = newState;
- hotspots[0].adjust(0,0,offImage[stateValue]);
- bufferInvalid = true;
- }
- }
-
- /**
- * Change the current toggle state.
- * If the parameter is not a valid toggle state value then it
- * is ignored and the button's state value is unchanged.
- * @param newState
- */
- public void setState(int newState){
- if(newState >= 0 && newState < nbrStates && newState != stateValue){
- stateValue = newState;
- hotspots[0].adjust(0,0,offImage[stateValue]);
- bufferInvalid = true;
- }
- }
-
- /**
- * If the parameter is true all 3 event types are generated, if false
- * only CLICKED events are generated (default behaviour).
- * For this toggle control I can't see the need for anything but
- * CLICKED events
- * @param all
- */
- public void fireAllEvents(boolean all){
- reportAllButtonEvents = all;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GKnob.java b/Processing/libraries/G4P/src/g4p_controls/GKnob.java
deleted file mode 100644
index f4329f2..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GKnob.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSarc;
-import g4p_controls.HotSpot.HScircle;
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-
-/**
- * The provides an extremely configurable GUI knob controller. GKnob
- * inherits from GValueControl so you should read the documentation
- * for that class as it also applies to GKnob.
- *
- * Configurable options
- * Knob size but it must be circular
- * Start and end of rotation arc.
- * Bezel width with tick marks
- * User defined value limits (i.e. the range of values returned
- *
- * Range of values associated with rotating the knob
- * Rotation is controlled by mouse movement - 3 modes available
- * (a) angular - drag round knob center
- * (b) horizontal - drag left or right
- * (c) vertical - drag up or down
- * User can specify mouse sensitivity for modes (b) and (c)
- * Use can specify easing to give smoother rotation
- *
- * Note: Angles are measured clockwise starting in the positive x direction i.e.
- *
- * 270
- * |
- * 180 --+-- 0
- * |
- * 90
- *
- *
- * @author Peter Lager
- *
- */
-public class GKnob extends GValueControl {
-
-
- protected float startAng = 110, endAng = 70;
-
- protected int mode = CTRL_HORIZONTAL;
-
- protected boolean showTrack = true;
-
- protected float bezelRadius, bezelWidth, gripRadius;
- protected boolean overIncludesBezel = true;
- protected float sensitivity = 1.0f;
-
- protected boolean drawArcOnly = false;
- protected boolean mouseOverArcOnly = false;
-
- protected float startMouseX, startMouseY;
- protected float lastMouseAngle, mouseAngle;
-
- // corresponds to target and current values
- // parametricTarget
- protected float angleTarget, lastAngleTarget;
-
- /**
- * Will create the a circular knob control that fits the rectangle define by
- * the values passed as parameters.
- * The knob has two zones the outer bezel and the inner gripper. The radius of
- * the outer bezel is calculated from
- *
bezel radius = min(width, height)/2 - 2
- * The radius of the inner griper radius is calculated from the bezel radius
- * and the last parameter.
- *
grip radius = bezel radiius * gripAmount
- * The gripAmount should be in te range 0.0 to 1.0 inclusive. The actual value
- * will be constrained to that range.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param gripAmount must be >=0.0 and <=1.0
- */
- public GKnob(PApplet theApplet, float p0, float p1, float p2, float p3, float gripAmount) {
- super(theApplet, p0, p1, p2, p3);
- bezelRadius = Math.min(width, height) / 2 - 2;
- setGripAmount(gripAmount);
- setTurnRange(startAng, endAng);
- // valuePos and valueTarget will start at 0.5;
- lastAngleTarget = angleTarget = scaleValueToAngle(parametricTarget);
- hotspots = new HotSpot[]{
- new HScircle(1, width/2, height/2, gripRadius)
- };
- z = Z_SLIPPY;
-
- epsilon = 0.98f / (endAng - startAng);
- showTicks = true;
-
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleKnobEvents",
- new Class>[]{ GValueControl.class, GEvent.class },
- new String[]{ "knob", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD ;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- /**
- * The radius of the inner griper radius is calculated from the bezel radius
- * and the parameter gripAmount using
- *
grip radius = bezel radiius * gripAmount
- * The gripAmount should be in te range 0.0 to 1.0 inclusive. The actual value
- * will be constrained to that range.
- *
- * @param gripAmount must be >=0.0 and <=1.0
- */
- public void setGripAmount(float gripAmount){
- gripAmount = PApplet.constrain(gripAmount, 0.0f, 1.0f);
- gripRadius = bezelRadius * gripAmount;
- if(gripRadius < 2.0f) gripRadius = 0.0f;
- bezelWidth = bezelRadius - gripRadius;
- bufferInvalid = true;
- }
-
- protected void calculateHotSpot(){
- float overRad = (this.overIncludesBezel) ? bezelRadius : gripRadius;
- if(mouseOverArcOnly)
- hotspots[0] = new HSarc(1, width/2 , height/2, overRad, startAng, endAng); // over grip
- else
- hotspots[0] = new HScircle(1, width/2, height/2, overRad);
- }
-
- /**
- * For a particular normalised value calculate the angle (degrees)
- *
- * @param v
- * @return the needle angle for the given value
- */
- protected float scaleValueToAngle(float v){
- float a = startAng + v * (endAng - startAng);
- return a;
- }
-
- /**
- * Calculates the knob angle based on the normalised value.
- *
- * @param a
- */
- protected float calcAngletoValue(float a){
- if(a < startAng)
- a += 360;
- float v = (a - startAng) / (endAng - startAng);
- return v;
- }
-
- /**
- * Set the value for the slider.
- * The user must ensure that the value is valid for the slider range.
- * @param v
- */
- public void setValue(float v){
- super.setValue(v);
- angleTarget = scaleValueToAngle(parametricTarget);
- }
-
- /**
- * Whether or not to show the circular progress bar.
- * @param showTrack true for visible
- */
- public void setShowTrack(boolean showTrack){
- if(this.showTrack != showTrack){
- this.showTrack = showTrack;
- bufferInvalid = true;
- }
- }
-
- /**
- * Are we showing the the value track bar.
- */
- public boolean isShowTrack(){
- return showTrack;
- }
-
- /**
- * Whether to include the bezel when deciding when the mouse is over.
- * @param overBezel true if bezel inclded.
- */
- public void setIncludeOverBezel(boolean overBezel){
- overIncludesBezel = overBezel;
- calculateHotSpot();
- }
-
- /**
- * Is the bezel included when considering when the mouse is over.
- * @return true if included.
- */
- public boolean isIncludeOverBezel(){
- return overIncludesBezel;
- }
-
- /**
- * Decides when the knob will respond to the mouse buttons. If set to true
- * it will only respond when ver the arc made by the start and end angles. If
- * false it will be the full circle.
- * @param arcOnly
- */
- public void setOverArcOnly(boolean arcOnly){
- mouseOverArcOnly = arcOnly;
- calculateHotSpot();
- }
-
- /**
- * Does the mouse only respond when over the arc?
- * @return true = yes
- */
- public boolean isOverArcOnly(){
- return mouseOverArcOnly;
- }
-
- /**
- * Convenience method to set both the show and the mouse over arc only properties
- * for this knob
- * @param over_arc_only mouse over arc only?
- * @param draw_arc_only draw arc only?
- * @param overfullsize include bezel in mouse over calculations?
- */
- public void setArcPolicy(boolean over_arc_only, boolean draw_arc_only, boolean overfullsize){
- this.mouseOverArcOnly = over_arc_only;
- setShowArcOnly(draw_arc_only);
- overIncludesBezel = overfullsize;
- calculateHotSpot();
- }
-
- /**
- * This will decide whether the knob is draw as a full circle or as an arc.
- *
- * @param arcOnly true for arc only
- */
- public void setShowArcOnly(boolean arcOnly){
- if(drawArcOnly != arcOnly){
- drawArcOnly = arcOnly;
- bufferInvalid = true;
- }
- }
-
- /**
- * Are we showing arc only?
- * @return true = yes
- */
- public boolean isShowArcOnly(){
- return drawArcOnly;
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- // Normalise ox and oy to the centre of the knob
- ox -= width/2;
- oy -= height/2;
-
- // currSpot == 1 for text display area
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot > -1 && z > focusObjectZ()){
- startMouseX = ox;
- startMouseY = oy;
- lastMouseAngle = mouseAngle = getAngleFromUser(ox, oy);
- offset = scaleValueToAngle(parametricTarget) - mouseAngle;
- takeFocus();
- }
- break;
- case MouseEvent.WHEEL:
- if(currSpot > -1 && z >= focusObjectZ()){
- System.out.print(tag + " " + parametricTarget + " " + event.getCount() + " " + wheelDelta + " >>> ");
- parametricTarget = calcParametricTarget(parametricTarget + event.getCount() * wheelDelta * G4P.wheelForSlider);
- System.out.println(parametricTarget);
- }
- break;
- case MouseEvent.RELEASE:
- if(focusIsWith == this){
- loseFocus(null);
- }
- // Correct for sticky ticks if needed
- if(stickToTicks)
- parametricTarget = findNearestTickValueTo(parametricTarget);
- dragging = false;
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this){
- mouseAngle = getAngleFromUser(ox, oy);
- if(mouseAngle != lastMouseAngle){
- float deltaMangle = mouseAngle - lastMouseAngle;
- // correct when we go over zero degree position
- if(deltaMangle < -180)
- deltaMangle += 360;
- else if(deltaMangle > 180)
- deltaMangle -= 360;
- // Calculate and adjust new needle angle so it is in the range aLow >>> aHigh
- angleTarget = constrainToTurnRange(angleTarget + deltaMangle);
- parametricTarget = calcAngletoValue(angleTarget);
- // Update offset for use with angular mouse control
- offset += (angleTarget - lastAngleTarget - deltaMangle);
- // Remember target needle and mouse angles
- lastAngleTarget = angleTarget;
- lastMouseAngle = mouseAngle;
- }
- }
- break;
- }
- }
-
-
- public void draw(){
- if(!visible) return;
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
- // Value labels
- if(children != null){
- for(GAbstractControl c : children)
- c.draw();
- }
- winApp.popMatrix();
-
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- double a, sina, cosa;
- float tickLength;
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- buffer.ellipseMode(PApplet.CENTER);
- // Background colour
- if(opaque == true)
- buffer.background(palette[6].getRGB());
- else
- buffer.background(buffer.color(255,0));
- buffer.translate(width/2, height/2);
- buffer.noStroke();
- float anglePos = scaleValueToAngle(parametricPos);
- if(bezelWidth > 0){
- // Draw bezel
- buffer.noStroke();
- buffer.fill(palette[5].getRGB());
- if(drawArcOnly)
- buffer.arc(0,0,2*bezelRadius, 2*bezelRadius, PApplet.radians(startAng), PApplet.radians(endAng));
- else
- buffer.ellipse(0,0,2*bezelRadius, 2*bezelRadius);
- // Draw ticks?
- if(showTicks){
- buffer.noFill();
- buffer.strokeWeight(1.6f);
- buffer.stroke(palette[3].getRGB());
- float deltaA = (endAng - startAng)/(nbrTicks - 1);
- for(int t = 0; t < nbrTicks; t++){
- tickLength = gripRadius + ((t == 0 || t == nbrTicks - 1) ? bezelWidth : bezelWidth * 0.8f);
- a = Math.toRadians(startAng + t * deltaA);
- sina = Math.sin(a);
- cosa = Math.cos(a);
- buffer.line((float)(gripRadius * cosa), (float)(gripRadius * sina), (float)(tickLength * cosa), (float)(tickLength * sina));
- }
- }
- // Draw track?
- if(showTrack){
- buffer.noStroke();
- buffer.fill(palette[14].getRGB());
- buffer.arc(0,0, 2*(gripRadius + bezelWidth * 0.5f), 2*(gripRadius + bezelWidth * 0.5f), PApplet.radians(startAng), PApplet.radians(anglePos));
- }
- }
-
- // draw grip (inner) part of knob
- buffer.strokeWeight(1.6f);
- buffer.stroke(palette[2].getRGB()); // was 14
- buffer.fill(palette[2].getRGB());
- if(drawArcOnly)
- buffer.arc(0,0,2*gripRadius, 2*gripRadius, PApplet.radians(startAng), PApplet.radians(endAng));
- else
- buffer.ellipse(0,0,2*gripRadius, 2*gripRadius);
-
- // Draw needle
- buffer.noFill();
- buffer.stroke(palette[14].getRGB());
- buffer.strokeWeight(3);
- a = Math.toRadians(anglePos);
- sina = Math.sin(a);
- cosa = Math.cos(a);
- buffer.line(0, 0, (float)(gripRadius * cosa), (float)(gripRadius * sina));
- buffer.endDraw();
- }
- }
-
-
- /**
- * Get the current mouse controller mode possible values are
- * GKnob.CTRL_ANGULAR or GKnob.CTRL_HORIZONTAL) orGKnob.CTRL_VERTICAL
- * @return the mode
- */
- public int getTurnMode() {
- return mode;
- }
-
- /**
- * Set the mouse control mode to use, acceptable values are
- * GKnob.CTRL_ANGULAR or GKnob.CTRL_HORIZONTAL) orGKnob.CTRL_VERTICAL any
- * other value will be ignored.
- * @param mode the mode to set
- */
- public void setTurnMode(int mode) {
- switch(mode){
- case CTRL_ANGULAR:
- case CTRL_HORIZONTAL:
- case CTRL_VERTICAL:
- this.mode = mode;
- }
- }
-
- /**
- * This gets the sensitivity to be used in modes CTRL_HORIZONTAL and CTRL_VERTICAL
- * @return the sensitivity
- */
- public float getSensitivity() {
- return sensitivity;
- }
-
- /**
- * This gets the sensitivity to be used in modes CTRL_HORIZONTAL and CTRL_VERTICAL
- * A value of 1 is 1 degree per pixel and a value of 2 is 2 degrees per pixel.
- * @param sensitivity the sensitivity to set
- */
- public void setSensitivity(float sensitivity) {
- this.sensitivity = (sensitivity < 0.1f) ? 0.1f : sensitivity;
- }
-
- /**
- * Calculates the 'angle' from the current mouse position based on the type
- * of 'controller' set.
- * @param px the distance from the knob centre in the x direction
- * @param py the distance from the knob centre in the y direction
- * @return the unconstrained angle
- */
- protected float getAngleFromUser(float px, float py){
- float degs = 0;
- switch(mode){
- case CTRL_ANGULAR:
- degs = calcRealAngleFromXY(ox, oy);
- break;
- case CTRL_HORIZONTAL:
- degs = sensitivity * (px - startMouseX);
- break;
- case CTRL_VERTICAL:
- degs = sensitivity * (py - startMouseY);
- break;
- }
- return degs;
- }
-
- /**
- * Set the limits for the range of valid rotation angles for the knob.
- *
- * @param start the range start angle in degrees
- * @param end the range end angle in degrees
- */
- public void setTurnRange(float start, float end){
- start = constrain360(start);
- end = constrain360(end);
- startAng = start;
- endAng = (startAng >= end) ? end + 360 : end;
- setValue(getValueF());
-// anglePos = angleTarget;
- bufferInvalid = true;
- }
-
- /**
- * Determines whether an angle is within the knob
- * rotation range.
- * @param a the angle in degrees
- * @return true is angle is within rotation range else false
- */
- protected boolean isInTurnRange(float a){
- a = constrain360(a);
- if(a < startAng)
- a += 360;
- return (a >= startAng && a <= endAng);
- }
-
- /**
- * Accept an angle and constrain it to the knob angle range.
- *
- * @param a
- * @return the constrained angle
- */
- protected float constrainToTurnRange(float a){
- if(a < startAng)
- a = startAng;
- else if(a > endAng)
- a = endAng;
- return a;
- }
-
- /**
- * Accept an angle and constrain it to the range 0-360
- * @param a
- * @return the constrained angle
- */
- protected float constrain360(float a){
- while(a < 0)
- a += 360;
- while(a > 360)
- a -= 360;
- return a;
- }
-
- /**
- * Calculate the angle to the knob centre making sure it is in
- * the range 0-360
- * @param px
- * @param py
- * @return the angle from the knob centre to the specified point.
- */
- protected float calcRealAngleFromXY(float px, float py){
- float a = (float) Math.toDegrees(Math.atan2(py, px));
- if(a < 0)
- a += 360;
- return a;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GLabel.java b/Processing/libraries/G4P/src/g4p_controls/GLabel.java
deleted file mode 100644
index 263de59..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GLabel.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Graphics2D;
-import java.awt.font.TextLayout;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-
-/**
- * The label component.
- *
- * This control can display text with/without an icon.
- *
- * @author Peter Lager
- *
- */
-public class GLabel extends GTextIconAlignBase {
-
- public GLabel(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, " ");
- }
-
- /**
- * Create a label control.
- *
- * use setIcon to add an icon
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param text
- */
- public GLabel(PApplet theApplet, float p0, float p1, float p2, float p3, String text) {
- super(theApplet, p0, p1, p2, p3);
- setText(text);
- opaque = false;
- // Now register control with applet
- registeredMethods = DRAW_METHOD;
- // Must register control
- G4P.registerControl(this);
- }
-
- public void draw(){
- if(!visible) return;
-
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
-
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
-
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
- // Back ground colour
- buffer.background(opaque ? palette[6].getRGB() : palette[2].getRGB() & 0xFFFFFF);
- // Calculate text and icon placement
- calcAlignment();
- // If there is an icon draw it
- if(iconW != 0)
- buffer.image(bicon[0], siX, siY);
- float wrapWidth = stext.getWrapWidth();
- float sx = 0, tw = 0;
- buffer.translate(stX, stY);
- for(TextLayoutInfo lineInfo : lines){
- TextLayout layout = lineInfo.layout;
- buffer.translate(0, layout.getAscent());
- switch(textAlignH){
- case CENTER:
- tw = layout.getVisibleAdvance();
- tw = (tw > wrapWidth) ? tw - wrapWidth : tw;
- sx = (wrapWidth - tw)/2;
- break;
- case RIGHT:
- tw = layout.getVisibleAdvance();
- tw = (tw > wrapWidth) ? tw - wrapWidth : tw;
- sx = wrapWidth - tw;
- break;
- case LEFT:
- case JUSTIFY:
- default:
- sx = 0;
- }
- // display text
- g2d.setColor(palette[2]);
- lineInfo.layout.draw(g2d, sx, 0);
- buffer.translate(0, layout.getDescent() + layout.getLeading());
- }
- buffer.endDraw();
- }
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GLinearTrackControl.java b/Processing/libraries/G4P/src/g4p_controls/GLinearTrackControl.java
deleted file mode 100644
index 1c41dc5..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GLinearTrackControl.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.font.TextLayout;
-
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-/**
- * Base class for linear sliders.
- *
- * This class provides the ability to control the orientation
- * the text should be displayed. It also enables the use of labels
- * for each tick mark.
- *
- * @author Peter Lager
- *
- */
-public abstract class GLinearTrackControl extends GValueControl {
-
- static protected float TINSET = 2;
-
- static protected int THUMB_SPOT = 1;
- static protected int TRACK_SPOT = 2;
-
- protected float trackWidth, trackLength, trackDisplayLength;
- protected float trackOffset;
-
- protected int textOrientation = ORIENT_TRACK;
-
- protected int downHotSpot = -1;
- // Mouse over status
- protected int status = OFF_CONTROL;
-
- // For labels
- protected StyledString[] labels;
- protected boolean labelsInvalid = true;
-
- // Introduced 4.0.2
- protected Font localFont = G4P.numericLabelFont;
-
- public GLinearTrackControl(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- }
-
- /**
- * Set the text orientation for the display of the limits and value if appropriate.
- * Acceptable values are G4P.ORIENT_LEFT, G4P.ORIENT_RIGHT or G4P.ORIENT_TRACK
- * If an invalid value is passed the ORIENT_TRACK is used.
- *
- * @param orient the orientation of the number labels
- */
- public void setTextOrientation(int orient){
- switch(orient){
- case ORIENT_LEFT:
- case ORIENT_RIGHT:
- case ORIENT_TRACK:
- textOrientation = orient;
- break;
- default:
- textOrientation = ORIENT_TRACK;
- }
- bufferInvalid = true;
- }
-
- /**
- * This method is used to set the text to appear alongside the tick marks.
- * The array passed must have a minimum of 2 elements and each label (element)
- * must have at least 1 character. If these two conditions are not met then
- * the call to this method will be ignored and no changes are made.
- *
- * @param tickLabels an array of strings for the labels
- */
- public void setTickLabels(String[] tickLabels){
- if(tickLabels == null || tickLabels.length < 2)
- return;
- for(String s : tickLabels)
- if(s == null || s.length() == 0)
- return;
- labels = new StyledString[tickLabels.length];
- for(int i = 0; i < tickLabels.length; i++)
- labels[i] = new StyledString(tickLabels[i]);
- setStickToTicks(true);
- setNbrTicks(labels.length);
- startLimit = 0;
- endLimit = nbrTicks - 1;
- valueType = INTEGER;
- showLimits = false;
- showValue = false;
- bufferInvalid = true;
- }
-
- /**
- * Set whether the tick marks are to be displayed or not. Then
- * recalculate the track offset for the value and limit text.
- * @param showTicks the showTicks to set
- */
- public void setShowTicks(boolean showTicks) {
- super.setShowTicks(showTicks);
- float newTrackOffset = calcTrackOffset();
- if(newTrackOffset != trackOffset){
- trackOffset = newTrackOffset;
- bufferInvalid = true;
- }
- bufferInvalid = true;
- }
-
- /**
- * Calculates the amount of offset for the labels
- */
- protected float calcTrackOffset(){
- return (showTicks) ? trackWidth + 2 : trackWidth/2 + 2;
- }
-
- /**
- * The offset is the distance the value/labels are drawn from the
- * centre of the track.
- * You may wish to tweak this value for visual effect.
- * @param offset
- */
- public void setTrackOffset(float offset){
- trackOffset = offset;
- }
-
- /**
- * Get the visual offset for the value/label text.
- */
- public float getTrackOffset(){
- return trackOffset;
- }
-
- /**
- * If we are using labels then this will get the label text
- * associated with the current value.
- * If labels have not been set then return null
- */
- public String getValueS(){
- // Use the valueTarget rather than the valuePos since intermediate values
- // have no meaning in this case.
- int idx = Math.round(startLimit + (endLimit - startLimit) * parametricTarget);
- return (labels == null) ? getNumericDisplayString(getValueF()) : labels[idx].getPlainText();
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- // Normalise ox and oy to the centre of the slider
- ox -= width/2;
- ox /= trackLength;
-
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot > -1 && z >= focusObjectZ()){
- downHotSpot = currSpot;
- status = (downHotSpot == THUMB_SPOT) ? PRESS_CONTROL : OFF_CONTROL;
- offset = ox + 0.5f - parametricPos; // normalised
- takeFocus();
- bufferInvalid = true;
- }
- break;
- case MouseEvent.CLICK:
- if(focusIsWith == this ){
- parametricTarget = ox + 0.5f;
- parametricTarget = calcParametricTarget(parametricTarget);
- dragging = false;
- status = OFF_CONTROL;
- loseFocus(null);
- bufferInvalid = true;
- }
- break;
- case MouseEvent.WHEEL:
- if(currSpot > -1 && z >= focusObjectZ()){
- System.out.print(tag + " " + parametricTarget + " " + event.getCount() + " " + wheelDelta + " >>> ");
- parametricTarget = calcParametricTarget(parametricTarget + event.getCount() * wheelDelta * G4P.wheelForSlider);
- System.out.println(parametricTarget);
- }
- break;
- case MouseEvent.RELEASE:
- if(focusIsWith == this && dragging){
- if(downHotSpot == THUMB_SPOT){
- parametricTarget = (ox - offset) + 0.5f;
- if(parametricTarget < 0 || parametricTarget > 1)
- offset = 0;
- parametricTarget = calcParametricTarget(parametricTarget);
-// if(parametricTarget < 0){
-// parametricTarget = 0;
-// offset = 0;
-// }
-// else if(parametricTarget > 1){
-// parametricTarget = 1;
-// offset = 0;
-// }
-// if(stickToTicks)
-// parametricTarget = findNearestTickValueTo(parametricTarget);
- }
- status = OFF_CONTROL;
- bufferInvalid = true;
- loseFocus(null);
- }
- dragging = false;
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this){
- status = DRAG_CONTROL;
- dragging = true;
- if(downHotSpot == THUMB_SPOT){
- parametricTarget = (ox - offset) + 0.5f;
- if(parametricTarget < 0){
- parametricTarget = 0;
- offset = 0;
- }
- else if(parametricTarget > 1){
- parametricTarget = 1;
- offset = 0;
- }
- bufferInvalid = true;
- }
- }
- break;
- case MouseEvent.MOVE:
- int currStatus = status;
- // If dragged state will stay as PRESSED
- if(currSpot == THUMB_SPOT)
- status = OVER_CONTROL;
- else
- status = OFF_CONTROL;
- if(currStatus != status)
- bufferInvalid = true;
- break;
- }
- }
-
-
-
- public void draw(){
- if(!visible) return;
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
- winApp.popMatrix();
-
- winApp.popStyle();
- }
-
- protected void drawValue(Graphics2D g2d){
- float px, py;
- TextLayout line;
- ssValue.setText(getNumericDisplayString(getValueF()));
- line = ssValue.getLines(g2d).getFirst().layout;
- float advance = line.getVisibleAdvance();
- switch(textOrientation){
- case ORIENT_LEFT:
- px = (parametricPos - 0.5f) * trackLength + line.getDescent();
- py = -trackOffset;
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(-PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- break;
- case ORIENT_RIGHT:
- px = (parametricPos - 0.5f) * trackLength - line.getDescent();
- py = - trackOffset - advance;
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- break;
- case ORIENT_TRACK:
- px = (parametricPos - 0.5f) * trackLength - advance /2;
- if(px < -trackDisplayLength/2)
- px = -trackDisplayLength/2;
- else if(px + advance > trackDisplayLength /2)
- px = trackDisplayLength/2 - advance;
- py = -trackOffset - line.getDescent();
- line.draw(g2d, px, py );
- line = ssEndLimit.getLines(g2d).getFirst().layout;
- break;
- }
- }
-
- protected void drawLimits(Graphics2D g2d){
- float px, py;
- TextLayout line;
- if(limitsInvalid){
- ssStartLimit.setText(getNumericDisplayString(startLimit));
- ssEndLimit.setText(getNumericDisplayString(endLimit));
- limitsInvalid = false;
- }
- switch(textOrientation){
- case ORIENT_LEFT:
- line = ssStartLimit.getLines(g2d).getFirst().layout;
- px = -trackLength/2 + line.getDescent();
- py = trackOffset + line.getVisibleAdvance();
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(-PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- line = ssEndLimit.getLines(g2d).getFirst().layout;
- px = trackLength/2 + line.getDescent();
- py = trackOffset + line.getVisibleAdvance();
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(-PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- break;
- case ORIENT_RIGHT:
- line = ssStartLimit.getLines(g2d).getFirst().layout;
- px = -trackLength/2 - line.getDescent();
- py = trackOffset;
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- line = ssEndLimit.getLines(g2d).getFirst().layout;
- px = trackLength/2 - line.getDescent();
- py = trackOffset;
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- break;
- case ORIENT_TRACK:
- line = ssStartLimit.getLines(g2d).getFirst().layout;
- px = -(trackLength + trackWidth)/2;
- py = trackOffset + line.getAscent();
- line.draw(g2d, px, py );
- line = ssEndLimit.getLines(g2d).getFirst().layout;
- px = (trackLength + trackWidth)/2 - line.getVisibleAdvance();
- py = trackOffset + line.getAscent();
- line.draw(g2d, px, py );
- break;
- }
- }
-
- protected void drawLabels(Graphics2D g2d){
- float px, py;
- TextLayout line;
- if(labelsInvalid){
- ssStartLimit.setText(getNumericDisplayString(startLimit));
- ssEndLimit.setText(getNumericDisplayString(endLimit));
- limitsInvalid = false;
- }
- float deltaX = 1.0f / (nbrTicks - 1);
- switch(textOrientation){
- case ORIENT_LEFT:
- for(int i = 0; i < labels.length; i++){
- line = labels[i].getLines(g2d).getFirst().layout;
- px = (i * deltaX - 0.5f)*trackLength + line.getDescent();
- py = trackOffset + line.getVisibleAdvance();
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(-PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- }
- break;
- case ORIENT_RIGHT:
- for(int i = 0; i < labels.length; i++){
- line = labels[i].getLines(g2d).getFirst().layout;
- px = (i * deltaX - 0.5f)*trackLength - line.getDescent();
- py = trackOffset;
- buffer.pushMatrix();
- buffer.translate(px, py);
- buffer.rotate(PI/2);
- line.draw(g2d, 0, 0 );
- buffer.popMatrix();
- }
- break;
- case ORIENT_TRACK:
- for(int i = 0; i < labels.length; i++){
- line = labels[i].getLines(g2d).getFirst().layout;
- px = (i * deltaX - 0.5f)*trackLength - 0.5f * line.getVisibleAdvance();
- py = trackOffset + line.getAscent();
- line.draw(g2d, px, py );
- }
- break;
- }
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GMessenger.java b/Processing/libraries/G4P/src/g4p_controls/GMessenger.java
deleted file mode 100644
index 319d0f7..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GMessenger.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2009 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-/**
- * CLASS FOR INTERNAL USE ONLY
- *
- * @author Peter Lager
- *
- */
-class GMessenger implements GConstants, GConstantsInternal {
-
- /**
- * Display an error message message
- *
- * @param id message ID number
- * @param obj
- * @param info
- */
- static void message(Integer id, Object[] info){
- // Display G4P messages if required
- if(G4P.showMessages){
- switch(id){
- case MISSING:
- missingEventHandler(info);
- break;
- case USER_COL_SCHEME:
- System.out.println("USER DEFINED colour schema active");
- break;
- }
- }
- // Display all runtime errors
- switch(id){
- case NONEXISTANT:
- nonexistantEventHandler(info);
- break;
- case INVALID_TYPE:
- inavlidControlType(info);
- break;
- case INVALID_PAPPLET:
- unmatchedPApplet(info);
- break;
- case EXCP_IN_HANDLER:
- eventHandlerFailed(info);
- break;
- }
- }
-
- /**
- * Error message when an exception is create inside an event handler.
- *
- * info[0] event generator class
- * info[1] event handling method name
- * info[2] the exception thrown
- *
- */
- private static void eventHandlerFailed(Object[] info) {
- String className = info[0].getClass().getSimpleName();
- String methodName = (String) info[1];
- Exception e = (Exception) info[2];
- Throwable t = e.getCause();
- StackTraceElement[] calls = t.getStackTrace();
- StringBuilder output = new StringBuilder();
- output.append("################ EXCEPTION IN EVENT HANDLER ################");
- output.append("\nAn error occured during execution of the eventhandler:");
- output.append("\nCLASS: "+className+" METHOD: "+methodName);
- output.append("\n\tCaused by " + t.toString());
- for(Object line : calls)
- output.append("\n\t"+ line.toString());
- output.append("\n##############################################################\n");
- System.out.println(output);
- }
-
- /**
- * Unable to find the default handler method.
- *
- * info[0] event generator class
- * info[1] event handling method name
- * info[2] the parameter class names
- * info[3] the parameter names (identifiers)
- *
- */
- private static void missingEventHandler(Object[] info) {
- String className = info[0].getClass().getSimpleName();
- String methodName = (String) info[1];
- StringBuilder output = new StringBuilder();
-
- output.append("You might want to add a method to handle " + className + " events syntax is\n");
- output.append("public void " + methodName + "(");
- Class>[] param_classes = (Class[])(info[2]);
- String[] param_names = (String[])(info[3]);
- if(param_classes != null) {
- for(int i = 0; i < param_classes.length; i++){
- String pname = (param_classes[i]).getSimpleName();
- output.append(pname + " " + param_names[i]);
- if(i < param_classes.length - 1)
- output.append(", ");
- }
- }
-
- output.append(") { /* code */ }\n");
- System.out.println(output.toString());
- }
-
- /**
- * Unable to find the user defined handler method.
- *
- * info[0] event generator class
- * info[1] event handling method name
- * info[2] the parameter class names
- *
- */
- private static void nonexistantEventHandler(Object[] info) {
- String className = info[0].getClass().getSimpleName();
- String methodName = (String) info[1];
- String pname;
- StringBuilder output = new StringBuilder();
-
- output.append("The "+className+" class cannot find this method \n");
- output.append("\tpublic void " + methodName + "(");
- Class>[] param_names = (Class[])(info[2]);
- for(int i = 0; i < param_names.length; i++){
- pname = (param_names[i]).getSimpleName();
- output.append(pname + " " + pname.substring(1).toLowerCase());
- if(i < param_names.length - 1)
- output.append(", ");
- }
- output.append(") { /* code */ }\n");
- System.out.println(output.toString());
- }
-
- /**
- * An attempt was made to add a G4P control that does not have a visual appearance or one that
- * does not respond to mouse / keyboard events.
- *
- * info[0] the group class
- * info[1] the G4P control class
- */
- private static void inavlidControlType(Object[] info){
- String groupClassName = info[0].getClass().getSimpleName();
- String className = info[1].getClass().getSimpleName();
-
- System.out.println("Controls of type " + className+" cannot be added to a control group (" + groupClassName + "\n");
- }
-
- /**
- * An attempt was made to add a G4P control that does not have a visual appearance or one that
- * does not respond to mouse / keyboard events.
- *
- * info[0] the group class
- * info[1] the G4P control class
- */
- private static void unmatchedPApplet(Object[] info){
- String groupClassName = info[0].getClass().getSimpleName();
- String className = info[1].getClass().getSimpleName();
- System.out.println("The " + className + " object cannot be added to this control group (" + groupClassName + ") because they are for different windows.\n");
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GOption.java b/Processing/libraries/G4P/src/g4p_controls/GOption.java
deleted file mode 100644
index 282a8dd..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GOption.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-
-/**
- * A two-state toggle control.
- *
- * GOption objects (also known as radio buttons) are two-state toggle switches that can either
- * be used independently or if added to a GToggleGroup control part of a single selection
- * option group.
- *
- * @author Peter Lager
- *
- */
-public class GOption extends GToggleControl{
-
- /**
- * Create an option button without text.
- *
- * @param theApplet that will display the control
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GOption(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, "");
- }
-
- /**
- * Create an option button with text.
- *
- * @param theApplet that will display the control
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param text text to be displayed
- */
- public GOption(PApplet theApplet, float p0, float p1, float p2, float p3, String text) {
- super(theApplet, p0, p1, p2, p3);
- opaque = false;
- setText(text);
- setIcon("pinhead.png", 2, GAlign.LEFT, null);
- setTextAlign(GAlign.LEFT, null);
- z = Z_SLIPPY;
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleToggleControlEvents",
- new Class>[]{ GToggleControl.class, GEvent.class },
- new String[]{ "option", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GPanel.java b/Processing/libraries/G4P/src/g4p_controls/GPanel.java
deleted file mode 100644
index 5f253f1..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GPanel.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.font.TextLayout;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-
-/**
- * A component that can be used to group GUI components that can be
- * dragged, collapsed (leaves title tab only) and un-collapsed.
- *
- * When created the Panel is collapsed by default. To open the panel
- * use setCollapsed(true); after creating it.
- *
- * Once a component has been added the x/y coordinates of the control are
- * calculated to be the centre of the panel to the centre of the control. This
- * is to facilitate rotating of controls on panels
- *
- * @author Peter Lager
- *
- */
-public class GPanel extends GTextBase {
-
- static protected int COLLAPSED_BAR_SPOT = 1;
- static protected int EXPANDED_BAR_SPOT = 2;
- static protected int SURFACE_SPOT = 0;
-
-
- /** Whether the panel is displayed in full or tab only */
- protected boolean tabOnly = false;
-
- /** The height of the tab calculated from font height + padding */
- protected int tabHeight, tabWidth;
-
- /** Used to restore position when closing panel */
- protected float dockX, dockY;
-
- // Defines the area that the panel must fit inside.
- protected float lowX, highX, lowY, highY;
-
- /** true if the panel is being dragged */
- protected boolean beingDragged = false;
-
- protected boolean draggable = true;
- protected boolean collapsible = true;
-
-
- /**
- * Create a Panel that comprises of 2 parts the tab which is used to
- * select and move the panel and the container window below the tab which
- * is used to hold other components.
- * If the panel fits inside the display window then its position will be
- * constrained so that it can't be dragged outside the viewable area.
- * Otherwise no constraint is applied.
- *
- * @param theApplet the PApplet reference
- * @param p0 horizontal position
- * @param p1 vertical position
- * @param p2 width of the panel
- * @param p3 height of the panel (excl. tab)
- */
- public GPanel(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, "Panel ");
- }
-
- /**
- * Create a Panel that comprises of 2 parts the tab which is used to
- * select and move the panel and the container window below the tab which
- * is used to hold other components.
- * If the panel fits inside the display window then its position will be
- * constrained so that it can't be dragged outside the viewable area.
- * Otherwise no constraint is applied.
- *
- * @param theApplet the PApplet reference
- * @param p0 horizontal position
- * @param p1 vertical position
- * @param p2 width of the panel
- * @param p3 height of the panel (excl. tab)
- * @param text to appear on tab
- */
- public GPanel(PApplet theApplet, float p0, float p1, float p2, float p3, String text) {
- super(theApplet, p0, p1, p2, p3);
- // Set the values used to constrain movement of the panel
- if(x < 0 || y < 0 || x + width > winApp.width || y+ height > winApp.height)
- clearDragArea();
- else
- setDragArea();
- // Create the list of children
- children = new LinkedList();
- setText(text);
- calcHotSpots();
- constrainPanelPosition();
- opaque = true;
- dockX = x;
- dockY = y;
- z = Z_PANEL;
-
- createEventHandler(G4P.sketchWindow, "handlePanelEvents",
- new Class>[]{ GPanel.class, GEvent.class },
- new String[]{ "panel", "event" }
- );
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- /**
- * This needs to be called if the tab text is changed
- */
- private void calcHotSpots(){
- hotspots = new HotSpot[]{
- new HSrect(COLLAPSED_BAR_SPOT, 0, 0, tabWidth, tabHeight), // tab text area
- new HSrect(EXPANDED_BAR_SPOT, 0, 0, width, tabHeight), // tab non-text area
- new HSrect(SURFACE_SPOT, 0, tabHeight, width, height - tabHeight) // panel content surface
- };
- }
-
- /**
- * This panel is being added to another additional changes that need to be made this control
- * is added to another.
- *
- * In this case we need to set the constraint limits to keep inside the parent.
- *
- * @param p the parent
- */
- protected void addToParent(GAbstractControl p){
- // Will this fit inside the parent panel
- if(width > p.width || height > p.height){ //No
- draggable = false;
- }
- else {
- lowX = -p.width/2;
- highX = p.width/2;
- lowY = -p.height/2;
- highY = p.height/2;
- }
- }
-
- public void setText(String text){
- super.setText(text);
- buffer.beginDraw();
- stext.getLines(buffer.g2);
- buffer.endDraw();
- tabHeight = (int) (stext.getMaxLineHeight() + 4);
- tabWidth = (int) (stext.getMaxLineLength() + 8);
- calcHotSpots();
- bufferInvalid = true;
- }
-
- public void setFont(Font font) {
- if(font != null)
- localFont = font;
- tabHeight = (int) (1.2f * localFont.getSize() + 2);
- buffer.g2.setFont(localFont);
- bufferInvalid = true;
- calcHotSpots();
- bufferInvalid = true;
- }
-
- /**
- * What to do when the FPanel loses focus.
- */
- protected void loseFocus(GAbstractControl grabber){
- focusIsWith = null;
- beingDragged = false;
- }
-
- /**
- * Draw the panel.
- * If tabOnly == true
- * then display the tab only
- * else
- * draw tab and all child (added) components
- */
- public void draw(){
- if(!visible) return;
- winApp.pushStyle();
- // Update buffer if invalid
- updateBuffer();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // If opaque draw the panel tab and back
- if(opaque){
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
- }
- // Draw the children
- if(!tabOnly){
- if(children != null){
- for(GAbstractControl c : children)
- c.draw();
- }
- }
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
- buffer.clear();
- // Draw tab
- buffer.noStroke();
- buffer.fill(palette[4].getRGB());
- if(tabOnly){
- buffer.rect(0, 0, tabWidth, tabHeight);
- }
- else {
- buffer.rect(0, 0, width, tabHeight);
- }
- // Draw tab text (panel name)
- stext.getLines(g2d);
- g2d.setColor(palette[2]);
- TextLayout tl = stext.getTLIforLineNo(0).layout;
- tl.draw(g2d, 4, 2 + tl.getAscent());
- // Draw extended panel background
- if(!tabOnly){
- buffer.noStroke();
- buffer.fill(palette[5].getRGB());
- buffer.rect(0, tabHeight, width, height - tabHeight);
- }
- buffer.endDraw();
- }
- }
-
- /**
- * Determines if a particular pixel position is over the panel taking
- * into account whether it is collapsed or not.
- */
- public boolean isOver(float x, float y){
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- return (tabOnly)? currSpot == COLLAPSED_BAR_SPOT : currSpot == EXPANDED_BAR_SPOT | currSpot == COLLAPSED_BAR_SPOT;
- }
-
- /**
- * All GUI components are registered for mouseEvents
- */
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
-
- currSpot = whichHotSpot(ox, oy);
- // Is mouse over the panel tab (taking into account extended with when not collapsed)
- boolean mouseOver = (tabOnly)? currSpot == COLLAPSED_BAR_SPOT : currSpot == EXPANDED_BAR_SPOT | currSpot == COLLAPSED_BAR_SPOT;
-
- if(mouseOver || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && mouseOver && z >= focusObjectZ()){
- takeFocus();
- beingDragged = false;
- }
- break;
- case MouseEvent.CLICK:
- if(focusIsWith == this && collapsible){
- tabOnly = !tabOnly;
- // Perform appropriate action depending on collapse state
- setCollapsed(tabOnly);
- if(tabOnly){
- x = dockX;
- y = dockY;
- }
- else {
- dockX = x;
- dockY = y;
- // Open panel move on screen if needed
- if(y + height > winApp.height)
- y = winApp.height - height;
- if(x + width > winApp.width)
- x = winApp.width - width;
- }
- // Maintain centre for drawing purposes
- cx = x + width/2;
- cy = y + height/2;
- constrainPanelPosition();
- if(tabOnly)
- fireEvent(this, GEvent.COLLAPSED);
- else
- fireEvent(this, GEvent.EXPANDED);
- bufferInvalid = true;
- beingDragged = false;
- // This component does not keep the focus when clicked
- loseFocus(null);
- }
- break;
- case MouseEvent.RELEASE: // After dragging NOT clicking
- if(focusIsWith == this){
- if(beingDragged){
- // Remember the dock position when the mouse has
- // been released after the panel has been dragged
- dockX = x;
- dockY = y;
- beingDragged = false;
- loseFocus(null);
- }
- }
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this && draggable ){//&& parent == null){
- // Maintain centre for drawing purposes
- cx += (winApp.mouseX - winApp.pmouseX);
- cy += (winApp.mouseY - winApp.pmouseY);
- // Update x and y positions
- x = cx - width/2;
- y = cy - height/2;
- constrainPanelPosition();
- beingDragged = true;
- fireEvent(this, GEvent.DRAGGED);
- }
- break;
- }
- }
-
- /**
- * Determines whether to show the tab and panel back colour. If the
- * parameter is the same as the current state then no changes will
- * be made.
- * If the parameter is false then the panel will be
- *
- *
expanded
- *
made non-collasible
- *
made unavailable to mouse control (so can't be dragged)
- *
- * If the parameter is true then the panel will remain non-collapsible
- * and the user must change this if required.
- * @param opaque
- */
- public void setOpaque(boolean opaque){
- if(this.opaque == opaque)
- return; // no change
- if(!opaque){
- setCollapsed(false);
- setCollapsible(false);
- }
- available = opaque;
- this.opaque = opaque;
- }
-
- /**
- * This method is used to discover whether the panel is being
- * dragged to a new position on the screen.
- * @return true if being dragged to a new position
- */
- public boolean isDragging(){
- return beingDragged;
- }
-
- /**
- * Sets whether the panel can be dragged by the mouse or not.
- * @param draggable
- */
- public void setDraggable(boolean draggable){
- this.draggable = draggable;
- }
-
- /**
- * Can we drag this panel with the mouse?
- * @return true if draggable
- */
- public boolean isDraggable(){
- return draggable;
- }
-
- /**
- * Collapse or open the panel
- * @param collapse
- */
- public void setCollapsed(boolean collapse){
- if(collapsible){
- tabOnly = collapse;
- // If we open the panel make sure it fits on the screen but if we collapse
- // the panel disable the panel controls but leave the panel available
- if(tabOnly){
- setAvailable(false);
- available = true; // Needed so we can click on the title bar
- }
- else {
- setAvailable(true);
- }
- }
- }
-
- /**
- * Find out if the panel is collapsed
- * @return true if collapsed
- */
- public boolean isCollapsed(){
- return tabOnly;
- }
-
- /**
- * Determine whether the panel can be collapsed when the title bar is clicked.
- *
- * If this is set to false then the panel will be expanded and it will
- * not be possible to collapse it until set back to true.
- *
- */
- public void setCollapsible(boolean c){
- collapsible = c;
- if(c == false){
- tabOnly = false;
- setAvailable(true);
- }
- }
-
- /**
- * Is this panel collapsible
- */
- public boolean isCollapsible(){
- return collapsible;
- }
-
- public int getTabHeight(){
- return tabHeight;
- }
-
- /**
- * Provided the panel is physically small enough this method will set the area
- * within which the panel can be dragged and move the panel inside the area if
- * not already inside.
- *
- * @param xMin
- * @param yMin
- * @param xMax
- * @param yMax
- * @return true if the constraint was applied successfully else false
- */
- public boolean setDragArea(float xMin, float yMin, float xMax, float yMax){
- if(xMax - xMin < width || yMax - yMin < height){
- if(G4P.showMessages)
- System.out.println("The constraint area is too small for this panel - request ignored");
- return false;
- }
- lowX = xMin;
- lowY = yMin;
- highX = xMax;
- highY = yMax;
- constrainPanelPosition();
- return true;
- }
-
- /**
- * Provided the panel is small enough to fit inside the display area then
- * the panel will be constrained to fit inside the display area.
- *
- * @return true if the constraint was applied successfully else false
- */
- public boolean setDragArea(){
- return setDragArea(0, 0, winApp.width, winApp.height);
- }
-
- /**
- * Remove any drag constraint from this panel.
- */
- public void clearDragArea(){
- lowX = lowY = -Float.MAX_VALUE;
- highX = highY = Float.MAX_VALUE;
- }
-
- /**
- * Ensures that the panel tab and panel body if open does not
- * extend off the screen.
- */
- private void constrainPanelPosition(){
- // Calculate the size of the visible part of the panel
- int w = (int) ((tabOnly)? tabWidth : width);
- int h = (int) ((tabOnly)? tabHeight : height);
- // Constrain horizontally
- if(x < lowX)
- x = lowX;
- else if(x + w > highX)
- x = (int) (highX - w);
- // Constrain vertically
- if(y < lowY)
- y = lowY;
- else if(y + h > highY)
- y = highY - h;
- // Maintain centre for
- cx = x + width/2;
- cy = y + height/2;
- }
-
-
- public String toString(){
- return tag + " [" + x + ", " + y+"]" + " [" + cx + ", " + cy+"]"+ " [" + dockX + ", " + dockY+"]";
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GPassword.java b/Processing/libraries/G4P/src/g4p_controls/GPassword.java
deleted file mode 100644
index 658b9aa..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GPassword.java
+++ /dev/null
@@ -1,757 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2014 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-import g4p_controls.StyledString.TextLayoutHitInfo;
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Font;
-import java.awt.Graphics2D;
-import java.awt.font.TextHitInfo;
-import java.awt.font.TextLayout;
-import java.awt.geom.GeneralPath;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-import processing.awt.PGraphicsJava2D;
-import processing.event.KeyEvent;
-import processing.event.MouseEvent;
-
-/**
- * The password field component.
- *
- * This control allows the user to secretly enter a password and supports an
- * optional horizontal scrollbar.
- *
- * Each key typed will display a # character, but the user can specify another character.
- *
- * Unlike a text field it does not support text selection or the copying and pasting of
- * text via the clipboard.
- *
- * Fires CHANGED, ENTERED, LOST_FOCUS, GETS_FOCUS events.
- * The focus events are only fired if the control is added to a GTabManager object.
- *
- * @author Peter Lager
- *
- */
-public final class GPassword extends GAbstractControl implements Focusable{
-
- protected TextLayoutHitInfo cursorTLHI = new TextLayoutHitInfo();
-
- private static char cover = '#';
-
- private StyledString stext = new StyledString(" ");
- private StyledString hidden = new StyledString(" ");
- private int maxWordLength = 10;
- private int wordLength = 0;
-
- GTabManager tabManager = null;
-
- // The width to break a line
- protected int wrapWidth = Integer.MAX_VALUE;
-
- // The typing area
- protected float tx,ty,th,tw;
- // Offset to display area
- protected float ptx, pty;
- // Caret position
- protected float caretX, caretY;
-
- protected boolean keepCursorInView = false;
-
- protected GeneralPath gpTextDisplayArea;
-
- // Used for identifying selection and cursor position
- protected TextLayoutHitInfo startTLHI = new TextLayoutHitInfo();
- protected TextLayoutHitInfo endTLHI = new TextLayoutHitInfo();
-
- // The scrollbars available
-// protected final int scrollbarPolicy;
-// protected boolean autoHide = false;
-// protected GScrollbar hsb, vsb;
-
- protected GTimer caretFlasher;
- protected boolean showCaret = false;
-
- // Stuff to manage text selections
- protected int endChar = -1, startChar = -1, pos = endChar, nbr = 0, adjust = 0;
- protected boolean textChanged = false;
-
- protected Font localFont = G4P.globalFont;
-
- /**
- * Create a password field without a scrollbar.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GPassword(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, SCROLLBARS_NONE);
- }
-
- /**
- * Create a password field with the given scrollbar policy.
- * This policy can be one of these
- *
- *
SCROLLBARS_NONE
- *
SCROLLBARS_HORIZONTAL_ONLY
- *
- * If you want the scrollbar to auto hide then perform a logical or with
- *
- *
SCROLLBARS_AUTOHIDE
- *
- * e.g. SCROLLBARS_HORIZONTAL_ONLY | SCROLLBARS_AUTOHIDE
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param sbPolicy
- */
- public GPassword(PApplet theApplet, float p0, float p1, float p2, float p3, int sbPolicy) {
- super(theApplet, p0, p1, p2, p3);
-// scrollbarPolicy = sbPolicy;
-// autoHide = ((sbPolicy & SCROLLBARS_AUTOHIDE) == SCROLLBARS_AUTOHIDE);
- caretFlasher = new GTimer(theApplet, this, "flashCaret", 400);
- caretFlasher.start();
- opaque = true;
- cursorOver = TEXT;
-
- setVisibleChar(cover);
- children = new LinkedList();
- tx = ty = 2;
- tw = width - 2 * 2;
-// th = height - ((scrollbarPolicy & SCROLLBAR_HORIZONTAL) != 0 ? 11 : 0);
- th = height;
- gpTextDisplayArea = new GeneralPath();
- gpTextDisplayArea.moveTo( 0, 0);
- gpTextDisplayArea.lineTo( 0, th);
- gpTextDisplayArea.lineTo(tw, th);
- gpTextDisplayArea.lineTo(tw, 0);
- gpTextDisplayArea.closePath();
-
- hotspots = new HotSpot[]{
- new HSrect(1, tx, ty, tw, th), // typing area
- new HSrect(9, 0, 0, width, height) // control surface
- };
-
- G4P.pushStyle();
- G4P.showMessages = false;
-
- z = Z_STICKY;
-
- G4P.control_mode = GControlMode.CORNER;
-// if((scrollbarPolicy & SCROLLBAR_HORIZONTAL) != 0){
-// hsb = new GScrollbar(theApplet, 0, 0, tw, 10);
-// addControl(hsb, tx, ty + th + 2, 0);
-// hsb.addEventHandler(this, "hsbEventHandler");
-// hsb.setAutoHide(autoHide);
-// }
- G4P.popStyle();
- // z = Z_STICKY;
- createEventHandler(G4P.sketchWindow, "handlePasswordEvents",
- new Class>[]{ GPassword.class, GEvent.class },
- new String[]{ "pwordControl", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD | KEY_METHOD;
- // Must register control
- G4P.registerControl(this);
- bufferInvalid = true;
- }
-
- /**
- * Set the character that will be displayed instead of the actual character
- * entered by the user.
- * Default value is '#'
- */
- public void setVisibleChar(char c){
- int ascii = (int) c;
- if((ascii >= 33 && ascii <= 255 && ascii != 127) || ascii == 8364)
- cover = c;
- }
-
- /**
- * Get the current password (hidden) value of this field.
- * @return actual password text
- */
- public String getPassword(){
- String password = hidden.getPlainText();
- return password.equals(" ") ? "" : password;
- }
-
- /**
- * Get the current length of the password entered.
- */
- public int getWordLength(){
- return wordLength;
- }
-
- /**
- * Sets the max length of the password. This method is ignored if the control
- * already holds some user input.
- * The default value is 10.
- * @param ml the new max length (must be >= 1)
- */
- public void setMaxWordLength(int ml){
- if(wordLength == 0 && ml >= 1)
- maxWordLength = ml;
- }
-
- /**
- * Set the font to be used in this control
- *
- * @param font AWT font to use
- */
- public void setFont(Font font) {
- if(font != null && font != localFont && buffer != null){
- localFont = font;
- buffer.g2.setFont(localFont);
- bufferInvalid = true;
- }
- }
-
- public PGraphics getSnapshot(){
- updateBuffer();
- PGraphicsJava2D snap = (PGraphicsJava2D) winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
- snap.beginDraw();
- snap.image(buffer,0,0);
-// if(hsb != null){
-// snap.pushMatrix();
-// snap.translate(hsb.getX(), hsb.getY());
-// snap.image(hsb.getBuffer(), 0, 0);
-// snap.popMatrix();
-// }
- snap.endDraw();
- return snap;
- }
-
- public void pre(){
- if(keepCursorInView){
- boolean horzScroll = false;
- float max_ptx = caretX - tw + 2;
- if(endTLHI != null){
- if(ptx > caretX){ // Scroll to the left (text moves right)
- ptx -= HORZ_SCROLL_RATE;
- if(ptx < 0) ptx = 0;
- horzScroll = true;
- }
- else if(ptx < max_ptx){ // Scroll to the right (text moves left)?
- ptx += HORZ_SCROLL_RATE;
- if(ptx > max_ptx) ptx = max_ptx;
- horzScroll = true;
- }
- // Ensure that we show as much text as possible keeping the caret in view
- // This is particularly important when deleting from the end of the text
- if(ptx > 0 && endTLHI.tli.layout.getAdvance() - ptx < tw - 2){
- ptx = Math.max(0, endTLHI.tli.layout.getAdvance() - tw - 2);
- horzScroll = true;
- }
-// if(horzScroll && hsb != null)
-// hsb.setValue(ptx / (stext.getMaxLineLength() + 4));
- }
- // If we have scrolled invalidate the buffer otherwise forget it
- if(horzScroll)
- bufferInvalid = true;
- else
- keepCursorInView = false;
- }
- }
-
- /**
- * Do not call this directly. A timer calls this method as and when required.
- */
- public void flashCaret(GTimer timer){
- showCaret = !showCaret;
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- ox -= tx; oy -= ty; // Remove translation
-
- currSpot = whichHotSpot(ox, oy);
-
- if(currSpot == 1 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(currSpot == 1){
- if(focusIsWith != this && z >= focusObjectZ()){
- keepCursorInView = true;
- takeFocus();
- }
- dragging = false;
- if(stext == null || stext.length() == 0){
- stext = new StyledString(" ", wrapWidth);
- stext.getLines(buffer.g2);
- }
- endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
- startTLHI = new TextLayoutHitInfo(endTLHI);
- calculateCaretPos(endTLHI);
- bufferInvalid = true;
- }
- else { // Not over this control so if we have focus loose it
- if(focusIsWith == this)
- loseFocus(null);
- }
- break;
- case MouseEvent.RELEASE:
- dragging = false;
- bufferInvalid = true;
- break;
- }
- }
-
- public void keyEvent(KeyEvent e) {
- if(!visible || !enabled || !available) return;
- if(focusIsWith == this && endTLHI != null){
- char keyChar = e.getKey();
- int keyCode = e.getKeyCode();
- int keyID = e.getAction();
- boolean shiftDown = e.isShiftDown();
- boolean ctrlDown = e.isControlDown();
-
- textChanged = false;
- keepCursorInView = true;
-
-// int startPos = pos, startNbr = nbr;
-
- // Get selection details
- endChar = endTLHI.tli.startCharIndex + endTLHI.thi.getInsertionIndex();
- startChar = (startTLHI != null) ? startTLHI.tli.startCharIndex + startTLHI.thi.getInsertionIndex() : endChar;
- pos = endChar;
- nbr = 0;
- adjust = 0;
- if(endChar != startChar){ // Have we some text selected?
- if(startChar < endChar){ // Forward selection
- pos = startChar; nbr = endChar - pos;
- }
- else if(startChar > endChar){ // Backward selection
- pos = endChar; nbr = startChar - pos;
- }
- }
- // Select either keyPressedProcess or keyTypeProcess. These two methods are overridden in child classes
- if(keyID == KeyEvent.PRESS) {
- keyPressedProcess(keyCode, keyChar, shiftDown, ctrlDown);
-// setScrollbarValues(ptx, pty);
- }
- else if(keyID == KeyEvent.TYPE ){ // && e.getKey() != KeyEvent.CHAR_UNDEFINED && !ctrlDown){
- keyTypedProcess(keyCode, keyChar, shiftDown, ctrlDown);
-// setScrollbarValues(ptx, pty);
- }
- if(textChanged){
- changeText();
- fireEvent(this, GEvent.CHANGED);
- }
- }
- }
-
- protected void keyPressedProcess(int keyCode, char keyChar, boolean X, boolean ctrlDown){
- boolean cursorMoved = true;
- switch(keyCode){
- case LEFT:
- moveCaretLeft(endTLHI);
- break;
- case RIGHT:
- moveCaretRight(endTLHI);
- break;
- case GConstants.HOME:
- moveCaretStartOfLine(endTLHI);
- break;
- case GConstants.END:
- moveCaretEndOfLine(endTLHI);
- break;
- default:
- cursorMoved = false;
- }
- if(cursorMoved){
- calculateCaretPos(endTLHI);
- startTLHI.copyFrom(endTLHI);
- }
- }
-
- protected void keyTypedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown){
- int ascii = (int)keyChar;
- if(isDisplayable(ascii) && wordLength < maxWordLength){
- if(hidden.getPlainText().equals(" ")){
- stext.setText(""+cover);
- hidden.setText(""+keyChar);
- }
- else {
- stext.insertCharacters( "" + cover, pos);
- hidden.insertCharacters("" + keyChar, pos);
- }
- wordLength++;
- adjust = 1; textChanged = true;
- }
- else if(keyChar == BACKSPACE){
- if(stext.deleteCharacters(pos - 1, 1)){
- hidden.deleteCharacters(pos - 1, 1);
- wordLength = --wordLength < 0 ? 0: wordLength;
- adjust = -1; textChanged = true;
- }
- }
- else if(keyChar == DELETE){
- if(stext.deleteCharacters(pos, 1)){
- hidden.deleteCharacters(pos, 1);
- wordLength--;
- adjust = 0; textChanged = true;
- }
- }
- else if(keyChar == ENTER || keyChar == RETURN) {
- fireEvent(this, GEvent.ENTERED);
- // If we have a tab manager and can tab forward then do so
- if(tabManager != null && tabManager.nextControl(this)){
- startTLHI.copyFrom(endTLHI);
- return;
- }
- }
- else if(keyChar == TAB){
- // If possible move to next text control
- if(tabManager != null){
- boolean result = (shiftDown) ? tabManager.prevControl(this) : tabManager.nextControl(this);
- if(result){
- startTLHI.copyFrom(endTLHI);
- return;
- }
- }
- }
- // If we have emptied the text then recreate a one character string (space)
- if(stext.length() == 0){
- stext.insertCharacters(" ", 0);
- hidden.insertCharacters(" ", 0);
- adjust++; textChanged = true;
- }
- }
-
- protected boolean changeText(){
- TextLayoutInfo tli;
- TextHitInfo thi = null, thiRight = null;
-
- pos += adjust;
- // Force layouts to be updated
- stext.getLines(buffer.g2);
-
- // Try to get text layout info for the current position
- tli = stext.getTLIforCharNo(pos);
- if(tli == null){
- // If unable to get a layout for pos then reset everything
- endTLHI = null;
- startTLHI = null;
- ptx = pty = 0;
- caretX = caretY = 0;
- return false;
- }
- // We have a text layout so we can do something
- // First find the position in line
- int posInLine = pos - tli.startCharIndex;
-
- // Get some hit info so we can see what is happening
- try{
- thiRight = tli.layout.getNextRightHit(posInLine);
- }
- catch(Exception excp){
- thiRight = null;
- }
-
- if(posInLine <= 0){ // At start of line
- thi = tli.layout.getNextLeftHit(thiRight);
- }
- else if(posInLine >= tli.nbrChars){ // End of line
- thi = tli.layout.getNextRightHit(tli.nbrChars - 1);
- }
- else { // Character in line;
- thi = tli.layout.getNextLeftHit(thiRight);
- }
-
- endTLHI.setInfo(tli, thi);
- // Cursor at end of paragraph graphic
- calculateCaretPos(endTLHI);
- bufferInvalid = true;
-
- startTLHI.copyFrom(endTLHI);
- return true;
- }
-
- public void draw(){
- if(!visible) return;
- updateBuffer();
-
- winApp.pushStyle();
- winApp.pushMatrix();
-
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
-
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
-
- // Draw caret if text display area
- if(focusIsWith == this && showCaret && endTLHI.tli != null){
- float[] cinfo = endTLHI.tli.layout.getCaretInfo(endTLHI.thi);
- float x_left = - ptx + cinfo[0];
- float y_top = - pty + endTLHI.tli.yPosInPara;
- float y_bot = y_top - cinfo[3] + cinfo[5];
- if(x_left >= 0 && x_left <= tw && y_top >= 0 && y_bot <= th){
- winApp.strokeWeight(1.9f);
- winApp.stroke(palette[12].getRGB());
- winApp.line(tx+x_left, ty+Math.max(0, y_top), tx+x_left, ty+Math.min(th, y_bot));
- }
- }
-
- winApp.popMatrix();
-
- if(children != null){
- for(GAbstractControl c : children)
- c.draw();
- }
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- /**
- * If the buffer is invalid then redraw it.
- * @TODO need to use palette for colours
- */
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
-
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
-
- // Whole control surface if opaque
- if(opaque)
- buffer.background(palette[6].getRGB());
- else
- buffer.background(buffer.color(255,0));
-
- // Now move to top left corner of text display area
- buffer.translate(tx,ty);
-
- // Typing area surface
- buffer.noStroke();
- buffer.fill(palette[7].getRGB());
- buffer.rect(-1,-1,tw+2,th+2);
-
- g2d.setClip(gpTextDisplayArea);
- buffer.translate(-ptx, -pty);
- // Translate in preparation for display selection and text
-
- // Display selection and text
- for(TextLayoutInfo lineInfo : lines){
- TextLayout layout = lineInfo.layout;
- buffer.translate(0, layout.getAscent());
- // Draw text
- g2d.setColor(palette[2]);
- lineInfo.layout.draw(g2d, 0, 0);
- buffer.translate(0, layout.getDescent() + layout.getLeading());
- }
- g2d.setClip(null);
- buffer.endDraw();
- }
- }
-
- /**
- * Give up focus but if the text is only made from spaces
- * then set it to null text.
- * Fire focus events for the GTextField and GTextArea controls
- */
- protected void loseFocus(GAbstractControl grabber){
- // If this control has focus then Fire a lost focus event
- if(focusIsWith == this)
- fireEvent(this, GEvent.LOST_FOCUS);
- // Process mouse-over cursor
- if(cursorIsOver == this)
- cursorIsOver = null;
- focusIsWith = grabber;
- // If only blank text clear it out allowing default text (if any) to be displayed
- if(stext.length() > 0){
- int tl = stext.getPlainText().trim().length();
- if(tl == 0)
- stext.setText("", wrapWidth);
- }
- keepCursorInView = true;
- bufferInvalid = true;
- }
-
- /**
- * Give the focus to this component but only after allowing the
- * current component with focus to release it gracefully.
- * Always cancel the keyFocusIsWith irrespective of the component
- * type.
- * Fire focus events for the GTextField and GTextArea controls
- */
- protected void takeFocus(){
- // If focus is not yet with this control fire a gets focus event
- if(focusIsWith != this){
- // If the focus is with another control then tell
- // that control to lose focus
- if(focusIsWith != null)
- focusIsWith.loseFocus(this);
- fireEvent(this, GEvent.GETS_FOCUS);
- }
- focusIsWith = this;
- }
-
- /**
- * Determines whether this component is to have focus or not.
- */
- public void setFocus(boolean focus){
- if(!focus){
- loseFocus(null);
- return;
- }
- // Make sure we have some text
- if(focusIsWith != this){
- dragging = false;
- if(stext == null || stext.length() == 0)
- stext.setText(" ", wrapWidth);
- LinkedList lines = stext.getLines(buffer.g2);
- startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-
- endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
- int lastChar = endTLHI.tli.layout.getCharacterCount();
- endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
- startTLHI.copyFrom(endTLHI);
-
- calculateCaretPos(endTLHI);
- bufferInvalid = true;
- }
- keepCursorInView = true;
- takeFocus();
- }
-
-
- /**
- * Calculate the caret (text insertion point)
- *
- * @param tlhi
- */
- protected void calculateCaretPos(TextLayoutHitInfo tlhi){
- float temp[] = tlhi.tli.layout.getCaretInfo(tlhi.thi);
- caretX = temp[0];
- caretY = tlhi.tli.yPosInPara;
- }
-
- /**
- * Move caret to home position
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretStartOfLine(TextLayoutHitInfo currPos){
- if(currPos.thi.getCharIndex() == 0)
- return false; // already at start of line
- currPos.thi = currPos.tli.layout.getNextLeftHit(1);
- return true;
- }
-
- /**
- * Move caret to the end of the line that has the current caret position
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretEndOfLine(TextLayoutHitInfo currPos){
- if(currPos.thi.getCharIndex() == currPos.tli.nbrChars - 1)
- return false; // already at end of line
- currPos.thi = currPos.tli.layout.getNextRightHit(currPos.tli.nbrChars - 1);
- return true;
- }
-
- /**
- * Move caret left by one character.
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretLeft(TextLayoutHitInfo currPos){
- TextHitInfo nthi = currPos.tli.layout.getNextLeftHit(currPos.thi);
- if(nthi == null){
- return false;
- }
- else {
- // Move the caret to the left of current position
- currPos.thi = nthi;
- }
- return true;
- }
-
- /**
- * Move caret right by one character.
- * @param currPos the current position of the caret
- * @return true if caret moved else false
- */
- protected boolean moveCaretRight(TextLayoutHitInfo currPos){
- TextHitInfo nthi = currPos.tli.layout.getNextRightHit(currPos.thi);
- if(nthi == null){
- return false;
- }
- else {
- currPos.thi = nthi;
- }
- return true;
- }
-
-// public void setJustify(boolean justify){
-// stext.setJustify(justify);
-// bufferInvalid = true;
-// }
-
- /**
- * Sets the local colour scheme for this control
- */
- public void setLocalColorScheme(int cs){
- super.setLocalColorScheme(cs);
-// if(hsb != null)
-// hsb.setLocalColorScheme(localColorScheme);
-// if(vsb != null)
-// vsb.setLocalColorScheme(localColorScheme);
- }
-
- @Override
- public void setTabManager(GTabManager tm){
- tabManager = tm;
- }
-
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GScrollbar.java b/Processing/libraries/G4P/src/g4p_controls/GScrollbar.java
deleted file mode 100644
index bcfb9be..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GScrollbar.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-/**
- * This class is only used by the GDropList, GTextField and GTextArea components to provide
- * a scrollbar.
- *
- * @author Peter Lager
- *
- */
-class GScrollbar extends GAbstractControl {
-
- private static float CORNER_RADIUS = 6;
- private static final int TRACK = 5;
-
- protected float value = 0.2f;
- protected float filler = .5f;
- protected boolean autoHide = true;
- protected boolean currOverThumb = false;
- protected boolean isValueChanging = false;
-
- protected float last_ox, last_oy;
-
- /**
- * Create the scroll bar
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GScrollbar(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- hotspots = new HotSpot[]{
- new HSrect(1, 0, 0, 16, height), // low cap
- new HSrect(2, width - 16, 0, 16, height), // high cap
- new HSrect(9, 17, 0, width - 17, height) // thumb track
- };
-
- opaque = false;
- z = Z_SLIPPY;
- registeredMethods = DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- // Must register control
- G4P.registerControl(this);
- }
-
- /**
- * If set to true then the scroll bar is only displayed when needed.
- *
- * @param autoHide
- */
- public void setAutoHide(boolean autoHide){
- if(this.autoHide != autoHide){
- this.autoHide = autoHide;
- if(this.autoHide && filler > 0.99999f)
- visible = false;
- bufferInvalid = true;
- }
- }
-
- /**
- * Set the position of the thumb. If the value forces the thumb
- * past the end of the scrollbar, reduce the filler.
- *
- * @param value must be in the range 0.0 to 1.0
- */
- public void setValue(float value){
- if(value + filler > 1)
- filler = 1 - value;
- this.value = value;
- if(autoHide && filler > 0.99999f)
- visible = false;
- else
- visible = true;
- bufferInvalid = true;
- }
-
- /**
- * Set the value and the thumb size. Force the value to be valid
- * depending on filler.
- * @param value must be in the range 0.0 to 1.0
- * @param filler must be >0 and <= 1
- */
- public void setValue(float value, float filler){
- if(value + filler > 1)
- value = 1 - filler;
- this.value = value;
- this.filler = filler;
- if(autoHide && this.filler > 0.99999f)
- visible = false;
- else
- visible = true;
- bufferInvalid = true;
- }
-
- /**
- * Get the current value of the scrolbar
- * @return
- */
- public float getValue(){
- return value;
- }
-
- /**
- * All GUI components are registered for mouseEvents
- */
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
-
- int spot = whichHotSpot(ox, oy);
-
- // If over the track then see if we are over the thumb
- if(spot >= 9 && isOverThumb(ox, oy))
- spot = 10;
-
-// if(spot >= 9){
-// if(isOverThumb(ox, oy))
-// spot = 10;
-// else
-// spot = -1; // Over empty track so ignore
-// }
- if(spot != currSpot){
- currSpot = spot;
- bufferInvalid = true;
- }
-
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot>= 0 && z > focusObjectZ()){
- dragging = false;
- last_ox = ox; last_oy = oy;
- takeFocus();
- }
- break;
- case MouseEvent.CLICK:
- if(focusIsWith == this){
- switch(currSpot){
- case 1:
- value -= 0.1f;
- if(value < 0)
- value = 0;
- bufferInvalid = true;
- fireEvent(this, GEvent.CHANGED);
- break;
- case 2:
- value += 0.1f;
- if(value + filler > 1.0)
- value = 1 - filler;
- bufferInvalid = true;
- fireEvent(this, GEvent.CHANGED);
- break;
- }
- dragging = false;
- loseFocus(parent);
- }
- break;
- case MouseEvent.WHEEL:
- if(currSpot > -1 && z >= focusObjectZ()){
- float pv = value + event.getCount() * 0.01f * G4P.wheelForScrollbar;
- pv = pv < 0 ? 0 : pv > 1 ? 1 : pv;
- setValue(pv, filler);
- isValueChanging = true;
- bufferInvalid = true;
- dragging = true;
- fireEvent(this, GEvent.CHANGED);
- }
- break;
- case MouseEvent.RELEASE:
- if(focusIsWith == this && dragging){
- loseFocus(parent);
- dragging = false;
- isValueChanging = false;
- bufferInvalid = true;
- }
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this && spot == 10){
- float movement = ox - last_ox;
- last_ox = ox;
- float deltaV = movement / (width - 32);
- value += deltaV;
- value = PApplet.constrain(value, 0, 1.0f - filler);
- isValueChanging = true;
- bufferInvalid = true;
- dragging = true;
- fireEvent(this, GEvent.CHANGED);
- }
- break;
- }
- }
-
- protected boolean isOverThumb(float px, float py){
- float p = (px - 16) / (width - 32);
- boolean over =( p >= value && p < value + filler);
- return over;
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- if(opaque) {
- buffer.background(buffer.color(255,0));
- buffer.fill(palette[6].getRGB());
- buffer.noStroke();
- buffer.rect(8,0,width-16,height);
- }
- else
- buffer.background(buffer.color(255,0));
- // Draw the track
- buffer.fill(palette[TRACK].getRGB());
- buffer.noStroke();
- buffer.rect(8,3,width-8,height-5);
-
- // ****************************************
- buffer.strokeWeight(1);
- buffer.stroke(3);
-
- // Draw the low cap
- if(currSpot == 1)
- buffer.fill(palette[6].getRGB());
- else
- buffer.fill(palette[4].getRGB());
- buffer.rect(1, 1, 15, height-2, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS);
-
- // Draw the high cap
- if(currSpot == 2)
- buffer.fill(palette[6].getRGB());
- else
- buffer.fill(palette[4].getRGB());
- buffer.rect(width - 15, 1, 14.5f, height-2, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS);
-
- // draw thumb
- float thumbWidth = (width - 32) * filler;
- buffer.translate((width - 32) * value + 16, 0);
- if(currSpot == 10)
- buffer.fill(palette[6].getRGB());
- else
- buffer.fill(palette[4].getRGB());
- buffer.rect(1,1,thumbWidth-1, height-2, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS, CORNER_RADIUS);
-
- buffer.endDraw();
- }
- }
-
- public void draw(){
- if(!visible) return;
- if(bufferInvalid)
- updateBuffer();
-
- winApp.pushStyle();
- winApp.pushMatrix();
-
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- winApp.imageMode(PApplet.CENTER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
-
- winApp.popMatrix();
- winApp.popStyle();
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GSketchPad.java b/Processing/libraries/G4P/src/g4p_controls/GSketchPad.java
deleted file mode 100644
index cfa9d93..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GSketchPad.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-
-/**
- * Display area for user generated graphics.
- *
- * This control will display a PGraphics object created and updated by the user.
- * If the size of the users graphic is different from the control the output will be
- * rescaled to fit the control size irrespective of the aspect ratio.
- *
- * @author Peter Lager
- *
- */
-public class GSketchPad extends GAbstractControl {
-
- // Scale graphic should be set to true if the grpahics object
- // and this sketch pad object are of different sizes.
- protected boolean scaleGraphic = false;
-
- protected PGraphics pad = null;
-
- public GSketchPad(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- cursorOver = G4P.mouseOff; // does not change
- registeredMethods = DRAW_METHOD;
- G4P.registerControl(this);
- }
-
- public void setGraphic(PGraphics pg){
- if(pg == null)
- return;
- pad = pg;
- scaleGraphic = (int)width != pg.width || (int)height != pg.height;
- }
-
- public void draw(){
- if(!visible) return;
-
- winApp.pushStyle();
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- if(pad != null){
- try {
- if(scaleGraphic)
- winApp.image(pad, 0, 0, width, height);
- else
- winApp.image(pad, 0, 0);
-// System.out.println("Graphic updated with alpha " + alphaLevel);
- }
- catch(Exception excp){ /* Do nothing */ }
- }
-// winApp.noFill();
-// winApp.stroke(palette[3]);
-// winApp.strokeWeight(1.5f);
-// winApp.rect(0, 0, width, height);
- winApp.popMatrix();
- winApp.popStyle();
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GSlider.java b/Processing/libraries/G4P/src/g4p_controls/GSlider.java
deleted file mode 100644
index 0851878..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GSlider.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HScircle;
-import g4p_controls.HotSpot.HSrect;
-
-import java.awt.Graphics2D;
-
-import processing.core.PApplet;
-
-/**
- * A simple graphical slider.
- *
- * Either drag the thumb or click on the track to change the slider value.
- *
- * Supports
- * user defined limits (ascending or descending values)
- * numeric display for limits and current value
- * track ticks and stick to ticks
- *
- *
- * @author Peter Lager
- *
- */
-public class GSlider extends GLinearTrackControl {
-
- public GSlider(PApplet theApplet, float p0, float p1, float p2, float p3, float tr_width) {
- super(theApplet, p0, p1, p2, p3);
- trackWidth = tr_width;
- trackDisplayLength = width - 2 * TINSET;
- trackLength = trackDisplayLength - trackWidth;
- trackOffset = calcTrackOffset();
-
- hotspots = new HotSpot[]{
- new HScircle(THUMB_SPOT, width/2 + (parametricPos - 0.5f) * trackLength, height/2, trackWidth/2 ), // thumb
- new HSrect(TRACK_SPOT, (width-trackLength)/2, (height-trackWidth)/2, trackLength, trackWidth), // track
- };
- z = Z_SLIPPY;
-
- epsilon = 0.98f / trackLength;
-
- ssStartLimit = new StyledString("0.00");
- ssEndLimit = new StyledString("1.00");
- ssValue = new StyledString("0.50");
-
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleSliderEvents",
- new Class>[]{ GValueControl.class, GEvent.class },
- new String[]{ "slider", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- protected void updateDueToValueChanging(){
- hotspots[0].x = (width/2 + (parametricPos - 0.5f) * trackLength);
- }
-
- /**
- * Enable or disable the ability of the component to generate mouse events.
- * GTextField - it also controls key press events
- * GPanel - controls whether the panel can be moved/collapsed/expanded
- * @param enable true to enable else false
- */
- public void setEnabled(boolean enable){
- super.setEnabled(enable);
- if(!enable)
- status = OFF_CONTROL;
- }
-
- // Palette index constants
- static int BACK = 6;
- static int TOFF = 3, TOVER = 11, TDOWN = 14, TDRAG = 15;
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
-
- buffer.rectMode(PApplet.CENTER);
- buffer.ellipseMode(PApplet.CENTER);
- // Back ground colour
- buffer.background(opaque ? palette[6].getRGB() : palette[2].getRGB() & 0xFFFFFF);
-
- // Draw track, thumb, ticks etc.
- buffer.pushMatrix();
- buffer.translate(width/2, height/2);
- // draw ticks
- if(showTicks){
- float delta = 1.0f / (nbrTicks - 1);
- for(int i = 0; i < nbrTicks; i++){
- float tickx = ((i * delta - 0.5f)*trackLength);
- buffer.strokeWeight(2);
- buffer.stroke(palette[4].getRGB());
- buffer.line(tickx, -trackWidth, tickx, trackWidth);
- buffer.strokeWeight(1.2f);
- buffer.stroke(palette[1].getRGB());
- buffer.line(tickx, -trackWidth, tickx, trackWidth);
- }
- }
-
- // Draw track surface
- buffer.fill(palette[5].getRGB());
- buffer.stroke(palette[3].getRGB());
- buffer.strokeWeight(2);
- buffer.rect(0, 0, trackDisplayLength, trackWidth, trackWidth );
-
-
- // Draw thumb
- switch(status){
- case OFF_CONTROL:
- buffer.fill(palette[TOFF].getRGB());
- break;
- case OVER_CONTROL:
- buffer.fill(palette[TOVER].getRGB());
- break;
- case PRESS_CONTROL:
- buffer.fill(palette[TDOWN].getRGB());
- break;
- case DRAG_CONTROL:
- buffer.fill(palette[TDRAG].getRGB());
- break;
- }
- buffer.noStroke();
- buffer.ellipse((parametricPos - 0.5f) * trackLength, 0, trackWidth, trackWidth);
-
-
- // Display slider values
- g2d.setColor(palette[2]);
- if(labels != null){
- drawLabels(g2d);
- }
- else {
- if(showLimits)
- drawLimits(g2d);
- // Display slider value
- if(showValue)
- drawValue(g2d);
- }
- buffer.popMatrix();
- buffer.endDraw();
- }
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GSlider2D.java b/Processing/libraries/G4P/src/g4p_controls/GSlider2D.java
deleted file mode 100644
index 8ea71ad..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GSlider2D.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2013 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-/**
- * This slider is used to control 2 variables by dragging the thumb over
- * a 2D surface. It has all the features of the standard slider (GSlider)
- * except that it does not have ticks or stick-to-ticks functionality.
- *
- * If no limits are set then the control will return a value in the range
- * 0.0 to 1.0 for both the x and the y axis. The setXlimits and setYlimits
- * can be used to set a different range for each axis independently.
- *
- * The minimum size for this control is 40x40 pixels and this is enforced
- * when the control is created. If necessary the width and/or height the
- * rectangle will be increased to 40pixels.
- *
- * @author Peter Lager
- *
- */
-public class GSlider2D extends GValueControl2D {
-
- // Palette index constants
- static int DBORDER = 1, LBORDER = 3, BACK = 6;
- static int TBORDER = 15, TOFF = 3, TOVER = 11, TDOWN = 14, TDRAG = 15;
-
- static final float THUMB_SIZE = 10;
- static final float HALF_THUMB_SIZE = THUMB_SIZE / 2;
- static final float BORDER_WIDTH = 2;
-
- // Define the drag area for this control
- protected float dragWidth, dragHeight, dragD;
-
- protected int downHotSpot = -1;
- // Mouse over status
- protected int status = OFF_CONTROL;
-
- protected float startXlimit = 0, endXlimit = 1;
- protected float startYlimit = 0, endYlimit = 1;
-
- /**
- * Create a 2D slider inside the specified rectangle.
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GSlider2D(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- // Enforce minimum size constraint
- if(width < 40 || height < 40)
- resize(PApplet.max(Math.round(width),40), PApplet.max(Math.round(height),40));
-
- dragWidth = width - THUMB_SIZE - 2 * BORDER_WIDTH;
- dragHeight = height - THUMB_SIZE - 2 * BORDER_WIDTH;
- dragD = 2 + THUMB_SIZE/2;
-
- hotspots = new HotSpot[]{
- new HSrect(THUMB_SPOT, dragD - HALF_THUMB_SIZE + parametricPosX * dragWidth,
- dragD - HALF_THUMB_SIZE + parametricPosY * dragHeight, THUMB_SIZE, THUMB_SIZE ), // thumb
- new HSrect(TRACK_SPOT, dragD, dragD, dragWidth, dragHeight) // track
- };
- z = Z_SLIPPY;
-
- epsilon = 0.98f / PApplet.max(dragWidth, dragHeight);
- opaque = true;
-
- // Now register control with applet
- createEventHandler(G4P.sketchWindow, "handleSlider2DEvents",
- new Class>[]{ GSlider2D.class, GEvent.class },
- new String[]{ "slider2d", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD;
- cursorOver = HAND;
- G4P.registerControl(this);
- }
-
- /**
- * Updates thumb hotspot due changes caused by easing
- */
- protected void updateDueToValueChanging(){
- hotspots[0].x = dragD - HALF_THUMB_SIZE + parametricPosX * dragWidth;
- hotspots[0].y = dragD - HALF_THUMB_SIZE + parametricPosY * dragHeight;
- }
-
-
- /**
- * Set the amount of easing to be used when a value is changing. The default value
- * is 1 (no easing) values > 1 will cause the value to rush from its starting value
- * and decelerate towards its final values. In other words it smoothes the movement
- * of the slider thumb or knob rotation.
- *
- * @param easeBy the easing to set
- */
- public void setEasing(float easeBy) {
- easing = (easeBy < 1) ? 1 : easeBy;
- }
-
- /**
- * X (horz) limits
- * Sets the range of values to be returned. This method will
- * assume that you want to set the valueType to INTEGER
- *
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setXlimits(int start, int end){
- startXlimit = start;
- endXlimit = end;
- setEpsilon();
- valueType = INTEGER;
- bufferInvalid = true;
- }
-
- /**
- * X (horz) limits
- * Sets the initial value and the range of values to be returned. This
- * method will assume that you want to set the valueType to INTEGER.
- *
- * @param initValue the initial value
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimitsX(int initValue, int start, int end){
- startXlimit = start;
- endXlimit = end;
- valueType = INTEGER;
- setEpsilon();
- bufferInvalid = true;
- setValueX(initValue);
- updateDueToValueChanging();
- }
-
- /**
- * X (horz) limits
- * Sets the range of values to be returned. This method will
- * assume that you want to set the valueType to DECIMAL
- *
- * @param start
- * @param end
- */
- public void setLimitsX(float start, float end){
- startXlimit = start;
- endXlimit = end;
- if(valueType == INTEGER){
- valueType = DECIMAL;
- setPrecision(1);
- }
- setEpsilon();
- bufferInvalid = true;
- }
-
- /**
- * X (horz) limits
- * Sets the initial value and the range of values to be returned. This
- * method will assume that you want to set the valueType to DECIMAL.
- *
- * @param initValue the initial value
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimitsX(float initValue, float start, float end){
- startXlimit = start;
- endXlimit = end;
- initValue = PApplet.constrain(initValue, start, end);
- if(valueType == INTEGER){
- valueType = DECIMAL;
- setPrecision(1);
- }
- setEpsilon();
- bufferInvalid = true;
- setValueX(initValue);
- updateDueToValueChanging();
- }
-
- /**
- * Y (vert) limits
- * Sets the range of values to be returned. This method will
- * assume that you want to set the valueType to INTEGER
- *
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimitsY(int start, int end){
- startYlimit = start;
- endYlimit = end;
- setEpsilon();
- valueType = INTEGER;
- bufferInvalid = true;
- }
-
- /**
- * Y (vert) limits
- * Sets the initial value and the range of values to be returned. This
- * method will assume that you want to set the valueType to INTEGER.
- *
- * @param initValue the initial value
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimitsY(int initValue, int start, int end){
- startYlimit = start;
- endYlimit = end;
- valueType = INTEGER;
- setEpsilon();
- bufferInvalid = true;
- setValueY(initValue);
- updateDueToValueChanging();
- }
-
- /**
- * Y (vert) limits
- * Sets the range of values to be returned. This method will
- * assume that you want to set the valueType to DECIMAL
- *
- * @param start
- * @param end
- */
- public void setLimitsY(float start, float end){
- startYlimit = start;
- endYlimit = end;
- if(valueType == INTEGER){
- valueType = DECIMAL;
- setPrecision(1);
- }
- setEpsilon();
- bufferInvalid = true;
- }
-
- /**
- * Y (vert) limits
- * Sets the initial value and the range of values to be returned. This
- * method will assume that you want to set the valueType to DECIMAL.
- *
- * @param initValue the initial value
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimitsY(float initValue, float start, float end){
- startYlimit = start;
- endYlimit = end;
- initValue = PApplet.constrain(initValue, start, end);
- if(valueType == INTEGER){
- valueType = DECIMAL;
- setPrecision(1);
- }
- setEpsilon();
- bufferInvalid = true;
- setValueY(initValue);
- updateDueToValueChanging();
- }
-
- /**
- * Set the X (horz) value for the slider.
- * The value supplied will be constrained to the current limits.
- * @param v the new value
- */
- public void setValueX(float v){
- if(valueType == INTEGER)
- v = Math.round(v);
- float t = (v - startXlimit) / (endXlimit - startXlimit);
- t = PApplet.constrain(t, 0.0f, 1.0f);
- parametricTargetX = t;
- }
-
- /**
- * Set the Y (vert) value for the slider.
- * The value supplied will be constrained to the current limits.
- * @param v the new value
- */
- public void setValueY(float v){
- if(valueType == INTEGER)
- v = Math.round(v);
- float t = (v - startYlimit) / (endYlimit - startYlimit);
- t = PApplet.constrain(t, 0.0f, 1.0f);
- parametricTargetY = t;
- }
-
- /**
- * Set both the XY values for the slider.
- * The values supplied will be constrained to the appropriate current limits.
- * @param vx the new X (horz) value
- * @param vy the new Y (vert) value
- */
- public void setValueXY(float vx, float vy){
- setValueX(vx);
- setValueY(vy);
- }
-
- /**
- * Get the current X value as a float
- */
- public float getValueXF(){
- return startXlimit + (endXlimit - startXlimit) * parametricPosX;
- }
-
- /**
- * Get the current X value as an integer.
- * DECIMAL and EXPONENT value types will be rounded to the nearest integer.
- */
- public int getValueXI(){
- return Math.round(getValueXF());
- }
-
- /**
- * Get the current X value as a string taking into account the number format.
- */
- public String getValueXS(){
- return getNumericDisplayString(getValueXF());
- }
-
- /**
- * Get the current Y value as a float
- */
- public float getValueYF(){
- return startYlimit + (endYlimit - startYlimit) * parametricPosY;
- }
-
- /**
- * Get the current Y value as an integer.
- * DECIMAL and EXPONENT value types will be rounded to the nearest integer.
- */
- public int getValueYI(){
- return Math.round(getValueYF());
- }
-
- /**
- * Get the current Y value as a string taking into account the number format.
- */
- public String getValueYS(){
- return getNumericDisplayString(getValueYF());
- }
-
- /**
- * Used to format the number into a string for display.
- * @param number
- * @return the number formated as a string
- */
- protected String getNumericDisplayString(float number){
- String s = "";
- switch(valueType){
- case INTEGER:
- s = String.format("%d", Math.round(number));
- break;
- case DECIMAL:
- s = String.format("%." + precision + "f", number);
- break;
- case EXPONENT:
- s = String.format("%." + precision + "e", number);
- break;
- }
- return s.trim();
- }
-
- /**
- * For DECIMAL values this sets the number of decimal places to
- * be displayed.
- * @param nd must be >= 1 otherwise will use 1
- */
- public void setPrecision(int nd){
- nd = PApplet.constrain(nd, 1, 5);
- if(nd < 1)
- nd = 1;
- if(nd != precision){
- precision = nd;
- setEpsilon();
- bufferInvalid = true;
- }
- }
-
- /**
- * Set the numberFormat and precision in one go.
- * Valid number formats are INTEGER, DECIMAL, EXPONENT
- * Precision must be >= 1 and is ignored for INTEGER.
- *
- * @param numberFormat G4P.INTEGER, G4P.DECIMAL orG4P. EXPONENT
- * @param precision must be >= 1
- */
- public void setNumberFormat(int numberFormat, int precision){
- switch(numberFormat){
- case INTEGER:
- case DECIMAL:
- case EXPONENT:
- this.valueType = numberFormat;
- break;
- default:
- valueType = DECIMAL;
- }
- setPrecision(precision);
- bufferInvalid = true;
- }
-
- /**
- * Set the numberFormat and precision in one go.
- * Valid number formats are INTEGER, DECIMAL, EXPONENT
- * Precision must be >= 1 and is ignored for INTEGER.
- *
- * @param numberFormat G4P.INTEGER, G4P.DECIMAL or G4P.EXPONENT
- */
- public void setNumberFormat(int numberFormat){
- switch(numberFormat){
- case INTEGER:
- case DECIMAL:
- case EXPONENT:
- this.valueType = numberFormat;
- break;
- default:
- valueType = DECIMAL;
- }
- bufferInvalid = true;
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- // Make ox,oy relative to top-left of drag area
- ox -= dragD;
- oy -= dragD;
-
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot > -1 && z >= focusObjectZ()){
- downHotSpot = currSpot;
- status = (downHotSpot == THUMB_SPOT) ? PRESS_CONTROL : OFF_CONTROL;
- offsetH = ox - parametricPosX * dragWidth; // normalised
- offsetV = oy - parametricPosY * dragHeight; // normalised
- takeFocus();
- bufferInvalid = true;
- }
- break;
- case MouseEvent.CLICK:
- if(focusIsWith == this){
- parametricTargetX = ox / dragWidth;
- parametricTargetY = oy / dragHeight;
- dragging = false;
- status = OFF_CONTROL;
- loseFocus(null);
- bufferInvalid = true;
- }
- break;
- case MouseEvent.RELEASE:
- if(focusIsWith == this && dragging){
- if(downHotSpot == THUMB_SPOT){
- mouseUpdateTargets();
- }
- status = OFF_CONTROL;
- bufferInvalid = true;
- loseFocus(null);
- }
- dragging = false;
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this){
- status = DRAG_CONTROL;
- dragging = true;
- if(downHotSpot == THUMB_SPOT){
- mouseUpdateTargets();
- bufferInvalid = true;
- }
- }
- break;
- case MouseEvent.MOVE:
- int currStatus = status;
- // If dragged state will stay as PRESSED
- if(currSpot == THUMB_SPOT)
- status = OVER_CONTROL;
- else
- status = OFF_CONTROL;
- if(currStatus != status)
- bufferInvalid = true;
- break;
- }
- }
-
- /**
- * Convenience method called during mouse event handling
- */
- private void mouseUpdateTargets(){
- parametricTargetX = ox / dragWidth;
- if(parametricTargetX < 0){
- parametricTargetX = 0;
- offsetH = 0;
- }
- else if(parametricTargetX > 1){
- parametricTargetX = 1;
- offsetH = 0;
- }
- parametricTargetY = oy / dragHeight;
- if(parametricTargetY < 0){
- parametricTargetY = 0;
- offsetV = 0;
- }
- else if(parametricTargetY > 1){
- parametricTargetY = 1;
- offsetV = 0;
- }
- }
-
- public void draw(){
- if(!visible) return;
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
- winApp.popMatrix();
-
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
-
- buffer.ellipseMode(PApplet.CENTER);
- buffer.rectMode(PApplet.CENTER);
- // Back ground colour
- if(opaque == true)
- buffer.background(palette[BACK].getRGB());
- else
- buffer.background(buffer.color(255,0));
-
- buffer.pushMatrix();
- // Draw thumb cursor lines
- float tx = dragD + parametricPosX * dragWidth;
- float ty = dragD + parametricPosY * dragHeight;
- buffer.stroke(palette[TBORDER].getRGB());
- buffer.strokeWeight(1);
- buffer.line(0, ty, width, ty);
- buffer.line(tx, 0, tx, height);
- switch(status){
- case OFF_CONTROL:
- buffer.fill(palette[TOFF].getRGB());
- break;
- case OVER_CONTROL:
- buffer.fill(palette[TOVER].getRGB());
- break;
- case PRESS_CONTROL:
- buffer.fill(palette[TDOWN].getRGB());
- break;
- case DRAG_CONTROL:
- buffer.fill(palette[TDRAG].getRGB());
- break;
- }
- buffer.rect(tx, ty, THUMB_SIZE, THUMB_SIZE);
-
- // Draw control border
- buffer.rectMode(PApplet.CORNERS);
- buffer.noFill();
- buffer.stroke(palette[LBORDER].getRGB());
- buffer.strokeWeight(2);
- buffer.rect(0,0,width-1,height-1);
- buffer.stroke(palette[DBORDER].getRGB());
- buffer.strokeWeight(1);
- buffer.rect(1,1,width-1,height-1);
-
- buffer.popMatrix();
- buffer.endDraw();
- }
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GStick.java b/Processing/libraries/G4P/src/g4p_controls/GStick.java
deleted file mode 100644
index e296683..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GStick.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HScircle;
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-/**
- * This control simulates a digital joystick and is designed to give more
- * intuitive control in game scenarios where you might use the keyboard
- * e.g. WASD keys for movement.
- *
- * The joystick has two modes - in the default mode the joystick just
- * responds to movement in 4 directions (left,right, up and down) the
- * second mode allows for diagonals so recognises 8 directions.
- *
- * As in a real joystick you have a dead zone near the centre which
- * does not generate signals, thus avoiding jitter. This area is shown
- * graphically.
- *
- * The direction of the joystick is represented by an integer in the
- * range 0-7 and -1 when in the dead zone.
- *
- * 5 6 7
- * \ | /
- * \ | /
- * 4 --- + --- 0 + is the dea zone so -1
- * / | \
- * / | \
- * 3 2 1
- *
- * As well as the direction there are two useful methods to decode these
- * into X and Y directions -
- * @return the X value (-1, 0 or 1)
- */
- public int getStickX(){
- return (position < 0) ? 0 : posX[position];
- }
-
- /**
- * Get the Y position of the stick from
- * *
- * @return the Y value (-1, 0 or 1)
- */
- public int getStickY(){
- return (position < 0) ? 0 : posY[position];
- }
-
- /**
- * Calculate the angle to the knob centre making sure it is in
- * the range 0-360
- * @param px relative to centre
- * @param py relative to centre
- * @return the angle made by the stick
- */
- protected float calcStickAngle(float px, float py){
- float a = PApplet.atan2(py, px);
- if(a < 0)
- a += PApplet.TWO_PI;
- return a;
- }
-
- /**
- * Calculate the position (mode dependent) from an angle in the range 0-2PI
- * @param a the angle 0-2PI
- * @return direction (0-7)
- */
- protected int getPositionFromAngle(float a){
- int newState;
- if(mode == 1){
- a = (a + RAD45) % PApplet.TWO_PI;
- newState = 2 * (int)(a / RAD90);
- }
- else {
- a = (a + RAD22_5) % PApplet.TWO_PI;
- newState = (int)(a / RAD45);
- }
- return newState % 8;
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- // Make ox and oy relative to the centre of the stick
- ox -= width/2;
- oy -= height/2;
-
- // currSpot == 1 for text display area
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot > -1 && z > focusObjectZ()){
- status = PRESS_CONTROL;
- position = -1;
- rodLength = PApplet.sqrt(ox*ox + oy*oy);
- stickAngle = calcStickAngle(ox, oy);
- dragging = false;
- takeFocus();
- bufferInvalid = true;
- }
- break;
- case MouseEvent.RELEASE:
- if(focusIsWith == this){
- loseFocus(null);
- }
- // If we are not already near the centre then make it so
- // and fire an event
- if(position != -1){
- position = -1;
- fireEvent(this, GEvent.CHANGED);
- }
- hotspots[0].adjust(width/2, height/2);
- rodLength = stickAngle = 0;
- dragging = false;
- status = OFF_CONTROL;
- bufferInvalid = true;
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this){
- status = DRAG_CONTROL;
- dragging = true;
- rodLength = PApplet.sqrt(ox*ox + oy*oy);
- stickAngle = calcStickAngle(ox, oy);
- int newPosition = -1;
- if(rodLength >= actionRad){
- newPosition = getPositionFromAngle(stickAngle);
- }
- if(rodLength > actionRadLimit){
- ox = actionRadLimit * PApplet.cos(stickAngle);
- oy = actionRadLimit * PApplet.sin(stickAngle);
- rodLength = actionRadLimit;
- }
- hotspots[0].adjust(ox + width/2, oy + height/2);
- if(newPosition != position){
- position = newPosition;
- fireEvent(this, GEvent.CHANGED);
- }
- bufferInvalid = true;
- }
- break;
- case MouseEvent.MOVE:
- int currStatus = status;
- // If dragged state will stay as PRESSED
- if(currSpot == 1)
- status = OVER_CONTROL;
- else
- status = OFF_CONTROL;
- if(currStatus != status)
- bufferInvalid = true;
- break;
- }
- }
-
- public void draw(){
- if(!visible) return;
-
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
-
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- // Back ground colour
- if(opaque == true)
- buffer.background(palette[BACK].getRGB());
- else
- buffer.background(buffer.color(255,0));
- // Move origin to centre
-
- buffer.translate(width/2, height/2);
-
- buffer.fill(palette[OUTERRING].getRGB());
- buffer.stroke(palette[BORDERS].getRGB());
- buffer.strokeWeight(1.0f);
- buffer.ellipse(0,0,2*ledRingRad, 2*ledRingRad);
- buffer.ellipse(0,0,2*actionRad, 2*actionRad);
- // Draw everything except the stick
- buffer.pushMatrix();
- int led = 0x00000001, delta = 2/mode;
- for(int i = 0; i < 8; i += delta){
- buffer.stroke(palette[BORDERS].getRGB());
- buffer.strokeWeight(1.0f);
- buffer.line(0,0,ledRingRad,0);
- // Only draw LEDs on even directions
- if(i%2 == 0){
- buffer.noStroke();
- if(position >= 0 && (posMap[position] & led) == led)
- buffer.fill(palette[LED_ACTIVE].getRGB());
- else
- buffer.fill(palette[LED_INACTIVE].getRGB());
- buffer.ellipse(ledRingRad,0,ledWidth,ledHeight);
- }
- led <<= delta;
- buffer.rotate(delta * RAD45);
- }
- buffer.popMatrix();
-
- // Draw the inactive area near the centre of the
- buffer.fill(palette[ACTIONRING].getRGB());
- buffer.stroke(palette[BORDERS].getRGB());
- buffer.strokeWeight(1.0f);
- buffer.ellipse(0,0,2*actionRad, 2*actionRad);
-
- // Draw the rod and button
- buffer.pushMatrix();
- buffer.rotate(stickAngle);
- buffer.noStroke();
- buffer.fill(palette[ROD].getRGB());
- buffer.ellipse(0,0,2*rodRad,2*rodRad);
- buffer.rect(0,-rodRad,rodLength,2*rodRad);
- buffer.strokeWeight(1);
- buffer.stroke(palette[ROD].getRGB());
- // Draw thumb
- switch(status){
- case OFF_CONTROL:
- buffer.fill(palette[STICK_TOP].getRGB());
- break;
- case OVER_CONTROL:
- buffer.fill(palette[STICK_TOP_OVER].getRGB());
- break;
- case PRESS_CONTROL:
- buffer.fill(palette[STICK_TOP_PRESS].getRGB());
- break;
- case DRAG_CONTROL:
- buffer.fill(palette[STICK_TOP_DRAG].getRGB());
- break;
- }
- buffer.ellipse(rodLength,0,2*gripRad, 2*gripRad);
- buffer.popMatrix();
- buffer.endDraw();
- }
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTabManager.java b/Processing/libraries/G4P/src/g4p_controls/GTabManager.java
deleted file mode 100644
index f229c04..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTabManager.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.util.LinkedList;
-
-/**
- * Allows TABBING between text controls.
- * A tab manager allows the user to use the TAB key to move from one text control
- * (GTextField or GTextArea) to the another. This is useful when creating a 'form'
- * made from several text controls.
- * The tab order is decided by the order the text controls are added to the tab
- * manager. The TAB key move the focus forwards and SHIFT+TAB moves it backwards.
- * Note that tabbing is not cyclic so pressing TAB on the last control does not
- * set the focus on the first control, in fact it will be ignored. Similar
- * logic applies to SHIFT_TAB on the first control
- * At least 2 controls must be added to the tab manager.
- *
- * @author Peter Lager
- *
- */
-public class GTabManager {
-
- private LinkedList textControls;
-
- public GTabManager(){
- textControls = new LinkedList();
- }
-
- /**
- * Attempt to add multiple controls to the tab manager. The tab order is determined
- * by their order as parameters to this method.
- *
- * @param controls a comma separated list of text field or text area controls.
- * @return true if any or all of the controls were added and false if none were added.
- */
- public boolean addControls(Focusable... controls){
- boolean result = false;
- for(Focusable control : controls)
- result |= addControl(control);
- return result;
- }
-
- /**
- * Add the next text control to this tab manager.
- *
- * @param control to add
- * @return true if added successfully
- */
- public boolean addControl(Focusable control){
- if(!textControls.contains(control)){
- control.setTabManager(this);
- textControls.addLast(control);
- return true;
- }
- return false;
- }
-
- /**
- * Remove a control from the tab manager. This does not affect the tab
- * order of the remaining controls.
- *
- * @param control
- * @return true if remove successfully
- */
- public boolean removeControl(Focusable control){
- int index = textControls.lastIndexOf(control);
- if(index > 0){
- control.setTabManager(null);
- textControls.remove(index);
- return true;
- }
- return false;
- }
-
- /**
- * Used when the tab key is pressed to move to the next control
- * @param control
- * @return true if it found a next control else false
- */
- boolean nextControl(Focusable control){
- int index = textControls.lastIndexOf(control);
- if(textControls.size() > 1 && index >= 0 && index < textControls.size() - 1){
- index++;
- GAbstractControl.controlToTakeFocus = (GAbstractControl)textControls.get(index);;
- return true;
- }
- return false;
- }
-
- /**
- * Used when the shift+tab key is pressed to move to the previous control
- * @param control
- * @return true if it found a previous control else false
- */
- boolean prevControl(Focusable control){
- int index = textControls.lastIndexOf(control);
- if(textControls.size() > 1 && index > 0){
- index--;
- GAbstractControl.controlToTakeFocus = (GAbstractControl)textControls.get(index);
- return true;
- }
- return false;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTextAlign.java b/Processing/libraries/G4P/src/g4p_controls/GTextAlign.java
deleted file mode 100644
index 2b288ec..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTextAlign.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-
-
-/**
- *
- * Is the basis for all classes that have some simple non-editable text element to them.
- *
- * @author Peter Lager
- *
- */
-public abstract class GTextAlign extends GTextBase {
-
- protected GAlign textAlignH = GAlign.CENTER, textAlignV = GAlign.MIDDLE;
-
- protected float stX, stY;
-
- public GTextAlign(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- }
-
- /**
- * Set the horizontal and/or vertical text alignment. Use the constants in GAlign
- * e.g.
GAlign.LEFT
- *
- * If you want to set just one of these then pass null in the other
- *
- * @param horz LEFT, CENTER, RIGHT or JUSTIFY
- * @param vert TOP, MIDDLE, BOTTOM
- */
- public void setTextAlign(GAlign horz, GAlign vert){
- if(horz != null && horz.isHorzAlign()){
- textAlignH = horz;
- stext.setJustify(textAlignH == GAlign.JUSTIFY);
- }
- if(vert != null && vert.isVertAlign()){
- textAlignV = vert;
- }
- bufferInvalid = true;
- }
-
- /**
- * Combines setting the text and text alignment in one method.
- *
- * If you want to set just one of the alignments then pass null
- * in the other.
- *
- * @param text
- * @param horz LEFT, CENTER, RIGHT or JUSTIFY
- * @param vert TOP, MIDDLE, BOTTOM
- */
- public void setText(String text, GAlign horz, GAlign vert){
- setText(text);
- setTextAlign(horz, vert);
- bufferInvalid = true;
- }
-
- protected void calcAlignment(){
- switch(textAlignH){
- case RIGHT:
- stX = width - stext.getWrapWidth() - TPAD2;
- break;
- case LEFT:
- case CENTER:
- case JUSTIFY:
- default:
- stX = TPAD2;
- }
- switch(textAlignV){
- case TOP:
- stY = TPAD2;
- break;
- case BOTTOM:
- stY = height - stext.getTextAreaHeight() - TPAD2;
- break;
- case MIDDLE:
- default:
- stY = (height - stext.getTextAreaHeight()) / 2;
- }
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTextArea.java b/Processing/libraries/G4P/src/g4p_controls/GTextArea.java
deleted file mode 100644
index 1af389a..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTextArea.java
+++ /dev/null
@@ -1,1112 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-import g4p_controls.StyledString.TextLayoutHitInfo;
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextHitInfo;
-import java.awt.font.TextLayout;
-import java.awt.geom.GeneralPath;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-import processing.event.MouseEvent;
-
-/**
- * The text area component.
- *
- * This control allows the user to enter and edit multiple lines of text. The control
- * also allows default text, horizontal and vertical scrollbars.
- *
- * Enables user to enter text at runtime. Text can be selected using the mouse
- * or keyboard shortcuts and then copied or cut to the clipboard. Text
- * can also be pasted in.
- *
- * There are some methods to add and clear text attributes to all or some of the
- * text in the control. If a method is expecting a line number, you should specify
- * the actual line number for the entire text (lines numbers start at 0). It is
- * not the line number in the visible display because this can change if the text
- * has been scrolled vertically.
- *
- *
- * Fires SELECTION_CHANGED, CHANGED, ENTERED, LOST_FOCUS, GETS_FOCUS events.
- * The focus events are only fired if the control is added to a GTabManager object.
- *
- * @author Peter Lager
- *
- */
-public class GTextArea extends GEditableTextControl {
-
- protected boolean newline = false, backspace = false;
-
- /**
- * Create a text area without scrollbars and a text wrap width to fit the control.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GTextArea(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, SCROLLBARS_NONE, Integer.MAX_VALUE);
- }
-
- /**
- * Create a text field with the given scrollbar policy and a text wrap width to fit the control.
- * The scrollbar policy can be one of these
- *
- *
SCROLLBARS_NONE
- *
SCROLLBARS_HORIZONTAL_ONLY
- *
SCROLLBARS_VERTICAL_ONLY
- *
SCROLLBARS_BOTH
- *
- * If you want the scrollbar to auto hide then perform a logical or with
- *
- *
SCROLLBARS_AUTOHIDE
- *
- * e.g. SCROLLBARS_BOTH | SCROLLBARS_AUTOHIDE
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param sbPolicy
- */
- public GTextArea(PApplet theApplet, float p0, float p1, float p2, float p3, int sbPolicy) {
- this(theApplet, p0, p1, p2, p3, sbPolicy, Integer.MAX_VALUE);
- }
-
- /**
- * Create a text field with the given scrollbar policy with a user specified text wrap length
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param sbPolicy
- * @param wrapWidth
- */
- public GTextArea(PApplet theApplet, float p0, float p1, float p2, float p3, int sbPolicy, int wrapWidth) {
- super(theApplet, p0, p1, p2, p3, sbPolicy);
- children = new LinkedList();
- tx = ty = TPAD6;
- tw = width - 2 * TPAD6 - ((scrollbarPolicy & SCROLLBAR_VERTICAL) != 0 ? 18 : 0);
- th = height - 2 * TPAD6 - ((scrollbarPolicy & SCROLLBAR_HORIZONTAL) != 0 ? 18 : 0);
- // The text wrap width is based on the width of the text display area unless
- // some other value is specified.
- this.wrapWidth = (wrapWidth == Integer.MAX_VALUE) ? (int)tw : wrapWidth;
- // Clip zone
- gpTextDisplayArea = new GeneralPath();
- gpTextDisplayArea.moveTo( 0, 0);
- gpTextDisplayArea.lineTo( 0, th);
- gpTextDisplayArea.lineTo(tw, th);
- gpTextDisplayArea.lineTo(tw, 0);
- gpTextDisplayArea.closePath();
-
- hotspots = new HotSpot[]{
- new HSrect(1, tx, ty, tw, th), // typing area
- new HSrect(9, 0, 0, width, height) // control surface
- };
- // Create scrollbars
- G4P.pushStyle();
- G4P.showMessages = false;
- z = Z_STICKY;
- G4P.control_mode = GControlMode.CORNER;
- if((scrollbarPolicy & SCROLLBAR_HORIZONTAL) != 0){
- hsb = new GScrollbar(theApplet, 0, 0, tw, 16);
- addControl(hsb, tx, ty + th + 2, 0);
- hsb.addEventHandler(this, "hsbEventHandler");
- hsb.setAutoHide(autoHide);
- }
- if((scrollbarPolicy & SCROLLBAR_VERTICAL) != 0){
- vsb = new GScrollbar(theApplet, 0, 0, th, 16);
- addControl(vsb, tx + tw + 18, ty, PI/2);
- vsb.addEventHandler(this, "vsbEventHandler");
- vsb.setAutoHide(autoHide);
- }
- setScrollbarValues(0,0);
- G4P.popStyle();
-
- setText("");
- createEventHandler(G4P.sketchWindow, "handleTextEvents",
- new Class>[]{ GEditableTextControl.class, GEvent.class },
- new String[]{ "textcontrol", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD | KEY_METHOD;
- // Must register control
- G4P.registerControl(this);
- bufferInvalid = true;
- }
-
- protected void setTextImpl(String text, int wrapWidth){
- if(text != null){
- // Change empty string to a 'space' character
- text = text.length() > 0 ? text : " ";
- stext.setText(text, wrapWidth);
- setStyledText(stext);
- bufferInvalid = true;
- }
- }
-
- /**
- * Set the text to display and adjust any scrollbars
- * @param text text to display
- * @param wrapWidth the wrap width
- */
- public void setText(String text, int wrapWidth){
- setTextImpl(text, wrapWidth);
- }
-
- /**
- * Set the text to be used. The wrap width is determined by the current
- * text wrapwidth or if there is no text then the text width
- * of the control.
- *
- * @param text to be displayed
- */
- public void setText(String text){
- // Set the wrap width the same as the control
- setTextImpl(text, wrapWidth);
- }
-
- /**
- * Set the text to display and adjust any scrollbars
- * @param lines an array of Strings representing the text to display
- */
- public void setText(String[] lines){
- if(lines != null && lines.length > 0)
- setTextImpl(PApplet.join(lines, "\n"), wrapWidth);
- }
-
-
- /**
- * Set the text to display and adjust any scrollbars
- * @param lines an array of Strings representing the text to display
- * @param wrapWidth the wrap width
- */
- public void setText(String[] lines, int wrapWidth){
- if(lines != null && lines.length > 0)
- setTextImpl(PApplet.join(lines, "\n"), wrapWidth);
- }
-
- /**
- * Get the text as a String array. (splitting on line breaks).
- *
- * @return the associated plain text as a String array split on line breaks
- */
- public String[] getTextAsArray(){
- return stext.getPlainTextAsArray();
- }
-
- /**
- * Adds the text attribute to a range of characters on a particular display line. If charEnd
- * is past the EOL then the attribute will be applied to the end-of-line.
- *
- * @param attr the text attribute to add
- * @param value value of the text attribute
- * @param lineNo the display line number (starts at 0)
- * @param charStart the position of the first character to apply the attribute
- * @param charEnd the position after the last character to apply the attribute
- */
- public void addStyle(TextAttribute attr, Object value, int lineNo, int charStart, int charEnd){
- stext.addAttribute(attr, value, lineNo, charStart, charEnd);
- bufferInvalid = true;
- }
-
- /**
- * Adds the text attribute to an entire display line.
- *
- * @param attr the text attribute to add
- * @param value value of the text attribute
- * @param lineNo the display line number (starts at 0)
- */
- public void addStyle(TextAttribute attr, Object value, int lineNo){
- stext.addAttribute(attr, value, lineNo);
- bufferInvalid = true;
- }
-
- /**
- * Clears all text attribute from a range of characters on a particular display line.
- * If charEnd is past the EOL then the attributes will be cleared to the
- * end-of-line.
- *
- * @param lineNo the display line number (starts at 0)
- * @param charStart the position of the first character to apply the attribute
- * @param charEnd the position after the last character to apply the attribute
- */
- public void clearStyles(int lineNo, int charStart, int charEnd){
- stext.clearAttributes(lineNo, charStart, charEnd);
- bufferInvalid = true;
- }
-
- /**
- * Clears all text attribute from an entire display line.
- *
- * @param lineNo the display line number (starts at 0)
- */
- public void clearStyles(int lineNo){
- stext.clearAttributes(lineNo);
- bufferInvalid = true;
- }
-
- /**
- * Set the styled text to be displayed.
- *
- */
- public void setStyledText(StyledString st){
- stext = st;
- if(stext.getWrapWidth() == Integer.MAX_VALUE)
- stext.setWrapWidth(wrapWidth);
- else
- wrapWidth = stext.getWrapWidth();
- stext.getLines(buffer.g2);
- if(stext.getNbrLines() > 0){
- endTLHI.tli = stext.getLines(buffer.g2).getFirst();
- endTLHI.thi = endTLHI.tli.layout.getNextLeftHit(1);
- startTLHI.copyFrom(endTLHI);
- calculateCaretPos(endTLHI);
- keepCursorInView = true;
- }
- ptx = pty = 0;
- setScrollbarValues(ptx,pty);
- bufferInvalid = true;
- }
-
- /**
- * Add text to the end of the current text. This is useful for a logging' type activity.
- *
- * No events will be generated and the caret will be moved to the end of any appended text.
- *
- * @param text the text to append
- * @return true if some characters were added
- */
- public boolean appendText(String text){
- if(text == null || text.equals("") || stext.insertCharacters(text, stext.length(), true, false) == 0)
- return false;
- LinkedList lines = stext.getLines(buffer.g2);
- endTLHI.tli = lines.getLast();
- endTLHI.thi = endTLHI.tli.layout.getNextRightHit(endTLHI.tli.nbrChars - 1);
- startTLHI.copyFrom(endTLHI);
- calculateCaretPos(endTLHI);
- setScrollbarValues(ptx,pty);
- bufferInvalid = true;
- return true;
- }
-
-
- /**
- * Insert text at the display position specified.
- *
- * The area line number starts at 0 and includes any lines scrolled off the top. So if
- * three lines have been scrolled off the top the first visible line is number 3.
- *
- * No events will be generated and the caret will be moved to the end of any inserted text.
- *
- * @param text the text to insert
- * @param lineNo the area line number
- * @param charNo the character position to insert text in display line
- * @return true if some characters were inserted
- */
- public boolean insertText(String text, int lineNo, int charNo){
- return insertText(text, lineNo, charNo, false, false);
- }
-
- /**
- * Insert text at the display position specified.
- *
- * The area line number starts at 0 and includes any lines scrolled off the top. So if
- * three lines have been scrolled off the top the first visible line is number 3.
- *
- * No events will be generated and the caret will be moved to the end of any inserted text.
- *
- * @param text the text to insert
- * @param lineNo the area line number
- * @param charNo the character position to insert text in display line
- * @param startWithEOL if true,inserted text will start on newline
- * @param endWithEOL if true, text after inserted text will start on new line
- * @return true if some characters were inserted
- */
- public boolean insertText(String text, int lineNo, int charNo, boolean startWithEOL, boolean endWithEOL){
- if(text != null && text.length() > 0){
- int pos = stext.getPos(lineNo, charNo);
- int change = stext.insertCharacters(text, lineNo, charNo, startWithEOL, endWithEOL);
- // displayCaretPos("Caret starts at ");
- if(change != 0){
- // Move caret to end of insert if possible
- pos += change;
- TextLayoutHitInfo tlhi = stext.getTLHIforCharPosition(pos);
- if(tlhi != null){
- endTLHI.copyFrom(tlhi);
- moveCaretLeft(endTLHI);
- startTLHI.copyFrom(endTLHI);
- // displayCaretPos("Caret ends at ");
- calculateCaretPos(tlhi);
- keepCursorInView = true;
- showCaret = true;
- }
- setScrollbarValues(ptx,pty);
- bufferInvalid = true;
- return true;
- }
- }
- return false;
- }
-
- /**
- * Insert text at the current caret position. If the current caret position is undefined
- * the text will be inserted at the beginning of the text.
- *
- * No events will be generated and the caret will be moved to the end of any inserted text.
- *
- * @param text the text to insert
- * @param startWithEOL if true,inserted text will start on newline
- * @param endWithEOL if true, text after inserted text will start on new line
- * @return true if some characters were inserted
- */
- public boolean insertText(String text, boolean startWithEOL, boolean endWithEOL){
- int lineNo = 0, charNo = 0;
- if(endTLHI.tli != null && endTLHI.thi != null){
- lineNo = endTLHI.tli.lineNo;
- charNo = endTLHI.thi.getCharIndex();
- }
- return insertText(text, lineNo, charNo, startWithEOL, endWithEOL);
- }
-
- /**
- * Insert text at the current caret position. If the current caret position is undefined
- * the text will be inserted at the beginning of the text.
- *
- * No events will be generated and the caret will be moved to the end of any inserted text.
- *
- * @param text the text to insert
- * @return true if some characters were inserted
- */
- public boolean insertText(String text){
- return insertText(text, false, false);
- }
-
- // For debugging only
- @SuppressWarnings("unused")
- private void displayCaretPos(String title){
- if(endTLHI != null && endTLHI.tli != null && endTLHI.thi != null){
- System.out.println(title + " :: Carat on line " + endTLHI.tli.lineNo + " at char " + endTLHI.thi.getCharIndex());
- }
- else {
- System.out.println(title + " :: unknown caret position");
- }
- }
-
- // private void updateScrollbars(float hvalue){
- // if(vsb != null){
- // float vfiller = Math.min(1, th/stext.getTextAreaHeight());
- // vsb.setValue(1 - vfiller, vfiller);
- // keepCursorInView = true;
- // }
- // // If needed update the horizontal scrollbar
- // if(hsb != null){
- // //float hvalue = lines.getLast().layout.getVisibleAdvance();
- // float hlinelength = stext.getMaxLineLength();
- // float hfiller = Math.min(1, tw/hlinelength);
- // if(caretX < tw)
- // hsb.setValue(0,hfiller);
- // else
- // hsb.setValue(hvalue/hlinelength, hfiller);
- // keepCursorInView = true;
- // }
- // }
-
- /**
- * Get the text on a particular line in the text area.
- * The line does not need to be visible and the line numbers
- * always start at 0.
- * The result is not dependent on what is visible at any
- * particular time but on the overall position in text area
- * control.
- * If the line number is invalid then an empty string is returned.
- * Trailing EOL characters are removed.
- *
- * @param lineNo the text area line number we want
- * @return the plain text in a display line
- */
- public String getText(int lineNo){
- Graphics2D g2d = buffer.g2;
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
- if(lineNo < 0 || lineNo >= lines.size())
- return "";
- TextLayoutInfo tli = lines.get(lineNo);
- String s = stext.getPlainText(tli.startCharIndex, tli.startCharIndex + tli.nbrChars);
- // Strip off trailing EOL
- int p = s.length() - 1;
- while(p > 0 && s.charAt(p) == EOL)
- p--;
- return (p == s.length() - 1) ? s : s.substring(0, p+1);
- }
-
- /**
- * Get the length of text on a particular line in the text area.
- * The line does not need to be visible and the line numbers
- * always start at 0.
- * The result is not dependent on what is visible at any
- * particular time but on the overall position in text area
- * control.
- * If ignoreEOL is true then EOL characters are not included in the count.
- *
- * @param lineNo the text area line number we want
- * @param ignoreEOL if true do not include trailing end=of-line characters
- * @return the length of the line, or <) if the line number is invalid
- */
- public int getTextLength(int lineNo, boolean ignoreEOL){
- Graphics2D g2d = buffer.g2;
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
- if(lineNo < 0 || lineNo >= lines.size())
- return -1;
- TextLayoutInfo tli = lines.get(lineNo);
- // String s = stext.getPlainText(tli.startCharIndex, tli.startCharIndex + tli.nbrChars);
- String s = stext.getPlainText();
- int len = tli.nbrChars;
- if(ignoreEOL){
- // Strip off trailing EOL
- int p = tli.startCharIndex + tli.nbrChars-1;
- while(p > tli.startCharIndex && s.charAt(p) == EOL){
- p--;
- len--;
- }
- }
- return len;
- }
-
- /**
- * If the buffer is invalid then redraw it.
- */
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
-
- boolean usePromptText = promptText != null && !hasFocus() && (lines.isEmpty() || stext.getPlainText().equals("") || stext.getPlainText().equals(" "));
- if(usePromptText)
- lines = promptText.getLines(g2d);
-
- TextLayoutHitInfo startSelTLHI = null, endSelTLHI = null;
- // Whole control surface if opaque
- if(opaque)
- buffer.background(palette[6].getRGB());
- else
- buffer.background(buffer.color(255,0));
-
- // Now move to top left corner of text display area
- buffer.translate(tx,ty);
-
- // Typing area surface
- buffer.noStroke();
- buffer.fill(palette[7].getRGB());
- buffer.rect(-1,-1,tw+2,th+2);
-
- g2d.setClip(gpTextDisplayArea);
- buffer.translate(-ptx, -pty);
- // Translate in preparation for display selection and text
-
- if(hasFocus() && stext.getPlainText().equals(" ")){
- lines = stext.getLines(buffer.g2);
- startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-
- endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
- int lastChar = endTLHI.tli.layout.getCharacterCount();
- endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
- }
-
- if(hasSelection()){
- if(endTLHI.compareTo(startTLHI) == -1){
- startSelTLHI = endTLHI;
- endSelTLHI = startTLHI;
- }
- else {
- startSelTLHI = startTLHI;
- endSelTLHI = endTLHI;
- }
- }
-
- // Display selection and text
- for(TextLayoutInfo lineInfo : lines){
- TextLayout layout = lineInfo.layout;
- buffer.translate(0, layout.getAscent());
- // Draw selection if any
- if(!usePromptText && hasSelection() && lineInfo.compareTo(startSelTLHI.tli) >= 0 && lineInfo.compareTo(endSelTLHI.tli) <= 0 ){
- int ss = 0;
- ss = (lineInfo.compareTo(startSelTLHI.tli) == 0) ? startSelTLHI.thi.getInsertionIndex() : 0;
- int ee = endSelTLHI.thi.getInsertionIndex();
- ee = (lineInfo.compareTo(endSelTLHI.tli) == 0) ? endSelTLHI.thi.getInsertionIndex() : lineInfo.nbrChars-1;
- g2d.setColor(palette[14]);
- Shape selShape = layout.getLogicalHighlightShape(ss, ee);
- g2d.fill(selShape);
- }
- // display text
- g2d.setColor(palette[2]);
- lineInfo.layout.draw(g2d, 0, 0);
- buffer.translate(0, layout.getDescent() + layout.getLeading());
- }
- g2d.setClip(null);
- buffer.endDraw();
- }
- }
-
- public void pre(){
- if(keepCursorInView){
- boolean horzScroll = false, vertScroll = false;
- float max_ptx = caretX - tw + 2;
- float max_pty = caretY - th + 2 * stext.getMaxLineHeight();
-
- if(endTLHI != null){
- if(ptx > caretX){ // LEFT?
- ptx -= HORZ_SCROLL_RATE;
- if(ptx < 0) ptx = 0;
- horzScroll = true;
- }
- else if(ptx < max_ptx){ // RIGHT?
- ptx += HORZ_SCROLL_RATE;
- if(ptx > max_ptx) ptx = max_ptx;
- horzScroll = true;
- }
- if(pty > caretY){ // UP?
- pty -= VERT_SCROLL_RATE;
- if(pty < 0) pty = 0;
- vertScroll = true;
- }
- else if(pty < max_pty){ // DOWN?
- pty += VERT_SCROLL_RATE;
- vertScroll = true;
- }
- if(horzScroll && hsb != null)
- hsb.setValue(ptx / (stext.getMaxLineLength() + 4));
- if(vertScroll && vsb != null)
- vsb.setValue(pty / (stext.getTextAreaHeight() + 1.5f * stext.getMaxLineHeight()));
- }
- // If we have scrolled invalidate the buffer otherwise forget it
- if(horzScroll || vertScroll)
- bufferInvalid = true;
- else
- keepCursorInView = false;
- }
- }
-
- public void draw(){
- if(!visible) return;
-
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
-
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
-
- // Draw caret if text display area
- if(focusIsWith == this && showCaret && endTLHI != null){
- float[] cinfo = endTLHI.tli.layout.getCaretInfo(endTLHI.thi);
- float x_left = - ptx + cinfo[0];
- float y_top = - pty + endTLHI.tli.yPosInPara;
- float y_bot = y_top - cinfo[3] + cinfo[5];
- if(x_left >= 0 && x_left <= tw && y_top >= 0 && y_bot <= th){
- winApp.strokeWeight(1.5f);
- winApp.stroke(palette[12].getRGB());
- winApp.line(tx+x_left, ty + Math.max(0, y_top), tx+x_left, ty + Math.min(th, y_bot));
- }
- }
- winApp.popMatrix();
- // Draw scrollbars
- if(children != null){
- for(GAbstractControl c : children)
- c.draw();
- }
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- public PGraphics getSnapshot(){
- updateBuffer();
- PGraphics snap = winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
- snap.beginDraw();
- snap.image(buffer,0,0);
- if(hsb != null){
- snap.pushMatrix();
- snap.translate(hsb.getX(), hsb.getY());
- snap.image(hsb.getBuffer(), 0, 0);
- snap.popMatrix();
- }
- if(vsb != null){
- snap.pushMatrix();
- //snap.translate(vsb.getX(), vsb.getY() - vsb.width);
- snap.translate(width - TPAD6, TPAD6);
- snap.rotate(PApplet.PI/2);
- snap.image(vsb.getBuffer(), 0, 0);
- snap.popMatrix();
- }
- snap.endDraw();
- return snap;
- }
-
- protected void keyPressedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown){
- boolean validKeyCombo = true;
-
- switch(keyCode){
- case LEFT:
- moveCaretLeft(endTLHI);
- break;
- case RIGHT:
- moveCaretRight(endTLHI);
- break;
- case UP:
- moveCaretUp(endTLHI);
- break;
- case DOWN:
- moveCaretDown(endTLHI);
- break;
- case GConstants.HOME:
- if(ctrlDown) // move to start of text
- moveCaretStartOfText(endTLHI);
- else // Move to start of line
- moveCaretStartOfLine(endTLHI);
- break;
- case GConstants.END:
- if(ctrlDown) // move to end of text
- moveCaretEndOfText(endTLHI);
- else // Move to end of line
- moveCaretEndOfLine(endTLHI);
- break;
- case 'A':
- if(ctrlDown){
- moveCaretStartOfText(startTLHI);
- moveCaretEndOfText(endTLHI);
- // Make shift down so that the start caret position is not
- // moved to match end caret position.
- shiftDown = true;
- }
- else
- validKeyCombo = false;
- break;
- case 'C':
- if(ctrlDown)
- GClip.copy(getSelectedText());
- validKeyCombo = false;
- break;
- case 'V':
- if(ctrlDown){
- String p = GClip.paste();
- if(p.length() > 0){
- // delete selection and add
- if(hasSelection())
- stext.deleteCharacters(pos, nbr);
- stext.insertCharacters(p, pos);
- adjust = p.length();
- textChanged = true;
- }
- }
- else
- validKeyCombo = false;
- break;
- default:
- validKeyCombo = false;
- }
-
- if(validKeyCombo){
- calculateCaretPos(endTLHI);
- //****************************************************************
- // If we have moved to the end of a paragraph marker
- if(caretX > stext.getWrapWidth()){
- switch(keyCode){
- case LEFT:
- case UP:
- case DOWN:
- case END:
- moveCaretLeft(endTLHI);
- validKeyCombo = true;
- break;
- case RIGHT:
- if(!moveCaretRight(endTLHI))
- moveCaretLeft(endTLHI);
- validKeyCombo = true;
- }
- // Calculate new caret position
- // calculateCaretPos(startTLHI);
- calculateCaretPos(endTLHI);
- }
- //****************************************************************
-
- calculateCaretPos(endTLHI);
-
- if(!shiftDown)
- startTLHI.copyFrom(endTLHI);
- bufferInvalid = true;
- }
- }
-
- protected void keyTypedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown){
- int ascii = (int)keyChar;
- newline = false;
- backspace = false;
- if(isDisplayable(ascii)){
- if(hasSelection())
- stext.deleteCharacters(pos, nbr);
- stext.insertCharacters("" + keyChar, pos);
- adjust = 1; textChanged = true;
- }
- else if(keyChar == BACKSPACE){
- if(hasSelection()){
- stext.deleteCharacters(pos, nbr);
- adjust = 0; textChanged = true;
- }
- else if(stext.deleteCharacters(pos - 1, 1)){
- adjust = -1; textChanged = true; backspace = true;
- }
- }
- else if(keyChar == DELETE){
- if(hasSelection()){
- stext.deleteCharacters(pos, nbr);
- adjust = 0; textChanged = true;
- }
- else if(stext.deleteCharacters(pos, 1)){
- adjust = 0; textChanged = true;
- }
- }
- else if(keyChar == ENTER || keyChar == RETURN) {
- fireEvent(this, GEvent.ENTERED); // Ticket 11
- if(stext.insertEOL(pos)){
- adjust = 1; textChanged = true;
- newline = true;
- }
- }
- else if(keyChar == TAB){
- // If possible move to next text control
- if(tabManager != null){
- boolean result = (shiftDown) ? tabManager.prevControl(this) : tabManager.nextControl(this);
- if(result){
- startTLHI.copyFrom(endTLHI);
- return;
- }
- }
- }
- // If we have emptied the text then recreate a one character string (space)
- if(stext.length() == 0){
- stext.insertCharacters(" ", 0);
- adjust++; textChanged = true;
- }
- }
-
- protected boolean changeText(){
- if(!super.changeText())
- return false;
- // The following actions handle multi-line stuff
- // Do we have to move cursor to start of next line
- if(newline) {
- if(pos >= stext.length()){
- stext.insertCharacters(" ", pos);
- stext.getLines(buffer.g2);
- }
- moveCaretRight(endTLHI);
- calculateCaretPos(endTLHI);
- }
- if(backspace && pos > 0){
- char ch = stext.getPlainText().charAt(pos-1);
- if(ch == '\n'){
- moveCaretRight(endTLHI);
- calculateCaretPos(endTLHI);
- }
- if(pos >= stext.length()){
- stext.insertCharacters(" ", pos);
- stext.getLines(buffer.g2);
- }
- }
- // Finish off by ensuring no selection, invalidate buffer etc.
- startTLHI.copyFrom(endTLHI);
- return true;
-
- }
-
- /**
- * Move caret to home position
- * @return true if caret moved else false
- */
- protected boolean moveCaretStartOfLine(TextLayoutHitInfo currPos){
- if(currPos.thi.getCharIndex() == 0)
- return false; // already at start of line
- currPos.thi = currPos.tli.layout.getNextLeftHit(1);
- return true;
- }
-
- protected boolean moveCaretEndOfLine(TextLayoutHitInfo currPos){
- if(currPos.thi.getCharIndex() == currPos.tli.nbrChars - 1)
- return false; // already at end of line
- currPos.thi = currPos.tli.layout.getNextRightHit(currPos.tli.nbrChars - 1);
- return true;
- }
-
- protected boolean moveCaretStartOfText(TextLayoutHitInfo currPos){
- if(currPos.tli.lineNo == 0 && currPos.thi.getCharIndex() == 0)
- return false; // already at start of text
- currPos.tli = stext.getTLIforLineNo(0);
- currPos.thi = currPos.tli.layout.getNextLeftHit(1);
- return true;
- }
-
- protected boolean moveCaretEndOfText(TextLayoutHitInfo currPos){
- if(currPos.tli.lineNo == stext.getNbrLines() - 1 && currPos.thi.getCharIndex() == currPos.tli.nbrChars - 1)
- return false; // already at end of text
- currPos.tli = stext.getTLIforLineNo(stext.getNbrLines() - 1);
- currPos.thi = currPos.tli.layout.getNextRightHit(currPos.tli.nbrChars - 1);
- return true;
- }
-
- protected boolean moveCaretUp(TextLayoutHitInfo currPos){
- if(currPos.tli.lineNo == 0)
- return false;
- TextLayoutInfo ntli = stext.getTLIforLineNo(currPos.tli.lineNo - 1);
- TextHitInfo nthi = ntli.layout.hitTestChar(caretX, 0);
- currPos.tli = ntli;
- currPos.thi = nthi;
- return true;
- }
-
- protected boolean moveCaretDown(TextLayoutHitInfo currPos){
- if(currPos.tli.lineNo == stext.getNbrLines() - 1)
- return false;
- TextLayoutInfo ntli = stext.getTLIforLineNo(currPos.tli.lineNo + 1);
- TextHitInfo nthi = ntli.layout.hitTestChar(caretX, 0);
- currPos.tli = ntli;
- currPos.thi = nthi;
- return true;
- }
-
- /**
- * Move caret left by one character. If necessary move to the end of the line above
- * @return true if caret was moved else false
- */
- protected boolean moveCaretLeft(TextLayoutHitInfo currPos){
- TextLayoutInfo ntli;
- TextHitInfo nthi = currPos.tli.layout.getNextLeftHit(currPos.thi);
- if(nthi == null){
- // Move the caret to the end of the previous line
- if(currPos.tli.lineNo == 0)
- // Can't goto previous line because this is the first line
- return false;
- else {
- // Move to end of previous line
- ntli = stext.getTLIforLineNo(currPos.tli.lineNo - 1);
- nthi = ntli.layout.getNextRightHit(ntli.nbrChars-1);
- currPos.tli = ntli;
- currPos.thi = nthi;
- }
- }
- else {
- // Move the caret to the left of current position
- currPos.thi = nthi;
- }
- return true;
- }
-
- /**
- * Move caret right by one character. If necessary move to the start of the next line
- * @return true if caret was moved else false
- */
- protected boolean moveCaretRight(TextLayoutHitInfo currPos){
- TextLayoutInfo ntli;
- TextHitInfo nthi = currPos.tli.layout.getNextRightHit(currPos.thi);
- if(nthi == null){
- // Move the caret to the start of the next line the previous line
- if(currPos.tli.lineNo >= stext.getNbrLines() - 1)
- // Can't goto next line because this is the last line
- return false;
- else {
- // Move to start of next line
- ntli = stext.getTLIforLineNo(currPos.tli.lineNo + 1);
- nthi = ntli.layout.getNextLeftHit(1);
- currPos.tli = ntli;
- currPos.thi = nthi;
- }
- }
- else {
- // Move the caret to the right of current position
- currPos.thi = nthi;
- }
- return true;
- }
-
- /**
- * Move the insertion point (caret) to the specified line and character. If the position is invalid
- * then the caret is not moved. The text will be scrolled so that the caret position is visible.
- *
- * @param lineNo the line number (starts at 0)
- * @param charNo the character position on the line (starts at 0)
- */
- public void moveCaretTo(int lineNo, int charNo){
- try {
- TextLayoutHitInfo tlhi = stext.getTLHIforCharPosition(lineNo, charNo);
- if(tlhi != null){
- startTLHI.copyFrom(tlhi);
- endTLHI.copyFrom(tlhi);
- calculateCaretPos(tlhi);
- keepCursorInView = true;
- showCaret = true;
- }
- }
- catch(Exception e){}
- }
-
- /**
- * Get the current caret position.
- *
- * The method will always return a 2 element array with the current caret position
- * { line no, char no }
- *
- * If the current caret position is undefined then it will return the array { -1, -1 }
- *
- * @return a two element int array holding the caret position.
- */
- public int[] getCaretPos(){
- return getCaretPos(null);
- }
-
- /**
- * Get the current caret position.
- *
- * If the parameter is a 2 element int array then it will be populated with the line number [0]
- * and character no [1] of the caret's current position.
- *
- * The method will always return a 2 element array with the current caret position
- * { line no, char no }
- *
- * If the current caret position is undefined then it will return the array { -1, -1 }
- *
- * @param cpos array to be populated with caret position
- * @return a two element int array holding the caret position.
- */
- public int[] getCaretPos(int [] cpos){
- if(cpos == null || cpos.length != 2)
- cpos = new int[2];
- if(endTLHI == null || endTLHI.tli == null || endTLHI.thi == null){
- cpos[0] = cpos[1] = -1;
- }
- else {
- cpos[0] = endTLHI.tli.lineNo;
- cpos[1] = endTLHI.thi.getCharIndex();
- }
- return cpos;
- }
-
- /**
- * Will respond to mouse events.
- */
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- ox -= tx; oy -= ty; // Remove translation
-
- currSpot = whichHotSpot(ox, oy);
-
- if(currSpot == 1 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(currSpot == 1){
- if(focusIsWith != this && z >= focusObjectZ()){
- keepCursorInView = true;
- takeFocus();
- }
- dragging = false;
- // If there is just a space then select it so it gets deleted on first key press
- if(stext.getPlainText().equals(""))
- stext.setText(" ", stext.getWrapWidth());
- if(stext.getPlainText().equals(" ")){
- LinkedList lines = stext.getLines(buffer.g2);
- startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-
- endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
- int lastChar = endTLHI.tli.layout.getCharacterCount();
- endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
- }
- else {
- endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
- startTLHI = new TextLayoutHitInfo(endTLHI);
- }
- calculateCaretPos(endTLHI);
- bufferInvalid = true;
- }
- else { // Not over this control so if we have focus loose it
- if(focusIsWith == this)
- loseFocus(null);
- }
- break;
- case MouseEvent.RELEASE:
- dragging = false;
- bufferInvalid = true;
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this){
- keepCursorInView = true;
- dragging = true;
- endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
- calculateCaretPos(endTLHI);
- fireEvent(this, GEvent.SELECTION_CHANGED);
- bufferInvalid = true;
- }
- break;
- }
- }
-
- protected void calculateCaretPos(TextLayoutHitInfo tlhi){
- float temp[] = tlhi.tli.layout.getCaretInfo(tlhi.thi);
- caretX = temp[0];
- caretY = tlhi.tli.yPosInPara;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTextBase.java b/Processing/libraries/G4P/src/g4p_controls/GTextBase.java
deleted file mode 100644
index 6181456..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTextBase.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2013 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Font;
-import java.awt.font.TextAttribute;
-
-import processing.core.PApplet;
-
-/**
- * Base class for any control that uses styled text.
- *
- * @author Peter Lager
- *
- */
-public abstract class GTextBase extends GAbstractControl {
-
- /** The styled text used by this control */
- protected StyledString stext = new StyledString("");
-
- protected Font localFont = G4P.globalFont;
-
-
- /**
- * Constructor
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GTextBase(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- setFont(localFont);
- }
-
- /**
- * Used internally to enforce minimum size constraints and to enable
- * minimising the height used by text icon controls (labels, buttons,
- * radio button and checkboxes)
- *
- * @param w the new width
- * @param h the new height
- */
- protected void resize(int w, int h){
- super.resize(w, h);
- setFont(localFont);
- }
-
- /**
- * Set the text to be displayed.
- *
- * @param text
- */
- public void setText(String text){
- if(text == null || text.length() == 0 )
- text = " ";
- stext.setText(text, Integer.MAX_VALUE);
- bufferInvalid = true;
- }
-
- /**
- * Load the styled string to be used by this control.
- *
- * @param fname the name of the file to use
- * @return true if loaded successfully else false
- */
- public boolean loadText(String fname){
- StyledString ss = StyledString.load(winApp, fname);
- if(ss != null){
- setStyledText(ss);
- stext.startIdx = stext.endIdx = -1;
- bufferInvalid = true;
- return true;
- }
- return false;
- }
-
- /**
- * Save the styled text used by this control to file.
- *
- * @param fname the name of the file to use
- * @return true if saved successfully else false
- */
- public boolean saveText(String fname){
- stext.startIdx = stext.endIdx = -1;
- StyledString.save(winApp, stext, fname);
- return true;
- }
-
- /**
- * Set the font to be used in this control
- *
- * @param font AWT font to use
- */
- public void setFont(Font font) {
- if(font != null && font != localFont) {// && buffer != null){
- localFont = font;
- bufferInvalid = true;
- }
- }
-
- /**
- * Allows the user to provide their own styled text for this component
- * @param ss
- */
- public void setStyledText(StyledString ss){
- if(ss != null) {
- stext = ss;
- stext.setWrapWidth((int)width - TPAD4);
- bufferInvalid = true;
- }
- }
-
- public void forceBufferUpdate(){
- if(stext != null)
- stext.invalidateText();
- bufferInvalid = true;
- }
-
- /**
- * Clear all applied styles from the whole text.
- */
- public void setTextPlain(){
- stext.clearAttributes();
- bufferInvalid = true;
- }
-
- /**
- * Make the selected characters bold.
- * Characters affected are >= start and < end
- *
- * @param start the first character to style
- * @param end the first character not to style
- */
- public void setTextBold(int start, int end){
- addAttributeImpl(G4P.WEIGHT, G4P.WEIGHT_BOLD, start, end);
- }
-
- /**
- * Make all the characters bold.
- */
- public void setTextBold(){
- addAttributeImpl(G4P.WEIGHT, G4P.WEIGHT_BOLD);
- }
-
- /**
- * Make the selected characters italic.
- * Characters affected are >= start and < end
- *
- * @param start the first character to style
- * @param end the first character not to style
- */
- public void setTextItalic(int start, int end){
- addAttributeImpl(G4P.POSTURE, G4P.POSTURE_OBLIQUE, start, end);
- }
-
- /**
- * Make all the characters italic.
- */
- public void setTextItalic(){
- addAttributeImpl(G4P.POSTURE, G4P.POSTURE_OBLIQUE);
- }
-
- /**
- * Get the text used for this control.
- * @return the displayed text with styling
- */
- public StyledString getStyledText(){
- return stext;
- }
-
- /**
- * Get the text used for this control.
- * @return the displayed text without styling
- */
- public String getText(){
- return stext.getPlainText();
- }
-
- /**
- * Apply the style to the whole text
- *
- * @param style the style attribute
- * @param value 'amount' to apply
- */
- protected void addAttributeImpl(TextAttribute style, Object value){
- stext.addAttribute(style, value);
- bufferInvalid = true;
- }
-
- /**
- * Apply the style to a portion of the string
- *
- * @param style the style attribute
- * @param value 'amount' to apply
- * @param s first character to be included for styling
- * @param e the first character not to be included for styling
- */
- protected void addAttributeImpl(TextAttribute style, Object value, int s, int e){
- if(s >= e) return;
- if(s < 0) s = 0;
- if(e > stext.length()) e = stext.length();
- stext.addAttribute(style, value, s, e);
- bufferInvalid = true;
- }
-
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTextField.java b/Processing/libraries/G4P/src/g4p_controls/GTextField.java
deleted file mode 100644
index 831d04d..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTextField.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-import g4p_controls.StyledString.TextLayoutHitInfo;
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.font.TextLayout;
-import java.awt.geom.GeneralPath;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.core.PGraphics;
-import processing.event.KeyEvent;
-import processing.event.MouseEvent;
-
-/**
- * The text field component.
- *
- * This control allows the user to enter and edit a single line of text. The control
- * also allows default text and a horizontal scrollbar.
- *
- * can be created to manage either a single line of text or
- * multiple lines of text.
- *
- * Enables user text input at runtime. Text can be selected using the mouse
- * or keyboard shortcuts and then copied or cut to the clipboard. Text
- * can also be pasted in.
- *
- * Fires SELECTION_CHANGED, CHANGED, ENTERED, LOST_FOCUS, GETS_FOCUS events.
- * The focus events are only fired if the control is added to a GTabManager object.
- *
- * @author Peter Lager
- *
- */
-public class GTextField extends GEditableTextControl {
-
- /**
- * Create a text field without a scrollbar.
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- */
- public GTextField(PApplet theApplet, float p0, float p1, float p2, float p3) {
- this(theApplet, p0, p1, p2, p3, SCROLLBARS_NONE);
- }
-
- /**
- * Create a text field with the given scrollbar policy.
- * This policy can be one of these
- *
- *
SCROLLBARS_NONE
- *
SCROLLBARS_HORIZONTAL_ONLY
- *
- * If you want the scrollbar to auto hide then perform a logical or with
- *
- *
SCROLLBARS_AUTOHIDE
- *
- * e.g. SCROLLBARS_HORIZONTAL_ONLY | SCROLLBARS_AUTOHIDE
- *
- * @param theApplet
- * @param p0
- * @param p1
- * @param p2
- * @param p3
- * @param sbPolicy
- */
- public GTextField(PApplet theApplet, float p0, float p1, float p2, float p3, int sbPolicy) {
- super(theApplet, p0, p1, p2, p3, sbPolicy);
- children = new LinkedList();
- tx = ty = 2;
- tw = width - 2 * 2;
- th = height - ((scrollbarPolicy & SCROLLBAR_HORIZONTAL) != 0 ? 11 : 0);
- wrapWidth = Integer.MAX_VALUE;
- gpTextDisplayArea = new GeneralPath();
- gpTextDisplayArea.moveTo( 0, 0);
- gpTextDisplayArea.lineTo( 0, th);
- gpTextDisplayArea.lineTo(tw, th);
- gpTextDisplayArea.lineTo(tw, 0);
- gpTextDisplayArea.closePath();
-
- hotspots = new HotSpot[]{
- new HSrect(1, tx, ty, tw, th), // typing area
- new HSrect(9, 0, 0, width, height) // control surface
- };
-
- G4P.pushStyle();
- G4P.showMessages = false;
-
- z = Z_STICKY;
-
- G4P.control_mode = GControlMode.CORNER;
- if((scrollbarPolicy & SCROLLBAR_HORIZONTAL) != 0){
- hsb = new GScrollbar(theApplet, 0, 0, tw, 10);
- addControl(hsb, tx, ty + th - hsb.halfHeight + 2, 0);
- hsb.addEventHandler(this, "hsbEventHandler");
- hsb.setAutoHide(autoHide);
- }
- G4P.popStyle();
- setText("");
-
- createEventHandler(G4P.sketchWindow, "handleTextEvents",
- new Class>[]{ GEditableTextControl.class, GEvent.class },
- new String[]{ "textcontrol", "event" }
- );
- registeredMethods = PRE_METHOD | DRAW_METHOD | MOUSE_METHOD | KEY_METHOD;
-
- // Must register control
- G4P.registerControl(this);
- bufferInvalid = true;
- }
-
- /**
- * Set the styled text for this textfield after ensuring that all EOL characters
- * have been removed.
- * @param ss
- */
- public void setStyledText(StyledString ss){
- stext = ss.convertToSingleLineText();
- stext.getLines(buffer.g2);
- if(stext.getNbrLines() > 0){
- endTLHI.tli = stext.getLines(buffer.g2).getFirst();
- endTLHI.thi = endTLHI.tli.layout.getNextLeftHit(1);
- startTLHI.copyFrom(endTLHI);
- calculateCaretPos(endTLHI);
- keepCursorInView = true;
- }
- ptx = pty = 0;
- // If needed update the horizontal scrollbar
- if(hsb != null){
- if(stext.getMaxLineLength() < tw)
- hsb.setValue(0, 1);
- else
- hsb.setValue(0, tw/stext.getMaxLineLength());
- }
- bufferInvalid = true;
- }
-
- /**
- * Set the text to be displayed.
- *
- * @param text
- */
- public void setText(String text){
- if(text != null){
- stext.setText(text, Integer.MAX_VALUE);
- setScrollbarValues(0,0);
- bufferInvalid = true;
- }
- }
-
- /**
- * Add some plain text to the end of the existing text.
- *
- * @param extraText
- */
- public void appendText(String extraText){
- if(extraText == null || extraText.equals(""))
- return;
- if(stext.insertCharacters(extraText, stext.length()) == 0)
- return;
- LinkedList lines = stext.getLines(buffer.g2);
- endTLHI.tli = lines.getLast();
- endTLHI.thi = endTLHI.tli.layout.getNextRightHit(endTLHI.tli.nbrChars - 1);
- startTLHI.copyFrom(endTLHI);
- calculateCaretPos(endTLHI);
- if(hsb != null){
- float hvalue = lines.getLast().layout.getVisibleAdvance();
- float hlinelength = stext.getMaxLineLength();
- float hfiller = Math.min(1, tw/hlinelength);
- if(caretX < tw)
- hsb.setValue(0,hfiller);
- else
- hsb.setValue(hvalue/hlinelength, hfiller);
- keepCursorInView = true;
- }
- bufferInvalid = true;
- }
-
- public PGraphics getSnapshot(){
- updateBuffer();
- PGraphics snap = winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
- snap.beginDraw();
- snap.image(buffer,0,0);
- if(hsb != null){
- snap.pushMatrix();
- snap.translate(hsb.getX(), hsb.getY() - hsb.halfHeight + 4);
- snap.image(hsb.getBuffer(), 0, 0);
- snap.popMatrix();
- }
- snap.endDraw();
- return snap;
- }
-
- public void pre(){
- if(keepCursorInView){
- boolean horzScroll = false;
- float max_ptx = caretX - tw + 2;
- if(endTLHI != null){
- if(ptx > caretX){ // Scroll to the left (text moves right)
- ptx -= HORZ_SCROLL_RATE;
- if(ptx < 0) ptx = 0;
- horzScroll = true;
- }
- else if(ptx < max_ptx){ // Scroll to the right (text moves left)?
- ptx += HORZ_SCROLL_RATE;
- if(ptx > max_ptx) ptx = max_ptx;
- horzScroll = true;
- }
- // Ensure that we show as much text as possible keeping the caret in view
- // This is particularly important when deleting from the end of the text
- if(ptx > 0 && endTLHI.tli.layout.getAdvance() - ptx < tw - 2){
- ptx = Math.max(0, endTLHI.tli.layout.getAdvance() - tw - 2);
- horzScroll = true;
- }
- if(horzScroll && hsb != null)
- hsb.setValue(ptx / (stext.getMaxLineLength() + 4));
- }
- // If we have scrolled invalidate the buffer otherwise forget it
- if(horzScroll)
- bufferInvalid = true;
- else
- keepCursorInView = false;
- }
- }
-
- public void mouseEvent(MouseEvent event){
- if(!visible || !enabled || !available) return;
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- ox -= tx; oy -= ty; // Remove translation
-
- currSpot = whichHotSpot(ox, oy);
-
- if(currSpot == 1 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(currSpot == 1){
- if(focusIsWith != this && z >= focusObjectZ()){
- keepCursorInView = true;
- takeFocus();
- }
- dragging = false;
- // If there is just a space then select it so it gets deleted on first key press
- if(stext.getPlainText().equals(""))
- stext.setText(" ");
- if(stext.getPlainText().equals(" ")){
- LinkedList lines = stext.getLines(buffer.g2);
- startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-
- endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
- int lastChar = endTLHI.tli.layout.getCharacterCount();
- endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
- }
- else {
- endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
- startTLHI = new TextLayoutHitInfo(endTLHI);
- }
- calculateCaretPos(endTLHI);
- bufferInvalid = true;
- }
- else { // Not over this control so if we have focus loose it
- if(focusIsWith == this)
- loseFocus(null);
- }
- break;
- case MouseEvent.RELEASE:
- dragging = false;
- bufferInvalid = true;
- break;
- case MouseEvent.DRAG:
- if(focusIsWith == this){
- keepCursorInView = true;
- dragging = true;
- endTLHI = stext.calculateFromXY(buffer.g2, ox + ptx, oy + pty);
- calculateCaretPos(endTLHI);
- fireEvent(this, GEvent.SELECTION_CHANGED);
- bufferInvalid = true;
- }
- break;
- }
- }
-
- public void keyEvent(KeyEvent e) {
- if(!visible || !enabled || !textEditEnabled || !available) return;
- if(focusIsWith == this && endTLHI != null){
- char keyChar = e.getKey();
- int keyCode = e.getKeyCode();
- int keyID = e.getAction();
- boolean shiftDown = e.isShiftDown();
- boolean ctrlDown = e.isControlDown();
-
- textChanged = false;
- keepCursorInView = true;
-
- int startPos = pos, startNbr = nbr;
-
- // Get selection details
- endChar = endTLHI.tli.startCharIndex + endTLHI.thi.getInsertionIndex();
- startChar = (startTLHI != null) ? startTLHI.tli.startCharIndex + startTLHI.thi.getInsertionIndex() : endChar;
- pos = endChar;
- nbr = 0;
- adjust = 0;
- if(endChar != startChar){ // Have we some text selected?
- if(startChar < endChar){ // Forward selection
- pos = startChar; nbr = endChar - pos;
- }
- else if(startChar > endChar){ // Backward selection
- pos = endChar; nbr = startChar - pos;
- }
- }
- if(startPos >= 0){
- if(startPos != pos || startNbr != nbr)
- fireEvent(this, GEvent.SELECTION_CHANGED);
- }
- // Select either keyPressedProcess or keyTypeProcess. These two methods are overridden in child classes
- if(keyID == KeyEvent.PRESS) {
- keyPressedProcess(keyCode, keyChar, shiftDown, ctrlDown);
- setScrollbarValues(ptx, pty);
- }
- else if(keyID == KeyEvent.TYPE ){ // && e.getKey() != KeyEvent.CHAR_UNDEFINED && !ctrlDown){
- keyTypedProcess(keyCode, keyChar, shiftDown, ctrlDown);
- setScrollbarValues(ptx, pty);
- }
- if(textChanged){
- changeText();
- fireEvent(this, GEvent.CHANGED);
- }
- }
- }
-
- /**
- * Do not call this method directly, G4P uses it to handle input from
- * the horizontal scrollbar.
- */
- public void hsbEventHandler(GScrollbar scrollbar, GEvent event){
- keepCursorInView = false;
- ptx = hsb.getValue() * (stext.getMaxLineLength() + 4);
- bufferInvalid = true;
- }
-
- protected void keyPressedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown){
- boolean validKeyCombo = true;
-
- switch(keyCode){
- case LEFT:
- moveCaretLeft(endTLHI);
- break;
- case RIGHT:
- moveCaretRight(endTLHI);
- break;
- case GConstants.HOME:
- moveCaretStartOfLine(endTLHI);
- break;
- case GConstants.END:
- moveCaretEndOfLine(endTLHI);
- break;
- case 'A':
- if(ctrlDown){ // Ctrl + A select all
- moveCaretStartOfLine(startTLHI);
- moveCaretEndOfLine(endTLHI);
- // Make shift down so that the start caret position is not
- // moved to match end caret position.
- shiftDown = true;
- }
- else
- validKeyCombo = false;
- break;
- case 'C':
- if(ctrlDown) // Ctrl + C copy selected text
- GClip.copy(getSelectedText());
- validKeyCombo = false;
- break;
- case 'V':
- if(ctrlDown){ // Ctrl + V paste selected text
- String p = GClip.paste();
- p.replaceAll("\n", "");
- if(p.length() > 0){
- // delete selection and add
- if(hasSelection())
- stext.deleteCharacters(pos, nbr);
- stext.insertCharacters(p, pos);
- adjust = p.length();
- textChanged = true;
- }
- }
- else
- validKeyCombo = false;
- break;
- default:
- validKeyCombo = false;
- }
- calculateCaretPos(endTLHI);
-
- if(validKeyCombo){
- if(!shiftDown) // Not extending selection
- startTLHI.copyFrom(endTLHI);
- bufferInvalid = true; // Selection changed
- }
- }
-
- protected void keyTypedProcess(int keyCode, char keyChar, boolean shiftDown, boolean ctrlDown){
- int ascii = (int)keyChar;
- if(isDisplayable(ascii)){
- if(hasSelection())
- stext.deleteCharacters(pos, nbr);
- stext.insertCharacters("" + keyChar, pos);
- adjust = 1; textChanged = true;
- }
- else if(keyChar == BACKSPACE){
- if(hasSelection()){
- stext.deleteCharacters(pos, nbr);
- adjust = 0; textChanged = true;
- }
- else if(stext.deleteCharacters(pos - 1, 1)){
- adjust = -1; textChanged = true;
- }
- }
- else if(keyChar == DELETE){
- if(hasSelection()){
- stext.deleteCharacters(pos, nbr);
- adjust = 0; textChanged = true;
- }
- else if(stext.deleteCharacters(pos, 1)){
- adjust = 0; textChanged = true;
- }
- }
- else if(keyChar == ENTER || keyChar == RETURN) {
- fireEvent(this, GEvent.ENTERED);
- // If we have a tab manager and can tab forward then do so
- if(tabManager != null && tabManager.nextControl(this)){
- startTLHI.copyFrom(endTLHI);
- return;
- }
- }
- else if(keyChar == TAB){
- // If possible move to next text control
- if(tabManager != null){
- boolean result = (shiftDown) ? tabManager.prevControl(this) : tabManager.nextControl(this);
- if(result){
- startTLHI.copyFrom(endTLHI);
- return;
- }
- }
- }
- // If we have emptied the text then recreate a one character string (space)
- if(stext.length() == 0){
- stext.insertCharacters(" ", 0);
- adjust++; textChanged = true;
- }
-// if(stext.length() == 0){
-// stext.insertCharacters(" ", 0);
-// adjust++; textChanged = true;
-// LinkedList lines = stext.getLines(buffer.g2);
-// startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
-// startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-//
-// endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
-// int lastChar = endTLHI.tli.layout.getCharacterCount();
-// endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
-// }
-
- }
-
- protected boolean changeText(){
- if(!super.changeText())
- return false;
- startTLHI.copyFrom(endTLHI);
- return true;
- }
-
-
- public void draw(){
- if(!visible) return;
- updateBuffer();
-
- winApp.pushStyle();
- winApp.pushMatrix();
-
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
-
- winApp.pushMatrix();
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
-
- // Draw caret if text display area
- if(focusIsWith == this && showCaret && endTLHI.tli != null){
- float[] cinfo = endTLHI.tli.layout.getCaretInfo(endTLHI.thi);
- float x_left = - ptx + cinfo[0];
- float y_top = - pty + endTLHI.tli.yPosInPara;
- float y_bot = y_top - cinfo[3] + cinfo[5];
- if(x_left >= 0 && x_left <= tw && y_top >= 0 && y_bot <= th){
- winApp.strokeWeight(1.5f);
- winApp.stroke(palette[12].getRGB());
- winApp.line(tx+x_left, ty+Math.max(0, y_top), tx+x_left, ty+Math.min(th, y_bot));
- }
- }
-
- winApp.popMatrix();
-
- if(children != null){
- for(GAbstractControl c : children)
- c.draw();
- }
- winApp.popMatrix();
- winApp.popStyle();
- }
-
- /**
- * If the buffer is invalid then redraw it.
- * @TODO need to use palette for colours
- */
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
-
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
-
- boolean usePromptText = promptText != null && !hasFocus() && (lines.isEmpty() || stext.getPlainText().equals("") || stext.getPlainText().equals(" "));
- if(usePromptText)
- lines = promptText.getLines(g2d);
-
- // If needed update the horizontal scrollbar
-// if(hsb != null){
-// if(stext.getMaxLineLength() < tw)
-// hsb.setValue(0, 1);
-// else
-// hsb.setValue(0, tw/stext.getMaxLineLength());
-// }
-
- TextLayoutHitInfo startSelTLHI = null, endSelTLHI = null;
- // Whole control surface if opaque
- if(opaque)
- buffer.background(palette[6].getRGB());
- else
- buffer.background(buffer.color(255,0));
-
- // Now move to top left corner of text display area
- buffer.translate(tx,ty);
-
- // Typing area surface
- buffer.noStroke();
- buffer.fill(palette[7].getRGB());
- buffer.rect(-1,-1,tw+2,th+2);
-
- g2d.setClip(gpTextDisplayArea);
- buffer.translate(-ptx, -pty);
- // Translate in preparation for display selection and text
-
- if(hasFocus() && stext.getPlainText().equals(" ")){
- lines = stext.getLines(buffer.g2);
- startTLHI = new TextLayoutHitInfo(lines.getFirst(), null);
- startTLHI.thi = startTLHI.tli.layout.getNextLeftHit(1);
-
- endTLHI = new TextLayoutHitInfo(lines.getLast(), null);
- int lastChar = endTLHI.tli.layout.getCharacterCount();
- endTLHI.thi = startTLHI.tli.layout.getNextRightHit(lastChar-1);
- }
-
- if(hasSelection()){
- if(endTLHI.compareTo(startTLHI) == -1){
- startSelTLHI = endTLHI;
- endSelTLHI = startTLHI;
- }
- else {
- startSelTLHI = startTLHI;
- endSelTLHI = endTLHI;
- }
- }
- // Display selection and text
- for(TextLayoutInfo lineInfo : lines){
- TextLayout layout = lineInfo.layout;
- buffer.translate(0, layout.getAscent());
- // Draw selection if any
- if(!usePromptText && hasSelection() && lineInfo.compareTo(startSelTLHI.tli) >= 0 && lineInfo.compareTo(endSelTLHI.tli) <= 0 ){
- int ss = startSelTLHI.thi.getInsertionIndex();
- int ee = endSelTLHI.thi.getInsertionIndex();
- g2d.setColor(palette[14]);
- Shape selShape = layout.getLogicalHighlightShape(ss, ee);
- g2d.fill(selShape);
- }
- // Draw text
- g2d.setColor(palette[2]);
- lineInfo.layout.draw(g2d, 0, 0);
- buffer.translate(0, layout.getDescent() + layout.getLeading());
- }
- g2d.setClip(null);
- buffer.endDraw();
- }
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTextIconAlignBase.java b/Processing/libraries/G4P/src/g4p_controls/GTextIconAlignBase.java
deleted file mode 100644
index f7d1b09..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTextIconAlignBase.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-import processing.core.PImage;
-
-/**
- * Base class for controls with text and/or icon.
- *
- * This class forms the basis for any control that has text and/or an icon.
- * Use the setIcon, setIconAlign, setText and setTextAlign to control
- * horizontal and vertical alignment of the icon and text within the control face.
- *
- * @author Peter Lager
- *
- */
-public abstract class GTextIconAlignBase extends GTextAlign {
-
- protected PImage[] bicon = null;
- protected int iconW = 0, iconH = 0;
- protected GAlign iconAlignH = GAlign.RIGHT, iconAlignV = GAlign.MIDDLE;
- protected int siX, siY;
-
-
- public GTextIconAlignBase(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- }
-
- /**
- * Set the text to be displayed and calculate the wrap length taking into
- * account any icon set.
- *
- * @param text
- */
- public void setText(String text){
- if(text == null || text.length() == 0 )
- text = " ";
- if(iconW == 0)
- stext.setText(text, (int) width - TPAD4);
- else
- stext.setText(text, (int) width - iconW - TPAD8);
- bufferInvalid = true;
- }
-
- /**
- * Set the icon to be used and the horizontal and/or vertical icon alignment.
- * Use the constants in GAlign e.g.
GAlign.LEFT
- *
- * @param fname the filename of the icon
- * @param nbrImages number of tiled images in the icon
- * @param horz LEFT or RIGHT
- * @param vert TOP, MIDDLE, BOTTOM
- */
- public void setIcon(String fname, int nbrImages, GAlign horz, GAlign vert){
- PImage iconImage = ImageManager.loadImage(winApp, fname);
- setIcon(iconImage, nbrImages, horz, vert);
- }
-
- /**
- * Set the icon to be used and the horizontal and/or vertical icon alignment.
- * Use the constants in GAlign e.g.
GAlign.LEFT
- *
- * If you want to set just one of these then pass null in the other
- *
- * @param icon the icon
- * @param nbrImages number of tiled images in the icon
- * @param horz LEFT or RIGHT
- * @param vert TOP, MIDDLE, BOTTOM
- */
- public void setIcon(PImage icon, int nbrImages, GAlign horz, GAlign vert){
- if(icon != null){
- if(nbrImages == 3)
- bicon = ImageManager.makeTiles1D(winApp, icon, nbrImages, 1);
- else {
- bicon = new PImage[3];
- PImage[] temp = ImageManager.makeTiles1D(winApp, icon, nbrImages, 1);
- System.arraycopy(temp, 0, bicon, 0, temp.length);
- for(int i = temp.length; i < 3; i++){
- bicon[i] = bicon[i-1];
- }
- }
-
- // We have loaded the image so validate alignment
- if(horz != null && horz.isHorzAlign() && horz != GAlign.CENTER){
- iconAlignH = horz;
- }
- if(vert != null && vert.isVertAlign()){
- iconAlignV = vert;
- }
- iconW = bicon[0].width;
- iconH = bicon[0].height;
- stext.setWrapWidth((int) width - iconW - TPAD8);
- bufferInvalid = true;
- }
- }
-
- /**
- * Change the alignment of an existing icon.
- * @param horz horizontal alignment (see @see GAlign)
- * @param vert vertical alignment (see @see GAlign)
- */
- public void setIconAlign(GAlign horz, GAlign vert){
- if(iconW != 0){
- if(horz != null && horz.isHorzAlign() && horz != GAlign.CENTER){
- iconAlignH = horz;
- }
- if(vert != null && vert != null && vert.isVertAlign()){
- iconAlignV = vert;
- }
- bufferInvalid = true;
- }
- }
-
- /**
- * This will change the controls height without changing the width so that it just
- * fits round the text and icon (if any).
- */
- public void setHeightToFit(){
- if(stext != null && buffer != null){
- stext.getLines(buffer.g2);
- int high = Math.round(stext.getTextAreaHeight());
- high = Math.max(high, iconH);
- int wide = Math.round(width);
- resize(wide, high); // resize this control
- calcAlignment();
- bufferInvalid = true;
- }
- }
-
- /**
- * Calculate various values based on alignment of text and icon
- */
- protected void calcAlignment(){
- super.calcAlignment(); // calculate the text alignment
- if(iconW != 0){
- switch(iconAlignH){
- case LEFT:
- siX = TPAD2;
- if(textAlignH != GAlign.RIGHT)
- stX += (iconW + TPAD4); // Image on left so adjust text start x position
- break;
- case RIGHT:
- default:
- siX = (int)width - iconW - TPAD4;
- if(textAlignH == GAlign.RIGHT)
- stX -= (iconW + TPAD4);
- break;
- }
- switch(iconAlignV){
- case TOP:
- siY = TPAD2;
- break;
- case BOTTOM:
- siY = (int) height - iconH - TPAD4;
- break;
- case MIDDLE:
- default:
- siY = (int)(height - iconH)/2;
- }
- }
- }
-
- public String toString(){
- return tag;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GTimer.java b/Processing/libraries/G4P/src/g4p_controls/GTimer.java
deleted file mode 100644
index 2af8da1..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GTimer.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.lang.reflect.Method;
-
-import javax.swing.Timer;
-
-import processing.core.PApplet;
-
-/**
- * This class is used to trigger events at user defined intervals. The event will
- * call a user defined method/function. The only restriction is that the method
- * used has a single parameter of type GTimer and returns void eg
- *
- * void fireBall(GTimer timer){ ... }
- *
- *
- * Each timer object must have its own handler
- *
- * It has no visible GUI representation so will not appear in the GUI.
- *
- * @author Peter Lager
- *
- */
-public class GTimer implements GConstantsInternal {
-
- /* This must be set by the constructor */
- protected PApplet app;
-
- /* The object to handle the event */
- protected Object eventHandlerObject = null;
- /* The method in eventHandlerObject to execute */
- protected Method eventHandlerMethod = null;
- /* the name of the method to handle the event */
- protected String eventHandlerMethodName;
-
- // The number of repeats i.e. events to be fired.
- protected int nrepeats = -1;
-
- protected Timer timer = null;
-
- /**
- * Create the GTimer object with this ctor.
- *
- * 'methodName' is the method/function to be called every 'interval'
- * milliseconds. 'obj' is the object that contains the method/function
- * 'methodName'
- *
- * For most users 'methodName' will be in their main sketch so this
- * parameter has the same value as 'theApplet'
- *
- * @param theApplet a reference to the PApplet object (invariably this)
- * @param obj the object that has the method to be executed (likely to be this)
- * @param methodName the name of the method to be called by the timer
- * @param delay the initial delay and the time (in millisecs) between function calls
- */
- public GTimer(PApplet theApplet, Object obj, String methodName, int delay){
- this(theApplet, obj, methodName, delay, delay);
- }
-
- /**
- * Create the GTimer object with this ctor.
- *
- * 'methodName' is the method/function to be called every 'interval'
- * milliseconds. 'obj' is the object that contains the method/function
- * 'methodName'
- *
- * For most users 'methodName' will be in their main sketch so this
- * parameter has the same value as 'theApplet'
- *
- * @param theApplet a reference to the PApplet object (invariably this)
- * @param obj the object that has the method to be executed (likely to be this)
- * @param methodName the name of the method to be called by the timer
- * @param delay the time (in millisecs) between function calls
- * @param initDelay the initial delay (in millisecs)
- */
- public GTimer(PApplet theApplet, Object obj, String methodName, int delay, int initDelay){
- app = theApplet;
- createEventHandler(obj, methodName);
- // If we have something to handle the event then create the Timer
- if(eventHandlerObject != null){
- timer = new Timer(delay, new ActionListener(){
-
- public void actionPerformed(ActionEvent e) {
- fireEvent();
- }
-
- });
- timer.setInitialDelay(initDelay);
- timer.setDelay(delay);
- timer.stop();
- }
- }
-
- /**
- * See if 'obj' has a method called 'methodName' that has a single parameter of type
- * GTimer and if so keep a reference to it.
- *
- * @param obj
- * @param methodName
- */
- protected void createEventHandler(Object handlerObj, String methodName){
- try{
- eventHandlerMethod = handlerObj.getClass().getMethod(methodName, new Class>[] { GTimer.class } );
- eventHandlerObject = handlerObj;
- eventHandlerMethodName = methodName;
- } catch (Exception e) {
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { GTimer.class }});
- eventHandlerObject = null;
- }
- }
-
- /**
- * Attempt to fire an event for this timer. This will call the
- * method/function defined in the ctor.
- */
- protected void fireEvent(){
- if(eventHandlerMethod != null){
- try {
- eventHandlerMethod.invoke(eventHandlerObject, this);
- if(--nrepeats == 0)
- stop();
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {eventHandlerObject, eventHandlerMethodName, e } );
- System.out.println("Disabling " + eventHandlerMethod.getName() + " due to an unknown error");
- eventHandlerMethod = null;
- eventHandlerObject = null;
- }
- }
- }
-
- /**
- * Start the timer (call the method forever)
- */
- public void start(){
- this.nrepeats = -1;
- if(timer != null)
- timer.start();
- }
-
- /**
- * Start the timer and call the method for the number of
- * times indicated by nrepeats
- * If nrepeats is <=0 then repeat forever
- *
- * @param nrepeats
- */
- public void start(int nrepeats){
- this.nrepeats = nrepeats;
- if(timer != null)
- timer.start();
- }
-
- /**
- * Stop the timer (can be restarted with start() method)
- */
- public void stop(){
- if(timer != null)
- timer.stop();
- }
-
- /**
- * Is the timer running?
- * @return true if running
- */
- public boolean isRunning(){
- if(timer != null)
- return timer.isRunning();
- else
- return false;
- }
-
- /**
- * Set the interval between events
- * @param interval delay between events in milliseconds
- */
- public void setInterval(int interval){
- if(timer != null)
- timer.setDelay(interval);
- }
-
- /**
- * Set the delay before the first event is triggered
- * @param initDelay initial delay in milliseconds
- */
- public void setInitialDelay(int initDelay){
- if(timer != null)
- timer.setInitialDelay(initDelay);
- }
-
- /**
- * Sets the initial delay and the interval between events.
- * This is equivalent to calling both -
- *
- * @param delay initial delay and interval in milliseconds
- */
- public void setDelay(int delay){
- if(timer != null){
- timer.setInitialDelay(delay);
- timer.setDelay(delay);
- }
- }
-
- /**
- * Get the interval time (milliseconds) between
- * events.
- * @return interval in millsecs or -1 if the timer failed to
- * be created.
- */
- public int getInterval(){
- if(timer != null)
- return timer.getDelay();
- else
- return -1;
- }
-
- /**
- * Get the initial delay time (milliseconds).
- * @return initial delay in millsecs or -1 if the timer failed to
- * be created.
- */
- public int getInitialDelay(){
- if(timer != null)
- return timer.getInitialDelay();
- else
- return -1;
- }
-
- /**
- * See if the GTimer object has been created successfully
- * @return true if successful
- */
- public boolean isValid(){
- return (eventHandlerObject != null && timer != null);
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GToggleControl.java b/Processing/libraries/G4P/src/g4p_controls/GToggleControl.java
deleted file mode 100644
index 271de41..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GToggleControl.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import g4p_controls.HotSpot.HSrect;
-import g4p_controls.StyledString.TextLayoutInfo;
-
-import java.awt.Graphics2D;
-import java.awt.font.TextLayout;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.event.MouseEvent;
-
-/**
- * This class forms the basis for any two-state type control (toggle switch).
- * A toggle control can be in one of 2 states selected or not selected
- * and is the base class for the GOption and GCheckbox controls.
- *
- * @author Peter Lager
- *
- */
-public abstract class GToggleControl extends GTextIconAlignBase {
-
- protected GToggleGroup group = null;
-
- protected boolean selected = false;
-
- public GToggleControl(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- opaque = false;
- hotspots = new HotSpot[]{
- new HSrect(1, 0, 0, width, height) // control surface
- };
- }
-
- // This method is called if this control is added to a toggle group. A toggle group
- // enforces single option selection from the group. Override this with an empty method
- // to allow each toggle control to be independent of others.
- protected void setToggleGroup(GToggleGroup tg) {
- this.group = tg;
- }
-
- /**
- * Get the toggle group. If null is returned then it is not part
- * of the group.
- */
- public GToggleGroup getToggleGroup(){
- return group;
- }
-
- /**
- * @return the selected
- */
- public boolean isSelected() {
- return selected;
- }
-
- /**
- * @param selected the selected to set
- */
- public void setSelected(boolean selected) {
- if(this.selected != selected)
- bufferInvalid = true;
- if(selected && group != null)
- group.makeSelected(this);
- this.selected = selected;
- }
-
-// public void setSelected() {
-// setSelected(true);
-// }
-
- /*
- * Only executed when clicked in the GUI.
- */
- protected void hasBeenClicked(){
- if(group == null){
- // Independent action e.g. check box
- selected = !selected;
- bufferInvalid = true;
- }
- else {
- // Only need to do something if we click on an unselected option
- if(!selected)
- setSelected(true);
- }
- }
-
- public void mouseEvent(MouseEvent event){
- // If this option does not belong to a group then ignore mouseEvents
- if(!visible || !enabled || !available) return;
-
-
- calcTransformedOrigin(winApp.mouseX, winApp.mouseY);
- currSpot = whichHotSpot(ox, oy);
- // currSpot == 1 for text display area
- if(currSpot >= 0 || focusIsWith == this)
- cursorIsOver = this;
- else if(cursorIsOver == this)
- cursorIsOver = null;
-
-
- switch(event.getAction()){
- case MouseEvent.PRESS:
- if(focusIsWith != this && currSpot >= 0 && z > focusObjectZ()){
- dragging = false;
- takeFocus();
- }
- break;
- case MouseEvent.CLICK:
- if(focusIsWith == this){
- hasBeenClicked();
- loseFocus(null);
- if(selected)
- fireEvent(this, GEvent.SELECTED);
- else if(group == null)
- fireEvent(this, GEvent.DESELECTED);
- }
- break;
- case MouseEvent.DRAG:
- dragging = true;
- break;
- case MouseEvent.RELEASE:
- // Release focus without firing an event - that would have
- // been done
- if(focusIsWith == this && dragging)
- this.loseFocus(null);
- dragging = false;
- break;
- }
- }
-
- public void draw(){
- if(!visible) return;
-
- // Update buffer if invalid
- updateBuffer();
- winApp.pushStyle();
-
- winApp.pushMatrix();
- // Perform the rotation
- winApp.translate(cx, cy);
- winApp.rotate(rotAngle);
- // Move matrix to line up with top-left corner
- winApp.translate(-halfWidth, -halfHeight);
- // Draw buffer
- winApp.imageMode(PApplet.CORNER);
- if(alphaLevel < 255)
- winApp.tint(TINT_FOR_ALPHA, alphaLevel);
- winApp.image(buffer, 0, 0);
- winApp.popMatrix();
-
- winApp.popStyle();
- }
-
- protected void updateBuffer(){
- if(bufferInvalid) {
- bufferInvalid = false;
- buffer.beginDraw();
- Graphics2D g2d = buffer.g2;
- g2d.setFont(localFont);
- // Get the latest lines of text
- LinkedList lines = stext.getLines(g2d);
- // Back ground colour
- buffer.background(opaque ? palette[6].getRGB() : palette[2].getRGB() & 0xFFFFFF);
- // Calculate text and icon placement
- calcAlignment();
- // If there is an icon draw it
- if(iconW != 0)
- if(selected)
- buffer.image(bicon[1], siX, siY);
- else
- buffer.image(bicon[0], siX, siY);
- float wrapWidth = stext.getWrapWidth();
- float sx = 0, tw = 0;
- buffer.translate(stX, stY);
- for(TextLayoutInfo lineInfo : lines){
- TextLayout layout = lineInfo.layout;
- buffer.translate(0, layout.getAscent());
- switch(textAlignH){
- case CENTER:
- tw = layout.getAdvance();
- tw = (tw > wrapWidth) ? tw - wrapWidth : tw;
- sx = (wrapWidth - tw)/2;
- break;
- case RIGHT:
- tw = layout.getAdvance();
- tw = (tw > wrapWidth) ? tw - wrapWidth : tw;
- sx = wrapWidth - tw;
- break;
- case LEFT:
- case JUSTIFY:
- default:
- sx = 0;
- }
- // display text
- g2d.setColor(palette[2]);
- lineInfo.layout.draw(g2d, sx, 0);
- buffer.translate(0, layout.getDescent() + layout.getLeading());
- }
- buffer.endDraw();
- }
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GToggleGroup.java b/Processing/libraries/G4P/src/g4p_controls/GToggleGroup.java
deleted file mode 100644
index 4925dfd..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GToggleGroup.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-
-/**
- * Use this class to create a single selection collection of options.
- *
- * To use create an object of this class and then add GOption objects to it with
- * the addControl method.
- *
- * You cannot add GCheckbox objects because they are designed to work independently.
- *
- * @author Peter Lager
- *
- */
-public class GToggleGroup {
-
- private GToggleControl selected = null;
- private GToggleControl deselected = null;
-
- /**
- * Create a toggle group object.
- */
- public GToggleGroup(){ }
-
- /**
- * Add a GOption object to this group.
- * @param tc
- */
- public void addControl(GToggleControl tc){
- tc.setToggleGroup(this);
- }
-
- /**
- * Add a set of comma separated GOptions.
- * @param controls
- */
- public void addControls(GToggleControl... controls ){
- for(GToggleControl tc : controls)
- tc.setToggleGroup(this);
- }
-
- /**
- * Used internally to change selection
- */
- void makeSelected(GToggleControl tc){
- deselected = selected;
- if(deselected != null)
- deselected.setSelected(false);
- selected = tc;
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GValueControl.java b/Processing/libraries/G4P/src/g4p_controls/GValueControl.java
deleted file mode 100644
index e9ab185..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GValueControl.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-
-/**
- * Base class for all slider and knob type controls.
- *
- * This class enables the creation of tick marks and constraining values to
- * the tick mark values.
- *
- * It also controls how the values are to be displayed INTEGER, DECIMAL or EXPONENT
- *
- * @author Peter Lager
- *
- */
-public abstract class GValueControl extends GAbstractControl {
-
- protected StyledString ssStartLimit, ssEndLimit, ssValue;
-
- protected float startLimit = 0, endLimit = 1;
- protected boolean showLimits = false;
-
- protected int valueType = DECIMAL;
- protected int precision = 2;
- protected String unit = "";
- protected boolean showValue = false;
-
- protected float parametricPos = 0.5f, parametricTarget = 0.5f;
- protected float easing = 1.0f; // must be >= 1.0
-
-
- protected int nbrTicks = 2;
- protected boolean stickToTicks = false;
- protected boolean showTicks = false;
- protected float wheelDelta = WHEEL_DELTA;
-
- protected boolean limitsInvalid = true;
- protected boolean valueInvalid = true;
-
- // Offset to between mouse and thumb centre
- protected float offset;
-
- public GValueControl(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- }
-
- public void pre(){
- if(Math.abs(parametricTarget - parametricPos) > epsilon){
- parametricPos += (parametricTarget - parametricPos) / easing;
- updateDueToValueChanging();
- bufferInvalid = true;
- if(Math.abs(parametricTarget - parametricPos) > epsilon){
- valueInvalid = true;
- fireEvent(this, GEvent.VALUE_CHANGING);
- }
- else {
- parametricPos = parametricTarget;
- fireEvent(this, GEvent.VALUE_STEADY);
- }
- }
- }
-
- /**
- * This should be overridden in child classes so they can perform any class specific
- * actions when the value changes.
- * Override this in GSlider to change the hotshot poaition.
- */
- protected void updateDueToValueChanging(){
- }
-
- /**
- * Used to format the number into a string for display.
- * @param number
- * @return a string representing the number
- */
- protected String getNumericDisplayString(float number){
- String s = "";
- switch(valueType){
- case INTEGER:
- s = String.format("%d %s", Math.round(number), unit);
- break;
- case DECIMAL:
- s = String.format("%." + precision + "f %s", number, unit);
- break;
- case EXPONENT:
- s = String.format("%." + precision + "e %s", number, unit);
- break;
- }
- return s.trim();
- }
-
-
- /**
- * Sets the range of values to be returned. This method will
- * assume that you want to set the valueType to INTEGER
- *
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimits(int start, int end){
- startLimit = start;
- endLimit = end;
- setEpsilon();
- valueType = INTEGER;
- limitsInvalid = true;
- bufferInvalid = true;
- }
-
- /**
- * Sets the initial value and the range of values to be returned. This
- * method will assume that you want to set the valueType to INTEGER.
- *
- * @param initValue the initial value
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimits(int initValue, int start, int end){
- startLimit = start;
- endLimit = end;
- valueType = INTEGER;
- setEpsilon();
- limitsInvalid = true;
- bufferInvalid = true;
- setValue(initValue);
- parametricPos = parametricTarget;
- updateDueToValueChanging();
- }
-
- /**
- * Sets the range of values to be returned. This method will
- * assume that you want to set the valueType to DECIMAL
- *
- * @param start
- * @param end
- */
- public void setLimits(float start, float end){
- startLimit = start;
- endLimit = end;
- if(valueType == INTEGER){
- valueType = DECIMAL;
- setPrecision(1);
- }
- setEpsilon();
- limitsInvalid = true;
- bufferInvalid = true;
- }
-
- /**
- * Sets the initial value and the range of values to be returned. This
- * method will assume that you want to set the valueType to DECIMAL.
- *
- * @param initValue the initial value
- * @param start the start value of the range
- * @param end the end value of the range
- */
- public void setLimits(float initValue, float start, float end){
- startLimit = start;
- endLimit = end;
- initValue = PApplet.constrain(initValue, start, end);
- if(valueType == INTEGER){
- valueType = DECIMAL;
- setPrecision(1);
- }
- setEpsilon();
- limitsInvalid = true;
- bufferInvalid = true;
- setValue(initValue);
- parametricPos = parametricTarget;
- updateDueToValueChanging();
- }
-
- /**
- * Set the value for the slider.
- * The user must ensure that the value is valid for the slider range.
- * @param v
- */
- public void setValue(float v){
- if(valueType == INTEGER)
- v = Math.round(v);
- float t = (v - startLimit) / (endLimit - startLimit);
- t = PApplet.constrain(t, 0.0f, 1.0f);
- if(stickToTicks)
- t = findNearestTickValueTo(t);
- parametricTarget = t;
- }
-
- /**
- * For DECIMAL values this sets the number of decimal places to
- * be displayed.
- * @param nd must be >= 1 otherwise will use 1
- */
- public void setPrecision(int nd){
- nd = PApplet.constrain(nd, 1, 5);
- if(nd < 1)
- nd = 1;
- if(nd != precision){
- precision = nd;
- setEpsilon();
- limitsInvalid = true;
- bufferInvalid = true;
- }
- }
-
- /**
- * Make epsilon to match the value of 1 pixel or the precision which ever is the smaller
- */
- protected void setEpsilon(){
- epsilon = (float) Math.min(0.001, Math.pow(10, -precision));
- }
-
- /**
- * The units to be displayed with the current and limit values e.g.
- * kg, m, ($), fps etc.
- * Do not use long labels such as 'miles per hour' as these take a
- * lot of space and can look messy.
- *
- * @param units for example kg, m, ($), fps
- */
- public void setUnits(String units){
- if(units == null)
- units = "";
- if(!unit.equals(units)){
- unit = units;
- limitsInvalid = true;
- bufferInvalid = true;
- }
- }
-
- /**
- * Set the numberFormat, precision and units in one go.
- * Valid number formats are INTEGER, DECIMAL, EXPONENT
- * Precision must be >= 1 and is ignored for INTEGER.
- *
- * @param numberFormat INTEGER, DECIMAL or EXPONENT
- * @param precision must be >= 1
- * @param unit for example kg, m, ($), fps
- */
- public void setNumberFormat(int numberFormat, int precision, String unit){
- this.unit = (unit == null) ? "" : unit;
- setNumberFormat(numberFormat, precision);
- }
-
- /**
- * Set the numberFormat and precision in one go.
- * Valid number formats are INTEGER, DECIMAL, EXPONENT
- * Precision must be >= 1 and is ignored for INTEGER.
- *
- * @param numberFormat G4P.INTEGER, G4P.DECIMAL orG4P. EXPONENT
- * @param precision must be >= 1
- */
- public void setNumberFormat(int numberFormat, int precision){
- switch(numberFormat){
- case INTEGER:
- case DECIMAL:
- case EXPONENT:
- this.valueType = numberFormat;
- break;
- default:
- valueType = DECIMAL;
- }
- setPrecision(precision);
- bufferInvalid = true;
- }
-
- /**
- * Set the numberFormat and precision in one go.
- * Valid number formats are INTEGER, DECIMAL, EXPONENT
- * Precision must be >= 1 and is ignored for INTEGER.
- *
- * @param numberFormat G4P.INTEGER, G4P.DECIMAL or G4P.EXPONENT
- */
- public void setNumberFormat(int numberFormat){
- switch(numberFormat){
- case INTEGER:
- case DECIMAL:
- case EXPONENT:
- this.valueType = numberFormat;
- break;
- default:
- valueType = DECIMAL;
- }
- bufferInvalid = true;
- }
-
- /**
- * Get the current value as a float
- */
- public float getValueF(){
- return startLimit + (endLimit - startLimit) * parametricPos;
- }
-
- /**
- * Get the current value as an integer.
- * DECIMAL and EXPONENT value types will be rounded to the nearest integer.
- */
- public int getValueI(){
- return Math.round(startLimit + (endLimit - startLimit) * parametricPos);
- }
-
- /**
- * If we are using labels then this will get the label text
- * associated with the current value.
- * If labels have not been set then return null
- */
- public String getValueS(){
- return getNumericDisplayString(getValueF());
- }
-
- /**
- * Get the current value used for easing.
- * @return the easing
- */
- public float getEasing() {
- return easing;
- }
-
- /**
- * Set the amount of easing to be used when a value is changing. The default value
- * is 1 (no easing) values > 1 will cause the value to rush from its starting value
- * and decelerate towards its final values. In other words it smoothes the movement
- * of the slider thumb or knob rotation.
- *
- * @param easeBy the easing to set
- */
- public void setEasing(float easeBy) {
- easing = (easeBy < 1) ? 1 : easeBy;
- }
-
- /**
- * Get the number of tick marks.
- * @return the nbrTicks
- */
- public int getNbrTicks() {
- return nbrTicks;
- }
-
- /**
- * The number of ticks must be >= 2 since 2 are required for the slider limits.
- *
- * @param noOfTicks the nbrTicks to set
- */
- public void setNbrTicks(int noOfTicks) {
- if(noOfTicks < 2)
- noOfTicks = 2;
- if(nbrTicks != noOfTicks){
- nbrTicks = noOfTicks;
- bufferInvalid = true;
- if(stickToTicks){
- wheelDelta = WHEEL_STICK_FACTOR / (nbrTicks - 1);
- parametricTarget = findNearestTickValueTo(parametricPos);
- }
- }
- System.out.println("setNbrTicks " + tag + " " + wheelDelta);
- }
-
- /**
- * Specify whether the values are to be constrained to the tick marks or not.
- * It will automatically display tick marks if set true.
- * @param stickToTicks true if you want to constrain the values else false
- */
- public void setStickToTicks(boolean stickToTicks) {
- this.stickToTicks = stickToTicks;
- if(stickToTicks){
- setShowTicks(true);
- wheelDelta = WHEEL_STICK_FACTOR / (nbrTicks - 1);
- parametricTarget = findNearestTickValueTo(parametricPos);
- bufferInvalid = true;
- }
- else {
- wheelDelta = WHEEL_DELTA;
- }
- System.out.println("setStickToTicks " + tag + " " + wheelDelta);
- }
-
- /**
- * Is the value constrained to the tick marks?
- * @return the stickToTicks true if values constrained else false
- */
- public boolean isStickToTicks() {
- return stickToTicks;
- }
-
-
- /**
- * These are normalised values i.e. between 0.0 and 1.0 inclusive
- * @param p
- * @return the parametric value of the nearest tick
- */
- protected float findNearestTickValueTo(float p){
- float tickSpace = 1.0f / (nbrTicks - 1);
- int tn = (int) (p / tickSpace + 0.5f);
- return tickSpace * tn;
- }
-
- /**
- * Calculate the correct value of the parametticTarget
- *
- * @param pt the value to correct
- * @return the corrected value 0.0 - 1.0 incl
- */
- protected float calcParametricTarget(float pt){
- pt = pt < 0 ? 0 : pt > 1 ? 1 : pt;
- if(stickToTicks)
- pt = findNearestTickValueTo(pt);
- return pt;
- }
-
- /**
- * Are the tick marks visible?
- * @return the showTicks
- */
- public boolean isShowTicks() {
- return showTicks;
- }
-
- /**
- * Set whether the tick marks are to be displayed or not.
- * @param showTicks the showTicks to set
- */
- public void setShowTicks(boolean showTicks) {
- if(this.showTicks != showTicks){
- this.showTicks = showTicks;
- bufferInvalid = true;
- }
- }
-
- /**
- * Are the limit values visible?
- * @return the showLimits
- */
- public boolean isShowLimits() {
- return showLimits;
- }
-
- /**
- * Set whether the limits are to be displayed or not.
- * @param showLimits the showLimits to set
- */
- public void setShowLimits(boolean showLimits) {
- this.showLimits = showLimits;
- bufferInvalid = true;
- }
-
- /**
- * Is the current value to be displayed?
- * @return the showValue
- */
- public boolean isShowValue() {
- return showValue;
- }
-
- /**
- * Set whether the current value is to be displayed or not.
- * @param showValue the showValue to set
- */
- public void setShowValue(boolean showValue) {
- this.showValue = showValue;
- bufferInvalid = true;
- }
-
- /**
- * Convenience method to set what is to be drawn to the screen.
- * @param opaque show background
- * @param ticks show tick marks
- * @param value show current value
- * @param limits show min and max values (limits)
- */
- public void setShowDecor(boolean opaque, boolean ticks, boolean value, boolean limits){
- setShowValue(value);
- bufferInvalid = true;
- setOpaque(opaque);
- setShowTicks(ticks);
- setShowLimits(limits);
- }
-
- /**
- * @return the startLimit
- */
- public float getStartLimit() {
- return startLimit;
- }
-
- /**
- * @return the endLimit
- */
- public float getEndLimit() {
- return endLimit;
- }
-
- /**
- *
- * @return the valueType
- */
- public int getValueType() {
- return valueType;
- }
-
- /**
- * Precision used with floating point numbers
- * @return the precision
- */
- public int getPrecision() {
- return precision;
- }
-
- /**
- * @return the unit
- */
- public String getUnit() {
- return unit;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GValueControl2D.java b/Processing/libraries/G4P/src/g4p_controls/GValueControl2D.java
deleted file mode 100644
index e5f9ccd..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GValueControl2D.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2013 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-
-/**
- * Base class for controls that have 2 variables e.f. GSlider2D
- *
- * @author Peter Lager
- *
- */
-public abstract class GValueControl2D extends GAbstractControl {
-
- static protected int THUMB_SPOT = 1;
- static protected int TRACK_SPOT = 2;
-
-
- protected float parametricPosX = 0.5f, parametricTargetX = 0.5f;
- protected float parametricPosY = 0.5f, parametricTargetY = 0.5f;
-
- protected float easing = 1.0f; // must be >= 1.0
-
- // Offset to between mouse and thumb centre
- protected float offsetH, offsetV;
-
- protected int valueType = DECIMAL;
- protected int precision = 2;
-
- public GValueControl2D(PApplet theApplet, float p0, float p1, float p2, float p3) {
- super(theApplet, p0, p1, p2, p3);
- }
-
- public void pre(){
- if(Math.abs(parametricTargetX - parametricPosX) > epsilon || Math.abs(parametricTargetY - parametricPosY) > epsilon){
- parametricPosX += (parametricTargetX - parametricPosX) / easing;
- parametricPosY += (parametricTargetY - parametricPosY) / easing;
- updateDueToValueChanging();
- bufferInvalid = true;
- if(Math.abs(parametricTargetX - parametricPosX) > epsilon || Math.abs(parametricTargetY - parametricPosY) > epsilon){
- fireEvent(this, GEvent.VALUE_CHANGING);
- }
- else {
- parametricPosX = parametricTargetX;
- parametricPosY = parametricTargetY;
- fireEvent(this, GEvent.VALUE_STEADY);
- }
- }
- }
-
- /**
- * This should be overridden in child classes so they can perform any class specific
- * actions when the value changes.
- * Override this in GSlider to change the hotshot poaition.
- */
- protected void updateDueToValueChanging(){
- }
-
- /**
- * Make epsilon to match the value of 1 pixel or the precision which ever is the smaller
- */
- protected void setEpsilon(){
- epsilon = (float) Math.min(0.001, Math.pow(10, -precision));
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GWinData.java b/Processing/libraries/G4P/src/g4p_controls/GWinData.java
deleted file mode 100644
index 5fddfea..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GWinData.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-/**
- * This class is used to hold the data associated with a GWindow object.
- *
- * You should extend this class to provide the data to be processed by
- * the window
- *
- * @author Peter Lager
- *
- */
-public class GWinData {
-
- public GWindow owner;
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GWindow.java b/Processing/libraries/G4P/src/g4p_controls/GWindow.java
deleted file mode 100644
index f1ac16e..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GWindow.java
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2015 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.core.PVector;
-import processing.event.KeyEvent;
-import processing.event.MouseEvent;
-
-/**
- * Base class for independent windows using JAVA2D, P2D or P3D renderers. These
- * can be used to hold G4P GUI components or used for drawing or both combined.
- *
- * A number of examples are included in the library and more info can be found
- * at www.lagers.org.uk
- *
- * Updated for Processing V3
- *
- * @author Peter Lager
- *
- */
-public abstract class GWindow extends PApplet implements GConstants, GConstantsInternal {
-
- /**
- * Factory method to create and start a new window. The renderer
- * must be JAVA2D, P2D or P3D otherwise this method returns null.
- *
- * @param title text to appear in frame title bar
- * @param px horizontal position of top-left corner
- * @param py vertical position of top-left corner
- * @param w width of drawing surface
- * @param h height of surface
- * @param r renderer must be JAVA2D, P3D or P3D
- * @return the window created (in case the user wants its.
- */
- public static GWindow getWindow(PApplet app, String title, int px, int py, int w, int h, String renderer){
- G4P.registerSketch(app);
- GWindow g3w = null;
- if(renderer.equals(JAVA2D))
- g3w = new GWindowAWT(title, w, h);
- else if(renderer.equals(P2D))
- g3w = new GWindowNEWT(title, w, h, false);
- else if(renderer.equals(P3D)){
- g3w = new GWindowNEWT(title, w, h, true);
- }
- if(g3w != null){
- String spath = "--sketch-path=" + G4P.sketchWindow.sketchPath();
- String loc = "--location=" + px + "," + py;
- String className = g3w.getClass().getName();
- String[] args = { spath, loc, className };
- G4P.registerWindow(g3w);
- PApplet.runSketch(args, g3w);
- }
- return g3w;
- }
-
- protected int actionOnClose = KEEP_OPEN;
-
- /** Used to associated data to a GWindow */
- public GWinData data;
-
- /** Simple tag that can be used by the user */
- public String tag;
-
- /** Allows user to specify a number for this component */
- public int tagNo;
-
- protected final int w, h;
- protected final String title;
- protected String renderer_type;
- protected boolean preparedForClosure = false;
-
- protected GWindow(String title, int w, int h) {
- super();
- this.title = title;
- this.w = w;
- this.h = h;
- registerMethods();
- }
-
- /**
- * Register this window for pre, draw, post, mouseEvent and
- * keyEvent methods.
- */
- protected void registerMethods(){
- registerMethod("pre", this);
- registerMethod("draw", this);
- registerMethod("post", this);
- registerMethod("mouseEvent", this);
- registerMethod("keyEvent", this);
- }
-
- /**
- * Unregister this window for pre, draw, post, mouseEvent and
- * keyEvent methods.
- * This method is called when the window closes.
- */
- protected void unregisterMethods(){
- unregisterMethod("pre", this);
- unregisterMethod("draw", this);
- unregisterMethod("post", this);
- unregisterMethod("mouseEvent", this);
- unregisterMethod("keyEvent", this);
- // bely and braces
- preHandlerObject = null;
- drawHandlerObject = null;
- postHandlerObject = null;
- mouseHandlerObject = null;
- keyHandlerObject = null;
- }
-
- /**
- * To provide a unique fields for this window create a class that inherits
- * from GWinData with public access fields. Then use this method to associate
- * the data with this window.
- * @param data
- */
- public void addData(GWinData data){
- this.data = data;
- }
-
- /**
- * Add a control to this window, ignoring duplicates.
- *
- * @param control control to be added
- */
- protected void addToWindow(GAbstractControl control){
- // Avoid adding duplicates
- if(!toAdd.contains(control) && !windowControls.contains(control))
- toAdd.add(control);
- }
-
- /**
- * Remove a control to this window.
- *
- * @param control control to be removed
- */
- protected void removeFromWindow(GAbstractControl control){
- toRemove.add(control);
- }
-
- /**
- * Set the colour scheme to be used by all controls on this window.
- * @param cs colour scheme e.g. G4P.GREEN_SCHEME
- */
- void invalidateBuffers(){
- for(GAbstractControl control : windowControls)
- control.bufferInvalid = true;
- }
-
- /**
- * Set the colour scheme to be used by all controls on this window.
- * @param cs colour scheme e.g. G4P.GREEN_SCHEME
- */
- void setColorScheme(int cs){
- for(GAbstractControl control : windowControls)
- control.setLocalColorScheme(cs);
- }
-
- /**
- * Set the alpha level for all controls on this window.
- * 0 = fully transparent
- * 255 = fully opaque
- * Controls are disabled when alpha gets below G4P.ALPHA_BLOCK (128)
- *
- * @param alpha 0-255 inclusive
- */
- void setAlpha(int alpha){
- for(GAbstractControl control : windowControls)
- control.setAlpha(alpha);
- }
-
- /** Set the windows visibility */
- public void setVisible(boolean visible){
- surface.setVisible(visible);
- }
-
- /** Returns the windows visibility */
- public abstract boolean isVisible();
-
- /** Set the window title */
- public void setTitle(String title){
- surface.setTitle(title);
- }
- /** Get the windowTitle */
- public abstract String getTitle();
-
- /** Set the windows position */
- public void setLocation(int x, int y){
- surface.setLocation(x, y);
- }
-
- /**
- Returns a PVector with the windows top-left coordinates.
- */
- public abstract PVector getPosition(PVector pos);
-
- /**
- * Sets whether this window should always be above other windows. If there are
- * multiple always-on-top windows, their relative order is unspecified and
- * platform dependent.
- */
- public void setAlwaysOnTop(boolean ontop) {
- surface.setAlwaysOnTop(ontop);
- }
-
- /**
- * Execute any draw handler for this window.
- */
- public void draw() {
- pushMatrix();
- if(drawHandlerObject != null){
- try {
- drawHandlerMethod.invoke(drawHandlerObject, new Object[] { this, data });
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {drawHandlerObject, drawHandlerMethodName, e} );
- }
- }
- popMatrix();
- }
-
- /**
- * Execute any pre handler associated with this window and its controls
- */
- public void pre(){
- if(preHandlerObject != null){
- try {
- preHandlerMethod.invoke(preHandlerObject,
- new Object[] { this, data });
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {preHandlerObject, preHandlerMethodName, e} );
- }
- }
- if(GAbstractControl.controlToTakeFocus != null && GAbstractControl.controlToTakeFocus.getPApplet() == this){
- GAbstractControl.controlToTakeFocus.setFocus(true);
- GAbstractControl.controlToTakeFocus = null;
- }
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & PRE_METHOD) == PRE_METHOD)
- control.pre();
- }
- }
-
- /**
- * Execute any post handler associated with this window and its controls.
- * Add/remove any controls request by user, this is done here outside the drawing
- * phase to prevent crashes.
- */
- public void post() {
- if(postHandlerObject != null){
- try {
- postHandlerMethod.invoke(postHandlerObject,
- new Object[] { this, data });
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {postHandlerObject, postHandlerMethodName, e} );
- }
- }
- if(G4P.cursorChangeEnabled){
- if(GAbstractControl.cursorIsOver != null && GAbstractControl.cursorIsOver.getPApplet() == this)
- cursor(GAbstractControl.cursorIsOver.cursorOver);
- else
- cursor(G4P.mouseOff);
- }
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & POST_METHOD) == POST_METHOD)
- control.post();
- }
- // =====================================================================================================
- // =====================================================================================================
- // This is where components are removed or added to the window to avoid concurrent access violations
- // =====================================================================================================
- // =====================================================================================================
- synchronized (this) {
- // Dispose of any unwanted controls
- if(!toRemove.isEmpty()){
- for(GAbstractControl control : toRemove){
- // If the control has focus then lose it
- if(GAbstractControl.focusIsWith == control)
- control.loseFocus(null);
- // Clear control resources
- control.buffer = null;
- if(control.parent != null){
- control.parent.children.remove(control);
- control.parent = null;
- }
- if(control.children != null)
- control.children.clear();
- control.palette = null;
- control.eventHandlerObject = null;
- control.eventHandlerMethod = null;
- control.winApp = null;
- windowControls.remove(control);
- System.gc();
- }
- toRemove.clear();
- }
- if(!toAdd.isEmpty()){
- for(GAbstractControl control : toAdd)
- windowControls.add(control);
- toAdd.clear();
- Collections.sort(windowControls, G4P.zorder);
- }
- }
- }
-
- /**
- * Execute any mouse event handler associated with this window and its controls
- */
- public void mouseEvent(MouseEvent event) {
- if(mouseHandlerObject != null){
- try {
- mouseHandlerMethod.invoke(mouseHandlerObject, new Object[] { this, data, event });
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {mouseHandlerObject, mouseHandlerMethodName, e} );
- }
- }
- for(GAbstractControl control : windowControls){
- if((control.registeredMethods & MOUSE_METHOD) == MOUSE_METHOD)
- control.mouseEvent(event);
- }
- }
-
- /**
- * Execute any key event handler associated with this window and its controls
- */
- public void keyEvent(KeyEvent event) {
- if(keyHandlerObject != null){
- try {
- keyHandlerMethod.invoke(keyHandlerObject, new Object[] { this, data, event });
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {keyHandlerObject, keyHandlerMethodName, e} );
- }
- }
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & KEY_METHOD) == KEY_METHOD)
- control.keyEvent(event);
- }
- }
-
- /**
- * Attempt to add the 'draw' handler method.
- * The default event handler is a method that returns void and has two
- * parameters PApplet and GWinData
- *
- * @param obj the object to handle the event
- * @param methodName the method to execute in the object handler class
- */
- public void addDrawHandler(Object obj, String methodName){
- try{
- drawHandlerMethod = obj.getClass().getMethod(methodName, new Class>[] {PApplet.class, GWinData.class } );
- drawHandlerObject = obj;
- drawHandlerMethodName = methodName;
- } catch (Exception e) {
- drawHandlerObject = null;
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { PApplet.class, GWinData.class } } );
- }
- }
-
- /**
- * Attempt to add the 'pre' handler method.
- * The default event handler is a method that returns void and has two
- * parameters GWinApplet and GWinData
- *
- * @param obj the object to handle the event
- * @param methodName the method to execute in the object handler class
- */
- public void addPreHandler(Object obj, String methodName){
- try{
- preHandlerMethod = obj.getClass().getMethod(methodName, new Class>[] {PApplet.class, GWinData.class } );
- preHandlerObject = obj;
- preHandlerMethodName = methodName;
- } catch (Exception e) {
- preHandlerMethod = null;
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { PApplet.class, GWinData.class } } );
- }
- }
-
- /**
- * Attempt to add the 'mouse' handler method.
- * The default event handler is a method that returns void and has three
- * parameters GWinApplet, GWinData and a MouseEvent
- *
- * @param obj the object to handle the event
- * @param methodName the method to execute in the object handler class
- */
- public void addMouseHandler(Object obj, String methodName){
- try{
- mouseHandlerMethod = obj.getClass().getMethod(methodName,
- new Class>[] {PApplet.class, GWinData.class, MouseEvent.class } );
- mouseHandlerObject = obj;
- mouseHandlerMethodName = methodName;
- } catch (Exception e) {
- mouseHandlerObject = null;
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { PApplet.class, GWinData.class, MouseEvent.class } } );
- }
- }
-
- /**
- * Attempt to add the 'key' handler method.
- * The default event handler is a method that returns void and has three
- * parameters GWinApplet, GWinData and a KeyEvent
- *
- * @param obj the object to handle the event
- * @param methodName the method to execute in the object handler class
- */
- public void addKeyHandler(Object obj, String methodName){
- try{
- keyHandlerMethod = obj.getClass().getMethod(methodName,
- new Class>[] {PApplet.class, GWinData.class, KeyEvent.class } );
- keyHandlerObject = obj;
- keyHandlerMethodName = methodName;
- } catch (Exception e) {
- keyHandlerObject = null;
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { PApplet.class, GWinData.class, KeyEvent.class } } );
- }
- }
-
- /**
- * Attempt to add the 'post' handler method.
- * The default event handler is a method that returns void and has two
- * parameters GWinApplet and GWinData
- *
- * @param obj the object to handle the event
- * @param methodName the method to execute in the object handler class
- */
- public void addPostHandler(Object obj, String methodName){
- try{
- postHandlerMethod = obj.getClass().getMethod(methodName,
- new Class>[] {PApplet.class, GWinData.class } );
- postHandlerObject = obj;
- postHandlerMethodName = methodName;
- } catch (Exception e) {
- postHandlerObject = null;
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { PApplet.class, GWinData.class } } );
- }
- }
-
- /**
- * Attempt to create the on-close-window event handler for this GWindow.
- * The default event handler is a method that returns void and has a single
- * parameter of type GWindow (this will be a reference to the window that is
- * closing)
- *
- * The handler will not be called> if the setActionOnClose flag is set
- * to EXIT_APP
- * If the flag is set to CLOSE_WINDOW then the handler is called when the window
- * is closed by clicking on the window-close-icon or using either the close or
- * forceClose methods.
- * If the flag is set to KEEP_OPEN the window can only be closed using the
- * forceClose method. In this case the handler will be called.
- *
- *
- * @param obj the object to handle the on-close-window event
- * @param methodName the method to execute in the object handler class
- */
- public void addOnCloseHandler(Object obj, String methodName){
- try{
- closeHandlerObject = obj;
- closetHandlerMethodName = methodName;
- closetHandlerMethod = obj.getClass().getMethod(methodName, new Class>[] { PApplet.class, GWinData.class } );
- } catch (Exception e) {
- GMessenger.message(NONEXISTANT, new Object[] {this, methodName, new Class>[] { PApplet.class, GWinData.class } } );
- closeHandlerObject = null;
- closetHandlerMethodName = "";
- }
- }
-
- /**
- * This will close the window provided the action-on-close flag is CLOSE_WINDOW
- * otherwise the window remains open.
- */
- public void close(){
- if(actionOnClose == KEEP_OPEN || actionOnClose == EXIT_APP ) return;
- prepareWindowForClosure();
- //G4P.markForWindowClosure(this);
- }
-
- /**
- * This will close the window provided the action-on-close flag is CLOSE_WINDOW
- * or KEEP_OPEN otherwise the window remains open.
- */
- public void forceClose(){
- if(actionOnClose == EXIT_APP) return;
- if(actionOnClose == KEEP_OPEN)
- setActionOnClose(CLOSE_WINDOW);
- prepareWindowForClosure();
- //G4P.markForWindowClosure(this);
- }
-
- /**
- * Fire a window closing event
- */
- protected abstract void fireCloseWindowEvent();
-
-
- /**
- * Prepare the window for closure by stopping the animation loop, unregistering
- * the event handlers and firing a window close event using a new thread.
- */
- protected void prepareWindowForClosure(){
- noLoop();
- unregisterMethods();
- G4P.deregisterWindow(this);
- (new Thread(new GCloseNotifier(this))).start();
- }
-
- /**
- * This sets what happens when the users attempts to close the window.
- * There are 3 possible actions depending on the value passed.
- * G4P.KEEP_OPEN - ignore attempt to close window (default action),
- * G4P.CLOSE_WINDOW - close this window,
- * G4P.EXIT_APP - exit the app, this will cause all windows to close.
- * @param action the required close action
- */
- public abstract void setActionOnClose(int action);
-
- public void settings() {
- size(w, h, renderer_type);
- }
-
- /**
- * Set up the 'window' listeners
- */
- protected abstract void initListeners();
-
- public void setup(){
- surface.setTitle(title); // does not like this in settings
- initListeners();
- }
-
- /**
- * This method is executed when the window closes. It will call the user defined
- * on-close-handler method set with
- */
- public void performCloseAction(){
- if(closeHandlerObject != null){
- try {
- closetHandlerMethod.invoke(closeHandlerObject,
- new Object[] { this, data });
- } catch (Exception e) {
- GMessenger.message(EXCP_IN_HANDLER,
- new Object[] {preHandlerObject, preHandlerMethodName, e} );
- }
- }
- }
-
- /**
- * This class is used to call the fireCloseWindowEvent in the appropriate
- * GWindow sub-class.
- * @author Peter Lager
- *
- */
- protected class GCloseNotifier implements Runnable {
-
- GWindow window = null;
-
- public GCloseNotifier(GWindow window) {
- super();
- this.window = window;
- }
-
- @Override
- public void run() {
- if(window != null){
- window.fireCloseWindowEvent();
- }
- }
-
- }
-
- /**
- * Window adapter class for the JAVA2D renderer
- *
- * @author Peter Lager
- */
- protected class WindowAdapterAWT extends WindowAdapter {
- GWindow window = null;
-
- public WindowAdapterAWT(GWindow window){
- this.window = window;
- }
-
- public void windowClosing(WindowEvent evt) {
- switch(actionOnClose){
- case EXIT_APP:
- System.exit(0);
- break;
- case CLOSE_WINDOW:
- performCloseAction();
- G4P.deregisterWindow(window);
- dispose();
- break;
- }
- }
- }
-
- /**
- * Window adapter class for the P2D and P3D renderers
- *
- * @author Peter Lager
- */
- protected class WindowAdapterNEWT extends com.jogamp.newt.event.WindowAdapter {
-
- GWindow window = null;
-
- public WindowAdapterNEWT(GWindow window){
- this.window = window;
- }
- public void windowGainedFocus(com.jogamp.newt.event.WindowEvent arg0) {
- focused = true;
- focusGained();
- }
-
- public void windowLostFocus(com.jogamp.newt.event.WindowEvent arg0) {
- focused = false;
- focusLost();
- }
-
- public void windowDestroyNotify(com.jogamp.newt.event.WindowEvent arg0) {
- switch(actionOnClose){
- case EXIT_APP:
- // Next two come from processing.opengl PSurfaceJOGL.java
- // performCloseAction();
- //dispose();
- exitActual();
- break;
- case CLOSE_WINDOW:
- performCloseAction();
- G4P.deregisterWindow(window);
- // Next one comes from processing.opengl PSurfaceJOGL.java
- dispose();
- break;
- }
- }
-
- }
-
- public LinkedList windowControls = new LinkedList();
- // These next two lists are for controls that are to be added or remove since these
- // actions must be performed outside the draw cycle to avoid concurrent modification
- // exceptions when changing windowControls
- public LinkedList toRemove = new LinkedList();
- public LinkedList toAdd = new LinkedList();
-
- /** The object to handle the pre event */
- protected Object preHandlerObject = null;
- /** The method in preHandlerObject to execute */
- protected Method preHandlerMethod = null;
- /** the name of the method to handle the event */
- protected String preHandlerMethodName;
-
- /** The object to handle the post event */
- protected Object postHandlerObject = null;
- /** The method in postHandlerObject to execute */
- protected Method postHandlerMethod = null;
- /** the name of the method to handle the event */
- protected String postHandlerMethodName;
-
- /** The object to handle the draw event */
- protected Object drawHandlerObject = null;
- /** The method in drawHandlerObject to execute */
- protected Method drawHandlerMethod = null;
- /** the name of the method to handle the event */
- protected String drawHandlerMethodName;
-
- /** The object to handle the key event */
- protected Object keyHandlerObject = null;
- /** The method in keyHandlerObject to execute */
- protected Method keyHandlerMethod = null;
- /** the name of the method to handle the event */
- protected String keyHandlerMethodName;
-
- /** The object to handle the mouse event */
- protected Object mouseHandlerObject = null;
- /** The method in mouseHandlerObject to execute */
- protected Method mouseHandlerMethod = null;
- /** the name of the method to handle the event */
- protected String mouseHandlerMethodName;
-
- /** The object to handle the window closing event */
- protected Object closeHandlerObject = null;
- /** The method in closeHandlerObject to execute */
- protected Method closetHandlerMethod = null;
- /** the name of the method to handle the event */
- protected String closetHandlerMethodName;
-
- protected boolean is3D;
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GWindowAWT.java b/Processing/libraries/G4P/src/g4p_controls/GWindowAWT.java
deleted file mode 100644
index e90b6fc..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GWindowAWT.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2015 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Frame;
-import java.awt.Point;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.JFrame;
-
-import processing.core.PVector;
-
-/**
- * Class for independent windows using the JAVA2D renderer. These
- * can be used to hold G4P GUI components or used for drawing or both combined.
- *
- * A number of examples are included in the library and more info can be found
- * at www.lagers.org.uk
- *
- * Updated for Processing V3
- *
- * @author Peter Lager
- *
- */
-public class GWindowAWT extends GWindow{
-
- protected GWindowAWT(String title, int w, int h) {
- super(title, w, h);
- is3D = false;
- renderer_type = JAVA2D;
- }
-
- public void draw() {
- super.draw();
- pushMatrix();
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & DRAW_METHOD) == DRAW_METHOD )
- control.draw();
- }
- popMatrix();
- }
-
- /**
- * Remove all existing window listeners and add our own custom listener.
- */
- protected void initListeners(){
- Frame awtCanvas = getCanvas();
- for(WindowListener l : awtCanvas.getWindowListeners())
- awtCanvas.removeWindowListener(l);
- awtCanvas.addWindowListener(new WindowAdapterAWT(this));
- }
-
- /**
- * This sets what happens when the users attempts to close the window.
- * There are 3 possible actions depending on the value passed.
- * G4P.KEEP_OPEN - ignore attempt to close window (default action),
- * G4P.CLOSE_WINDOW - close this window,
- * G4P.EXIT_APP - exit the app, this will cause all windows to close.
- * @param action the required close action
- */
- public void setActionOnClose(int action){
- JFrame awtCanvas = getCanvas();
- if(action == KEEP_OPEN)
- awtCanvas.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- else
- awtCanvas.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- actionOnClose = action;
- }
-
- private JFrame getCanvas(){
- return (JFrame) ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame();
- }
-
- /**
- * Fire a window closing event. This method will be called from a new THread, do not call directly
- */
- protected void fireCloseWindowEvent(){
- Frame awtCanvas = getCanvas();
- awtCanvas.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(awtCanvas, WindowEvent.WINDOW_CLOSING));
- }
-
- /**
- * Returns true if the window is visible else false
- */
- public boolean isVisible(){
- return getCanvas().isVisible();
- }
-
- /**
- * Get the window title
- */
- public String getTitle() {
- return getCanvas().getTitle();
- }
-
- /**
- * Get the window position
- */
- public PVector getPosition(PVector pos) {
- if(pos == null)
- pos = new PVector();
- Point p = getCanvas().getLocation();
- pos.x = p.x;
- pos.y = p.y;
- return pos;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GWindowImpl.java b/Processing/libraries/G4P/src/g4p_controls/GWindowImpl.java
deleted file mode 100644
index dcc34c1..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GWindowImpl.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package g4p_controls;
-
-import java.util.Collections;
-import java.util.LinkedList;
-
-import processing.core.PApplet;
-import processing.core.PMatrix;
-import processing.core.PMatrix3D;
-import processing.event.KeyEvent;
-import processing.event.MouseEvent;
-
-/**
- * This class calls the appropriate methods for G4P controls for the main applet window.
- *
- * This will be created when the first control is added to the main window.
- *
- * @author Peter Lager
- *
- */
-public class GWindowImpl implements GConstants, GConstantsInternal {
-
- public LinkedList windowControls = new LinkedList();
- // These next two lists are for controls that are to be added or remove since these
- // actions must be performed outside the draw cycle to avoid concurrent modification
- // exceptions when changing windowControls
- public LinkedList toRemove = new LinkedList();
- public LinkedList toAdd = new LinkedList();
-
-
- PApplet app;
- PMatrix orgMatrix = null;
-
- public GWindowImpl(PApplet app){
- this.app = app;
- PMatrix mat = app.getMatrix();
- if(mat instanceof PMatrix3D)
- orgMatrix = mat;
- registerMethods();
- }
-
- protected void registerMethods(){
- app.registerMethod("pre", this);
- app.registerMethod("draw", this);
- app.registerMethod("post", this);
- app.registerMethod("mouseEvent", this);
- app.registerMethod("keyEvent", this);
- }
-
- protected void unregisterMethods(){
- app.unregisterMethod("pre", this);
- app.unregisterMethod("draw", this);
- app.unregisterMethod("post", this);
- app.unregisterMethod("mouseEvent", this);
- app.unregisterMethod("keyEvent", this);
- }
-
- protected void addToWindow(GAbstractControl control){
- // Avoid adding duplicates
- if(!toAdd.contains(control) && !windowControls.contains(control)){
- toAdd.add(control);
- }
- }
-
- protected void removeFromWindow(GAbstractControl control){
- toRemove.add(control);
- }
-
- /**
- * Set the colour scheme to be used by all controls on this window.
- * @param cs colour scheme e.g. G4P.GREEN_SCHEME
- */
- void invalidateBuffers(){
- for(GAbstractControl control : windowControls)
- control.bufferInvalid = true;
- }
-
- /**
- * Set the colour scheme to be used by all controls on this window.
- * @param cs colour scheme e.g. G4P.GREEN_SCHEME
- */
- void setColorScheme(int cs){
- for(GAbstractControl control : windowControls)
- control.setLocalColorScheme(cs);
- }
-
- /**
- * Set the alpha level for all controls on this window.
- * 0 = fully transparent
- * 255 = fully opaque
- * Controls are disabled when alpha gets below G4P.ALPHA_BLOCK (128)
- *
- * @param alpha 0-255 inclusive
- */
- void setAlpha(int alpha){
- for(GAbstractControl control : windowControls)
- control.setAlpha(alpha);
- }
-
- public void draw() {
- app.pushMatrix();
- if(orgMatrix != null)
- app.setMatrix(orgMatrix);
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & DRAW_METHOD) == DRAW_METHOD )
- control.draw();
- }
- app.popMatrix();
- }
-
- /**
- * The mouse method registered with Processing
- *
- * @param event
- */
- public void mouseEvent(MouseEvent event){
- for(GAbstractControl control : windowControls){
- if((control.registeredMethods & MOUSE_METHOD) == MOUSE_METHOD)
- control.mouseEvent(event);
- }
- }
-
- /**
- * The key method registered with Processing
- */
- public void keyEvent(KeyEvent event) {
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & KEY_METHOD) == KEY_METHOD)
- control.keyEvent(event);
- }
- }
-
- /**
- * The pre method registered with Processing
- */
- public void pre(){
- if(GAbstractControl.controlToTakeFocus != null && GAbstractControl.controlToTakeFocus.getPApplet() == app){
- GAbstractControl.controlToTakeFocus.setFocus(true);
- GAbstractControl.controlToTakeFocus = null;
- }
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & PRE_METHOD) == PRE_METHOD)
- control.pre();
- }
- }
-
- public void post() {
- //System.out.println("POST");
- if(G4P.cursorChangeEnabled){
- if(GAbstractControl.cursorIsOver != null && GAbstractControl.cursorIsOver.getPApplet() == app)
- app.cursor(GAbstractControl.cursorIsOver.cursorOver);
- else
- app.cursor(G4P.mouseOff);
- }
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & POST_METHOD) == POST_METHOD)
- control.post();
- }
- // =====================================================================================================
- // =====================================================================================================
- // This is where components are removed or added to the window to avoid concurrent access violations
- // =====================================================================================================
- // =====================================================================================================
- synchronized (this) {
- // Dispose of any unwanted controls
- if(!toRemove.isEmpty()){
- for(GAbstractControl control : toRemove){
- // If the control has focus then lose it
- if(GAbstractControl.focusIsWith == control)
- control.loseFocus(null);
- // Clear control resources
- control.buffer = null;
- if(control.parent != null){
- control.parent.children.remove(control);
- control.parent = null;
- }
- if(control.children != null)
- control.children.clear();
- control.palette = null;
- control.eventHandlerObject = null;
- control.eventHandlerMethod = null;
- control.winApp = null;
- windowControls.remove(control);
- System.gc();
- }
- toRemove.clear();
- }
- if(!toAdd.isEmpty()){
- for(GAbstractControl control : toAdd)
- windowControls.add(control);
- toAdd.clear();
- Collections.sort(windowControls, G4P.zorder);
- }
- }
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/GWindowNEWT.java b/Processing/libraries/G4P/src/g4p_controls/GWindowNEWT.java
deleted file mode 100644
index 8929324..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/GWindowNEWT.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2015 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PMatrix;
-import processing.core.PVector;
-
-/**
- * Class for independent windows using P2D or P3D renderers. These
- * can be used to hold G4P GUI components or used for drawing or both combined.
- *
- * A number of examples are included in the library and more info can be found
- * at www.lagers.org.uk
- *
- * Updated for Processing V3
- *
- * @author Peter Lager
- *
- */
-public class GWindowNEWT extends GWindow {
-
- private PMatrix orgMatrix = null;
-
- protected GWindowNEWT(String title, int w, int h, boolean is3D) {
- super(title, w, h);
- this.is3D = is3D;
- renderer_type = is3D ? P3D : P2D;
- }
-
- public void setup(){
- super.setup();
- orgMatrix = getMatrix();
- }
-
- public void draw() {
- super.draw();
- pushMatrix();
- if(is3D) {
- hint(DISABLE_DEPTH_TEST);
- setMatrix(orgMatrix);
- }
- for(GAbstractControl control : windowControls){
- if( (control.registeredMethods & DRAW_METHOD) == DRAW_METHOD )
- control.draw();
- }
- if(is3D) hint(ENABLE_DEPTH_TEST);
- popMatrix();
- }
-
- /**
- * Remove all existing window listeners added by Processing and add our own custom listener.
- */
- protected void initListeners(){
- //com.jogamp.newt.opengl.GLWindow newtCanvas = (com.jogamp.newt.opengl.GLWindow) surface.getNative();
- com.jogamp.newt.opengl.GLWindow newtCanvas = getCanvas();
- for(com.jogamp.newt.event.WindowListener l : newtCanvas.getWindowListeners())
- if(l.getClass().getName().startsWith("processing"))
- newtCanvas.removeWindowListener(l);
- newtCanvas.addWindowListener(new WindowAdapterNEWT(this));
- }
-
- /**
- * This sets what happens when the users attempts to close the window.
- * There are 3 possible actions depending on the value passed.
- * G4P.KEEP_OPEN - ignore attempt to close window (default action),
- * G4P.CLOSE_WINDOW - close this window,
- * G4P.EXIT_APP - exit the app, this will cause all windows to close.
- * @param action the required close action
- */
- public void setActionOnClose(int action){
- com.jogamp.newt.opengl.GLWindow newtCanvas = getCanvas();
- if(action == KEEP_OPEN)
- newtCanvas.setDefaultCloseOperation(com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSE);
- else
- newtCanvas.setDefaultCloseOperation(com.jogamp.nativewindow.WindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE);
- actionOnClose = action;
- }
-
- private com.jogamp.newt.opengl.GLWindow getCanvas(){
- return (com.jogamp.newt.opengl.GLWindow) surface.getNative();
- }
-
- /**
- * Fire a window closing event
- */
- protected void fireCloseWindowEvent() {
- getCanvas().destroy();
- }
-
- /**
- * Returns true if the window is visible else false
- */
- public boolean isVisible(){
- return getCanvas().isVisible();
- }
-
- /**
- * Get the window title
- */
- public String getTitle() {
- return getCanvas().getTitle();
- }
-
- /**
- * Get the window position.
- */
- public PVector getPosition(PVector pos) {
- if(pos == null)
- pos = new PVector();
- pos.x = getCanvas().getX();
- pos.y = getCanvas().getY();
- return pos;
- }
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/HotSpot.java b/Processing/libraries/G4P/src/g4p_controls/HotSpot.java
deleted file mode 100644
index 4d7bedb..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/HotSpot.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import processing.core.PApplet;
-import processing.core.PImage;
-
-/**
- * Base class for different types of hot spot.
- *
- * @author Peter Lager
- *
- */
-abstract class HotSpot implements GConstants, Comparable {
-
- public final Integer id;
- public float x, y;
-
- abstract public boolean contains(float px, float py);
-
- protected HotSpot(int id){
- this.id = Math.abs(id);
- }
-
- public void adjust(Object ... arguments){}
-
- public int compareTo(HotSpot spoto) {
- return id.compareTo(spoto.id);
- }
-
- /**
- * Hit is based on being inside a rectangle.
- *
- * @author Peter Lager
- */
- static class HSrect extends HotSpot {
- public float w, h;
-
- public HSrect(int id, float x, float y, float w, float h) {
- super(id);
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- }
-
- @Override
- public boolean contains(float px, float py) {
- return (px >= x && py >= y && px <= x + w && py <= y + h);
- }
- }
-
- /**
- * Hit based on an arc (pie slice)
- *
- * @author Peter Lager
- *
- */
- static class HSarc extends HotSpot {
-
- public float sa, ea, r, r2;
-
- public HSarc(int id, float x, float y, float r, float sa, float ea) {
- super(id);
- this.x = x;
- this.y = y;
- this.r = r;
- this.r2 = r * r;
- this.sa = sa;
- this.ea = ea;
- }
-
-
- @Override
- public boolean contains(float px, float py) {
- if((px-x)*(px-x) + (py-y)*(py-y) > r2)
- return false;
- // Now check angle
- float a = (float) Math.toDegrees(Math.atan2(py-y, px-x));
- if(a < 0) a += 360;
- if(a < sa) a += 360;
- return (a >= sa && a <= ea);
- }
- }
-
- /**
- * Hit is based on being inside a rectangle.
- *
- * @author Peter Lager
- */
- static class HScircle extends HotSpot {
- public float r, r2;
-
- public HScircle(int id, float x, float y, float r) {
- super(id);
- this.x = x;
- this.y = y;
- this.r = r;
- this.r2 = r * r;
- }
-
- @Override
- public boolean contains(float px, float py) {
- return ((px-x)*(px-x) + (py-y)*(py-y) <= r2);
- }
-
- /**
- * If used the parameters must be in the order x, y then r.
- *
- */
- @SuppressWarnings(value={"fallthrough"})
- public void adjust(Object ... arguments){
- switch(arguments.length){
- case 3:
- r = Float.valueOf(arguments[2].toString());
- r2 = r * r;
- case 2:
- y = Float.valueOf(arguments[1].toString());
- case 1:
- x = Float.valueOf(arguments[0].toString());
- }
- }
-
-
- public String toString(){
- return "HS circle ["+x+", "+y+"] radius = "+r;
- }
- }
-
- /**
- * Hit depends on the mask image. non-transparent areas are black and
- * transparent areas are white.
- *
- * It is better this way because scaling the image can change the
- * colour white to very nearly white but black is unchanged so is
- * easier to test.
- *
- * @author Peter Lager
- *
- */
- static class HSmask extends HotSpot {
-
- private PImage mask = null;
-
- protected HSmask(int id, PImage mask) {
- super(id);
- this.mask = mask;
- }
-
- @Override
- public boolean contains(float px, float py) {
- if(mask != null){
- int pixel = mask.get((int)px, (int)py);
- float alpha = (pixel >> 24) & 0xff;
- // A > 0 and RGB = 0 is transparent
- if(alpha > 0 && (pixel & 0x00ffffff) == 0){
- return true;
- }
- }
- return false;
- }
-
- public String toString(){
- return "HS mask ["+x+", "+y+"]";
- }
-
- }
-
- /**
- * Hit is determined by the alpha channel value.
- * @author Peter
- *
- */
- static class HSalpha extends HotSpot {
-
- private PImage image = null;
-
- private int offX, offY;
-
- protected HSalpha(int id, float x, float y, PImage image, int imageMode) {
- super(id);
- this.image = image;
- this.x = x;
- this.y = y;
- if(imageMode == PApplet.CENTER){
- offX = -image.width/2;
- offY = -image.height/2;
- }
- else
- offX = offY = 0;
- }
-
- /**
- * If used the parameters must be in the order x, y then image.
- */
- @SuppressWarnings(value={"fallthrough"})
- public void adjust(Object ... arguments){
- switch(arguments.length){
- case 3:
- image = (PImage) arguments[2];
- case 2:
- y = Float.valueOf(arguments[1].toString());
- case 1:
- x = Float.valueOf(arguments[0].toString());
- }
- }
-
- @Override
- public boolean contains(float px, float py) {
- if(image != null){
- int imgX = Math.round(px - x) - offX;
- int imgY = Math.round(py - y) - offY;
- float alpha = (image.get(imgX, imgY) >> 24) & 0xff;
- if(alpha > ALPHA_PICK)
- return true;
- }
- return false;
- }
-
- public String toString(){
- return "HS alpha ["+x+", "+y+"]";
- }
-
- }
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/ImageManager.java b/Processing/libraries/G4P/src/g4p_controls/ImageManager.java
deleted file mode 100644
index f82647d..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/ImageManager.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2012 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.util.HashMap;
-
-import processing.core.PApplet;
-import processing.core.PImage;
-
-/**
- * This class is used to load bitmap files and create images.
- *
- * Although there maybe multiple requests for a particular bitmap file only
- * one PImage is created for each file.
- *
- * @author Peter Lager
- *
- */
-public class ImageManager {
-
- private static HashMap textures = new HashMap();
-
- /**
- * Load a single bitmap file return a reference to the PImage created.
- *
- * @param app
- * @param filename
- * @return null if the file does not exist else the PImage object
- */
- public static PImage loadImage(PApplet app, String filename){
- if(textures.containsKey(filename)){
- return textures.get(filename);
- }
- PImage image = app.loadImage(filename);
- if(image != null){
- textures.put(filename, image);
- }
- else
- PApplet.println("Unable to load image from file '" + filename+"'");
- return image;
- }
-
- /**
- * Load images from multiple files
- * @param app
- * @param filename an array of filenames
- * @return an array of images
- */
- public static PImage[] loadImage(PApplet app, String[] filename){
- PImage[] images = new PImage[filename.length];
- for(int i = 0; i < images.length; i++)
- images[i] = loadImage(app, filename[i]);
- return images;
- }
-
-
-
- /**
- * Make multiple images from a given image. This method creates
- * a 2D array (size [nCols, nRows] ) of PImage objects.
- *
- * @param app
- * @param img the tiled image
- * @param nCols number of tiles across
- * @param nRows number of tiles down
- * @return a 2D array of images (tiles)
- */
- public static PImage[][] makeTiles2D(PApplet app, PImage img, int nCols, int nRows){
- PImage[][] imageTiles = new PImage[nCols][nRows];
- int tileW = img.width / nCols;
- int tileH = img.height / nRows;
- for(int y = 0; y < nRows; y++){
- for(int x = 0; x < nCols; x++){
- imageTiles[x][y] = app.createImage(tileW, tileH, PApplet.ARGB);
- imageTiles[x][y].copy(img, x * tileW, y * tileH, tileW, tileH, 0, 0, tileW, tileH);
- }
- }
- return imageTiles;
- }
-
- /**
- * Make multiple images from a given image. This method creates
- * a 1D array of PImage objects. The order is left-right and top-down.
- *
- * @param app
- * @param img the tiled image
- * @param nCols number of tiles across
- * @param nRows number of tiles down
- * @return a 1D array of images (tiles)
- */
- public static PImage[] makeTiles1D(PApplet app, PImage img, int nCols, int nRows){
- PImage[] imageTiles = new PImage[nCols * nRows];
- int tileW = img.width / nCols;
- int tileH = img.height / nRows;
- int tileNo = 0;
- for(int y = 0; y < nRows; y++){
- for(int x = 0; x < nCols; x++){
- imageTiles[tileNo] = app.createImage(tileW, tileH, PApplet.ARGB);
- imageTiles[tileNo].copy(img, x * tileW, y * tileH, tileW, tileH, 0, 0, tileW, tileH);
- tileNo++;
- }
- }
- return imageTiles;
- }
-
-
-
-}
diff --git a/Processing/libraries/G4P/src/g4p_controls/StyledString.java b/Processing/libraries/G4P/src/g4p_controls/StyledString.java
deleted file mode 100644
index e1ccfb0..0000000
--- a/Processing/libraries/G4P/src/g4p_controls/StyledString.java
+++ /dev/null
@@ -1,1360 +0,0 @@
-/*
- Part of the G4P library for Processing
- http://www.lagers.org.uk/g4p/index.html
- http://sourceforge.net/projects/g4p/files/?source=navbar
-
- Copyright (c) 2013 Peter Lager
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General
- Public License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- Boston, MA 02111-1307 USA
- */
-
-package g4p_controls;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GraphicAttribute;
-import java.awt.font.ImageGraphicAttribute;
-import java.awt.font.LineBreakMeasurer;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextHitInfo;
-import java.awt.font.TextLayout;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.text.AttributedCharacterIterator;
-import java.text.AttributedCharacterIterator.Attribute;
-import java.text.AttributedString;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.ListIterator;
-
-import processing.core.PApplet;
-
-/**
- * This class is used to represent text with attributes.
- * It means that you don't have to have the same style of font
- * or even the same font face over the whole length of the text.
- *
- * Most font features can be modified all except the text background
- * which is transparent. There is a feature to highlight part of the string
- * by having a different background colour but this is used for highlighting
- * selected text in GTextField and GTextArea components.
- *
- * It is also used for all controls that use text.
- * @author Peter Lager
- *
- */
-public final class StyledString implements GConstantsInternal, Serializable {
-
- private static final long serialVersionUID = -8272976313009558508L;
-
- transient private AttributedString styledText = null;
- transient private ImageGraphicAttribute spacer = null;
- transient private LineBreakMeasurer lineMeasurer = null;
- transient private LinkedList linesInfo = new LinkedList();
- transient private Font font = null;
-
- private static final char EOL = '\n';
-
- // The plain text to be styled
- private String plainText = "";
- // List of attribute runs to match font
- private LinkedList baseStyle = new LinkedList();
- // List of attribute runs to be applied over the base style
- private LinkedList atrun = new LinkedList();
-
- // The width to break a line
- private int wrapWidth = Integer.MAX_VALUE;
- // Flag to determine whether the text layouts need recalculating
- private boolean invalidLayout = true;
- // Flag to determine whether the actual character string have changed
- private boolean invalidText = true;
-
- // Base justification
- private boolean justify = false;
- private float justifyRatio = 0.7f;
-
- // Stats
- private float textHeight = 0;
- private float maxLineLength = 0;
- private float maxLineHeight = 0;
- private int nbrLines;
-
- // These are only used by GTextField and GTextArea to store the start and end positions
- // for selected text when the string is to be saved.
- int startIdx = -1;
- int endIdx = -1;
-
- /**
- * This is assumed to be a single line of text (i.e. no wrap).
- * EOL characters will be stripped from the text before use.
- *
- * @param startText
- */
- public StyledString(String startText){
- plainText = removeSingleSpacingFromPlainText(startText);
- spacer = getParagraghSpacer(1); // safety
- // Get rid of any EOLs
- styledText = new AttributedString(plainText);
- clearAttributes();
- applyAttributes();
- invalidText = true;
- invalidLayout = true;
- }
-
- /**
- * Supports multiple lines of text wrapped on word boundaries.
- *
- * @param startText the text to use
- * @param wrapWidth the wrap width
- */
- public StyledString(String startText, int wrapWidth){
- if(wrapWidth > 0 && wrapWidth < Integer.MAX_VALUE)
- this.wrapWidth = wrapWidth;
- plainText = (wrapWidth == Integer.MAX_VALUE) ? removeSingleSpacingFromPlainText(startText) : removeDoubleSpacingFromPlainText(startText);
- spacer = getParagraghSpacer(this.wrapWidth);
- styledText = new AttributedString(plainText);
- styledText = insertParagraphMarkers(plainText, styledText);
- clearAttributes();
- applyAttributes();
- invalidText = true;
- invalidLayout = true;
- }
-
- /**
- * Change the text for single line styled string
- * @param text the text to use
- */
- public void setText(String text){
- setText(text, Integer.MAX_VALUE);
- }
-
- /**
- * Change the text for single line styled string
- * @param text the text to use
- * @param wrapWidth the wrap width
- */
- public void setText(String text, int wrapWidth){
- setWrapWidth(wrapWidth);
- if(text != null && !text.equals(plainText)){
- plainText = text;
- if(this.wrapWidth == Integer.MAX_VALUE){
- removeSingleSpacingFromPlainText(plainText);
- spacer = getParagraghSpacer(1);
- styledText = new AttributedString(plainText);
- }
- else {
- removeDoubleSpacingFromPlainText(plainText);
- spacer = getParagraghSpacer(this.wrapWidth);
- styledText = new AttributedString(plainText);
- styledText = insertParagraphMarkers(plainText, styledText);
- }
- clearAttributes();
- applyAttributes();
- invalidText = true;
- invalidLayout = true;
- }
- }
-
- /**
- * Converts this StyledString from multi-line to single-line by replacing all EOL
- * characters with the space character
- * for paragraphs
- * @param ptext
- * @param as
- * @return the converted string
- */
- StyledString convertToSingleLineText(){
- // Make sure we have something to work with.
- if(styledText == null || plainText == null){
- plainText = "";
- styledText = new AttributedString(plainText);
- }
- else {
- // Scan through plain text and for each EOL replace the paragraph spacer from
- // the attributed string (styledText).
- int fromIndex = plainText.indexOf('\n', 0);
- if(fromIndex >= 0){
- while(fromIndex >= 0){
- try { // if text == "\n" then an exception is thrown
- styledText.addAttribute(TextAttribute.CHAR_REPLACEMENT, ' ', fromIndex, fromIndex + 1);
- fromIndex = plainText.indexOf('\n', fromIndex + 1);
- }
- catch(Exception excp){
- break;
- }
- }
- // Finally replace all EOL in the plainText
- plainText = plainText.replace('\n', ' ');
- }
- }
- wrapWidth = Integer.MAX_VALUE;
- return this;
- }
-
- /**
- * Get the plain text as a String. Any line breaks will kept and will
- * be represented by the character 'backslash n'
- * @return the associated plain text
- */
- public String getPlainText(){
- return plainText;
- }
-
- /**
- * Get the plain text as a String. Any line breaks will kept and will
- * be represented by the character 'backslash n'
- *
- * @param beginIdx the beginning index inclusive
- * @param endIdx the ending index exclusive
- * @return the substring starting at beginIdx to endIdx-1
- */
- public String getPlainText(int beginIdx, int endIdx){
- if(beginIdx < 0) beginIdx = 0;
- if(endIdx > plainText.length()) endIdx = plainText.length();
- return plainText.substring(beginIdx, endIdx);
- }
-
- /**
- * Get a line of text from the plain text. Lines are separated by
- * End-of-line (EOL) characters.
- *
- * @param lineNo the line number we want the text for
- * @return the line of text or an empty string if the line number is invalid.
- */
- public String getPlainText(int lineNo){
- Point loc = getPlainTextLinePosImpl(lineNo, null);
- return (loc == null) ? "" : plainText.substring(loc.x, loc.y);
- }
-
-
- private Point getPlainTextLinePosImpl(int lineNo, Point loc){
- if(lineNo < 0)
- return null;
- int pos = 0, p0 = 0, count = lineNo;
- // Find start of line
- while(count > 0 && pos < plainText.length()){
- if(plainText.charAt(pos) == EOL)
- count--;
- pos++;
- }
- // If we haven't found start of line then return empty string
- if(count > 0)
- return null;
- p0 = pos;
- while(pos < plainText.length() && plainText.charAt(pos) != EOL)
- pos++;
- if(loc == null)
- loc = new Point();
- else {
- loc.x = p0;
- loc.y = pos;
- }
- return loc;
- }
-
- /**
- * Get the plain text as a String array. (splitting on line breaks)
- * @return the associated plain text as a String array split on line breaks
- */
- public String[] getPlainTextAsArray(){
- return plainText.split("\n");
- }
-
- /**
- * Get the number of characters in this styled string
- */
- public int length(){
- return plainText.length();
- }
-
- /**
- * Text can be either left or fully justified.
- * @param justify true for full justification
- */
- public void setJustify(boolean justify){
- if(this.justify != justify){
- this.justify = justify;
- invalidLayout = true;
- }
- }
-
- /**
- * Justify only if the line has sufficient text to do so.
- *
- * @param jRatio ratio of text length to visibleWidth
- */
- public void setJustifyRatio(float jRatio){
- if(justifyRatio != jRatio){
- justifyRatio = jRatio;
- if(justify)
- invalidLayout = true;
- }
- }
-
- /**
- * This class uses transparent images to simulate end/starting positions
- * for paragraphs
- * @param ptext
- * @param as
- * @return the styled string with paragraph marker images embedded
- */
- private AttributedString insertParagraphMarkers(String ptext, AttributedString as ){
- if(ptext != null && ptext.length() > 0)
- plainText = ptext;
- int fromIndex = ptext.indexOf('\n', 0);
- while(fromIndex >= 0){
- try { // if text == "\n" then an exception is thrown
- as.addAttribute(TextAttribute.CHAR_REPLACEMENT, spacer, fromIndex, fromIndex + 1);
- fromIndex = ptext.indexOf('\n', fromIndex + 1);
- }
- catch(Exception excp){
- break;
- }
- }
- return as;
- }
-
- /**
- * If the text attribute is BACKGROUND or FOREGROUND then if we pass
- * an integer (e.g. from Processing sketch) then convert it.
- *
- * @param ta the text attribute
- * @param value the value to use with this text attribute
- */
- private Object validateTextAttributeColor(TextAttribute ta, Object value){
- if((ta == TextAttribute.BACKGROUND || ta == TextAttribute.FOREGROUND) && !(value instanceof Color))
- return new Color((Integer) value);
- else
- return value;
- }
-
- /**
- * Add an attribute that affects the whole length of the string.
- *
- * @param type attribute type
- * @param value attribute value
- */
- public void addAttribute(Attribute type, Object value){
- addAttribute(type, value, Integer.MIN_VALUE, Integer.MAX_VALUE);
- }
-
- /**
- * Add a text attribute (style) to the specifies range of characters
- *
- * @param type attribute type
- * @param value attribute value
- * @param lineNo the line of test affected
- * @param charStart the first character affected
- * @param charEnd the character position after the last character affected.
- */
- public void addAttribute(Attribute type, Object value, int lineNo, int charStart, int charEnd){
- if(lineNo >= 0 && lineNo < linesInfo.size()){
- TextLayoutInfo tli = linesInfo.get(lineNo);
- int lineStartsAt = tli.startCharIndex;
- charEnd = Math.min(charEnd, tli.nbrChars);
- addAttribute(type, value, lineStartsAt + charStart, lineStartsAt + charEnd);
- }
- }
-
- /**
- * Add a text attribute (style) to an entire display line
- *
- * @param type attribute type
- * @param value attribute value
- * @param lineNo the line of test affected
- */
- public void addAttribute(Attribute type, Object value, int lineNo){
- if(lineNo >= 0 && lineNo < linesInfo.size()){
- TextLayoutInfo tli = linesInfo.get(lineNo);
- addAttribute(type, value, tli.startCharIndex, tli.startCharIndex + tli.nbrChars);
- }
- }
-
- /**
- * Set the attribute to be applied to a range of characters starting at
- * beginIdx and ending with endIdx-1.
- *
- * @param type attribute type
- * @param value attribute value
- * @param beginIdx the index of the first character (inclusive)
- * @param endIdx the index of the last character (exclusive)
- */
- public void addAttribute(Attribute type, Object value, int beginIdx, int endIdx){
- value = validateTextAttributeColor((TextAttribute) type, value);
- AttributeRun ar = new AttributeRun(type, value, beginIdx, endIdx);
- // If we already have attributes try and rationalize the number by merging
- // runs if possible and removing runs that no longer have a visible effect.
- if(atrun.size() > 0){
- ListIterator iter = atrun.listIterator(atrun.size());
- while(iter.hasPrevious()){
- AttributeRun a = iter.previous();
- int action = ar.intersectionWith(a);
- int intersect = action & I_MODES;
- int combiMode = action & COMBI_MODES;
- if(combiMode == MERGE_RUNS){
- switch(intersect){
- case I_TL:
- case I_CL:
- ar.start = a.start;
- iter.remove();
- break;
- case I_TR:
- case I_CR:
- ar.end = a.end;
- iter.remove();
- break;
- }
- }
- else if(combiMode == CLIP_RUN){
- switch(intersect){
- case I_CL:
- a.end = ar.start;
- break;
- case I_CR:
- a.start = ar.end;
- break;
- }
- }
- switch(intersect){
- case I_INSIDE:
- iter.remove();
- break;
- case I_COVERED:
- ar = null;
- break;
- }
- }
- }
- // If the run is still effective then add it
- if(ar != null)
- atrun.addLast(ar);
- applyAttributes();
- invalidLayout = true;
- }
-
- /**
- * Remove text attributes (style) to the specified line and range of characters.
- *
- * @param lineNo the line of test affected
- * @param beginIdx the index of the first character (inclusive)
- * @param endIdx the index of the last character (exclusive)
- */
- public void clearAttributes(int lineNo, int beginIdx, int endIdx){
- if(lineNo >= 0 && lineNo < linesInfo.size()){
- TextLayoutInfo tli = linesInfo.get(lineNo);
- int lineStartsAt = tli.startCharIndex;
- endIdx = Math.min(endIdx, tli.nbrChars);
- clearAttributes(lineStartsAt + beginIdx, lineStartsAt + endIdx);
- }
- }
-
- /**
- *
- * @param lineNo
- */
- public void clearAttributes(int lineNo){
- if(lineNo >= 0 && lineNo < linesInfo.size()){
- TextLayoutInfo tli = linesInfo.get(lineNo);
- clearAttributes(tli.startCharIndex, tli.startCharIndex + tli.nbrChars);
- }
- }
-
- /**
- * Remove text attributes (style) to the specified range of characters.
- *
- * @param beginIdx the index of the first character (inclusive)
- * @param endIdx the index of the last character (exclusive)
- */
- public void clearAttributes(int beginIdx, int endIdx){
- ListIterator iter = atrun.listIterator();
- AttributeRun ar;
- while(iter.hasNext()){
- ar = iter.next();
- // Make sure we have intersection
- if( !(beginIdx >= ar.end && endIdx >= ar.start )){
- // Find the limits to clear
- int s = Math.max(beginIdx, ar.start);
- int e = Math.min(endIdx, ar.end);
- if(ar.start == s && ar.end == e)
- iter.remove();
- else if(ar.start == s) // clear style from beginning
- ar.start = e;
- else if(ar.end == e) // clear style from end
- ar.end = s;
- else { // Split attribute run
- AttributeRun ar2 = new AttributeRun(ar.atype, ar.value, e, ar.end);
- iter.add(ar2);
- ar.end = s;
- }
- }
- }
- invalidText = true;
- }
-
- /**
- * Removes all styling from the string.
- *
- */
- public void clearAttributes(){
- atrun.clear();
- invalidText = true;
- }
-
- /**
- * Must call this method to apply
- */
- private void applyAttributes(){
- if(plainText.length() > 0){
- for(AttributeRun bsar : baseStyle)
- styledText.addAttribute(bsar.atype, bsar.value);
- Iterator iter = atrun.iterator();
- AttributeRun ar;
-
- while(iter.hasNext()){
- ar = iter.next();
- if(ar.end == Integer.MAX_VALUE)
- styledText.addAttribute(ar.atype, ar.value);
- else {
- // If an attribute run fails do not try and fix it - dump it
- try {
- styledText.addAttribute(ar.atype, ar.value, ar.start, ar.end);
- }
- catch(Exception excp){
- System.out.println("Dumping " + ar);
- excp.printStackTrace();
- iter.remove();
- }
- }
- }
- }
- invalidLayout = true;
- }
-
- /**
- * Insert some text into the position indicated.
- *
- * @param lineNo a valid line number
- * @param charStart the position in the line >= 0
- * @param chars the characters to insert
- * @param startNewLine prefix the chars with a EOL
- * @param endNewLine postfix the chars with a EOL
- * @return the number of characters inserted
- */
- public int insertCharacters(String chars, int lineNo, int charStart, boolean startNewLine, boolean endNewLine){
- if(lineNo >= 0 && lineNo < linesInfo.size()){
- TextLayoutInfo tli = linesInfo.get(lineNo);
- int insertPos = tli.startCharIndex + Math.min(charStart, tli.nbrChars);
- return insertCharactersImpl(insertPos, chars, startNewLine, endNewLine);
- }
- return 0;
- }
-
- /**
- * Insert 1 or more characters into the string. The inserted text will first be made
- * safe by removing any inappropriate EOL characters.
- * Do not use this method to insert EOL characters, use the
insertEOL(int)
- * method instead.
- *
- * @param insertPos position in string to insert characters
- * @param chars the characters to insert
- * @return the number of characters inserted
- */
- public int insertCharacters(String chars, int insertPos){
- return insertCharactersImpl(insertPos, chars, false, false);
- }
-
- /**
- * Insert 1 or more characters into the string. The inserted text will first be made
- * safe by removing any inappropriate EOL characters.
- * Do not use this method to insert EOL characters, use the
insertEOL(int)
- * method instead.
- *
- * @param insertPos position in string to insert characters
- * @param chars the characters to insert
- * @param startNewLine if true insert onto a new line
- * @return the number of characters inserted
- */
- public int insertCharacters(String chars, int insertPos, boolean startNewLine, boolean endNewLine){
- return insertCharactersImpl(insertPos, chars, startNewLine, endNewLine);
- }
-
- /**
- * Implementation for inserting characters into the plain text.
- *
- * @param insertPos the position to insert the text
- * @param chars the characters to insert
- * @param startNewLine inserted text to start on new line
- * @param endNewLine text after inserted text to start on new line
- * @return the number of characters inserted including EOLs
- */
- private int insertCharactersImpl(int insertPos, String chars, boolean startNewLine, boolean endNewLine){
- chars = makeStringSafeForInsert(chars);
- int nbrChars = chars.length();
- int nbrCharsInserted = nbrChars;
- if(nbrChars > 0){
- plainText = plainText.substring(0, insertPos) + chars + plainText.substring(insertPos);
- if(endNewLine && plainText.charAt(insertPos + nbrChars) != '\n')
- nbrCharsInserted += insertEOL(insertPos + nbrChars) ? 1 : 0;
- if(startNewLine && insertPos > 0)
- nbrCharsInserted += insertEOL(insertPos) ? 1 : 0;
- insertParagraphMarkers(plainText, styledText);
- for(AttributeRun ar : atrun){
- if(ar.end < Integer.MAX_VALUE){
- if(ar.end >= insertPos){
- ar.end += nbrChars;
- if(ar.start >= insertPos)
- ar.start += nbrChars;
- }
- }
- }
- invalidText = true;
- }
- return nbrCharsInserted;
- }
-
- /**
- * This is ONLY used when multiple characters are to be inserted.
- * If it is single line text i.e. no wrapping then it removes all EOLs
- * If it is multiple line spacing it will reduce all double EOLs to single
- * EOLs and remove any EOLs at the start or end of the string.
- *
- * @param chars
- * @return a string that is safe for inserting
- */
- private String makeStringSafeForInsert(String chars){
- // Get rid of single / double line spacing
- if(chars.length() > 0){
- if(wrapWidth == Integer.MAX_VALUE) // no wrapping remove all
- chars = removeSingleSpacingFromPlainText(chars);
- else {
- chars = removeDoubleSpacingFromPlainText(chars); // wrapping remove double spacing
- // no remove EOL at ends of string
- while(chars.length() > 0 && chars.charAt(0) == '\n')
- chars = chars.substring(1);
- while(chars.length() > 0 && chars.charAt(chars.length() - 1) == '\n')
- chars = chars.substring(0, chars.length() - 1);
- }
- }
- return chars;
- }
-
- /**
- * Use this method to insert an EOL character.
- * @param insertPos index position to insert EOL
- * @return true if an EOL was inserted into the string
- */
- public boolean insertEOL(int insertPos){
- if(wrapWidth != Integer.MAX_VALUE){
- if(insertPos == 0)
- return false;
- if(insertPos > 0 && plainText.charAt(insertPos-1) == '\n')
- return false;
- if(insertPos < plainText.length()-1 && plainText.charAt(insertPos+1) == '\n'){
- return false;
- }
- plainText = plainText.substring(0, insertPos) + "\n" + plainText.substring(insertPos);
- insertParagraphMarkers(plainText, styledText);
- for(AttributeRun ar : atrun){
- if(ar.end < Integer.MAX_VALUE){
- if(ar.end >= insertPos){
- ar.end += 1;
- if(ar.start >= insertPos)
- ar.start += 1;
- }
- }
- }
- invalidText = true;
- return true;
- }
- return false;
- }
-
-
- /**
- * Remove a number of characters from the string
- *
- * @param nbrToRemove number of characters to remove
- * @param fromPos start location for removal
- * @return true if the deletion was successful else false
- */
- public boolean deleteCharacters(int fromPos, int nbrToRemove){
- if(fromPos < 0 || fromPos + nbrToRemove > plainText.length())
- return false;
- /*
- * If the character preceding the selection and the character immediately after the selection
- * are both EOLs then increment the number of characters to be deleted
- */
- if(wrapWidth != Integer.MAX_VALUE){
- if(fromPos > 0 && fromPos + nbrToRemove < plainText.length() - 1){
- if(plainText.charAt(fromPos) == '\n' && plainText.charAt(fromPos + nbrToRemove) == '\n'){
- nbrToRemove++;
- }
- }
- }
- if(fromPos != 0)
- plainText = plainText.substring(0, fromPos) + plainText.substring(fromPos + nbrToRemove);
- else
- plainText = plainText.substring(fromPos + nbrToRemove);
- // For wrappable text make sure we have not created
- if(plainText.length() == 0){
- atrun.clear();
- styledText = null;
- }
- else {
- ListIterator iter = atrun.listIterator(atrun.size());
- AttributeRun ar;
- while(iter.hasPrevious()){
- ar = iter.previous();
- if(ar.end < Integer.MAX_VALUE){
- // Only need to worry about this if the run ends after the deletion point
- if(ar.end >= fromPos){
- int lastPos = fromPos + nbrToRemove;
- // Deletion removes entire run
- if(fromPos <= ar.start && lastPos >= ar.end){
- iter.remove();
- continue;
- }
- // Deletion fits entirely within the run
- if(fromPos > ar.start && lastPos < ar.end){
- ar.end -= nbrToRemove;
- continue;
- }
- // Now we have overlap either at one end of the run
- // Overlap at start of run?
- if(fromPos <= ar.start){
- ar.start = fromPos;
- ar.end -= nbrToRemove;
- continue;
- }
- // Overlap at end of run?
- if(lastPos >= ar.end){
- ar.end = fromPos;
- continue;
- }
- System.out.println("This run was not modified");
- System.out.println("Run from " + ar.start + " to " + ar.end);
- System.out.println("Delete from " + fromPos + " To " + lastPos + " (" + nbrToRemove + " to remove)");
- }
- }
- }
- }
- invalidText = true;
- return true;
- }
-
- private void setFont(Font a_font){
- if(a_font != null && a_font != font){
- font = a_font;
- baseStyle.clear();
- baseStyle.add(new AttributeRun(TextAttribute.FAMILY, font.getFamily()));
- baseStyle.add(new AttributeRun(TextAttribute.SIZE, font.getSize()));
- baseStyle.add(new AttributeRun(TextAttribute.WIDTH, TextAttribute.WIDTH_REGULAR));
- if(font.isBold())
- baseStyle.add(new AttributeRun(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR));
- else
- baseStyle.add(new AttributeRun(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR));
- if(font.isItalic())
- baseStyle.add(new AttributeRun(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE));
- else
- baseStyle.add(new AttributeRun(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR));
- invalidText = true;
- }
- }
-
- public void invalidateText(){
- invalidText = true;
- }
-
- /**
- * Get the text layouts for display if the string has changed since last call
- * to this method regenerate them.
- *
- * @param g2d Graphics2D display context
- * @return a list of text layouts for rendering
- */
- public LinkedList getLines(Graphics2D g2d){
- if(font != g2d.getFont()){
- setFont(g2d.getFont());
- invalidText = true;
- }
- if(invalidText){
- styledText = new AttributedString(plainText);
- styledText = insertParagraphMarkers(plainText, styledText);
- setFont(font);
- applyAttributes();
- invalidText = false;
- invalidLayout = true;
- }
- if(invalidLayout){
- linesInfo.clear();
- if(plainText.length() > 0){
- textHeight = 0;
- maxLineLength = 0;
- maxLineHeight = 0;
- nbrLines = 0;
- AttributedCharacterIterator paragraph = styledText.getIterator(null, 0, plainText.length());
- FontRenderContext frc = g2d.getFontRenderContext();
- lineMeasurer = new LineBreakMeasurer(paragraph, frc);
- float yposinpara = 0;
- int charssofar = 0;
- while (lineMeasurer.getPosition() < plainText.length()) {
- TextLayout layout = lineMeasurer.nextLayout(wrapWidth);
- float advance = layout.getVisibleAdvance();
- if(justify){
- if(justify && advance > justifyRatio * wrapWidth){
- // If advance > breakWidth then we have a line break
- float jw = (advance > wrapWidth) ? advance - wrapWidth : wrapWidth;
- layout = layout.getJustifiedLayout(jw);
- }
- }
- // Remember the longest and tallest value for a layout so far.
- float lh = getHeight(layout);
- if(lh > maxLineHeight)
- maxLineHeight = lh;
- textHeight += lh;
- if(advance <= wrapWidth && advance > maxLineLength)
- maxLineLength = advance;
-
- // Store layout and line info
- linesInfo.add(new TextLayoutInfo(nbrLines, layout, charssofar, layout.getCharacterCount(), yposinpara));
- charssofar += layout.getCharacterCount();
- yposinpara += lh;
- nbrLines++;
- }
- }
- invalidLayout = false;
- }
- return linesInfo;
- }
-
- /**
- * Get the number of lines in the layout
- */
- public int getNbrLines(){
- return nbrLines;
- }
-
- /**
- * Return the height of the text line(s)
- */
- public float getTextAreaHeight(){
- return textHeight;
- }
-
- /**
- * Return the length of the longest line.
- */
- public float getMaxLineLength(){
- return maxLineLength;
- }
-
- /**
- * Get the height of the tallest line
- */
- public float getMaxLineHeight(){
- return maxLineHeight;
- }
-
- /**
- * Get the height of the given TextLayout
- * @param layout
- * @return the height of a given text layout
- */
- private float getHeight(TextLayout layout){
- return layout.getAscent() +layout.getDescent() + layout.getLeading();
- }
-
- /**
- * Get the break width used to create the lines.
- */
- public int getWrapWidth(){
- return wrapWidth;
- }
-
- /**
- * Set the maximum width of a line.
- * @param wrapWidth
- */
- public void setWrapWidth(int wrapWidth){
- if(this.wrapWidth != wrapWidth){
- this.wrapWidth = wrapWidth;
- invalidLayout = true;
- }
- }
-
- /**
- * Calculate the TLHI for a given pixel position
- * @param g2d
- * @param px
- * @param py
- * @return
- */
- TextLayoutHitInfo calculateFromXY(Graphics2D g2d, float px, float py){
- TextHitInfo thi = null;
- TextLayoutInfo tli = null;
- TextLayoutHitInfo tlhi = null;
- if(invalidLayout)
- getLines(g2d);
- if(px < 0) px = 0;
- if(py < 0) py = 0;
- tli = getTLIforYpos(py);
- // Correct py to match layout's upper-left bounds
- py -= tli.yPosInPara;
- // get hit
- thi = tli.layout.hitTestChar(px,py);
- tlhi = new TextLayoutHitInfo(tli, thi);
- return tlhi;
- }
-
- /**
- * Get a layout based on line number
- * @param ln line number
- * @return text layout info for the line ln
- */
- TextLayoutInfo getTLIforLineNo(int ln){
- if(ln >= 0 || ln < linesInfo.size())
- return linesInfo.get(ln);
- else
- return null;
- }
-
- /**
- * This will always return a layout provide there is some text.
- * @param y Must be >= 0
- * @return the first layout where y is above the upper layout bounds
- */
- TextLayoutInfo getTLIforYpos(float y){
- TextLayoutInfo tli = null;
- if(!linesInfo.isEmpty()){
- for(int i = linesInfo.size()-1; i >= 0; i--){
- tli = linesInfo.get(i);
- if(tli.yPosInPara <= y)
- break;
- }
- }
- return tli;
- }
-
- /**
- * This will always return a layout provided charNo >= 0.
- *
- * If charNo > than the index of the last character in the plain text then this
- * should be corrected to the last character in the layout by the caller.
- *
- * @param charNo the character position in text (must be >= 0)
- * @return the first layout where c is greater that the layout's start char index.
- */
- TextLayoutInfo getTLIforCharNo(int charNo){
- TextLayoutInfo tli = null;
- if(!linesInfo.isEmpty()){
- for(int i = linesInfo.size()-1; i >= 0; i--){
- tli = linesInfo.get(i);
- if(tli.startCharIndex < charNo)
- break;
- }
- }
- return tli;
- }
-
- /**
- * For a given line number and character position get the
- * corresponding TextLayoutHitInfo object
- * @param lineNo line number
- * @param charNo position in line
- * @return the corresponding TextLayoutHitInfo object
- */
- TextLayoutHitInfo getTLHIforCharPosition(int lineNo, int charNo){
- TextLayoutHitInfo tlhi = null;
- TextHitInfo thi = null;
- TextLayoutInfo tli = getTLIforLineNo(lineNo);
- if(tli != null){
- charNo = PApplet.constrain(charNo, 0, tli.nbrChars-2);
- thi = tli.layout.getNextRightHit(charNo);
- if(thi != null)
- tlhi = new TextLayoutHitInfo(tli, thi);
- }
- return tlhi;
- }
-
- /**
- * For a given position in the plain text get the
- * corresponding TextLayoutHitInfo object.
- *
- * @param pos position in the plaintext
- * @return the corresponding TextLayoutHitInfo object
- */
- TextLayoutHitInfo getTLHIforCharPosition(int pos){
- if(pos < 0 || pos >= plainText.length())
- return null;
- int lineNo = 0, posInLine = pos;
- for(lineNo = linesInfo.size()-1; lineNo >= 0; lineNo--){
- TextLayoutInfo tli = getTLIforLineNo(lineNo);
- posInLine = pos - tli.startCharIndex;
- if(tli.startCharIndex <= pos)
- break;
- }
- return getTLHIforCharPosition(lineNo, posInLine);
- }
-
- /**
- * Get the character position in the plain text that is associated
- * with the given line and character number.
- *
- * @param lineNo the line number (starts with 0)
- * @param charNo the character position in the line (starts with 0)
- * @return the position in plain text or -1 if an invalid lineNo
- */
- int getPos(int lineNo, int charNo){
- TextLayoutInfo tli = getTLIforLineNo(lineNo);
- if(tli != null)
- return tli.startCharIndex + charNo;
- else
- return -1;
- }
-
- /**
- * Ensure we do not have blank lines by replacing double EOL characters by
- * single EOL until there are only single EOLs.
- * Using replaceAll on its own will not work because EOL/EOL/EOL would
- * become EOL/EOL not the single EOL required.
- *
- */
- private String removeDoubleSpacingFromPlainText(String chars){
- while(chars.indexOf("\n\n") >= 0){
- invalidText = true;
- chars = chars.replaceAll("\n\n", "\n");
- }
- return chars;
- }
-
- /**
- * Remove all EOL characters from the string. This is necessary if the string
- * is for a single line component.
- * @param chars the string to use
- * @return the string with all EOLs removed
- */
- private String removeSingleSpacingFromPlainText(String chars){
- while(chars.indexOf("\n") >= 0){
- invalidText = true;
- chars = chars.replaceAll("\n", "");
- }
- return chars;
- }
-
- /**
- * Create a graphic image character to simulate paragraph breaks
- *
- * @param ww
- * @return a blank image to manage paragraph ends.
- */
- private ImageGraphicAttribute getParagraghSpacer(int ww){
- if(ww == Integer.MAX_VALUE)
- ww = 1;
- BufferedImage img = new BufferedImage(ww, 10, BufferedImage.TYPE_INT_ARGB);
- Graphics g = img.getGraphics();
- g.setColor(new Color(255, 255, 255, 0));
- g.fillRect(0,0,img.getWidth(), img.getHeight());
- return new ImageGraphicAttribute(img, GraphicAttribute.TOP_ALIGNMENT);
- }
-
-
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- * Serialisation routines to save/restore the StyledString to disc.
- */
-
- /**
- * Save the named StyleString in the named file.
- *
- * @param papp
- * @param ss the styled string
- * @param fname
- */
- public static void save(PApplet papp, StyledString ss, String fname){
- OutputStream os;
- ObjectOutputStream oos;
- try {
- os = papp.createOutput(fname);
- oos = new ObjectOutputStream(os);
- oos.writeObject(ss);
- os.close();
- oos.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Load and return a StyledString object from the given file.
- *
- * @param papp
- * @param fname the filename of the StyledString
- */
- public static StyledString load(PApplet papp, String fname){
- StyledString ss = null;
- InputStream is;
- ObjectInputStream ios;
- try {
- is = papp.createInput(fname);
- ios = new ObjectInputStream(is);
- ss = (StyledString) ios.readObject();
- is.close();
- ios.close();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- return ss;
- }
-
-
- private void readObject(ObjectInputStream ois)
- throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- // Recreate transient elements
- spacer = getParagraghSpacer(wrapWidth);
- styledText = new AttributedString(plainText);
- styledText = insertParagraphMarkers(plainText, styledText);
- linesInfo = new LinkedList();
- applyAttributes();
- }
-
- /**
- * For multi-line text, the TextHitInfo class is not enough. We also need
- * information about the layout so that the caret(s) can be drawn.
- *
- * @author Peter Lager
- *
- */
- static public class TextLayoutHitInfo implements Comparable{
- public TextLayoutInfo tli;
- public TextHitInfo thi;
-
-
- public TextLayoutHitInfo() {
- this.tli = null;
- this.thi = null;
- }
-
- /**
- * @param tli
- */
- public TextLayoutHitInfo(TextLayoutInfo tli) {
- this.tli = tli;
- this.thi = null;
- }
-
- /**
- * @param tli
- * @param thi
- */
- public TextLayoutHitInfo(TextLayoutInfo tli, TextHitInfo thi) {
- this.tli = tli;
- this.thi = thi;
- }
-
- /**
- * Copy constructor
- * @param tlhi
- */
- public TextLayoutHitInfo(TextLayoutHitInfo tlhi){
- tli = tlhi.tli;
- thi = tlhi.thi;
- }
-
- public void copyFrom(TextLayoutHitInfo other){
- this.tli = other.tli;
- this.thi = other.thi;
- }
-
- public void setInfo(TextLayoutInfo tli, TextHitInfo thi) {
- this.tli = tli;
- this.thi = thi;
- }
-
- public int compareTo(TextLayoutHitInfo other) {
- if(tli == null || other.tli == null)
- return 0;
- int layoutComparison = tli.compareTo(other.tli);
- if(layoutComparison != 0)
- return layoutComparison; // Different layouts so return comparison
-
- // Same layout SO test hit info
- if(thi == null || other.thi == null || thi.equals(other.thi))
- return 0;
- // if(thi.equals(other.thi))
- // return 0;
- // Same layout different hit info SO test char index
- if(thi.getCharIndex() != other.thi.getCharIndex()){
- // Different current chars so order on position
- return (thi.getCharIndex() < other.thi.getCharIndex() ? -1 : 1);
- }
- // Same layout same char different edge hit SO test on edge hit
- return (thi.isLeadingEdge() ? -1 : 1);
- }
-
- public String toString(){
- StringBuilder s = new StringBuilder(tli.toString());
- s.append(" Hit char = " + thi.getCharIndex());
- return new String(s);
- }
- }
-
- /**
- * Class to hold information about a text layout. This class helps simplify the
- * algorithms needed for multi-line text.
- *
- * @author Peter Lager
- *
- */
- static public class TextLayoutInfo implements Comparable {
- public TextLayout layout; // The matching layout
- public int lineNo; // The line number
- public int startCharIndex; // Position of the first char in text
- public int nbrChars; // Number of chars in this layout
- public float yPosInPara; // Top-left corner of bounds
-
- /**
- * @param startCharIndex
- * @param nbrChars
- * @param yPosInPara
- */
- public TextLayoutInfo(int lineNo, TextLayout layout, int startCharIndex, int nbrChars, float yPosInPara) {
- this.lineNo = lineNo;
- this.layout = layout;
- this.startCharIndex = startCharIndex;
- this.nbrChars = nbrChars;
- this.yPosInPara = yPosInPara;
- }
-
- public int compareTo(TextLayoutInfo other) {
- if(lineNo == other.lineNo)
- return 0;
- return (startCharIndex < other.startCharIndex) ? -1 : 1;
- }
-
- public String toString(){
- StringBuilder s = new StringBuilder("{ Line no = " + lineNo + " starts @ char pos " + startCharIndex);
- s.append(" last index " + (startCharIndex+nbrChars+1));
- s.append(" (" + nbrChars +") ");
- return new String(s);
- }
- }
-
- /**
- * Since most of the Java classes associated with AttributedString
- * are immutable with virtually no public methods this class represents
- * an attribute to be applied.
- *
- * This class is only used from within StyledString.
- *
- * @author Peter Lager
- *
- */
- private class AttributeRun implements Serializable {
-
- private static final long serialVersionUID = -8401062069478890163L;
-
- public Attribute atype;
- public Object value;
- public Integer start;
- public Integer end;
-
-
- /**
- * The attribute and value to be applied over the whole string
- * @param atype
- * @param value
- */
- public AttributeRun(Attribute atype, Object value) {
- this.atype = atype;
- this.value = value;
- this.start = Integer.MIN_VALUE;
- this.end = Integer.MAX_VALUE;
- }
-
- /**
- * The attribute and value to be applied over the given range
- * @param atype
- * @param value
- * @param start
- * @param end
- */
- public AttributeRun(Attribute atype, Object value, int start, int end) {
- this.atype = atype;
- this.value = value;
- this.start = start;
- this.end = end;
- }
-
- /**
- * If possible merge the two runs or crop the prevRun run.
- *
- * If both runs have the same attribute type and the represent
- * the same location and size in the text then the intersection
- * mode will be MM_SURROUNDS rather than MM_SURROUNDED because
- * 'this' is the attribute being added.
- * @param m
- * @param s
- * @return
- */
- private int intersectionWith(AttributeRun ar){
- // Different attribute types?
- if(atype != ar.atype)
- return I_NONE;
- // Check for combination mode
- int combi_mode = (value.equals(ar.value)) ? MERGE_RUNS : CLIP_RUN;
- int sdx = 4, edx = 0;
- // Start index
- if(ar.start < start)
- sdx = 0;
- else if(ar.start == start)
- sdx = 1;
- else if (ar.start < end)
- sdx = 2;
- else if(ar.start == end)
- sdx = 3;
- if(sdx < 4){
- if(ar.end > end)
- edx = 4;
- else if(ar.end == end)
- edx = 3;
- else if(ar.end > start)
- edx = 2;
- else if(ar.end == start)
- edx = 1;
- }
- combi_mode |= grid[sdx][edx];
- return combi_mode;
- }
-
- public String toString(){
- String s = atype.toString() + " value = " + value.toString() + " from " + start + " to " + end;
- return s;
- }
-
- } // End of AttributeRun class
-
-}
diff --git a/Processing/libraries/controlP5/examples/controllers/ControlP5accordion/ControlP5accordion.pde b/Processing/libraries/controlP5/examples/controllers/ControlP5accordion/ControlP5accordion.pde
deleted file mode 100644
index 81d395d..0000000
--- a/Processing/libraries/controlP5/examples/controllers/ControlP5accordion/ControlP5accordion.pde
+++ /dev/null
@@ -1,286 +0,0 @@
-/**
- * ControlP5 Accordion
- * arrange controller groups in an accordion like style.
- *
- * find a list of public methods available for the Accordion Controller
- * at the bottom of this sketch. In the example below 3 groups with controllers
- * are created and added to an accordion controller. Furthermore several key
- * combinations are mapped to control individual settings of the accordion.
- * An accordion comes in 2 modes, Accordion.SINGLE and Accordion.MULTI where the
- * latter allows to open multiple groups of an accordion and the SINGLE mode only
- * allows 1 group to be opened at a time.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-Accordion accordion;
-
-color c = color(0, 160, 100);
-
-void setup() {
- size(400, 600);
- noStroke();
- smooth();
- gui();
-}
-
-void gui() {
-
- cp5 = new ControlP5(this);
-
- // group number 1, contains 2 bangs
- Group g1 = cp5.addGroup("myGroup1")
- .setBackgroundColor(color(0, 64))
- .setBackgroundHeight(150)
- ;
-
- cp5.addBang("bang")
- .setPosition(10,20)
- .setSize(100,100)
- .moveTo(g1)
- .plugTo(this,"shuffle");
- ;
-
- // group number 2, contains a radiobutton
- Group g2 = cp5.addGroup("myGroup2")
- .setBackgroundColor(color(0, 64))
- .setBackgroundHeight(150)
- ;
-
- cp5.addRadioButton("radio")
- .setPosition(10,20)
- .setItemWidth(20)
- .setItemHeight(20)
- .addItem("black", 0)
- .addItem("red", 1)
- .addItem("green", 2)
- .addItem("blue", 3)
- .addItem("grey", 4)
- .setColorLabel(color(255))
- .activate(2)
- .moveTo(g2)
- ;
-
- // group number 3, contains a bang and a slider
- Group g3 = cp5.addGroup("myGroup3")
- .setBackgroundColor(color(0, 64))
- .setBackgroundHeight(150)
- ;
-
- cp5.addBang("shuffle")
- .setPosition(10,20)
- .setSize(40,50)
- .moveTo(g3)
- ;
-
- cp5.addSlider("hello")
- .setPosition(60,20)
- .setSize(100,20)
- .setRange(100,500)
- .setValue(100)
- .moveTo(g3)
- ;
-
- cp5.addSlider("world")
- .setPosition(60,50)
- .setSize(100,20)
- .setRange(100,500)
- .setValue(200)
- .moveTo(g3)
- ;
-
- // create a new accordion
- // add g1, g2, and g3 to the accordion.
- accordion = cp5.addAccordion("acc")
- .setPosition(40,40)
- .setWidth(200)
- .addItem(g1)
- .addItem(g2)
- .addItem(g3)
- ;
-
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.open(0,1,2);}}, 'o');
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.close(0,1,2);}}, 'c');
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setWidth(300);}}, '1');
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setPosition(0,0);accordion.setItemHeight(190);}}, '2');
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setCollapseMode(ControlP5.ALL);}}, '3');
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {accordion.setCollapseMode(ControlP5.SINGLE);}}, '4');
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {cp5.remove("myGroup1");}}, '0');
-
- accordion.open(0,1,2);
-
- // use Accordion.MULTI to allow multiple group
- // to be open at a time.
- accordion.setCollapseMode(Accordion.MULTI);
-
- // when in SINGLE mode, only 1 accordion
- // group can be open at a time.
- // accordion.setCollapseMode(Accordion.SINGLE);
-}
-
-
-void radio(int theC) {
- switch(theC) {
- case(0):c=color(0,200);break;
- case(1):c=color(255,0,0,200);break;
- case(2):c=color(0, 200, 140,200);break;
- case(3):c=color(0, 128, 255,200);break;
- case(4):c=color(50,128);break;
- }
-}
-
-
-void shuffle() {
- c = color(random(255),random(255),random(255),random(128,255));
-}
-
-
-void draw() {
- background(220);
-
- fill(c);
-
- float s1 = cp5.getController("hello").getValue();
- ellipse(200,400,s1,s1);
-
- float s2 = cp5.getController("world").getValue();
- ellipse(300,100,s2,s2);
-}
-
-
-
-
-
-/*
-a list of all methods available for the Accordion Controller
-use ControlP5.printPublicMethodsFor(Accordion.class);
-to print the following list into the console.
-
-You can find further details about class Accordion in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.Accordion : Accordion addItem(ControlGroup)
-controlP5.Accordion : Accordion close()
-controlP5.Accordion : Accordion open()
-controlP5.Accordion : Accordion remove(ControllerInterface)
-controlP5.Accordion : Accordion removeItem(ControlGroup)
-controlP5.Accordion : Accordion setCollapseMode(int)
-controlP5.Accordion : Accordion setItemHeight(int)
-controlP5.Accordion : Accordion setMinItemHeight(int)
-controlP5.Accordion : Accordion setWidth(int)
-controlP5.Accordion : Accordion updateItems()
-controlP5.Accordion : int getItemHeight()
-controlP5.Accordion : int getMinItemHeight()
-controlP5.ControlGroup : Accordion activateEvent(boolean)
-controlP5.ControlGroup : Accordion addListener(ControlListener)
-controlP5.ControlGroup : Accordion removeListener(ControlListener)
-controlP5.ControlGroup : Accordion setBackgroundColor(int)
-controlP5.ControlGroup : Accordion setBackgroundHeight(int)
-controlP5.ControlGroup : Accordion setBarHeight(int)
-controlP5.ControlGroup : Accordion setSize(int, int)
-controlP5.ControlGroup : Accordion updateInternalEvents(PApplet)
-controlP5.ControlGroup : String getInfo()
-controlP5.ControlGroup : String toString()
-controlP5.ControlGroup : int getBackgroundHeight()
-controlP5.ControlGroup : int getBarHeight()
-controlP5.ControlGroup : int listenerSize()
-controlP5.ControllerGroup : Accordion add(ControllerInterface)
-controlP5.ControllerGroup : Accordion addListener(ControlListener)
-controlP5.ControllerGroup : Accordion bringToFront()
-controlP5.ControllerGroup : Accordion bringToFront(ControllerInterface)
-controlP5.ControllerGroup : Accordion close()
-controlP5.ControllerGroup : Accordion disableCollapse()
-controlP5.ControllerGroup : Accordion enableCollapse()
-controlP5.ControllerGroup : Accordion hide()
-controlP5.ControllerGroup : Accordion hideArrow()
-controlP5.ControllerGroup : Accordion hideBar()
-controlP5.ControllerGroup : Accordion moveTo(ControlWindow)
-controlP5.ControllerGroup : Accordion moveTo(PApplet)
-controlP5.ControllerGroup : Accordion open()
-controlP5.ControllerGroup : Accordion registerProperty(String)
-controlP5.ControllerGroup : Accordion registerProperty(String, String)
-controlP5.ControllerGroup : Accordion remove(CDrawable)
-controlP5.ControllerGroup : Accordion remove(ControllerInterface)
-controlP5.ControllerGroup : Accordion removeCanvas(Canvas)
-controlP5.ControllerGroup : Accordion removeListener(ControlListener)
-controlP5.ControllerGroup : Accordion removeProperty(String)
-controlP5.ControllerGroup : Accordion removeProperty(String, String)
-controlP5.ControllerGroup : Accordion setAddress(String)
-controlP5.ControllerGroup : Accordion setArrayValue(float[])
-controlP5.ControllerGroup : Accordion setArrayValue(int, float)
-controlP5.ControllerGroup : Accordion setCaptionLabel(String)
-controlP5.ControllerGroup : Accordion setColor(CColor)
-controlP5.ControllerGroup : Accordion setColorActive(int)
-controlP5.ControllerGroup : Accordion setColorBackground(int)
-controlP5.ControllerGroup : Accordion setColorForeground(int)
-controlP5.ControllerGroup : Accordion setColorLabel(int)
-controlP5.ControllerGroup : Accordion setColorValue(int)
-controlP5.ControllerGroup : Accordion setHeight(int)
-controlP5.ControllerGroup : Accordion setId(int)
-controlP5.ControllerGroup : Accordion setLabel(String)
-controlP5.ControllerGroup : Accordion setMouseOver(boolean)
-controlP5.ControllerGroup : Accordion setMoveable(boolean)
-controlP5.ControllerGroup : Accordion setOpen(boolean)
-controlP5.ControllerGroup : Accordion setPosition(float, float)
-controlP5.ControllerGroup : Accordion setPosition(float[])
-controlP5.ControllerGroup : Accordion setSize(int, int)
-controlP5.ControllerGroup : Accordion setStringValue(String)
-controlP5.ControllerGroup : Accordion setTitle(String)
-controlP5.ControllerGroup : Accordion setUpdate(boolean)
-controlP5.ControllerGroup : Accordion setValue(float)
-controlP5.ControllerGroup : Accordion setVisible(boolean)
-controlP5.ControllerGroup : Accordion setWidth(int)
-controlP5.ControllerGroup : Accordion show()
-controlP5.ControllerGroup : Accordion showArrow()
-controlP5.ControllerGroup : Accordion showBar()
-controlP5.ControllerGroup : Accordion update()
-controlP5.ControllerGroup : Accordion updateAbsolutePosition()
-controlP5.ControllerGroup : CColor getColor()
-controlP5.ControllerGroup : Canvas addCanvas(Canvas)
-controlP5.ControllerGroup : ControlWindow getWindow()
-controlP5.ControllerGroup : Controller getController(String)
-controlP5.ControllerGroup : ControllerProperty getProperty(String)
-controlP5.ControllerGroup : ControllerProperty getProperty(String, String)
-controlP5.ControllerGroup : Label getCaptionLabel()
-controlP5.ControllerGroup : Label getValueLabel()
-controlP5.ControllerGroup : String getAddress()
-controlP5.ControllerGroup : String getInfo()
-controlP5.ControllerGroup : String getName()
-controlP5.ControllerGroup : String getStringValue()
-controlP5.ControllerGroup : String toString()
-controlP5.ControllerGroup : Tab getTab()
-controlP5.ControllerGroup : boolean isBarVisible()
-controlP5.ControllerGroup : boolean isCollapse()
-controlP5.ControllerGroup : boolean isMouseOver()
-controlP5.ControllerGroup : boolean isMoveable()
-controlP5.ControllerGroup : boolean isOpen()
-controlP5.ControllerGroup : boolean isUpdate()
-controlP5.ControllerGroup : boolean isVisible()
-controlP5.ControllerGroup : boolean setMousePressed(boolean)
-controlP5.ControllerGroup : float getArrayValue(int)
-controlP5.ControllerGroup : float getValue()
-controlP5.ControllerGroup : float[] getArrayValue()
-controlP5.ControllerGroup : float[] getPosition()
-controlP5.ControllerGroup : int getHeight()
-controlP5.ControllerGroup : int getId()
-controlP5.ControllerGroup : int getWidth()
-controlP5.ControllerGroup : int listenerSize()
-controlP5.ControllerGroup : void controlEvent(ControlEvent)
-controlP5.ControllerGroup : void remove()
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-created: 2015/03/24 12:25:32
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/controllers/ControlP5background/ControlP5background.pde b/Processing/libraries/controlP5/examples/controllers/ControlP5background/ControlP5background.pde
deleted file mode 100644
index 11a974c..0000000
--- a/Processing/libraries/controlP5/examples/controllers/ControlP5background/ControlP5background.pde
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
-* ControlP5 Background
-*
-*
-* find a list of public methods available for the Group Controller
-* at the bottom of this sketch.
-*
-* by Andreas Schlegel, 2014
-* www.sojamo.de/libraries/controlp5
-*
-*/
-
-import controlP5.*;
-
-ControlP5 cp5;
-int v1;
-boolean lines = true;
-
-void setup() {
- size(800, 400);
- noStroke();
- cp5 = new ControlP5(this);
-
- cp5.begin(cp5.addBackground("abc"));
-
- cp5.addSlider("v1")
- .setPosition(10, 20)
- .setSize(200, 20)
- .setRange(100, 300)
- .setValue(250)
- ;
-
- cp5.addToggle("lines")
- .setPosition(10,50)
- .setSize(80,20)
- .setMode(Toggle.SWITCH)
- ;
-
- cp5.end();
-
-}
-
-void draw() {
- background(200, 200, 200);
-
- pushMatrix();
-
- pushMatrix();
- fill(255, 255, 0);
- rect(v1, 100, 60, 200);
- fill(0, 255, 110);
- rect(40, v1, 320, 40);
- translate(200, 200);
- rotate(map(v1, 100, 300, -PI, PI));
- fill(255, 0, 128);
- rect(0, 0, 100, 100);
- popMatrix();
-
- if(lines) {
- translate(600, 100);
- for (int i=0; i<20; i++) {
- pushMatrix();
- fill(255);
- translate(0, i*10);
- rotate(map(v1+i, 0, 300, -PI, PI));
- rect(-150, 0, 300, 4);
- popMatrix();
- }
- }
-
- popMatrix();
-}
-
-/*
-a list of all methods available for the Background Controller
-use ControlP5.printPublicMethodsFor(Background.class);
-to print the following list into the console.
-
-You can find further details about class Background in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.ControlGroup : Background activateEvent(boolean)
-controlP5.ControlGroup : Background addListener(ControlListener)
-controlP5.ControlGroup : Background removeListener(ControlListener)
-controlP5.ControlGroup : Background setBackgroundColor(int)
-controlP5.ControlGroup : Background setBackgroundHeight(int)
-controlP5.ControlGroup : Background setBarHeight(int)
-controlP5.ControlGroup : Background setSize(int, int)
-controlP5.ControlGroup : Background updateInternalEvents(PApplet)
-controlP5.ControlGroup : String getInfo()
-controlP5.ControlGroup : String toString()
-controlP5.ControlGroup : int getBackgroundHeight()
-controlP5.ControlGroup : int getBarHeight()
-controlP5.ControlGroup : int listenerSize()
-controlP5.ControllerGroup : Background add(ControllerInterface)
-controlP5.ControllerGroup : Background addListener(ControlListener)
-controlP5.ControllerGroup : Background bringToFront()
-controlP5.ControllerGroup : Background bringToFront(ControllerInterface)
-controlP5.ControllerGroup : Background close()
-controlP5.ControllerGroup : Background disableCollapse()
-controlP5.ControllerGroup : Background enableCollapse()
-controlP5.ControllerGroup : Background hide()
-controlP5.ControllerGroup : Background hideArrow()
-controlP5.ControllerGroup : Background hideBar()
-controlP5.ControllerGroup : Background moveTo(ControlWindow)
-controlP5.ControllerGroup : Background moveTo(PApplet)
-controlP5.ControllerGroup : Background open()
-controlP5.ControllerGroup : Background registerProperty(String)
-controlP5.ControllerGroup : Background registerProperty(String, String)
-controlP5.ControllerGroup : Background remove(CDrawable)
-controlP5.ControllerGroup : Background remove(ControllerInterface)
-controlP5.ControllerGroup : Background removeCanvas(Canvas)
-controlP5.ControllerGroup : Background removeListener(ControlListener)
-controlP5.ControllerGroup : Background removeProperty(String)
-controlP5.ControllerGroup : Background removeProperty(String, String)
-controlP5.ControllerGroup : Background setAddress(String)
-controlP5.ControllerGroup : Background setArrayValue(float[])
-controlP5.ControllerGroup : Background setArrayValue(int, float)
-controlP5.ControllerGroup : Background setCaptionLabel(String)
-controlP5.ControllerGroup : Background setColor(CColor)
-controlP5.ControllerGroup : Background setColorActive(int)
-controlP5.ControllerGroup : Background setColorBackground(int)
-controlP5.ControllerGroup : Background setColorForeground(int)
-controlP5.ControllerGroup : Background setColorLabel(int)
-controlP5.ControllerGroup : Background setColorValue(int)
-controlP5.ControllerGroup : Background setHeight(int)
-controlP5.ControllerGroup : Background setId(int)
-controlP5.ControllerGroup : Background setLabel(String)
-controlP5.ControllerGroup : Background setMouseOver(boolean)
-controlP5.ControllerGroup : Background setMoveable(boolean)
-controlP5.ControllerGroup : Background setOpen(boolean)
-controlP5.ControllerGroup : Background setPosition(float, float)
-controlP5.ControllerGroup : Background setPosition(float[])
-controlP5.ControllerGroup : Background setSize(int, int)
-controlP5.ControllerGroup : Background setStringValue(String)
-controlP5.ControllerGroup : Background setTitle(String)
-controlP5.ControllerGroup : Background setUpdate(boolean)
-controlP5.ControllerGroup : Background setValue(float)
-controlP5.ControllerGroup : Background setVisible(boolean)
-controlP5.ControllerGroup : Background setWidth(int)
-controlP5.ControllerGroup : Background show()
-controlP5.ControllerGroup : Background showArrow()
-controlP5.ControllerGroup : Background showBar()
-controlP5.ControllerGroup : Background update()
-controlP5.ControllerGroup : Background updateAbsolutePosition()
-controlP5.ControllerGroup : CColor getColor()
-controlP5.ControllerGroup : Canvas addCanvas(Canvas)
-controlP5.ControllerGroup : ControlWindow getWindow()
-controlP5.ControllerGroup : Controller getController(String)
-controlP5.ControllerGroup : ControllerProperty getProperty(String)
-controlP5.ControllerGroup : ControllerProperty getProperty(String, String)
-controlP5.ControllerGroup : Label getCaptionLabel()
-controlP5.ControllerGroup : Label getValueLabel()
-controlP5.ControllerGroup : String getAddress()
-controlP5.ControllerGroup : String getInfo()
-controlP5.ControllerGroup : String getName()
-controlP5.ControllerGroup : String getStringValue()
-controlP5.ControllerGroup : String toString()
-controlP5.ControllerGroup : Tab getTab()
-controlP5.ControllerGroup : boolean isBarVisible()
-controlP5.ControllerGroup : boolean isCollapse()
-controlP5.ControllerGroup : boolean isMouseOver()
-controlP5.ControllerGroup : boolean isMoveable()
-controlP5.ControllerGroup : boolean isOpen()
-controlP5.ControllerGroup : boolean isUpdate()
-controlP5.ControllerGroup : boolean isVisible()
-controlP5.ControllerGroup : boolean setMousePressed(boolean)
-controlP5.ControllerGroup : float getArrayValue(int)
-controlP5.ControllerGroup : float getValue()
-controlP5.ControllerGroup : float[] getArrayValue()
-controlP5.ControllerGroup : float[] getPosition()
-controlP5.ControllerGroup : int getHeight()
-controlP5.ControllerGroup : int getId()
-controlP5.ControllerGroup : int getWidth()
-controlP5.ControllerGroup : int listenerSize()
-controlP5.ControllerGroup : void controlEvent(ControlEvent)
-controlP5.ControllerGroup : void remove()
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-created: 2015/03/24 12:25:35
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/controllers/ControlP5background/sketch.properties b/Processing/libraries/controlP5/examples/controllers/ControlP5background/sketch.properties
deleted file mode 100644
index 8630fa2..0000000
--- a/Processing/libraries/controlP5/examples/controllers/ControlP5background/sketch.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-mode.id=processing.mode.java.JavaMode
-mode=Java
diff --git a/Processing/libraries/controlP5/examples/controllers/ControlP5bang/ControlP5bang.pde b/Processing/libraries/controlP5/examples/controllers/ControlP5bang/ControlP5bang.pde
deleted file mode 100644
index c84e786..0000000
--- a/Processing/libraries/controlP5/examples/controllers/ControlP5bang/ControlP5bang.pde
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * ControlP5 Bang
- * A bang triggers an event that can be received by a function named after the bang.
- * By default a bang is triggered when pressed, this can be changed to 'release'
- * using theBang.setTriggerEvent(Bang.RELEASE).
- *
- * find a list of public methods available for the Bang Controller
- * at the bottom of this sketch.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-int myColorBackground = color(0, 0, 0);
-
-color[] col = new color[] {
- color(100), color(150), color(200), color(250)
-};
-
-
-void setup() {
- size(400, 600);
- noStroke();
- cp5 = new ControlP5(this);
- for (int i=0;i presets = new ArrayList();
- int currentPreset = 0;
- Thread update;
-
- CustomMatrix(ControlP5 cp5, String theName) {
- super(cp5, theName);
- stop(); // stop the default sequencer and
- // create our custom sequencer thread. Here we
- // check if the sequencer has reached the end and if so
- // we updated to the next preset.
- update = new Thread(theName) {
- public void run( ) {
- while ( true ) {
- cnt++;
- cnt %= _myCellX;
- if (cnt==0) {
- // we reached the end and go back to start and
- // update the preset
- next();
- }
- trigger(cnt);
- try {
- sleep( _myInterval );
- }
- catch ( InterruptedException e ) {
- }
- }
- }
- };
- update.start();
- }
-
-
- void next() {
- currentPreset++;
- currentPreset %= presets.size();
- setCells(presets.get(currentPreset));
- }
-
- // initialize some random presets.
- void initPresets() {
- for (int i=0;i<4;i++) {
- presets.add(createPreset(_myCellX, _myCellY));
- }
- setCells(presets.get(0));
- }
-
- // create a random preset
- int[][] createPreset(int theX, int theY) {
- int[][] preset = new int[theX][theY];
- for (int x=0;x0.5 ? 1:0;
- }
- }
- return preset;
- }
-
-}
-
diff --git a/Processing/libraries/controlP5/examples/experimental/ControlP5MenuList/ControlP5MenuList.pde b/Processing/libraries/controlP5/examples/experimental/ControlP5MenuList/ControlP5MenuList.pde
deleted file mode 100644
index 651c1e2..0000000
--- a/Processing/libraries/controlP5/examples/experimental/ControlP5MenuList/ControlP5MenuList.pde
+++ /dev/null
@@ -1,187 +0,0 @@
-
-/**
- * ControlP5 MenuList
- *
- * A custom Controller, a scrollable Menu List, using a PGraphics buffer.
- * Allows custom designs for List Item.
- *
- * by Andreas Schlegel, 2013
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-import static controlP5.ControlP5.*;
-import java.util.*;
-import java.util.Map.Entry;
-
-
-ControlP5 cp5;
-
-PFont f1, f2;
-void setup() {
- size(800, 500, P3D );
- f1 = createFont("Helvetica", 20);
- f2 = createFont("Helvetica", 12);
-
- cp5 = new ControlP5( this );
-
-
- /* create a custom MenuList with name menu, notice that function
- * menu will be called when a menu item has been clicked.
- */
- MenuList m = new MenuList( cp5, "menu", 200, 368 );
-
- m.setPosition(40, 40);
- // add some items to our menuList
- for (int i=0;i<100;i++) {
- m.addItem(makeItem("headline-"+i, "subline", "some copy lorem ipsum ", createImage(50, 50, RGB)));
- }
-}
-
-/* a convenience function to build a map that contains our key-value pairs which we will
- * then use to render each item of the menuList.
- */
-Map makeItem(String theHeadline, String theSubline, String theCopy, PImage theImage) {
- Map m = new HashMap();
- m.put("headline", theHeadline);
- m.put("subline", theSubline);
- m.put("copy", theCopy);
- m.put("image", theImage);
- return m;
-}
-
-void menu(int i) {
- println("got some menu event from item with index "+i);
-}
-
-public void controlEvent(ControlEvent theEvent) {
- if(theEvent.isFrom("menu")){
- Map m = ((MenuList)theEvent.getController()).getItem(int(theEvent.getValue()));
- println("got a menu event from item : "+m);
- }
-}
-
-void draw() {
- background( 40 );
-}
-
-
-/* A custom Controller that implements a scrollable menuList. Here the controller
- * uses a PGraphics element to render customizable list items. The menuList can be scrolled
- * using the scroll-wheel, touchpad, or mouse-drag. Items are triggered by a click. clicking
- * the scrollbar to the right makes the list scroll to the item correspoinding to the
- * click-location.
- */
-class MenuList extends Controller {
-
- float pos, npos;
- int itemHeight = 100;
- int scrollerLength = 40;
- List< Map> items = new ArrayList< Map>();
- PGraphics menu;
- boolean updateMenu;
-
- MenuList(ControlP5 c, String theName, int theWidth, int theHeight) {
- super( c, theName, 0, 0, theWidth, theHeight );
- c.register( this );
- menu = createGraphics(getWidth(), getHeight() );
-
- setView(new ControllerView() {
-
- public void display(PGraphics pg, MenuList t ) {
- if (updateMenu) {
- updateMenu();
- }
- if (inside() ) {
- menu.beginDraw();
- int len = -(itemHeight * items.size()) + getHeight();
- int ty = int(map(pos, len, 0, getHeight() - scrollerLength - 2, 2 ) );
- menu.fill(255 );
- menu.rect(getWidth()-4, ty, 4, scrollerLength );
- menu.endDraw();
- }
- pg.image(menu, 0, 0);
- }
- }
- );
- updateMenu();
- }
-
- /* only update the image buffer when necessary - to save some resources */
- void updateMenu() {
- int len = -(itemHeight * items.size()) + getHeight();
- npos = constrain(npos, len, 0);
- pos += (npos - pos) * 0.1;
- menu.beginDraw();
- menu.noStroke();
- menu.background(255, 64 );
- menu.textFont(cp5.getFont().getFont());
- menu.pushMatrix();
- menu.translate( 0, pos );
- menu.pushMatrix();
-
- int i0 = PApplet.max( 0, int(map(-pos, 0, itemHeight * items.size(), 0, items.size())));
- int range = ceil((float(getHeight())/float(itemHeight))+1);
- int i1 = PApplet.min( items.size(), i0 + range );
-
- menu.translate(0, i0*itemHeight);
-
- for (int i=i0;i0.01 ? true:false;
- }
-
- /* when detecting a click, check if the click happend to the far right, if yes, scroll to that position,
- * otherwise do whatever this item of the list is supposed to do.
- */
- public void onClick() {
- if (getPointer().x()>getWidth()-10) {
- npos= -map(getPointer().y(), 0, getHeight(), 0, items.size()*itemHeight);
- updateMenu = true;
- }
- else {
- int len = itemHeight * items.size();
- int index = int( map( getPointer().y() - pos, 0, len, 0, items.size() ) ) ;
- setValue(index);
- }
- }
-
- public void onMove() {
- }
-
- public void onDrag() {
- npos += getPointer().dy() * 2;
- updateMenu = true;
- }
-
- public void onScroll(int n) {
- npos += ( n * 4 );
- updateMenu = true;
- }
-
- void addItem(Map m) {
- items.add(m);
- updateMenu = true;
- }
-
- Map getItem(int theIndex) {
- return items.get(theIndex);
- }
-}
-
diff --git a/Processing/libraries/controlP5/examples/experimental/ControlP5SliderList/ControlP5SliderList.pde b/Processing/libraries/controlP5/examples/experimental/ControlP5SliderList/ControlP5SliderList.pde
deleted file mode 100644
index 88b7536..0000000
--- a/Processing/libraries/controlP5/examples/experimental/ControlP5SliderList/ControlP5SliderList.pde
+++ /dev/null
@@ -1,257 +0,0 @@
-
-/**
- * ControlP5 SilderList
- *
- * A custom Controller, a scrollable Menu List, using a PGraphics buffer.
- * Allows custom designs for List Item.
- *
- * you will need a controlP5 version >= 2.1.5
- * you can download a copy from
- * http://sojamo.de/files/archive/controlP5-2.1.5.zip
- *
- * by Andreas Schlegel, 2013
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-import java.util.*;
-
-
-ControlP5 cp5;
-
-PFont f1;
-int NUM = 100;
-float[] rotation = new float[NUM];
-
-
-void setup() {
- size(800, 400 ,P3D);
- f1 = createFont("Helvetica", 12);
-
- cp5 = new ControlP5( this );
-
-
- // create a custom SilderList with name menu, notice that function
- // menu will be called when a menu item has been clicked.
-
- SilderList m = new SilderList( cp5, "menu", 250, 350 );
-
- m.setPosition(40, 20);
- // add some items to our SilderList
- for (int i=0;i makeItem(String theLabel, float theValue, float theMin, float theMax) {
- Map m = new HashMap();
- m.put("label", theLabel);
- m.put("sliderValue", theValue);
- m.put("sliderValueMin", theMin);
- m.put("sliderValueMax", theMax);
- return m;
-}
-
-void menu(int i) {
- println("got some slider-list event from item with index "+i);
-}
-
-public void controlEvent(ControlEvent theEvent) {
- if (theEvent.isFrom("menu")) {
- int index = int(theEvent.getValue());
- Map m = ((SilderList)theEvent.getController()).getItem(index);
- println("got a slider event from item : "+m);
- rotation[index] = f(m.get("sliderValue"));
- }
-}
-
-void draw() {
- background( 220 );
- fill(0, 128, 255);
- noStroke();
- pushMatrix();
- translate(width/2, 30 );
- for (int i=0;i {
-
- float pos, npos;
- int itemHeight = 60;
- int scrollerLength = 40;
- int sliderWidth = 150;
- int sliderHeight = 15;
- int sliderX = 10;
- int sliderY = 25;
-
- int dragMode = 0;
- int dragIndex = -1;
-
- List< Map> items = new ArrayList< Map>();
- PGraphics menu;
- boolean updateMenu;
-
- SilderList(ControlP5 c, String theName, int theWidth, int theHeight) {
- super( c, theName, 0, 0, theWidth, theHeight );
- c.register( this );
- menu = createGraphics(getWidth(), getHeight());
-
- setView(new ControllerView() {
-
- public void display(PGraphics pg, SilderList t ) {
- if (updateMenu) {
- updateMenu();
- }
- if (inside() ) { // draw scrollbar
- menu.beginDraw();
- int len = -(itemHeight * items.size()) + getHeight();
- int ty = int(map(pos, len, 0, getHeight() - scrollerLength - 2, 2 ) );
- menu.fill( 128 );
- menu.rect(getWidth()-6, ty, 4, scrollerLength );
- menu.endDraw();
- }
- pg.image(menu, 0, 0);
- }
- }
- );
- updateMenu();
- }
-
- // only update the image buffer when necessary - to save some resources
- void updateMenu() {
- int len = -(itemHeight * items.size()) + getHeight();
- npos = constrain(npos, len, 0);
- pos += (npos - pos) * 0.1;
-
- /// draw the SliderList
- menu.beginDraw();
- menu.noStroke();
- menu.background(240);
- menu.textFont(cp5.getFont().getFont());
- menu.pushMatrix();
- menu.translate( 0, int(pos) );
- menu.pushMatrix();
-
- int i0 = PApplet.max( 0, int(map(-pos, 0, itemHeight * items.size(), 0, items.size())));
- int range = ceil((float(getHeight())/float(itemHeight))+1);
- int i1 = PApplet.min( items.size(), i0 + range );
-
- menu.translate(0, i0*itemHeight);
-
- for (int i=i0;i0.01 ? true:false;
- }
-
- // when detecting a click, check if the click happend to the far right,
- // if yes, scroll to that position, otherwise do whatever this item of
- // the list is supposed to do.
- public void onClick() {
- if (getPointer().x()>getWidth()-10) {
- npos= -map(getPointer().y(), 0, getHeight(), 0, items.size()*itemHeight);
- updateMenu = true;
- }
- }
-
-
- public void onPress() {
- int x = getPointer().x();
- int y = (int)(getPointer().y()-pos)%itemHeight;
- boolean withinSlider = within(x, y, sliderX, sliderY, sliderWidth, sliderHeight);
- dragMode = withinSlider ? 2:1;
- if (dragMode==2) {
- dragIndex = getIndex();
- float min = f(items.get(dragIndex).get("sliderValueMin"));
- float max = f(items.get(dragIndex).get("sliderValueMax"));
- float val = constrain(map(getPointer().x()-sliderX, 0, sliderWidth, min, max), min, max);
- items.get(dragIndex).put("sliderValue", val);
- setValue(dragIndex);
- }
- updateMenu = true;
- }
-
- public void onDrag() {
- switch(dragMode) {
- case(1): // drag and scroll the list
- npos += getPointer().dy() * 2;
- updateMenu = true;
- break;
- case(2): // drag slider
- float min = f(items.get(dragIndex).get("sliderValueMin"));
- float max = f(items.get(dragIndex).get("sliderValueMax"));
- float val = constrain(map(getPointer().x()-sliderX, 0, sliderWidth, min, max), min, max);
- items.get(dragIndex).put("sliderValue", val);
- setValue(dragIndex);
- updateMenu = true;
- break;
- }
- }
-
- public void onScroll(int n) {
- npos += ( n * 4 );
- updateMenu = true;
- }
-
- void addItem(Map m) {
- items.add(m);
- updateMenu = true;
- }
-
- Map getItem(int theIndex) {
- return items.get(theIndex);
- }
-
- private int getIndex() {
- int len = itemHeight * items.size();
- int index = int( map( getPointer().y() - pos, 0, len, 0, items.size() ) ) ;
- return index;
- }
-}
-
-public static float f( Object o ) {
- return ( o instanceof Number ) ? ( ( Number ) o ).floatValue( ) : Float.MIN_VALUE;
-}
-
-public static boolean within(int theX, int theY, int theX1, int theY1, int theW1, int theH1) {
- return (theX>theX1 && theXtheY1 && theY midimapper = new HashMap();
-
-void setup() {
-
- size( 600, 400 );
-
- cp5 = new ControlP5( this );
-
- cp5.begin(cp5.addTab("a"));
- cp5.addSlider("a-1").setPosition(20, 120).setSize(200, 20);
- cp5.addSlider("a-2").setPosition(20, 160).setSize(200, 20);
- cp5.addSlider("a-3").setPosition(20, 200).setSize(200, 20);
- cp5.addToggle("a-4").setPosition(280, 120).setSize(100, 20);
- cp5.addButton("a-5").setPosition(280, 160).setSize(100, 20);
- cp5.addBang("a-6").setPosition(280, 200).setSize(100, 20);
- cp5.end();
-
- cp5.begin(cp5.addTab("b"));
- cp5.addSlider("b-1").setPosition(20, 120).setSize(200, 20);
- cp5.addSlider("b-2").setPosition(20, 160).setSize(200, 20);
- cp5.addSlider("b-3").setPosition(20, 200).setSize(200, 20);
- cp5.end();
-
- final String device = "SLIDER/KNOB";
-
- //midimapper.clear();
-
- midimapper.put( ref( device, 0 ), "a-1" );
- midimapper.put( ref( device, 1 ), "a-2" );
- midimapper.put( ref( device, 2 ), "a-3" );
- midimapper.put( ref( device, 32 ), "a-4" );
- midimapper.put( ref( device, 48 ), "a-5" );
- midimapper.put( ref( device, 64 ), "a-6" );
-
- midimapper.put( ref( device, 16 ), "b-1" );
- midimapper.put( ref( device, 17 ), "b-2" );
- midimapper.put( ref( device, 18 ), "b-3" );
-
- boolean DEBUG = false;
-
- if (DEBUG) {
- new MidiSimple( device );
- }
- else {
- new MidiSimple( device , new Receiver() {
-
- @Override public void send( MidiMessage msg, long timeStamp ) {
-
- byte[] b = msg.getMessage();
-
- if ( b[ 0 ] != -48 ) {
-
- Object index = ( midimapper.get( ref( device , b[ 1 ] ) ) );
-
- if ( index != null ) {
-
- Controller c = cp5.getController(index.toString());
- if (c instanceof Slider ) {
- float min = c.getMin();
- float max = c.getMax();
- c.setValue(map(b[ 2 ], 0, 127, min, max) );
- } else if ( c instanceof Button ) {
- if ( b[ 2 ] > 0 ) {
- c.setValue( c.getValue( ) );
- c.setColorBackground( 0xff08a2cf );
- } else {
- c.setColorBackground( 0xff003652 );
- }
- } else if ( c instanceof Bang ) {
- if ( b[ 2 ] > 0 ) {
- c.setValue( c.getValue( ) );
- c.setColorForeground( 0xff08a2cf );
- } else {
- c.setColorForeground( 0xff00698c );
- }
- } else if ( c instanceof Toggle ) {
- if ( b[ 2 ] > 0 ) {
- ( ( Toggle ) c ).toggle( );
- }
- }
- }
- }
- }
-
- @Override public void close( ) {
- }
- }
- );
- }
-}
-
-
-String ref(String theDevice, int theIndex) {
- return theDevice+"-"+theIndex;
-}
-
-
-void draw() {
- background( 0 );
-}
-
-
diff --git a/Processing/libraries/controlP5/examples/experimental/MidiMapper/MidiSimple.java b/Processing/libraries/controlP5/examples/experimental/MidiMapper/MidiSimple.java
deleted file mode 100644
index f23252f..0000000
--- a/Processing/libraries/controlP5/examples/experimental/MidiMapper/MidiSimple.java
+++ /dev/null
@@ -1,107 +0,0 @@
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.sound.midi.MidiDevice;
-import javax.sound.midi.MidiMessage;
-import javax.sound.midi.MidiSystem;
-import javax.sound.midi.MidiUnavailableException;
-import javax.sound.midi.Receiver;
-import javax.sound.midi.Transmitter;
-
-public class MidiSimple {
-
- public MidiSimple( String theDeviceName , Receiver theReceiver ) {
-
- MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
- for ( int i = 0; i < aInfos.length; i++ ) {
- try {
- MidiDevice device = MidiSystem.getMidiDevice( aInfos[ i ] );
- boolean bAllowsInput = ( device.getMaxTransmitters() != 0 );
- boolean bAllowsOutput = ( device.getMaxReceivers() != 0 );
- System.out.println( "" + i + " " + ( bAllowsInput ? "IN " : " " ) + ( bAllowsOutput ? "OUT " : " " ) + aInfos[ i ].getName() + ", " + aInfos[ i ].getVendor() + ", "
- + aInfos[ i ].getVersion() + ", " + aInfos[ i ].getDescription() );
- }
- catch ( MidiUnavailableException e ) {
- // device is obviously not available...
- // out(e);
- }
- }
-
- try {
- MidiDevice device;
- device = MidiSystem.getMidiDevice( getMidiDeviceInfo( theDeviceName, false ) );
- device.open();
- Transmitter conTrans = device.getTransmitter();
- conTrans.setReceiver( theReceiver );
- }
- catch ( MidiUnavailableException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NullPointerException e) {
- System.out.println("No Midi device ( "+theDeviceName+" ) is available.");
- }
-
- }
-
- public MidiSimple( String theDeviceName ) {
- new MidiSimple(theDeviceName , new MidiInputReceiver( theDeviceName ) );
- }
-
-
- public MidiDevice.Info getMidiDeviceInfo( String strDeviceName, boolean bForOutput ) {
- MidiDevice.Info[] aInfos = MidiSystem.getMidiDeviceInfo();
- for ( int i = 0; i < aInfos.length; i++ ) {
- if ( aInfos[ i ].getName().equals( strDeviceName ) ) {
- try {
- MidiDevice device = MidiSystem.getMidiDevice( aInfos[ i ] );
- boolean bAllowsInput = ( device.getMaxTransmitters() != 0 );
- boolean bAllowsOutput = ( device.getMaxReceivers() != 0 );
- if ( ( bAllowsOutput && bForOutput ) || ( bAllowsInput && !bForOutput ) ) {
- return aInfos[ i ];
- }
- }
- catch ( MidiUnavailableException e ) {
- // TODO:
- }
- }
- }
- return null;
- }
-
- class MidiInputReceiver implements Receiver {
- public String name;
- Map< Byte, String > commandMap = new HashMap< Byte, String >();
-
- public MidiInputReceiver( String name ) {
- this.name = name;
- commandMap.put( ( byte ) -112, "Note On" );
- commandMap.put( ( byte ) -128, "Note Off" );
- commandMap.put( ( byte ) -48, "Channel Pressure" );
- commandMap.put( ( byte ) -80, "Continuous Controller" );
- }
-
- public void send( MidiMessage msg, long timeStamp ) {
- System.out.println( "midi received (" + name + ")" );
- System.out.println( "Timestamp: " + timeStamp );
- byte[] b = msg.getMessage();
-
- if ( b[ 0 ] != -48 ) {
- // System.out.println("Message length: " + msg.getLength());
- System.out.println( "Note command: " + commandMap.get( b[ 0 ] ) );
- System.out.println( "Which note: " + b[ 1 ] );
- System.out.println( "Note pressure: " + b[ 2 ] );
- System.out.println( "---------------------" );
- }
- else {
- // System.out.println("Message length: " + msg.getLength());
- System.out.println( "Note command: " + commandMap.get( b[ 0 ] ) );
- System.out.println( "Note Pressure: " + b[ 1 ] );
- System.out.println( "---------------------" );
- }
- }
-
- public void close( ) {
- }
- }
-}
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5AutoDetectFields/ControlP5AutoDetectFields.pde b/Processing/libraries/controlP5/examples/extra/ControlP5AutoDetectFields/ControlP5AutoDetectFields.pde
deleted file mode 100644
index bd405bb..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5AutoDetectFields/ControlP5AutoDetectFields.pde
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * ControlP5 Autodetect Fields
- *
- * test sketch, controller values will automatically be set
- * to its corresponding sketch fields.
- *
- * by Andreas Schlegel, 2011
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-
-import controlP5.*;
-
-int s1 = 50;
-int s2 = 50;
-
-int nb1 = 50;
-int nb2 = 50;
-
-int k1 = 50;
-int k2 = 50;
-
-boolean t1 = false;
-boolean t2 = false;
-
-int r1 = 20;
-int r2 = 50;
-
-void setup() {
- size(400,400);
- ControlP5 cp5 = new ControlP5(this);
- cp5.addSlider("s1",10,150,10,10,100,15).setLabel("50");
- cp5.addSlider("s2",10,150,20,150,10,100,15).setLabel("20");
-
- cp5.addNumberbox("nb1",10,50,100,15).setLabel("50");
- cp5.addNumberbox("nb2",20,150,50,100,15).setLabel("20");
-
- cp5.addKnob("k1",10,150,10,150,50).setLabel("50");
- cp5.addKnob("k2",10,150,20,150,150,50).setLabel("20");
-
- cp5.addToggle("t1",10,240,100,15).setLabel("false");
- cp5.addToggle("t2",true,150,240,100,15).setLabel("true");
-
- cp5.addButton("b1",50,10,280,100,15).setLabel("50");
- cp5.addButton("b2",20,150,280,100,15).setLabel("20");
-
- cp5.addRange("r1",10,150,r1,r2,10,320,100,15).setLabel("50");
-
-}
-
-void draw() {
- background(0);
-}
-
-void controlEvent(ControlEvent c) {
- println(c.getValue());
-}
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5ControllerInsideClass/ControlP5ControllerInsideClass.pde b/Processing/libraries/controlP5/examples/extra/ControlP5ControllerInsideClass/ControlP5ControllerInsideClass.pde
deleted file mode 100644
index 8590f82..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5ControllerInsideClass/ControlP5ControllerInsideClass.pde
+++ /dev/null
@@ -1,33 +0,0 @@
-import controlP5.*;
-
-ControlP5 cp5;
-Test t;
-void setup() {
- size(400,400);
- cp5 = new ControlP5( this );
- t = new Test( "test" );
-}
-
-void draw() {
- background(20);
- println( t.value );
-}
-
-class Test {
-
- int value;
-
- Test( String thePrefix ) {
- cp5.addSlider( "value-"+thePrefix )
- .setRange( 0, 255 )
- .plugTo( this, "setValue" )
- .setValue( 127 )
- .setLabel("value")
- ;
- }
-
- void setValue(int theValue) {
- value = theValue;
- }
-}
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5canvasDrawIntoCanvas/ControlP5canvasDrawIntoCanvas.pde b/Processing/libraries/controlP5/examples/extra/ControlP5canvasDrawIntoCanvas/ControlP5canvasDrawIntoCanvas.pde
deleted file mode 100644
index 5b9f962..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5canvasDrawIntoCanvas/ControlP5canvasDrawIntoCanvas.pde
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * ControlP5 DrawIntoCanvas
- *
- * this example demonstrates how to draw into a Canvas.
- * Click and drag the mouse to show and draw into the Canvas.
- *
- * by Andreas Schlegel, 2011
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-Canvas cc;
-
-// your controlWindowCanvas class
-class MyCanvas extends Canvas {
-
- boolean mousePressed;
- int mouseX, mouseY;
- public void update(PApplet theApplet) {
- mousePressed = theApplet.mousePressed;
- mouseX = theApplet.mouseX;
- mouseY = theApplet.mouseY;
- }
-
- public void draw(PGraphics theApplet) {
- theApplet.background(255);
- // a rectangle will be drawn if the mouse has been
- // pressed inside the main sketch window.
- // mousePressed here refers to the mousePressed
- // variable of your main sketch
- if(mousePressed) {
- theApplet.fill(255,0,0);
- theApplet.rect(10,10,100,100);
- theApplet.fill(0);
- theApplet.ellipse(mouseX,mouseY,20,20);
- }
- // will draw a rectangle into the controlWindow
- // if the mouse has been pressed inside the controlWindow itself.
- // theApplet.mousePressed here refers to the
- // mousePressed variable of the controlWindow.
- if(mousePressed) {
- theApplet.fill(0);
- theApplet.rect(10,10,100,100);
- theApplet.fill(255,0,0);
- theApplet.ellipse(mouseX,mouseY,20,20);
- }
-
- }
-
-}
-
-
-void setup() {
- size(400,400);
- frameRate(30);
- cp5 = new ControlP5(this);
-
- cc = new MyCanvas();
- cc.pre();
- cp5.addCanvas(cc);
-
-}
-
-void draw(){
- background(0);
-}
-
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5chartsCombined/ControlP5chartsCombined.pde b/Processing/libraries/controlP5/examples/extra/ControlP5chartsCombined/ControlP5chartsCombined.pde
deleted file mode 100644
index d8a0e79..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5chartsCombined/ControlP5chartsCombined.pde
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
-* ControlP5 ControlP5chartsCombined
-*
-* find a list of public methods available for the Chart Controller
-* at the bottom of this sketch.
-*
-* by Andreas Schlegel, 2012
-* www.sojamo.de/libraries/controlp5
-*
-*/
-
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-Chart myChart;
-
-void setup() {
- size(400, 700);
- smooth();
- cp5 = new ControlP5(this);
- cp5.printPublicMethodsFor(Chart.class);
- myChart = cp5.addChart("hello")
- .setPosition(50, 50)
- .setSize(200, 200)
- .setRange(-20, 20)
- .setView(Chart.BAR) // use Chart.LINE, Chart.PIE, Chart.AREA, Chart.BAR_CENTERED
- ;
-
- myChart.getColor().setBackground(color(255, 100));
-
-
- myChart.addDataSet("world");
- myChart.setColors("world", color(255,0,255),color(255,0,0));
- myChart.setData("world", new float[4]);
-
- myChart.setStrokeWeight(1.5);
-
- myChart.addDataSet("earth");
- myChart.setColors("earth", color(255), color(0, 255, 0));
- myChart.updateData("earth", 1, 2, 10, 3);
-
-}
-
-
-void draw() {
- background(0);
- // unshift: add data from left to right (first in)
- myChart.unshift("world", (sin(frameCount*0.01)*10));
-
- // push: add data from right to left (last in)
- myChart.push("earth", (sin(frameCount*0.1)*10));
-}
-
-
-
-
-
-
-
-/*
-a list of all methods available for the Chart Controller
-use ControlP5.printPublicMethodsFor(Chart.class);
-to print the following list into the console.
-
-You can find further details about class Chart in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.Chart : Chart addData(ChartData)
-controlP5.Chart : Chart addData(ChartDataSet, float)
-controlP5.Chart : Chart addData(String, ChartData)
-controlP5.Chart : Chart addData(String, float)
-controlP5.Chart : Chart addData(float)
-controlP5.Chart : Chart addDataSet(String)
-controlP5.Chart : Chart addFirst(String, float)
-controlP5.Chart : Chart addFirst(float)
-controlP5.Chart : Chart addLast(String, float)
-controlP5.Chart : Chart addLast(float)
-controlP5.Chart : Chart push(String, float)
-controlP5.Chart : Chart push(float)
-controlP5.Chart : Chart removeData(ChartData)
-controlP5.Chart : Chart removeData(String, ChartData)
-controlP5.Chart : Chart removeData(String, int)
-controlP5.Chart : Chart removeData(int)
-controlP5.Chart : Chart removeDataSet(String)
-controlP5.Chart : Chart removeFirst()
-controlP5.Chart : Chart removeFirst(String)
-controlP5.Chart : Chart removeLast()
-controlP5.Chart : Chart removeLast(String)
-controlP5.Chart : Chart setData(String, int, ChartData)
-controlP5.Chart : Chart setData(int, ChartData)
-controlP5.Chart : Chart setDataSet(ChartDataSet)
-controlP5.Chart : Chart setDataSet(String, ChartDataSet)
-controlP5.Chart : Chart setRange(float, float)
-controlP5.Chart : Chart setResolution(int)
-controlP5.Chart : Chart setStrokeWeight(float)
-controlP5.Chart : Chart setValue(float)
-controlP5.Chart : Chart setView(int)
-controlP5.Chart : Chart unshift(String, float)
-controlP5.Chart : Chart unshift(float)
-controlP5.Chart : ChartData getData(String, int)
-controlP5.Chart : ChartDataSet getDataSet(String)
-controlP5.Chart : LinkedHashMap getDataSet()
-controlP5.Chart : String getInfo()
-controlP5.Chart : String toString()
-controlP5.Chart : float getStrokeWeight()
-controlP5.Chart : float[] getValuesFrom(String)
-controlP5.Chart : int getResolution()
-controlP5.Chart : int size()
-controlP5.Chart : void onEnter()
-controlP5.Chart : void onLeave()
-controlP5.Controller : CColor getColor()
-controlP5.Controller : Chart addCallback(CallbackListener)
-controlP5.Controller : Chart addListener(ControlListener)
-controlP5.Controller : Chart addListenerFor(int, CallbackListener)
-controlP5.Controller : Chart align(int, int, int, int)
-controlP5.Controller : Chart bringToFront()
-controlP5.Controller : Chart bringToFront(ControllerInterface)
-controlP5.Controller : Chart hide()
-controlP5.Controller : Chart linebreak()
-controlP5.Controller : Chart listen(boolean)
-controlP5.Controller : Chart lock()
-controlP5.Controller : Chart onChange(CallbackListener)
-controlP5.Controller : Chart onClick(CallbackListener)
-controlP5.Controller : Chart onDoublePress(CallbackListener)
-controlP5.Controller : Chart onDrag(CallbackListener)
-controlP5.Controller : Chart onDraw(ControllerView)
-controlP5.Controller : Chart onEndDrag(CallbackListener)
-controlP5.Controller : Chart onEnter(CallbackListener)
-controlP5.Controller : Chart onLeave(CallbackListener)
-controlP5.Controller : Chart onMove(CallbackListener)
-controlP5.Controller : Chart onPress(CallbackListener)
-controlP5.Controller : Chart onRelease(CallbackListener)
-controlP5.Controller : Chart onReleaseOutside(CallbackListener)
-controlP5.Controller : Chart onStartDrag(CallbackListener)
-controlP5.Controller : Chart onWheel(CallbackListener)
-controlP5.Controller : Chart plugTo(Object)
-controlP5.Controller : Chart plugTo(Object, String)
-controlP5.Controller : Chart plugTo(Object[])
-controlP5.Controller : Chart plugTo(Object[], String)
-controlP5.Controller : Chart registerProperty(String)
-controlP5.Controller : Chart registerProperty(String, String)
-controlP5.Controller : Chart registerTooltip(String)
-controlP5.Controller : Chart removeBehavior()
-controlP5.Controller : Chart removeCallback()
-controlP5.Controller : Chart removeCallback(CallbackListener)
-controlP5.Controller : Chart removeListener(ControlListener)
-controlP5.Controller : Chart removeListenerFor(int, CallbackListener)
-controlP5.Controller : Chart removeListenersFor(int)
-controlP5.Controller : Chart removeProperty(String)
-controlP5.Controller : Chart removeProperty(String, String)
-controlP5.Controller : Chart setArrayValue(float[])
-controlP5.Controller : Chart setArrayValue(int, float)
-controlP5.Controller : Chart setBehavior(ControlBehavior)
-controlP5.Controller : Chart setBroadcast(boolean)
-controlP5.Controller : Chart setCaptionLabel(String)
-controlP5.Controller : Chart setColor(CColor)
-controlP5.Controller : Chart setColorActive(int)
-controlP5.Controller : Chart setColorBackground(int)
-controlP5.Controller : Chart setColorCaptionLabel(int)
-controlP5.Controller : Chart setColorForeground(int)
-controlP5.Controller : Chart setColorLabel(int)
-controlP5.Controller : Chart setColorValue(int)
-controlP5.Controller : Chart setColorValueLabel(int)
-controlP5.Controller : Chart setDecimalPrecision(int)
-controlP5.Controller : Chart setDefaultValue(float)
-controlP5.Controller : Chart setHeight(int)
-controlP5.Controller : Chart setId(int)
-controlP5.Controller : Chart setImage(PImage)
-controlP5.Controller : Chart setImage(PImage, int)
-controlP5.Controller : Chart setImages(PImage, PImage, PImage)
-controlP5.Controller : Chart setImages(PImage, PImage, PImage, PImage)
-controlP5.Controller : Chart setLabel(String)
-controlP5.Controller : Chart setLabelVisible(boolean)
-controlP5.Controller : Chart setLock(boolean)
-controlP5.Controller : Chart setMax(float)
-controlP5.Controller : Chart setMin(float)
-controlP5.Controller : Chart setMouseOver(boolean)
-controlP5.Controller : Chart setMoveable(boolean)
-controlP5.Controller : Chart setPosition(float, float)
-controlP5.Controller : Chart setPosition(float[])
-controlP5.Controller : Chart setSize(PImage)
-controlP5.Controller : Chart setSize(int, int)
-controlP5.Controller : Chart setStringValue(String)
-controlP5.Controller : Chart setUpdate(boolean)
-controlP5.Controller : Chart setValue(float)
-controlP5.Controller : Chart setValueLabel(String)
-controlP5.Controller : Chart setValueSelf(float)
-controlP5.Controller : Chart setView(ControllerView)
-controlP5.Controller : Chart setVisible(boolean)
-controlP5.Controller : Chart setWidth(int)
-controlP5.Controller : Chart show()
-controlP5.Controller : Chart unlock()
-controlP5.Controller : Chart unplugFrom(Object)
-controlP5.Controller : Chart unplugFrom(Object[])
-controlP5.Controller : Chart unregisterTooltip()
-controlP5.Controller : Chart update()
-controlP5.Controller : Chart updateSize()
-controlP5.Controller : ControlBehavior getBehavior()
-controlP5.Controller : ControlWindow getControlWindow()
-controlP5.Controller : ControlWindow getWindow()
-controlP5.Controller : ControllerProperty getProperty(String)
-controlP5.Controller : ControllerProperty getProperty(String, String)
-controlP5.Controller : ControllerView getView()
-controlP5.Controller : Label getCaptionLabel()
-controlP5.Controller : Label getValueLabel()
-controlP5.Controller : List getControllerPlugList()
-controlP5.Controller : Pointer getPointer()
-controlP5.Controller : String getAddress()
-controlP5.Controller : String getInfo()
-controlP5.Controller : String getName()
-controlP5.Controller : String getStringValue()
-controlP5.Controller : String toString()
-controlP5.Controller : Tab getTab()
-controlP5.Controller : boolean isActive()
-controlP5.Controller : boolean isBroadcast()
-controlP5.Controller : boolean isInside()
-controlP5.Controller : boolean isLabelVisible()
-controlP5.Controller : boolean isListening()
-controlP5.Controller : boolean isLock()
-controlP5.Controller : boolean isMouseOver()
-controlP5.Controller : boolean isMousePressed()
-controlP5.Controller : boolean isMoveable()
-controlP5.Controller : boolean isUpdate()
-controlP5.Controller : boolean isVisible()
-controlP5.Controller : float getArrayValue(int)
-controlP5.Controller : float getDefaultValue()
-controlP5.Controller : float getMax()
-controlP5.Controller : float getMin()
-controlP5.Controller : float getValue()
-controlP5.Controller : float[] getAbsolutePosition()
-controlP5.Controller : float[] getArrayValue()
-controlP5.Controller : float[] getPosition()
-controlP5.Controller : int getDecimalPrecision()
-controlP5.Controller : int getHeight()
-controlP5.Controller : int getId()
-controlP5.Controller : int getWidth()
-controlP5.Controller : int listenerSize()
-controlP5.Controller : void remove()
-controlP5.Controller : void setView(ControllerView, int)
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-created: 2014/08/16 19:11:34
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5console/ControlP5console.pde b/Processing/libraries/controlP5/examples/extra/ControlP5console/ControlP5console.pde
deleted file mode 100644
index c5b5f38..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5console/ControlP5console.pde
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * ControlP5 Println
- *
- *
- * a console like textarea which captures the output from the System.out stream
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-Textarea myTextarea;
-
-int c = 0;
-
-Println console;
-
-void setup() {
- size(700, 400);
- cp5 = new ControlP5(this);
- cp5.enableShortcuts();
- frameRate(50);
- myTextarea = cp5.addTextarea("txt")
- .setPosition(100, 100)
- .setSize(200, 200)
- .setFont(createFont("", 10))
- .setLineHeight(14)
- .setColor(color(200))
- .setColorBackground(color(0, 100))
- .setColorForeground(color(255, 100));
- ;
-
- console = cp5.addConsole(myTextarea);//
-}
-
-
-void draw() {
- background(128);
- noStroke();
- ellipseMode(CENTER);
- float n = sin(frameCount*0.01)*300;
- fill(110, 255,220);
- ellipse(width/2, height/2, n , n);
-
- println(frameCount+"\t"+String.format("%.2f", frameRate)+"\t"+String.format("%.2f", n));
-}
-
-void keyPressed() {
- switch(key) {
- case('1'):
- console.pause();
- break;
- case('2'):
- console.play();
- break;
- case('3'):
- console.setMax(8);
- break;
- case('4'):
- console.setMax(-1);
- break;
- case('5'):
- console.clear();
- break;
- }
-}
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5controllerOnTop3D/ControlP5controllerOnTop3D.pde b/Processing/libraries/controlP5/examples/extra/ControlP5controllerOnTop3D/ControlP5controllerOnTop3D.pde
deleted file mode 100644
index cd28d9d..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5controllerOnTop3D/ControlP5controllerOnTop3D.pde
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * ControlP5 Controller on top of 3D
- * demonstrates how to use controlP5 controllers on top of a
- * OpenGL 3D scene.
- *
- * by Andreas Schlegel, 2011
- * www.sojamo.de/libraries/controlP5
- *
- */
-
-
-
-import controlP5.*;
-import processing.opengl.*;
-
-ControlP5 cp5;
-ControlGroup messageBox;
-int messageBoxResult = -1;
-String messageBoxString = "";
-float t;
-
-void setup() {
- size(640,480,P3D);
- cp5 = new ControlP5(this);
- noStroke();
- createMessageBox();
- Button b = cp5.addButton("toggleBox",1,20,20,100,20);
- b.setLabel("Toggle Box");
- textFont(createFont("",30));
-}
-
-
-void draw() {
- hint(ENABLE_DEPTH_TEST);
- pushMatrix();
- if(messageBox.isVisible()) {
- background(128);
- } else {
- background(0);
- fill(255);
- text(messageBoxString,20,height-40);
- }
-
- translate(width/2,height/2,mouseX);
- rotateY(t+=0.1);
- fill(255);
- rect(-50,-50,100,100);
- popMatrix();
- hint(DISABLE_DEPTH_TEST);
- // in case yo uare using the camera or you have
- // changed the default camera setting, reset the camera
- // to default by uncommenting the following line.
- // camera();
-}
-
-
-
-void toggleBox(int theValue) {
- if(messageBox.isVisible()) {
- messageBox.hide();
- } else {
- messageBox.show();
- }
-}
-
-
-void createMessageBox() {
- // create a group to store the messageBox elements
- messageBox = cp5.addGroup("messageBox",width/2 - 150,100,300);
- messageBox.setBackgroundHeight(120);
- messageBox.setBackgroundColor(color(0,100));
- messageBox.hideBar();
-
- // add a TextLabel to the messageBox.
- Textlabel l = cp5.addTextlabel("messageBoxLabel","Some MessageBox text goes here.",20,20);
- l.moveTo(messageBox);
-
- // add a textfield-controller with named-id inputbox
- // this controller will be linked to function inputbox() below.
- Textfield f = cp5.addTextfield("inputbox",20,36,260,20);
- f.getCaptionLabel().setVisible(false);
- f.moveTo(messageBox);
- f.setColorForeground(color(20));
- f.setColorBackground(color(20));
- f.setColorActive(color(100));
- // add the OK button to the messageBox.
- // the name of the button corresponds to function buttonOK
- // below and will be triggered when pressing the button.
- Button b1 = cp5.addButton("buttonOK",0,65,80,80,24);
- b1.moveTo(messageBox);
- b1.setColorBackground(color(40));
- b1.setColorActive(color(20));
- // by default setValue would trigger function buttonOK,
- // therefore we disable the broadcasting before setting
- // the value and enable broadcasting again afterwards.
- // same applies to the cancel button below.
- b1.setBroadcast(false);
- b1.setValue(1);
- b1.setBroadcast(true);
- b1.setCaptionLabel("OK");
- // centering of a label needs to be done manually
- // with marginTop and marginLeft
- //b1.captionLabel().style().marginTop = -2;
- //b1.captionLabel().style().marginLeft = 26;
-
- // add the Cancel button to the messageBox.
- // the name of the button corresponds to function buttonCancel
- // below and will be triggered when pressing the button.
- Button b2 = cp5.addButton("buttonCancel",0,155,80,80,24);
- b2.moveTo(messageBox);
- b2.setBroadcast(false);
- b2.setValue(0);
- b2.setBroadcast(true);
- b2.setCaptionLabel("Cancel");
- b2.setColorBackground(color(40));
- b2.setColorActive(color(20));
- //b2.captionLabel().toUpperCase(false);
- // centering of a label needs to be done manually
- // with marginTop and marginLeft
- //b2.captionLabel().style().marginTop = -2;
- //b2.captionLabel().style().marginLeft = 16;
-}
-
-// function buttonOK will be triggered when pressing
-// the OK button of the messageBox.
-void buttonOK(int theValue) {
- println("a button event from button OK.");
- messageBoxString = ((Textfield)cp5.getController("inputbox")).getText();
- messageBoxResult = theValue;
- messageBox.hide();
-}
-
-
-// function buttonCancel will be triggered when pressing
-// the Cancel button of the messageBox.
-void buttonCancel(int theValue) {
- println("a button event from button Cancel.");
- messageBoxResult = theValue;
- messageBox.hide();
-}
-
-// inputbox is called whenever RETURN has been pressed
-// in textfield-controller inputbox
-void inputbox(String theString) {
- println("got something from the inputbox : "+theString);
- messageBoxString = theString;
- messageBox.hide();
-}
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5frame/ControlP5frame.pde b/Processing/libraries/controlP5/examples/extra/ControlP5frame/ControlP5frame.pde
deleted file mode 100644
index 4bc9a82..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5frame/ControlP5frame.pde
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * ControlP5 Controlframe
- *
- * this example shows you how to create separate window to
- * display and use controllers with processing 3
- *
- * by Andreas Schlegel, 2016
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlFrame cf;
-
-float speed;
-float pos;
-float c0, c1, c2, c3;
-boolean auto;
-
-void settings() {
- size(400, 400, P3D);
-}
-
-void setup() {
- cf = new ControlFrame(this, 400, 800, "Controls");
- surface.setLocation(420, 10);
- noStroke();
-}
-
-void draw() {
- if (auto) pos += speed;
- background(0);
- translate(width/2, height/2);
- rotateY(pos);
- lights();
- fill(c0, c1, c2, c3);
- box(100);
-}
-
-
-
-
-class ControlFrame extends PApplet {
-
- int w, h;
- PApplet parent;
- ControlP5 cp5;
-
- public ControlFrame(PApplet _parent, int _w, int _h, String _name) {
- super();
- parent = _parent;
- w=_w;
- h=_h;
- PApplet.runSketch(new String[]{this.getClass().getName()}, this);
- }
-
- public void settings() {
- size(w, h);
- }
-
- public void setup() {
- surface.setLocation(10, 10);
- cp5 = new ControlP5(this);
-
- cp5.addToggle("auto")
- .plugTo(parent, "auto")
- .setPosition(10, 70)
- .setSize(50, 50)
- .setValue(true);
-
- cp5.addKnob("blend")
- .plugTo(parent, "c3")
- .setPosition(100, 300)
- .setSize(200, 200)
- .setRange(0, 255)
- .setValue(200);
-
- cp5.addNumberbox("color-red")
- .plugTo(parent, "c0")
- .setRange(0, 255)
- .setValue(255)
- .setPosition(100, 10)
- .setSize(100, 20);
-
- cp5.addNumberbox("color-green")
- .plugTo(parent, "c1")
- .setRange(0, 255)
- .setValue(128)
- .setPosition(100, 70)
- .setSize(100, 20);
-
- cp5.addNumberbox("color-blue")
- .plugTo(parent, "c2")
- .setRange(0, 255)
- .setValue(0)
- .setPosition(100, 130)
- .setSize(100, 20);
-
- cp5.addSlider("speed")
- .plugTo(parent, "speed")
- .setRange(0, 0.1)
- .setValue(0.01)
- .setPosition(100, 240)
- .setSize(200, 30);
-
- }
-
- void draw() {
- background(190);
- }
-}
\ No newline at end of file
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5frameRate/ControlP5frameRate.pde b/Processing/libraries/controlP5/examples/extra/ControlP5frameRate/ControlP5frameRate.pde
deleted file mode 100644
index 85aed00..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5frameRate/ControlP5frameRate.pde
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * ControlP5 FrameRate
- *
- *
- * uses a textlabel to display the current or average
- * framerate of the sketch.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-void setup() {
- size(400,500);
- frameRate(60);
- cp5 = new ControlP5(this);
- cp5.addFrameRate().setInterval(10).setPosition(0,height - 10);
-
-}
-
-void draw() {
- background(129);
-}
-
-/*
-a list of all methods available for the FrameRate Controller
-use ControlP5.printPublicMethodsFor(FrameRate.class);
-to print the following list into the console.
-
-You can find further details about class FrameRate in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.Controller : CColor getColor()
-controlP5.Controller : ControlBehavior getBehavior()
-controlP5.Controller : ControlWindow getControlWindow()
-controlP5.Controller : ControlWindow getWindow()
-controlP5.Controller : ControllerProperty getProperty(String)
-controlP5.Controller : ControllerProperty getProperty(String, String)
-controlP5.Controller : ControllerView getView()
-controlP5.Controller : FrameRate addCallback(CallbackListener)
-controlP5.Controller : FrameRate addListener(ControlListener)
-controlP5.Controller : FrameRate addListenerFor(int, CallbackListener)
-controlP5.Controller : FrameRate align(int, int, int, int)
-controlP5.Controller : FrameRate bringToFront()
-controlP5.Controller : FrameRate bringToFront(ControllerInterface)
-controlP5.Controller : FrameRate hide()
-controlP5.Controller : FrameRate linebreak()
-controlP5.Controller : FrameRate listen(boolean)
-controlP5.Controller : FrameRate lock()
-controlP5.Controller : FrameRate onChange(CallbackListener)
-controlP5.Controller : FrameRate onClick(CallbackListener)
-controlP5.Controller : FrameRate onDoublePress(CallbackListener)
-controlP5.Controller : FrameRate onDrag(CallbackListener)
-controlP5.Controller : FrameRate onDraw(ControllerView)
-controlP5.Controller : FrameRate onEndDrag(CallbackListener)
-controlP5.Controller : FrameRate onEnter(CallbackListener)
-controlP5.Controller : FrameRate onLeave(CallbackListener)
-controlP5.Controller : FrameRate onMove(CallbackListener)
-controlP5.Controller : FrameRate onPress(CallbackListener)
-controlP5.Controller : FrameRate onRelease(CallbackListener)
-controlP5.Controller : FrameRate onReleaseOutside(CallbackListener)
-controlP5.Controller : FrameRate onStartDrag(CallbackListener)
-controlP5.Controller : FrameRate onWheel(CallbackListener)
-controlP5.Controller : FrameRate plugTo(Object)
-controlP5.Controller : FrameRate plugTo(Object, String)
-controlP5.Controller : FrameRate plugTo(Object[])
-controlP5.Controller : FrameRate plugTo(Object[], String)
-controlP5.Controller : FrameRate registerProperty(String)
-controlP5.Controller : FrameRate registerProperty(String, String)
-controlP5.Controller : FrameRate registerTooltip(String)
-controlP5.Controller : FrameRate removeBehavior()
-controlP5.Controller : FrameRate removeCallback()
-controlP5.Controller : FrameRate removeCallback(CallbackListener)
-controlP5.Controller : FrameRate removeListener(ControlListener)
-controlP5.Controller : FrameRate removeListenerFor(int, CallbackListener)
-controlP5.Controller : FrameRate removeListenersFor(int)
-controlP5.Controller : FrameRate removeProperty(String)
-controlP5.Controller : FrameRate removeProperty(String, String)
-controlP5.Controller : FrameRate setArrayValue(float[])
-controlP5.Controller : FrameRate setArrayValue(int, float)
-controlP5.Controller : FrameRate setBehavior(ControlBehavior)
-controlP5.Controller : FrameRate setBroadcast(boolean)
-controlP5.Controller : FrameRate setCaptionLabel(String)
-controlP5.Controller : FrameRate setColor(CColor)
-controlP5.Controller : FrameRate setColorActive(int)
-controlP5.Controller : FrameRate setColorBackground(int)
-controlP5.Controller : FrameRate setColorCaptionLabel(int)
-controlP5.Controller : FrameRate setColorForeground(int)
-controlP5.Controller : FrameRate setColorLabel(int)
-controlP5.Controller : FrameRate setColorValue(int)
-controlP5.Controller : FrameRate setColorValueLabel(int)
-controlP5.Controller : FrameRate setDecimalPrecision(int)
-controlP5.Controller : FrameRate setDefaultValue(float)
-controlP5.Controller : FrameRate setHeight(int)
-controlP5.Controller : FrameRate setId(int)
-controlP5.Controller : FrameRate setImage(PImage)
-controlP5.Controller : FrameRate setImage(PImage, int)
-controlP5.Controller : FrameRate setImages(PImage, PImage, PImage)
-controlP5.Controller : FrameRate setImages(PImage, PImage, PImage, PImage)
-controlP5.Controller : FrameRate setLabel(String)
-controlP5.Controller : FrameRate setLabelVisible(boolean)
-controlP5.Controller : FrameRate setLock(boolean)
-controlP5.Controller : FrameRate setMax(float)
-controlP5.Controller : FrameRate setMin(float)
-controlP5.Controller : FrameRate setMouseOver(boolean)
-controlP5.Controller : FrameRate setMoveable(boolean)
-controlP5.Controller : FrameRate setPosition(float, float)
-controlP5.Controller : FrameRate setPosition(float[])
-controlP5.Controller : FrameRate setSize(PImage)
-controlP5.Controller : FrameRate setSize(int, int)
-controlP5.Controller : FrameRate setStringValue(String)
-controlP5.Controller : FrameRate setUpdate(boolean)
-controlP5.Controller : FrameRate setValue(float)
-controlP5.Controller : FrameRate setValueLabel(String)
-controlP5.Controller : FrameRate setValueSelf(float)
-controlP5.Controller : FrameRate setView(ControllerView)
-controlP5.Controller : FrameRate setVisible(boolean)
-controlP5.Controller : FrameRate setWidth(int)
-controlP5.Controller : FrameRate show()
-controlP5.Controller : FrameRate unlock()
-controlP5.Controller : FrameRate unplugFrom(Object)
-controlP5.Controller : FrameRate unplugFrom(Object[])
-controlP5.Controller : FrameRate unregisterTooltip()
-controlP5.Controller : FrameRate update()
-controlP5.Controller : FrameRate updateSize()
-controlP5.Controller : Label getCaptionLabel()
-controlP5.Controller : Label getValueLabel()
-controlP5.Controller : List getControllerPlugList()
-controlP5.Controller : Pointer getPointer()
-controlP5.Controller : String getAddress()
-controlP5.Controller : String getInfo()
-controlP5.Controller : String getName()
-controlP5.Controller : String getStringValue()
-controlP5.Controller : String toString()
-controlP5.Controller : Tab getTab()
-controlP5.Controller : boolean isActive()
-controlP5.Controller : boolean isBroadcast()
-controlP5.Controller : boolean isInside()
-controlP5.Controller : boolean isLabelVisible()
-controlP5.Controller : boolean isListening()
-controlP5.Controller : boolean isLock()
-controlP5.Controller : boolean isMouseOver()
-controlP5.Controller : boolean isMousePressed()
-controlP5.Controller : boolean isMoveable()
-controlP5.Controller : boolean isUpdate()
-controlP5.Controller : boolean isVisible()
-controlP5.Controller : float getArrayValue(int)
-controlP5.Controller : float getDefaultValue()
-controlP5.Controller : float getMax()
-controlP5.Controller : float getMin()
-controlP5.Controller : float getValue()
-controlP5.Controller : float[] getAbsolutePosition()
-controlP5.Controller : float[] getArrayValue()
-controlP5.Controller : float[] getPosition()
-controlP5.Controller : int getDecimalPrecision()
-controlP5.Controller : int getHeight()
-controlP5.Controller : int getId()
-controlP5.Controller : int getWidth()
-controlP5.Controller : int listenerSize()
-controlP5.Controller : void remove()
-controlP5.Controller : void setView(ControllerView, int)
-controlP5.FrameRate : FrameRate setInterval(int)
-controlP5.FrameRate : void draw(PGraphics)
-controlP5.Textlabel : ControllerStyle getStyle()
-controlP5.Textlabel : Label get()
-controlP5.Textlabel : Textlabel append(String, int)
-controlP5.Textlabel : Textlabel setColor(int)
-controlP5.Textlabel : Textlabel setFont(ControlFont)
-controlP5.Textlabel : Textlabel setFont(PFont)
-controlP5.Textlabel : Textlabel setHeight(int)
-controlP5.Textlabel : Textlabel setLetterSpacing(int)
-controlP5.Textlabel : Textlabel setLineHeight(int)
-controlP5.Textlabel : Textlabel setMultiline(boolean)
-controlP5.Textlabel : Textlabel setStringValue(String)
-controlP5.Textlabel : Textlabel setText(String)
-controlP5.Textlabel : Textlabel setValue(String)
-controlP5.Textlabel : Textlabel setValue(float)
-controlP5.Textlabel : Textlabel setWidth(int)
-controlP5.Textlabel : int getLineHeight()
-controlP5.Textlabel : void draw()
-controlP5.Textlabel : void draw(PApplet)
-controlP5.Textlabel : void draw(PGraphics)
-controlP5.Textlabel : void draw(int, int)
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-created: 2015/03/24 12:22:02
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5frames/ControlP5frames.pde b/Processing/libraries/controlP5/examples/extra/ControlP5frames/ControlP5frames.pde
deleted file mode 100644
index 1c1979d..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5frames/ControlP5frames.pde
+++ /dev/null
@@ -1,134 +0,0 @@
-
-import java.awt.*;
-import java.awt.event.*;
-import controlP5.*;
-
-private ControlP5 cp5;
-
-ControlFrame cf1, cf2;
-
-int bgColor;
-
-void setup() {
- size(400, 400 ,P3D );
- /* add a controlP5 instance for the main sketch window (not required for other ControlFrames to work) */
- cp5 = new ControlP5( this );
- cp5.addSlider( "s2" );
-
-
- /* Add a controlframe */
-
- cf1 = addControlFrame( "hello", 200, 200, 20, 20, color( 100 ) );
-
- // add a slider with an EventListener. When dragging the slider,
- // variable bgColor will change accordingly.
- cf1.control().addSlider( "s1" ).setRange( 0, 255 ).addListener( new ControlListener() {
- public void controlEvent( ControlEvent ev ) {
- bgColor = color( ev.getValue() );
- }
- }
- );
-
-
- /* Add a second controlframe */
-
- cf2 = addControlFrame( "world", 200, 200, 20, 240, color( 100 ) );
-
- // add a button with an EventListener. When releasing the button,
- // variable bgColor will change to color( 255 );
- cf2.control().addButton( "b1" ).addListener( new ControlListener() {
- public void controlEvent( ControlEvent ev ) {
- bgColor = color( 255 );
- }
- }
- );
-
- cf2.control().addButton( "b2" ).addListener( new ControlListener() {
- public void controlEvent(ControlEvent ev) {
- bgColor = color( random( 255 ), random( 255 ), random( 255 ) );
- }
- }
- );
-}
-
-void draw() {
- background( bgColor );
-}
-
-
-/* no changes required below */
-
-
-ControlFrame addControlFrame(String theName, int theWidth, int theHeight) {
- return addControlFrame(theName, theWidth, theHeight, 100, 100, color( 0 ) );
-}
-
-ControlFrame addControlFrame(String theName, int theWidth, int theHeight, int theX, int theY, int theColor ) {
- final Frame f = new Frame( theName );
- final ControlFrame p = new ControlFrame( this, theWidth, theHeight, theColor );
-
- f.add( p );
- p.init();
- f.setTitle(theName);
- f.setSize( p.w, p.h );
- f.setLocation( theX, theY );
- f.addWindowListener( new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent we) {
- p.dispose();
- f.dispose();
- }
- }
- );
- f.setResizable( false );
- f.setVisible( true );
- // sleep a little bit to allow p to call setup.
- // otherwise a nullpointerexception might be caused.
- try {
- Thread.sleep( 100 );
- }
- catch(Exception e) {
- }
- return p;
-}
-
-
-// the ControlFrame class extends PApplet, so we
-// are creating a new processing applet inside a
-// new frame with a controlP5 object loaded
-public class ControlFrame extends PApplet {
-
- int w, h;
-
- int bg;
-
- public void setup() {
- size(w, h);
- frameRate(25);
- cp5 = new ControlP5( this );
- }
-
- public void draw() {
- background( bg );
- }
-
- private ControlFrame() {
- }
-
- public ControlFrame(Object theParent, int theWidth, int theHeight, int theColor) {
- parent = theParent;
- w = theWidth;
- h = theHeight;
- bg = theColor;
- }
-
-
- public ControlP5 control() {
- return this.cp5;
- }
-
- ControlP5 cp5;
-
- Object parent;
-}
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5groupCanvas/ControlP5groupCanvas.pde b/Processing/libraries/controlP5/examples/extra/ControlP5groupCanvas/ControlP5groupCanvas.pde
deleted file mode 100644
index 73c2bb7..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5groupCanvas/ControlP5groupCanvas.pde
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * ControlP5 Canvas
- *
- * by andreas schlegel, 2011
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-void setup() {
- size(400,600);
- smooth();
-
- cp5 = new ControlP5(this);
- cp5.addGroup("myGroup")
- .setLabel("Testing Canvas")
- .setPosition(100,200)
- .setWidth(200)
- .addCanvas(new TestCanvas())
- ;
-}
-
-void draw() {
- background(0);
-}
-
-
-class TestCanvas extends Canvas {
-
- float n;
- float a;
-
- public void setup(PGraphics pg) {
- println("starting a test canvas.");
- n = 1;
- }
- public void draw(PGraphics pg) {
- n += 0.01;
- pg.ellipseMode(CENTER);
- pg.fill(lerpColor(color(0,100,200),color(0,200,100),map(sin(n),-1,1,0,1)));
- pg.rect(0,0,200,200);
- pg.fill(255,150);
- a+=0.01;
- ellipse(100,100,abs(sin(a)*150),abs(sin(a)*150));
- ellipse(40,40,abs(sin(a+0.5)*50),abs(sin(a+0.5)*50));
- ellipse(60,140,abs(cos(a)*80),abs(cos(a)*80));
- }
-}
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/ControlP5imageButton.pde b/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/ControlP5imageButton.pde
deleted file mode 100644
index 309ea21..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/ControlP5imageButton.pde
+++ /dev/null
@@ -1,38 +0,0 @@
-import controlP5.*;
-
-ControlP5 cp5;
-
-int myColor = color(0);
-
-
-void setup() {
- size(400,600);
- cp5 = new ControlP5(this);
-
- // replace the default controlP5 button with an image.
- // button.setImages(defaultImage, rolloverImage, pressedImage);
- // use button.updateSize() to adjust the size of the button and
- // resize to the dimensions of the defaultImage
-
- cp5.addButton("buttonA")
- .setPosition(175,275)
- .setImages(loadImage("Arrow-Left.png"), loadImage("Arrow-Right.png"), loadImage("Refresh.png"))
- .updateSize();
-}
-
-void draw() {
- background(myColor);
-}
-
-public void controlEvent(ControlEvent theEvent) {
- println(theEvent.getController().getName());
-
-}
-
-// function buttonA will receive changes from
-// controller with name buttonA
-public void buttonA(int theValue) {
- println("a button event from buttonA: "+theValue);
- myColor = color(128);
-}
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Arrow-Left.png b/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Arrow-Left.png
deleted file mode 100644
index 33ab6ee..0000000
Binary files a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Arrow-Left.png and /dev/null differ
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Arrow-Right.png b/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Arrow-Right.png
deleted file mode 100644
index 5afff9b..0000000
Binary files a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Arrow-Right.png and /dev/null differ
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Refresh.png b/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Refresh.png
deleted file mode 100644
index 6582a31..0000000
Binary files a/Processing/libraries/controlP5/examples/extra/ControlP5imageButton/data/Refresh.png and /dev/null differ
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5key/ControlP5key.pde b/Processing/libraries/controlP5/examples/extra/ControlP5key/ControlP5key.pde
deleted file mode 100644
index 095b7e4..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5key/ControlP5key.pde
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * ControlP5 ControlKey
- * use ControlKeys to map key combinations to particular events.
- * multi-keypress supported.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-int col;
-int colEllipse;
-boolean visible;
-
-void setup() {
- size(400, 600);
- smooth();
- noStroke();
- col = color(0);
- colEllipse = color(0,255,90);
- cp5 = new ControlP5(this);
-
- // press key 1 to change background to white
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {col = color(255);}}, '1');
-
- // press key 2 to change background to black
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {col = color(0);}}, '2');
-
- // press key 1 and ALT to make circles visible
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {visible = true;}}, ALT,'1');
-
- // press key 2 and ALT to hide circles
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {visible = false;}}, ALT,'2');
-
- // press key 1 and ALT and SHIFT to change the color of circles
- cp5.mapKeyFor(new ControlKey() {public void keyEvent() {colEllipse = color(random(255));}}, ALT,'1',SHIFT);
-}
-
-void draw() {
- background(col);
- if(visible) {
- fill(colEllipse);
- ellipse(100,100,50,50);
- ellipse(150,400,200,200);
- }
-}
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5listBoxClear/ControlP5listBoxClear.pde b/Processing/libraries/controlP5/examples/extra/ControlP5listBoxClear/ControlP5listBoxClear.pde
deleted file mode 100644
index 177d019..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5listBoxClear/ControlP5listBoxClear.pde
+++ /dev/null
@@ -1,74 +0,0 @@
-import controlP5.*;
-
-String[][] s = new String[3][];
-ControlP5 controlP5;
-ListBox l;
-
-void setup() {
- size(400,400);
- controlP5 = new ControlP5(this);
- l = controlP5.addListBox("myList",100,100,120,150);
- // l.actAsPulldownMenu(true);
- l.setItemHeight(23);
-
-
- s[0] = new String[] {
- "a","b","c","d"
- };
- s[1] = new String[] {
- "a","b","c","d","e","f","g","h","i","j","k","l","m","n"
- };
- s[2] = new String[] {
- "l","m","n"
- };
-
- for(int i=0;i "+theEvent.getGroup().getValue());
- int n = int(theEvent.getGroup().getValue());
- println("\t\t group:"+(n >> 8 & 0xff)+", item:"+(n >> 0 & 0xff));
- }
-}
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5mouseWheel/ControlP5mouseWheel.pde b/Processing/libraries/controlP5/examples/extra/ControlP5mouseWheel/ControlP5mouseWheel.pde
deleted file mode 100644
index 74904e8..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5mouseWheel/ControlP5mouseWheel.pde
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * ControlP5 KeyEventAndWheel
- *
- * with controlP5 2.0 all java.awt dependencies have been removed
- * as a consequence the option to use the MouseWheel for some controllers
- * has been removed. But the following example shows how to manually add
- * the mouseWheel support.
- *
- * With early versions of the processing 2.0 beta releases the keyEvent forwarding
- * does not work as expected and needs to be forwarded manually.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-
-import controlP5.*;
-import java.util.*;
-
-ControlP5 cp5;
-
-void setup() {
- size(700, 300);
- cp5 = new ControlP5(this);
-
-
- cp5.addNumberbox("numberbox")
- .setPosition(20, 20)
- .setSize(100, 20)
- ;
-
- cp5.addSlider("slider")
- .setPosition(20, 70)
- .setSize(200, 20)
- ;
-
- cp5.addKnob("knob")
- .setPosition(20, 120)
- .setRadius(50)
- ;
-
- List drops = new ArrayList();
- for(int i=0;i<100;i++) {
- drops.add("item "+i);
- }
-
- cp5.addDropdownList("drop")
- .setPosition(300, 30)
- .setWidth(200)
- .addItems(drops)
- ;
-
- cp5.addListBox("list")
- .setPosition(520, 30)
- .setSize(150,200)
- .addItems(drops)
- ;
-
- cp5.addTextarea("area")
- .setPosition(300, 150)
- .setSize(200,100)
- .setLineHeight(10)
- .setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam feugiat porttitor tempus. Donec hendrerit aliquam mauris, a interdum ante pellentesque et. In dui erat, condimentum et sodales eget, scelerisque quis libero. Nam non nibh vitae enim auctor fringilla sit amet quis magna. Quisque ultricies mi at arcu vulputate imperdiet tristique purus adipiscing. Maecenas pretium odio ac leo aliquam id commodo nulla eleifend. Aenean in pharetra mauris. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla suscipit, nisl vitae eleifend tincidunt, dolor justo sollicitudin nunc, sit amet rhoncus odio purus eu purus. Cras bibendum placerat elementum. Donec in lorem libero. Praesent auctor, felis quis volutpat facilisis, neque turpis tempor nisi, interdum viverra enim purus vel mi. Nam faucibus accumsan lorem, convallis consectetur elit vulputate ut.");
- ;
- // add mousewheel support, now hover the slide with your mouse
- // and use the mousewheel (or trackpad on a macbook) to change the
- // value of the slider.
- addMouseWheelListener();
-}
-
-
-void draw() {
- background(0);
-}
-
-
-void controlEvent(ControlEvent event) {
- println(event);
-}
-
-// When working in desktop mode, you can add mousewheel support for
-// controlP5 by using java.awt.event.MouseWheelListener and
-// java.awt.event.MouseWheelEvent
-
-void addMouseWheelListener() {
- frame.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
- public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {
- cp5.setMouseWheelRotation(e.getWheelRotation());
- }
- }
- );
-}
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5pointer/ControlP5pointer.pde b/Processing/libraries/controlP5/examples/extra/ControlP5pointer/ControlP5pointer.pde
deleted file mode 100644
index a278691..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5pointer/ControlP5pointer.pde
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
-* ControlP5 Pointer
-*
-* Default mouse actions use the Pointer class to trigger events.
-* you can manipulate the x and y fields of the Pointer class
-* for customizing input events for example when using a
-* different input than the mouse.
-* Here in this example the mouse coordiates are reveresed.
-*
-* by Andreas Schlegel, 2012
-* www.sojamo.de/libraries/controlp5
-*
-*/
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-void setup() {
- size(400, 600);
-
- cp5 = new ControlP5(this);
- // disable outodraw because we want to draw our
- // custom cursor on to of controlP5
- cp5.setAutoDraw(false);
-
- cp5.addSlider("hello", 0, 100, 50, 40, 40, 100, 20);
-
- // enable the pointer (and disable the mouse as input)
- cp5.getPointer().enable();
- cp5.getPointer().set(width/2, height/2);
-}
-
-
-void draw() {
- background(cp5.get("hello").getValue());
- // first draw controlP5
- cp5.draw();
-
- // the draw our pointer
- cp5.getPointer().set(width - mouseX, height - mouseY);
- pushMatrix();
- translate(cp5.getPointer().getX(), cp5.getPointer().getY());
- stroke(255);
- line(-10,0,10,0);
- line(0,-10,0,10);
- popMatrix();
- println(cp5.isMouseOver());
-}
-
-void mousePressed() {
- cp5.getPointer().pressed();
-}
-
-void mouseReleased() {
- cp5.getPointer().released();
-}
-
-/*
-a list of all methods available for the Pointer Controller
-use ControlP5.printPublicMethodsFor(Pointer.class);
-to print the following list into the console.
-
-You can find further details about class Pointer in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-
-created: 2015/03/24 12:22:14
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/ControlP5propertiesSets.pde b/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/ControlP5propertiesSets.pde
deleted file mode 100644
index 2c3d1a6..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/ControlP5propertiesSets.pde
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * ControlP5 properties sets.
- *
- * saves/loads controller values into/from properties-file.
- * this example shows how to make property sets of controllers that can be loaded and
- * saved individually. By default property files come in a serialized format
- * with a .ser extension.
- *
- *
- * default properties load/save key combinations are
- * alt+shift+l to load properties
- * alt+shift+s to save properties
- *
- *
- * find a list of public methods available for the ControllerPropererties Controller
- * at the bottom of this sketch's source code
- *
- * by andreas schlegel, 2011
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-public int slider1 = 32;
-public int slider2 = 64;
-public int slider3 = 128;
-public int slider4 = 255;
-
-
-void setup() {
- size(400, 600);
- cp5 = new ControlP5(this);
-
- // add a vertical slider
- cp5.addSlider("slider1", 0, 255, 20, 100, 128, 20);
- cp5.addSlider("slider2", 0, 255, 20, 150, 128, 20);
- cp5.addSlider("slider3", 0, 255, 20, 200, 128, 20);
- cp5.addSlider("slider4", 0, 255, 20, 250, 128, 20);
-
- cp5.addButton("b1", 0, 20, 350, 80, 12).setCaptionLabel("save setA");
- cp5.addButton("b2", 0, 101, 350, 80, 12).setCaptionLabel("load setA").setColorBackground(color(0, 100, 50));
-
- cp5.addButton("b3", 0, 200, 350, 80, 12).setCaptionLabel("save default");
- cp5.addButton("b4", 0, 281, 350, 80, 12).setCaptionLabel("load default").setColorBackground(color(0, 100, 50));
-
-
- // add a new properties set 'setA'
- cp5.getProperties().addSet("setA");
-
- // move controller 'slider' from the default set to setA
- // the 3 parameters read like this: move controller(1) from set(2) to set(3)
- cp5.getProperties().move(cp5.getController("slider1"), "default", "setA");
- // use copy instead of move to register 'slider' with both sets (default and setA)
-
- // prints the current list of properties registered and the set(s) they belong to
- cp5.getProperties().print();
-
- /* by default properties are saved in JSON format, if you want to change to the old default (java's serialized format), un-comment line below*/
- // cp5.getProperties().setFormat(ControlP5.SERIALIZED);
-}
-
-void draw() {
- background(0);
-
- fill(slider1);
- rect(250, 100, 100, 20);
-
- fill(slider2);
- rect(250, 150, 100, 20);
-
- fill(slider3);
- rect(250, 200, 100, 20);
-
- fill(slider4);
- rect(250, 250, 100, 20);
-}
-
-void b1(float v) {
- cp5.saveProperties("setA", "setA");
-}
-
-void b2(float v) {
- cp5.loadProperties(("setA"));
-}
-
-void b3(float v) {
- cp5.saveProperties("default", "default");
-}
-
-void b4(float v) {
- cp5.loadProperties(("default.json"));
-}
-
-
-
-
-
-/*
- a list of all methods available for the ControllerProperties class
- use ControlP5.printPublicMethodsFor(ControllerProperties.class);
- to print the following list into the console.
-
- You can find further details about class ControllerProperties in the javadoc.
-
- Format:
- ClassName : returnType methodName(parameter type)
-
-controlP5.ControllerProperties : ControllerProperties remove(ControllerInterface)
-controlP5.ControllerProperties : ControllerProperties remove(ControllerInterface, String)
-controlP5.ControllerProperties : ControllerProperties remove(ControllerInterface, String, String)
-controlP5.ControllerProperties : ControllerProperty getProperty(ControllerInterface, String)
-controlP5.ControllerProperties : ControllerProperty getProperty(ControllerInterface, String, String)
-controlP5.ControllerProperties : ControllerProperty register(ControllerInterface, String)
-controlP5.ControllerProperties : ControllerProperty register(ControllerInterface, String, String)
-controlP5.ControllerProperties : HashSet addSet(String)
-controlP5.ControllerProperties : HashSet getPropertySet(ControllerInterface)
-controlP5.ControllerProperties : List get(ControllerInterface)
-controlP5.ControllerProperties : Map get()
-controlP5.ControllerProperties : String toString()
-controlP5.ControllerProperties : boolean load()
-controlP5.ControllerProperties : boolean load(String)
-controlP5.ControllerProperties : void delete(ControllerProperty)
-controlP5.ControllerProperties : void move(ControllerInterface, String, String)
-controlP5.ControllerProperties : void move(ControllerProperty, String, String)
-controlP5.ControllerProperties : void only(ControllerProperty, String)
-controlP5.ControllerProperties : void print()
-controlP5.ControllerProperties : void setFormat(Format)
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-*/
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/default.json b/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/default.json
deleted file mode 100644
index 473af1b..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/default.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "/slider3": {
- "min": 0,
- "max": 255,
- "value": 12.750000953674316
- },
- "/slider2": {
- "min": 0,
- "max": 255,
- "value": 130.05001831054688
- },
- "/slider4": {
- "min": 0,
- "max": 255,
- "value": 214.20004272460938
- }
-}
\ No newline at end of file
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/setA.json b/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/setA.json
deleted file mode 100644
index 8a50c9b..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5propertiesSets/setA.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{"/slider1": {
- "min": 0,
- "max": 255,
- "value": 255
-}}
\ No newline at end of file
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5renderIntoPGraphics/ControlP5renderIntoPGraphics.pde b/Processing/libraries/controlP5/examples/extra/ControlP5renderIntoPGraphics/ControlP5renderIntoPGraphics.pde
deleted file mode 100644
index 0c11bc9..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5renderIntoPGraphics/ControlP5renderIntoPGraphics.pde
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
-* ControlP5 RenderIntoPGraphics
-*
-*
-* experimental
-*
-* by Andreas Schlegel, 2013
-* www.sojamo.de/libraries/controlp5
-*
-*/
-
-
-import controlP5.*;
-
-ControlP5 c1 , c2;
-PGraphics panel1 , panel2;
-
-void setup() {
- size( 1024, 500 , P3D ); //
- panel1 = createGraphics( 200 , height/2 );
- panel2 = createGraphics( 200 , height/2 );
- c1 = new ControlP5( this );
- c1.enableShortcuts();
- c1.setBackground( color( 0 , 50 ) );
- c1.addButton("hello").setSize(200,20).setPosition( 0 , 0 );
- c1.addButton("world").setSize(200,100).setPosition( 0 , 70 );
- c1.addSlider("slider").setSize(50,20).setPosition( 0 , 40 );
- c1.setGraphics( panel1 , 0 , 0 );
-
- c2 = new ControlP5( this );
- c2.enableShortcuts();
- c2.setBackground( color( 0 , 50 ) );
- c2.addButton("hello").setSize(200,20).setPosition( 0 , 0 );
- c2.addButton("world").setSize(200,100).setPosition( 0 , 70 );
- c2.addSlider("slider").setSize(50,20).setPosition( 0 , 40 );
- c2.setGraphics( panel2 , 220 , 0 );
-
-}
-
-
-void draw() {
- background( 100 , 0 , 0 );
-
- /* TODO update mouseevent when using setGraphics */
- c1.setGraphics( panel1 , 100 + int(sin(frameCount*0.1) * 100) , 250 );
-}
-
-
-void controlEvent( ControlEvent ce) {
- println(ce);
-}
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5style/ControlP5style.pde b/Processing/libraries/controlP5/examples/extra/ControlP5style/ControlP5style.pde
deleted file mode 100644
index 01147c0..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5style/ControlP5style.pde
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
-* ControlP5 ControllerStyle
-*
-*
-* find a list of public methods available for the ControllerStyle Controller
-* at the bottom of this sketch.
-*
-* by Andreas Schlegel, 2011
-* www.sojamo.de/libraries/controlp5
-*
-*/
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-float v1 = 50, v2 = 100, v3 = 100, v4 = 100;
-
-void setup() {
- size(400,600);
- smooth();
- noStroke();
- cp5 = new ControlP5(this);
-
- cp5.begin(100,100);
- cp5.addSlider("v1",0,255).linebreak();
- cp5.addSlider("v2",0,200).linebreak();
- cp5.addSlider("v3",0,300).linebreak();
- cp5.addSlider("v4",0,400);
- cp5.end();
-
- // change the caption label for controller v1 and apply styles
- cp5.getController("v1").setCaptionLabel("Background");
- style("v1");
-
- // change the caption label for controller v2 and apply styles
- cp5.getController("v2").setCaptionLabel("Ellipse A");
- style("v2");
-
- // change the caption label for controller v3 and apply styles
- cp5.getController("v3").setCaptionLabel("Ellipse B");
- style("v3");
-
- // change the caption label for controller v3 and apply styles
- cp5.getController("v4").setCaptionLabel("Ellipse C");
- style("v4");
-
-
-}
-
-void style(String theControllerName) {
- Controller c = cp5.getController(theControllerName);
- // adjust the height of the controller
- c.setHeight(15);
-
- // add some padding to the caption label background
- c.getCaptionLabel().getStyle().setPadding(4,4,3,4);
-
- // shift the caption label up by 4px
- c.getCaptionLabel().getStyle().setMargin(-4,0,0,0);
-
- // set the background color of the caption label
- c.getCaptionLabel().setColorBackground(color(10,20,30,140));
-}
-
-void draw() {
- background(v1);
- fill(255,255,220,100);
- ellipse(width/2-100, height/2-100,v2 + 50,v2 + 50);
- ellipse(width/2+100, height/2,v3,v3);
- ellipse(width/2, height/2+100,v4,v4);
-}
-
-
-
-/*
-a list of all methods available for the ControllerStyle Controller
-use ControlP5.printPublicMethodsFor(ControllerStyle.class);
-to print the following list into the console.
-
-You can find further details about class ControllerStyle in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-
-
-controlP5.ControllerStyle : ControllerStyle margin(int)
-controlP5.ControllerStyle : ControllerStyle margin(int, int, int, int)
-controlP5.ControllerStyle : ControllerStyle moveMargin(int, int, int, int)
-controlP5.ControllerStyle : ControllerStyle movePadding(int, int, int, int)
-controlP5.ControllerStyle : ControllerStyle padding(int)
-controlP5.ControllerStyle : ControllerStyle padding(int, int, int, int)
-controlP5.ControllerStyle : ControllerStyle setMargin(int, int, int, int)
-controlP5.ControllerStyle : ControllerStyle setMarginBottom(int)
-controlP5.ControllerStyle : ControllerStyle setMarginLeft(int)
-controlP5.ControllerStyle : ControllerStyle setMarginRight(int)
-controlP5.ControllerStyle : ControllerStyle setMarginTop(int)
-controlP5.ControllerStyle : ControllerStyle setPadding(int, int, int, int)
-controlP5.ControllerStyle : ControllerStyle setPaddingBottom(int)
-controlP5.ControllerStyle : ControllerStyle setPaddingLeft(int)
-controlP5.ControllerStyle : ControllerStyle setPaddingRight(int)
-controlP5.ControllerStyle : ControllerStyle setPaddingTop(int)
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-
-*/
-
diff --git a/Processing/libraries/controlP5/examples/extra/ControlP5textfieldAdvanced/ControlP5textfieldAdvanced.pde b/Processing/libraries/controlP5/examples/extra/ControlP5textfieldAdvanced/ControlP5textfieldAdvanced.pde
deleted file mode 100644
index 61899bd..0000000
--- a/Processing/libraries/controlP5/examples/extra/ControlP5textfieldAdvanced/ControlP5textfieldAdvanced.pde
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * ControlP5 textfield (advanced)
- *
- * demonstrates how to use keepFocus, setText, getText, getTextList,
- * clear, setAutoClear, isAutoClear and submit.
- *
- * by andreas schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-String textValue = "";
-
-Textfield myTextfield;
-
-void setup() {
- size(400, 600);
-
- cp5 = new ControlP5(this);
- myTextfield = cp5.addTextfield("textinput")
- .setPosition(100, 200)
- .setSize(200, 20)
- .setFocus(true)
- ;
-
- cp5.addTextfield("textValue")
- .setPosition(100, 300)
- .setSize(200, 20)
- ;
-
- // use setAutoClear(true/false) to clear a textfield or keep text displayed in
- // a textfield after pressing return.
- myTextfield.setAutoClear(true).keepFocus(true);
-
- cp5.addButton("clear", 0, 20, 200, 70, 20);
- cp5.addButton("submit", 0, 310, 200, 60, 20);
- cp5.addButton("performTextfieldActions", 0, 20, 100, 150, 20);
- cp5.addToggle("toggleAutoClear", true, 180, 100, 90, 20).setCaptionLabel("Auto Clear");
- cp5.addToggle("toggleKeepFocus", true, 280, 100, 90, 20).setCaptionLabel("Keep Focus");
-
-
-}
-
-void draw() {
- background(0);
-}
-
-void toggleAutoClear(boolean theFlag) {
- myTextfield.setAutoClear(theFlag);
-}
-
-void toggleKeepFocus(boolean theFlag) {
- myTextfield.keepFocus(theFlag);
-}
-
-void clear(int theValue) {
- myTextfield.clear();
-}
-
-void submit(int theValue) {
- myTextfield.submit();
-}
-
-
-void controlEvent(ControlEvent theEvent) {
- if (theEvent.isAssignableFrom(Textfield.class)) {
- Textfield t = (Textfield)theEvent.getController();
-
- println("controlEvent: accessing a string from controller '"
- +t.getName()+"': "+t.getStringValue()
- );
-
- // Textfield.isAutoClear() must be true
- print("controlEvent: trying to setText, ");
-
- t.setText("controlEvent: changing text.");
- if (t.isAutoClear()==false) {
- println(" success!");
- }
- else {
- println(" but Textfield.isAutoClear() is false, could not setText here.");
- }
- }
-}
-
-void performTextfieldActions() {
- println("\n");
- // Textfield.getText();
- println("the current text of myTextfield: "+myTextfield.getText());
- println("the current value of textValue: "+textValue);
- // Textfield.setText();
- myTextfield.setText("changed the text of a textfield");
- println("changing text of myTextfield to: "+myTextfield.getText());
- // Textfield.getTextList();
- println("the textlist of myTextfield has "+myTextfield.getTextList().length+" items.");
- for (int i=0;i
- * After initializing controlP5 you can add controllers to controlP5.
- * Here we use three numberboxes, one slider and one textfield.
- * The numberbox with name numberboxC will trigger function numberboxC()
- * in the example below. Whenever controlP5 detects a function in your
- * sketch that corresponds to the name of a controller, it will forward
- * an event to that function. Any event triggered by a controller
- * will be forwarded to function controlEvent in your sketch.
- * related examples ControlP5numberbox, ControlP5slider, ControlP5textfield
- *
- * by Andreas Schlegel, 2011
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-
-import controlP5.*;
-
-ControlP5 cp5;
-public int myColorRect = 200;
-public int myColorBackground = 100;
-
-void setup() {
- size(400, 400);
- noStroke();
-
- cp5 = new ControlP5(this);
-
- // create a slider
- // parameters:
- // name, minValue, maxValue, defaultValue, x, y, width, height
- cp5.addSlider("sliderA", 100, 200, 100, 100, 260, 100, 14);
-
-
- // create 3 numberboxes and assign an id for each
- cp5.addNumberbox("numberboxA", myColorRect, 100, 140, 100, 14).setId(1);
- cp5.addNumberbox("numberboxB", myColorBackground, 100, 180, 100, 14).setId(2);
- cp5.addNumberbox("numberboxC", 0, 100, 220, 100, 14).setId(3);
-
-
- // create a texfield
- cp5.addTextfield("textA", 100, 290, 100, 20);
-
- // change individual settings for a controller
- cp5.getController("numberboxA").setMax(255);
- cp5.getController("numberboxA").setMin(0);
-}
-
-void draw() {
- background(myColorBackground);
- fill(myColorRect);
- rect(0, 0, width, 100);
-}
-
-
-// events from controller numberboxC are received here
-public void numberboxC(int theValue) {
- println("### got an event from numberboxC : "+theValue);
-}
-
-
-// an event from slider sliderA will change the value of textfield textA here
-public void sliderA(int theValue) {
- Textfield txt = ((Textfield)cp5.getController("textA"));
- txt.setValue(""+theValue);
-}
-
-
-// for every change (a textfield event confirmed with a return) in textfield textA,
-// function textA will be invoked
-public void textA(String theValue) {
- println("### got an event from textA : "+theValue);
-}
-
-
-// function controlEvent will be invoked with every value change
-// in any registered controller
-public void controlEvent(ControlEvent theEvent) {
- println("got a control event from controller with id "+theEvent.getId());
- switch(theEvent.getId()) {
- case(1): // numberboxA is registered with id 1
- myColorRect = (int)(theEvent.getController().getValue());
- break;
- case(2): // numberboxB is registered with id 2
- myColorBackground = (int)(theEvent.getController().getValue());
- break;
- }
-}
-
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5beginEnd/ControlP5beginEnd.pde b/Processing/libraries/controlP5/examples/use/ControlP5beginEnd/ControlP5beginEnd.pde
deleted file mode 100644
index 954ddd2..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5beginEnd/ControlP5beginEnd.pde
+++ /dev/null
@@ -1 +0,0 @@
-// TBD
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5behavior/ControlP5behavior.pde b/Processing/libraries/controlP5/examples/use/ControlP5behavior/ControlP5behavior.pde
deleted file mode 100644
index 6f76b82..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5behavior/ControlP5behavior.pde
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * ControlP5 Behavior
- * ControlBehavior is an abstract class that can be extended using your
- * custom control behaviors. What is a control behavior? Control Behaviors
- * allow you to automate and dynamically change the state or value of a
- * controller. One behavior per controller is currently supported. i case you
- * need to use more that one bahavior, the implementation has to happen
- * on your side - inside your control behavior.
- *
- * find a list of public methods available for the ControlBehavior Controller
- * at the bottom of this sketch.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-
-ControlP5 cp5;
-
-int myColorBackground = color(0, 0, 0);
-
-public int sliderValue = 100;
-
-void setup() {
- size(400, 400);
- noStroke();
-
- cp5 = new ControlP5(this);
- cp5.addSlider("sliderValue")
- .setRange(0,255)
- .setValue(128)
- .setPosition(100, 50 + height/2)
- .setSize(40, 100);
-
- cp5.addSlider("slider")
- .setRange(100, 255)
- .setValue(128)
- .setPosition(100, 50)
- .setSize(100, 40);
-
-
- cp5.addBang("bang")
- .setPosition(40, 50 + height/2)
- .setSize(40, 40);
-
- // add a custom ControlBehavior to controller bang,
- // class TimerEvent is included in this sketch at the bottom
- // and extends abstract class ControlBehavior.
- cp5.getController("bang").setBehavior(new TimedEvent());
-
- // use an anonymous class of type ControlBehavior.
- cp5.getController("slider").setBehavior(new ControlBehavior() {
- float a = 0;
- public void update() {
- setValue(sin(a += 0.1) * 50 + 150);
- }
- }
- );
-}
-
-void draw() {
- background(myColorBackground);
- fill(sliderValue);
- rect(0, 0, width, height/2);
-}
-
-void slider(float theColor) {
- myColorBackground = color(theColor);
- println("# a slider event. setting background to "+theColor);
-}
-
-public void bang() {
- println("# an event received from controller bang.");
- // a bang will set the value of controller sliderValue
- // to a random number between 0 and 255.
- cp5.getController("sliderValue").setValue(random(0, 255));
-}
-
-// custom ControlBehavior
-class TimedEvent extends ControlBehavior {
- long myTime;
- int interval = 200;
-
- public TimedEvent() {
- reset();
- }
- void reset() {
- myTime = millis() + interval;
- }
-
- public void update() {
- if (millis()>myTime) {
- setValue(1);
- reset();
- }
- }
-}
-
-
-
-
-/*
-a list of all methods available for the ControlBehavior Controller
-use ControlP5.printPublicMethodsFor(ControlBehavior.class);
-to print the following list into the console.
-
-You can find further details about class ControlBehavior in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.ControlBehavior : Controller controller()
-controlP5.ControlBehavior : boolean isActive()
-controlP5.ControlBehavior : void setActive(boolean)
-controlP5.ControlBehavior : void setValue(float)
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-
-*/
-
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5bringToFront/ControlP5bringToFront.pde b/Processing/libraries/controlP5/examples/use/ControlP5bringToFront/ControlP5bringToFront.pde
deleted file mode 100644
index d777514..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5bringToFront/ControlP5bringToFront.pde
+++ /dev/null
@@ -1,55 +0,0 @@
-import controlP5.*;
-
-ControlP5 cp5;
-
-void setup() {
- size(700, 400);
-
- cp5 = new ControlP5(this);
-
- CallbackListener toFront = new CallbackListener() {
- public void controlEvent(CallbackEvent theEvent) {
- theEvent.getController().bringToFront();
- ((ScrollableList)theEvent.getController()).open();
- }
- };
-
- CallbackListener close = new CallbackListener() {
- public void controlEvent(CallbackEvent theEvent) {
- ((ScrollableList)theEvent.getController()).close();
- }
- };
-
- cp5.addScrollableList("myList1")
- .setPosition(100, 100)
- .addItems(new String[] {"a-1","b-1","c-1","d-1","e-1"})
- .onEnter(toFront)
- .onLeave(close)
- .setWidth(200)
- .setItemHeight(20)
- .setBarHeight(20)
- .setBackgroundColor(color(128))
- .setHeight(100)
- .close()
- ;
-
- cp5.addScrollableList("myList2")
- .setPosition(100, 125)
- .addItems(new String[] {"a-2","b-2","c-2","d-2","e-2"})
- .onEnter(toFront)
- .onLeave(close)
- .setWidth(200)
- .setItemHeight(20)
- .setBarHeight(20)
- .setBackgroundColor(color(128))
- .setHeight(100)
- .setColor(ControlP5.THEME_RED)
- .close()
- ;
-}
-
-
-
-void draw() {
- background(220);
-}
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5callback/ControlP5callback.pde b/Processing/libraries/controlP5/examples/use/ControlP5callback/ControlP5callback.pde
deleted file mode 100644
index 216797c..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5callback/ControlP5callback.pde
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * ControlP5 Callback
- *
- * The following example demonstrates the CallbackListener and CallbackEvent.
- * Here additional information about each available slider will be show when
- * hovering the controller with the mouse. The info will fade out when leaving
- * the controller.
- *
- * When hovering a controller, the mouse pointer will change as well.
- *
- * find a list of public methods available for the CallbackEvent Controller
- * at the bottom of this sketch.
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlp5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-Slider s1, s2;
-Info info;
-CallbackListener cb;
-
-void setup() {
- size(800, 400);
-
- cp5 = new ControlP5(this);
-
-
- // create a new instance of class Info
- // info will be used to display a controller's information and
- // will fade in when a CallbackEvent is invoked.
- info = new Info();
-
-
- // add 2 sliders
- s1 = cp5.addSlider("hello")
- .setRange(0, 100)
- .setValue(50)
- .setPosition(40, 40)
- .setSize(100, 20);
-
- s2 = cp5.addSlider("world")
- .setRange(0, 100)
- .setValue(10)
- .setPosition(40, 70)
- .setSize(100, 20);
-
-
- // the following CallbackListener will listen to any controlP5
- // action such as enter, leave, pressed, released, releasedoutside, broadcast
- // see static variables starting with ACTION_ inside class controlP5.ControlP5Constants
-
- cb = new CallbackListener() {
- public void controlEvent(CallbackEvent theEvent) {
- switch(theEvent.getAction()) {
- case(ControlP5.ACTION_ENTER):
- info.n = 1;
- info.label.setText(theEvent.getController().getInfo());
- cursor(HAND);
- break;
- case(ControlP5.ACTION_LEAVE):
- case(ControlP5.ACTION_RELEASEDOUTSIDE):
- info.n = 0;
- cursor(ARROW);
- break;
- }
- }
- };
-
- // add the above callback to controlP5
- cp5.addCallback(cb);
-
- // add another callback to slider s1, callback event will only be invoked for this
- // particular controller.
- s1.addCallback(new CallbackListener() {
- public void controlEvent(CallbackEvent theEvent) {
- if (theEvent.getAction()==ControlP5.ACTION_BROADCAST) {
- s2.setValue(s2.getMax() - s1.getValue());
- }
- }
- }
- );
-}
-
-void draw() {
- background(0);
- info.update();
-}
-
-
-void controlEvent(ControlEvent theEvent) {
- println("Got a ControlEvent for "+theEvent.name()+" = "+theEvent.value());
- info.label.setText(theEvent.getController().getInfo());
-}
-
-void keyPressed() {
- // uncomment the line below to remove callback cb from controlP5
- // when a key is pressed.
- //controlP5.removeCallback(cb);
-}
-
-// controlEvent(CallbackEvent) is called whenever a callback
-// has been triggered. controlEvent(CallbackEvent) is detected by
-// controlP5 automatically.
-void controlEvent(CallbackEvent theEvent) {
- if (theEvent.getController().equals(s2)) {
- switch(theEvent.getAction()) {
- case(ControlP5.ACTION_ENTER):
- println("Action:ENTER");
- break;
- case(ControlP5.ACTION_LEAVE):
- println("Action:LEAVE");
- break;
- case(ControlP5.ACTION_PRESSED):
- println("Action:PRESSED");
- break;
- case(ControlP5.ACTION_RELEASED):
- println("Action:RELEASED");
- break;
- case(ControlP5.ACTION_RELEASEDOUTSIDE):
- println("Action:RELEASED OUTSIDE");
- break;
- case(ControlP5.ACTION_BROADCAST):
- println("Action:BROADCAST");
- break;
- }
- }
-}
-
-
-
-class Info {
- float a;
- float n = 0;
- String txt = "";
- Textarea label;
-
- Info() {
- label = cp5.addTextarea("Hello\nWorld")
- .setSize(200,200)
- .setPosition(300,40)
- .setColor(color(255))
- .setColorBackground(color(100,0))
- .setLineHeight(12);
-
- }
-
- void update() {
- a += (n-a)*0.1;
- label.setColorBackground(color(100,255*a));
- }
-}
-
-
-/*
-a list of all methods available for the CallbackEvent Controller
- use ControlP5.printPublicMethodsFor(CallbackEvent.class);
- to print the following list into the console.
-
- You can find further details about class CallbackEvent in the javadoc.
-
- Format:
- ClassName : returnType methodName(parameter type)
-
-
- controlP5.CallbackEvent : Controller getController()
- controlP5.CallbackEvent : int getAction()
- java.lang.Object : String toString()
- java.lang.Object : boolean equals(Object)
-
-
- */
-
-
-
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5controlEvent/ControlP5controlEvent.pde b/Processing/libraries/controlP5/examples/use/ControlP5controlEvent/ControlP5controlEvent.pde
deleted file mode 100644
index 5f7a909..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5controlEvent/ControlP5controlEvent.pde
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * ControlP5 ControlEvent.
- * every control event is automatically forwarded to the function controlEvent(ControlEvent)
- * inside a sketch if such function is available. For further details about the API of
- * the ControlEvent class, please refer to the documentation.
- *
- *
- * find a list of public methods available for ControlEvent
- * at the bottom of this sketch's source code
- *
- * by Andreas Schlegel, 2012
- * www.sojamo.de/libraries/controlP5
- *
- */
-
-import controlP5.*;
-
-ControlP5 cp5;
-
-public int myColorRect1 = 200;
-
-public int myColorRect2 = 100;
-
-
-void setup() {
- size(400, 400);
- noStroke();
-
- cp5 = new ControlP5(this);
- cp5.addNumberbox("n1")
- .setValue(myColorRect1)
- .setPosition(20, 20)
- .setSize(100, 20)
- .setMin(0)
- .setMax(255)
- .setId(1);
-
- cp5.addNumberbox("n2")
- .setValue(myColorRect2)
- .setPosition(20, 60)
- .setSize(100, 20)
- .setMin(0)
- .setMax(255)
- .setId(2);
-
- cp5.addTextfield("n3")
- .setPosition(20, 100)
- .setSize(100, 20)
- .setId(3);
-
-}
-
-void draw() {
- background(ControlP5.MAROON);
- fill(ControlP5.RED, myColorRect1);
- rect(140, 20, 240, 170);
- fill(ControlP5.FUCHSIA, myColorRect2);
- rect(140, 210, 240, 170);
-}
-
-
-void controlEvent(ControlEvent theEvent) {
- println("got a control event from controller with id "+theEvent.getController().getId());
-
- if (theEvent.isFrom(cp5.getController("n1"))) {
- println("this event was triggered by Controller n1");
- }
-
- switch(theEvent.getController().getId()) {
- case(1):
- myColorRect1 = (int)(theEvent.getController().getValue());
- break;
- case(2):
- myColorRect2 = (int)(theEvent.getController().getValue());
- break;
- case(3):
- println(theEvent.getController().getStringValue());
- break;
- }
-}
-
-
-/*
-a list of all methods available for the ControlEvent Controller
-use ControlP5.printPublicMethodsFor(ControlEvent.class);
-to print the following list into the console.
-
-You can find further details about class ControlEvent in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.ControlEvent : ControlGroup getGroup()
-controlP5.ControlEvent : Controller getController()
-controlP5.ControlEvent : String getLabel()
-controlP5.ControlEvent : String getName()
-controlP5.ControlEvent : String getStringValue()
-controlP5.ControlEvent : String toString()
-controlP5.ControlEvent : Tab getTab()
-controlP5.ControlEvent : boolean isAssignableFrom(Class)
-controlP5.ControlEvent : boolean isController()
-controlP5.ControlEvent : boolean isFrom(ControllerInterface)
-controlP5.ControlEvent : boolean isFrom(String)
-controlP5.ControlEvent : boolean isGroup()
-controlP5.ControlEvent : boolean isTab()
-controlP5.ControlEvent : float getArrayValue(int)
-controlP5.ControlEvent : float getValue()
-controlP5.ControlEvent : float[] getArrayValue()
-controlP5.ControlEvent : int getId()
-controlP5.ControlEvent : int getType()
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-created: 2015/03/24 12:22:35
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5controlFont/ControlP5controlFont.pde b/Processing/libraries/controlP5/examples/use/ControlP5controlFont/ControlP5controlFont.pde
deleted file mode 100644
index 35df35c..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5controlFont/ControlP5controlFont.pde
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * ControlP5 controlFont.
- *
- * this example shows how to create a button with controlP5 (1), how to
- * load and use a PFont with controlP5 (2), apply a ControlFont to
- * the caption label of a button (3), and adjust the location of a
- * caption label using the style() property of a controller.
- *
- * by andreas schlegel, 2012
- */
-import controlP5.*;
-
-ControlP5 cp5;
-
-controlP5.Button b;
-
-int buttonValue = 1;
-
-boolean isOpen;
-
-int myColorBackground = color(0,0,0);
-
-
-void setup() {
- size(700,400);
- smooth();
-
- cp5 = new ControlP5(this);
- // (1)
- // create some controllers
- cp5.addButton("button")
- .setValue(10)
- .setPosition(20,20)
- .setSize(100,50)
- .setId(1);
-
- b = cp5.addButton("buttonValue")
- .setValue(4)
- .setPosition(100,190)
- .setSize(200,200)
- .setId(2);
-
- // (2)
- // load a new font. ControlFont is a wrapper for processing's PFont
- // with processing 1.1 ControlFont.setSmooth() is not supported anymore.
- // to display a font as smooth or non-smooth, use true/false as 3rd parameter
- // when creating a PFont:
-
- PFont pfont = createFont("Arial",20,true); // use true/false for smooth/no-smooth
- ControlFont font = new ControlFont(pfont,241);
-
-
-
- // (3)
- // change the font and content of the captionlabels
- // for both buttons create earlier.
- cp5.getController("button")
- .getCaptionLabel()
- .setFont(font)
- .toUpperCase(false)
- .setSize(24)
- ;
-
- b.getCaptionLabel()
- .setFont(font)
- .setSize(50)
- .toUpperCase(false)
- .setText("hello")
- ;
-//
- // (4)
- // adjust the location of a catiption label using the
- // style property of a controller.
- b.getCaptionLabel().getStyle().marginLeft = 20;
- b.getCaptionLabel().getStyle().marginTop = 40;
-
-}
-
-void draw() {
- background(ControlP5.SILVER);
- // animate button b
- float x = b.x(b.getPosition());
- x += ((isOpen==true ? 0:-200) - x) * 0.2;;
- float y = b.y(b.getPosition());
- b.setPosition(x,y);
-}
-
-public void controlEvent(ControlEvent theEvent) {
- println(theEvent.getController().getId());
-}
-
-public void button(float theValue) {
- println("a button event. "+theValue);
- isOpen = !isOpen;
- cp5.getController("button").setCaptionLabel((isOpen==true) ? "close":"open");
-}
-
-
-
-/*
-a list of all methods available for the ControlFont Controller
-use ControlP5.printPublicMethodsFor(ControlFont.class);
-to print the following list into the console.
-
-You can find further details about class ControlFont in the javadoc.
-
-Format:
-ClassName : returnType methodName(parameter type)
-
-
-controlP5.ControlFont : PFont getFont()
-controlP5.ControlFont : int getBaseline()
-controlP5.ControlFont : int getBottom()
-controlP5.ControlFont : int getCenter()
-controlP5.ControlFont : int getHeight()
-controlP5.ControlFont : int getOffset(int)
-controlP5.ControlFont : int getOverflow()
-controlP5.ControlFont : int getSize()
-controlP5.ControlFont : int getTextHeight()
-controlP5.ControlFont : int getTop()
-controlP5.ControlFont : int getWidth()
-controlP5.ControlFont : void adjust(PGraphics, Label)
-controlP5.ControlFont : void draw(ControlP5, Label)
-controlP5.ControlFont : void draw(PGraphics, Label)
-controlP5.ControlFont : void init(Label)
-controlP5.ControlFont : void setSize(int)
-java.lang.Object : String toString()
-java.lang.Object : boolean equals(Object)
-
-created: 2015/03/24 12:22:36
-
-*/
-
-
diff --git a/Processing/libraries/controlP5/examples/use/ControlP5customView/ControlP5customView.pde b/Processing/libraries/controlP5/examples/use/ControlP5customView/ControlP5customView.pde
deleted file mode 100644
index 4db2e6f..0000000
--- a/Processing/libraries/controlP5/examples/use/ControlP5customView/ControlP5customView.pde
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
-* ControlP5 Custom View
-*
-*
-* find a list of public methods available for the ControllerDisplay Controller
-* at the bottom of this sketch.
-*
-* by Andreas Schlegel, 2012
-* www.sojamo.de/libraries/controlp5
-*
-*/
-
-
-import controlP5.*;
-
-
-ControlP5 cp5;
-
-
-void setup() {
- size(400, 400);
- smooth();
- cp5 = new ControlP5(this);
- cp5.addButton("hello")
- .setPosition(50, 100)
- .setSize(150,150)
- .setView(new CircularButton())
- ;
-
- cp5.addButton("world")
- .setPosition(250, 100)
- .setSize(50,50)
- .setView(new CircularButton())
- ;
-}
-
-
-void draw() {
- background(ControlP5.BLACK);
-}
-
-public void hello(int theValue) {
- println("Hello pressed");
-}
-
-public void world(int theValue) {
- println("World pressed");
-}
-
-/**
- * to define a custom View for a controller use the ContollerView interface
- * T here must be replace by the name of the Controller class your custom View will be
- * applied to. In our example T is replace by Button since we are aplpying the View
- * to the Button instance create in setup. The ControllerView interface requires
- * you to implement the display(PApplet, T) method. Same here, T must be replaced by
- * the Controller class you are designing the custom view for, for us this is the
- * Button class.
- */
-
-class CircularButton implements ControllerView