Source Code Cross Referenced for SimpleNodeEditPart.java in  » Code-Analyzer » soot » ca » mcgill » sable » graph » editparts » 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 » Code Analyzer » soot » ca.mcgill.sable.graph.editparts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Soot - a J*va Optimization Framework
002:         * Copyright (C) 2005 Jennifer Lhotak
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the
016:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017:         * Boston, MA 02111-1307, USA.
018:         */
019:
020:        package ca.mcgill.sable.graph.editparts;
021:
022:        import java.beans.PropertyChangeEvent;
023:        import java.beans.PropertyChangeListener;
024:
025:        import org.eclipse.draw2d.*;
026:        import org.eclipse.gef.*;
027:        import org.eclipse.gef.editparts.*;
028:        import org.eclipse.draw2d.graph.*;
029:        import java.util.*;
030:        import ca.mcgill.sable.graph.model.*;
031:        import ca.mcgill.sable.graph.figures.*;
032:        import org.eclipse.draw2d.geometry.*;
033:        import org.eclipse.swt.graphics.RGB;
034:        import org.eclipse.swt.widgets.Display;
035:        import ca.mcgill.sable.graph.editpolicies.*;
036:        import ca.mcgill.sable.graph.*;
037:
038:        public class SimpleNodeEditPart extends AbstractGraphicalEditPart
039:                implements  NodeEditPart, PropertyChangeListener {
040:
041:            private Object data;
042:
043:            public SimpleNodeEditPart() {
044:                super ();
045:            }
046:
047:            /* (non-Javadoc)
048:             * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
049:             */
050:            protected IFigure createFigure() {
051:                RectangleFigure rect = new RectangleFigure();
052:                ToolbarLayout layout = new ToolbarLayout();
053:                layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
054:                rect.setLayoutManager(layout);
055:
056:                Label label = new Label();
057:                label.getInsets().top = 1;
058:                label.getInsets().bottom = 1;
059:                label.getInsets().right = 1;
060:                label.getInsets().left = 1;
061:                rect.add(label);
062:
063:                return rect;
064:            }
065:
066:            public void contributeNodesToGraph(DirectedGraph graph, HashMap map) {
067:                Node node = new Node(this );
068:                node.width = getFigure().getBounds().width;//getNode().getWidth();
069:                node.height = getFigure().getBounds().height;
070:                graph.nodes.add(node);
071:                map.put(this , node);
072:            }
073:
074:            public void contributeEdgesToGraph(DirectedGraph graph, HashMap map) {
075:                List outgoing = getSourceConnections();
076:                for (int i = 0; i < outgoing.size(); i++) {
077:                    EdgeEditPart edge = (EdgeEditPart) outgoing.get(i);
078:                    edge.contributeToGraph(graph, map);
079:                }
080:            }
081:
082:            public void applyGraphResults(DirectedGraph graph, HashMap map) {
083:                Node node = (Node) map.get(this );
084:                if (node != null) {
085:                    getFigure().setBounds(
086:                            new Rectangle(node.x + 10, node.y, node.width,
087:                                    node.height));//getFigure().getBounds().height));//getFigure().getBounds().height));
088:                    List outgoing = getSourceConnections();
089:                    for (int i = 0; i < outgoing.size(); i++) {
090:                        EdgeEditPart edge = (EdgeEditPart) outgoing.get(i);
091:                        edge.applyGraphResults(graph, map);
092:                    }
093:                }
094:
095:            }
096:
097:            public SimpleNode getNode() {
098:                return (SimpleNode) getModel();
099:            }
100:
101:            /* (non-Javadoc)
102:             * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
103:             */
104:            protected void createEditPolicies() {
105:            }
106:
107:            public List getModelSourceConnections() {
108:                return getNode().getOutputs();
109:            }
110:
111:            public List getModelTargetConnections() {
112:                return getNode().getInputs();
113:            }
114:
115:            /* (non-Javadoc)
116:             * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
117:             */
118:            public ConnectionAnchor getSourceConnectionAnchor(
119:                    ConnectionEditPart arg0) {
120:                return new ChopboxAnchor(getFigure());
121:            }
122:
123:            /* (non-Javadoc)
124:             * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
125:             */
126:            public ConnectionAnchor getTargetConnectionAnchor(
127:                    ConnectionEditPart arg0) {
128:                return new ChopboxAnchor(getFigure());
129:            }
130:
131:            /* (non-Javadoc)
132:             * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
133:             */
134:            public ConnectionAnchor getSourceConnectionAnchor(Request arg0) {
135:                return new ChopboxAnchor(getFigure());
136:            }
137:
138:            /* (non-Javadoc)
139:             * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
140:             */
141:            public ConnectionAnchor getTargetConnectionAnchor(Request arg0) {
142:                return new ChopboxAnchor(getFigure());
143:            }
144:
145:            public void activate() {
146:                super .activate();
147:                getNode().addPropertyChangeListener(this );
148:            }
149:
150:            public void deactivate() {
151:                super .deactivate();
152:                getNode().removePropertyChangeListener(this );
153:            }
154:
155:            public void propertyChange(PropertyChangeEvent event) {
156:                if (event.getPropertyName().equals(Element.DATA)) {
157:                    //System.out.println("new val: "+event.getNewValue());
158:                    setData(event.getNewValue());
159:                    refreshVisuals();
160:                } else if (event.getPropertyName().equals(Element.INPUTS)) {
161:                    refreshTargetConnections();
162:                } else if (event.getPropertyName().equals(Element.OUTPUTS)) {
163:                    refreshSourceConnections();
164:                }
165:
166:            }
167:
168:            public List getModelChildren() {
169:                return getNode().getChildren();
170:            }
171:
172:            protected void refreshVisuals() {
173:                Iterator it = getFigure().getChildren().iterator();
174:                while (it.hasNext()) {
175:                    Object next = it.next();
176:                    if (next instanceof  Label) {
177:                        ((Label) next).setText(getData().toString());
178:                        if (getData() != null) {
179:                            getFigure()
180:                                    .setSize(
181:                                            (getData().toString().length() * 7) + 10,
182:                                            ((((Label) next).getBounds().height / 2) + 10));
183:                            getFigure().revalidate();
184:                            ((GraphEditPart) getParent()).getFigure()
185:                                    .revalidate();
186:                        }
187:                    }
188:                }
189:            }
190:
191:            private boolean expanded;
192:            private boolean topLevel;
193:            private boolean bottomLevel;
194:
195:            public void switchToComplex() {
196:                GraphPlugin.getDefault().getGenerator().expandGraph(getNode());
197:
198:            }
199:
200:            /**
201:             * @return
202:             */
203:            public Object getData() {
204:                return data;
205:            }
206:
207:            /**
208:             * @param string
209:             */
210:            public void setData(Object obj) {
211:                data = obj;
212:            }
213:
214:            /**
215:             * @return
216:             */
217:            public boolean isBottomLevel() {
218:                return bottomLevel;
219:            }
220:
221:            /**
222:             * @return
223:             */
224:            public boolean isExpanded() {
225:                return expanded;
226:            }
227:
228:            /**
229:             * @return
230:             */
231:            public boolean isTopLevel() {
232:                return topLevel;
233:            }
234:
235:            /**
236:             * @param b
237:             */
238:            public void setBottomLevel(boolean b) {
239:                bottomLevel = b;
240:            }
241:
242:            /**
243:             * @param b
244:             */
245:            public void setExpanded(boolean b) {
246:                expanded = b;
247:            }
248:
249:            /**
250:             * @param b
251:             */
252:            public void setTopLevel(boolean b) {
253:                topLevel = b;
254:            }
255:
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.