本文整理汇总了Java中y.io.GraphMLIOHandler类的典型用法代码示例。如果您正苦于以下问题:Java GraphMLIOHandler类的具体用法?Java GraphMLIOHandler怎么用?Java GraphMLIOHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphMLIOHandler类属于y.io包,在下文中一共展示了GraphMLIOHandler类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeIOHandler
import y.io.GraphMLIOHandler; //导入依赖的package包/类
/**
* This method is called before the view modes and actions are registered
* and the menu and toolbar is build.
*/
protected void initializeIOHandler() {
// set up io handlers
graphMLIOHandler = new GraphMLIOHandler();
final GraphMLHandler handler = graphMLIOHandler.getGraphMLHandler();
handler.addOutputHandlerProvider(new NodeOutputHandler());
handler.addOutputHandlerProvider(new EdgeOutputHandler());
handler.addInputHandlerProvider(new EdgeInputHandler());
handler.addInputHandlerProvider(new NodeInputHandler());
ygfIOHandler = new YGFIOHandler();
}
示例2: getGraphXML
import y.io.GraphMLIOHandler; //导入依赖的package包/类
/**
* return a xml string representation of the given graph
*
* @param graph
* @return graph XML string
*/
public static String getGraphXML(Graph2D graph) {
StringBuilder xmlStringBuilder = new StringBuilder();
String name = "temp.graphxml";
File outputFile = new File(name);
// write graph to a temp file
GraphMLIOHandler ioh = new GraphMLIOHandler();
final GraphMLHandler handler = ioh.getGraphMLHandler();
handler.addInputHandlerProvider(new NodeInputHandler());
handler.addInputHandlerProvider(new EdgeInputHandler());
try {
ioh.write(graph, name);
} catch (IOException ioe) {
D.show(ioe);
}
try {
FileInputStream fstream = new FileInputStream(name);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
// Read File Line By Line
while ((strLine = br.readLine()) != null) {
xmlStringBuilder.append(strLine);
xmlStringBuilder.append("\n");
}
in.close();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
outputFile.delete();
return xmlStringBuilder.toString();
}