|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpicedt.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.BoundingBox
|
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 Drawing.BoundingBox |
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<Element> c)
Construct a new Drawing from the given Collection, which is supposed to contain Element 's. |
|
Drawing(Drawing dr)
Cloning constructor. |
Method Summary | ||
---|---|---|
boolean |
add(Element o)
convenience call to RootElement's method |
|
void |
add(int position,
Element o)
convenience call to RootElement's method |
|
boolean |
addAll(Collection<? extends Element> c)
convenience call to RootElement's method |
|
boolean |
addAll(int pos,
Collection<? extends Element> c)
convenience call to RootElement's method |
|
void |
addDrawingListener(DrawingListener l)
adds a DrawingListener to the Drawing . |
|
void |
clear()
convenience call to RootElement's method |
|
Drawing |
clone()
|
|
boolean |
contains(Object o)
convenience call to RootElement's method |
|
boolean |
containsAll(Collection<?> c)
convenience call to RootElement's method |
|
protected void |
fireChangedUpdate(Element changed,
DrawingEvent.EventType type)
Notify all listeners that have registered interest for notification on this event type. |
|
Element |
get(int i)
|
|
Rectangle2D |
getBoundingBox()
|
|
Drawing.Customizer |
getCustomizer()
Return a bounding box customizer for this Drawing |
|
String |
getNotparsedCommands()
|
|
Drawing.RootElement |
getRootElement()
|
|
View |
getRootView()
|
|
int |
indexOf(Object child)
Returns the index of the given Element . |
|
boolean |
isAutoComputeBoundingBox()
Return true if the bb is computed automatically on-the-fly. |
|
boolean |
isDisplayBoundingBox()
Return true if the bb is computed automatically on-the-fly. |
|
boolean |
isEmpty()
convenience call to RootElement's method |
|
Iterator<Element> |
iterator()
convenience call to RootElement's method |
|
int |
lastIndexOf(Object o)
Returns the last index of the given Element |
|
ListIterator<Element> |
listIterator()
|
|
ListIterator<Element> |
listIterator(int index)
|
|
Element |
remove(int index)
Remove the Element with the given index from this BranchElement |
|
boolean |
remove(Object o)
convenience call to RootElement's method |
|
boolean |
removeAll(Collection<?> c)
convenience call to RootElement's method |
|
void |
removeDrawingListener(DrawingListener l)
removes a DrawingListener from the Drawing . |
|
void |
replace(Element src,
Element dest)
Replace the given "src" element with the given "dest" element, if "src" belongs to this drawing. |
|
void |
restoreState(Hashtable<?,?> map)
Restore RootElement from the given Hashtable, using key="state" |
|
boolean |
retainAll(Collection<?> c)
convenience call to RootElement's method |
|
Element |
set(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 |
setAutoComputeBoundingBox(boolean b)
Return true if the bb is computed automatically on-the-fly. |
|
void |
setBoundingBox(Rectangle2D bb)
Set bounding box manually. |
|
void |
setDisplayBoundingBox(boolean b)
Return true if the bb is computed automatically on-the-fly. |
|
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<Object,Object> map)
Store a clone of RootElement in the given Hashtable, with key = "state" |
|
List<Element> |
subList(int fromIndex,
int toIndex)
|
|
Object[] |
toArray()
convenience call to RootElement's method |
|
|
toArray(T[] a)
convenience call to RootElement's method |
|
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 |
Methods inherited from interface java.util.List |
---|
equals, hashCode |
Field Detail |
---|
protected Drawing.RootElement root
protected EventListenerList listenerList
DrawingListener
's) that get notified events from this model
protected String notParsedCommands
protected Drawing.BoundingBox boundingBox
Constructor Detail |
---|
public Drawing()
public Drawing(Collection<Element> c)
Element
's.
Children are cloned beforehands.
public Drawing(BranchElement e)
BranchElement
. Children are cloned beforehands, so it's perfectly safe to use this
constructor if one doesn't want to modify the initial content of the given BranchElement
.
public Drawing(Drawing dr)
Method Detail |
---|
public Drawing clone()
clone
in class Object
Drawing
.public Drawing.RootElement getRootElement()
public int size()
size
in interface Collection<Element>
size
in interface List<Element>
public Element set(int index, Element element)
set
in interface List<Element>
public void replace(Element src, Element dest)
public Element get(int i)
get
in interface List<Element>
i
.public Rectangle2D getBoundingBox()
public void setBoundingBox(Rectangle2D bb)
public boolean isAutoComputeBoundingBox()
public void setAutoComputeBoundingBox(boolean b)
public boolean isDisplayBoundingBox()
public void setDisplayBoundingBox(boolean b)
public View getRootView()
Drawing
to a graphic context ; this is actually
the View associated with the root-element.public void setViewTree(ViewFactory f)
PECanvas
), otherwise
calls to repaint
, etc… will fail.
f
- the ViewFactory
that produces View
's for the Element
's
of the tree.public void addDrawingListener(DrawingListener l)
DrawingListener
to the Drawing
.
public void removeDrawingListener(DrawingListener l)
DrawingListener
from the Drawing
.
protected void fireChangedUpdate(Element changed, DrawingEvent.EventType type)
changed
- an array containing the elements that changedpublic void storeState(Hashtable<Object,Object> map)
storeState
in interface StateEditable
public void restoreState(Hashtable<?,?> map)
restoreState
in interface StateEditable
public boolean add(Element o)
add
in interface Collection<Element>
add
in interface List<Element>
public void add(int position, Element o)
add
in interface List<Element>
public boolean addAll(Collection<? extends Element> c)
addAll
in interface Collection<Element>
addAll
in interface List<Element>
public boolean addAll(int pos, Collection<? extends Element> c)
addAll
in interface List<Element>
public void clear()
clear
in interface Collection<Element>
clear
in interface List<Element>
public boolean contains(Object o)
contains
in interface Collection<Element>
contains
in interface List<Element>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<Element>
containsAll
in interface List<Element>
public boolean isEmpty()
isEmpty
in interface Collection<Element>
isEmpty
in interface List<Element>
public Iterator<Element> iterator()
iterator
in interface Iterable<Element>
iterator
in interface Collection<Element>
iterator
in interface List<Element>
public boolean remove(Object o)
remove
in interface Collection<Element>
remove
in interface List<Element>
public Element remove(int index)
remove
in interface List<Element>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<Element>
removeAll
in interface List<Element>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<Element>
retainAll
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 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)
lastIndexOf
in interface List<Element>
public int indexOf(Object child)
Element
.
indexOf
in interface List<Element>
public String toString()
toString
in class Object
public void setNotparsedCommands(String str)
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 |