Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jpicedt.graphic.model
Class Drawing  view Drawing download Drawing.java

java.lang.Object
  extended byjpicedt.graphic.model.Drawing
All Implemented Interfaces:
javax.swing.undo.StateEditable

public class Drawing
extends java.lang.Object
implements javax.swing.undo.StateEditable

An extensible array used to store Elements

This is the model (aka javax.swing.text.Document) to be plugged into an existing PECanvas.

Objects are stored in ascending order according to their z-value, i.e. from back to front.

Since:
PicEdt 1.3 ; modified 1.3.2-beta6

Nested Class Summary
 class Drawing.Customizer
          a customizer for editing the bounding box
 class Drawing.RootElement
          the Element that is the root of the tree of Element's in this Drawing.
 class Drawing.UndoableDrawingEvent
          an implementation of DrawingEvent [pending] UndoableEditEvent (use CompountEdit) not used so far.
 
Field Summary
protected  java.awt.geom.Rectangle2D boundingBox
          bounding box used when formatting to text ; null means that it'll be computed automatically
protected  javax.swing.event.EventListenerList listenerList
          list of listener's (e.g.
protected  java.lang.String notParsedCommands
          a string containing commands read from file but not parsed
protected  Drawing.RootElement root
          the root-element of the drawing
private  jpicedt.graphic.view.ViewFactory viewFactory
           
 
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(java.util.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(jpicedt.graphic.event.DrawingListener l)
          adds a DrawingListener to the Drawing
 void addElement(Element element)
          Add the given element to this Drawing
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 java.util.Iterator elements()
           
protected  void fireChangedUpdate(Element[] changed, jpicedt.graphic.event.DrawingEvent.EventType type)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireChangedUpdate(Element changed, jpicedt.graphic.event.DrawingEvent.EventType type)
          Notify all listeners that have registered interest for notification on this event type.
 java.awt.geom.Rectangle2D getBoundingBox()
           
 Drawing.Customizer getCustomizer()
          Return a bounding box customizer for this Drawing
 Element getElement(int i)
           
 java.lang.String getNotparsedCommands()
           
 Drawing.RootElement getRootElement()
           
 jpicedt.graphic.view.View getRootView()
           
 void removeDrawingListener(jpicedt.graphic.event.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(int index, Element element)
          Replace the element at the given index with the given graphic element
 void restoreState(java.util.Hashtable map)
          Restore RootElement from the given Hashtable, using key="state"
 void setBoundingBox(java.awt.geom.Rectangle2D bb)
          set bounding box manually ; set to null to switch back to automatic behaviour
 void setNotparsedCommands(java.lang.String str)
           
 void setViewTree(jpicedt.graphic.view.ViewFactory f)
          set the view tree that renders this drawing to screen, starting from the root-element.
 int size()
           
 void storeState(java.util.Hashtable map)
          Store a clone of RootElement in the given Hashtable, with key = "state"
 java.lang.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

root

protected Drawing.RootElement root
the root-element of the drawing


listenerList

protected javax.swing.event.EventListenerList listenerList
list of listener's (e.g. DrawingListener's) that get notified events from this model


notParsedCommands

protected java.lang.String notParsedCommands
a string containing commands read from file but not parsed


boundingBox

protected java.awt.geom.Rectangle2D boundingBox
bounding box used when formatting to text ; null means that it'll be computed automatically


viewFactory

private jpicedt.graphic.view.ViewFactory viewFactory
Constructor Detail

Drawing

public Drawing()
Construct a new empty Drawing

Since:
jPicEdt 1.3

Drawing

public Drawing(java.util.Collection c)
Construct a new Drawing from the given Collection, which is supposed to contain Element's. Children are cloned beforehands.

Since:
jPicEdt 1.3

Drawing

public Drawing(BranchElement e)
construct a new Drawing whose content is initialized from the content of the given 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.

Since:
jPicEdt 1.3

Drawing

public Drawing(Drawing dr)
cloning constructor

Since:
jPicEdt 1.3.2
Method Detail

clone

public java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 

Since:
PicEdt 1.3

getRootElement

public Drawing.RootElement getRootElement()

size

public int size()

removeElement

public void removeElement(Element element)
Remove the given graphic object from this Drawing, overriden so as to update selection if this element was selected.


addElement

public void addElement(Element element)
Add the given element to this Drawing


replaceElement

public void replaceElement(int index,
                           Element element)
Replace the element at the given index with the given graphic element


elements

public java.util.Iterator elements()

getElement

public Element getElement(int i)

getBoundingBox

public java.awt.geom.Rectangle2D getBoundingBox()

setBoundingBox

public void setBoundingBox(java.awt.geom.Rectangle2D bb)
set bounding box manually ; set to null to switch back to automatic behaviour


getRootView

public jpicedt.graphic.view.View getRootView()

setViewTree

public void setViewTree(jpicedt.graphic.view.ViewFactory f)
set the view tree that renders this drawing to screen, starting from the root-element. The root-view produced by the factory (to be associated with the root-element) must know how to find its container (normally a PECanvas), otherwise calls to repaint, etc... will fail.


addDrawingListener

public void addDrawingListener(jpicedt.graphic.event.DrawingListener l)
adds a DrawingListener to the Drawing


removeDrawingListener

public void removeDrawingListener(jpicedt.graphic.event.DrawingListener l)
removes a DrawingListener from the Drawing


fireChangedUpdate

protected void fireChangedUpdate(Element[] changed,
                                 jpicedt.graphic.event.DrawingEvent.EventType type)
Notify all listeners that have registered interest for notification on this event type.


fireChangedUpdate

protected void fireChangedUpdate(Element changed,
                                 jpicedt.graphic.event.DrawingEvent.EventType type)
Notify all listeners that have registered interest for notification on this event type.


storeState

public void storeState(java.util.Hashtable map)
Store a clone of RootElement in the given Hashtable, with key = "state"

Specified by:
storeState in interface javax.swing.undo.StateEditable

restoreState

public void restoreState(java.util.Hashtable map)
Restore RootElement from the given Hashtable, using key="state"

Specified by:
restoreState in interface javax.swing.undo.StateEditable

toString

public java.lang.String toString()
Returns a String representing the drawing for debugging use only.


setNotparsedCommands

public void setNotparsedCommands(java.lang.String str)

getNotparsedCommands

public java.lang.String getNotparsedCommands()

getCustomizer

public Drawing.Customizer getCustomizer()
Return a bounding box customizer for this Drawing