Search this API

y.view
Class MoveNodePortMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.MoveNodePortMode
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class MoveNodePortMode
extends ViewMode

This view mode allows interactive reassignment of node port positions.

A node port can be moved to another position by pressing with the left mouse button and dragging the node port around. The movement is restricted by the PortLocationModel of the dragged node port.

 

Field Summary
protected  NodePort port
          The node port that is being moved.
 
Fields inherited from class y.view.ViewMode
ACTIVE_PROPERTY, ACTIVE_VIEW_PROPERTY, CHILD_MODE_PROPERTY, EDITING_PROPERTY, GRAB_FOCUS_ENABLED_PROPERTY, lastClickEvent, lastDragEvent, lastMoveEvent, lastPressEvent, lastReleaseEvent, MODIFIER_MASK_PROPERTY, NAME_PROPERTY, originalX, originalY, PARENT_MODE_PROPERTY, view
 
Constructor Summary
MoveNodePortMode()
          Initializes a new MoveNodePortMode instance.
MoveNodePortMode(ViewContainer vc)
          Initializes a new MoveNodePortMode instance.
 
Method Summary
protected  YPoint adjustCoordinates(double x, double y)
          Determines the best-match location for the port location model of the currently moved node port.
protected  YPoint adjustCoordinates(NodePort port, double x, double y)
          Determines the best-match location for the port location model of the currently moved node port.
 void cancelEditing()
          This can be used to cleanly exit an edit that is currently in progress.
protected  HitInfo getHitInfo(double x, double y)
          Determines whether or not a node port is located at the specified coordinates.
protected  boolean isOrthogonalRouting(Edge edge)
          Determines whether the given edge instance should be routed orthogonally.
 void mouseDraggedLeft(double x, double y)
          Moves the current node port to the specified location.
 void mousePressedLeft(double x, double y)
          Determines the node port that will be moved.
 void mouseReleasedLeft(double x, double y)
          Ends the movement of the current node port.
protected  void portMoved(NodePort port, double x, double y)
          Invoked when the moved node port has been assigned its final position.
protected  void portWillBeMoved(NodePort port)
          Invoked when the node port that will be moved is first determined.
protected  void updatePortPosition(double x, double y)
          Updates the position of the currently moved node port to the specified coordinates.
protected  void updatePortPosition(NodePort port, double x, double y)
          Updates the position of the currently moved node port to the specified coordinates.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getLastClickEvent, getLastDragEvent, getLastHitInfo, getLastMoveEvent, getLastPressEvent, getLastReleaseEvent, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedLeft, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

port

protected NodePort port
The node port that is being moved.

Constructor Detail

MoveNodePortMode

public MoveNodePortMode()
Initializes a new MoveNodePortMode instance.


MoveNodePortMode

public MoveNodePortMode(ViewContainer vc)
Initializes a new MoveNodePortMode instance.

Parameters:
vc - the container that will provide the Graph2DView for this MoveNodePortMode instance.
Method Detail

isOrthogonalRouting

protected boolean isOrthogonalRouting(Edge edge)
Determines whether the given edge instance should be routed orthogonally. This implementation uses the DataProvider bound to the current graph via the EditMode.ORTHOGONAL_ROUTING_DPKEY data provider key to determine whether the given edge should be routed orthogonally.

Parameters:
edge - the edge to check.
Returns:
true if the edge should be routed orthogonally; false otherwise.
See Also:
EditMode.isOrthogonalRouting(y.base.Edge)

mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Determines the node port that will be moved.

Overrides:
mousePressedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseDraggedLeft

public void mouseDraggedLeft(double x,
                             double y)
Moves the current node port to the specified location.

Overrides:
mouseDraggedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseReleasedLeft

public void mouseReleasedLeft(double x,
                              double y)
Ends the movement of the current node port.

Overrides:
mouseReleasedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

cancelEditing

public void cancelEditing()
                   throws java.lang.UnsupportedOperationException
Description copied from class: ViewMode
This can be used to cleanly exit an edit that is currently in progress.
The implementation and interpretation of "canceling" is left to subclasses. This implementation does nothing but calls setEditing(false) if ViewMode.isEditing() returns true

Overrides:
cancelEditing in class ViewMode
Throws:
java.lang.UnsupportedOperationException - if the editing cannot be canceled for any reason.

portWillBeMoved

protected void portWillBeMoved(NodePort port)
Invoked when the node port that will be moved is first determined.

Parameters:
port - the port that will be moved.

portMoved

protected void portMoved(NodePort port,
                         double x,
                         double y)
Invoked when the moved node port has been assigned its final position.

Parameters:
port - the port that has been moved.
x - the port's final, absolute x-coordinate.
y - the port's final, absolute y-coordinate.

adjustCoordinates

protected YPoint adjustCoordinates(double x,
                                   double y)
Determines the best-match location for the port location model of the currently moved node port. Calls adjustCoordinates(NodePort, double, double).

Parameters:
x - the x-coordinate of the location that should be matched as best as possible.
y - the y-coordinate of the location that should be matched as best as possible.
Returns:
the best-match location for the specified coordinates.

adjustCoordinates

protected YPoint adjustCoordinates(NodePort port,
                                   double x,
                                   double y)
Determines the best-match location for the port location model of the currently moved node port.

Parameters:
port - the port that is moved.
x - the x-coordinate of the location that should be matched as best as possible.
y - the y-coordinate of the location that should be matched as best as possible.
Returns:
the best-match location for the specified coordinates.

updatePortPosition

protected void updatePortPosition(double x,
                                  double y)
Updates the position of the currently moved node port to the specified coordinates. Calls updatePortPosition(NodePort, double, double).

Parameters:
x - the x-coordinate of the node port's new position.
y - the y-coordinate of the node port's new position.

updatePortPosition

protected void updatePortPosition(NodePort port,
                                  double x,
                                  double y)
Updates the position of the currently moved node port to the specified coordinates.

Parameters:
port - the port that is moved.
x - the x-coordinate of the node port's new position.
y - the y-coordinate of the node port's new position.

getHitInfo

protected HitInfo getHitInfo(double x,
                             double y)
Determines whether or not a node port is located at the specified coordinates.

Overrides:
getHitInfo in class ViewMode
Parameters:
x - x world coordinate.
y - y world coordinate.
Returns:
mouse hit information for the specified world coordinates.
See Also:
ViewMode.createHitInfo(double,double,boolean)

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.