public class DefaultSelectionHandler extends PicGroup implements SelectionHandler, DrawingListener, ViewConstants, PicObjectConstants
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.
PicGroup.GroupPointIterator| Modifier and Type | Field and Description |
|---|---|
static java.lang.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 java.lang.String |
LOCAL_MODE
Highlighting mode corresponding to each Element belonging to the selection is highlighted
|
FIRST_PT, LAST_PT, LL, LM, LR, ML, MR, UL, UM, URchangeLock, children, ptsX, ptsYattributeSet, parent, viewBARBELL_SIZE, CLICK_DISTANCEARROW_GLOBAL_SCALE_LENGTH, ARROW_GLOBAL_SCALE_WIDTH, ARROW_INSET_SCALE, ARROW_LENGTH_SCALE, ARROW_WIDTH_LINEWIDTH_SCALE, ARROW_WIDTH_MINIMUM_MM, BRACKET_LENGTH_SCALE, CROSSHATCH, CROSSHATCH_FILLED, DASH_OPAQUE, DASH_TRANSPARENT, DASH1, DASH2, DASH3, DASHED, DIMEN, DOT_SEP, DOT_SEP1, DOT_SEP2, DOT_SEP3, DOTTED, DOUBLE_COLOR, DOUBLE_LINE, DOUBLE_SEP, FILL_COLOR, FILL_STYLE, HATCH_ANGLE, HATCH_COLOR, HATCH_SEP, HATCH_WIDTH, HLINES, HLINES_FILLED, INNER, LEFT_ARROW, LINE_COLOR, LINE_STYLE, LINE_WIDTH, MIDDLE, NONE, OUTER, OVER_STRIKE, OVER_STRIKE_COLOR, OVER_STRIKE_WIDTH, POLYDOTS_ANGLE, POLYDOTS_CIRCLE, POLYDOTS_DISK, POLYDOTS_PENTAGON, POLYDOTS_PENTAGON_FILLED, POLYDOTS_PLUS, POLYDOTS_SCALE_H, POLYDOTS_SCALE_V, POLYDOTS_SIZE_LINEWIDTH_SCALE, POLYDOTS_SIZE_MINIMUM_MM, POLYDOTS_SQUARE, POLYDOTS_SQUARE_FILLED, POLYDOTS_STYLE, POLYDOTS_SUPERIMPOSE, POLYDOTS_TRIANGLE, POLYDOTS_TRIANGLE_FILLED, PS_POINT, PST_CUSTOM, RBRACKET_LENGTH_SCALE, RIGHT_ARROW, SHADOW, SHADOW_ANGLE, SHADOW_COLOR, SHADOW_SIZE, SOLID, TBAR_WIDTH_LINEWIDTH_SCALE, TBAR_WIDTH_MINIMUM_MM, TEXT_BOX_CIRCLE, TEXT_BOX_NO_FRAME, TEXT_BOX_OVAL, TEXT_BOX_RECTANGLE, TEXT_FRAME, TEXT_HALIGN_CENTER, TEXT_HALIGN_LEFT, TEXT_HALIGN_RIGHT, TEXT_HOR_ALIGN, TEXT_ROTATION, TEXT_VALIGN_BASELINE, TEXT_VALIGN_BOTTOM, TEXT_VALIGN_CENTER, TEXT_VALIGN_TOP, TEXT_VERT_ALIGN, VLINES, VLINES_FILLED| Constructor and Description |
|---|
DefaultSelectionHandler(EditorKit kit)
construct a new selection handler for this editor kit, with SelectionHandlerView as the default view.
|
| Modifier and Type | Method and Description |
|---|---|
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)
|
java.util.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.
|
java.util.Iterator |
elements()
Return an iterator over the selected Element's
|
protected void |
fireChangedUpdate(DrawingEvent.EventType eventType)
Called each time this DefaultSelectionHandler changes.
|
java.lang.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(java.awt.Graphics2D g,
java.awt.geom.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(java.lang.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
|
java.lang.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.
|
anchorPointsIterator, clone, createActions, createCustomizer, getFirstPointIndex, getLastPointIndex, getName, getPointX, getPointY, setPointadd, 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, updateBoundingBoxgetAttribute, getAttributeSet, getDrawing, getView, setParentfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontainsClass, createFilteredCollection, sizepublic static final java.lang.String LOCAL_MODE
public static final java.lang.String GLOBAL_MODE
public DefaultSelectionHandler(EditorKit kit)
public void setHighlightingMode(java.lang.String mode)
mode - or LOCAL_MODE or GLOBAL_MODEpublic java.lang.String getHighlightingMode()
public void toggleHighlightingMode()
public void paint(java.awt.Graphics2D g,
java.awt.geom.Rectangle2D allocation,
double scale)
public HitInfo hitTest(PEMouseEvent me)
public java.util.Iterator elements()
SelectionHandlerelements in interface SelectionHandlerpublic java.util.Collection asCollection()
SelectionHandlerasCollection in interface SelectionHandlerpublic Element[] asArray()
SelectionHandlerasArray in interface SelectionHandlerpublic boolean isSelected(Element e, boolean includeAncestors)
SelectionHandlerisSelected in interface SelectionHandlerincludeAncestors - if true, return true if this Element or one of its ancestors is selected.public void selectAll(Drawing d)
selectAll in interface SelectionHandlerpublic void unSelectAll()
unSelectAll in interface SelectionHandlerpublic void addToSelection(Element e)
addToSelection in interface SelectionHandlerpublic void replaceSelection(Element e)
replaceSelection in interface SelectionHandlerpublic void unSelect(Element e)
unSelect in interface SelectionHandlerpublic void delete(Drawing dr)
delete in interface SelectionHandlerpublic void addChild(Element child)
addChild in class BranchElementpublic void removeChild(Element child)
removeChild in class BranchElementchild - if child is the selection-handler itself, call removeAllChildren().public void removeAllChildren()
removeAllChildren in class BranchElementpublic Element getParent()
getParent in interface ElementgetParent in class AbstractElementpublic void sort()
protected void fireChangedUpdate(DrawingEvent.EventType eventType)
super.fireChangeUpdate.fireChangedUpdate in class AbstractElementtype - the event typepublic java.lang.String toString()
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 DrawingListenerSubmit a bug : syd@jpicedt.org