devisor2.grid.backend
Class BaseSelector

java.lang.Object
  extended bydevisor2.grid.backend.BaseSelector
Direct Known Subclasses:
GridHotspotter

public abstract class BaseSelector
extends java.lang.Object

This class is responsible for managing the select box which can be dragged open on the DrawingArea. All event handling is taken care of in the GridListener class, here just the neccessary methods for drawing and changing the select box are provided.
Additionally, this class provides the container for selections (in other words, the internal selection management) and methods to modify it.


Field Summary
protected  boolean boundaryNodesOnly
           
protected  ControlCenter cc
           
protected  boolean containsCircles
           
protected  java.awt.Rectangle currentRect
           
protected  DrawingArea da
           
protected  java.awt.Graphics2D g
           
protected  boolean nodesonly
           
protected  java.awt.Rectangle perimeter
           
protected  java.awt.Rectangle previousRectDrawn
           
protected  java.awt.Rectangle rectToDraw
           
protected  MainFrame root
           
 
Constructor Summary
BaseSelector(MainFrame mf, DrawingArea da)
          The constructor just sets references correctly and initializes some variables
 
Method Summary
 void clearSelectBox()
          clears the gui feedback of the rectangle last drawn
 boolean containsCircles()
           
 GridItem getClickedItem(int x, int y)
          returns the GridItem which is positioned at the given world coords
 java.awt.Rectangle getSelectBox()
          returns the current SelectBox as a Rectangle object (in screen coordinates, not in world coordinates)
 java.util.Vector getSelectedItems(boolean additive, java.util.Vector previous)
          returns all selected GridItems inside the currently used rubber band / lasso.
 boolean isBoundaryNodesOnly()
           
 boolean isNodesOnly()
           
 void paintSelectBox()
          paints the selection box to the drawing area's graphics context
 void setGraphics(java.awt.Graphics g)
          updates the graphics handle
 void startSelectBox(int x, int y)
          starts the rectangle drawing process
 void updateSelectBox(int x, int y)
          Update the size of the select box and redraw it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected MainFrame root

cc

protected ControlCenter cc

currentRect

protected java.awt.Rectangle currentRect

rectToDraw

protected java.awt.Rectangle rectToDraw

previousRectDrawn

protected java.awt.Rectangle previousRectDrawn

perimeter

protected java.awt.Rectangle perimeter

da

protected DrawingArea da

g

protected java.awt.Graphics2D g

nodesonly

protected boolean nodesonly

containsCircles

protected boolean containsCircles

boundaryNodesOnly

protected boolean boundaryNodesOnly
Constructor Detail

BaseSelector

public BaseSelector(MainFrame mf,
                    DrawingArea da)
The constructor just sets references correctly and initializes some variables

Parameters:
mf - - the MainFrame reference
da - - the drawing area where the select box will be painted on
Method Detail

setGraphics

public void setGraphics(java.awt.Graphics g)
updates the graphics handle


containsCircles

public boolean containsCircles()
Returns:
true <=> circles are part of the current selection

isBoundaryNodesOnly

public boolean isBoundaryNodesOnly()
Returns:
true <=> boundarynodes part of the current selection

isNodesOnly

public boolean isNodesOnly()
Returns:
true <=> the selection contains a single node

getSelectBox

public java.awt.Rectangle getSelectBox()
returns the current SelectBox as a Rectangle object (in screen coordinates, not in world coordinates)


paintSelectBox

public void paintSelectBox()
paints the selection box to the drawing area's graphics context


startSelectBox

public void startSelectBox(int x,
                           int y)
starts the rectangle drawing process


updateSelectBox

public void updateSelectBox(int x,
                            int y)
Update the size of the select box and redraw it.


clearSelectBox

public void clearSelectBox()
clears the gui feedback of the rectangle last drawn


getClickedItem

public GridItem getClickedItem(int x,
                               int y)
returns the GridItem which is positioned at the given world coords

Returns:
GridItem or null

getSelectedItems

public java.util.Vector getSelectedItems(boolean additive,
                                         java.util.Vector previous)
returns all selected GridItems inside the currently used rubber band / lasso. Also updates the contains... flags

Parameters:
additive - - if true, selection is added to ...
previous - - previously selected items
Returns:
a Vector of GridItems