|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.event.KeyAdapter jpicedt.graphic.toolkit.MouseTool
public abstract class MouseTool
An implementation of PEMouseInputListener that factors common behaviour for EditorKit's mouse tools, and implements KeyListener so that mouse-tools can also listen to key events (e.g. to update cursor,…)
This implementation offers a convenient mechanism for generating MouseMoved
events as a result of a KeyPressed/KeyReleased event. If this behaviour is
to be preserved, subclassers should either call
super.mouseXXX()
before all in their own implementation of the
corresponding methods, or alternately simply add the following line of
code: lastMouseEvent=e
, where e
denotes the
mouse-event parameter.
Besides, this class provide a "paint" method which, like Element's, allows the tool to draw shapes (on the associated PECanvas) that are specific to this tool.
Nested Class Summary | |
---|---|
static class |
MouseTool.MouseToolType
|
Field Summary | |
---|---|
protected static PEMouseEvent |
lastMouseEvent
this field remembers the last mouse-event produced by a call to one of the mouseXXX methods shared by every MouseTool |
protected boolean |
mouseOutside
this flag is set to true/false whenever a mouseExited/Entered event is caught. |
Constructor Summary | |
---|---|
MouseTool()
|
Method Summary | |
---|---|
void |
flush()
called when this tool is being replaced by another mouse-tool in the hosting editor kit ; this is mainly for mousetools using more than one sequence, for it gives them a chance to clean themselves up for the next time |
PEMouseEvent |
getLastMouseEvent()
Returns the last mouse-event as produced by the last invokation of a mouseXXX method |
void |
init()
called when this tool is being activated in the hosting editor kit ; this is mainly for mousetools that need to do some initialization work before any mouse-event occurs. |
void |
keyPressed(KeyEvent ke)
Triggers a fake "mouseMoved" event when a key is pressed. |
void |
keyReleased(KeyEvent ke)
Triggers a fake "mouseMoved" event when a key is released. |
void |
mouseClicked(PEMouseEvent e)
this default implementation simply stores the given mouse-event in lastMouseEvent field |
void |
mouseDragged(PEMouseEvent e)
this default implementation simply stores the given mouse-event in lastMouseEvent field |
void |
mouseEntered(PEMouseEvent e)
Sets the mouseOutside flag to true, stores the given mouse-event in lastMouseEvent field,
and request focus on the PECanvas that dispatched this mouse event. |
void |
mouseExited(PEMouseEvent e)
Sets the mouseOutside flag to false, and stores the given mouse-event in lastMouseEvent
field. |
void |
mouseMoved(PEMouseEvent e)
this default implementation simply stores the given mouse-event in lastMouseEvent field |
void |
mousePressed(PEMouseEvent e)
this default implementation simply stores the given mouse-event in lastMouseEvent field |
void |
mouseReleased(PEMouseEvent e)
this default implementation simply stores the given mouse-event in lastMouseEvent field |
void |
paint(Graphics2D g,
Rectangle2D allocation,
double scale)
Allow the tool to paint shapes that are specific to this tool. |
protected void |
processKeyEvent(KeyEvent ke,
boolean pressed)
Triggers a fake "mouseMoved" event if a key is pressed or released, with the adequate key modifiers ; this is a "lazy" handling of key-events which delegates to the mouse-handler. |
Methods inherited from class java.awt.event.KeyAdapter |
---|
keyTyped |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean mouseOutside
protected static PEMouseEvent lastMouseEvent
MouseTool
Constructor Detail |
---|
public MouseTool()
Method Detail |
---|
public void mousePressed(PEMouseEvent e)
lastMouseEvent
field
mousePressed
in interface PEMouseInputListener
public void mouseReleased(PEMouseEvent e)
lastMouseEvent
field
mouseReleased
in interface PEMouseInputListener
public void mouseClicked(PEMouseEvent e)
lastMouseEvent
field
mouseClicked
in interface PEMouseInputListener
public void mouseMoved(PEMouseEvent e)
lastMouseEvent
field
mouseMoved
in interface PEMouseInputListener
public void mouseDragged(PEMouseEvent e)
lastMouseEvent
field
mouseDragged
in interface PEMouseInputListener
public PEMouseEvent getLastMouseEvent()
public void mouseEntered(PEMouseEvent e)
lastMouseEvent
field,
and request focus on the PECanvas that dispatched this mouse event.
mouseEntered
in interface PEMouseInputListener
public void mouseExited(PEMouseEvent e)
lastMouseEvent
field.
mouseExited
in interface PEMouseInputListener
public void paint(Graphics2D g, Rectangle2D allocation, double scale)
public void init()
public void flush()
public void keyPressed(KeyEvent ke)
processKeyEvent(java.awt.event.KeyEvent, boolean)
.
keyPressed
in interface KeyListener
keyPressed
in class KeyAdapter
public void keyReleased(KeyEvent ke)
processKeyEvent(java.awt.event.KeyEvent, boolean)
.
keyReleased
in interface KeyListener
keyReleased
in class KeyAdapter
protected void processKeyEvent(KeyEvent ke, boolean pressed)
pressed
- if TRUE, process a keyPressed event, else process a keyReleased
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |