01: package org.apache.ojb.broker;
02:
03: import java.io.Serializable;
04: import java.util.Collection;
05: import java.util.Vector;
06:
07: /**
08: * GraphNode and GraphEdge model oriented graph with named nodes.
09: * In this case there are two relations between two classes.
10: * @author Oleg Nitz
11: */
12: public class GraphNode implements Serializable {
13: private int id;
14: private String name;
15: private Collection outgoingEdges;
16: private Collection incomingEdges;
17: private int locationId;
18: private Point location;
19:
20: public GraphNode() {
21: }
22:
23: public GraphNode(int id, String name, int locationId) {
24: this .id = id;
25: this .name = name;
26: this .locationId = locationId;
27: }
28:
29: public GraphNode(String name) {
30: this .name = name;
31: }
32:
33: public void addOutgoingEdge(GraphEdge edge) {
34: if (outgoingEdges == null) {
35: outgoingEdges = new Vector();
36: }
37: outgoingEdges.add(edge);
38: }
39:
40: public void addIncomingEdge(GraphEdge edge) {
41: if (incomingEdges == null) {
42: incomingEdges = new Vector();
43: }
44: incomingEdges.add(edge);
45: }
46:
47: public Collection getOutgoingEdges() {
48: return outgoingEdges;
49: }
50:
51: public Collection getIncomingEdges() {
52: return incomingEdges;
53: }
54:
55: public String getName() {
56: return name;
57: }
58:
59: public int getLocationId() {
60: return locationId;
61: }
62:
63: public Point getLocation() {
64: return location;
65: }
66:
67: public int getId() {
68: return id;
69: }
70:
71: public void setOutgoingEdges(Collection edges) {
72: outgoingEdges = edges;
73: }
74:
75: public void setIncomingEdges(Collection edges) {
76: incomingEdges = edges;
77: }
78:
79: public void setName(String name) {
80: this .name = name;
81: }
82:
83: public void setLocationId(int locationId) {
84: this .locationId = locationId;
85: }
86:
87: public void setLocation(Point location) {
88: this .location = location;
89: }
90:
91: public void setId(int id) {
92: this .id = id;
93: }
94:
95: public String toString() {
96: return name + " " + outgoingEdges;
97: }
98:
99: }
|