ini.trakem2.display
Class Selection

java.lang.Object
  extended by ini.trakem2.display.Selection

public class Selection
extends java.lang.Object

Keeps track of selected objects and mediates their transformation.


Field Summary
static int PADDING
          Outward padding in pixels around the selected Displayables maximum enclosing box that may need repainting when updating the screen.
 
Constructor Summary
Selection(Display display)
          The Display can be null, as long as paint, OvalHandle.contains, setTransforming, and getLinkedBox methods are never called on this object.
 
Method Summary
 void add(Displayable d)
           
protected  void apply(int what, double[] params)
           
 void clear()
          Remove all Displayables from this selection.
 boolean contains(java.lang.Class<?> c)
          Returns true if selection contains any items of the given class.
 boolean contains(Displayable d)
           
 boolean containsAffected(java.lang.Class<?> c)
          If any of the selected or linked is of Class c.
protected  void debug(java.lang.String msg)
           
 boolean deleteAll()
          Delete all selected objects from their Layer.
<T extends Displayable>
java.util.List<T>
get(java.lang.Class<T> c)
          Returns a list of selected Displayable of class c only.
 Displayable getActive()
           
 java.util.Set<Displayable> getAffected()
          Returns the set of all Displayable objects affected by this selection, that is, the selected ones and their linked ones.
 java.util.Set<Displayable> getAffected(java.lang.Class<?> c)
          Returns the set of all Displayable objects of the given class affected by this selection, that is, among the selected ones and their linked ones.
 java.awt.Rectangle getBox()
          Returns a copy of the box enclosing all selected ob, or null if none.
 Layer getLayer()
          Returns the Layer of the Display, or if the latter is null, that of the first selected Displayable.
 java.awt.Rectangle getLinkedBox()
          Returns the total box enclosing all selected objects and their linked objects within the current layer, or null if none are selected.
 int getNLinked()
           
 int getNSelected()
           
 Project getProject()
          Returns the Project of the Display, or if the latter is null, that of the first selected Displayable.
 java.util.ArrayList<Displayable> getSelected()
          Returns a copy of the list of all selected Displayables (and not their linked ones).
 java.util.ArrayList<Displayable> getSelected(java.lang.Class<?> c)
          Returns a copy of the list of all selected Displayables (and not their linked ones) of the given class.
 java.util.List<Displayable> getSelectedSorted(java.lang.Class<? extends Displayable> c)
          Returns the subset of selected objects of Class c, in the proper order according to the Layer.indexOf or the LayerSet.indexOf.
 boolean isEmpty()
           
 boolean isLocked()
          Test if any of the selection objects is directly or indirectly locked.
 void measure()
          Call measure(ResultsTable) on every selected Displayable.
 void moveDown()
          Send all selected components to the next layer.
 void moveUp()
          Send all selected components to the previous layer.
 void remove(Displayable d)
          Remove the given displayable from this selection.
 void removeAll(java.util.Collection<Displayable> col)
          Remove all given displayables from this selection.
protected  void removeFromPrev(Displayable d)
          Removes the given Displayable from the selection and previous selection list.
 void resetBox()
          Recalculate box and reset handles.
 void restore()
          Restore the previous selection.
 void rotate(double angle, double xo, double yo)
          Rotate the objects in the current selection by the given angle, in degrees, relative to the x_o, y_o origin.
 void scale(double sx, double sy, double x_o, double y_o)
          Scale all selected objects and their links by by the given scales, relative to the origin position.
 void selectAll()
          Select all objects in the Display's current layer, preserving the active one (if any) as active; includes all the ZDisplayables, whether visible in this layer or not.
 void selectAll(java.util.Collection<? extends Displayable> al)
           
 void selectAll(Layer layer)
          Select all objects in the given layer, preserving the active one (if any) as active.
 void selectAll(ij.gui.Roi roi, boolean visible_only)
          Select all objects under the given roi, in the current display's layer.
 void selectAllVisible()
          Select all isVisible() objects in the Display's current layer, preserving the active one (if any) as active; includes all the ZDisplayables, whether visible in this layer or not, as long as their return true from isVisible().
 void setActive(Displayable d)
           
 void setAlpha(float alpha)
           
 void setColor(java.awt.Color c)
           
 void setLocked(boolean b)
          Lock / unlock all selected objects.
 void setLut(java.awt.image.ColorModel cm)
          Apply the given LUT to all selected 8-bit, 16-bit, 32-bit images.
 java.util.Collection<Displayable> setVisible(boolean b)
          Set all selected objects visible/hidden; returns a collection of those that changed state.
 void specify()
           
 void translate(double dx, double dy)
          Translate all selected objects and their links by the given differentials.
 void updateTransform(Displayable d)
          Update the bounding box of the whole selection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PADDING

public static int PADDING
Outward padding in pixels around the selected Displayables maximum enclosing box that may need repainting when updating the screen.

Constructor Detail

Selection

public Selection(Display display)
The Display can be null, as long as paint, OvalHandle.contains, setTransforming, and getLinkedBox methods are never called on this object.

Method Detail

setActive

public void setActive(Displayable d)

getActive

public Displayable getActive()

add

public void add(Displayable d)

selectAll

public void selectAll()
Select all objects in the Display's current layer, preserving the active one (if any) as active; includes all the ZDisplayables, whether visible in this layer or not.


selectAllVisible

public void selectAllVisible()
Select all isVisible() objects in the Display's current layer, preserving the active one (if any) as active; includes all the ZDisplayables, whether visible in this layer or not, as long as their return true from isVisible().


selectAll

public void selectAll(Layer layer)
Select all objects in the given layer, preserving the active one (if any) as active.


selectAll

public void selectAll(ij.gui.Roi roi,
                      boolean visible_only)
Select all objects under the given roi, in the current display's layer. If visible_only, then a Displayable is not selected when its visible boolean flag is false, or its alpha value is zero, or either of its width,height dimensions are 0.


selectAll

public void selectAll(java.util.Collection<? extends Displayable> al)

deleteAll

public boolean deleteAll()
Delete all selected objects from their Layer.


removeAll

public void removeAll(java.util.Collection<Displayable> col)
Remove all given displayables from this selection.


remove

public void remove(Displayable d)
Remove the given displayable from this selection.


clear

public void clear()
Remove all Displayables from this selection.


getLinkedBox

public java.awt.Rectangle getLinkedBox()
Returns the total box enclosing all selected objects and their linked objects within the current layer, or null if none are selected. Includes the position of the floater, when transforming.


isLocked

public boolean isLocked()
Test if any of the selection objects is directly or indirectly locked.


setLocked

public void setLocked(boolean b)
Lock / unlock all selected objects.


setColor

public void setColor(java.awt.Color c)

setAlpha

public void setAlpha(float alpha)

isEmpty

public boolean isEmpty()

contains

public boolean contains(Displayable d)

contains

public boolean contains(java.lang.Class<?> c)
Returns true if selection contains any items of the given class.


debug

protected void debug(java.lang.String msg)

updateTransform

public void updateTransform(Displayable d)
Update the bounding box of the whole selection.


getNSelected

public int getNSelected()

getNLinked

public int getNLinked()

rotate

public void rotate(double angle,
                   double xo,
                   double yo)
Rotate the objects in the current selection by the given angle, in degrees, relative to the x_o, y_o origin.


translate

public void translate(double dx,
                      double dy)
Translate all selected objects and their links by the given differentials. The floater position is unaffected; if you want to update it call centerFloater()


scale

public void scale(double sx,
                  double sy,
                  double x_o,
                  double y_o)
Scale all selected objects and their links by by the given scales, relative to the origin position.


getSelected

public java.util.ArrayList<Displayable> getSelected()
Returns a copy of the list of all selected Displayables (and not their linked ones).


getSelected

public java.util.ArrayList<Displayable> getSelected(java.lang.Class<?> c)
Returns a copy of the list of all selected Displayables (and not their linked ones) of the given class.


get

public <T extends Displayable> java.util.List<T> get(java.lang.Class<T> c)
Returns a list of selected Displayable of class c only. Same as getSelected(Class) but returning a List of the desired type.


getSelectedSorted

public java.util.List<Displayable> getSelectedSorted(java.lang.Class<? extends Displayable> c)
Returns the subset of selected objects of Class c, in the proper order according to the Layer.indexOf or the LayerSet.indexOf. Class c cannot be Displayable (returns null); must be any Displayable subclass.


getAffected

public java.util.Set<Displayable> getAffected()
Returns the set of all Displayable objects affected by this selection, that is, the selected ones and their linked ones.


getAffected

public java.util.Set<Displayable> getAffected(java.lang.Class<?> c)
Returns the set of all Displayable objects of the given class affected by this selection, that is, among the selected ones and their linked ones.


containsAffected

public boolean containsAffected(java.lang.Class<?> c)
If any of the selected or linked is of Class c.


moveUp

public void moveUp()
Send all selected components to the previous layer.


moveDown

public void moveDown()
Send all selected components to the next layer.


setVisible

public java.util.Collection<Displayable> setVisible(boolean b)
Set all selected objects visible/hidden; returns a collection of those that changed state. Also updates checkboxes state in the Display.


removeFromPrev

protected void removeFromPrev(Displayable d)
Removes the given Displayable from the selection and previous selection list.


restore

public void restore()
Restore the previous selection.


specify

public void specify()

apply

protected void apply(int what,
                     double[] params)

setLut

public void setLut(java.awt.image.ColorModel cm)
Apply the given LUT to all selected 8-bit, 16-bit, 32-bit images.


getProject

public Project getProject()
Returns the Project of the Display, or if the latter is null, that of the first selected Displayable.


getLayer

public Layer getLayer()
Returns the Layer of the Display, or if the latter is null, that of the first selected Displayable.


getBox

public java.awt.Rectangle getBox()
Returns a copy of the box enclosing all selected ob, or null if none.


resetBox

public void resetBox()
Recalculate box and reset handles.


measure

public void measure()
Call measure(ResultsTable) on every selected Displayable.