|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.nwoods.jgo.svg.DefaultDocument
A wrapper class for org.w3c.dom.Document. By implementing the interface DomDocument, this class allows the com.nwoods.jgo package to provide methods that manipulate org.w3c.dom.Document objects while not requiring the org.w3c.dom.Document class to be present in order to build com.nwoods.jgo. JGo applications that support serialization to and from SVG XML files require this class.
Constructor Summary | |
DefaultDocument()
Create a new DefaultDocument |
Method Summary | |
void |
buildJGoDoc(JGoDocument jGoDoc)
Build a JGoDocument document from this DefaultDocument. |
void |
buildSVGDoc(JGoDocument jGoDoc)
Build a DefaultDocument from this JGoDocument. |
DomCDATASection |
createCDATASection(java.lang.String s)
|
DomElement |
createElement(java.lang.String s)
Creates an DomElement of the type specified. |
DomElement |
createJGoClassElement(java.lang.String className,
DomElement parent)
Creates an JGoClass DomElement. |
DomText |
createText(java.lang.String s)
Creates a DomText node given the specified string. |
protected void |
GenerateTooltipInitialization(DomElement parent)
|
protected void |
GenerateTooltipScript(DomElement parent)
|
org.w3c.dom.Document |
getDocument()
Return the org.w3c.dom.Document associated with this DefaultDocument. |
DomElement |
getDocumentElement()
This is a convenience attribute that allows direct access to the child DomElement that is the root element of the document. |
double |
getJGoSVGVersion()
Return the JGo SVG version number associated with this document. |
org.w3c.dom.Node |
importNode(org.w3c.dom.Node importedNode,
boolean deep)
Imports a node from another document to this document. |
DomNode |
initializeObjectFromXML(JGoDocument jGoDoc,
DomElement element,
DomElement jGoChildElement,
java.lang.Object obj)
Initialize the JGoClass element that has been read from the XML file and instantiated. |
boolean |
isDisabledDrawing()
Determines if output of SVG visible elements by superclass is currently disabled |
boolean |
isGenerateJGoXML()
Determines if output of JGo XML extensions to SVG is enabled. |
boolean |
isGenerateSVG()
Determines if output of any SVG elements to the generated XML is enabled. |
boolean |
isReadSVG()
|
boolean |
isRegisteredReference(java.lang.Object obj)
Determines whether a reference to a particular object has already been regigistered by registerReferencingNode(). |
boolean |
isSVGTooltips()
Dermines if SVG tooltips along with associated tooltip scripts should be generated. |
boolean |
JGoXMLOutputEnabled()
Compute whether the output of JGo XML extensions is currently allowed. |
void |
registerObject(java.lang.Object obj,
DomElement node)
Register the DomElement associated with an Object. |
void |
registerReferencingNode(DomElement referencingNode,
java.lang.String refName,
java.lang.Object referencedObj)
Register the attribute name and referenced Object associated with a referencing DomElement. |
void |
registerReferencingObject(java.lang.Object obj,
java.lang.String attr,
java.lang.String refTag)
Register the attribute name and referenced identifier associated with a referencing Object. |
void |
registerTag(java.lang.String tag,
java.lang.Object obj)
Register the Object associated with a DomElement id attribute. |
protected void |
RenderTooltip(DomElement parent)
|
void |
resetDocument()
Create a new empty document for reading or writing SVG XML. |
void |
setDisabledDrawing(boolean disable)
Disable the output of any visible SVG elements by superclass. |
void |
setGenerateJGoXML(boolean enable)
Enable the output of JGo XML extensions to SVG. |
void |
setGenerateSVG(boolean enable)
Enable the output of SVG elements to the generated XML. |
void |
setReadSVG(boolean enable)
|
void |
setSVGTooltips(boolean enable)
Enable the generation of SVG tooltips along with associated tooltip scripts. |
boolean |
SVGOutputEnabled()
Compute whether the output of SVG elements is currently allowed. |
void |
SVGReadDoc(java.io.InputStream ins,
JGoDocument jGoDoc)
Read an SVG XML document into the specified JGoDocument. |
void |
SVGReadDoc(java.io.Reader inr,
JGoDocument jGoDoc)
Read an SVG XML document into the specified JGoDocument. |
DomNode |
SVGReadElement(JGoDocument jGoDoc,
java.lang.String sTag,
DomElement element,
java.lang.String sFirstChildTag,
DomElement jGoChildElement,
JGoArea parent,
boolean addToDoc)
Read a DomElement, create an object to represent the DomElement and call SVGReadObject() on that object. |
void |
SVGTraverseChildren(JGoDocument jGoDoc,
DomNode svgNode,
JGoArea parent,
boolean addToDoc)
Traverse the DomNode children of a DomNode. |
void |
SVGWriteDoc(java.io.OutputStream outs,
JGoDocument jGoDoc)
Write an SVG XML document representing this JGoDocument. |
void |
SVGWriteDoc(java.io.Writer outw,
JGoDocument jGoDoc)
Write an SVG XML document representing this JGoDocument. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultDocument()
Method Detail |
public void resetDocument()
public DomElement createElement(java.lang.String s)
DomDoc
createElement
in interface DomDoc
s
- the name of the element type to instantiate.
SVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
public DomText createText(java.lang.String s)
DomDoc
createText
in interface DomDoc
s
- data for the new DomText node.
SVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
public DomCDATASection createCDATASection(java.lang.String s)
createCDATASection
in interface DomDoc
public DomElement getDocumentElement()
public void registerObject(java.lang.Object obj, DomElement node)
DomDoc
registerObject
in interface DomDoc
obj
- the object to register in the map.node
- the DomElement associated with the objSVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
DomDoc.registerReferencingNode(com.nwoods.jgo.DomElement, java.lang.String, java.lang.Object)
,
JGoObject.SVGReadObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.JGoDocument, com.nwoods.jgo.DomElement, com.nwoods.jgo.DomElement)
public void registerReferencingNode(DomElement referencingNode, java.lang.String refName, java.lang.Object referencedObj)
DomDoc
registerReferencingNode
in interface DomDoc
referencingNode
- the DomElement containing a reference to another DomElement.refName
- the name of the reference attribute in the referencing DomElement.referencedObj
- the referenced ObjectSVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
public boolean isRegisteredReference(java.lang.Object obj)
DomDoc
isRegisteredReference
in interface DomDoc
SVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
JGoObject.SVGWriteObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.DomElement)
,
DomDoc.registerReferencingNode(com.nwoods.jgo.DomElement, java.lang.String, java.lang.Object)
public void registerTag(java.lang.String tag, java.lang.Object obj)
DomDoc
registerTag
in interface DomDoc
tag
- the id attribute to be used as a key value for lookupsobj
- the object associated with this tag id valueSVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
JGoObject.SVGReadObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.JGoDocument, com.nwoods.jgo.DomElement, com.nwoods.jgo.DomElement)
,
JGoObject.SVGUpdateReference(java.lang.String, java.lang.Object)
public void registerReferencingObject(java.lang.Object obj, java.lang.String attr, java.lang.String refTag)
DomDoc
registerReferencingObject
in interface DomDoc
obj
- the Object containing a reference to another Object described by a DomElement.attr
- the name of the reference attribute in the referencing DomElement.refTag
- the unique identifier of the referenced Object as specified in the referencing DomElement.SVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
,
com.nwoods.jgo
public void SVGWriteDoc(java.io.OutputStream outs, JGoDocument jGoDoc)
This method will create a Scalable Vector Graphics (SVG) XML representation of the indicated JGoDocument. For every JGoObject contained in the the JGoDocument, JGoObject.SVGWriteObject() will be called to output an appropriate SVG representation of that object. If you have created subclasses of JGoObjects containing data that you would like to save in the SVG representation, you should override SVGWriteObject() to add this information. Refer to JGoObject.SVGWriteObject() for more details. Documents written by this method may be read by SVGReadDoc().
outs
- the OutputStream to which the document will be writtenjGoDoc
- the JGoDocument to be output as SVG XMLSVGWriteDoc(Writer, JGoDocument)
,
SVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
JGoObject.SVGWriteObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.DomElement)
,
DomDoc
,
DomNode
,
DomElement
,
DomText
public void SVGWriteDoc(java.io.Writer outw, JGoDocument jGoDoc)
This method will create a Scalable Vector Graphics (SVG) XML representation of the indicated JGoDocument. For every JGoObject contained in the the JGoDocument, JGoObject.SVGWriteObject() will be called to output an appropriate SVG representation of that object. If you have created subclasses of JGoObjects containing data that you would like to save in the SVG representation, you should override SVGWriteObject() to add this information. Refer to JGoObject.SVGWriteObject() for more details. Documents written by this method may be read by SVGReadDoc().
outw
- the Writer to which the document will be writtenjGoDoc
- the JGoDocument to be output as SVG XMLSVGWriteDoc(OutputStream, JGoDocument)
,
SVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
JGoObject.SVGWriteObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.DomElement)
,
DomDoc
,
DomNode
,
DomElement
,
DomText
public void SVGReadDoc(java.io.InputStream ins, JGoDocument jGoDoc) throws java.lang.Exception
This method will read a Scalable Vector Graphics (SVG) XML representation writen by SVGWriteDoc() into indicated JGoDocument. This method will call JGoObject.SVGReadObject() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.
This method may also be called to read any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.
ins
- the InputStream from which the document will be readjGoDoc
- the JGoDocument to be populated from the SVG XML document
java.lang.Exception
SVGReadDoc(Reader, JGoDocument)
,
SVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
JGoObject.SVGReadObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.JGoDocument, com.nwoods.jgo.DomElement, com.nwoods.jgo.DomElement)
,
DomDoc
,
DomNode
,
DomElement
,
DomText
public void SVGReadDoc(java.io.Reader inr, JGoDocument jGoDoc) throws java.lang.Exception
This method will read a Scalable Vector Graphics (SVG) XML representation writen by SVGWriteDoc() into indicated JGoDocument. This method will call JGoObject.SVGReadObject() for every <JGoClass> element encountered in a DomDoc. First, an object of the type specified by the class attribute will be created and then the SVGReadObject() method will be called on that newly created object. Refer to SVGWriteObject() for a description of the expected format of the SVG document.
This method may also be called to read any SVG document, including those not generated by JGo and therefore not containing any <JGoClass> elements. In such cases, the DefaultDocument.SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard JGoObjects such as JGoRectangles, JGoStrokes, etc will be created to represent these objects.
inr
- the Reader from which the document will be readjGoDoc
- the JGoDocument to be populated from the SVG XML document
java.lang.Exception
SVGReadDoc(InputStream, JGoDocument)
,
SVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
JGoObject.SVGReadObject(com.nwoods.jgo.DomDoc, com.nwoods.jgo.JGoDocument, com.nwoods.jgo.DomElement, com.nwoods.jgo.DomElement)
,
DomDoc
,
DomNode
,
DomElement
,
DomText
public void buildSVGDoc(JGoDocument jGoDoc)
This is typically called prior to writing out a DefaultDocument by calling writeFile(). See the implementation of SVGWriteDoc() for typical use of this method.
jGoDoc
- the JGoDocument from which to populate this DefaultDocument.public void buildJGoDoc(JGoDocument jGoDoc)
This is typically called after reading in an extended SVG representation to the DefaultDocument by calling readFile(). See the implementation of SVGReadDoc() for typical use of this method.
jGoDoc
- the JGoDocument to be populated from this DefaultDocumentpublic void SVGTraverseChildren(JGoDocument jGoDoc, DomNode svgNode, JGoArea parent, boolean addToDoc)
DomDoc
SVGTraverseChildren
in interface DomDoc
jGoDoc
- the JGoDocument being populated from the SVG XML documentsvgNode
- the DomNode whose children are to be traversedparent
- the JGoArea to which child objects should be added, or nulladdToDoc
- a flag indicating whether objects should be added to the JGoDocumentSVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
SVGReadElement(com.nwoods.jgo.JGoDocument, java.lang.String, com.nwoods.jgo.DomElement, java.lang.String, com.nwoods.jgo.DomElement, com.nwoods.jgo.JGoArea, boolean)
,
com.nwoods.jgo
public DomNode SVGReadElement(JGoDocument jGoDoc, java.lang.String sTag, DomElement element, java.lang.String sFirstChildTag, DomElement jGoChildElement, JGoArea parent, boolean addToDoc)
This method recognized JGoClass DomElements and automatically creates Objects of the class specified by the class attribute. If the newly created Object is a JGoObject it will automatically call SVGReadObject() on that object.
In order to handle DomElements which are not JGoClass elements or to handle JGoClass elements where the class attribute identifies a class which is not a subclass of JGoObject, the SVGReadElement() method may be subclassed to examine the SVG element and cause the appropriate JGoObject to be created to represent that element and call SVGReadObject() on that newly created object. By default, standard SVG elements such as <line> and <rect> are handled by creating similar JGoObjects such as JGoRectangles, JGoStrokes, etc. to represent these objects.
For convenience, because the DomElements representing a JGoObject are surrounded by a <g> element, the arguments passed to this method identify not only the DomElement beging read, but also the first child DomElement which represents the most specific subclass of the JGoObject to be created.
jGoDoc
- the JGoDocument being populated from the SVG XML documentsTag
- the tag of the DomElement being readelement
- the DomElement being readsFirstChildTag
- the tag of the first DomElement child of the DomElement being readparent
- the JGoArea to which child objects should be added, or nulladdToDoc
- a flag indicating whether objects should be added to the JGoDocumentSVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
public DomNode initializeObjectFromXML(JGoDocument jGoDoc, DomElement element, DomElement jGoChildElement, java.lang.Object obj)
jGoDoc
- the JGoDocument being populated from the SVG XML documentelement
- the DomElement being readjGoChildElement
- the current <JGoClass> element being read withing the <g>obj
- the newly instatiated Object specified by the JGoClass elementSVGReadDoc(java.io.InputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
public DomElement createJGoClassElement(java.lang.String className, DomElement parent)
DomDoc
Create a JGoClass DomElement with the specified className value for the class attribute and append it as the next child node of the specified parent. Note that the className supplied must be accurate and complete as it will be used to create an object of the correct type when the SVG XML file is read.
createJGoClassElement
in interface DomDoc
className
- the class name JGoObject this JGoClass DomElement representsparent
- the parent <g> to which to append the newly created DomElement that contains the definition of this JGoObject
SVGWriteDoc(java.io.OutputStream, com.nwoods.jgo.JGoDocument)
,
com.nwoods.jgo
public void setDisabledDrawing(boolean disable)
DomDoc
setDisabledDrawing
in interface DomDoc
disable
- true if SVG output of visible elements is to be disabledpublic boolean isDisabledDrawing()
DomDoc
isDisabledDrawing
in interface DomDoc
DomDoc.setDisabledDrawing(boolean)
public double getJGoSVGVersion()
DomDoc
getJGoSVGVersion
in interface DomDoc
public void setGenerateJGoXML(boolean enable)
DomDoc
setGenerateJGoXML
in interface DomDoc
enable
- true if JGo XML extensions to SVG are to be disabledpublic boolean isGenerateJGoXML()
DomDoc
isGenerateJGoXML
in interface DomDoc
DomDoc.setDisabledDrawing(boolean)
public void setGenerateSVG(boolean enable)
DomDoc
setGenerateSVG
in interface DomDoc
enable
- true if the output of any SVG elements to the generated XML is to be enabledpublic boolean isGenerateSVG()
DomDoc
isGenerateSVG
in interface DomDoc
DomDoc.setDisabledDrawing(boolean)
public void setReadSVG(boolean enable)
public boolean isReadSVG()
public void setSVGTooltips(boolean enable)
DomDoc
setSVGTooltips
in interface DomDoc
public boolean isSVGTooltips()
DomDoc
isSVGTooltips
in interface DomDoc
public boolean SVGOutputEnabled()
DomDoc
SVGOutputEnabled
in interface DomDoc
public boolean JGoXMLOutputEnabled()
DomDoc
JGoXMLOutputEnabled
in interface DomDoc
public org.w3c.dom.Node importNode(org.w3c.dom.Node importedNode, boolean deep) throws org.w3c.dom.DOMException
importedNode
- node to import.deep
- If true, recursively import the subtree under the specified node; if false, import only the node itself.
org.w3c.dom.DOMException
public org.w3c.dom.Document getDocument()
protected void GenerateTooltipInitialization(DomElement parent)
protected void RenderTooltip(DomElement parent)
protected void GenerateTooltipScript(DomElement parent)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |