org.jscience.architecture.traffic
Class Selection

java.lang.Object
  extended by java.util.Observable
      extended by org.jscience.architecture.traffic.Selection
All Implemented Interfaces:
Overlay

public class Selection
extends java.util.Observable
implements Overlay

Selections can be made in the simulator and editor


Constructor Summary
Selection(Selection copy)
          Creates a new Selection object that is a clone of the given Selection object
Selection(View v)
           
Selection(View v, java.lang.Class[] sf)
           
Selection(View v, java.lang.Class[] sf, SelectionStarter ss)
           
 
Method Summary
 void addToSelection(java.awt.Point p)
          Adds the Selectable located at given point to the selection
 void addToSelection(java.awt.Rectangle r)
          Adds all Selectables inside given rectangle to selection.
 void deselect(Selectable o)
          Removes a Selectable from the list of selected objects.
 void deselectAll()
          Removes all objects from the list of selected objects.
 int getNumSelectedObjects()
          Return the number of currently selected object
 java.util.LinkedList getSelectedObjects()
          Returns the list of all selected objects
 java.lang.Class[] getSelectionFilter()
          Returns the current selection filter
 SelectionStarter getSelectionStarter()
          Returns the current selection starter
 View getView()
          Returns the view associated with this selection
 void invertWithSelection(java.awt.Point p)
          Removes the Selectable located at given point from the selection.
 boolean isEmpty()
          Checks if the selection is empty
 void newSelection(java.awt.Point p)
          Creates a new selection holding the Selectable located at given point.
 void newSelection(java.awt.Rectangle r)
          Creates a new selection holding all Selectables inside given rectangle
 void newSelection(Selectable o)
          Creates a new selection containing the given Selectable
 int overlayType()
          Returns the type of overlay. 1 indicates a view overlay. 2 indicates a buffer overlay.
 void paint(java.awt.Graphics gr)
          Draws this Overlay on a given Graphics object.
 void selectAll()
          Adds all objects to the list of selected objects.
static java.lang.Object selectObject(java.lang.Class[] sf, SelectionStarter ss, java.awt.Point p)
          Returns the closest object selected by given point using given SelectionStarter
 void setSelectedObjects(java.util.LinkedList l)
          Sets the list of all selected objects
 void setSelection(Selection s)
          Sets this selection to the given selection
 void setSelectionFilter(java.lang.Class[] sf)
          Sets the current selection filter
 void setSelectionStarter(SelectionStarter ss)
          Sets the current selection starter
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Selection

public Selection(View v)

Selection

public Selection(View v,
                 java.lang.Class[] sf)

Selection

public Selection(View v,
                 java.lang.Class[] sf,
                 SelectionStarter ss)

Selection

public Selection(Selection copy)
Creates a new Selection object that is a clone of the given Selection object

Method Detail

overlayType

public int overlayType()
Description copied from interface: Overlay
Returns the type of overlay. 1 indicates a view overlay. 2 indicates a buffer overlay.

Specified by:
overlayType in interface Overlay
Returns:
DOCUMENT ME!

paint

public void paint(java.awt.Graphics gr)
           throws TrafficException
Description copied from interface: Overlay
Draws this Overlay on a given Graphics object.

Specified by:
paint in interface Overlay
Parameters:
gr - The Graphics object to draw this Paintable on
Throws:
TrafficException - DOCUMENT ME!

getView

public View getView()
Returns the view associated with this selection


getSelectionStarter

public SelectionStarter getSelectionStarter()
Returns the current selection starter


setSelectionStarter

public void setSelectionStarter(SelectionStarter ss)
Sets the current selection starter


getSelectionFilter

public java.lang.Class[] getSelectionFilter()
Returns the current selection filter


setSelectionFilter

public void setSelectionFilter(java.lang.Class[] sf)
Sets the current selection filter


getSelectedObjects

public java.util.LinkedList getSelectedObjects()
Returns the list of all selected objects


setSelectedObjects

public void setSelectedObjects(java.util.LinkedList l)
Sets the list of all selected objects


getNumSelectedObjects

public int getNumSelectedObjects()
Return the number of currently selected object


isEmpty

public boolean isEmpty()
Checks if the selection is empty


setSelection

public void setSelection(Selection s)
Sets this selection to the given selection


deselectAll

public void deselectAll()
Removes all objects from the list of selected objects.


deselect

public void deselect(Selectable o)
Removes a Selectable from the list of selected objects.

Parameters:
o - The Selectable to remove from the list

selectAll

public void selectAll()
Adds all objects to the list of selected objects.

Parameters:
o - The Selectable that contains a recursive list of all objects to add

newSelection

public void newSelection(Selectable o)
Creates a new selection containing the given Selectable

Parameters:
o - The Selectable the new selection should contain

newSelection

public void newSelection(java.awt.Point p)
Creates a new selection holding the Selectable located at given point. If no such Selectable exists, the selection is emptied.

Parameters:
p - The point of the Selectable to add to the new selection

addToSelection

public void addToSelection(java.awt.Point p)
Adds the Selectable located at given point to the selection

Parameters:
p - The location of the Selectable to add

invertWithSelection

public void invertWithSelection(java.awt.Point p)
Removes the Selectable located at given point from the selection. If no such Selectable is selected, adds the Selectable located at given point to the selection.

Parameters:
p - The point the Selectable is located at

addToSelection

public void addToSelection(java.awt.Rectangle r)
Adds all Selectables inside given rectangle to selection.

Parameters:
r - The rectangle enclosing Selectables to add

newSelection

public void newSelection(java.awt.Rectangle r)
Creates a new selection holding all Selectables inside given rectangle

Parameters:
r - The rectangle enclosing Selectables

selectObject

public static java.lang.Object selectObject(java.lang.Class[] sf,
                                            SelectionStarter ss,
                                            java.awt.Point p)
Returns the closest object selected by given point using given SelectionStarter

Parameters:
sf - The selection filter to aply
ss - The selection starter
p - The point