01: /* Exit.java */
02:
03: package org.quilt.graph;
04:
05: import org.quilt.exception.QuiltException;
06:
07: /**
08: * An exit vertex in a directed graph. This vertex always has an
09: * index of 1.
10: *
11: * @author <a href="jddixon@users.sourceforge.net">Jim Dixon</a>
12: */
13: public class Exit extends Vertex {
14:
15: /**
16: * Constructor for the exit vertex for a Quilt directed graph.
17: * This may be a subgraph. Only the entry vertex should use
18: * this constructor.
19: *
20: * @param g Reference to the parent Directed graph.
21: */
22: protected Exit(Directed g) {
23: checkForNull(g, "graph");
24: graph = g;
25: index = g.anotherVertex(this );
26: connector = new UnaryConnector(new Edge(this , this ));
27: }
28:
29: // ACCESSOR METHODS /////////////////////////////////////////////
30: /**
31: * Get the connection, back to the entry vertex in a top-level
32: * graph. XXX Perhaps we don't want to implement this.
33: */
34: public Connector getConnector() {
35: return connector;
36: }
37:
38: // CONVENIENCE METHODS //////////////////////////////////////////
39: /** Get the outgoing edge. */
40: public Edge getEdge() {
41: return ((UnaryConnector) connector).getEdge();
42: }
43:
44: /** Get its target. */
45: public Vertex getTarget() {
46: return ((UnaryConnector) connector).getTarget();
47: }
48:
49: /** Set its target. */
50: public void setTarget(Vertex v) {
51: checkForNull(v, "target");
52: if (graph == v.getGraph()) {
53: throw new IllegalArgumentException(
54: "target of exit must be in different graph");
55: }
56: ((UnaryConnector) connector).setTarget(v);
57: }
58:
59: // OTHER METHODS ////////////////////////////////////////////////
60: public String toString() {
61: return "Exit " + super.toString();
62: }
63: }
|