|
|
|||||||||
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
public class BranchElement
A class for Element
's that allow children, eg, primarily:
The implementation of the Collection interface is done through calls to
addChild
, removeChild
, children
,
removeAllChildren
, except for the addAll
method which is implemented from
scratch so as to fire a changed-event only once all elements have been added.
As a result, subclasses only need to override these methods
to change the behaviour of content-modifying methods.
This element has only one control point, namely, the bottom-left corner of the bounding box. Moving this
point result in a global translation of the element (however no rescale capability is available here using
the setCtrlPt()
method, use the PicGroup class instead).
Nested Class Summary | |
---|---|
static class |
BranchElement.CompoundMode
This BranchElement can be displayed, either as a group of objects (=children, "SEPARATE"
mode), or as a single path constructed by piecing children's paths together ("JOINT" mode). |
Field Summary | |
---|---|
protected boolean |
changeLock
A semaphor that signals a change of state is underway in this BranchElement and
it shouldn't process events coming from its children before the change is completed
(hence this is used inside forwardChangedUpdate() );
set it to true each time you start modifying children in batch mode and you don't want
events to be forwarded to the root of the hierarchy before everything is completed (e.g. to
get rid of side-effects, or to reduce the burden for the repaint manager). |
protected ArrayList<Element> |
children
the array that contains children |
protected BranchElement.CompoundMode |
compoundMode
current CompoundMode |
static int |
DEFAULT_LIFTPEN
[underway] liftpen not used yet. |
protected boolean |
isPathClosed
whether the path is closed or not (in "JOINT" mode) |
protected int |
liftPen
see PSTricks' doc, page 36; may take only integer values b/w 0 and 2; default to 0 ; [underway] liftpen not use yet. |
protected double[] |
ptsX
An array of X-coordinates representing the two opposite corner of the bounding box that contains all children |
protected double[] |
ptsY
an array of Y-coordinates representing the two opposite corner of the bounding box that contains all children |
protected GeneralPath |
shape
a path constructed by appending every child's path, aka pscustom; may be null if N/A |
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, name, parent, view |
Constructor Summary | |
---|---|
BranchElement()
Construct a BranchElement with no parent and a default PicAttributeSet . |
|
BranchElement(BranchElement src)
Cloning constructor (though with no parent and no view): attribute set is deeply copied. |
|
BranchElement(Collection<? extends Element> c)
Create a new BranchElement from the content of the given Collection of
Element 's. |
|
BranchElement(PicAttributeSet attributeSet)
Construct a BranchElement with no parent and the given PicAttributeSet |
Method Summary | ||
---|---|---|
boolean |
add(Element child)
Add the given child to this BranchElement , setting its parent to this. |
|
void |
add(int position,
Element child)
Insert the given child in this BranchElement at the given position, setting its parent to
this, and create a view for the child using the ViewFactory that produced the View for
this BranchElement . |
|
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)
Inserts all the elements in the given collection that are instance of Element
as children of this BranchElement , at the given position. |
|
void |
bringBackward(Element obj)
Move the given child one position backward, i.e. removes it from its current position and insert it one position backward. |
|
void |
bringForward(Element obj)
Move the given child one position forward, i.e. removes it from its current position and insert it one position forward. |
|
void |
bringToBack(Element obj)
Move the given child to back (i.e. following z-ordering policy), i.e. removes it from its current position and insert it at position 0 Does nothing if the given child can't be found in this Drawing or is already to back. |
|
void |
bringToFront(Element obj)
Move the given child to front, i.e. removes it from its current position and appends to the drawing. |
|
void |
clear()
Remove all children from this BranchElement , set each child's parent to null. |
|
BranchElement |
clone()
Returns a clone of this Element |
|
void |
closePath()
Closes the path generated by the children of this BranchElement . |
|
boolean |
contains(Object o)
Returns true if the given Element (or one of its ancestor) is contained in this
BranchElement . |
|
boolean |
containsAll(Collection<?> c)
Returns true if this BranchElement contains all of the elements
in the specified collection, possibly through indirect lineage. |
|
boolean |
containsClass(Class<? extends Element> clazz)
Returns whether this BranchElement contains children, grandchildren, etc. that are of the
same type of inherit from the given clazz . |
|
|
createFilteredCollection(Class<T> clazz)
Returns a list containing children, grand-children, etc. of this BranchElement that are of
the same type or inherit the given clazz . |
|
Shape |
createShape()
Creates a GeneralPath generated by the shapes of the
children of this BranchElement (aka PSTricks' pscustom object). |
|
boolean |
equals(Object o)
|
|
void |
forwardChangedUpdate(Element child,
DrawingEvent.EventType eventType)
Called by a child of this BranchElement to inform its parent of some change that occured
to it or one of its children. |
|
Element |
get(int childIndex)
|
|
Rectangle2D |
getBoundingBox(Rectangle2D r)
Returns the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of the \begin{picture} command. |
|
BranchElement.CompoundMode |
getCompoundMode()
Returns whether this group should be painted as single path or not. |
|
PicPoint |
getCtrlPt(int numPoint,
PicPoint dest)
Return the user-controlled point having the given index. |
|
CtrlPtSubset |
getCtrlPtSubset(ConvexZoneGroup csg,
BitSet czExtension)
Renvoie un la partie des points de contrôle qui satisfont à l'un des deux critères suivants: ceux compris dans l'ensemble de zones convexes csg , et
ceux en relation avec les points de contrôle satisfaisant au première critère selon une relation
définies par czExtension
|
|
double |
getCtrlPtX(int numPoint)
|
|
double |
getCtrlPtY(int numPoint)
This default implementation returns ptsY[numPoint] .This might be a valid implementation
as long as subclasses don't have other control points. |
|
String |
getDefaultName()
|
|
int |
getFirstPointIndex()
Return the index of the first user-controlled point that can be retrieved by getCtrlPt() |
|
int |
getLastPointIndex()
Return the index of the last user-controlled point that can be retrieved by getCtrlPt() |
|
int |
getLiftPen()
Returns the value of the liftPen parameter. |
|
int |
hashCode()
|
|
int |
indexOf(Object child)
Returns the index of the given child amongst the offspring of this BranchElement . |
|
boolean |
isEmpty()
|
|
boolean |
isPathClosed()
Returns whether the path generated by the children of this BranchElement
is closed or not. |
|
boolean |
isToBack(Element obj)
|
|
boolean |
isToFront(Element obj)
|
|
Iterator<Element> |
iterator()
Returns an iterator over children. |
|
int |
lastIndexOf(Object o)
Returns the index of the given child amongst the offspring of this BranchElement . |
|
ListIterator<Element> |
listIterator()
|
|
ListIterator<Element> |
listIterator(int index)
|
|
void |
mirror(PicPoint ptOrg,
PicVector normalVector)
Effectue une reflection sur le PicGroup . |
|
void |
openPath()
Closes the path generated by the children of this BranchElement . |
|
Element |
remove(int index)
Remove the child with the given index from this BranchElement . |
|
boolean |
remove(Object child)
Remove the given child from this BranchElement , setting its parent to null so
that the given child become (possibly) eligible for garbage collection if there are no other reference
to it. |
|
boolean |
removeAll(Collection<?> c)
Removes all this collection's elements that are also contained in the specified collection. |
|
void |
removeView()
Remove the view that render this element and propagate to children ; this may be used to remove any reference to the view, and render it eligible for garbage collection ; if no View, does nothing. |
|
void |
replace(Element src,
Element dest)
Replace the given "src" element with the given "dest" element, if "src" belongs to this BranchElement . |
|
boolean |
retainAll(Collection<?> c)
Retains only the elements in this BranchElement that are contained in the specified
collection. |
|
void |
rotate(PicPoint ptOrg,
double angle)
Rotate this Element by the given angle along the given point |
|
void |
scale(double ptOrgX,
double ptOrgY,
double sx,
double sy,
UserConfirmationCache ucc)
Scale children by (sx,sy) using (ptOrgX,ptOrgY) as origin; sx
or sy can be negative. |
|
Element |
set(int position,
Element newChild)
Replace the child at the given position by the given child. |
|
|
setAttribute(PicAttributeName<T> name,
T value)
Set an Attribute for this BranchElement and propagate to children. |
|
void |
setAttributeSet(PicAttributeSet set)
Set AttributeSet for this BranchElement and propagate to children. |
|
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 |
setCtrlPt(int index,
PicPoint pt)
Deprecated. use setCtrlPt(int, PicPoint, EditPointConstraint) instead. |
|
void |
setCtrlPt(int numPoint,
PicPoint pt,
EditPointConstraint c)
Set the point indexed by "numPoint" to the given value using the given constraint. |
|
void |
setLiftPen(int i)
Sets the value of the liftPen parameter. |
|
void |
setViewFromFactory(ViewFactory f)
Set the view for this Element from the given view factory, then set the view for children. |
|
void |
shear(PicPoint ptOrg,
double shx,
double shy)
Cisaille cet élément par (shx,shy) en utilisant ptOrg comme origine. |
|
void |
shear(PicPoint ptOrg,
double shx,
double shy,
UserConfirmationCache ucc)
Shear this Element by the given params wrt to the given origin. |
|
int |
size()
Return the number of children in this BranchElement (direct offspring only). |
|
List<Element> |
subList(int fromIndex,
int toIndex)
|
|
void |
syncArrowGeometry(ArrowView v,
ArrowView.Direction d)
Helper for the associated View. |
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection. |
|
|
toArray(T[] a)
Returns an array containing all of the elements in this collection whose runtime type is that of the specified array. |
|
void |
toggleCompoundMode()
Toggles whether this group should be painted as a single path or not. |
|
void |
togglePathClosure()
Toggles the closure of the path generated by the children of this BranchElement . |
|
String |
toString()
Returns a String representing the group for debugging use only. |
|
void |
translate(double dx,
double dy)
Translate children by the given vector. |
|
protected void |
updateBoundingBox()
Update the bounding box by "unioning" the children's bounding box (actually computes the two specification points defining the diagonal of the box). |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
anchorPointsIterator, createActions, fireChangedUpdate, getAttribute, getAttributeSet, getDrawing, getName, getParent, getView, pullOutOfGroup, replaceBy, scale, scale, scale, setName, setParent |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ArrayList<Element> children
protected boolean changeLock
BranchElement
and
it shouldn't process events coming from its children before the change is completed
(hence this is used inside forwardChangedUpdate()
);
set it to true each time you start modifying children in batch mode and you don't want
events to be forwarded to the root of the hierarchy before everything is completed (e.g. to
get rid of side-effects, or to reduce the burden for the repaint manager).
Example of use: whenever we call translate()
on this BranchElement
,
translate()
on every children: this in turn make children forward a
DrawingEvent
to their parent (= this BranchElement
), yet this event is
trapped here, hence not propagated upward ; note however that children update their own view
whatever the value of the changeLock semaphor;changeLock
semaphor, and fire a change-update event (which in turn
will propagate the event upward along the tree).
protected double[] ptsX
protected double[] ptsY
protected GeneralPath shape
protected BranchElement.CompoundMode compoundMode
protected boolean isPathClosed
protected int liftPen
public static final int DEFAULT_LIFTPEN
Constructor Detail |
---|
public BranchElement()
BranchElement
with no parent and a default PicAttributeSet
.
public BranchElement(PicAttributeSet attributeSet)
BranchElement
with no parent and the given PicAttributeSet
public BranchElement(BranchElement src)
BranchElement
.
public BranchElement(Collection<? extends Element> c)
BranchElement
from the content of the given Collection of
Element
's. Children are cloned as well (i.e. this isa deep copy).
Method Detail |
---|
public BranchElement clone()
AbstractElement
clone
in interface Element
clone
in class AbstractElement
public String getDefaultName()
getDefaultName
in class AbstractElement
public Element get(int childIndex)
get
in interface List<Element>
public boolean add(Element child)
BranchElement
, setting its parent to this.
Since a child can't have two parents, this also remove the child from its former parent, if any.
ViewFactory
to create View
's for the
new child.
add
in interface Collection<Element>
add
in interface List<Element>
public void add(int position, Element child)
BranchElement
at the given position, setting its parent to
this, and create a view for the child using the ViewFactory
that produced the View for
this BranchElement
.
add
in interface List<Element>
public Element set(int position, Element newChild)
BranchElement
, this has no effect.
set
in interface List<Element>
newChild
- if null, this calls remove(position)public void replace(Element src, Element dest)
BranchElement
. No effect if "dest" already belongs to this BranchElement
.
public boolean remove(Object child)
BranchElement
, setting its parent to null
so
that the given child become (possibly) eligible for garbage collection if there are no other reference
to it.
remove
in interface Collection<Element>
remove
in interface List<Element>
child
- any children of this BranchElement
, possibly through undirect lineage.public Element remove(int index)
BranchElement
.
remove
in interface List<Element>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<Element>
removeAll
in interface List<Element>
c
- elements to be removed from this collection.
public void clear()
BranchElement
, set each child's parent to null.
clear
in interface Collection<Element>
clear
in interface List<Element>
public int getFirstPointIndex()
Element
getFirstPointIndex
in interface Element
getCtrlPt
.
This returns PT_ANCHOR
.public int getLastPointIndex()
Element
getLastPointIndex
in interface Element
public double getCtrlPtX(int numPoint)
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
numPoint
.public double getCtrlPtY(int numPoint)
ptsY[numPoint]
.This might be a valid implementation
as long as subclasses don't have other control points.
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
numPoint
.public PicPoint getCtrlPt(int numPoint, PicPoint dest)
Element
is to return an IMMUTABLE instance of PicPoint
, so that the only way
to alter the geometry of this element is by calling the setCtrlPt
method, hence this
implementation simply calls getCtrlPtX()
and getCtrlPtY()
.
getCtrlPt
in interface Element
numPoint
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
numPoint
;
if src
is null, allocates a new PicPoint and return it,
otherwise directly modifies src
and returns it as well for convenience.public void setCtrlPt(int index, PicPoint pt)
setCtrlPt
with a null constraint, then fires a change-update of type
GEOMETRY_CHANGE
.
setCtrlPt
in interface Element
setCtrlPt
in class AbstractElement
public void setCtrlPt(int numPoint, PicPoint pt, EditPointConstraint c)
setCtrlPt
in interface Element
c
- a geometry constraint, or null if no particular constraint is being imposed (aka default).public void translate(double dx, double dy)
translate
in interface Element
dx
- The X coordinate of translation vectordy
- The Y coordinate of translation vectorpublic CtrlPtSubset getCtrlPtSubset(ConvexZoneGroup csg, BitSet czExtension)
Element
csg
, et
czExtension
getCtrlPtSubset
in interface Element
getCtrlPtSubset
in class AbstractElement
csg
- un ensemble de zones convexesczExtension
- un BitSet
permettant d'étendre l'ensemble des points de contrôle
compris dans l'ensemble de zones convexes csg
. La signification des bit est selon
l'énuméré CtrlPtSubset.CZExtension
.
null
jpicedt.graphic.model
public void scale(double ptOrgX, double ptOrgY, double sx, double sy, UserConfirmationCache ucc)
(sx,sy)
using (ptOrgX,ptOrgY)
as origin; sx
or sy
can be negative.
scale
in interface Element
ucc
- une valeur UserConfirmationCache
permettant de demander à l'utilisateur
confirmation, de se souvenir de la dernière confirmation qu'il a donné, ou de ses préférences.public void mirror(PicPoint ptOrg, PicVector normalVector)
PicGroup
.
mirror
in interface Element
ptOrg
- le PicPoint
par lequel passe l'axe de la réflexion.normalVector
- le PicVector
normal à l'axe de la réflexion.public void rotate(PicPoint ptOrg, double angle)
Element
by the given angle along the given point
rotate
in interface Element
angle
- rotation angle in radianspublic void shear(PicPoint ptOrg, double shx, double shy)
AbstractElement
(shx,shy)
en utilisant ptOrg
comme origine.
Ceci est une commodité d'appel de
shear(ptOrg, shx, shy,UserConfirmationCache.DEFAULT)
.
shear
in interface Element
shear
in class AbstractElement
public void shear(PicPoint ptOrg, double shx, double shy, UserConfirmationCache ucc)
Element
by the given params wrt to the given origin.
shear
in interface Element
ucc
- une valeur UserConfirmationCache
permettant de demander à l'utilisateur
confirmation, de se souvenir de la dernière confirmation qu'il a donné, ou de ses préférences.public void setCompoundMode(BranchElement.CompoundMode m)
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.
public BranchElement.CompoundMode getCompoundMode()
public void toggleCompoundMode()
public void closePath()
BranchElement
.
This only makes sense in "JOINT" mode.
public void openPath()
BranchElement
.
This only makes sense in "JOINT" mode.
public boolean isPathClosed()
BranchElement
is closed or not.
This only makes sense in "JOINT" mode.
public void togglePathClosure()
BranchElement
.
This only makes sense in "JOINT" mode.
public void setLiftPen(int i)
public int getLiftPen()
public Shape createShape()
GeneralPath
generated by the shapes of the
children of this BranchElement
(aka PSTricks' pscustom object).
createShape
in interface Element
createShape
in class AbstractElement
public void syncArrowGeometry(ArrowView v, ArrowView.Direction d)
syncArrowGeometry
in interface Element
syncArrowGeometry
in class AbstractElement
public void forwardChangedUpdate(Element child, DrawingEvent.EventType eventType)
BranchElement
to inform its parent of some change that occured
to it or one of its children. This gives a chance to the receiver to update its layout, then to
propagate the change-event upward.
eventType
- the event typechild
- public void setViewFromFactory(ViewFactory f)
Element
from the given view factory, then set the view for children.
setViewFromFactory
in interface Element
setViewFromFactory
in class AbstractElement
public void removeView()
removeView
in interface Element
removeView
in class AbstractElement
public void bringToBack(Element obj)
public void bringToFront(Element obj)
Drawing
or if it's
already to front.
public void bringBackward(Element obj)
Drawing
, or if it's already to back.
public void bringForward(Element obj)
public boolean isToBack(Element obj)
public boolean isToFront(Element obj)
public Rectangle2D getBoundingBox(Rectangle2D r)
\begin{picture}
command.Straigthforwardly computed from the diagonal.
getBoundingBox
in interface Element
BranchElement
has no childrenprotected void updateBoundingBox()
public void setAttributeSet(PicAttributeSet set)
AttributeSet
for this BranchElement
and propagate to children.
setAttributeSet
in interface Element
setAttributeSet
in class AbstractElement
public <T> void setAttribute(PicAttributeName<T> name, T value)
Attribute
for this BranchElement
and propagate to children.
setAttribute
in interface Element
setAttribute
in class AbstractElement
public String toString()
toString
in class AbstractElement
public int hashCode()
hashCode
in interface Collection<Element>
hashCode
in interface List<Element>
hashCode
in class Object
public boolean addAll(Collection<? extends Element> c)
Element
as children of this BranchElement
.
addAll
in interface Collection<Element>
addAll
in interface List<Element>
public boolean addAll(int index, Collection<? extends Element> c)
Element
as children of this BranchElement
, at the given position.
addAll
in interface List<Element>
public int size()
BranchElement
(direct offspring only).
size
in interface Collection<Element>
size
in interface List<Element>
public boolean isEmpty()
isEmpty
in interface Collection<Element>
isEmpty
in interface List<Element>
BranchElement
contains no childrenpublic boolean contains(Object o)
Element
(or one of its ancestor) is contained in this
BranchElement
.
contains
in interface Collection<Element>
contains
in interface List<Element>
public Iterator<Element> iterator()
iterator
in interface Iterable<Element>
iterator
in interface Collection<Element>
iterator
in interface List<Element>
public List<Element> subList(int fromIndex, int toIndex)
subList
in interface List<Element>
public ListIterator<Element> listIterator()
listIterator
in interface List<Element>
public ListIterator<Element> listIterator(int index)
listIterator
in interface List<Element>
public int lastIndexOf(Object o)
BranchElement
.
lastIndexOf
in interface List<Element>
public int indexOf(Object child)
BranchElement
.
indexOf
in interface List<Element>
public Object[] toArray()
toArray
in interface Collection<Element>
toArray
in interface List<Element>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<Element>
toArray
in interface List<Element>
public boolean containsAll(Collection<?> c)
BranchElement
contains all of the elements
in the specified collection, possibly through indirect lineage.
containsAll
in interface Collection<Element>
containsAll
in interface List<Element>
public boolean equals(Object o)
equals
in interface Collection<Element>
equals
in interface List<Element>
equals
in class Object
public boolean retainAll(Collection<?> c)
BranchElement
that are contained in the specified
collection.
retainAll
in interface Collection<Element>
retainAll
in interface List<Element>
c
- elements to be retained in this collection.
public <T extends Element> ArrayList<T> createFilteredCollection(Class<T> clazz)
BranchElement
that are of
the same type or inherit the given clazz
. Search down the children tree stops whenever a
matching class is encountered.
public boolean containsClass(Class<? extends Element> clazz)
BranchElement
contains children, grandchildren, etc. that are of the
same type of inherit from the given clazz
.
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |