Source Code Cross Referenced for GraphObjectFactory.java in  » Workflow-Engines » JaWE » org » enhydra » jawe » components » 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 » Workflow Engines » JaWE » org.enhydra.jawe.components.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.jawe.components.graph;
002:
003:        import java.awt.Color;
004:        import java.awt.Font;
005:        import java.awt.Point;
006:        import java.awt.Rectangle;
007:        import java.util.List;
008:        import java.util.Map;
009:        import java.util.Properties;
010:
011:        import org.enhydra.jawe.JaWEManager;
012:        import org.enhydra.shark.xpdl.elements.Activity;
013:        import org.enhydra.shark.xpdl.elements.ExtendedAttribute;
014:        import org.enhydra.shark.xpdl.elements.Participant;
015:        import org.enhydra.shark.xpdl.elements.Transition;
016:        import org.jgraph.graph.AttributeMap;
017:        import org.jgraph.graph.GraphConstants;
018:
019:        /**
020:         * Factory for generating graph objects.
021:         * @author Sasa Bojanic
022:         */
023:        public class GraphObjectFactory {
024:
025:            protected Properties properties;
026:
027:            public void configure(Properties props) throws Exception {
028:                this .properties = props;
029:            }
030:
031:            public GraphActivityInterface createActivity(Map viewMap,
032:                    Activity act, Point partPoint) {
033:                String type = JaWEManager.getInstance().getJaWEController()
034:                        .getTypeResolver().getJaWEType(act).getTypeId();
035:                Point offset = GraphUtilities.getOffsetPoint(act);
036:                GraphActivityInterface gact = createActivityCell(act, type);
037:
038:                Map m = initActivityProperties(partPoint, offset, act, type);
039:
040:                viewMap.put(gact, m);
041:                return gact;
042:            }
043:
044:            protected GraphActivityInterface createActivityCell(Activity act,
045:                    String type) {
046:                return new DefaultGraphActivity(act);
047:            }
048:
049:            protected Map initActivityProperties(Point partPoint, Point offset,
050:                    Activity act, String type) {
051:                AttributeMap map = new AttributeMap();
052:                Rectangle bounds = new Rectangle(partPoint.x + offset.x,
053:                        partPoint.y + offset.y, GraphUtilities
054:                                .getGraphController().getGraphSettings()
055:                                .getActivityWidth(), GraphUtilities
056:                                .getGraphController().getGraphSettings()
057:                                .getActivityHeight());
058:                GraphConstants.setBounds(map, bounds);
059:                GraphConstants.setOpaque(map, true);
060:                GraphConstants.setBorderColor(map, Color.darkGray);
061:                String fntn = JaWEManager.getFontName();
062:                int fntsize = GraphUtilities.getGraphController()
063:                        .getGraphSettings().getGraphFontSize();
064:                javax.swing.plaf.FontUIResource f;
065:                try {
066:                    try {
067:                        f = new javax.swing.plaf.FontUIResource(fntn,
068:                                Font.PLAIN, fntsize);
069:                    } catch (Exception ex) {
070:                        f = new javax.swing.plaf.FontUIResource("Label.font",
071:                                Font.PLAIN, fntsize);
072:                    }
073:                    GraphConstants.setFont(map, f);
074:                } catch (Exception ex) {
075:                }
076:                return map;
077:            }
078:
079:            public GraphBubbleActivityInterface createStart(Map viewMap,
080:                    ExtendedAttribute sea, Point partPoint) {
081:                GraphBubbleActivityInterface gact = createStartCell(sea);
082:
083:                Map m = initStartProperties(partPoint, sea);
084:
085:                viewMap.put(gact, m);
086:                return gact;
087:            }
088:
089:            protected GraphBubbleActivityInterface createStartCell(
090:                    ExtendedAttribute sea) {
091:                return new DefaultGraphBubbleActivity(sea);
092:            }
093:
094:            protected Map initStartProperties(Point partPoint,
095:                    ExtendedAttribute sea) {
096:                AttributeMap map = new AttributeMap();
097:                StartEndDescription sed = new StartEndDescription(sea);
098:                Rectangle bounds = new Rectangle(partPoint.x
099:                        + sed.getOffset().x, partPoint.y + sed.getOffset().y,
100:                        GraphUtilities.getGraphController().getGraphSettings()
101:                                .getActivityHeight() / 5 * 3, GraphUtilities
102:                                .getGraphController().getGraphSettings()
103:                                .getActivityHeight() / 5 * 3);
104:                GraphConstants.setBounds(map, bounds);
105:                GraphConstants.setOpaque(map, true);
106:                GraphConstants.setBorderColor(map, Color.darkGray);
107:                String fntn = JaWEManager.getFontName();
108:                int fntsize = GraphUtilities.getGraphController()
109:                        .getGraphSettings().getGraphFontSize();
110:                javax.swing.plaf.FontUIResource f;
111:                try {
112:                    try {
113:                        f = new javax.swing.plaf.FontUIResource(fntn,
114:                                Font.PLAIN, fntsize);
115:                    } catch (Exception ex) {
116:                        f = new javax.swing.plaf.FontUIResource("Label.font",
117:                                Font.PLAIN, fntsize);
118:                    }
119:                    GraphConstants.setFont(map, f);
120:                } catch (Exception ex) {
121:                }
122:                return map;
123:            }
124:
125:            public GraphBubbleActivityInterface createEnd(Map viewMap,
126:                    ExtendedAttribute eea, Point partPoint) {
127:                GraphBubbleActivityInterface gact = createEndCell(eea);
128:
129:                Map m = initEndProperties(partPoint, eea);
130:
131:                viewMap.put(gact, m);
132:                return gact;
133:            }
134:
135:            protected GraphBubbleActivityInterface createEndCell(
136:                    ExtendedAttribute eea) {
137:                return new DefaultGraphBubbleActivity(eea);
138:            }
139:
140:            protected Map initEndProperties(Point partPoint,
141:                    ExtendedAttribute eea) {
142:                AttributeMap map = new AttributeMap();
143:                StartEndDescription sed = new StartEndDescription(eea);
144:                Rectangle bounds = new Rectangle(partPoint.x
145:                        + sed.getOffset().x, partPoint.y + sed.getOffset().y,
146:                        GraphUtilities.getGraphController().getGraphSettings()
147:                                .getActivityHeight() / 5 * 3, GraphUtilities
148:                                .getGraphController().getGraphSettings()
149:                                .getActivityHeight() / 5 * 3);
150:                GraphConstants.setBounds(map, bounds);
151:                GraphConstants.setOpaque(map, true);
152:                GraphConstants.setBorderColor(map, Color.darkGray);
153:                String fntn = JaWEManager.getFontName();
154:                int fntsize = GraphUtilities.getGraphController()
155:                        .getGraphSettings().getGraphFontSize();
156:                javax.swing.plaf.FontUIResource f;
157:                try {
158:                    try {
159:                        f = new javax.swing.plaf.FontUIResource(fntn,
160:                                Font.PLAIN, fntsize);
161:                    } catch (Exception ex) {
162:                        f = new javax.swing.plaf.FontUIResource("Label.font",
163:                                Font.PLAIN, fntsize);
164:                    }
165:                    GraphConstants.setFont(map, f);
166:                } catch (Exception ex) {
167:                }
168:                return map;
169:            }
170:
171:            public GraphParticipantInterface createParticipant(
172:                    Rectangle bounds, Map viewMap, Participant par) {
173:                GraphParticipantInterface gpar = createParticipantCell(par);
174:
175:                Map m = initParticipantProperties(bounds, par);
176:
177:                viewMap.put(gpar, m);
178:                return gpar;
179:            }
180:
181:            protected GraphParticipantInterface createParticipantCell(
182:                    Participant par) {
183:                return new DefaultGraphParticipant(par);
184:            }
185:
186:            protected Map initParticipantProperties(Rectangle bounds,
187:                    Participant par) {
188:                AttributeMap map = new AttributeMap();
189:                GraphConstants.setBounds(map, bounds);
190:                GraphConstants.setOpaque(map, false);
191:                GraphConstants.setBorderColor(map, Color.black);
192:                GraphConstants.setMoveable(map, false);
193:                String fntn = JaWEManager.getFontName();
194:                int fntsize = GraphUtilities.getGraphController()
195:                        .getGraphSettings().getGraphFontSize();
196:                javax.swing.plaf.FontUIResource f;
197:                try {
198:                    try {
199:                        f = new javax.swing.plaf.FontUIResource(fntn,
200:                                Font.PLAIN, fntsize);
201:                    } catch (Exception ex) {
202:                        f = new javax.swing.plaf.FontUIResource("Label.font",
203:                                Font.PLAIN, fntsize);
204:                    }
205:                    GraphConstants.setFont(map, f);
206:                } catch (Exception ex) {
207:                }
208:                return map;
209:            }
210:
211:            public GraphTransitionInterface createTransition(List points,
212:                    Map viewMap, Transition tra) {
213:                GraphTransitionInterface gtra = createTransitionCell(tra);
214:
215:                Map m = initTransitionProperties(points, tra);
216:
217:                viewMap.put(gtra, m);
218:
219:                return gtra;
220:            }
221:
222:            public GraphTransitionInterface createBubbleTransition(List points,
223:                    Map viewMap, String style) {
224:                GraphTransitionInterface gtra = createTransitionCell(null);
225:
226:                Map m = initBubbleTransitionProperties(points, style);
227:
228:                viewMap.put(gtra, m);
229:
230:                return gtra;
231:            }
232:
233:            protected GraphTransitionInterface createTransitionCell(
234:                    Transition tra) {
235:                return new DefaultGraphTransition(tra);
236:            }
237:
238:            protected Map initTransitionProperties(List points, Transition tra) {
239:                AttributeMap map = new AttributeMap();
240:                //if (points!=null && points.size()>0) System.out.println("Setting points "+points);
241:                GraphConstants.setPoints(map, points);
242:                setTransitionStyle(GraphUtilities.getStyle(tra), map);
243:
244:                //GraphConstants.setLineColor(map,Utils.getColor(JaWEConfig.getInstance().getTransitionColor()));
245:                GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
246:                GraphConstants.setEndFill(map, true);
247:                GraphConstants.setEndSize(map, 10);
248:                String fntn = JaWEManager.getFontName();
249:                int fntsize = GraphUtilities.getGraphController()
250:                        .getGraphSettings().getGraphFontSize();
251:                javax.swing.plaf.FontUIResource f;
252:                try {
253:                    try {
254:                        f = new javax.swing.plaf.FontUIResource(fntn,
255:                                Font.PLAIN, fntsize);
256:                    } catch (Exception ex) {
257:                        f = new javax.swing.plaf.FontUIResource("Label.font",
258:                                Font.PLAIN, fntsize);
259:                    }
260:                    GraphConstants.setFont(map, f);
261:                } catch (Exception ex) {
262:                }
263:
264:                return map;
265:            }
266:
267:            protected Map initBubbleTransitionProperties(List points,
268:                    String style) {
269:                AttributeMap map = new AttributeMap();
270:                //if (points!=null && points.size()>0) System.out.println("Setting points "+points);
271:                GraphConstants.setPoints(map, points);
272:                setTransitionStyle(style, map);
273:                //GraphConstants.setLineColor(map,Utils.getColor(JaWEConfig.getInstance().getTransitionColor()));
274:                GraphConstants.setLineEnd(map, GraphConstants.ARROW_TECHNICAL);
275:                GraphConstants.setEndFill(map, true);
276:                GraphConstants.setEndSize(map, 10);
277:                String fntn = JaWEManager.getFontName();
278:                int fntsize = GraphUtilities.getGraphController()
279:                        .getGraphSettings().getGraphFontSize();
280:                javax.swing.plaf.FontUIResource f;
281:                try {
282:                    try {
283:                        f = new javax.swing.plaf.FontUIResource(fntn,
284:                                Font.PLAIN, fntsize);
285:                    } catch (Exception ex) {
286:                        f = new javax.swing.plaf.FontUIResource("Label.font",
287:                                Font.PLAIN, fntsize);
288:                    }
289:                    GraphConstants.setFont(map, f);
290:                } catch (Exception ex) {
291:                }
292:
293:                return map;
294:            }
295:
296:            protected void setTransitionStyle(String style, AttributeMap map) {
297:                if (style
298:                        .equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_BEZIER)) {
299:                    GraphConstants.setLineStyle(map,
300:                            GraphConstants.STYLE_BEZIER);
301:                } else if (style
302:                        .equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_NO_ROUTING_SPLINE)) {
303:                    GraphConstants.setLineStyle(map,
304:                            GraphConstants.STYLE_SPLINE);
305:                } else if (style
306:                        .equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_SIMPLE_ROUTING_BEZIER)) {
307:                    GraphConstants.setRouting(map,
308:                            GraphConstants.ROUTING_SIMPLE);
309:                    GraphConstants.setLineStyle(map,
310:                            GraphConstants.STYLE_BEZIER);
311:                } else if (style
312:                        .equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_SIMPLE_ROUTING_ORTHOGONAL)) {
313:                    GraphConstants.setRouting(map,
314:                            GraphConstants.ROUTING_SIMPLE);
315:                    GraphConstants.setLineStyle(map,
316:                            GraphConstants.STYLE_ORTHOGONAL);
317:                } else if (style
318:                        .equals(GraphEAConstants.EA_JAWE_GRAPH_TRANSITION_STYLE_VALUE_SIMPLE_ROUTING_SPLINE)) {
319:                    GraphConstants.setRouting(map,
320:                            GraphConstants.ROUTING_SIMPLE);
321:                    GraphConstants.setLineStyle(map,
322:                            GraphConstants.STYLE_SPLINE);
323:                } else {
324:                    GraphConstants.setLineStyle(map,
325:                            GraphConstants.STYLE_ORTHOGONAL);
326:                }
327:            }
328:
329:            public GraphPortInterface createPort(String name, String type) {
330:                GraphPortInterface gpor = createPortCell(name, type);
331:                return gpor;
332:            }
333:
334:            protected GraphPortInterface createPortCell(String name, String type) {
335:                return new DefaultGraphPort(name, type);
336:            }
337:
338:            protected Map initPortProperties(String type) {
339:                AttributeMap map = new AttributeMap();
340:                return map;
341:            }
342:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.