Source Code Cross Referenced for ComplexConnector.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:        /* ComplexConnector.java */
002:
003:        package org.quilt.graph;
004:
005:        /** 
006:         * A Connector holding a single edge plus a fixed size array of edges.
007:         * This is a combination of the UnaryConnector and MultiConnector.
008:         *
009:         * @author <a href="jddixon@users.sourceforge.net">Jim Dixon</a>
010:         */
011:        public class ComplexConnector extends Connector {
012:
013:            /** The single edge */
014:            private Edge edge;
015:
016:            /** The array of edges. */
017:            private Edge[] edges = null;
018:
019:            /** Source of all edges in this connector. */
020:            private Vertex source = null;
021:
022:            /**
023:             * Constructor for a Connector with a single edge plus a fixed-size 
024:             * array of edges.  The source of the single edge becomes the source
025:             * of the array of edges.  All edges in the array are set to point
026:             * to the graph exit.
027:             *
028:             * @param e     Becomes preferred edge of the connector.
029:             * @param n     Number of edges in the array
030:             * @param graph Graph this appears in.
031:             */
032:            public ComplexConnector(final Edge e, int n
033:            //, final Exit exit
034:            ) {
035:                if (e == null || n < 1
036:                // || exit == null
037:                ) {
038:                    throw new IllegalArgumentException(
039:                            "constructor arguments must be in range and not null");
040:                }
041:                edge = new Edge(e); // the preferred edge 
042:                edges = new Edge[n]; // fixed-size array of edges
043:                source = edge.getSource();
044:                Vertex target = edge.getTarget();
045:                for (int i = 0; i < n; i++) {
046:                    edges[i] = new Edge(source, target);
047:                }
048:            }
049:
050:            public ComplexConnector(Connector conn, int n
051:            //, final Exit exit
052:            ) {
053:                // will throw NPE if conn is null 
054:                this (conn.getEdge(), n
055:                // , exit
056:                );
057:            }
058:
059:            // INTERFACE CONNECTOR //////////////////////////////////////////
060:            /** Get the single edge. */
061:            public Edge getEdge() {
062:                return edge;
063:            }
064:
065:            /** Get the target of the single edge. */
066:            public Vertex getTarget() {
067:                return edge.getTarget();
068:            }
069:
070:            /** Change the target of the single edge. */
071:            public void setTarget(Vertex v) {
072:                checkTarget(v);
073:                edge.setTarget(v);
074:            }
075:
076:            // OTHER METHODS ////////////////////////////////////////////////
077:            private void checkTarget(final Vertex target) {
078:                if (target == null) {
079:                    throw new IllegalArgumentException("target may not be null");
080:                }
081:                if (source.getGraph() != target.getGraph()) {
082:                    throw new IllegalArgumentException(
083:                            "ComplexConnector's target must be in the same graph");
084:                }
085:            }
086:
087:            private void rangeCheck(int n) {
088:                if (n < 0 || n >= edges.length) {
089:                    throw new IllegalArgumentException(
090:                            "ComplexConnector index " + n + " out of range 0.."
091:                                    + (edges.length - 1));
092:                }
093:            }
094:
095:            /** Get the Nth edge from the array. */
096:            public Edge getEdge(int n) {
097:                rangeCheck(n);
098:                return edges[n];
099:            }
100:
101:            /** Get the target of the Nth edge. */
102:            public Vertex getTarget(int n) {
103:                rangeCheck(n);
104:                return edges[n].getTarget();
105:            }
106:
107:            /** Change the target of the Nth edge. */
108:            public void setTarget(Vertex v, int n) {
109:                checkTarget(v);
110:                rangeCheck(n);
111:                edges[n].setTarget(v);
112:            }
113:
114:            /** 
115:             * Returns the number of edges in the connector EXCLUDING the
116:             * preferred edge. This is the same number used in the 
117:             * constructor as the size of the connector.
118:             *
119:             * @return Total number of edges in the multiway part of the connector.
120:             */
121:            public int size() {
122:                return edges.length;
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.