|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecty.io.IOHandler
yext.graphml.graph2D.GraphMLIOHandler
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.
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 |
protected boolean writeDTDEnabled
protected boolean writeXMLSchemaEnabled
protected boolean validationEnabled
protected boolean ignoreGraphicsEnabled
protected List inputHandlers
protected List graphOutputHandlers
protected List graphmlOutputHandlers
protected List portOutputHandlers
protected List nodeOutputHandlers
protected List edgeOutputHandlers
| Constructor Detail |
public GraphMLIOHandler()
y.view are already registered.
Also provided by default is support for post-processors.
PostprocessorInputHandler| Method Detail |
public String getOutputEncoding()
public void setOutputEncoding(String outputEncoding)
outputEncoding - custom output encodingpublic boolean isReadEmbeddedResources()
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.
public void setReadEmbeddedResources(boolean readEmbeddedResource)
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.
readEmbeddedResource - whether embedded resources should be preferred.public boolean isWriteEmbeddedResources()
false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the
OutputHandler used. Default is true.
public void setWriteEmbeddedResources(boolean writeEmbeddedResource)
false, no resources are embedded in the graphml file. The exact behaviour in this case depends on the
OutputHandler used. Default is true.
writeEmbeddedResource - whether embedded resources should be written in a separate block.public void setWriteSelectionStateEnabled(boolean enabled)
enabled - true iff the selcetion state should be writtenpublic boolean isWriteSelectionStateEnabled()
true iff the selcetion state should be writtenpublic RealizerSerializerManager getRealizerSerializerManager()
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.
public ResourceDecoderProvider getResourceDecoderProvider()
ResourceDecoderProvider instance used by this
IOHandler.
public ResourceEncoderProvider getResourceEncoderProvider()
ResourceDecoderProvider instance used by this
IOHandler.
public GraphMLParseErrorHandler getErrorHandler()
public void setErrorHandler(GraphMLParseErrorHandler errorHandler)
errorHandler - the parse error handler that should be used by this instance.public String getGraphmlCoreNS()
"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"
public void setGraphmlCoreNS(String graphmlCoreNS)
"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"
graphmlCoreNS - the namespace URI where the core GraphML elements livepublic String getFileFormatString()
public String getFileNameExtension()
graphmlpublic boolean canRead()
true.
public boolean canWrite()
true.
public void addInputHandler(DOMInputHandler inputHandler,
int scope)
addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) instead
addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) and
test the scope in DOMInputHandler.acceptKey(org.w3c.dom.NamedNodeMap,int) instead
inputHandler - the input handler to be added.scope - This parameter is unusedpublic void addInputHandler(DOMInputHandler inputHandler)
for attribute of the key node
inputHandler - the input handler to be added.
public void addOutputHandler(OutputHandler outputHandler,
int scope)
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.public Collection getInputHandlers()
public Collection getInputHandlers(int scope)
getInputHandlers() instead
addInputHandler(org.graphdrawing.graphml.reader.dom.DOMInputHandler) and
test the scope in DOMInputHandler.acceptKey(org.w3c.dom.NamedNodeMap,int) instead
scope - This parameter is unused
public void clearInputHandlers()
public void removeInputHandler(DOMInputHandler handler)
handler - public Collection getOutputHandlers(int scope)
scope - Scope specifier; one of GraphMLConstants.SCOPE_GRAPH, GraphMLConstants.SCOPE_NODE,
or GraphMLConstants.SCOPE_EDGE.
protected DirectGraphMLWriter createDirectGraphMLWriter(Graph graph)
public static void addNodeRealizerSerializer(NodeRealizerSerializer nrs)
getRealizerSerializerManager() instead and register the serializer there
NodeRealizer implementation.
public static void addEdgeRealizerSerializer(EdgeRealizerSerializer ers)
getRealizerSerializerManager() instead and register the serializer there
EdgeRealizer implementation.
public void addAttribute(NodeMap map,
String attrName,
int type)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
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.
public void addAttribute(EdgeMap map,
String attrName,
int type)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
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.
public void addGraphAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
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.
public void addNodeAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
Note that the currently used yFiles data accessor implementations type-cast Java types long and float to int and double, respectively.
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.
public void addEdgeAttribute(DataProvider out,
DataAcceptor in,
String attrName,
int type)
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.public boolean isIgnoreGraphicsEnabled()
public boolean isValidationEnabled()
public boolean isWriteDTDEnabled()
public boolean isWriteXMLSchemaEnabled()
public void setIgnoreGraphicsEnabled(boolean b)
public void setValidationEnabled(boolean b)
public void setWriteDTDEnabled(boolean b)
public void setWriteXMLSchemaEnabled(boolean b)
public void addNamespace(String namespaceURI,
String shortName)
public void addSchemaLocation(String namespace,
String schemaLocation)
public void write(Graph2D graph,
OutputStream os)
throws IOException
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.
graph - The Graph2D object that is to be written to a GraphML file.os - The output stream that becomes the GraphML file.
IOExceptionYGraphElementProvider,
YHierarchyGraphElementProvider
public void write(Graph2D graph,
Writer writer)
throws IOException
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.
graph - The Graph2D object that is to be written to a GraphML file.writer - The writer that becomes the GraphML file.
IOExceptionYGraphElementProvider,
YHierarchyGraphElementProvider
protected void configureCoreWriter(XmlWriter coreWriter,
Graph graph)
public void write(Graph2D graph,
Result result)
throws IOException
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.
graph - The Graph2D object that is to be written to a GraphML file.result - The Transformer result that stores the output.
IOExceptionYGraphElementProvider,
YHierarchyGraphElementProviderprotected GraphElementProvider createGraphElementProvider(Graph graph)
protected DomXmlWriter createXmlWriter(Writer w)
protected DomXmlWriter createXmlWriter(OutputStream w)
throws UnsupportedEncodingException
UnsupportedEncodingExceptionprotected DomXmlWriter createXmlWriter(Result res)
public DataProvider getIdDataProvider()
setIdDataProvider(y.base.DataProvider)
setIdDataProvider(y.base.DataProvider)public void setIdDataProvider(DataProvider idDataProvider)
DataProvider instance that provides graphml element ids for each element.
DirectGraphMLWriter
will be used.setGraphIdProvider(y.base.DataProvider)
idDataProvider - public DataAcceptor getIdDataAcceptor()
setIdDataAcceptor(y.base.DataAcceptor)
setIdDataAcceptor(y.base.DataAcceptor)public void setIdDataAcceptor(DataAcceptor idDataAcceptor)
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)
idDataAcceptor - public DataAcceptor getGraphIdAcceptor()
setGraphIdAcceptor(y.base.DataAcceptor)
setGraphIdAcceptor(y.base.DataAcceptor)public void setGraphIdAcceptor(DataAcceptor graphIdAcceptor)
DataAcceptor instance that stores graphml graph element ids for each graph itself.
This stores a graph id for each group node in hierarchic graphs.
graphIdAcceptor - public DataProvider getGraphIdProvider()
setGraphIdProvider(y.base.DataProvider)
setGraphIdProvider(y.base.DataProvider)public void setGraphIdProvider(DataProvider graphIdProvider)
DataProvider instance that provides graphml element ids for each graph itself.
This should provide a graph id for each group node in hierarchic graphs.
DirectGraphMLWriter
will be used.
graphIdProvider - public DOMGraphMLParser.HandlerProvider getInputHandlerProvider()
public void setInputHandlerProvider(DOMGraphMLParser.HandlerProvider inputHandlerProvider)
inputHandlerProvider - The input handler provider to use.public DirectGraphMLWriter.HandlerProvider getOutputHandlerProvider()
public void setOutputHandlerProvider(DirectGraphMLWriter.HandlerProvider outputHandlerProvider)
outputHandlerProvider - The output handler provider to use.
public void read(Graph2D graph,
InputStream is)
throws IOException
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.
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.
IOExceptionYGraphElementFactory,
YHierarchyGraphElementFactory
public void read(Graph2D graph,
Node n)
throws IOException
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
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.
IOExceptionYGraphElementFactory,
YHierarchyGraphElementFactoryprotected DOMGraphMLParser createParser(Graph graph)
protected GraphElementFactory createGraphElementFactory(Graph graph)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||