mkv.MyGUI
Class MyGUI

java.lang.Object
  extended bymkv.MyGUI.MyGUIObject
      extended bymkv.MyGUI.MyGUIGroup
          extended bymkv.MyGUI.MyGUI

public class MyGUI
extends MyGUIGroup

Controller object that registers Draw, Mouse and Key events with PApplet.

Since the introduction of MyGUIGroup, most the code from MyGUI has been stripped out to the extent where I decided that MyGUI should now extend MyGUIGroup to regain the same level of functionality.

So, the MyGUI controller is infact a fancy version of a MyGUIGroup. That is besides from containing other MyGUI elements as the root of the hierarchy it also has the important task of registering its methods with the parent PApplet so that it, and all its children will respond to mouse and key events as well as automatically drawing them selves to the screen.

Version:
0008
Author:
John Beech
See Also:
MyGUIGroup

Field Summary
 
Fields inherited from class mkv.MyGUI.MyGUIGroup
_actionCommand, _disabled, _height, _id, _root, _rotation, _scale, _style, _visible, _width, _x, _y, customMouse, dragged, hover, lastHover, tmouseX, tmouseY
 
Constructor Summary
MyGUI(processing.core.PApplet parent)
          Default class constructor.
MyGUI(processing.core.PApplet parent, int size)
          Class constructor where the size of the element array can be specified.
MyGUI(processing.core.PApplet parent, int size, MyGUIStyle style)
          Class constructor where the size of the element array can be specified as well as a reference to a MyGUIStyle object.
MyGUI(processing.core.PApplet parent, MyGUIStyle style)
          Class constructor with a reference to a custom MyGUIStyle object.
 
Method Summary
 boolean isDisabled()
          Returns the enabled or disabled state of this object.
 void keyEvent(java.awt.event.KeyEvent e)
          Recalls Key events based on type.
 void mouseEvent(java.awt.event.MouseEvent e)
          Recalls Mouse events based on type.
 void updateLocalMouse()
          Updates local mouse coordinates tmouseX and tmouseY.
 
Methods inherited from class mkv.MyGUI.MyGUIGroup
add, checkForHit, disable, draw, drawStates, enable, get, getFocused, getFocusIndex, getStyle, hasFocus, isDragged, isEmpty, isFull, keyPressed, keyReleased, keyTyped, mouseDragged, mousePressed, mouseReleased, normalize, remove, rotate, rotateRadians, setActionCommand, setID, setMouseCoords, setParent, setStyle, useCustomMouse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyGUI

public MyGUI(processing.core.PApplet parent)
Default class constructor. The default size of the element array will be set to 25, and have x,y coordinates 0,0. This constructor registers Draw, MouseEvent and KeyEvent with the parent processing PApplet.

Parameters:
parent - the processing PApplet where all elements will be drawn to

MyGUI

public MyGUI(processing.core.PApplet parent,
             int size)
Class constructor where the size of the element array can be specified. The x,y coordinates will be set to 0,0. This constructor registers Draw, MouseEvent and KeyEvent with the parent processing PApplet.

Parameters:
parent - the processing PApplet where all elements will be drawn to
size - size of element array. The default size is 25.

MyGUI

public MyGUI(processing.core.PApplet parent,
             int size,
             MyGUIStyle style)
Class constructor where the size of the element array can be specified as well as a reference to a MyGUIStyle object. Alternatively you can call one of the above default constructors and then use MyGUI.getStyle() to return the current style in use and modify it from there.

Parameters:
parent - the processing PApplet where all elements will be drawn to
size - size of element array. The default size is 25.
style - the style object used by all MyGUI elements when they draw themselves

MyGUI

public MyGUI(processing.core.PApplet parent,
             MyGUIStyle style)
Class constructor with a reference to a custom MyGUIStyle object. Alternatively you can call one of the above default constructors and then use MyGUI.getStyle() to return the current style in use and modify it from there.

Parameters:
parent - the processing PApplet where all elements will be drawn to
style - the style object used by all MyGUI elements when they draw themselves
Method Detail

mouseEvent

public void mouseEvent(java.awt.event.MouseEvent e)
Recalls Mouse events based on type. This method will recall mousePressed, mouseReleased and mouseDragged events when a MouseEvent is detected in the parent PApplet.


keyEvent

public void keyEvent(java.awt.event.KeyEvent e)
Recalls Key events based on type. This method will recall keyPressed, keyReleased and keyTyped events when a KeyEvent is detected in the parent PApplet.


isDisabled

public boolean isDisabled()
Returns the enabled or disabled state of this object. Because MyGUI objects do not have MyGUIObject parents, this method overides the MyGUIObject version.

Overrides:
isDisabled in class MyGUIObject
Returns:
returns true if the object is disabled, false if it is enabled
See Also:
MyGUIObject._disabled

updateLocalMouse

public void updateLocalMouse()
Updates local mouse coordinates tmouseX and tmouseY. Taken from the check for hit code, this calculates the local mouse coordinates after translation, rotation and scaling.

Because the MyGUI controller is considered a parent object that sits above all others then it has a customized updateLocalMouse() method that uses PApplet mouseX, mouseY instead of _parent.tmouseX, _parent.tmouseY.

Overrides:
updateLocalMouse in class MyGUIGroup
See Also:
MyGUIGroup.useCustomMouse(boolean), MyGUIGroup.setMouseCoords(int, int), MyGUIObject.checkForHit()