public class KTGUI extends Object implements def.processing.core.PConstants
In order to separate the two types of the said codes, we can use the ability of the Processing library to 'register'
some of its 'specific' methods in the external class. To register the 'specific' methods in the external class,
the PApplet uses the registerMethod(String methodName, PApplet parentPApplet) method. After these methods
were being registered, they will be executed at a particular moments of the 'main' code execution allowing to
'synchronize' the execution of the 'main' code with the execution of the particular methods of the external class.
(More detailed information can be found in the Processing's
documentation here).
The full list of these 'specific' methods can be found here. We will be registering (in the external class) and using for separating the code only the following three methods:
public void draw() Method that's called at the end of the PApplet's draw() method.public void mouseEvent(MouseEvent e) Method that's called when a mouse event occurs in the parent PApplet.
Drawing inside this method is allowed because mouse events are queued, unless the sketch has called noLoop().public void keyEvent(KeyEvent e) Method that's called when a key event occurs in the parent PApplet.
Drawing is allowed because key events are queued, unless the sketch has called noLoop().| Modifier and Type | Field and Description |
|---|---|
static int |
COLOR_BG_HOVERED |
static int |
COLOR_BG_PASSIVE |
static int |
COLOR_BG_PRESSED |
static int |
COLOR_FG_HOVERED |
static int |
COLOR_FG_PASSIVE |
static int |
COLOR_FG_PRESSED |
static int |
DEFAULT_ALIGN_GAP |
static int |
DEFAULT_COMPONENT_WIDTH |
static int |
DEFAULT_ROUNDING |
ArrayList<String> |
drawCallStack |
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z| Constructor and Description |
|---|
KTGUI(def.processing.core.PApplet pa)
This is a constructor of the KTGUI class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDrawCallStackDebugMessage(String msg) |
void |
addToGarbage(Controller controller,
int millis) |
Button |
createButton(int x,
int y,
int w,
int h) |
Button |
createButton(String title,
int x,
int y,
int w,
int h) |
ArrowButton |
createDirectionButton(int x,
int y,
int w,
int h,
int dir) |
ArrowButton |
createDirectionButton(String title,
int x,
int y,
int w,
int h,
int dir) |
InputTextBox |
createInputTextBox(int x,
int y,
int w,
int h) |
InputTextBox |
createInputTextBox(String title,
int x,
int y,
int w,
int h) |
Pane |
createPane(int x,
int y,
int w,
int h) |
Pane |
createPane(String title,
int x,
int y,
int w,
int h) |
Panel |
createPanel(int x,
int y,
int w,
int h) |
Panel |
createPanel(String title,
int x,
int y,
int w,
int h) |
ScrollBar |
createScrollBar(int x,
int y,
int w,
int h,
int sr,
int er) |
ScrollBar |
createScrollBar(String title,
int x,
int y,
int w,
int h,
int sr,
int er) |
Slider |
createSlider(int posx,
int posy,
int w,
int h,
int sr,
int er) |
Slider |
createSlider(String title,
int posx,
int posy,
int w,
int h,
int sr,
int er) |
static void |
debug(String string) |
void |
draw()
This method is intended to be called automatically at the end of each draw() cycle of the parent PApplet.
|
static def.processing.core.PApplet |
getParentPApplet() |
void |
keyEvent(def.processing.event.KeyEvent e)
This method 'redirects' the emitted keyboard event from PApplet to KTGUI 'transfer' methods.
|
void |
mouseEvent(def.processing.event.MouseEvent e)
This method 'redirects' the emitted mouse event from PApplet to KTGUI 'transfer' methods.
|
void |
setDrawCallStackFlag(boolean debug) |
public static int COLOR_FG_HOVERED
public static int COLOR_FG_PRESSED
public static int COLOR_FG_PASSIVE
public static int COLOR_BG_HOVERED
public static int COLOR_BG_PASSIVE
public static int COLOR_BG_PRESSED
public static int DEFAULT_COMPONENT_WIDTH
public static int DEFAULT_ALIGN_GAP
public static int DEFAULT_ROUNDING
public KTGUI(def.processing.core.PApplet pa)
public static def.processing.core.PApplet getParentPApplet()
public void draw()
public void setDrawCallStackFlag(boolean debug)
public void addDrawCallStackDebugMessage(String msg)
public void addToGarbage(Controller controller, int millis)
public Button createButton(int x, int y, int w, int h)
public ArrowButton createDirectionButton(String title, int x, int y, int w, int h, int dir)
public ArrowButton createDirectionButton(int x, int y, int w, int h, int dir)
public Slider createSlider(String title, int posx, int posy, int w, int h, int sr, int er)
public Slider createSlider(int posx, int posy, int w, int h, int sr, int er)
public Panel createPanel(int x, int y, int w, int h)
public Pane createPane(int x, int y, int w, int h)
public ScrollBar createScrollBar(int x, int y, int w, int h, int sr, int er)
public ScrollBar createScrollBar(String title, int x, int y, int w, int h, int sr, int er)
public InputTextBox createInputTextBox(String title, int x, int y, int w, int h)
public InputTextBox createInputTextBox(int x, int y, int w, int h)
public void mouseEvent(def.processing.event.MouseEvent e)
public void keyEvent(def.processing.event.KeyEvent e)
public static void debug(String string)