|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--y.view.ViewMode
This class handles events comming from a Graph2DView. Events are mouse events like mouse button pressed, mouse button released etc. on a certain position in the view. Depending on the event, a method of the view mode is invoked with coordinates of the mouse pointer as argument. The coordinates are world coordinates. If the view is in grid mode, these coordinates are always grid coordinates.
A ViewMode can have a child, in this case all events are delegated to the child.
Field Summary | |
protected MouseEvent |
lastClickEvent
Stores last mouse event received via ViewMode.mouseClicked(MouseEvent) |
protected MouseEvent |
lastDragEvent
Stores last mouse event received via ViewMode.mouseDragged(MouseEvent) |
protected MouseEvent |
lastPressEvent
Stores last mouse event received via ViewMode.mousePressed(MouseEvent) |
protected MouseEvent |
lastReleaseEvent
Stores last mouse event received via ViewMode.mouseReleased(MouseEvent) |
protected int |
originalX
Original view x-coordinate received with the last mouse event. |
protected int |
originalY
Original view y-coordinate received with the last mouse event. |
protected Graph2DView |
view
The view this mode operates on. |
Constructor Summary | |
ViewMode()
Creates a new ViewMode |
|
ViewMode(ViewContainer vc)
Creates a new ViewMode which is bound to a given ViewContainer |
Method Summary | |
void |
activate(boolean b)
Invoked when the Mode is activated/deactiveted from the ViewControl |
protected Graph2D |
getGraph2D()
Returns the Graph2D displayed in the view this mode belongs to. |
protected double |
getGridX(double x)
Translates a given X-Coordinate to the next X grid line coordinate. |
protected double |
getGridY(double y)
Translates a given X-Coordinate to the next X grid line coordinate. |
protected HitInfo |
getHitInfo(double x,
double y)
Query which objects are located on Position (x,y) in the view. |
protected HitInfo |
getHitInfo(MouseEvent ev)
Query which objects are located on Position (x,y) in the view. |
protected HitInfo |
getLastHitInfo()
Returns the last hit info that has was returned by ViewMode.getHitInfo(double,double) . |
String |
getName()
Get the name of this mode |
void |
init()
This method is called in a child mode when it gets installed in another mode. |
boolean |
isGrabFocusEnabled()
Returns whether or not the UI focus should be grabbed by the Graph2DView associated with this mode, when pressing the mouse button. |
boolean |
isGridMode()
Query if gridmode is active. |
void |
mouseClicked(double x,
double y)
Called when the mouse was clicked |
void |
mouseClicked(MouseEvent e)
A mouse button get clicked |
void |
mouseDragged(MouseEvent e)
The mouse gets dragged |
void |
mouseDraggedLeft(double x,
double y)
Called when the mouse was dragged with the left button down. |
void |
mouseDraggedMiddle(double x,
double y)
Called when the mouse was dragged with the middle button down. |
void |
mouseDraggedRight(double x,
double y)
Called when the mouse was dragged with the right button down. |
void |
mouseEntered(MouseEvent e)
The mouse enters the viewer component. |
void |
mouseExited(MouseEvent e)
The mouse leaves the viewer component. |
void |
mouseMoved(double x,
double y)
Called when the mouse was moved |
void |
mouseMoved(MouseEvent e)
The Mouse gets moved. |
void |
mousePressed(MouseEvent e)
A mouse button gets pressed. |
void |
mousePressedLeft(double x,
double y)
Called when the left mouse button was pressed. |
void |
mousePressedMiddle(double x,
double y)
Called when the middle mouse button was pressed. |
void |
mousePressedRight(double x,
double y)
Called when the right mouse button was pressed. |
void |
mouseReleased(double x,
double y)
Called when a mouse button was released. |
void |
mouseReleased(MouseEvent e)
A mouse button get released |
void |
mouseReleasedLeft(double x,
double y)
Called when the left mouse button was released. |
void |
mouseReleasedMiddle(double x,
double y)
Called when the middle mouse button was released. |
void |
mouseReleasedRight(double x,
double y)
Called when the right mouse button was released |
void |
mouseShiftPressedLeft(double x,
double y)
Called when the left mouse button was pressed with shift key down. |
void |
mouseShiftPressedMiddle(double x,
double y)
Called when the middle mouse button was pressed with shift key down. |
void |
mouseShiftPressedRight(double x,
double y)
Called when the right mouse button was pressed with shift key down. |
void |
mouseShiftReleasedLeft(double x,
double y)
Called when the left mouse button was released with shift key down. |
void |
mouseShiftReleasedMiddle(double x,
double y)
Called when the middle mouse button was released with shift key down NOTE: this implementation calls ViewMode.mouseReleasedMiddle(double, double) ! |
void |
mouseShiftReleasedRight(double x,
double y)
Called when the right mouse button was released with shift key down. |
void |
reactivateParent()
The parent of this ViewMode is reactivated and this ViewMode is deactivated. |
void |
setActiveView(Graph2DView view)
Sets the active view this mode operates on. |
void |
setChild(ViewMode child,
MouseEvent pressEvent,
MouseEvent dragEvent)
Sets a child mode for this mode. |
void |
setChild(ViewMode child,
MouseEvent pressEvent,
MouseEvent dragEvent,
MouseEvent releaseEvent)
Sets a child mode for this mode. |
void |
setGrabFocusEnabled(boolean enabled)
Whether or not the UI focus should be grabbed by the Graph2DView associated with this mode, when pressing the mouse button. |
void |
setGridMode(boolean mode)
Enable/Disable grid mode of the Graph2DView |
void |
setLastHitInfo(HitInfo hInfo)
|
void |
setName(String s)
Set the name of this mode, important for resource handling |
void |
setParent(ViewMode l)
Sets the parent mode of a child mode. |
protected double |
translateX(int x)
Returns the world coordinate value of the given x view coordinate value |
protected double |
translateY(int y)
Returns the world coordinate value of the given y view coordinate value |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Graph2DView view
protected int originalX
protected int originalY
protected MouseEvent lastPressEvent
ViewMode.mousePressed(MouseEvent)
protected MouseEvent lastDragEvent
ViewMode.mouseDragged(MouseEvent)
protected MouseEvent lastReleaseEvent
ViewMode.mouseReleased(MouseEvent)
protected MouseEvent lastClickEvent
ViewMode.mouseClicked(MouseEvent)
Constructor Detail |
public ViewMode()
public ViewMode(ViewContainer vc)
Method Detail |
public void setActiveView(Graph2DView view)
public void activate(boolean b)
b
- set true
when mode should be activated
false
otherwisepublic void setGridMode(boolean mode)
public boolean isGridMode()
public void setGrabFocusEnabled(boolean enabled)
By default this feature is active.
public boolean isGrabFocusEnabled()
public void setChild(ViewMode child, MouseEvent pressEvent, MouseEvent dragEvent)
ViewMode.reactivateParent()
.
After the child mode is installed it will receive the
given press and drag events before any other mouse events.
Only non-null events will be delegated.
public void setChild(ViewMode child, MouseEvent pressEvent, MouseEvent dragEvent, MouseEvent releaseEvent)
ViewMode.reactivateParent()
.
After the child mode is installed it will receive the
given press, drag and release events before any other mouse events.
Only non-null events will be delegated.
public void init()
ViewMode.setChild(ViewMode,MouseEvent,MouseEvent)
public void reactivateParent()
public void setParent(ViewMode l)
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseMoved(MouseEvent e)
ViewMode.mouseMoved(double,double)
.
mouseMoved
in interface MouseMotionListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
protected double getGridX(double x)
protected double getGridY(double y)
protected Graph2D getGraph2D()
protected double translateX(int x)
protected double translateY(int y)
public void setName(String s)
public String getName()
protected HitInfo getHitInfo(MouseEvent ev)
protected HitInfo getHitInfo(double x, double y)
protected HitInfo getLastHitInfo()
ViewMode.getHitInfo(double,double)
.
public void setLastHitInfo(HitInfo hInfo)
public void mousePressedLeft(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftPressedLeft(double x, double y)
ViewMode.mousePressedLeft(double, double)
!
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftPressedRight(double x, double y)
ViewMode.mousePressedRight(double, double)
!
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftPressedMiddle(double x, double y)
ViewMode.mousePressedMiddle(double, double)
!
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mousePressedMiddle(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mousePressedRight(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseReleased(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseReleasedLeft(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftReleasedLeft(double x, double y)
ViewMode.mouseReleasedLeft(double, double)
!
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftReleasedRight(double x, double y)
ViewMode.mouseReleasedRight(double, double)
!
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseReleasedMiddle(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftReleasedMiddle(double x, double y)
ViewMode.mouseReleasedMiddle(double, double)
!
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseReleasedRight(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseDraggedLeft(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseDraggedMiddle(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseDraggedRight(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseClicked(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseMoved(double x, double y)
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |