procope.data
Class XGMMLWriter

java.lang.Object
  extended by procope.data.XGMMLWriter

public class XGMMLWriter
extends Object

Writes nodes and edges of any network to XGMML format. Supports arbitrary annotations for both edges and nodes.

Author:
Jan Krumsiek
See Also:
NetworkWriter, XGMMLGenerator

Constructor Summary
XGMMLWriter(OutputStream outstream)
          Creates a new XGMML writer to a given OutputStream
XGMMLWriter(String outfile)
          Create a new XGMML writer to a specified output file
 
Method Summary
 void close()
          Closes the writer and the underlying stream
 void footer()
          Prints the XGMML footer
 void writeEdge(String label, String source, String target, Map<String,? extends Object> annotations)
          Writes an edge to the XGMML data.
 void writeEdge(String label, String source, String target, Map<String,? extends Object> annotations, boolean directed)
          Writes an edge to the XGMML data.
 void writeNode(String ID, String label, Map<String,? extends Object> annotations)
          Write a network node in XGMML format.
 void writeNode(String id, String label, Map<String,? extends Object> annotations, boolean transition)
          Write a network node in XGMML format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XGMMLWriter

public XGMMLWriter(String outfile)
            throws FileNotFoundException
Create a new XGMML writer to a specified output file

Parameters:
outfile - path to the output file
Throws:
FileNotFoundException - if the file could not be opened

XGMMLWriter

public XGMMLWriter(OutputStream outstream)
Creates a new XGMML writer to a given OutputStream

Parameters:
outstream - the output stream
Method Detail

footer

public void footer()
Prints the XGMML footer


close

public void close()
Closes the writer and the underlying stream


writeNode

public void writeNode(String ID,
                      String label,
                      Map<String,? extends Object> annotations)
Write a network node in XGMML format. The ID will not be written to the data directly but functions as an internal unique identifier for that node. Use the same IDs to identify the adjacent nodes of an edge.

Parameters:
ID - internal identifier for that node, not written to the XGMML data but used for uniquely identifying that node when creating edges with this XGMML writer
label - label of that node, stored as canonicalName attribute in the XGMML data
annotations - list of key/values pairs which are annotated with that node, the string representation of each value will be used

writeNode

public void writeNode(String id,
                      String label,
                      Map<String,? extends Object> annotations,
                      boolean transition)
Write a network node in XGMML format. The ID will not be written to the data directly but functions as an internal unique identifier for that node. Use the same IDs to identify the adjacent nodes of an edge.

Parameters:
id - internal identifier for that node, not written to the XGMML data but used for uniquely identifying that node when creating edges with this XGMML writer
label - label of that node, stored as canonicalName attribute in the XGMML data
annotations - list of key/values pairs which are annotated with that node, the string representation of each value will be used
transition - special argument used for petri net creation, normal nodes will be displayed as circles, but if transition the node will be displayed as a rectangle

writeEdge

public void writeEdge(String label,
                      String source,
                      String target,
                      Map<String,? extends Object> annotations)
Writes an edge to the XGMML data. Use the same internal identifiers you used for the writeNode(java.lang.String, java.lang.String, java.util.Map) calls.

Parameters:
label - label of that edge, will be stored as a label attribute
source - internal identifier of the source node
target - internal identifier of the target node
annotations - list of key/values pairs which are annotated with that node, the string representation of each value will be used

writeEdge

public void writeEdge(String label,
                      String source,
                      String target,
                      Map<String,? extends Object> annotations,
                      boolean directed)
Writes an edge to the XGMML data. Use the same internal identifiers you used for the writeNode(java.lang.String, java.lang.String, java.util.Map) calls.

Parameters:
label - label of that edge, will be stored as a label attribute
source - internal identifier of the source node
target - internal identifier of the target node
annotations - list of key/values pairs which are annotated with that node, the string representation of each value will be used
directed - if true there will be an arrow towards the target node in the graph