com.yworks.yfiles.server.graphml.support
Class GraphMLLayoutGraphIOHandler

java.lang.Object
  extended byy.io.graphml.GraphMLHandler
      extended bycom.yworks.yfiles.server.graphml.support.GraphMLLayoutGraphIOHandler
Direct Known Subclasses:
GraphRoundtripSupportBase.RoundtripGraphMLLayoutGraphIOHandler

public class GraphMLLayoutGraphIOHandler
extends GraphMLHandler

IOHandler for (de)serializing graphs from/to GraphML format. GraphMLLayoutGraphIOHandler supports (de)serialization of custom GraphML attributes that hold data of simple type, as well as ids, and styles as DocumentFragments.

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


Nested Class Summary
 
Nested classes inherited from class y.io.graphml.GraphMLHandler
GraphMLHandler.BoolDataAcceptorInputHandler, GraphMLHandler.BooleanDataProviderOutputHandler, GraphMLHandler.DoubleDataAcceptorInputHandler, GraphMLHandler.DoubleDataProviderOutputHandler, GraphMLHandler.FloatDataAcceptorInputHandler, GraphMLHandler.FloatDataProviderOutputHandler, GraphMLHandler.InputHandlerQueryPredicate, GraphMLHandler.IntDataAcceptorInputHandler, GraphMLHandler.IntDataProviderOutputHandler, GraphMLHandler.LongDataAcceptorInputHandler, GraphMLHandler.LongDataProviderOutputHandler, GraphMLHandler.StringDataAcceptorInputHandler, GraphMLHandler.StringDataProviderOutputHandler
 
Field Summary
 
Fields inherited from class y.io.graphml.GraphMLHandler
z
 
Constructor Summary
GraphMLLayoutGraphIOHandler()
          Creates a new instance of GraphMLLayoutGraphIOHandler.
 
Method Summary
protected  void configureInputHandlers(Graph graph, GraphMLParser parser)
          Configures default event handlers for the GraphMLParser.fireQueryInputHandlersEvent(y.io.graphml.input.QueryInputHandlersEvent) event.
protected  void configureLookup(Graph graph, GraphMLParser parser)
          Configure the default lookup map of parser.
protected  void configureLookup(Graph graph, GraphMLWriter writer)
          Configure the default lookup map of writer.
protected  void configureOutputHandlers(Graph graph, GraphMLWriter writer)
          Configures default event handlers for the QueryOutputHandlersEvent event.
protected  GraphElementFactory createGraphElementFactory(GraphMLParser parser, Graph graph)
          Create an GraphElementFactory instance that creates the graph elements for the graph instance.
protected  HierarchySupport createHierarchySupport(Graph graph, GraphMLWriter writer)
          Creates a new HierarchySupport that can be used to traverse the hierarchy structure of the graph.
protected  PortProvider createPortProvider(Graph graph, GraphMLWriter writer)
          Creates a new PortProvider that is used to get the ports to write.
 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)
 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)
 boolean isAutoCreateGroupingDPs()
          Returns whether data providers for grouping information should automatically be created and registered.
 void read(Graph graph, java.lang.String name)
          Fills the contents of the given graph from a file.
 void read(Graph graph, java.net.URL url)
          Fills the contents of the given graph from a URL.
 void setAutoCreateGroupingDPs(boolean autoCreateGroupingDPs)
          Sets whether data providers for grouping information should automatically be created and registered.
 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 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 write(Graph graph, java.lang.String name)
          Writes the contents of the given graph to a file.
 
Methods inherited from class y.io.graphml.GraphMLHandler
addDeserializationHandler, addInputDataAcceptor, addInputDataAcceptor, addInputDataAcceptor, addInputDataAcceptor, addInputDataAcceptor, addInputDataAcceptor, addInputDataAcceptorFuture, addInputDataAcceptorFuture, addInputDataAcceptorFuture, addInputHandlerProvider, addNamespace, addOutputDataProvider, addOutputDataProvider, addOutputDataProvider, addOutputDataProvider, addOutputHandlerProvider, addParseEventListener, addRegisteredOutputDataProvider, addRegisteredOutputDataProvider, addRegisteredOutputDataProvider, addSchemaLocation, addSerializationHandler, addWriteEventListener, configureDeserializationHandlers, configureDeserializationProperties, configureGraphMLParser, configureGraphMLWriter, configureNamespaces, configureParseEvents, configureSchemaLocations, configureSerializationHandlers, configureSerializationProperties, configureWriteEvents, configureXMLWriter, createGraphMLParser, createGraphMLWriter, createXMLWriter, createXMLWriter, fireDeserializationEvent, fireQueryInputHandlersProviders, fireQueryOutputHandlersEvent, fireSerializationEvent, getDeserializationProperty, getKeyName, getKeyScope, getKeyType, getKeyUri, getSerializationProperty, isClearGraphBeforeRead, isWriteXMLSchema, matchesName, matchesScope, matchesType, matchesUri, onGraphMLParserHandleDeserialization, onGraphMLParserQueryInputHandlers, onGraphMLWriterHandleSerialization, onGraphMLWriterQueryOutputHandlers, read, read, removeDeserializationHandler, removeDeserializationProperty, removeInputHandlerProvider, removeOutputHandlerProvider, removeParseEventListener, removeSerializationHandler, removeSerializationProperty, removeWriteEventListener, setClearGraphBeforeRead, setDeserializationProperty, setSerializationProperty, setWriteXMLSchema, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphMLLayoutGraphIOHandler

public GraphMLLayoutGraphIOHandler()
Creates a new instance of GraphMLLayoutGraphIOHandler.

Method Detail

isAutoCreateGroupingDPs

public boolean isAutoCreateGroupingDPs()
Returns whether data providers for grouping information should automatically be created and registered. This only has an effect if these DataProviders don't exist yet on the graph, otherwise an existing instance will away be used. Default value is false.

Returns:
See Also:
setAutoCreateGroupingDPs(boolean), GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY

setAutoCreateGroupingDPs

public void setAutoCreateGroupingDPs(boolean autoCreateGroupingDPs)
Sets whether data providers for grouping information should automatically be created and registered. This only has an effect if these DataProviders don't exist yet on the graph, otherwise an existing instance will away be used. Default value is true.

Note: If this flag is set to true, DataProviders for the following keys will be automatically created and registered:

In that case, it is not safe to modify the graph afterwards and query the group structure.

See Also:
isAutoCreateGroupingDPs(), GroupingKeys.GROUP_DPKEY, GroupingKeys.NODE_ID_DPKEY, GroupingKeys.PARENT_NODE_ID_DPKEY

configureLookup

protected void configureLookup(Graph graph,
                               GraphMLWriter writer)
Configure the default lookup map of writer.

This implementation add a HierarchySupport created by createHierarchySupport(y.base.Graph, y.io.graphml.output.GraphMLWriter), a PortProvider created via createPortProvider(y.base.Graph, y.io.graphml.output.GraphMLWriter) a custom GraphElementIdProvider as well as this instance as GraphMLHandler to the lookup.

Parameters:
graph - The graph that will be written.
writer - The writer to configure.
See Also:
GraphMLWriter.setLookup(Class,Object), HierarchySupport, PortProvider, GraphElementIdProvider, GraphMLHandler

createHierarchySupport

protected HierarchySupport createHierarchySupport(Graph graph,
                                                  GraphMLWriter writer)
Creates a new HierarchySupport that can be used to traverse the hierarchy structure of the graph.

Parameters:
graph - The graph to create the support for.
writer - The writer the support is used in.
Returns:

createPortProvider

protected PortProvider createPortProvider(Graph graph,
                                          GraphMLWriter writer)
Creates a new PortProvider that is used to get the ports to write.

Parameters:
graph - The graph the provider shall provide ports for.
writer - The writer that uses the port provider.
Returns:

configureLookup

protected void configureLookup(Graph graph,
                               GraphMLParser parser)
Configure the default lookup map of parser.

This implementation does add a GraphElementIdAcceptor as well as a ReferenceResolver to the lookup.

Parameters:
graph - The graph that will be populated.
parser - The parser to configure.
See Also:
GraphMLParser.setLookup(Class,Object), GraphElementIdAcceptor, ReferenceResolver

configureInputHandlers

protected void configureInputHandlers(Graph graph,
                                      GraphMLParser parser)
Configures default event handlers for the GraphMLParser.fireQueryInputHandlersEvent(y.io.graphml.input.QueryInputHandlersEvent) event.

Support for post-processors is added by default

.

Parameters:
graph - The graph object the parser shall use.
parser - The parser that should be configured.

configureOutputHandlers

protected void configureOutputHandlers(Graph graph,
                                       GraphMLWriter writer)
Configures default event handlers for the QueryOutputHandlersEvent event.

This implementation does add handlers writing the node and edge layouts.

Parameters:
graph - The graph that will be written.
writer - The writer that should be configured.

write

public void write(Graph graph,
                  java.lang.String name)
           throws java.io.IOException
Writes the contents of the given graph to a file.

Parameters:
name - The name of the output file
Throws:
java.io.IOException

read

public void read(Graph graph,
                 java.lang.String name)
          throws java.io.IOException
Fills the contents of the given graph from a file.

Parameters:
name - The name of the file to be read.
Throws:
java.io.IOException

read

public void read(Graph graph,
                 java.net.URL url)
          throws java.io.IOException
Fills the contents of the given graph from a URL.

Parameters:
url - The url of the resource to be read.
Throws:
java.io.IOException

createGraphElementFactory

protected GraphElementFactory createGraphElementFactory(GraphMLParser parser,
                                                        Graph graph)
Create an GraphElementFactory instance that creates the graph elements for the graph instance.

Parameters:
parser - The parser to use.
graph - The graph that is populated.
Returns:
An GraphElementFactory instance that is configured for the given parameters.

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 -

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 -

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 -


Copyright © 2000-2013 yWorks GmbH. All rights reserved