|
JGraphpad Pro
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavax.swing.tree.DefaultTreeModel
com.jgraph.editor.JGraphEditorModel
Default document model for JGraph editors. This class is in charge of
preparing the bean info classes and has a map of persistence delegate for XML
encoding. You should use the writeObject and readObject method of this class
for file I/O to properly use the registered peristence delegates.
Note: The API refers to the children of the rootNodeas roots.
| Field Summary | |
protected Map |
persistenceDelegates
Holds the (class, persistence delegate) pairs. |
protected DefaultMutableTreeNode |
rootNode
Reference to the mutable root node. |
| Fields inherited from class javax.swing.tree.DefaultTreeModel |
asksAllowsChildren, listenerList, root |
| Constructor Summary | |
JGraphEditorModel()
Constructs a new JGraph editor model adding persistence delegates for the DefaultGraphModel, GraphLayoutCache and DefaultEdge.DefaultRouting classes. |
|
| Method Summary | |
MutableTreeNode |
addChild(MutableTreeNode child,
MutableTreeNode parent)
Adds the specified child to parent. |
Object |
addFile(String uri)
Reads the specified URI and adds it as a root. |
Object |
addPersistenceDelegate(Class clazz,
PersistenceDelegate delegate)
Associates the specified persistence delegate with clazz
for XML encoding. |
MutableTreeNode |
addRoot(MutableTreeNode node)
Adds the specified root as a child to rootNode. |
protected void |
configureEncoder(XMLEncoder enc)
Hook for subclassers to configure a new XML encoder for writing an object. |
JGraphEditorFile |
getFileByFilename(String filename)
Returns the file for the specified filename if it is in the model or null if no such file exists. |
InputStream |
getInputStream(String uri)
Hook for subclassers to create an input stream for the specified URI. |
OutputStream |
getOutputStream(String uri)
Hook for subclassers to create an output stream for the specified URI. |
static JGraphEditorFile |
getParentFile(TreeNode node)
Returns the parent file for node or the node itself, if it
is a file. |
PersistenceDelegate |
getPersistenceDelegate(Class clazz)
Returns the associated persistence delegate for clazz or
null if no association exists. |
protected void |
installDiagramListeners(JGraphEditorDiagram diagram)
Installs the listeners required to update the modified state of the parent file node to diagram. |
protected void |
installListeners(TreeNode node)
Hook for subclassers to install the required listeners in new tree nodes. |
static void |
makeCellViewFieldsTransient(Class clazz)
Makes all fields but cell and attributes
transient in the bean info of clazz. |
static void |
makeTransient(Class clazz,
String field)
Makes the specified field transient in the bean info of clazz. |
Object |
readFile(String uri)
Reads the specified URI and returns the deserialized object. |
Object |
readObject(InputStream in)
Returns a new object from the specified stream using a new XML decoder. |
Enumeration |
roots()
Returns the first generation of childs, aka roots. |
void |
setFilename(JGraphEditorFile file,
String filename)
Sets the filename of the specified file and dispatches a notification event. |
void |
setModified(JGraphEditorFile file,
boolean modified)
Sets the modified state of the specified file and dispatches a notification event. |
void |
setName(JGraphEditorDiagram diagram,
String name)
Sets the name of the specified diagram and dispatches a notification event. |
void |
setUserObject(TreeNode node,
Object userObject)
Sets the user object of the specified node and dispatches a notification event. |
void |
writeObject(Object object,
OutputStream out)
Writes the specified object to the output stream using an xml encoder which was configured using configureEncoder(XMLEncoder). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Map persistenceDelegates
protected DefaultMutableTreeNode rootNode
| Constructor Detail |
public JGraphEditorModel()
| Method Detail |
public Enumeration roots()
rootNode.
public Object addPersistenceDelegate(Class clazz,
PersistenceDelegate delegate)
clazz
for XML encoding.
clazz - The class to associate the delegate with.
clazz.public PersistenceDelegate getPersistenceDelegate(Class clazz)
clazz or
null if no association exists.
clazz - The clazz to return the delegate for.
clazz or
null.public MutableTreeNode addRoot(MutableTreeNode node)
rootNode. Calls
installListeners(TreeNode)on the node.
node - The node to add to rootNode.
public MutableTreeNode addChild(MutableTreeNode child,
MutableTreeNode parent)
parent. Calls
installListeners(TreeNode)on the child.
child - The node to add to parent.parent - The parent to add child to.
public Object readFile(String uri)
throws MalformedURLException,
IOException
uri - The URI to read the object from.
MalformedURLException
IOException
public Object addFile(String uri)
throws MalformedURLException,
IOException
uri - The URI to read the object from.
MalformedURLException
IOExceptionprotected void installListeners(TreeNode node)
installDiagramListeners(JGraphEditorDiagram)on all diagrams
that are found along the invocation chain.
node - The node to scan for diagrams.protected void installDiagramListeners(JGraphEditorDiagram diagram)
diagram. This implementation adds a
graph layout cache listener and a graph model listener.
diagram - The diagram to install the listeners to.
public void setUserObject(TreeNode node,
Object userObject)
node - The node to change the user object for.userObject - The new user object.
public void setFilename(JGraphEditorFile file,
String filename)
file - The file to change the filename for.filename - The new filename.
public void setName(JGraphEditorDiagram diagram,
String name)
diagram - The diagram to change the name for.name - The new name.
public void setModified(JGraphEditorFile file,
boolean modified)
file - The file to change the modified state for.modified - The new modified state.public JGraphEditorFile getFileByFilename(String filename)
null if no such file exists.
filename - The filename to return the file for.
filename or null.
public void writeObject(Object object,
OutputStream out)
configureEncoder(XMLEncoder). The
exceptions that are thrown during encoding are caught by a local handler
and passed to the caller as a RuntimeException with description of the
encoding problems.
object - The object to be written.out - The output strem to write to.
RuntimeException - If there are problems during encoding.protected void configureEncoder(XMLEncoder enc)
enc - The encoder to be configured.
public InputStream getInputStream(String uri)
throws MalformedURLException,
FileNotFoundException,
IOException
JGraphEditorResources.getInputStream(String) and wraps it in a
GZIPInputStream if the URI ends with .gz.
uri - The URI to return the input stream for.
MalformedURLException
FileNotFoundException
IOException
public OutputStream getOutputStream(String uri)
throws IOException
JGraphEditorResources.getOutputStream(String) and wraps it in a
GZIPOutputStream if the URI ends with
.gz.
uri - The URI to return the output stream for.
IOExceptionpublic Object readObject(InputStream in)
public static void makeTransient(Class clazz,
String field)
clazz.
clazz - The class whos field should be made transient.field - The name of the field that should be made transient.public static void makeCellViewFieldsTransient(Class clazz)
cell and attributes
transient in the bean info of clazz.
clazz - The cell view class who fields should be made transient.public static JGraphEditorFile getParentFile(TreeNode node)
node or the node itself, if it
is a file. This method returns null if no parent file is
found for node.
node - The node to find the parent file for.
null.
|
JGraphpad Pro
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||