Source Code Cross Referenced for Vertex.java in  » Test-Coverage » Quilt » org » quilt » graph » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » Quilt » org.quilt.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Vertex.java */
002:
003:        package org.quilt.graph;
004:
005:        /** 
006:         * A vertex in a directed graph. 
007:         *
008:         * @author < a href="jddixon@users.sourceforge.net">Jim Dixon</a>
009:         */
010:        public class Vertex {
011:
012:            /** Unique non-negative assigned to the Vertex; -1 means 'unassigned' */
013:            protected int index = -1;
014:            /** The graph this vertex belongs to. */
015:            protected Directed graph = null;
016:            /** Connects this vertex to one or more other vertices. */
017:            protected Connector connector = null;
018:            /** Optional label. */
019:            protected String label_ = null;
020:
021:            /** Creates a vertex without an index and belonging to no graph. */
022:            protected Vertex() {
023:            }
024:
025:            /** 
026:             * Creates a vertex belonging to a graph, assigns an index unique
027:             * within this graph.
028:             * @param g The graph the vertex belongs to.
029:             */
030:            public Vertex(Directed g) {
031:                checkForNull(g, "graph");
032:                graph = g;
033:                index = g.anotherVertex(this );
034:            }
035:
036:            // ACCESSOR METHODS /////////////////////////////////////////////
037:            public Connector getConnector() {
038:                return connector;
039:            }
040:
041:            public void setConnector(Connector c) {
042:                checkForNull(c, "connector");
043:                connector = c;
044:            }
045:
046:            public Edge getEdge() {
047:                if (connector == null) {
048:                    return null;
049:                } else {
050:                    return connector.getEdge();
051:                }
052:            }
053:
054:            public Vertex getTarget() {
055:                if (connector == null) {
056:                    return null;
057:                } else {
058:                    return connector.getTarget();
059:                }
060:            }
061:
062:            /** Get the graph this vertex is in. */
063:            public Directed getGraph() {
064:                return graph;
065:            }
066:
067:            /** @return Vertex index, a non-negative integer. */
068:            public int getIndex() {
069:                return index;
070:            }
071:
072:            /** @return String label or null */
073:            public String getLabel() {
074:                return label_;
075:            }
076:
077:            /** Assign a label to the Vertex. */
078:            public void setLabel(String s) {
079:                label_ = s;
080:            }
081:
082:            // CONNECTOR CONVERTERS //////////////////////////////////////////
083:            /** 
084:             * Convert the existing connector to a BinaryConnector.
085:             * 
086:             * @return The 'other' edge created.
087:             */
088:            public Edge makeBinary() {
089:                Edge otherEdge = new Edge(this , graph.getExit());
090:                connector = new BinaryConnector(connector, otherEdge);
091:                return otherEdge;
092:            }
093:
094:            /**
095:             * Convert the exiting connector to a ComplexConnector, using the 
096:             * existing Edge as seed. 
097:             */
098:            public ComplexConnector makeComplex(int n) {
099:                // rely on range check in constructor;
100:                connector = new ComplexConnector(connector, n);
101:                return (ComplexConnector) connector;
102:            }
103:
104:            /**
105:             * Convert the exiting connector to a MultiConnector, using the 
106:             * existing Edge as seed. 
107:             */
108:            public MultiConnector makeMulti(int n) {
109:                // rely on range check in constructor;
110:                connector = new MultiConnector(connector, n);
111:                return (MultiConnector) connector;
112:            }
113:
114:            // UTILITY FUNCTIONS ////////////////////////////////////////////
115:
116:            /** 
117:             * Is the graph a parent, grandparent of this vertex?
118:             *
119:             * @param g Candidate progenitor.
120:             * @return  True if match is found.
121:             */
122:            public boolean above(final Directed g) {
123:                // DEBUG
124:                System.out.println("above: checking whether graph "
125:                        + g.getIndex() + " is above vertex " + toString()
126:                        + " whose parent is graph "
127:                        + getGraph().getParent().getIndex());
128:                // END
129:                if (g == null || g == graph) {
130:                    return false;
131:                }
132:
133:                // search upward through parent graphs
134:                for (Directed pop = graph.getParent(); pop != null; pop = pop
135:                        .getParent()) {
136:                    // DEBUG
137:                    System.out.println("  checking whether graph "
138:                            + g.getIndex() + " is the same as graph "
139:                            + pop.getIndex());
140:                    // END
141:                    if (pop == g) {
142:                        return true;
143:                    }
144:                }
145:                return false;
146:            }
147:
148:            /** 
149:             * Throw an exception if the argument is null.
150:             *
151:             * @param o    Argument being checked
152:             * @param what What it is - for error message.
153:             */
154:            public static void checkForNull(Object o, String what) {
155:                if (o == null) {
156:                    throw new IllegalArgumentException("null " + what);
157:                }
158:            }
159:
160:            /** 
161:             * @return A String in parent-index:my-index form. 
162:             */
163:            public String toString() {
164:                StringBuffer sb = new StringBuffer().append(graph.getIndex())
165:                        .append(":").append(index);
166:                return sb.toString();
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.