Skip to content
Snippets Groups Projects
Commit 7fdd6c80 authored by Sören Henning's avatar Sören Henning
Browse files

worked on dot export

parent e2610b35
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
package kieker.analysis.graph;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import kieker.analysis.graph.export.dot.DotWriter2;
import kieker.analysis.graph.export.graphml.GraphMLExporter;
import kieker.analysis.graph.impl.GraphImpl;
......@@ -97,6 +99,9 @@ public class GraphTester {
GraphMLExporter graphMLExporter = new GraphMLExporter();
graphMLExporter.export(graph, System.out);
DotWriter2 dotWriter = new DotWriter2(graph, new OutputStreamWriter(System.out));
dotWriter.transform();
// DotExporter dotExporter = new DotExporter();
// dotExporter.export(graph, System.out);
......
......@@ -8,7 +8,6 @@ import kieker.analysis.graph.traversal.FlatGraphTraverser;
import kieker.analysis.graph.traversal.GraphTraverser;
import kieker.analysis.graph.traversal.VertexVisitor;
//TODO better name mapper
public abstract class AbstractTransformer<O> implements VertexVisitor, EdgeVisitor {
private final GraphTraverser graphTraverser = new FlatGraphTraverser(this, this);
......
package kieker.analysis.graph.export.dot;
import java.io.IOException;
import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex;
import kieker.analysis.graph.export.AbstractTransformer;
import kieker.analysis.graph.util.dot.DotWriter;
class AbstractDotWriter extends AbstractTransformer<Void> {
private final DotWriter dotWriter;
public AbstractDotWriter(final Graph graph, final DotWriter dotWriter) {
super(graph);
this.dotWriter = dotWriter;
// TODO Better put this in own method
try {
dotWriter.start(graph.getName());
// TODO more stuff
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected void mapVertex(final Vertex vertex) {
try {
if (vertex.hasChildGraph()) {
Graph childGraph = vertex.getChildGraph();
dotWriter.addClusterStart(childGraph.getName());
// TODO more stuff
DotSubgraphWriter dotWriter2 = new DotSubgraphWriter(childGraph, dotWriter);
dotWriter2.transform();
dotWriter.addClusterStop();
} else {
dotWriter.addNode(vertex.getId().toString(), null); // TODO
}
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected void mapEdge(final Edge edge) {
// TODO Auto-generated method stub
try {
String sourceId = edge.getVertex(Direction.OUT).getId().toString();
String targetId = edge.getVertex(Direction.IN).getId().toString();
dotWriter.addEdge(sourceId, targetId); // TODO
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected Void getTransformation() {
// TODO own method
try {
dotWriter.finish();
} catch (IOException e) {
// TODO Handle IO Exception
}
return null;
}
}
package kieker.analysis.graph.export.dot;
import java.io.IOException;
import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex;
import kieker.analysis.graph.export.AbstractTransformer;
import kieker.analysis.graph.util.dot.DotWriter;
class DotSubgraphWriter extends AbstractTransformer<Void> {
private final DotWriter dotWriter;
protected DotSubgraphWriter(final Graph graph, final DotWriter dotWriter) {
super(graph);
this.dotWriter = dotWriter;
}
@Override
protected void mapVertex(final Vertex vertex) {
try {
if (vertex.hasChildGraph()) {
Graph childGraph = vertex.getChildGraph();
dotWriter.addClusterStart(childGraph.getName());
// TODO more stuff
DotSubgraphWriter dotWriter2 = new DotSubgraphWriter(childGraph, dotWriter);
dotWriter2.transform();
dotWriter.addClusterStop();
} else {
dotWriter.addNode(vertex.getId().toString(), null); // TODO
}
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected void mapEdge(final Edge edge) {
// TODO Auto-generated method stub
try {
String sourceId = edge.getVertex(Direction.OUT).getId().toString();
String targetId = edge.getVertex(Direction.IN).getId().toString();
dotWriter.addEdge(sourceId, targetId); // TODO
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected Void getTransformation() {
return null;
}
}
package kieker.analysis.graph.export.dot;
import java.io.IOException;
import java.io.Writer;
import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex;
import kieker.analysis.graph.export.AbstractTransformer;
import kieker.analysis.graph.util.dot.DotWriter;
//TODO rename
public class DotWriter2 extends AbstractTransformer<Void> {
private final DotWriter dotWriter;
private DotSubgraphWriter dotSubgraphWriter;
public DotWriter2(final Graph graph, final Writer writer) {
super(graph);
this.dotWriter = new DotWriter(writer);
// TODO Better put this in own method
try {
dotWriter.start(graph.getName());
// TODO more stuff
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected void mapVertex(final Vertex vertex) {
try {
if (vertex.hasChildGraph()) {
Graph childGraph = vertex.getChildGraph();
dotWriter.addClusterStart(childGraph.getName());
// TODO more stuff
DotSubgraphWriter dotWriter2 = new DotSubgraphWriter(childGraph, dotWriter);
dotWriter2.transform();
dotWriter.addClusterStop();
} else {
dotWriter.addNode(vertex.getId().toString(), null); // TODO
}
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected void mapEdge(final Edge edge) {
// TODO Auto-generated method stub
try {
String sourceId = edge.getVertex(Direction.OUT).getId().toString();
String targetId = edge.getVertex(Direction.IN).getId().toString();
dotWriter.addEdge(sourceId, targetId); // TODO
} catch (IOException e) {
// TODO Handle IO Exception
}
}
@Override
protected Void getTransformation() {
// TODO own method
try {
dotWriter.finish();
} catch (IOException e) {
// TODO Handle IO Exception
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment