http://www.jpicedt.org

jpicedt.graphic.model
Class Drawing.RootElement

java.lang.Object
  extended by jpicedt.graphic.model.AbstractElement
      extended by jpicedt.graphic.model.BranchElement
          extended by jpicedt.graphic.model.Drawing.RootElement
All Implemented Interfaces:
Iterable<Element>, Collection<Element>, List<Element>, Element, ActionFactory
Enclosing class:
Drawing

public class Drawing.RootElement
extends BranchElement

The Element that is the root of the tree of Element's in this Drawing. Children can be directly added to this RootElement (i.e. instead of using the Drawing API), since changed-update are always forwarded to the hosting drawing.


Nested Class Summary
 
Nested classes/interfaces inherited from class jpicedt.graphic.model.BranchElement
BranchElement.CompoundMode
 
Field Summary
 
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
Drawing.RootElement()
          Construct a new empty RootElement
Drawing.RootElement(BranchElement e)
          construct a new RootElement whose content is initialized from the content of the given BranchElement Children are cloned beforehands, so it's perfectly safe to use this constructor when one doesn't want to modify the initial content of the given BranchElement.
Drawing.RootElement(Collection<Element> c)
          Create a new BranchElement from the content of the given Collection of Element's.
 
Method Summary
 Drawing.RootElement clone()
          Returns a clone of this Element
protected  void fireChangedUpdate(DrawingEvent.EventType eventType)
          Called each time the content of this RootElement has changed.
 void forwardChangedUpdate(Element child, DrawingEvent.EventType eventType)
          Called by a child to inform of some change that occured to it or one of its children.
 Drawing.BoundingBox getBoundingBox()
           
 PicPoint getCtrlPt(int numPoint, PicPoint src)
          return null
 String getDefaultName()
           
 Drawing getDrawing()
          Retrieves the underlying drawing Overriden to return this.
 int getFirstPointIndex()
          Return 0
 int getLastPointIndex()
          Return 0
 String getName()
          Return a non-localised string representing this element's name.
 BranchElement getParent()
          Gets the parent of the element.
 void setCtrlPt(int numPoint, PicPoint src, EditPointConstraint c)
          does nothing
 void setParent(BranchElement p)
          Sets the parent of the element.
 void setViewFromFactory(ViewFactory f)
          set the view for this Element from the given view factory, then set the view for children.
 
Methods inherited from class jpicedt.graphic.model.BranchElement
add, add, addAll, addAll, bringBackward, bringForward, bringToBack, bringToFront, clear, closePath, contains, containsAll, containsClass, createFilteredCollection, createShape, equals, get, getBoundingBox, getCompoundMode, getCtrlPtSubset, getCtrlPtX, getCtrlPtY, getLiftPen, hashCode, indexOf, isEmpty, isPathClosed, isToBack, isToFront, iterator, lastIndexOf, listIterator, listIterator, mirror, openPath, remove, remove, removeAll, removeView, replace, retainAll, rotate, scale, set, setAttribute, setAttributeSet, setCompoundMode, setCtrlPt, setLiftPen, shear, shear, size, subList, syncArrowGeometry, toArray, toArray, toggleCompoundMode, togglePathClosure, toString, translate, updateBoundingBox
 
Methods inherited from class jpicedt.graphic.model.AbstractElement
anchorPointsIterator, createActions, getAttribute, getAttributeSet, getView, pullOutOfGroup, replaceBy, scale, scale, scale, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Drawing.RootElement

public Drawing.RootElement()
Construct a new empty RootElement


Drawing.RootElement

public Drawing.RootElement(BranchElement e)
construct a new RootElement whose content is initialized from the content of the given BranchElement Children are cloned beforehands, so it's perfectly safe to use this constructor when one doesn't want to modify the initial content of the given BranchElement.

Parameters:
e - The Drawing object to clone

Drawing.RootElement

public Drawing.RootElement(Collection<Element> c)
Create a new BranchElement from the content of the given Collection of Element's. Children are cloned as well (i.e. this is a deep copy).

Method Detail

getBoundingBox

public Drawing.BoundingBox getBoundingBox()

getDefaultName

public String getDefaultName()
Overrides:
getDefaultName in class BranchElement
Returns:
the name of this element

getName

public String getName()
Description copied from interface: Element
Return a non-localised string representing this element's name. This may be used by a UI to display some information related to this element, or by a localizer to fetch a i18n'd string.

Specified by:
getName in interface Element
Overrides:
getName in class AbstractElement
Returns:
a localised string that represents this object's name

clone

public Drawing.RootElement clone()
Description copied from class: AbstractElement
Returns a clone of this Element

Specified by:
clone in interface Element
Overrides:
clone in class BranchElement
Returns:
a deep copy of this Drawing

getDrawing

public Drawing getDrawing()
Retrieves the underlying drawing Overriden to return this.

Specified by:
getDrawing in interface Element
Overrides:
getDrawing in class AbstractElement
Returns:
the drawing ; null if this AbstractElement doesn't belong to any drawing yet.

getParent

public BranchElement getParent()
Gets the parent of the element. Overriden to return null (root element has no parent)

Specified by:
getParent in interface Element
Overrides:
getParent in class AbstractElement
Returns:
the parent

setParent

public void setParent(BranchElement p)
Sets the parent of the element. This implementation does nothing, since this root-element has no parent.

Specified by:
setParent in interface Element
Overrides:
setParent in class AbstractElement
Parameters:
p - The parent to be set for this element.

fireChangedUpdate

protected void fireChangedUpdate(DrawingEvent.EventType eventType)
Called each time the content of this RootElement has changed. This fires the change to the hosting drawing.
Ex : called addChild() on this RootElement -> fires an INSERT event.

Overrides:
fireChangedUpdate in class AbstractElement
Parameters:
eventType - the event type

forwardChangedUpdate

public void forwardChangedUpdate(Element child,
                                 DrawingEvent.EventType eventType)
Called by a child to inform of some change that occured to it or one of its children. This fires a DrawingEvent with the given child as the element that changed. This mainly occurs when the geometry of an element is modified.

Overrides:
forwardChangedUpdate in class BranchElement
eventType - the event type

getCtrlPt

public PicPoint getCtrlPt(int numPoint,
                          PicPoint src)
return null

Specified by:
getCtrlPt in interface Element
Overrides:
getCtrlPt in class BranchElement
Parameters:
numPoint - the point index, should be greater or equal to the value returned by getFirstPointIndex, and lower or equal to getLastPointIndex.
Returns:
the point indexed by numPoint ; if src is null, allocates a new PicPoint and return it, otherwise directly modifies src and returns it as well for convenience.

setCtrlPt

public void setCtrlPt(int numPoint,
                      PicPoint src,
                      EditPointConstraint c)
does nothing

Specified by:
setCtrlPt in interface Element
Overrides:
setCtrlPt in class BranchElement
c - a geometry constraint, or null if no particular constraint is being imposed (aka default).

getFirstPointIndex

public int getFirstPointIndex()
Return 0

Specified by:
getFirstPointIndex in interface Element
Overrides:
getFirstPointIndex in class BranchElement
Returns:
the index of the first point that can be retrieved by getCtrlPt. This returns PT_ANCHOR.

getLastPointIndex

public int getLastPointIndex()
Return 0

Specified by:
getLastPointIndex in interface Element
Overrides:
getLastPointIndex in class BranchElement
Returns:
the index of the last point that can be retrieved by getCtrlPt This returns PT_ANCHOR.

setViewFromFactory

public void setViewFromFactory(ViewFactory f)
set the view for this Element from the given view factory, then set the view for children.

Specified by:
setViewFromFactory in interface Element
Overrides:
setViewFromFactory in class BranchElement

http://www.jpicedt.org

Submit a bug : syd@jpicedt.org