org.mt4j
Class MTApplication

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by processing.core.PApplet
                      extended by org.mt4j.MTApplication
All Implemented Interfaces:
java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, processing.core.PConstants
Direct Known Subclasses:
StartAirHockey, StartDrawExample, StartFiducialExample, StartFlickrExample, StartFluidExample, StartHelloWorld, StartMapsExample, StartModelExample, StartMTGestures, StartMTShell, StartPhysicsExample, StartSceneExample, StartSpaceExample, StartSVGExample, StartTailExample, StartWaterScene

public class MTApplication
extends processing.core.PApplet

    

Use this class to create a new multitouch application.
The best way to create your application would be to extend this class and put the main method into that class. In the main method call the initialize() method. Then override the startUp() method which is called automatically after the initialize method. The startUp() method can be used to create your scenes (extend the AbstractScene class) and add them to the application by calling addScene method.

Internally, the main method of processings PApplet class is called with the class name of the extended PApplet class as an argument. The PApplet class then instantiates the given class and calls its setup() and then repeatedly its run() method.

Author:
Christopher Ruff
See Also:
Serialized Form

Nested Class Summary
static class MTApplication.CurrentClassGetter
          Gets the class name.
 
Nested classes/interfaces inherited from class processing.core.PApplet
processing.core.PApplet.RegisteredMethods, processing.core.PApplet.RendererChangeException
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class processing.core.PApplet
args, ARGS_BGCOLOR, ARGS_DISPLAY, ARGS_EDITOR_LOCATION, ARGS_EXCLUSIVE, ARGS_EXTERNAL, ARGS_HIDE_STOP, ARGS_LOCATION, ARGS_PRESENT, ARGS_SKETCH_FOLDER, ARGS_STOP_COLOR, DEFAULT_HEIGHT, DEFAULT_WIDTH, defaultSize, disposeMethods, dmouseX, dmouseY, drawMethods, emouseX, emouseY, exitCalled, EXTERNAL_MOVE, EXTERNAL_STOP, finished, firstMouse, focused, frame, frameCount, frameRate, frameRateLastNanos, frameRatePeriod, frameRateTarget, g, height, ICON_IMAGE, javaVersion, javaVersionName, key, keyCode, keyEvent, keyEventMethods, keyPressed, loadImageFormats, looping, MENU_SHORTCUT, MIN_WINDOW_HEIGHT, MIN_WINDOW_WIDTH, mouseButton, mouseEvent, mouseEventMethods, mousePressed, mouseX, mouseY, online, parentFrame, pixels, platform, pmouseX, pmouseY, postMethods, preMethods, recorder, redraw, requestImageMax, screen, selectedFile, sizeMethods, sketchPath, width
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MTApplication()
          Dont instiatiate this class directly!
 
Method Summary
 void addAll(Iscene[] scenes)
          Adds all scenes.
 void addScene(Iscene scene)
          Adds the scene to the list of scenes.
 void addSceneChangeListener(ISceneChangeListener listener)
          Adds a scene change listener.
 boolean changeScene(Iscene newScene)
          Changes the scene to the specified scene.
 void destroySceneAfterTransition(Iscene scene)
          Destroy scene after transition.
 void draw()
          ******************************************************************************************** Processings draw() gets called repeatedly by processings PApplet Class - unless noloop() is called ********************************************************************************************.
protected  void fireSceneChangeEvent(SceneChangeEvent sc)
          Fire scene change event.
 Iscene getCurrentScene()
          Gets the currently active scene.
 InputManager getInputManager()
          Gets the input manager.
 Iscene getScene(java.lang.String name)
          Gets the scene by name.
 ISceneChangeListener[] getSceneChangeListener()
          Gets the scene change listeners.
 int getSceneCount()
          Gets the scene count.
 Iscene[] getScenes()
          Gets the registered scenes.
 int getSceneStackCount()
           
static void initialize()
          Initializes the processings settings.
 void invokeLater(java.lang.Runnable runnable)
          Invokes the specified runnable at the beginning the next rendering loop in the rendering thread.
 Iscene peekScene()
          Checks which scene is on top of the scene stack at the moment.
 boolean popScene()
          Pops the scene thats currently ontop of the scene stack and changes back to it.
 void pushScene()
          Pushes the current scene on the scene stack.
 boolean removeScene(Iscene scene)
          Removes the scene from the list of scenes.
 void removeSceneChangeListener(ISceneChangeListener listener)
          Removes the scene change listener.
 void setInputManager(InputManager inputManager)
          Sets the input manager.
 void setP5Context(processing.core.PApplet pa)
          Sets the p5 context.
 void setup()
          *********************************************************** Processings setup. this is called once when the applet is started Used to define some initial settings **********************************************************.
 void startUp()
          Is called at the end of the setup() method.
 
Methods inherited from class processing.core.PApplet
abs, abs, acos, addListeners, alpha, ambient, ambient, ambient, ambientLight, ambientLight, append, append, append, append, append, append, applyMatrix, applyMatrix, applyMatrix, applyMatrix, applyMatrix, arc, arraycopy, arrayCopy, arraycopy, arrayCopy, arraycopy, arrayCopy, asin, atan, atan2, background, background, background, background, background, background, background, beginCamera, beginRaw, beginRaw, beginRecord, beginRecord, beginShape, beginShape, bezier, bezier, bezierDetail, bezierPoint, bezierTangent, bezierVertex, bezierVertex, binary, binary, binary, binary, blend, blend, blendColor, blue, box, box, breakShape, brightness, camera, camera, ceil, checkKeyEvent, checkMouseEvent, checkParentFrame, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, concat, concat, concat, concat, concat, concat, concat, constrain, constrain, copy, copy, cos, createFont, createFont, createFont, createGraphics, createGraphics, createImage, createInput, createInput, createInputRaw, createOutput, createOutput, createPath, createPath, createReader, createReader, createReader, createWriter, createWriter, createWriter, cursor, cursor, cursor, cursor, curve, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, dataFile, dataPath, day, degrees, delay, dequeueKeyEvents, dequeueMouseEvents, destroy, die, die, directionalLight, displayable, dist, dist, edge, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endRaw, endRecord, endShape, endShape, enqueueKeyEvent, enqueueMouseEvent, exec, exit, exp, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, expand, fill, fill, fill, fill, fill, fill, filter, filter, floor, flush, focusGained, focusGained, focusLost, focusLost, frameRate, frustum, get, get, get, getCache, getMatrix, getMatrix, getMatrix, getSketchHeight, getSketchRenderer, getSketchWidth, green, handleDraw, handleKeyEvent, handleMouseEvent, hex, hex, hex, hex, hint, hour, hue, image, image, image, imageMode, init, insertFrame, join, join, keyPressed, keyPressed, keyReleased, keyReleased, keyTyped, keyTyped, lerp, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, line, link, link, loadBytes, loadBytes, loadBytes, loadFont, loadImage, loadImage, loadImageIO, loadImageMT, loadImageTGA, loadPixels, loadShape, loadStrings, loadStrings, loadStrings, log, loop, mag, mag, main, makeGraphics, map, mask, mask, match, matchAll, max, max, max, max, max, max, millis, min, min, min, min, min, min, minute, modelX, modelY, modelZ, month, mouseClicked, mouseClicked, mouseDragged, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressed, mouseReleased, mouseReleased, nf, nf, nf, nf, nfc, nfc, nfc, nfc, nfp, nfp, nfp, nfp, nfs, nfs, nfs, nfs, noCursor, noFill, noise, noise, noise, noiseDetail, noiseDetail, noiseSeed, noLights, noLoop, norm, normal, noSmooth, noStroke, noTint, open, open, openStream, ortho, ortho, paint, paint, param, parseBoolean, parseBoolean, parseBoolean, parseBoolean, parseBoolean, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseByte, parseChar, parseChar, parseChar, parseChar, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseFloat, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, parseInt, perspective, perspective, point, point, pointLight, popMatrix, popStyle, pow, print, print, print, print, print, print, print, printCamera, println, println, println, println, println, println, println, println, printMatrix, printProjection, pushMatrix, pushStyle, quad, radians, random, random, randomSeed, rect, rectMode, red, redraw, registerDispose, registerDraw, registerKeyEvent, registerMouseEvent, registerNoArgs, registerPost, registerPre, registerSize, registerWithArgs, removeCache, requestImage, requestImage, resetMatrix, resizeRenderer, reverse, reverse, reverse, reverse, reverse, reverse, reverse, rotate, rotate, rotateX, rotateY, rotateZ, round, run, saturation, save, saveBytes, saveBytes, saveBytes, saveFile, saveFrame, saveFrame, savePath, saveStream, saveStream, saveStream, saveStrings, saveStrings, saveStrings, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, second, selectFileImpl, selectFolder, selectFolder, selectInput, selectInput, selectOutput, selectOutput, set, set, setCache, setMatrix, setMatrix, setMatrix, setupExternalMessages, setupFrameResizeListener, shape, shape, shape, shapeMode, shininess, shorten, shorten, shorten, shorten, shorten, shorten, shorten, sin, size, size, size, sketchFile, sketchPath, smooth, sort, sort, sort, sort, sort, sort, sort, sort, sort, sort, specular, specular, specular, sphere, sphereDetail, sphereDetail, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, splice, split, split, splitTokens, splitTokens, spotLight, sq, sqrt, start, status, stop, str, str, str, str, str, str, str, str, str, str, stroke, stroke, stroke, stroke, stroke, stroke, strokeCap, strokeJoin, strokeWeight, style, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, subset, tan, text, text, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textAscent, textDescent, textFont, textFont, textLeading, textMode, textSize, texture, textureMode, textWidth, textWidth, tint, tint, tint, tint, tint, tint, translate, translate, triangle, trim, trim, unbinary, unhex, unregisterDispose, unregisterDraw, unregisterKeyEvent, unregisterMouseEvent, unregisterNoArgs, unregisterPost, unregisterPre, unregisterSize, unregisterWithArgs, update, updatePixels, updatePixels, vertex, vertex, vertex, vertex, vertex, year
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MTApplication

public MTApplication()
Dont instiatiate this class directly! It gets instantiated by the PApplet class via java reflection.

Method Detail

initialize

public static void initialize()
Initializes the processings settings. Call this method in your main method prior to anything else!


setP5Context

public void setP5Context(processing.core.PApplet pa)
Sets the p5 context.

Parameters:
pa - the new p5 context

setup

public void setup()
*********************************************************** Processings setup. this is called once when the applet is started Used to define some initial settings **********************************************************.

Overrides:
setup in class processing.core.PApplet

draw

public void draw()
******************************************************************************************** Processings draw() gets called repeatedly by processings PApplet Class - unless noloop() is called ********************************************************************************************.

Overrides:
draw in class processing.core.PApplet

startUp

public void startUp()
Is called at the end of the setup() method.
Override this method in your extended MTApplication class!


invokeLater

public void invokeLater(java.lang.Runnable runnable)
Invokes the specified runnable at the beginning the next rendering loop in the rendering thread. This is especially useful for executing opengl commands from another thread - which would lead to errors if not synchronized with the rendering thread.

Parameters:
runnable - the runnable

peekScene

public Iscene peekScene()
Checks which scene is on top of the scene stack at the moment. If no scene has been pushed on the stack, null is returned.

Returns:
the iscene

getSceneStackCount

public int getSceneStackCount()

pushScene

public void pushScene()
Pushes the current scene on the scene stack.


popScene

public boolean popScene()
Pops the scene thats currently ontop of the scene stack and changes back to it. If the stack is empty no error is thrown and no scene change will happen.


changeScene

public boolean changeScene(Iscene newScene)
Changes the scene to the specified scene.

NOTE: This is not threadsafe while using OpenGL mode. If in openGL mode make, sure to call this only from the same thread. If running in a different thread, execute the scene change using the invokeLater(Runnable runnable) method of the MTApplication instance!

NOTE: If the scene is not already added to the application by invoking addScene(), the scene is automatically added to the mtapplication.

Parameters:
newScene - the new scene

getCurrentScene

public Iscene getCurrentScene()
Gets the currently active scene.

Returns:
the current scene

addScene

public void addScene(Iscene scene)
Adds the scene to the list of scenes. Also changes to that scene if it is the first one to be added.

Parameters:
scene - the scene

addAll

public void addAll(Iscene[] scenes)
Adds all scenes.

Parameters:
scenes - the scenes

removeScene

public boolean removeScene(Iscene scene)
Removes the scene from the list of scenes. Fails if the scene is the currently active scene. If the scene isnt going to be used anymore, calling the scene's destroy() method is the better choice than the removeScene method alone.

Parameters:
scene - the scene

destroySceneAfterTransition

public void destroySceneAfterTransition(Iscene scene)
Destroy scene after transition. Workaround so that if a scene's destroy() method is called but the scene is in a transition (cant be removed then) we call destroy on the scene after the transition. Only has an impact if there is a pending transition with the specified scene as the last scene.

Parameters:
scene - the scene

getScenes

public Iscene[] getScenes()
Gets the registered scenes.

Returns:
the scenes

getScene

public Iscene getScene(java.lang.String name)
Gets the scene by name.

Parameters:
name - the name
Returns:
the scene

getSceneCount

public int getSceneCount()
Gets the scene count.

Returns:
the scene count

getInputManager

public InputManager getInputManager()
Gets the input manager.

Returns:
the input manager

setInputManager

public void setInputManager(InputManager inputManager)
Sets the input manager.

Parameters:
inputManager - the new input manager

fireSceneChangeEvent

protected void fireSceneChangeEvent(SceneChangeEvent sc)
Fire scene change event.

Parameters:
sc - the sc

addSceneChangeListener

public void addSceneChangeListener(ISceneChangeListener listener)
Adds a scene change listener.

Parameters:
listener - the listener

removeSceneChangeListener

public void removeSceneChangeListener(ISceneChangeListener listener)
Removes the scene change listener.

Parameters:
listener - the listener

getSceneChangeListener

public ISceneChangeListener[] getSceneChangeListener()
Gets the scene change listeners.

Returns:
the scene change listeners