Search this API

y.io.graphml.graph2d
Class AbstractNodeRealizerSerializer

java.lang.Object
  extended by y.io.graphml.graph2d.AbstractNodeRealizerSerializer
All Implemented Interfaces:
NodeRealizerSerializer
Direct Known Subclasses:
FallbackNodeRealizerSerializer, GenericNodeRealizerSerializer, ImageNodeRealizerSerializer, ProxyShapeNodeRealizerSerializer, ShapeNodeRealizerSerializer

public abstract class AbstractNodeRealizerSerializer
extends Object
implements NodeRealizerSerializer

Abstract base class for instances of NodeRealizerSerializer. This class parses/writes basic properties of NodeRealizers.


Constructor Summary
AbstractNodeRealizerSerializer()
           
 
Method Summary
 boolean canHandle(Node n, GraphMLParseContext context)
          Returns true iff n.getNamespaceURI().equals(getNamespaceURI()) && n.getLocalName().equals(getName()).
 boolean canHandle(NodeRealizer nr, GraphMLWriteContext context)
          Returns true iff nr.getClass() == getRealizerClass().
 NodeRealizer createRealizerInstance(Node node, GraphMLParseContext context)
          Create new instance of the Realizer from the given information
 String getNamespacePrefix()
          The namespace prefix to use for writing.
 void parse(NodeRealizer nr, Node domNode, GraphMLParseContext context)
          Parses the properties into an instance of NodeRealizer.
protected  void parseLabel(NodeRealizer nr, Node n, GraphMLParseContext context)
          Parses a single NodeLabel element.
protected  void parseNodePorts(NodeRealizer nr, Node domNode, GraphMLParseContext context)
          Parses the NodePorts elements and its NodePort child elements.
 void write(NodeRealizer nr, XmlWriter writer, GraphMLWriteContext context)
          Writes the realizer element's content.
 void writeAttributes(NodeRealizer nr, XmlWriter writer, GraphMLWriteContext context)
          Writes the attributes of an NodeRealizer element.
protected  void writeFill(XmlWriter writer, NodeRealizer nr)
          Write the Fill element.
protected  void writeNodeLabel(NodeLabel label, XmlWriter writer, GraphMLWriteContext context)
          Writes a single NodeLabel element.
protected  void writeNodePorts(NodeRealizer nr, XmlWriter writer, GraphMLWriteContext context)
          Writes the NodePorts elements and its NodePort child elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface y.io.graphml.graph2d.NodeRealizerSerializer
getName, getNamespaceURI, getRealizerClass
 

Constructor Detail

AbstractNodeRealizerSerializer

public AbstractNodeRealizerSerializer()
Method Detail

parse

public void parse(NodeRealizer nr,
                  Node domNode,
                  GraphMLParseContext context)
           throws GraphMLParseException
Description copied from interface: NodeRealizerSerializer
Parses the properties into an instance of NodeRealizer.

Specified by:
parse in interface NodeRealizerSerializer
Throws:
GraphMLParseException
Parameters:
nr - An existing NodeRealizer instance which is configured.
domNode - The XML node containing the realizer data.
context - The current parse context.

parseNodePorts

protected void parseNodePorts(NodeRealizer nr,
                              Node domNode,
                              GraphMLParseContext context)
                       throws GraphMLParseException
Parses the NodePorts elements and its NodePort child elements.

Throws:
GraphMLParseException
Parameters:
nr - The node realizer that will own the node ports.
domNode - The DOM node containing node port data.
context - The current parse context.

parseLabel

protected void parseLabel(NodeRealizer nr,
                          Node n,
                          GraphMLParseContext context)
                   throws GraphMLParseException
Parses a single NodeLabel element.

Throws:
GraphMLParseException
Parameters:
nr - The NodeRealizer that will own this label.
n - The DOM node containing the label data.
context - The current parse context.

writeAttributes

public void writeAttributes(NodeRealizer nr,
                            XmlWriter writer,
                            GraphMLWriteContext context)
Description copied from interface: NodeRealizerSerializer
Writes the attributes of an NodeRealizer element.

Specified by:
writeAttributes in interface NodeRealizerSerializer
Parameters:
nr - The Realizer to write.
writer - The XmlWriter for the serialization.
context - The current write context.

write

public void write(NodeRealizer nr,
                  XmlWriter writer,
                  GraphMLWriteContext context)
           throws GraphMLWriteException
Description copied from interface: NodeRealizerSerializer
Writes the realizer element's content.

Specified by:
write in interface NodeRealizerSerializer
Throws:
GraphMLWriteException
Parameters:
nr - The Realizer to write.
writer - The XmlWriter for the serialization.
context - The current write context.

writeNodePorts

protected void writeNodePorts(NodeRealizer nr,
                              XmlWriter writer,
                              GraphMLWriteContext context)
                       throws GraphMLWriteException
Writes the NodePorts elements and its NodePort child elements.

Throws:
GraphMLWriteException
Parameters:
nr - The node realizer for which node port information is written.
writer - The XML writer to use.
context - The current write context.

writeNodeLabel

protected void writeNodeLabel(NodeLabel label,
                              XmlWriter writer,
                              GraphMLWriteContext context)
                       throws GraphMLWriteException
Writes a single NodeLabel element.

Throws:
GraphMLWriteException
Parameters:
label - The label to write.
writer - The XML writer to use.
context - The current write context.

writeFill

protected void writeFill(XmlWriter writer,
                         NodeRealizer nr)
Write the Fill element.

Parameters:
writer - The writer to use.
nr - The NodeRealizer whose fill is to be written.

canHandle

public boolean canHandle(NodeRealizer nr,
                         GraphMLWriteContext context)
Returns true iff nr.getClass() == getRealizerClass().

Specified by:
canHandle in interface NodeRealizerSerializer
Parameters:
nr - The realizer that may be written.
context - The current write context.
Returns:
true iff nr.getClass() == getRealizerClass().

canHandle

public boolean canHandle(Node n,
                         GraphMLParseContext context)
Returns true iff n.getNamespaceURI().equals(getNamespaceURI()) && n.getLocalName().equals(getName()).

Specified by:
canHandle in interface NodeRealizerSerializer
Parameters:
n - The DOM node that may be parsed.
context - The current parse context.
Returns:
true iff n.getNamespaceURI().equals(getNamespaceURI()) && n.getLocalName().equals(getName()).

createRealizerInstance

public NodeRealizer createRealizerInstance(Node node,
                                           GraphMLParseContext context)
                                    throws GraphMLParseException
Description copied from interface: NodeRealizerSerializer
Create new instance of the Realizer from the given information

Specified by:
createRealizerInstance in interface NodeRealizerSerializer
Throws:
GraphMLParseException
Parameters:
node - The DOM node that represents the realizer data.
context - The current parse context.
Returns:
new instance of the Realizer

getNamespacePrefix

public String getNamespacePrefix()
The namespace prefix to use for writing.

Specified by:
getNamespacePrefix in interface NodeRealizerSerializer
Returns:
null, meaning that a predeclared mapping should be used.

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.