y.view
Class AbstractSelectionBoxMode

java.lang.Object
  |
  +--y.view.ViewMode
        |
        +--y.view.AbstractSelectionBoxMode
All Implemented Interfaces:
EventListener, MouseInputListener, MouseListener, MouseMotionListener
Direct Known Subclasses:
SelectionBoxMode

public abstract class AbstractSelectionBoxMode
extends ViewMode

An abstract view mode that draws a temporary box in a view The bounds of this box can be controlled by dragging a corner of the box. When the box is closed the abstract callback method AbstractSelectionBoxMode.selectionBoxAction(java.awt.Rectangle, boolean) is invoked.


Field Summary
 
Fields inherited from class y.view.ViewMode
lastClickEvent, lastDragEvent, lastPressEvent, lastReleaseEvent, originalX, originalY, view
 
Constructor Summary
AbstractSelectionBoxMode()
          Instantiates a new AbstactSelectionBoxMode.
AbstractSelectionBoxMode(ViewContainer view)
          Instantiates a new AbstactSelectionBoxMode for a given ViewContainer.
 
Method Summary
 void mouseDraggedLeft(double x, double y)
          Changes the size of the selection box in such a way that the dragged corner of the box is at the given world coordinate.
 void mousePressedLeft(double x, double y)
          Initiates the selection box action, by opening a selection box at the given world coordinates.
 void mouseReleasedLeft(double x, double y)
          Terminates the selection box action and calls the hook method AbstractSelectionBoxMode.selectionBoxAction(Rectangle sb, boolean shiftMode).
 void mouseShiftPressedLeft(double x, double y)
          Initiates the selection box action, by opening a selection box at the given world coordinates.
 void mouseShiftReleasedLeft(double x, double y)
          Terminates the selection box action and calls the hook method AbstractSelectionBoxMode.selectionBoxAction(Rectangle sb, boolean shiftMode).
protected  void selectionBoxAction(Rectangle2D.Double sb, boolean shiftMode)
          This method is called when the selection box is closed.
protected abstract  void selectionBoxAction(Rectangle sb, boolean shiftMode)
          This method is called when the selection box is closed.
protected  Rectangle2D.Double updateDoubleSelectionBox(double x, double y)
          Updates the bounds of the active selection box.
 
Methods inherited from class y.view.ViewMode
activate, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastHitInfo, getName, init, isGrabFocusEnabled, isGridMode, mouseClicked, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, setActiveView, setChild, setChild, setGrabFocusEnabled, setGridMode, setLastHitInfo, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSelectionBoxMode

public AbstractSelectionBoxMode(ViewContainer view)
Instantiates a new AbstactSelectionBoxMode for a given ViewContainer.


AbstractSelectionBoxMode

public AbstractSelectionBoxMode()
Instantiates a new AbstactSelectionBoxMode.

Method Detail

mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Initiates the selection box action, by opening a selection box at the given world coordinates.

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.

mouseShiftPressedLeft

public void mouseShiftPressedLeft(double x,
                                  double y)
Initiates the selection box action, by opening a selection box at the given world coordinates.

Overrides:
mouseShiftPressedLeft 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)
Changes the size of the selection box in such a way that the dragged corner of the box is at the given world coordinate.

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)
Terminates the selection box action and calls the hook method AbstractSelectionBoxMode.selectionBoxAction(Rectangle sb, boolean shiftMode).

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.

mouseShiftReleasedLeft

public void mouseShiftReleasedLeft(double x,
                                   double y)
Terminates the selection box action and calls the hook method AbstractSelectionBoxMode.selectionBoxAction(Rectangle sb, boolean shiftMode).

Overrides:
mouseShiftReleasedLeft 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.

updateDoubleSelectionBox

protected Rectangle2D.Double updateDoubleSelectionBox(double x,
                                                      double y)
Updates the bounds of the active selection box. The given world coordinates are the coordinates of the current active selection box corner.


selectionBoxAction

protected abstract void selectionBoxAction(Rectangle sb,
                                           boolean shiftMode)
This method is called when the selection box is closed. Implement this method to write your own ViewMode. Note: to get better results use the overloaded double version. Of course you still have to implement this function, at least with an empty implementation. This method will never be called by this class, if you override the double version.

Parameters:
sb - The position and size of the selection box.
shiftMode - true if shift was pressed when box was closed, false otherwise.

selectionBoxAction

protected void selectionBoxAction(Rectangle2D.Double sb,
                                  boolean shiftMode)
This method is called when the selection box is closed. Implement this method to write your own ViewMode. To provide compatability with older version the int version is called here.

Parameters:
sb - The position and size of the selection box.
shiftMode - true if shift was pressed when box was closed, false otherwise.

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

2003