com.mindfusion.diagramming
Class Selection

java.lang.Object
  extended by com.mindfusion.diagramming.DiagramItem
      extended by com.mindfusion.diagramming.Selection
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public final class Selection
extends DiagramItem

Represents a selection of multiple items. Each Diagram has its own Selection instance, which can be accessed via the Diagram.getSelection() method.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.mindfusion.diagramming.DiagramItem
brush, cycleDetected, cycleProtect, modifyDX, modifyDY, modifyHandle, modifying, pen, ptEnd, ptMdfLast, ptOrg, ptSavedEnd, ptSavedOrg, subordinateGroup
 
Constructor Summary
Selection()
          Initializes a new Selection instance.
 
Method Summary
 void addItem(DiagramItem item)
          Adds the specified item to the selection.
protected  boolean allowCreate(java.awt.geom.Point2D current, InteractionState ist)
          Invoked during interactive creation of items to test whether the operation can be completed in the current context.
protected  boolean allowModify(java.awt.geom.Point2D current, InteractionState ist)
          Invoked during interactive modification of items to test whether the operation can be completed in the current context.
protected  void cancelModify(InteractionState ist)
          Invoked when the interactive modification of this object has been canceled.
 void change(DiagramItem item)
          Changes the selection to the specified item.
 void clear()
          Removes all items from the selection.
protected  void completeCreate(java.awt.geom.Point2D end)
          Invoked when the item creation has been completed.
protected  void completeModify(java.awt.geom.Point2D end, InteractionState ist)
          Invoked when the item modification has been completed.
 boolean containsPoint(java.awt.geom.Point2D point)
          DiagramItem.containsPoint override.
protected  void draw(java.awt.Graphics2D g, RenderOptions options)
           
protected  void drawShadow(java.awt.Graphics2D g, RenderOptions options)
           
 boolean getAllowMultipleSelection()
          Gets a value indicating whether users are allowed to select multiple items.
 java.awt.geom.Rectangle2D.Float getBounds()
          Gets the smallest rectangle that bounds all selected items.
 int getHandlesStyle()
          Gets a value indicating how multiple selection is drawn on the screen.
 DiagramItemList getItems()
          Gets a list of all selected items.
 DiagramLinkList getLinks()
          Gets a list of all selected links.
 DiagramNodeList getNodes()
          Gets a list of all selected boxes.
protected  java.awt.geom.Rectangle2D getRepaintRect(boolean connected)
          Gets the repaint region for this item, taking into account factors such as pen, selection handles and shadow.
 boolean itemInSelection(DiagramItem item)
          Determines whether the specified item is selected.
 void readExternal(java.io.ObjectInput in)
          Implements Externalizable.
 boolean removeItem(DiagramItem item)
          Removes the specified item from the selection.
 void setAllowMultipleSelection(boolean value)
          Sets a value indicating whether users are allowed to select multiple items.
 void setHandlesStyle(int value)
          Sets a value indicating how multiple selection should be drawn on the screen.
 int size()
          Returns the number of selected items.
protected  void startCreate(java.awt.geom.Point2D org)
          Invoked once when the user starts creating a new item interactively.
protected  void startModify(java.awt.geom.Point2D org, int handle, InteractionState ist)
          Invoked when the user starts modifying this item interactively.
 void toggle(DiagramItem item)
          Toggles the selection state of the specified item.
protected  void updateCreate(java.awt.geom.Point2D current)
          Invoked during interactive creation of this item.
protected  void updateModify(java.awt.geom.Point2D current, InteractionState ist)
          Invoked during interactive modification of this item.
 void writeExternal(java.io.ObjectOutput out)
          Implements Externalizable.
 
Methods inherited from class com.mindfusion.diagramming.DiagramItem
clone, createProperties, createState, getBrush, getEffectiveBrush, getEffectiveFont, getEffectivePen, getEffectiveShadowBrush, getEffectiveTextBrush, getFont, getHyperLink, getId, getIgnoreLayout, getLayerIndex, getLayoutTraits, getLocked, getMasterGroup, getMeasureUnit, getParent, getPen, getPrintable, getRuntimeIndex, getSelected, getShadowBrush, getShadowOffsetX, getShadowOffsetY, getStyle, getSubordinateGroup, getTag, getTextBrush, getTextPadding, getToolTip, getValue, getVisible, getWeight, getZIndex, hasSubordinates, loadFromXml, onAdd, onChangeFont, onChangeTextPadding, onChildModified, onClick, onDoubleClick, onLoad, onModify, onRemove, onStyleChanged, putSelected, query, repaint, repaint, repaint, restoreProperties, restoreState, saveProperties, saveState, saveToXml, setBrush, setDiagramDirty, setFont, setHyperLink, setId, setIgnoreLayout, setLayerIndex, setLocked, setPen, setPrintable, setSelected, setShadowBrush, setShadowOffsetX, setShadowOffsetY, setStyle, setTag, setTextBrush, setTextPadding, setToolTip, setVisible, setWeight, setZIndex, shouldRender, zBottom, zLevelDown, zLevelUp, zTop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Selection

public Selection()
Initializes a new Selection instance.

Method Detail

startModify

protected void startModify(java.awt.geom.Point2D org,
                           int handle,
                           InteractionState ist)
Description copied from class: DiagramItem
Invoked when the user starts modifying this item interactively.

Overrides:
startModify in class DiagramItem
Parameters:
org - Position of the mouse pointer.
handle - Index of the adjustment handle used to modify the item.
ist - An InteractionState object containing more information about the current state of the operation.

updateModify

protected void updateModify(java.awt.geom.Point2D current,
                            InteractionState ist)
Description copied from class: DiagramItem
Invoked during interactive modification of this item.

Overrides:
updateModify in class DiagramItem
Parameters:
current - Position of the mouse pointer.
ist - An InteractionState object containing more information about the current state of the operation.

completeModify

protected void completeModify(java.awt.geom.Point2D end,
                              InteractionState ist)
Description copied from class: DiagramItem
Invoked when the item modification has been completed.

Overrides:
completeModify in class DiagramItem
Parameters:
end - The mouse pointer position.
ist - An InteractionState object containing more information about the current state of the operation.

startCreate

protected void startCreate(java.awt.geom.Point2D org)
Description copied from class: DiagramItem
Invoked once when the user starts creating a new item interactively.

Overrides:
startCreate in class DiagramItem
Parameters:
org - Position of the mouse pointer.

updateCreate

protected void updateCreate(java.awt.geom.Point2D current)
Description copied from class: DiagramItem
Invoked during interactive creation of this item.

Overrides:
updateCreate in class DiagramItem
Parameters:
current - Position of the mouse pointer.

completeCreate

protected void completeCreate(java.awt.geom.Point2D end)
Description copied from class: DiagramItem
Invoked when the item creation has been completed.

Overrides:
completeCreate in class DiagramItem
Parameters:
end - The mouse pointer position.

allowModify

protected boolean allowModify(java.awt.geom.Point2D current,
                              InteractionState ist)
Description copied from class: DiagramItem
Invoked during interactive modification of items to test whether the operation can be completed in the current context.

Specified by:
allowModify in class DiagramItem
Parameters:
current - The current mouse pointer position.
ist - An InteractionState object containing more information about the current state of the operation.
Returns:
true to allow the modification of this item; otherwise, false.

cancelModify

protected void cancelModify(InteractionState ist)
Description copied from class: DiagramItem
Invoked when the interactive modification of this object has been canceled.

Overrides:
cancelModify in class DiagramItem
Parameters:
ist - An InteractionState object containing more information about the current state of the operation.

draw

protected void draw(java.awt.Graphics2D g,
                    RenderOptions options)
Specified by:
draw in class DiagramItem

drawShadow

protected void drawShadow(java.awt.Graphics2D g,
                          RenderOptions options)
Specified by:
drawShadow in class DiagramItem

containsPoint

public boolean containsPoint(java.awt.geom.Point2D point)
DiagramItem.containsPoint override.

Specified by:
containsPoint in class DiagramItem
Parameters:
point - The point to check.
Returns:
true it this item contains the specified point; otherwise, false.

getRepaintRect

protected java.awt.geom.Rectangle2D getRepaintRect(boolean connected)
Description copied from class: DiagramItem
Gets the repaint region for this item, taking into account factors such as pen, selection handles and shadow.

Overrides:
getRepaintRect in class DiagramItem
Parameters:
connected - true if related items should be considered too; otherwise, false.
Returns:
A rectangular region that should be repainted when this item is modified.

size

public int size()
Returns the number of selected items.

Returns:
An integer value specifying the number of selected items.

allowCreate

protected boolean allowCreate(java.awt.geom.Point2D current,
                              InteractionState ist)
Description copied from class: DiagramItem
Invoked during interactive creation of items to test whether the operation can be completed in the current context.

Specified by:
allowCreate in class DiagramItem
Parameters:
current - The current mouse pointer position.
ist - An InteractionState object containing more information about the current state of the operation.
Returns:
true to allow the creation of this item; otherwise, false.

toggle

public void toggle(DiagramItem item)
Toggles the selection state of the specified item.

Parameters:
item - An DiagramItem whose selection state should be toggled.

change

public void change(DiagramItem item)
Changes the selection to the specified item. I.e. that item gets selected and all other items are unselected.

Parameters:
item - The DiagramItem that should be selected.

addItem

public void addItem(DiagramItem item)
Adds the specified item to the selection.

Parameters:
item - An DiagramItem that should be added to the multiple selection.

removeItem

public boolean removeItem(DiagramItem item)
Removes the specified item from the selection.

Parameters:
item - The DiagramItem that should be deselected.
Returns:
false if the specified item was not selected, otherwise true.

itemInSelection

public boolean itemInSelection(DiagramItem item)
Determines whether the specified item is selected.

Parameters:
item - The DiagramItem whose selection state to check.
Returns:
true if the item is selected, otherwise false.

clear

public void clear()
Removes all items from the selection.


getItems

public DiagramItemList getItems()
Gets a list of all selected items.

Returns:
An DiagramItemList containing the selected items.

getLinks

public DiagramLinkList getLinks()
Gets a list of all selected links.

Returns:
An DiagramLinkList containing the selected links.

getNodes

public DiagramNodeList getNodes()
Gets a list of all selected boxes.

Returns:
A ShapeNodeList containing the selected boxes.

getHandlesStyle

public int getHandlesStyle()
Gets a value indicating how multiple selection is drawn on the screen.

Returns:
One of the SelectionStyle constants.

setHandlesStyle

public void setHandlesStyle(int value)
Sets a value indicating how multiple selection should be drawn on the screen.

Parameters:
value - One of the SelectionStyle constants.

getAllowMultipleSelection

public boolean getAllowMultipleSelection()
Gets a value indicating whether users are allowed to select multiple items.

Returns:
true if users are allowed to select multiple items, otherwise false.

setAllowMultipleSelection

public void setAllowMultipleSelection(boolean value)
Sets a value indicating whether users are allowed to select multiple items.

Parameters:
value - true if users are allowed to select multiple items, otherwise false.

getBounds

public java.awt.geom.Rectangle2D.Float getBounds()
Gets the smallest rectangle that bounds all selected items.

Specified by:
getBounds in class DiagramItem
Returns:
A Rectangle2D.Float object representing the rectangle that bounds all selected items.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Implements Externalizable.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class DiagramItem
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implements Externalizable.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class DiagramItem
Throws:
java.io.IOException
java.lang.ClassNotFoundException