yext.graphml.graph2D
Class GraphMLIOHandler

java.lang.Object
  extended byy.io.IOHandler
      extended byyext.graphml.graph2D.GraphMLIOHandler
Direct Known Subclasses:
GraphMLLayoutGraphIOHandler, ZipGraphMLIOHandler

public class GraphMLIOHandler
extends IOHandler

IOHandler for (de)serializing graphs from/to GraphML format. By default, GraphMLIOHandler serializes all attributes that relate to the visual representation of both NodeRealizer and EdgeRealizer implementations. This does also include all information regarding a realizer's dimension or its position. To avoid this behavior and instead serialize only the graph's structure, property ignoreGraphics can be enabled.

GraphMLIOHandler supports (de)serialization of custom GraphML attributes that hold data of simple type. Such GraphML attributes with graph, node, or edge scope can be conveniently enabled using one of the following methods addGraphAttribute, addNodeAttribute, or addEdgeAttribute.

For realizer implementations which are not included in the yFiles Viewer component a realizer serializer has to be provided.

For more information about the GraphML file format please refer to the GraphML Primer.

See Also:
AbstractEdgeRealizerSerializer, AbstractNodeRealizerSerializer

Field Summary
protected  List edgeOutputHandlers
           
protected  List graphmlOutputHandlers
           
protected  List graphOutputHandlers
           
protected  boolean ignoreGraphicsEnabled
           
protected  List inputHandlers
           
protected  List nodeOutputHandlers
           
protected  List portOutputHandlers
           
protected  boolean validationEnabled
           
protected  boolean writeDTDEnabled
           
protected  boolean writeXMLSchemaEnabled
           
 
Constructor Summary
GraphMLIOHandler()
          Creates a new instance of GraphMLIOHandler.
 
Method Summary
 void addAttribute(EdgeMap map, String attrName, int type)
          Adds a GraphML attribute with edge scope that holds data of simple type.
 void addAttribute(NodeMap map, String attrName, int type)
          Adds a GraphML attribute with node scope that holds data of simple type.
 void addEdgeAttribute(DataProvider out, DataAcceptor in, String attrName, int type)
          Adds a GraphML attribute with edge scope that holds data of simple type.
static void addEdgeRealizerSerializer(EdgeRealizerSerializer ers)
          Deprecated. Use getRealizerSerializerManager() instead and register the serializer there
 void addGraphAttribute(DataProvider out, DataAcceptor in, String attrName, int type)
          Adds a GraphML attribute with graph scope that holds data of simple type.
 void addInputHandler(DOMInputHandler inputHandler)
          Adds a subordinate input handler to this GraphMLIOHandler.
 void addInputHandler(DOMInputHandler inputHandler, int scope)
          Deprecated. Use addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) instead
 void addNamespace(String namespaceURI, String shortName)
          Adds a namespace declaration to the GraphML file.
 void addNodeAttribute(DataProvider out, DataAcceptor in, String attrName, int type)
          Adds a GraphML attribute with node scope that holds data of simple type.
static void addNodeRealizerSerializer(NodeRealizerSerializer nrs)
          Deprecated. Use getRealizerSerializerManager() instead and register the serializer there
 void addOutputHandler(OutputHandler outputHandler, int scope)
          Adds a subordinate output handler for the given element scope to this GraphMLIOHandler.
 void addSchemaLocation(String namespace, String schemaLocation)
          Adds a schema location to the header of a GraphML file.
 boolean canRead()
          Returns true.
 boolean canWrite()
          Returns true.
 void clearInputHandlers()
          Clear all input handlers
protected  void configureCoreWriter(XmlWriter coreWriter, Graph graph)
           
protected  DirectGraphMLWriter createDirectGraphMLWriter(Graph graph)
          Creates and returns a GraphML writer instance.
protected  GraphElementFactory createGraphElementFactory(Graph graph)
          Create the factory instance used for reading the graph
protected  GraphElementProvider createGraphElementProvider(Graph graph)
          Create the provider instance used for writing the graph
protected  DOMGraphMLParser createParser(Graph graph)
           
protected  DomXmlWriter createXmlWriter(OutputStream w)
           
protected  DomXmlWriter createXmlWriter(Result res)
           
protected  DomXmlWriter createXmlWriter(Writer w)
           
 GraphMLParseErrorHandler getErrorHandler()
          Return the parse error handler that is used by this instance.
 String getFileFormatString()
          Returns the GraphML file format string.
 String getFileNameExtension()
          Returns the default file name extension for GraphML files.
 DataAcceptor getGraphIdAcceptor()
          Return the DataAcceptor instance for graph ids that has been previously registered with setGraphIdAcceptor(y.base.DataAcceptor)
 DataProvider getGraphIdProvider()
          Return the DataProvider instance for graph ids that has been previously registered with setGraphIdProvider(y.base.DataProvider)
 String getGraphmlCoreNS()
          Get the namespace URI where the core GraphML elements live.
 DataAcceptor getIdDataAcceptor()
          Return the DataAcceptor instance for graph element ids that has been previously registered with setIdDataAcceptor(y.base.DataAcceptor)
 DataProvider getIdDataProvider()
          Return the DataProvider instance for graph element ids that has been previously registered with setIdDataProvider(y.base.DataProvider)
 DOMGraphMLParser.HandlerProvider getInputHandlerProvider()
          Returns the input handler provider used when parsing a graph.
 Collection getInputHandlers()
          Returns the registered input handlers for GraphML attributes that are registered with this GraphMLIOHandler.
 Collection getInputHandlers(int scope)
          Deprecated. Use getInputHandlers() instead
 String getOutputEncoding()
          Get the output encoding that is used by this handler instance.
 DirectGraphMLWriter.HandlerProvider getOutputHandlerProvider()
          Returns the output handler provider used when writing a graph.
 Collection getOutputHandlers(int scope)
          Returns an editable view on the registered output handlers for GraphML attributes with given scope that are registered with this GraphMLIOHandler.
 RealizerSerializerManager getRealizerSerializerManager()
          Get the RealizerSerializerManager instance used by this IOHandler.
 ResourceDecoderProvider getResourceDecoderProvider()
          Get the ResourceDecoderProvider instance used by this IOHandler.
 ResourceEncoderProvider getResourceEncoderProvider()
          Get the ResourceDecoderProvider instance used by this IOHandler.
 boolean isIgnoreGraphicsEnabled()
          Returns whether graphic attributes stored in the realizers are not serialized.
 boolean isReadEmbeddedResources()
          Returns whether embedded resources should be evaluated.
 boolean isValidationEnabled()
          Returns if a validating parser is used.
 boolean isWriteDTDEnabled()
          Returns if a reference to the GraphML DTD should be written.
 boolean isWriteEmbeddedResources()
          Returns whether embedded resources should be written in a separate block.
 boolean isWriteSelectionStateEnabled()
          Returns whether or not to serialize the selection state of the realizer.
 boolean isWriteXMLSchemaEnabled()
          Returns if a reference to the GraphML XML Schema definition should be written.
 void read(Graph2D graph, InputStream is)
          Reads a GraphML file from the given input stream and populates the Graph2D object.
 void read(Graph2D graph, Node n)
          Reads a Graph from a preparsed DOM tree object.
 void removeInputHandler(DOMInputHandler handler)
          unregister an inputhandler
 void setErrorHandler(GraphMLParseErrorHandler errorHandler)
          Set a custom parse error handler that is used by this instance.
 void setGraphIdAcceptor(DataAcceptor graphIdAcceptor)
          Register a DataAcceptor instance that stores graphml graph element ids for each graph itself.
 void setGraphIdProvider(DataProvider graphIdProvider)
          Register a DataProvider instance that provides graphml element ids for each graph itself.
 void setGraphmlCoreNS(String graphmlCoreNS)
          Set the namespace URI where the core GraphML elements live.
 void setIdDataAcceptor(DataAcceptor idDataAcceptor)
          Register a DataAcceptor instance that stores graphml element ids.
 void setIdDataProvider(DataProvider idDataProvider)
          Register a DataProvider instance that provides graphml element ids for each element.
 void setIgnoreGraphicsEnabled(boolean b)
          Sets if graphic attributes stored in the realizers must not be serialized.
 void setInputHandlerProvider(DOMGraphMLParser.HandlerProvider inputHandlerProvider)
          Sets the input handler provider used when parsing a graph.
 void setOutputEncoding(String outputEncoding)
          Set a specific encoding for the output.
 void setOutputHandlerProvider(DirectGraphMLWriter.HandlerProvider outputHandlerProvider)
          Sets the output handler provider used when writing a graph.
 void setReadEmbeddedResources(boolean readEmbeddedResource)
          Set whether embedded resources should be preferred on reading.
 void setValidationEnabled(boolean b)
          Sets if a validating parser is used.
 void setWriteDTDEnabled(boolean b)
          Sets if a reference to the GraphML DTD should be written.
 void setWriteEmbeddedResources(boolean writeEmbeddedResource)
          Set whether embedded resources should be written in a separate block.
 void setWriteSelectionStateEnabled(boolean enabled)
          Whether or not to serialize the selection state of the realizer.
 void setWriteXMLSchemaEnabled(boolean b)
          Returns if a reference to the GraphML XML Schema definition should be written.
 void write(Graph2D graph, OutputStream os)
          Writes the given Graph2D object to the output stream creating a GraphML file.
 void write(Graph2D graph, Result result)
          Writes the given Graph2D object to a Transformer result.
 void write(Graph2D graph, Writer writer)
          Writes the given Graph2D object to the output stream creating a GraphML file.
 
Methods inherited from class y.io.IOHandler
canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, read, shouldSerialize, shouldSerialize, write, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writeDTDEnabled

protected boolean writeDTDEnabled

writeXMLSchemaEnabled

protected boolean writeXMLSchemaEnabled

validationEnabled

protected boolean validationEnabled

ignoreGraphicsEnabled

protected boolean ignoreGraphicsEnabled

inputHandlers

protected List inputHandlers

graphOutputHandlers

protected List graphOutputHandlers

graphmlOutputHandlers

protected List graphmlOutputHandlers

portOutputHandlers

protected List portOutputHandlers

nodeOutputHandlers

protected List nodeOutputHandlers

edgeOutputHandlers

protected List edgeOutputHandlers
Constructor Detail

GraphMLIOHandler

public GraphMLIOHandler()
Creates a new instance of GraphMLIOHandler. By default, realizer serializers for all yFiles node and edge realizer implementations as found in package y.view are already registered. Also provided by default is support for post-processors.

See Also:
PostprocessorInputHandler
Method Detail

getOutputEncoding

public String getOutputEncoding()
Get the output encoding that is used by this handler instance. Default is UTF-8

Returns:
the current output encoding

setOutputEncoding

public void setOutputEncoding(String outputEncoding)
Set a specific encoding for the output. Default is UTF-8

Parameters:
outputEncoding - custom output encoding

isReadEmbeddedResources

public boolean isReadEmbeddedResources()
Returns whether embedded resources should be evaluated. If false, no resources are read from an embedded resource data tag. The exact behaviour in this case depends on the InputHandler used (i.e. resolve an external URL instead). Default is true.

Returns:
whether embedded resources should be read if present.

setReadEmbeddedResources

public void setReadEmbeddedResources(boolean readEmbeddedResource)
Set whether embedded resources should be preferred on reading. If true, resources are always read from an embedded resource description, otherwise, the exact behaviour depends on the InputHandler used (i.e. resolve an external URL instead). Default is true.

Parameters:
readEmbeddedResource - whether embedded resources should be preferred.

isWriteEmbeddedResources

public boolean isWriteEmbeddedResources()
Returns whether embedded resources should be written in a separate block. If false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the OutputHandler used. Default is true.

Returns:
whether embedded resources should be written in a separate block.

setWriteEmbeddedResources

public void setWriteEmbeddedResources(boolean writeEmbeddedResource)
Set whether embedded resources should be written in a separate block. If false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the OutputHandler used. Default is true.

Parameters:
writeEmbeddedResource - whether embedded resources should be written in a separate block.

setWriteSelectionStateEnabled

public void setWriteSelectionStateEnabled(boolean enabled)
Whether or not to serialize the selection state of the realizer. By default this feature is disabled.

Parameters:
enabled - true iff the selcetion state should be written

isWriteSelectionStateEnabled

public boolean isWriteSelectionStateEnabled()
Returns whether or not to serialize the selection state of the realizer. By default this feature is disabled.

Returns:
true iff the selcetion state should be written

getRealizerSerializerManager

public RealizerSerializerManager getRealizerSerializerManager()
Get the RealizerSerializerManager instance used by this IOHandler. This allows to set/add/remove RealizerSerializers for a specific handler instance, thus giving mode control than possible by addNodeRealizerSerializer(NodeRealizerSerializer) etc.

Returns:
the RealizerSerializerManager instance that is used by this IOHandler instance

getResourceDecoderProvider

public ResourceDecoderProvider getResourceDecoderProvider()
Get the ResourceDecoderProvider instance used by this IOHandler.

Returns:
the ResourceDecoderProvider instance that is used by this IOHandler instance

getResourceEncoderProvider

public ResourceEncoderProvider getResourceEncoderProvider()
Get the ResourceDecoderProvider instance used by this IOHandler.

Returns:
the ResourceDecoderProvider instance that is used by this IOHandler instance

getErrorHandler

public GraphMLParseErrorHandler getErrorHandler()
Return the parse error handler that is used by this instance.

Returns:
the parse error handler that is used by this instance.

setErrorHandler

public void setErrorHandler(GraphMLParseErrorHandler errorHandler)
Set a custom parse error handler that is used by this instance. If this is not set, a default implementation that handles some common cases is used.

Parameters:
errorHandler - the parse error handler that should be used by this instance.

getGraphmlCoreNS

public String getGraphmlCoreNS()
Get the namespace URI where the core GraphML elements live. By default, this is set to "http://graphml.graphdrawing.org/xmlns/graphml" for compatibility with older yfiles GraphML releases, however, the official GraphML namespace is now "http://graphml.graphdrawing.org/xmlns"

Returns:
the namespace URI where the core GraphML elements live

setGraphmlCoreNS

public void setGraphmlCoreNS(String graphmlCoreNS)
Set the namespace URI where the core GraphML elements live. By default, this is set to "http://graphml.graphdrawing.org/xmlns/graphml" for compatibility with older yfiles GraphML releases, however, the official GraphML namespace is now "http://graphml.graphdrawing.org/xmlns"

Parameters:
graphmlCoreNS - the namespace URI where the core GraphML elements live

getFileFormatString

public String getFileFormatString()
Returns the GraphML file format string.


getFileNameExtension

public String getFileNameExtension()
Returns the default file name extension for GraphML files.

Returns:
graphml

canRead

public boolean canRead()
Returns true.


canWrite

public boolean canWrite()
Returns true.


addInputHandler

public void addInputHandler(DOMInputHandler inputHandler,
                            int scope)
Deprecated. Use addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) instead

Adds a subordinate input handler to this GraphMLIOHandler. This is deprecated, use addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) and test the scope in DOMInputHandler.acceptKey(org.w3c.dom.NamedNodeMap,int) instead

Parameters:
inputHandler - the input handler to be added.
scope - This parameter is unused

addInputHandler

public void addInputHandler(DOMInputHandler inputHandler)
Adds a subordinate input handler to this GraphMLIOHandler. The scope is determined by the for attribute of the key node

Parameters:
inputHandler - the input handler to be added.

addOutputHandler

public void addOutputHandler(OutputHandler outputHandler,
                             int scope)
Adds a subordinate output handler for the given element scope to this GraphMLIOHandler.

Parameters:
outputHandler - the output handler to be added.
scope - Scope specifier; one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_GRAPHML, GraphMLConstants.SCOPE_NODE, or GraphMLConstants.SCOPE_EDGE.

getInputHandlers

public Collection getInputHandlers()
Returns the registered input handlers for GraphML attributes that are registered with this GraphMLIOHandler.

Returns:
All registered subordinate input handlers for GraphML.

getInputHandlers

public Collection getInputHandlers(int scope)
Deprecated. Use getInputHandlers() instead

Returns the registered input handlers for GraphML attributes that are registered with this GraphMLIOHandler. This is deprecated, use addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) and test the scope in DOMInputHandler.acceptKey(org.w3c.dom.NamedNodeMap,int) instead

Parameters:
scope - This parameter is unused
Returns:
All registered subordinate input handlers for GraphML.

clearInputHandlers

public void clearInputHandlers()
Clear all input handlers


removeInputHandler

public void removeInputHandler(DOMInputHandler handler)
unregister an inputhandler

Parameters:
handler -

getOutputHandlers

public Collection getOutputHandlers(int scope)
Returns an editable view on the registered output handlers for GraphML attributes with given scope that are registered with this GraphMLIOHandler. Output handlers can be added or removed from the returned collection.

Parameters:
scope - Scope specifier; one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE, or GraphMLConstants.SCOPE_EDGE.
Returns:
All registered subordinate output handlers for GraphML attributes with given scope.

createDirectGraphMLWriter

protected DirectGraphMLWriter createDirectGraphMLWriter(Graph graph)
Creates and returns a GraphML writer instance. Note that this method is also invoked to create the GraphML writer that is used with this GraphMLIOHandler.


addNodeRealizerSerializer

public static void addNodeRealizerSerializer(NodeRealizerSerializer nrs)
Deprecated. Use getRealizerSerializerManager() instead and register the serializer there

Adds a serializer for a custom NodeRealizer implementation.


addEdgeRealizerSerializer

public static void addEdgeRealizerSerializer(EdgeRealizerSerializer ers)
Deprecated. Use getRealizerSerializerManager() instead and register the serializer there

Adds a serializer for a custom EdgeRealizer implementation.


addAttribute

public void addAttribute(NodeMap map,
                         String attrName,
                         int type)
Adds a GraphML attribute with node scope that holds data of simple type. Supported are Java types such as boolean, int, long, float, double, and String.

Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.

Parameters:
map - The node map that is accessed by both input and output handler whenever actual data for a node is to be read from or written to a GraphML file.
attrName - The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
type - Type specifier as defined in interface AttributeConstants.

addAttribute

public void addAttribute(EdgeMap map,
                         String attrName,
                         int type)
Adds a GraphML attribute with edge scope that holds data of simple type. Supported are Java types such as boolean, int, long, float, double, and String.

Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.

Parameters:
map - The edge map that is accessed by both input and output handler whenever actual data for an edge is to be read from or written to a GraphML file.
attrName - The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
type - Type specifier as defined in interface AttributeConstants.

addGraphAttribute

public void addGraphAttribute(DataProvider out,
                              DataAcceptor in,
                              String attrName,
                              int type)
Adds a GraphML attribute with graph scope that holds data of simple type. Supported are Java types such as boolean, int, long, float, double, and String.

Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.

Parameters:
out - The data provider that is accessed by the output handler whenever actual data for a graph is to be written to a GraphML file.
in - The data acceptor that is accessed by the input handler whenever actual data for a graph is to be read from a GraphML file.
attrName - The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
type - Type specifier as defined in interface AttributeConstants.

addNodeAttribute

public void addNodeAttribute(DataProvider out,
                             DataAcceptor in,
                             String attrName,
                             int type)
Adds a GraphML attribute with node scope that holds data of simple type. Supported are Java types such as boolean, int, long, float, double, and String.

Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.

Parameters:
out - The data provider that is accessed by the output handler whenever actual data for a node is to be written to a GraphML file.
in - The data acceptor that is accessed by the input handler whenever actual data for a node is to be read from a GraphML file.
attrName - The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
type - Type specifier as defined in interface AttributeConstants.

addEdgeAttribute

public void addEdgeAttribute(DataProvider out,
                             DataAcceptor in,
                             String attrName,
                             int type)
Adds a GraphML attribute with edge scope that holds data of simple type. Supported are Java types such as boolean, int, long, float, double, and String.

Parameters:
out - The data provider that is accessed by the output handler whenever actual data for an edge is to be written to a GraphML file.
in - The data acceptor that is accessed by the input handler whenever actual data for an edge is to be read from a GraphML file.
attrName - The name that is used inside the GraphML file with the XML attr.name attribute of the GraphML <key> element.
type - Type specifier as defined in interface AttributeConstants.

isIgnoreGraphicsEnabled

public boolean isIgnoreGraphicsEnabled()
Returns whether graphic attributes stored in the realizers are not serialized.


isValidationEnabled

public boolean isValidationEnabled()
Returns if a validating parser is used.


isWriteDTDEnabled

public boolean isWriteDTDEnabled()
Returns if a reference to the GraphML DTD should be written.


isWriteXMLSchemaEnabled

public boolean isWriteXMLSchemaEnabled()
Returns if a reference to the GraphML XML Schema definition should be written.


setIgnoreGraphicsEnabled

public void setIgnoreGraphicsEnabled(boolean b)
Sets if graphic attributes stored in the realizers must not be serialized.


setValidationEnabled

public void setValidationEnabled(boolean b)
Sets if a validating parser is used.


setWriteDTDEnabled

public void setWriteDTDEnabled(boolean b)
Sets if a reference to the GraphML DTD should be written.


setWriteXMLSchemaEnabled

public void setWriteXMLSchemaEnabled(boolean b)
Returns if a reference to the GraphML XML Schema definition should be written.


addNamespace

public void addNamespace(String namespaceURI,
                         String shortName)
Adds a namespace declaration to the GraphML file.


addSchemaLocation

public void addSchemaLocation(String namespace,
                              String schemaLocation)
Adds a schema location to the header of a GraphML file.


write

public void write(Graph2D graph,
                  OutputStream os)
           throws IOException
Writes the given Graph2D object to the output stream creating a GraphML file. The proper DTD (Document Type Definition), or alternatively XML Schema definition, as well as the XML header is also written.

Note that the graph element provider that is used by the encoder logic to write the GraphML file is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

Parameters:
graph - The Graph2D object that is to be written to a GraphML file.
os - The output stream that becomes the GraphML file.
Throws:
IOException
See Also:
YGraphElementProvider, YHierarchyGraphElementProvider

write

public void write(Graph2D graph,
                  Writer writer)
           throws IOException
Writes the given Graph2D object to the output stream creating a GraphML file. The proper DTD (Document Type Definition), or alternatively XML Schema definition, as well as the XML header is also written.

Note that the graph element provider that is used by the encoder logic to write the GraphML file is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

Parameters:
graph - The Graph2D object that is to be written to a GraphML file.
writer - The writer that becomes the GraphML file.
Throws:
IOException
See Also:
YGraphElementProvider, YHierarchyGraphElementProvider

configureCoreWriter

protected void configureCoreWriter(XmlWriter coreWriter,
                                   Graph graph)

write

public void write(Graph2D graph,
                  Result result)
           throws IOException
Writes the given Graph2D object to a Transformer result. The proper DTD (Document Type Definition), or alternatively XML Schema definition, as well as the XML header is also written.

Note that the graph element provider that is used by the encoder logic to write the GraphML file is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

This method is especially useful if the result should be postprocessed by other XML applications directly (i.e. without re-reading and parsing)

Parameters:
graph - The Graph2D object that is to be written to a GraphML file.
result - The Transformer result that stores the output.
Throws:
IOException
See Also:
YGraphElementProvider, YHierarchyGraphElementProvider

createGraphElementProvider

protected GraphElementProvider createGraphElementProvider(Graph graph)
Create the provider instance used for writing the graph


createXmlWriter

protected DomXmlWriter createXmlWriter(Writer w)

createXmlWriter

protected DomXmlWriter createXmlWriter(OutputStream w)
                                throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

createXmlWriter

protected DomXmlWriter createXmlWriter(Result res)

getIdDataProvider

public DataProvider getIdDataProvider()
Return the DataProvider instance for graph element ids that has been previously registered with setIdDataProvider(y.base.DataProvider)

Returns:
the DataProvider instance for graph element ids that has been previously registered with setIdDataProvider(y.base.DataProvider)

setIdDataProvider

public void setIdDataProvider(DataProvider idDataProvider)
Register a DataProvider instance that provides graphml element ids for each element.

Parameters:
idDataProvider -

getIdDataAcceptor

public DataAcceptor getIdDataAcceptor()
Return the DataAcceptor instance for graph element ids that has been previously registered with setIdDataAcceptor(y.base.DataAcceptor)

Returns:
the DataAcceptor instance for graph element ids that has been previously registered with setIdDataAcceptor(y.base.DataAcceptor)

setIdDataAcceptor

public void setIdDataAcceptor(DataAcceptor idDataAcceptor)
Register a DataAcceptor instance that stores graphml element ids. This stores a graphml element id for each graph element, except for nested graphs (see setGraphIdAcceptor(y.base.DataAcceptor)

Parameters:
idDataAcceptor -

getGraphIdAcceptor

public DataAcceptor getGraphIdAcceptor()
Return the DataAcceptor instance for graph ids that has been previously registered with setGraphIdAcceptor(y.base.DataAcceptor)

Returns:
the DataAcceptor instance for graph ids that has been previously registered with setGraphIdAcceptor(y.base.DataAcceptor)

setGraphIdAcceptor

public void setGraphIdAcceptor(DataAcceptor graphIdAcceptor)
Register a DataAcceptor instance that stores graphml graph element ids for each graph itself. This stores a graph id for each group node in hierarchic graphs.
  • Note: This is used for nested graphs, when a graphML graph element has no corresponding ygraph object (i.e. for group nodes)
  • Parameters:
    graphIdAcceptor -

    getGraphIdProvider

    public DataProvider getGraphIdProvider()
    Return the DataProvider instance for graph ids that has been previously registered with setGraphIdProvider(y.base.DataProvider)

    Returns:
    the DataProvider instance for graph ids that has been previously registered with setGraphIdProvider(y.base.DataProvider)

    setGraphIdProvider

    public void setGraphIdProvider(DataProvider graphIdProvider)
    Register a DataProvider instance that provides graphml element ids for each graph itself. This should provide a graph id for each group node in hierarchic graphs.

    Parameters:
    graphIdProvider -

    getInputHandlerProvider

    public DOMGraphMLParser.HandlerProvider getInputHandlerProvider()
    Returns the input handler provider used when parsing a graph.

    Returns:
    The input handler provider used when parsing a graph.

    setInputHandlerProvider

    public void setInputHandlerProvider(DOMGraphMLParser.HandlerProvider inputHandlerProvider)
    Sets the input handler provider used when parsing a graph.

    Parameters:
    inputHandlerProvider - The input handler provider to use.

    getOutputHandlerProvider

    public DirectGraphMLWriter.HandlerProvider getOutputHandlerProvider()
    Returns the output handler provider used when writing a graph.

    Returns:
    The output handler provider used when writing a graph.

    setOutputHandlerProvider

    public void setOutputHandlerProvider(DirectGraphMLWriter.HandlerProvider outputHandlerProvider)
    Sets the output handler provider used when writing a graph.

    Parameters:
    outputHandlerProvider - The output handler provider to use.

    read

    public void read(Graph2D graph,
                     InputStream is)
              throws IOException
    Reads a GraphML file from the given input stream and populates the Graph2D object.

    Note that the graph element factory that is used by the parser logic to create new graph elements (and eventually also new graphs) is chosen depending on whether the Graph2D object has a HierarchyManager associated or not.

    Parameters:
    graph - The Graph2D object that is to be populated with nodes and edges as read from the GraphML file.
    is - The input stream that holds the GraphML file to be read.
    Throws:
    IOException
    See Also:
    YGraphElementFactory, YHierarchyGraphElementFactory

    read

    public void read(Graph2D graph,
                     Node n)
              throws IOException
    Reads a Graph from a preparsed DOM tree object.

    Note that the graph element factory that is used by the parser logic to create new graph elements (and eventually also new graphs) is chosen depending on whether the Graph2D object has a HierarchyManager associated or not. This overload is useful if the IOHandler is used after a chain of TRaX transformations

    Note: No validation is performed on the DOM tree by this overload.

    Parameters:
    graph - The Graph2D object that is to be populated with nodes and edges as read from the GraphML file.
    n - The root node of the preparsed DOM tree.
    Throws:
    IOException
    See Also:
    YGraphElementFactory, YHierarchyGraphElementFactory

    createParser

    protected DOMGraphMLParser createParser(Graph graph)

    createGraphElementFactory

    protected GraphElementFactory createGraphElementFactory(Graph graph)
    Create the factory instance used for reading the graph



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