|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpicedt.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 |
Nested classes/interfaces inherited from class jpicedt.graphic.model.BranchElement |
---|
BranchElement.CompoundMode |
Field Summary |
---|
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, compoundMode, DEFAULT_LIFTPEN, isPathClosed, liftPen, ptsX, ptsY, shape |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, name, parent, view |
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)
|
boolean |
add(Element child)
overriden so that the parent of the added element isn't set to this, and its view is left unchanged. |
void |
add(int position,
Element child)
Convenient call to add(child). |
boolean |
addAll(Collection<? extends Element> c)
Appends all the elements in the given collection that are instance of Element as children of this BranchElement. |
boolean |
addAll(int index,
Collection<? extends Element> c)
Commodité d'appel de addAll(c) . |
Element[] |
asArray()
Return the selected elements wrapped in an array (may be a convenience call to asCollection) |
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 |
clear()
overriden so as to leave children parent and view unchanged. |
void |
delete(Drawing dr)
Delete all selected Element 's from the given Drawing , and remove the
reference to them from the SelectionHandler . |
protected void |
fireChangedUpdate(DrawingEvent.EventType eventType)
Called each time this DefaultSelectionHandler changes. |
String |
getName()
Return a non-localised string representing this element's name. |
BranchElement |
getParent()
Gets the parent of the element. |
HitInfo |
hitTest(PEMouseEvent me)
hitTest on the content of the selection only |
boolean |
intersect(Rectangle2D r,
ArrayList<Element> list)
|
void |
paint(Graphics2D g,
Rectangle2D allocation,
double scale)
paint the selection handler highlighting |
Element |
remove(int index)
Remove the child with the given index from this BranchElement . |
boolean |
remove(Object child)
Overriden so as to leave child's parent and view unchanged. |
void |
replace(Element e)
Replace the current selection with the given element. |
void |
replace(Element oldE,
Element newE)
La méthode correspondante de PicGroup est surchargée pour ne pas affecter les vues. |
void |
selectAll(Drawing d)
Select all Element 's in the given drawing. |
void |
setCompoundMode(BranchElement.CompoundMode m)
If s is true, the associated view will attempt to paint this BranchElement
as a single path made up by piecing childrens' shapes (aka PSTricks' pscustom). |
void |
sort()
Sort selected elements according to their z-ordering in the given drawing |
String |
toString()
Returns a String representing the group for debugging use only. |
Methods inherited from class jpicedt.graphic.model.PicGroup |
---|
anchorPointsIterator, clone, createActions, createCustomizer, getCtrlPtX, getCtrlPtY, getDefaultName, getFirstPointIndex, getHighlightingMode, getLastPointIndex, setCtrlPt, setHighlightingMode, toggleHighlightingMode, unGroup |
Methods inherited from class jpicedt.graphic.model.BranchElement |
---|
bringBackward, bringForward, bringToBack, bringToFront, closePath, contains, containsAll, containsClass, createFilteredCollection, createShape, equals, forwardChangedUpdate, get, getBoundingBox, getCompoundMode, getCtrlPt, getCtrlPtSubset, getLiftPen, hashCode, indexOf, isEmpty, isPathClosed, isToBack, isToFront, iterator, lastIndexOf, listIterator, listIterator, mirror, openPath, removeAll, removeView, retainAll, rotate, scale, set, setAttribute, setAttributeSet, setCtrlPt, setLiftPen, setViewFromFactory, shear, shear, size, subList, syncArrowGeometry, toArray, toArray, toggleCompoundMode, togglePathClosure, translate, updateBoundingBox |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
getAttribute, getAttributeSet, getDrawing, getView, pullOutOfGroup, replaceBy, scale, scale, scale, setName, setParent |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface jpicedt.graphic.SelectionHandler |
---|
containsClass, createFilteredCollection, getCtrlPtSubset |
Methods inherited from interface java.util.Collection |
---|
contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface jpicedt.graphic.model.Element |
---|
createShape, getAttribute, getAttributeSet, getBoundingBox, getCtrlPt, getCtrlPtSubset, getDrawing, getView, mirror, removeView, replaceBy, rotate, scale, scale, scale, scale, setAttribute, setAttributeSet, setCtrlPt, setParent, setViewFromFactory, shear, shear, syncArrowGeometry, translate |
Constructor Detail |
---|
public DefaultSelectionHandler(EditorKit kit)
Method Detail |
---|
public String getName()
Element
getName
in interface Element
getName
in class AbstractElement
public void paint(Graphics2D g, Rectangle2D allocation, double scale)
public HitInfo hitTest(PEMouseEvent me)
hitTest
on the content of the selection only
public boolean intersect(Rectangle2D r, ArrayList<Element> list)
public void setCompoundMode(BranchElement.CompoundMode m)
BranchElement
BranchElement
as a single path made up by piecing childrens' shapes (aka PSTricks' pscustom).
The associated formatter is expected to do likewise if its hosting content-type
supports it. If s is false, this is the legacy behaviour, that is, every
child is painted independently.
setCompoundMode
in class BranchElement
public Element[] asArray()
asArray
in interface SelectionHandler
public void selectAll(Drawing d)
Element
's in the given drawing.
selectAll
in interface SelectionHandler
public void replace(Element e)
unSelectAll
then addToSelection
.
replace
in interface SelectionHandler
public void replace(Element oldE, Element newE)
PicGroup
est surchargée pour ne pas affecter les vues.
replace
in interface SelectionHandler
replace
in class BranchElement
oldE
- l'Element
à remplacer.newE
- l'Element
qui sert de remplacement.SelectionHandler.replace(Element oldE, Element newE)
public void delete(Drawing dr)
Element
's from the given Drawing
, and remove the
reference to them from the SelectionHandler
.
delete
in interface SelectionHandler
public boolean add(Element child)
add
in interface Collection<Element>
add
in interface List<Element>
add
in class BranchElement
public void add(int position, Element child)
add
in interface List<Element>
add
in class BranchElement
public boolean addAll(Collection<? extends Element> c)
addAll
in interface Collection<Element>
addAll
in interface List<Element>
addAll
in class BranchElement
public boolean addAll(int index, Collection<? extends Element> c)
addAll(c)
.
addAll
in interface List<Element>
addAll
in class BranchElement
public boolean remove(Object child)
remove
in interface Collection<Element>
remove
in interface List<Element>
remove
in class BranchElement
child
- if child is the selection-handler itself, call removeAllChildren()
.
true
si child faisait partie de la sélection.public Element remove(int index)
BranchElement
.
remove
in interface List<Element>
remove
in class BranchElement
public void clear()
clear
in interface Collection<Element>
clear
in interface List<Element>
clear
in class BranchElement
public BranchElement getParent()
getParent
in interface Element
getParent
in class AbstractElement
public void sort()
protected void fireChangedUpdate(DrawingEvent.EventType eventType)
AbstractElement
so as to update the associated View
only, i.e. there is no
event being forwarded to the parent (which here is the Drawing.RootElement, see
e.g. getParent()
). The point is that this method gets called whenever
setCtrlPt/scale/translate/… is called on the selection-handler, which indirectly triggers a
DrawingEvent on behalf of the selected elements themselves. Hence it doesn't make sense to post these
events twice. super.fireChangeUpdate
.
fireChangedUpdate
in class AbstractElement
eventType
- the event typepublic String toString()
toString
in class PicGroup
public void _changedUpdate(DrawingEvent e)
public void changedUpdate(DrawingEvent e)
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
).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 |