1 package edu.uci.ics.jung.graph.event;
2
3 import edu.uci.ics.jung.graph.Graph;
4
5
6
7
8
9
10
11
12
13 public abstract class GraphEvent<V,E> {
14
15 protected Graph<V,E> source;
16 protected Type type;
17
18
19
20
21
22 public GraphEvent(Graph<V, E> source, Type type) {
23 this.source = source;
24 this.type = type;
25 }
26
27
28
29
30 public static enum Type {
31 VERTEX_ADDED,
32 VERTEX_REMOVED,
33 EDGE_ADDED,
34 EDGE_REMOVED
35 }
36
37
38
39
40 public static class Vertex<V,E> extends GraphEvent<V,E> {
41 protected V vertex;
42
43
44
45
46 public Vertex(Graph<V,E> source, Type type, V vertex) {
47 super(source,type);
48 this.vertex = vertex;
49 }
50
51
52
53
54 public V getVertex() {
55 return vertex;
56 }
57
58 @Override
59 public String toString() {
60 return "GraphEvent type:"+type+" for "+vertex;
61 }
62
63 }
64
65
66
67
68 public static class Edge<V,E> extends GraphEvent<V,E> {
69 protected E edge;
70
71
72
73
74 public Edge(Graph<V,E> source, Type type, E edge) {
75 super(source,type);
76 this.edge = edge;
77 }
78
79
80
81
82 public E getEdge() {
83 return edge;
84 }
85
86 @Override
87 public String toString() {
88 return "GraphEvent type:"+type+" for "+edge;
89 }
90
91 }
92
93
94
95
96 public Graph<V, E> getSource() {
97 return source;
98 }
99
100
101
102
103 public Type getType() {
104 return type;
105 }
106 }