|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.interactor.AbstractInteractor
ptolemy.domains.gr.lib.FigureInteractor
public class FigureInteractor
Listen for and handle events on a Diva figure. Because Diva figures are not derived from Java's component class, implementing a key listener directly would be problematic. Instead, this class must be made aware of the ViewScreen2D object that contains the figure, as the ViewScreen2D object will forward all keyboard events that occur on a selected figure to this listener. When initially adding a figure to the view screen, the view screen must call the setViewScreen() method of the figure with a reference to itself as the parameter.
Red (cxh) |
Yellow (ismael) |
Field Summary | |
---|---|
private JCanvas |
_canvas
|
private AbstractFigure |
_figure
|
private boolean |
_isSelected
|
private ViewScreen2D |
_viewScreen
|
private double |
dragPointX
|
private double |
dragPointY
|
Constructor Summary | |
---|---|
FigureInteractor(AbstractFigure figure)
Construct a FigureInteractor for the given figure. |
Method Summary | |
---|---|
boolean |
isSelected()
Return whether or not a figure has been selected in the viewscreen. |
void |
keyPressed(java.awt.event.KeyEvent e)
Translate a selected figure according to which arrow key is pressed. |
void |
keyReleased(java.awt.event.KeyEvent e)
Included to comply with the KeyListener interface requirement. |
void |
keyTyped(java.awt.event.KeyEvent e)
Included to comply with the KeyListener interface requirement. |
void |
mouseClicked(LayerEvent layerEvent)
Included to comply with the AbstractListener implementation requirement. |
void |
mouseDragged(LayerEvent layerEvent)
Translate the figure to wherever the mouse is dragged. |
void |
mouseEntered(LayerEvent layerEvent)
Included to comply with the AbstractListener implementation requirement. |
void |
mouseExited(LayerEvent layerEvent)
Included to comply with the AbstractListener implementation requirement. |
void |
mouseMoved(LayerEvent layerEvent)
Included to comply with the AbstractListener implementation requirement. |
void |
mousePressed(LayerEvent layerEvent)
Update the state of this listener to reflect where on the figure the mouse button was pressed, and change the mouse cursor to show that the figure can now be dragged. |
void |
mouseReleased(LayerEvent layerEvent)
Included to comply with the AbstractListener implementation requirement. |
void |
setSelected(boolean selected)
Set whether the figure being listened to is selected or not selected. |
void |
setViewScreen(ViewScreen2D viewScreen)
Notify this object of the view screen which contains the figure this object is listening to. |
Methods inherited from class diva.canvas.interactor.AbstractInteractor |
---|
accept, getMouseFilter, isConsuming, isEnabled, isMotionEnabled, setConsuming, setEnabled, setMotionEnabled, setMouseFilter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private JCanvas _canvas
private double dragPointX
private double dragPointY
private AbstractFigure _figure
private boolean _isSelected
private ViewScreen2D _viewScreen
Constructor Detail |
---|
public FigureInteractor(AbstractFigure figure)
figure
- The figure this interactor is to listen and respond to.Method Detail |
---|
public boolean isSelected()
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
e
- The KeyEvent received.public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
e
- The KeyEvent received.public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
e
- The KeyEvent received.public void mouseClicked(LayerEvent layerEvent)
mouseClicked
in interface LayerListener
mouseClicked
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void mouseDragged(LayerEvent layerEvent)
mouseDragged
in interface LayerListener
mouseDragged
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void mouseEntered(LayerEvent layerEvent)
mouseEntered
in interface LayerMotionListener
mouseEntered
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void mouseExited(LayerEvent layerEvent)
mouseExited
in interface LayerMotionListener
mouseExited
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void mouseMoved(LayerEvent layerEvent)
mouseMoved
in interface LayerMotionListener
mouseMoved
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void mousePressed(LayerEvent layerEvent)
mousePressed
in interface LayerListener
mousePressed
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void mouseReleased(LayerEvent layerEvent)
mouseReleased
in interface LayerListener
mouseReleased
in class AbstractInteractor
layerEvent
- The LayerEvent received.public void setSelected(boolean selected)
selected
- true if the figure being listened to is
selected, false otherwise.public void setViewScreen(ViewScreen2D viewScreen)
viewScreen
- The viewScreen containing the figure this
interactor is listening to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |