|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmkv.MyGUI.MyGUIObject
mkv.MyGUI.MyGUIGroup
A non visible grouping object that contains other MyGUI elements. MyGUIGroup allows objects to be grouped so that they can be moved, rotated, enabled, disabled and hidden as a group. MyGUIGroup objects difer from traditional Panel objects because they have no width or height, and so do not crop objects that are out of bounds.
Objects placed in the group will be translated, rotated, and scaled before their own draw methods are called. MyGUIGroup also holds the responsibility of passing Mouse and Key events to members of the group. Part of this involves filtering events based on states such as _disabled and _visible. In other words, it only passes Key and Mouse events to objects which are visible and not disabled.
MyGUIGroup plays a larger role in the sense that the MyGUI object inherits many of its methods from the MyGUIGroup class. Originally it was the case that the code from MyGUI was used to build MyGUIGroup but this was obviously leading to a lot of redundancy.
MyGUIObject,
MyGUI| Field Summary | |
java.lang.String |
_actionCommand
Description attached to an ActionEvent generated by the component. |
boolean |
_disabled
Used to block mouse and key events. |
int |
_height
Used to define the bounding box of an object. |
int |
_id
The id used to self check if the object has focus. |
MyGUIObject |
_parent
The MyGUIObject which acts as the parent of this object. |
processing.core.PApplet |
_root
A direct reference to the main processing PApplet. |
float |
_rotation
The value in degrees defining the object rotation. |
float |
_scale
Visual scale of the object. |
MyGUIStyle |
_style
A reference to a MyGUIStyle object used in draw or for font metrics. |
boolean |
_visible
The visibility and active state of the object. |
int |
_width
Used to define the bounding box of an object. |
int |
_x
Positional coordinate of the object. |
int |
_y
Positional coordinate of the object. |
protected boolean |
customMouse
State if user wants to use custom mouse coordinates |
protected boolean |
dragged
State where mouse is clicked and dragged across object. |
protected boolean |
hover
State where mouse hovers over object. |
protected boolean |
lastHover
State that changes when as a mouse moved outside bounding box. |
int |
tmouseX
Local mouse coordinate based on parent. |
int |
tmouseY
Local mouse coordinate based on parent. |
| Constructor Summary | |
MyGUIGroup(processing.core.PApplet root,
int x,
int y)
Default class constructor. |
|
MyGUIGroup(processing.core.PApplet root,
int x,
int y,
int size)
Class constructor where the size of the element array can be specified. |
|
MyGUIGroup(processing.core.PApplet root,
int x,
int y,
int size,
MyGUIStyle style)
Class constructor where you can specify the size of the element array and set the style. |
|
MyGUIGroup(processing.core.PApplet root,
int x,
int y,
MyGUIStyle style)
Class constructor where you can specify the style but the element array stays at its default value. |
|
| Method Summary | |
int |
add(MyGUIObject newElement)
Adds a compatable MyGUI object as a child. |
boolean |
checkForHit()
Defines the bounding box or 'hitzone' and returns true if the mouse is in contact. |
void |
disable()
Disables this object so that it not longer receives mouse or keyboard events. |
void |
draw()
Registered method that tells its children to draw. |
void |
drawStates()
Interface method called by draw(). |
void |
enable()
Activates this object so it is able to receive mouse and keyboard events. |
MyGUIObject |
get(int index)
Return an object based on the supplied index or id. |
MyGUIObject |
getFocused()
Returns a reference to the MyGUIObject that currently has focus. |
int |
getFocusIndex()
Returns the id/index of the currently focused element. |
MyGUIStyle |
getStyle()
Returns the currently assigned style. |
boolean |
hasFocus()
Returns true if the object has focus. |
boolean |
isDisabled()
Checks the _disabled variable and its parent. |
boolean |
isDragged()
Returns constant state of mouse clicked compared to this object. |
boolean |
isEmpty()
Returns true if there are no elements in the group. |
boolean |
isFull()
Returns true if the element array is full. |
void |
keyPressed(java.awt.event.KeyEvent e)
Notifies the focus child of the keyPressed event. |
void |
keyReleased(java.awt.event.KeyEvent e)
Notifies the focus child of the keyReleased event. |
void |
keyTyped(java.awt.event.KeyEvent e)
Notifies the focus child of the keyTyped event. |
void |
mouseDragged()
Notifies children of the mouseDragged event. |
void |
mousePressed()
Notifies children of the mousePressed event. |
void |
mouseReleased()
Notifies children of the mouseReleased event. |
protected float |
normalize(float n,
float min,
float max)
Normalization function that ensures a value always lies within min/max. |
void |
remove(int id)
Removes an element by its id. |
void |
rotate(float degs)
Increases/decreases the _rotation attribute by the supplied amount. |
void |
rotateRadians(float rads)
Increases/decreases the _rotation attribute by the given amount. |
void |
setActionCommand(java.lang.String command)
Sets the descriptive action command when an ActionEvent is generated. |
void |
setID(int newID)
Sets the unique id to the specified integer. |
void |
setMouseCoords(int x,
int y)
Allows the user to specify custom mouse coordinates. |
void |
setParent(MyGUIObject parent)
Tells the object who its parent is. |
void |
setStyle(MyGUIStyle style)
Sets the style of an object after initilisation. |
void |
updateLocalMouse()
Calculates the local relative mouse coordinates. |
void |
useCustomMouse(boolean mode)
Tells MyGUI that you want to use custom mouse coordinates. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected boolean customMouse
public processing.core.PApplet _root
public MyGUIObject _parent
MyGUIObject.setParent(MyGUIObject parent)public MyGUIStyle _style
public int _x
MyGUIObject._rotation,
MyGUIObject._scale,
MyGUIObject._width,
MyGUIObject._heightpublic int _y
MyGUIObject._rotation,
MyGUIObject._scale,
MyGUIObject._width,
MyGUIObject._heightpublic int _width
MyGUIObject._width,
MyGUIObject._height,
MyGUIObject._x,
MyGUIObject._y,
MyGUIObject.checkForHit()public int _height
MyGUIObject._width,
MyGUIObject._height,
MyGUIObject._x,
MyGUIObject._y,
MyGUIObject.checkForHit()public int _id
MyGUIObject.hasFocus(),
MyGUIGrouppublic float _rotation
MyGUIObject.rotate(float),
MyGUIObject.rotateRadians(float)public float _scale
public boolean _visible
MyGUIObject._disabledpublic boolean _disabled
MyGUIObject._visible,
MyGUIStyle.disabledpublic java.lang.String _actionCommand
MyGUIActionEvent,
MyGUIObject.setActionCommand(String)public int tmouseX
MyGUIObject.updateLocalMouse()public int tmouseY
MyGUIObject.updateLocalMouse()protected boolean dragged
MyGUIObject.isDragged()protected boolean hover
MyGUIObject.checkForHit(),
MyGUIObject.lastHoverprotected boolean lastHover
MyGUIObject.hover,
MyGUIObject.dragged,
MyGUIButton| Constructor Detail |
public MyGUIGroup(processing.core.PApplet root,
int x,
int y)
root - a direct reference to the main processing PApplet.x - x coordinate of the groupy - y coordinate of the group
public MyGUIGroup(processing.core.PApplet root,
int x,
int y,
int size)
root - a direct reference to the main processing PApplet.x - x coordinate of the groupy - y coordinate of the groupsize - size of the element array. The default size is 25.
public MyGUIGroup(processing.core.PApplet root,
int x,
int y,
int size,
MyGUIStyle style)
root - a direct reference to the main processing PApplet.x - x coordinate of the groupy - y coordinate of the groupsize - size of the element array. The default size is 25.style - personalized style for this object and its children
public MyGUIGroup(processing.core.PApplet root,
int x,
int y,
MyGUIStyle style)
root - a direct reference to the main processing PApplet.x - x coordinate of the groupy - y coordinate of the groupstyle - personalized style for this object and its children| Method Detail |
public int add(MyGUIObject newElement)
When adding a new element, add first checks to see if there are any null entries in the element array caused by sudden removals. If one is found this will be used first. If there were no null elements and the number of elements is less then the size of the array, then the new element will be added first available place before the end of the array. If there are no spaces left in the array, this method will return -1.
When an object has been successfully added, the setParent() and setID() methods are called in the new object passing information down the hierarchy from parent to child.
newElement - A reference to the MyGUIObject to be added to the group.
remove(int),
MyGUIObject.setParent(MyGUIObject),
MyGUIObject.setID(int)public void remove(int id)
id - The id of the element to be removed.MyGUIObject._visible,
add(MyGUIObject)public void setStyle(MyGUIStyle style)
setStyle in class MyGUIObjectstyle - A reference to the new personalized style.MyGUIStyle,
MyGUIObject._stylepublic void useCustomMouse(boolean mode)
mode - Set true to use custom mouse. Set false to use parental mouse coordinates.setMouseCoords(int, int),
updateLocalMouse()
public void setMouseCoords(int x,
int y)
x - the x coordinate of the mouse relative to this shapey - the y coordinate of the mouse relative to this shapepublic MyGUIObject getFocused()
get(int),
getFocusIndex()public int getFocusIndex()
getFocusIndex in class MyGUIObjectgetFocused(),
get(int)public MyGUIObject get(int index)
index - the index or id of the object when it was added to the element array.
getFocused(),
getFocusIndex()public boolean isEmpty()
isFull()public boolean isFull()
isEmpty(),
remove(int)public void mousePressed()
The method first filters based on the _visible and _disabled states. If either of these are true then no action will be taken, stopping the child elements from receiving this event.
The focus index is cleared, set to -1. It then loops backwards through the element array calling checkForHit() on each element and testing _disabled and _visible for each object. If checkForHit() is true, and the element is not disabled and is visible then the element will be given focus and the loop stopped. Only one element may have focus.
The array is looped through again this time to pass the mousePressed() call onto all the visible and active children. This is required so objects know when the mouse has been released outside their boundary.
mousePressed in class MyGUIObjectMyGUIObject.mousePressed(),
MyGUIObject.checkForHit(),
MyGUIObject._visible,
MyGUIObject._disabledpublic void mouseReleased()
mouseReleased in class MyGUIObjectMyGUIObject.mouseReleased(),
MyGUIObject._visible,
MyGUIObject._disabledpublic void mouseDragged()
mouseDragged in class MyGUIObjectMyGUIObject.mouseDragged(),
MyGUIObject._visible,
MyGUIObject._disabledpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in class MyGUIObjectMyGUIObject.keyPressed(KeyEvent),
KeyEventpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in class MyGUIObjectMyGUIObject.keyReleased(KeyEvent),
KeyEventpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in class MyGUIObjectMyGUIObject.keyTyped(KeyEvent),
KeyEventpublic void draw()
draw in class MyGUIObjectupdateLocalMouse()public void updateLocalMouse()
This only applies if customMouse state is not set to true. If it is set, tmouseX and tmouseY are not updated and instead values used/set by setMouseCoords().
updateLocalMouse in class MyGUIObjectuseCustomMouse(boolean),
setMouseCoords(int, int),
MyGUIObject.checkForHit()public boolean hasFocus()
MyGUIObject.getFocusIndex(),
getFocusIndex(),
MyGUIObject._idpublic boolean isDisabled()
MyGUIObject._disabledpublic boolean isDragged()
MyGUIObject.hover,
MyGUIObject.mousePressed(),
MyGUIObject.hasFocus()public void drawStates()
MyGUIStyle,
MyGUIObject.draw(),
MyGUIObject._disabled,
MyGUIObject.hasFocus(),
MyGUIObject.hover,
MyGUIObject.draggedpublic void setID(int newID)
newID - The new ID of the object.MyGUIObject._id,
MyGUIObject.hasFocus(),
MyGUIObject.getFocusIndex()public void setParent(MyGUIObject parent)
parent - the parent MyGUIObject of this object. Usually a MyGUIGroup object.MyGUIGrouppublic void setActionCommand(java.lang.String command)
command - The string value used to identify this action command.MyGUIActionEvent,
MyGUIObject._actionCommandpublic void enable()
MyGUIObject.disable(),
MyGUIObject._disabledpublic void disable()
MyGUIObject.enable(),
MyGUIObject._disabledpublic void rotate(float degs)
degs - the value in degrees to alter the rotation byMyGUIObject._rotation,
MyGUIObject.rotateRadians(float),
MyGUIObject.normalize(float, float, float)public void rotateRadians(float rads)
rads - the value in radiands to alter the rotation byMyGUIObject._rotation,
MyGUIObject.rotate(float),
MyGUIObject.normalize(float, float, float)
protected float normalize(float n,
float min,
float max)
n - the number you want to normalizemin - the minimum boundary valuemax - the maximum boundary value
public boolean checkForHit()
This default checkForHit methods checks the bounding box of a shape (-width/2, _y-width/2, _width/2, _height/2) taking into account when rotatation and scale.
MyGUIObject._width,
MyGUIObject._height,
MyGUIObject.updateLocalMouse()public MyGUIStyle getStyle()
MyGUIStyle,
MyGUIObject.setStyle(MyGUIStyle),
MyGUIObject._style
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||