|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.tmachine.gpg.hue.BaseHUD
net.tmachine.gpg.hue.ShapeShifter2
Simple HUD which displays a "your mouse cursor is currently floating over THIS shape" selection-box style thing, and includes a tool which will allow you to drag shapes around the document, even multiple shapes at once (if they overlap and can be dragged in a single gesture).
Not very user-friendly, but a basic example.
Note how it uses the ContextManager to find out the cursor position, and uses that to decide which shapes are currently under the cursor; this is instead of listening to all input events. It would be possible to split this HUD into it's rendering and tool components and have the input part ignoring the cursor position inside/outside shapes (using some abstracted concept of "selected shape" in the ContextManager) and have the display part not needing any information on input events, instead deriving cursor co-ords indirectly from the context, as it does now.
| Field Summary | |
protected int |
lastx
Co-ords where a drag-translate was last updated (so we can work out how far to shift it) |
protected int |
lasty
Co-ords where a drag-translate was last updated (so we can work out how far to shift it) |
protected java.util.ArrayList |
movingObjects
|
protected int |
sx
Co-ords where a drag-translate was started |
protected int |
sy
Co-ords where a drag-translate was started |
| Fields inherited from class net.tmachine.gpg.hue.BaseHUD |
isActive, isVisible, manager, name |
| Constructor Summary | |
ShapeShifter2()
|
|
| Method Summary | |
void |
mouseDragged(java.awt.event.MouseEvent e)
Compares the mouse cursor position to it's last known position, and translates all "currently being moved" shapes by the same relative distance |
void |
mousePressed(java.awt.event.MouseEvent e)
Finds all shapes under the mouse cursor, and flags them internally as being "currently being moved" |
void |
paint(java.awt.Graphics g)
If this HUD is visible, it will be asked to paint to the supplied display surface during repaints |
| Methods inherited from class net.tmachine.gpg.hue.BaseHUD |
getName, isActive, isActive, isVisible, isVisible, mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseReleased, setManager, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.ArrayList movingObjects
protected int sx
protected int sy
protected int lastx
protected int lasty
| Constructor Detail |
public ShapeShifter2()
| Method Detail |
public void paint(java.awt.Graphics g)
HUD
g - public void mousePressed(java.awt.event.MouseEvent e)
A mouse press over an empty area will clear the "currently being moved" list
mousePressed in interface java.awt.event.MouseListenermousePressed in class BaseHUDmouseDragged(MouseEvent)public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenermouseDragged in class BaseHUDmousePressed(MouseEvent)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||