Source Code Cross Referenced for JGraphLocation.java in  » Testing » abbot-1.0.1 » abbot » tester » extensions » 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 » Testing » abbot 1.0.1 » abbot.tester.extensions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package abbot.tester.extensions;
002:
003:        import java.awt.*;
004:        import java.awt.geom.*;
005:
006:        import org.jgraph.JGraph;
007:
008:        import abbot.Log;
009:        import abbot.tester.*;
010:        import abbot.i18n.Strings;
011:        import abbot.util.ExtendedComparator;
012:
013:        /** Provides encapsulation of the location of vertices and edges in a
014:         {@link JGraph} (a coordinate or item index). 
015:         This class provides an example of a {@link ComponentLocation} extension.
016:         Note that all bounds information must be converted to screen coordinates
017:         with {@link JGraph#toScreen(Point2D)} or
018:         {@link JGraph#toScreen(Rectangle2D)} before use in actions.
019:         */
020:        // TODO: encode cell "values" (view.toString?)
021:        public class JGraphLocation extends ComponentLocation {
022:            private int index = -1;
023:
024:            public JGraphLocation() {
025:            }
026:
027:            public JGraphLocation(int index) {
028:                if (index < 0) {
029:                    String msg = Strings.get("tester.JGraph.invalid_index",
030:                            new Object[] { new Integer(index) });
031:                    throw new LocationUnavailableException(msg);
032:                }
033:                this .index = index;
034:            }
035:
036:            public JGraphLocation(Point where) {
037:                super (where);
038:            }
039:
040:            protected String badFormat(String encoded) {
041:                return Strings.get("location.graph.bad_format",
042:                        new Object[] { encoded });
043:            }
044:
045:            private void checkIndex(JGraph graph, int index) {
046:                if (index < 0 || index >= graph.getRoots().length) {
047:                    String msg = Strings.get("tester.JGraph.invalid_index",
048:                            new Object[] { new Integer(index) });
049:                    throw new LocationUnavailableException(msg);
050:                }
051:            }
052:
053:            /** Return the bounds of the cell in screen coordinates. */
054:            protected Rectangle getCellBounds(JGraph graph, Object o) {
055:                Rectangle2D rect = graph.getCellBounds(o);
056:                if (rect != null) {
057:                    return toScreen(graph, (Rectangle2D) rect.clone());
058:                }
059:                String msg = Strings.get("tester.JGraph.cell_not_found",
060:                        new Object[] { o });
061:                throw new LocationUnavailableException(msg);
062:            }
063:
064:            /** Convert the given object index into a screen coordinate. */
065:            protected Point indexToPoint(JGraph graph, int index) {
066:                checkIndex(graph, index);
067:                Rectangle rect = getCellBounds(graph, graph.getRoots()[index]);
068:
069:                // FIXME this is the center of the bounding box; should use the center
070:                // of the CellView/Renderer instead
071:                return new Point(rect.x + rect.width / 2, rect.y + rect.height
072:                        / 2);
073:            }
074:
075:            /** Return a concrete point for the abstract location. */
076:            public Point getPoint(Component c) {
077:                if (index != -1)
078:                    return indexToPoint((JGraph) c, index);
079:                return super .getPoint(c);
080:            }
081:
082:            /** Return the bounds of this location.  If the location refers to a cell,
083:                returns the cell's bounding box.
084:             */
085:            public Rectangle getBounds(Component c) {
086:                JGraph graph = (JGraph) c;
087:                if (index != -1) {
088:                    checkIndex(graph, index);
089:                    return getCellBounds(graph, graph.getRoots()[index]);
090:                }
091:                return super .getBounds(c);
092:            }
093:
094:            public boolean equals(Object o) {
095:                if (o instanceof  JGraphLocation) {
096:                    JGraphLocation loc = (JGraphLocation) o;
097:                    if (index != -1)
098:                        return index == loc.index;
099:                }
100:                return super .equals(o);
101:            }
102:
103:            public String toString() {
104:                if (index != -1)
105:                    return encodeIndex(index);
106:                return super .toString();
107:            }
108:
109:            public ComponentLocation parse(String encoded) {
110:                encoded = encoded.trim();
111:                if (isIndex(encoded)) {
112:                    index = parseIndex(encoded);
113:                    return this ;
114:                }
115:                return super .parse(encoded);
116:            }
117:
118:            protected Point toScreen(JGraph graph, int x, int y) {
119:                Point2D p = graph.toScreen(new Point(x, y));
120:                return new Point((int) p.getX(), (int) p.getY());
121:            }
122:
123:            protected Rectangle toScreen(JGraph graph, Rectangle2D rect) {
124:                Rectangle2D r = graph.toScreen(rect);
125:                return new Rectangle((int) r.getX(), (int) r.getY(), (int) r
126:                        .getWidth(), (int) r.getHeight());
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.