|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.ViewMode
public class ViewMode
This class handles events coming 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 | |
---|---|
static java.lang.String |
ACTIVE_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
static java.lang.String |
ACTIVE_VIEW_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
static java.lang.String |
CHILD_MODE_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
static java.lang.String |
EDITING_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
static java.lang.String |
GRAB_FOCUS_ENABLED_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
protected java.awt.event.MouseEvent |
lastClickEvent
Stores last mouse event received via mouseClicked(MouseEvent) |
protected java.awt.event.MouseEvent |
lastDragEvent
Stores last mouse event received via mouseDragged(MouseEvent) |
protected java.awt.event.MouseEvent |
lastMoveEvent
Stores last mouse event received via mouseMoved(java.awt.event.MouseEvent) |
protected java.awt.event.MouseEvent |
lastPressEvent
Stores last mouse event received via mousePressed(MouseEvent) |
protected java.awt.event.MouseEvent |
lastReleaseEvent
Stores last mouse event received via mouseReleased(MouseEvent) |
static java.lang.String |
MODIFIER_MASK_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
static java.lang.String |
NAME_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
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. |
static java.lang.String |
PARENT_MODE_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName() . |
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/deactivated from the ViewControl or via the setChild() and reactivateParent operations This behaves like a bound property using ACTIVE_PROPERTY as the property name. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds a PropertyChangeListener to the list of registered listeners. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener pcl)
Adds a PropertyChangeListener for the given property
to the list of registered listeners. |
void |
cancelEditing()
This can be used to cleanly exit an edit that is currently in progress. |
protected void |
deactivateChild(ViewMode childMode)
This is a callback method, to deactivate old child modi. |
protected void |
firePropertyChange(java.lang.String name,
boolean oldValue,
boolean newValue)
Helper method for subclasses to indicate a property change. |
protected void |
firePropertyChange(java.lang.String name,
int oldValue,
int newValue)
Helper method for subclasses to indicate a property change. |
protected void |
firePropertyChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Helper method for subclasses to indicate a property change. |
ViewMode |
getChild()
Returns the current child ViewMode or null if this mode has no child. |
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 object is located at position (x,y) in world coordinate space. |
protected HitInfo |
getHitInfo(java.awt.event.MouseEvent ev)
Query which object is located at position (x,y) in the view. |
java.awt.event.MouseEvent |
getLastClickEvent()
Returns the last mouse clicked event that has been recorded by the view mode. |
java.awt.event.MouseEvent |
getLastDragEvent()
Returns the last mouse dragged event that has been recorded by the view mode. |
protected HitInfo |
getLastHitInfo()
Returns the most current HitInfo object that has been set/was returned by getHitInfo(double, double) . |
java.awt.event.MouseEvent |
getLastMoveEvent()
Returns the last mouse moved event that has been recorded by the view mode. |
java.awt.event.MouseEvent |
getLastPressEvent()
Returns the last mouse pressed event that has been recorded by the view mode. |
java.awt.event.MouseEvent |
getLastReleaseEvent()
Returns the last mouse released event that has been recorded by the view mode. |
int |
getModifierMask()
Gets the current modifierMask. |
java.lang.String |
getName()
Get the name of this mode |
ViewMode |
getParent()
Returns the current parent ViewMode or null if this mode has no parent. |
void |
init()
This method is called in a child mode when it gets installed in another mode. |
boolean |
isActive()
Returns whether this Mode has been activate(boolean) d previously. |
boolean |
isEditing()
Determines whether the mode is currently "editing". |
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 grid mode is active. |
protected boolean |
isModifierPressed(java.awt.event.MouseEvent me)
This method determines whether at the creation time of the given MouseEvent the modifier key was pressed. |
void |
mouseClicked(double x,
double y)
Called when the mouse was clicked |
void |
mouseClicked(java.awt.event.MouseEvent e)
A mouse button get clicked |
void |
mouseDragged(java.awt.event.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(java.awt.event.MouseEvent e)
The mouse enters the viewer component. |
void |
mouseExited(java.awt.event.MouseEvent e)
The mouse leaves the viewer component. |
void |
mouseMoved(double x,
double y)
Called when the mouse was moved |
void |
mouseMoved(java.awt.event.MouseEvent e)
The Mouse gets moved. |
void |
mousePressed(java.awt.event.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(java.awt.event.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 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 |
removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Removes a PropertyChangeListener from
the list of registered listeners. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener pcl)
Removes a PropertyChangeListener for a given property from
the list of registered listeners. |
void |
setActiveView(Graph2DView view)
Sets the active view this mode operates on. |
void |
setChild(ViewMode child,
java.awt.event.MouseEvent pressEvent,
java.awt.event.MouseEvent dragEvent)
Sets a child mode for this mode. |
void |
setChild(ViewMode child,
java.awt.event.MouseEvent pressEvent,
java.awt.event.MouseEvent dragEvent,
java.awt.event.MouseEvent releaseEvent)
Sets a child mode for this mode. |
protected void |
setEditing(boolean editing)
Used by subclasses to update the current state. |
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)
Sets the given HitInfo as the most current HitInfo object, which is referred to as "last hit info." |
void |
setModifierMask(int modifierMask)
Sets the current modifierMask. |
void |
setName(java.lang.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 |
---|
public static final java.lang.String ACTIVE_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if activate(boolean)
is called
public static final java.lang.String CHILD_MODE_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setChild(ViewMode, MouseEvent, MouseEvent, MouseEvent)
is called.
public static final java.lang.String ACTIVE_VIEW_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setActiveView(Graph2DView)
is called.
public static final java.lang.String GRAB_FOCUS_ENABLED_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setGrabFocusEnabled(boolean)
is called.
public static final java.lang.String PARENT_MODE_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setParent(ViewMode)
is called
public static final java.lang.String NAME_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setName(String)
is called
public static final java.lang.String MODIFIER_MASK_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setModifierMask(int)
is called
public static final java.lang.String EDITING_PROPERTY
PropertyChangeEvent.getPropertyName()
.
This property is used if setEditing(boolean)
is called
protected Graph2DView view
protected int originalX
protected int originalY
protected java.awt.event.MouseEvent lastPressEvent
mousePressed(MouseEvent)
protected java.awt.event.MouseEvent lastDragEvent
mouseDragged(MouseEvent)
protected java.awt.event.MouseEvent lastMoveEvent
mouseMoved(java.awt.event.MouseEvent)
protected java.awt.event.MouseEvent lastReleaseEvent
mouseReleased(MouseEvent)
protected java.awt.event.MouseEvent lastClickEvent
mouseClicked(MouseEvent)
Constructor Detail |
---|
public ViewMode()
public ViewMode(ViewContainer vc)
Method Detail |
---|
public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
PropertyChangeListener
to the list of registered listeners.
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
PropertyChangeListener
for the given property
to the list of registered listeners.
public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
PropertyChangeListener
from
the list of registered listeners.
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
PropertyChangeListener
for a given property from
the list of registered listeners.
protected void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
protected void firePropertyChange(java.lang.String name, boolean oldValue, boolean newValue)
protected void firePropertyChange(java.lang.String name, int oldValue, int newValue)
public boolean isEditing()
setEditing(boolean)
,
cancelEditing()
protected void setEditing(boolean editing)
EDITING_PROPERTY
as the property name.
editing
- the new editing stateisEditing()
,
cancelEditing()
public void cancelEditing() throws java.lang.UnsupportedOperationException
setEditing(false)
if
isEditing()
returns true
java.lang.UnsupportedOperationException
- if the editing cannot be canceled
for any reason.public void setActiveView(Graph2DView view)
ACTIVE_VIEW_PROPERTY
as the property name.
public void activate(boolean b)
ACTIVE_PROPERTY
as the property name.
b
- set true
when mode was activated
false
otherwisepublic boolean isActive()
activate(boolean)
d previously.
public void setGridMode(boolean mode)
Graph2DView
.
public boolean isGridMode()
Graph2DView
.
public void setGrabFocusEnabled(boolean enabled)
true
.
This is a bound property using GRAB_FOCUS_ENABLED_PROPERTY
as the property name.
public boolean isGrabFocusEnabled()
public void setChild(ViewMode child, java.awt.event.MouseEvent pressEvent, java.awt.event.MouseEvent dragEvent)
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, java.awt.event.MouseEvent pressEvent, java.awt.event.MouseEvent dragEvent, java.awt.event.MouseEvent releaseEvent)
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. active view
,
its new parent
, the last HitInfo
,
and will be activated
. null
is passed as the child or the child calls
its reactivateParent()
method,
the previously installed child will be deactivated
and have its parent
set to null
.
This behaves like a bound property using CHILD_MODE_PROPERTY
as the property name.
protected void deactivateChild(ViewMode childMode)
childMode
- The child mode to deactivatepublic void init()
setChild(ViewMode,MouseEvent,MouseEvent)
public void reactivateParent()
public void setParent(ViewMode l)
PARENT_MODE_PROPERTY
as the property name.
public ViewMode getParent()
null
if this mode has no parent.
null
reactivateParent()
,
setChild(ViewMode, java.awt.event.MouseEvent, java.awt.event.MouseEvent, java.awt.event.MouseEvent)
public ViewMode getChild()
null
if this mode has no child.
null
getParent()
,
setChild(ViewMode, java.awt.event.MouseEvent, java.awt.event.MouseEvent, java.awt.event.MouseEvent)
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved(double,double)
.
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.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(java.lang.String s)
NAME_PROPERTY
as the property name.
public java.lang.String getName()
protected HitInfo getHitInfo(java.awt.event.MouseEvent ev)
getHitInfo(double, double)
is returned.
protected HitInfo getHitInfo(double x, double y)
Note that prior to returning the HitInfo, it is set as the most current HitInfo
object.
See setLastHitInfo(HitInfo)
.
x
- x world coordinatey
- y world coordinate
createHitInfo(double,double,boolean)
protected HitInfo getLastHitInfo()
getHitInfo(double, double)
.
See also setLastHitInfo(HitInfo)
.
public void setLastHitInfo(HitInfo hInfo)
getLastHitInfo()
.
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)
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)
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)
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)
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)
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)
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.protected boolean isModifierPressed(java.awt.event.MouseEvent me)
setModifierMask(int)
,
getModifierMask()
public int getModifierMask()
(mouseEvent.getModifier() & modifierMask) != 0
.
The default is MouseEvent.SHIFT_MASK
.
public void setModifierMask(int modifierMask)
(mouseEvent.getModifier() & modifierMask) != 0
.
Valid values are the static fields in the MouseEvent
class.
modifierMask
- the new modifier mask that will be used to determine
whether the "shift" variants of the callback methods should be used.public java.awt.event.MouseEvent getLastPressEvent()
public java.awt.event.MouseEvent getLastDragEvent()
public java.awt.event.MouseEvent getLastMoveEvent()
public java.awt.event.MouseEvent getLastReleaseEvent()
public java.awt.event.MouseEvent getLastClickEvent()
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |