public class CGXParser
extends org.xml.sax.helpers.DefaultHandler
Modifier and Type | Field and Description |
---|---|
private boolean |
_ignoreLayout |
private boolean |
_keepIDs |
private boolean |
_makeList
Whether to gather all parsed objects into a arraylist (usually used for
selecting)
|
private Point2D.Double |
_offset |
private ArrayList |
_parsedObjects |
private boolean |
_preserveGraph
Whether to keep the top level graph intact (perhaps adding to it), but
retaining its created, modified, etc.
|
private Graph |
_topLevelGraph |
private boolean |
_traceTags |
static Properties |
CharGerXMLTagNameToClassName
used to keep track of old and new versions of CharGer class names that
might appear in a ".cgx" file.
|
(package private) String |
definition |
(package private) ArrayList |
descriptors |
(package private) org.w3c.dom.Document |
doc |
(package private) GenericTypeDescriptor |
genericDescr |
(package private) String |
genericString |
static Point2D.Double |
offsetZero |
private Hashtable<String,String> |
oldNewIDs
Has entries of the form "nnn", "nnn" denoting the old ident (i.e.
|
(package private) StringBuilder |
stringCollector |
(package private) WordnetTypeDescriptor |
wordnetDescr |
Constructor and Description |
---|
CGXParser()
Parser works as an instance; this allows for multiple parsers to be open
at the same time.
|
CGXParser(InputStream is) |
CGXParser(String input)
Used for copy/paste.
|
Modifier and Type | Method and Description |
---|---|
void |
buildDocument(InputStream is)
Create the entire parse tree for the document.
|
Point2D.Double |
getOffset() |
Graph |
getParsedGraph() |
ArrayList<GraphObject> |
getParsedObjects() |
private GraphObject |
instantiateGraphObject(String tagname)
Factory to create a graph object from the given tagname.
|
boolean |
isIgnoreLayout() |
boolean |
isKeepIDs() |
boolean |
isMakeList() |
boolean |
isPreserveGraph() |
static void |
loadCharGerKeyWordToClassTable()
Creates a lookup that helps parsers determine (from an XML tag) what
class is required.
|
void |
parseCGXMLCG(Graph graph)
Assumes that the Document has already been built.
|
void |
parseCGXMLGraphTagElement(org.w3c.dom.Element graphelem,
Graph g)
Handle the "graph" tag.
|
void |
parseColorInfo(org.w3c.dom.Node node,
GraphObject go)
Assumes its node is a "color" tag generated by Charger.
|
void |
parseEdgeInfo(org.w3c.dom.Node node,
GraphObject go)
Handles the "edge" tag element for arrow height, width and edge thickness.
|
void |
parseFontInfo(org.w3c.dom.Node node,
GraphObject go)
Handles the "font" tag element for arrow height, width and edge thickness.
|
static ArrayList<GraphObject> |
parseForCopying(String cgxmlString,
Graph g)
Factory method for setting up a parser for a list of graph objects from a
string.
|
static boolean |
parseForNewGraph(InputStream is,
Graph g)
Factory method for setting up a parser for a new graph from a stream.
|
static void |
parseForNewGraph(String xmlString,
Graph g)
Factory method for setting up a parser for a new graph from a string.
|
void |
parseGraphObjectElement(org.w3c.dom.Element goelem,
GraphObject go)
Handles any document element representing a GraphObject.
|
void |
parseHistoryInfo(org.w3c.dom.Element historyElem,
GraphObject go)
Handles the "history" tag element which contains one or more history event nodes..
|
void |
parseHistoryRecordInfo(org.w3c.dom.Element eventElem,
GraphObject go)
Parse an individual history event tag and add the history event to the given object.
|
void |
parseLayoutInfo(org.w3c.dom.Element layoutElem,
GraphObject go)
Handles the "layout" tag element for the rectangle, color, font and edge elements.
|
void |
parseLayoutOnly(GraphObject go)
Assume document consists of only layout information.
|
void |
parseRectangleInfo(org.w3c.dom.Node node,
GraphObject go)
Assumes its node is a rectangle tag from Charger.
|
void |
parseRectangleInfo(org.w3c.dom.Node node,
GraphObject go,
Point2D.Double offset)
Handles the "rectangle" tag element for arrow height, width and edge thickness.
|
void |
parseReferentInfo(org.w3c.dom.Element element,
GraphObject go)
Handles the "referent" tag element
|
static Color |
parseRGB(String rgb) |
void |
parseTypeInfo(org.w3c.dom.Element element,
GraphObject go)
Handles the "type" tag element for the type label and for
both generic descriptors and wordnet descriptors.
|
void |
setID(org.w3c.dom.Element elem,
GraphObject go)
Set the object's id, either by using its already-generated id or else by
the id attribute in the element.
|
void |
setIgnoreLayout(boolean _ignoreLayout) |
void |
setKeepIDs(boolean _keepIDs) |
void |
setMakeList(boolean _makeList) |
void |
setOffset(Point2D.Double _offset) |
void |
setParsedObjects(ArrayList<GraphObject> _parsedObjects) |
void |
setPreserveGraph(boolean _preserveGraph) |
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
org.w3c.dom.Document doc
private boolean _traceTags
private boolean _keepIDs
private boolean _ignoreLayout
private boolean _preserveGraph
private boolean _makeList
public static Point2D.Double offsetZero
private Point2D.Double _offset
private ArrayList _parsedObjects
private Graph _topLevelGraph
private Hashtable<String,String> oldNewIDs
String genericString
StringBuilder stringCollector
WordnetTypeDescriptor wordnetDescr
GenericTypeDescriptor genericDescr
ArrayList descriptors
String definition
public static Properties CharGerXMLTagNameToClassName
public CGXParser()
public CGXParser(String input) throws CGEncodingException
input
- CGEncodingException
public CGXParser(InputStream is) throws CGEncodingException
CGEncodingException
public boolean isIgnoreLayout()
public void setIgnoreLayout(boolean _ignoreLayout)
public boolean isKeepIDs()
public void setKeepIDs(boolean _keepIDs)
public Point2D.Double getOffset()
public void setOffset(Point2D.Double _offset)
public boolean isMakeList()
public void setMakeList(boolean _makeList)
public boolean isPreserveGraph()
public void setPreserveGraph(boolean _preserveGraph)
public ArrayList<GraphObject> getParsedObjects()
public void setParsedObjects(ArrayList<GraphObject> _parsedObjects)
public Graph getParsedGraph()
public static void loadCharGerKeyWordToClassTable()
public static boolean parseForNewGraph(InputStream is, Graph g)
is
- public static void parseForNewGraph(String xmlString, Graph g)
xmlString
- a complete cgx graph stringpublic static ArrayList<GraphObject> parseForCopying(String cgxmlString, Graph g)
cgxmlString
- a string of an arbitrary set of objectsg
- the graph to which the parsed objects will be addedpublic void buildDocument(InputStream is) throws CGEncodingException
is
- an XML stream containing CG-XML objects.CGEncodingException
public void parseCGXMLCG(Graph graph)
graph
- initialized but possibly empty graphpublic void parseCGXMLGraphTagElement(org.w3c.dom.Element graphelem, Graph g)
graphelem
- g
- the graph object, already instantiated (but probably empty).public void parseLayoutOnly(GraphObject go)
public void parseTypeInfo(org.w3c.dom.Element element, GraphObject go)
node
- The DOM element containing the tag and its subtree.go
- the graph object to be modifiedWordnetTypeDescriptor.getInstanceFromXMLDOM(org.w3c.dom.Element)
,
GenericTypeDescriptor.getInstanceFromXMLDOM(org.w3c.dom.Element)
public void parseReferentInfo(org.w3c.dom.Element element, GraphObject go)
element
- The DOM element containing the tag and its subtree.go
- the graph object to be modifiedpublic void parseLayoutInfo(org.w3c.dom.Element layoutElem, GraphObject go)
layoutElem
- The DOM element containing the tag and its subtree.go
- the graph object to be modifiedpublic void parseRectangleInfo(org.w3c.dom.Node node, GraphObject go)
node
- go
- parseRectangleInfo(org.w3c.dom.Node, charger.obj.GraphObject, java.awt.geom.Point2D.Double)
public void parseRectangleInfo(org.w3c.dom.Node node, GraphObject go, Point2D.Double offset)
node
- The DOM element containing the tag and its subtree.go
- the graph object to be modifiedpublic void parseColorInfo(org.w3c.dom.Node node, GraphObject go)
node
- The DOM element containing the tag and its subtree.go
- the graph object to be modifiedpublic void parseFontInfo(org.w3c.dom.Node node, GraphObject go)
node
- The DOM element containing the tag and its subtree.go
- the graph object to be modifiedpublic void parseEdgeInfo(org.w3c.dom.Node node, GraphObject go)
node
- The DOM element containing the tag and its subtree.go
- the edge to be modifiedpublic static Color parseRGB(String rgb)
rgb
- a string of the form "rrr,ggg,bbb"public void parseHistoryInfo(org.w3c.dom.Element historyElem, GraphObject go)
historyElem
- The DOM element containing the tag and its subtree.go
- the graph object to which the history belongspublic void parseHistoryRecordInfo(org.w3c.dom.Element eventElem, GraphObject go)
eventElem
- a DOM node with an "event" tag.go
- private GraphObject instantiateGraphObject(String tagname)
CharGerXMLTagNameToClassName
public void setID(org.w3c.dom.Element elem, GraphObject go)
elem
- Any element that might contain an "id" attributego
- The object whose id is to be set.public void parseGraphObjectElement(org.w3c.dom.Element goelem, GraphObject go)
goelem
- The graphobject tag element. Uses the tag name to determine which type argument "go" is.go
- The graph object whose properties are to be set from this. Must be already instantiated.
element.