Search this API

y.view
Class AbstractSelectionBoxMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.AbstractSelectionBoxMode
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener
Direct Known Subclasses:
AreaZoomMode, 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 selectionBoxAction(java.awt.Rectangle, boolean) is invoked.

 
Your browser does not support SVG content.

Field Summary
 
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
AbstractSelectionBoxMode()
          Instantiates a new AbstractSelectionBoxMode.
AbstractSelectionBoxMode(ViewContainer view)
          Instantiates a new AbstractSelectionBoxMode for a given ViewContainer.
 
Method Summary
 void cancelEditing()
          Aborts the selection box action and removes the temporary box drawn in the view.
 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 selectionBoxAction(Rectangle sb, boolean shiftMode).
 void mouseReleasedRight(double x, double y)
          Called when the right mouse button was released
 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 selectionBoxAction(Rectangle sb, boolean shiftMode).
protected  void selectionBoxAction(java.awt.geom.Rectangle2D.Double sb, boolean shiftMode)
          This method is called when the selection box is closed.
protected abstract  void selectionBoxAction(java.awt.Rectangle sb, boolean shiftMode)
          This method is called when the selection box is closed.
protected  java.awt.geom.Rectangle2D.Double updateDoubleSelectionBox(double x, double y)
          Updates the bounds of the active selection box.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, 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, mouseShiftPressedMiddle, mouseShiftPressedRight, 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
 

Constructor Detail

AbstractSelectionBoxMode

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


AbstractSelectionBoxMode

public AbstractSelectionBoxMode()
Instantiates a new AbstractSelectionBoxMode.

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.

cancelEditing

public void cancelEditing()
Aborts the selection box action and removes the temporary box drawn in the view.

Overrides:
cancelEditing in class ViewMode

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 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 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.

mouseReleasedRight

public void mouseReleasedRight(double x,
                               double y)
Description copied from class: ViewMode
Called when the right mouse button was released

Overrides:
mouseReleasedRight 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 java.awt.geom.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(java.awt.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(java.awt.geom.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 compatibility 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-2022,
yWorks GmbH.
All rights reserved.