public class GraphDocument extends AbstractDocument
This is one of two classes that must be provided to produce a complete application using the diva.gui framework. (The other is diva.gui.Application -- see the CanvasDemo class.) Generally, the easiest way to implement diva.gui.Document is to extend diva.gui.AbstractDocument.
This class implements those methods that are left abstract in diva.gui.AbstractDocument. This is a set of methods that deal with loading the document from a file or URL and vice versa, such as close(), open(), save(), and saveAs(). These methods simply implement the "raw" functionality implied by the method names; they do not perform functions such as querying the user for whether to save a file before closing. (That function is performed by an instance of diva.gui.StoragePolicy.)
To read and write canvas data, it uses the diva.util.xml utility package. In general, there is no need for applications to use the XML utilities; however, it does make it very simple and fast to construct a working application with complete file I/O. See the various method comments for further imformation.
Modifier and Type | Class and Description |
---|---|
static class |
GraphDocument.Factory
GraphDocument.Factory is a factory for graph documents.
|
Constructor and Description |
---|
GraphDocument(Application a)
Construct a graph document that is owned by the given
application.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the document.
|
BasicGraphModel |
getGraphModel()
Get the graph data model.
|
XmlDocument |
getXmlDocument()
Get the XML document that contains the raw XML data.
|
void |
open()
Open the document from its current file.
|
void |
save()
Save the document to the current file.
|
void |
saveAs(File file)
Save the document to the given file.
|
void |
saveAs(URL url)
Save the document to the given file.
|
void |
setGraphModel(BasicGraphModel m)
Set the graph data model.
|
String |
toString()
Print information about the graph document
|
addPropertyChangeListener, getApplication, getEditSupport, getFile, getShortTitle, getTitle, getUndoManager, getURL, isDirty, isEditable, isWritable, removePropertyChangeListener, setDirty, setEditable, setFile, setURL, setWritable
public GraphDocument(Application a)
public void close() throws Exception
close
in interface Document
close
in class AbstractDocument
Exception
- If the close operation fails.public BasicGraphModel getGraphModel()
public XmlDocument getXmlDocument()
public void open() throws Exception
The implementation of this method uses the diva.xml package:
open
in interface Document
open
in class AbstractDocument
Exception
- If there is no file, or if the I/O operation failed.public void save() throws Exception
save
in interface Document
save
in class AbstractDocument
Exception
- If there is no file, or if the I/O operation failed.public void saveAs(File file) throws Exception
The implementation of this class uses the diva.util.xml package:
saveAs
in interface Document
saveAs
in class AbstractDocument
Exception
- If the I/O operation failed.AbstractDocument.save()
public void saveAs(URL url) throws Exception
saveAs
in interface Document
saveAs
in class AbstractDocument
Exception
- AlwaysAbstractDocument.save()
public void setGraphModel(BasicGraphModel m)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.