|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjpicedt.graphic.model.Drawing
public class Drawing
An extensible array used to store Elements
This is the MODEL part of the View-Model-Controller paradigm (aka javax.swing.text.Document), aimed
at being plugged into an existing PECanvas. It has the structure of a tree-model, with the root element
of the tree being Drawing.RootElement : Element's added to this Drawing are actually added to its RootElement ;
each Element in turn may or may not have children (see e.g. classes DefaultLeafElement and BranchElement).
Element's should be added to this Drawing using the Drawing's API (i.e. shouldn't be directly added to RootElement),
by using the addElement()
method.
so that DrawingEvent's dispatching works properly.
Objects are stored in ascending order according to their z-value, i.e. from back to front. Note that this class does NOT include any selection-handling mechanism : for a variety of reasons, this mechanism has been moved to the associated EditorKit (aka "Controller" in the VMC paradigm), which may itself delegate this behaviour to an appropriate SelectionHandler. This makes the Drawing class a versatile document model for handling a variety of graphics elements without bothering about the UI interaction.
EditorKit
,
PECanvas
Nested Class Summary | |
---|---|
class |
Drawing.Customizer
a customizer for editing the bounding box |
class |
Drawing.DefaultDrawingEvent
an implementation of DrawingEvent |
class |
Drawing.RootElement
the Element that is the root of the tree of Element's in this Drawing. |
Field Summary | |
---|---|
protected Rectangle2D |
boundingBox
bounding box used when formatting to text ; null means that it'll be computed automatically |
protected EventListenerList |
listenerList
list of listener's (e.g. |
protected String |
notParsedCommands
a string containing commands read from file but not parsed |
protected Drawing.RootElement |
root
the root-element of the drawing |
Fields inherited from interface javax.swing.undo.StateEditable |
---|
RCSID |
Constructor Summary | |
---|---|
Drawing()
Construct a new empty Drawing |
|
Drawing(BranchElement e)
construct a new Drawing whose content is initialized from the content of the given BranchElement. |
|
Drawing(Collection c)
Construct a new Drawing from the given Collection, which is supposed to contain Element's. |
|
Drawing(Drawing dr)
cloning constructor |
Method Summary | |
---|---|
void |
addDrawingListener(DrawingListener l)
adds a DrawingListener to the Drawing |
void |
addElement(Element element)
Add the given element to this Drawing |
Object |
clone()
|
Iterator |
elements()
|
protected void |
fireChangedUpdate(Element changed,
DrawingEvent.EventType type)
Notify all listeners that have registered interest for notification on this event type. |
Rectangle2D |
getBoundingBox()
|
Drawing.Customizer |
getCustomizer()
Return a bounding box customizer for this Drawing |
Element |
getElement(int i)
|
String |
getNotparsedCommands()
|
Drawing.RootElement |
getRootElement()
|
View |
getRootView()
|
boolean |
isAutoComputeBoundingBox()
Return true if the bb is computed automatically on-the-fly |
void |
removeDrawingListener(DrawingListener l)
removes a DrawingListener from the Drawing |
void |
removeElement(Element element)
Remove the given graphic object from this Drawing, overriden so as to update selection if this element was selected. |
void |
replaceElement(Element src,
Element dest)
Replace the given "src" element with the given "dest" element, if "src" belongs to this drawing. |
void |
replaceElement(int index,
Element element)
Replace the element at the given index with the given graphic element No effet if "element" already belongs to the drawing. |
void |
restoreState(Hashtable map)
Restore RootElement from the given Hashtable, using key="state" |
void |
setBoundingBox(Rectangle2D bb)
set bounding box manually ; set to null to switch back to automatic behaviour |
void |
setNotparsedCommands(String str)
|
void |
setViewTree(ViewFactory f)
set the view tree that renders this drawing to screen, starting from the root-element. |
int |
size()
|
void |
storeState(Hashtable map)
Store a clone of RootElement in the given Hashtable, with key = "state" |
String |
toString()
Returns a String representing the drawing for debugging use only. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Drawing.RootElement root
protected EventListenerList listenerList
protected String notParsedCommands
protected Rectangle2D boundingBox
Constructor Detail |
---|
public Drawing()
public Drawing(Collection c)
public Drawing(BranchElement e)
public Drawing(Drawing dr)
Method Detail |
---|
public Object clone()
clone
in class Object
public Drawing.RootElement getRootElement()
public int size()
public void removeElement(Element element)
public void addElement(Element element)
public void replaceElement(int index, Element element)
public void replaceElement(Element src, Element dest)
public Iterator elements()
public Element getElement(int i)
public Rectangle2D getBoundingBox()
rootElement.getBoundingBox
except if setBoundingBox was called
with a non-null argument before.public void setBoundingBox(Rectangle2D bb)
public boolean isAutoComputeBoundingBox()
public View getRootView()
public void setViewTree(ViewFactory f)
repaint
, etc... will fail.
f
- the ViewFactory that produces View's for the Element's of the treepublic void addDrawingListener(DrawingListener l)
public void removeDrawingListener(DrawingListener l)
protected void fireChangedUpdate(Element changed, DrawingEvent.EventType type)
changed
- an array containing the elements that changedpublic void storeState(Hashtable map)
storeState
in interface StateEditable
public void restoreState(Hashtable map)
restoreState
in interface StateEditable
public String toString()
toString
in class Object
public void setNotparsedCommands(String str)
a
- string containing commands read from file or inserted by user, but not parsable.public String getNotparsedCommands()
public Drawing.Customizer getCustomizer()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |