|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjpicedt.graphic.model.AbstractElement
jpicedt.graphic.model.BranchElement
jpicedt.graphic.model.PicGroup
jpicedt.graphic.toolkit.DefaultSelectionHandler
public class DefaultSelectionHandler
Stores references to selected Element's.
This handler has the same capabilities as jpicedt.graphic.model.PicGroup, except that it does not belong to any jpicedt.graphic.model.Drawing.RootElement. Hence it is guaranteed that this handler will NEVER notify the parent document (=the hosting Drawing) when content gets added to/removed from it, since it has no parent. This design choice is aimed at avoiding redundant event generation, since (for instance) deleting a selected element would then trigger the same DrawingEvent twice (one on behalf of this handler, the other one on behalf of the hosting Drawing). Content modifying method are overriden so as to reflect this.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class jpicedt.graphic.model.PicGroup |
---|
PicGroup.GroupPointIterator |
Field Summary | |
---|---|
static String |
GLOBAL_MODE
Highlighting mode corresponding to the selection-handler behaving as if it were a PicGroup, hence its 8 control-points only are highlighted |
static String |
LOCAL_MODE
Highlighting mode corresponding to each Element belonging to the selection is highlighted |
Fields inherited from class jpicedt.graphic.model.PicGroup |
---|
FIRST_PT, LAST_PT, LL, LM, LR, ML, MR, UL, UM, UR |
Fields inherited from class jpicedt.graphic.model.BranchElement |
---|
changeLock, children, ptsX, ptsY |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, parent, view |
Fields inherited from interface jpicedt.graphic.view.ViewConstants |
---|
BARBELL_SIZE, CLICK_DISTANCE |
Constructor Summary | |
---|---|
DefaultSelectionHandler(EditorKit kit)
construct a new selection handler for this editor kit, with SelectionHandlerView as the default view. |
Method Summary | |
---|---|
void |
_changedUpdate(DrawingEvent e)
|
void |
addChild(Element child)
overriden so that the parent of the added element isn't set to this, and its view is left unchanged. |
void |
addToSelection(Element e)
Add the given Element to the current selection |
Element[] |
asArray()
Return the selected elements wrapped in an array (may be a convenience call to asCollection) |
Collection |
asCollection()
Return the selected elements wrapped in a Collection |
void |
changedUpdate(DrawingEvent e)
Implementation of DrawingListener interface aimed at keeping this selection-handler always synchronized with the Drawing, especially when the Drawing content gets modified directly throught the Drawing API (as opposed to using selection-related methods in PECanvas). |
void |
delete(Drawing dr)
Delete all selected Element's from the given Drawing, and remove the reference to them from the SelectionHandler. |
Iterator |
elements()
Return an iterator over the selected Element's |
protected void |
fireChangedUpdate(DrawingEvent.EventType eventType)
Called each time this DefaultSelectionHandler changes. |
String |
getHighlightingMode()
Return the current highlighting mode |
Element |
getParent()
Gets the parent of the element. |
HitInfo |
hitTest(PEMouseEvent me)
hitTest on the content of the selection only |
boolean |
isSelected(Element e,
boolean includeAncestors)
Return whether the given Element is selected or not |
void |
paint(Graphics2D g,
Rectangle2D allocation,
double scale)
paint the selection handler highlighting |
void |
removeAllChildren()
overriden so as to leave children parent and view unchanged. |
void |
removeChild(Element child)
overriden so as to leave child's parent and view unchanged. |
void |
replaceSelection(Element e)
Replace the current selection with the given element. |
void |
selectAll(Drawing d)
Select all Element's in the given drawing. |
void |
setHighlightingMode(String mode)
set the current highlighting mode ; this influences the way the Highligther is painted, but also the result returned by HitTest. |
void |
sort()
Sort selected elements according to their z-ordering in the given drawing |
void |
toggleHighlightingMode()
Toggle the current highlighting mode |
String |
toString()
Returns a String representing the group for debugging use only. |
void |
unSelect(Element e)
Unselect the given Element, ie remove it from the current selection. |
void |
unSelectAll()
Unselect all Element's in the given drawing. |
Methods inherited from class jpicedt.graphic.model.PicGroup |
---|
anchorPointsIterator, clone, createActions, createCustomizer, getFirstPointIndex, getLastPointIndex, getName, getPointX, getPointY, setPoint |
Methods inherited from class jpicedt.graphic.model.BranchElement |
---|
add, addAll, addChild, bringBackward, bringForward, bringToBack, bringToFront, children, clear, contains, contains, containsAll, containsClass, createFilteredCollection, equals, forwardChangedUpdate, getAllowsChildren, getBoundingBox, getChildAt, getChildCount, getChildIndex, getPoint, isEmpty, isToBack, isToFront, iterator, remove, removeAll, removeView, replaceChild, retainAll, rotate, scale, scale, setAttribute, setAttributeSet, setPoint, setViewFromFactory, shear, size, toArray, toArray, translate, updateBoundingBox |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
getAttribute, getAttributeSet, getDrawing, getView, setParent |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface jpicedt.graphic.SelectionHandler |
---|
containsClass, createFilteredCollection, size |
Methods inherited from interface java.util.Collection |
---|
hashCode |
Field Detail |
---|
public static final String LOCAL_MODE
public static final String GLOBAL_MODE
Constructor Detail |
---|
public DefaultSelectionHandler(EditorKit kit)
Method Detail |
---|
public void setHighlightingMode(String mode)
mode
- or LOCAL_MODE or GLOBAL_MODEpublic String getHighlightingMode()
public void toggleHighlightingMode()
public void paint(Graphics2D g, Rectangle2D allocation, double scale)
public HitInfo hitTest(PEMouseEvent me)
public Iterator elements()
SelectionHandler
elements
in interface SelectionHandler
public Collection asCollection()
SelectionHandler
asCollection
in interface SelectionHandler
public Element[] asArray()
SelectionHandler
asArray
in interface SelectionHandler
public boolean isSelected(Element e, boolean includeAncestors)
SelectionHandler
isSelected
in interface SelectionHandler
includeAncestors
- if true, return true if this Element or one of its ancestors is selected.
public void selectAll(Drawing d)
selectAll
in interface SelectionHandler
public void unSelectAll()
unSelectAll
in interface SelectionHandler
public void addToSelection(Element e)
addToSelection
in interface SelectionHandler
public void replaceSelection(Element e)
replaceSelection
in interface SelectionHandler
public void unSelect(Element e)
unSelect
in interface SelectionHandler
public void delete(Drawing dr)
delete
in interface SelectionHandler
public void addChild(Element child)
addChild
in class BranchElement
public void removeChild(Element child)
removeChild
in class BranchElement
child
- if child is the selection-handler itself, call removeAllChildren().public void removeAllChildren()
removeAllChildren
in class BranchElement
public Element getParent()
getParent
in interface Element
getParent
in class AbstractElement
public void sort()
protected void fireChangedUpdate(DrawingEvent.EventType eventType)
super.fireChangeUpdate
.
fireChangedUpdate
in class AbstractElement
type
- the event typepublic String toString()
toString
in class PicGroup
public void _changedUpdate(DrawingEvent e)
public void changedUpdate(DrawingEvent e)
This method is invoked when an element changed in the Drawing.
If this is a REMOVE event type, and if the removed children (of the changed Element) were selected, we remove these children from the selection as well, ie we always keep the content of the selection-handler synchronized with the associated Drawing.
changedUpdate
in interface DrawingListener
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |