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

graphs can now have properties

parent 391d627a
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
package kieker.analysis.graph;
public interface Edge extends Element {
public interface Edge extends GraphElement {
public Vertex getVertex(Direction direction) throws IllegalArgumentException;
......
package kieker.analysis.graph;
import java.util.Set;
public abstract interface Element {
public <T> T getProperty(String key);
public Set<String> getPropertyKeys();
public void setProperty(String key, Object value);
public <T> T removeProperty(String key);
public void remove();
public Object getId();
}
package kieker.analysis.graph;
import java.util.Set;
public abstract interface Element {
public <T> T getProperty(String key);
public Set<String> getPropertyKeys();
public void setProperty(String key, Object value);
public <T> T removeProperty(String key);
}
package kieker.analysis.graph;
public interface Graph {
public interface Graph extends Element {
public String getName();
......
......@@ -3,7 +3,7 @@ package kieker.analysis.graph;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import kieker.analysis.graph.export.dot.DotWriter;
import kieker.analysis.graph.export.dot.DotExporter;
import kieker.analysis.graph.export.graphml.GraphMLExporter;
import kieker.analysis.graph.impl.GraphImpl;
......@@ -99,7 +99,7 @@ public class GraphTester {
GraphMLExporter graphMLExporter = new GraphMLExporter();
graphMLExporter.export(graph, System.out);
DotWriter dotWriter = new DotWriter(graph, new OutputStreamWriter(System.out));
DotExporter dotWriter = new DotExporter(graph, new OutputStreamWriter(System.out));
dotWriter.transform();
// DotExporter dotExporter = new DotExporter();
......
package kieker.analysis.graph;
public interface Vertex extends Element {
public interface Vertex extends GraphElement {
public Graph addChildGraph();
......
......@@ -4,7 +4,7 @@ import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Vertex;
class EdgeImpl extends ElementImpl implements Edge {
class EdgeImpl extends GraphElementImpl implements Edge {
private final Vertex outVertex;
private final Vertex inVertex;
......
package kieker.analysis.graph.impl;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import kieker.analysis.graph.Element;
abstract class ElementImpl implements Element {
protected Map<String, Object> properties = new HashMap<String, Object>();
protected final String id;
protected final GraphImpl graph;
protected ElementImpl(final String id, final GraphImpl graph) {
this.graph = graph;
this.id = id;
}
@Override
@SuppressWarnings("unchecked")
public <T> T getProperty(final String key) {
return (T) this.properties.get(key);
}
@Override
public Set<String> getPropertyKeys() {
return new HashSet<String>(this.properties.keySet());
}
@Override
public void setProperty(final String key, final Object value) {
this.properties.put(key, value);
}
@Override
@SuppressWarnings("unchecked")
public <T> T removeProperty(final String key) {
return (T) this.properties.remove(key);
}
@Override
abstract public void remove();
@Override
public Object getId() {
return this.id;
}
}
package kieker.analysis.graph.impl;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import kieker.analysis.graph.Element;
abstract class ElementImpl implements Element {
protected Map<String, Object> properties = new HashMap<String, Object>();
@Override
@SuppressWarnings("unchecked")
public <T> T getProperty(final String key) {
return (T) this.properties.get(key);
}
@Override
public Set<String> getPropertyKeys() {
return new HashSet<String>(this.properties.keySet());
}
@Override
public void setProperty(final String key, final Object value) {
this.properties.put(key, value);
}
@Override
@SuppressWarnings("unchecked")
public <T> T removeProperty(final String key) {
return (T) this.properties.remove(key);
}
}
package kieker.analysis.graph.impl;
import kieker.analysis.graph.GraphElement;
abstract class GraphElementImpl extends ElementImpl implements GraphElement {
protected final String id;
protected final GraphImpl graph;
protected GraphElementImpl(final String id, final GraphImpl graph) {
super();
this.graph = graph;
this.id = id;
}
@Override
abstract public void remove();
@Override
public Object getId() {
return this.id;
}
}
......@@ -9,7 +9,7 @@ import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex;
public class GraphImpl implements Graph {
public class GraphImpl extends ElementImpl implements Graph {
protected String name = "G";
......
......@@ -9,7 +9,7 @@ import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex;
class VertexImpl extends ElementImpl implements Vertex {
class VertexImpl extends GraphElementImpl implements Vertex {
protected Map<String, Edge> outEdges = new HashMap<String, Edge>();
protected Map<String, Edge> inEdges = new HashMap<String, Edge>();
......
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