Source Code Cross Referenced for TransitionDescriptor.java in  » Workflow-Engines » JFolder » org » jfolder » console » base » 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 » JFolder » org.jfolder.console.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFolder, Copyright 2001-2006 Gary Steinmetz
003:         *
004:         * Distributable under LGPL license.
005:         * See terms of license at gnu.org.
006:         */
007:
008:        package org.jfolder.console.base;
009:
010:        //base classes
011:        import java.io.IOException;
012:        import java.util.ArrayList;
013:
014:        //project specific classes
015:        import org.jfolder.common.utils.misc.CommonSeparators;
016:
017:        //other classes
018:
019:        public class TransitionDescriptor {
020:
021:            //private final int Z_INDEX = 0;
022:
023:            //
024:            private final String VERTICAL = ConsolePageParameters.GIF_VERTICAL;
025:            private final String HORIZONTAL = ConsolePageParameters.GIF_HORIZONTAL;
026:            //
027:            private final String LEFT_UP = ConsolePageParameters.GIF_LEFT_UP;
028:            private final String LEFT_DOWN = ConsolePageParameters.GIF_LEFT_DOWN;
029:            private final String RIGHT_UP = ConsolePageParameters.GIF_RIGHT_UP;
030:            private final String RIGHT_DOWN = ConsolePageParameters.GIF_RIGHT_DOWN;
031:            //
032:            private final String LEFT_ARROW = ConsolePageParameters.GIF_LEFT_ARROW;
033:            private final String RIGHT_ARROW = ConsolePageParameters.GIF_RIGHT_ARROW;
034:            private final String UP_ARROW = ConsolePageParameters.GIF_UP_ARROW;
035:            private final String DOWN_ARROW = ConsolePageParameters.GIF_DOWN_ARROW;
036:            //
037:            private final String BLANK = ConsolePageParameters.GIF_BLANK;
038:
039:            private String sourceNode = null;
040:            private String destinationNode = null;
041:
042:            private int sideLength = 0;
043:            private int sideHeight = 0;
044:            private int transitionThickness = 0;
045:
046:            private double sourceDisplacement = 0;
047:            private double destinationDisplacement = 0;
048:
049:            private int branchNumber = 0;
050:            private int transitionNumber = 0;
051:
052:            private int sourceX = 0;
053:            private int sourceY = 0;
054:
055:            private int destinationX = 0;
056:            private int destinationY = 0;
057:
058:            public TransitionDescriptor() {
059:            }
060:
061:            private int getTolerance() {
062:                final int TOLERANCE = 3 * this .transitionThickness;
063:                return TOLERANCE;
064:            }
065:
066:            public void createTable(ConsolePageContext inCpc)
067:                    throws IOException {
068:
069:                //MiscHelper.println("<!--------------------->");
070:
071:                //String nextGraphic = null;
072:
073:                //int indent[] = new int[]{0};
074:
075:                if (isTransitionNotPossible()) {
076:                    //don't render transition
077:                } else if (isNodeMostlyVerticalOfOtherNode()) {
078:
079:                    int sourceAdjustX = this .sourceX
080:                            + ((int) (this .sourceDisplacement * this .sideLength));
081:                    int destinationAdjustX = this .destinationX
082:                            + ((int) (this .destinationDisplacement * this .sideLength));
083:
084:                    //Note '<' used here! lower value equals higher on graph
085:                    boolean sourceOnTop = (this .sourceY < this .destinationY);
086:
087:                    if (Math.abs(sourceAdjustX - destinationAdjustX) < getTolerance()) {
088:
089:                        int left = Math.min(sourceAdjustX, destinationAdjustX);
090:                        int width = Math
091:                                .abs(sourceAdjustX - destinationAdjustX)
092:                                + this .transitionThickness;
093:                        int top = Math.min(this .sourceY, this .destinationY)
094:                                + this .sideHeight;
095:                        int height = Math.abs(this .sourceY - this .destinationY)
096:                                - this .sideHeight;
097:
098:                        String id = this .sourceNode + "-"
099:                                + this .destinationNode;
100:                        ArrayList content = new ArrayList();
101:
102:                        if (height <= width) {
103:                            if (sourceOnTop) {
104:                                content.add(new String[] { height + "",
105:                                        width + "", DOWN_ARROW });
106:                            } else {
107:                                content.add(new String[] { height + "",
108:                                        width + "", UP_ARROW });
109:                            }
110:                        } else {
111:                            if (sourceOnTop) {
112:                                content.add(new String[] {
113:                                        (height - width) + "", width + "",
114:                                        VERTICAL });
115:                                content.add(new String[] { width + "",
116:                                        width + "", DOWN_ARROW });
117:                            } else {
118:                                content.add(new String[] { width + "",
119:                                        width + "", UP_ARROW });
120:                                content.add(new String[] {
121:                                        (height - width) + "", width + "",
122:                                        VERTICAL });
123:                            }
124:                        }
125:
126:                        renderTable(inCpc, id, top, left, height, width,
127:                                content, "isNodeMostlyVerticalOfOtherNode");
128:                    } else if (((sourceAdjustX < destinationAdjustX) && (this .sourceY < this .destinationY))
129:                            || ((sourceAdjustX > destinationAdjustX) && (this .sourceY > this .destinationY))) {
130:
131:                        createUpperLowerZigZagTable(inCpc);
132:                    } else {
133:                        createLowerUpperZigZagTable(inCpc);
134:                    }
135:                } else if (isNodeMostlyHorizontalOfOtherNode()) {
136:
137:                    int sourceAdjustY = this .sourceY
138:                            + ((int) (this .sourceDisplacement * this .sideHeight));
139:                    int destinationAdjustY = this .destinationY
140:                            + ((int) (this .destinationDisplacement * this .sideHeight));
141:
142:                    //Note '<' used here! lower value equals lefter on graph
143:                    boolean sourceOnLeft = (this .sourceX < this .destinationX);
144:
145:                    if (Math.abs(sourceAdjustY - destinationAdjustY) < getTolerance()) {
146:
147:                        int top = Math.min(sourceAdjustY, destinationAdjustY);
148:                        int height = Math.abs(sourceAdjustY
149:                                - destinationAdjustY)
150:                                + this .transitionThickness;
151:                        int left = Math.min(this .sourceX, this .destinationX)
152:                                + this .sideLength;
153:                        int width = Math.abs(this .sourceX - this .destinationX)
154:                                - this .sideLength;
155:
156:                        String id = this .sourceNode + "-"
157:                                + this .destinationNode;
158:                        ArrayList content = new ArrayList();
159:
160:                        if (width <= height) {
161:                            if (sourceOnLeft) {
162:                                content.add(new String[] { height + "",
163:                                        width + "", RIGHT_ARROW });
164:                            } else {
165:                                content.add(new String[] { height + "",
166:                                        width + "", LEFT_ARROW });
167:                            }
168:                        } else {
169:                            if (sourceOnLeft) {
170:                                content
171:                                        .add(new String[] { height + "",
172:                                                (width - height) + "",
173:                                                HORIZONTAL, height + "",
174:                                                height + "", RIGHT_ARROW });
175:                            } else {
176:                                content.add(new String[] { height + "",
177:                                        height + "", LEFT_ARROW, height + "",
178:                                        (width - height) + "", HORIZONTAL });
179:                            }
180:                        }
181:
182:                        renderTable(inCpc, id, top, left, height, width,
183:                                content, "isNodeMostlyHorizontalOfOtherNode");
184:                    } else if (((sourceAdjustY < destinationAdjustY) && (this .sourceX < this .destinationX))
185:                            || ((sourceAdjustY > destinationAdjustY) && (this .sourceX > this .destinationX))) {
186:
187:                        createLeftRightZigZagTable(inCpc);
188:                    } else {
189:                        createRightLeftZigZagTable(inCpc);
190:                    }
191:                } else if (isNodeUpperLeftOfOtherNode()) {
192:                    createLowerLeftOrUpperRightTable(inCpc);
193:                } else {
194:                    createUpperLeftOrLowerRightTable(inCpc);
195:                }
196:
197:                //MiscHelper.println("<!--------------------->");
198:
199:            }
200:
201:            private boolean isNodeMostlyVerticalOfOtherNode() {
202:
203:                int deltaY = Math.abs(this .sourceY - this .destinationY);
204:                deltaY = deltaY - this .sideHeight;
205:
206:                int sourceAdjustX = this .sourceX
207:                        + ((int) (this .sourceDisplacement * this .sideLength));
208:                int destinationAdjustX = this .destinationX
209:                        + ((int) (this .destinationDisplacement * this .sideLength));
210:
211:                int deltaX = Math.abs(sourceAdjustX - destinationAdjustX);
212:
213:                return (deltaY > (2 * deltaX));
214:            }
215:
216:            private boolean isTransitionNotPossible() {
217:
218:                int deltaX = Math.abs(this .sourceX - this .destinationX)
219:                        - this .sideLength;
220:
221:                int deltaY = Math.abs(this .sourceY - this .destinationY)
222:                        - this .sideHeight;
223:
224:                return ((deltaX < getTolerance()) && (deltaY < getTolerance()));
225:            }
226:
227:            private boolean isNodeMostlyHorizontalOfOtherNode() {
228:
229:                int deltaX = Math.abs(this .sourceX - this .destinationX);
230:                deltaX = deltaX - this .sideLength;
231:
232:                int sourceAdjustY = this .sourceY
233:                        + ((int) (this .sourceDisplacement * this .sideHeight));
234:                int destinationAdjustY = this .destinationY
235:                        + ((int) (this .destinationDisplacement * this .sideHeight));
236:
237:                int deltaY = Math.abs(sourceAdjustY - destinationAdjustY);
238:
239:                return (deltaX > (2 * deltaY));
240:            }
241:
242:            private void createUpperLeftOrLowerRightTable(
243:                    ConsolePageContext inCpc) throws IOException {
244:
245:                int leftNodeX = 0;
246:                int leftNodeY = 0;
247:                int leftNodeLengthDisplacement = 0;
248:                int leftNodeHeightDisplacement = 0;
249:                int rightNodeX = 0;
250:                int rightNodeY = 0;
251:                int rightNodeLengthDisplacement = 0;
252:                int rightNodeHeightDisplacement = 0;
253:
254:                //determine which node is the left node, and which is the right node
255:                if (this .sourceX < this .destinationX) {
256:                    //left node
257:                    leftNodeX = this .sourceX;
258:                    leftNodeY = this .sourceY;
259:                    leftNodeLengthDisplacement = ((int) (this .sourceDisplacement * this .sideLength));
260:                    leftNodeHeightDisplacement = ((int) (this .sourceDisplacement * this .sideHeight));
261:
262:                    //right node
263:                    rightNodeX = this .destinationX;
264:                    rightNodeY = this .destinationY;
265:                    rightNodeLengthDisplacement = ((int) (this .destinationDisplacement * this .sideLength));
266:                    rightNodeHeightDisplacement = ((int) (this .destinationDisplacement * this .sideHeight));
267:                } else {
268:                    //left node
269:                    leftNodeX = this .destinationX;
270:                    leftNodeY = this .destinationY;
271:                    leftNodeLengthDisplacement = ((int) (this .destinationDisplacement * this .sideLength));
272:                    leftNodeHeightDisplacement = ((int) (this .destinationDisplacement * this .sideHeight));
273:
274:                    //right node
275:                    rightNodeX = this .sourceX;
276:                    rightNodeY = this .sourceY;
277:                    rightNodeLengthDisplacement = ((int) (this .sourceDisplacement * this .sideLength));
278:                    rightNodeHeightDisplacement = ((int) (this .sourceDisplacement * this .sideHeight));
279:                }
280:
281:                int deltaX = Math.abs(this .sourceX - this .destinationX);
282:                int deltaY = Math.abs(this .sourceY - this .destinationY);
283:
284:                int upperLeftLength = deltaX - leftNodeLengthDisplacement;
285:                int upperLeftHeight = deltaY - rightNodeHeightDisplacement;
286:
287:                int lowerRightLength = deltaX - this .sideLength
288:                        + rightNodeLengthDisplacement;
289:                int lowerRightHeight = deltaY - this .sideHeight
290:                        + leftNodeHeightDisplacement;
291:
292:                boolean useUpperLeftTransition = true;
293:
294:                int tableLeft = 0;
295:                int tableTop = 0;
296:                int tableLength = 0;
297:                int tableHeight = 0;
298:
299:                //see if upper left transition has longest side
300:                //if (((upperLeftLength > lowerRightLength)
301:                //    && (upperLeftLength > lowerRightHeight)) ||
302:                //    ((upperLeftHeight > lowerRightLength)
303:                //    && (upperLeftHeight > lowerRightHeight))) {
304:                if (false) {//TO DO: use above condition
305:                    useUpperLeftTransition = true;
306:                    tableLeft = leftNodeX + leftNodeLengthDisplacement;
307:                    tableTop = rightNodeY + rightNodeHeightDisplacement;
308:                    tableLength = upperLeftLength;
309:                    tableHeight = upperLeftHeight;
310:                } else {
311:                    useUpperLeftTransition = false;
312:                    tableLeft = leftNodeX + this .sideLength;
313:                    tableTop = rightNodeY + this .sideHeight;
314:                    tableLength = lowerRightLength;
315:                    tableHeight = lowerRightHeight;
316:                }
317:
318:                //corrections
319:                tableLength = tableLength + this .transitionThickness;
320:                tableHeight = tableHeight + this .transitionThickness;
321:
322:                String id = this .sourceNode + "-" + this .destinationNode;
323:                ArrayList content = new ArrayList();
324:
325:                String height1 = (tableHeight - this .transitionThickness) + "";
326:                String height2 = this .transitionThickness + "";
327:                String width1 = (tableLength - this .transitionThickness) + "";
328:                String width2 = this .transitionThickness + "";
329:
330:                content.add(new String[] { height1, width1, BLANK, height1,
331:                        width2, VERTICAL });
332:
333:                content.add(new String[] { height2, width1, HORIZONTAL,
334:                        height2, width2, LEFT_UP });
335:
336:                renderTable(inCpc, id, tableTop, tableLeft, tableHeight,
337:                        tableLength, content,
338:                        "createUpperLeftOrLowerRightTable");
339:            }
340:
341:            private void createLowerLeftOrUpperRightTable(
342:                    ConsolePageContext inCpc) throws IOException {
343:
344:                int leftNodeX = 0;
345:                int leftNodeY = 0;
346:                int leftNodeLengthDisplacement = 0;
347:                int leftNodeHeightDisplacement = 0;
348:                int rightNodeX = 0;
349:                int rightNodeY = 0;
350:                int rightNodeLengthDisplacement = 0;
351:                int rightNodeHeightDisplacement = 0;
352:
353:                //determine which node is the left node, and which is the right node
354:                if (this .sourceX < this .destinationX) {
355:                    //left node
356:                    leftNodeX = this .sourceX;
357:                    leftNodeY = this .sourceY;
358:                    leftNodeLengthDisplacement = ((int) (this .sourceDisplacement * this .sideLength));
359:                    leftNodeHeightDisplacement = ((int) (this .sourceDisplacement * this .sideHeight));
360:
361:                    //right node
362:                    rightNodeX = this .destinationX;
363:                    rightNodeY = this .destinationY;
364:                    rightNodeLengthDisplacement = ((int) (this .destinationDisplacement * this .sideLength));
365:                    rightNodeHeightDisplacement = ((int) (this .destinationDisplacement * this .sideHeight));
366:                } else {
367:                    //left node
368:                    leftNodeX = this .destinationX;
369:                    leftNodeY = this .destinationY;
370:                    leftNodeLengthDisplacement = ((int) (this .destinationDisplacement * this .sideLength));
371:                    leftNodeHeightDisplacement = ((int) (this .destinationDisplacement * this .sideHeight));
372:
373:                    //right node
374:                    rightNodeX = this .sourceX;
375:                    rightNodeY = this .sourceY;
376:                    rightNodeLengthDisplacement = ((int) (this .sourceDisplacement * this .sideLength));
377:                    rightNodeHeightDisplacement = ((int) (this .sourceDisplacement * this .sideHeight));
378:                }
379:
380:                int deltaX = Math.abs(this .sourceX - this .destinationX);
381:                int deltaY = Math.abs(this .sourceY - this .destinationY);
382:
383:                int lowerLeftLength = deltaX - leftNodeLengthDisplacement;
384:                int lowerLeftHeight = deltaY - this .sideHeight
385:                        + rightNodeHeightDisplacement;
386:
387:                int upperRightLength = deltaX - this .sideLength
388:                        + rightNodeLengthDisplacement;
389:                int upperRightHeight = deltaY - leftNodeHeightDisplacement;
390:
391:                boolean useLowerLeftTransition = true;
392:
393:                int tableLeft = 0;
394:                int tableTop = 0;
395:                int tableLength = 0;
396:                int tableHeight = 0;
397:
398:                //see if lower left transition has longest side
399:                //if (((lowerLeftLength > upperRightLength)
400:                //    && (lowerLeftLength > upperRightHeight)) ||
401:                //    ((lowerLeftHeight > upperRightLength)
402:                //    && (lowerLeftHeight > upperRightHeight))) {
403:                if (false) {//TO DO: use above condition
404:                    useLowerLeftTransition = true;
405:                    tableLeft = leftNodeX + leftNodeLengthDisplacement;
406:                    tableTop = leftNodeY + this .sideHeight;
407:                    tableLength = lowerLeftLength;
408:                    tableHeight = lowerLeftHeight;
409:                } else {
410:                    useLowerLeftTransition = false;
411:                    tableLeft = leftNodeX + this .sideLength;
412:                    tableTop = leftNodeY + leftNodeHeightDisplacement;
413:                    tableLength = upperRightLength;
414:                    tableHeight = upperRightHeight;
415:                }
416:
417:                //corrections
418:                tableLength = tableLength + this .transitionThickness;
419:                //tableHeight = tableHeight + this.transitionThickness;
420:
421:                String id = this .sourceNode + "-" + this .destinationNode;
422:                ArrayList content = new ArrayList();
423:
424:                String height1 = this .transitionThickness + "";
425:                String height2 = (tableHeight - this .transitionThickness) + "";
426:                String width1 = (tableLength - this .transitionThickness) + "";
427:                String width2 = this .transitionThickness + "";
428:
429:                content.add(new String[] { height1, width1, HORIZONTAL,
430:                        height1, width2, LEFT_DOWN });
431:
432:                content.add(new String[] { height2, width1, BLANK, height2,
433:                        width2, VERTICAL });
434:
435:                renderTable(inCpc, id, tableTop, tableLeft, tableHeight,
436:                        tableLength, content,
437:                        "createLowerLeftOrUpperRightTable");
438:            }
439:
440:            private void createUpperLowerZigZagTable(ConsolePageContext inCpc)
441:                    throws IOException {
442:
443:                int sourceAdjustX = this .sourceX
444:                        + ((int) (this .sourceDisplacement * this .sideLength));
445:                int destinationAdjustX = this .destinationX
446:                        + ((int) (this .destinationDisplacement * this .sideLength));
447:
448:                int left = Math.min(sourceAdjustX, destinationAdjustX);
449:                int width = Math.abs(sourceAdjustX - destinationAdjustX)
450:                        + this .transitionThickness;
451:                int top = Math.min(this .sourceY, this .destinationY)
452:                        + this .sideHeight;
453:                int height = Math.abs(this .sourceY - this .destinationY)
454:                        - this .sideHeight;
455:
456:                int heightMargin = (height - this .transitionThickness) / 2;
457:                int widthMargin = (width - (2 * this .transitionThickness));
458:
459:                String id = this .sourceNode + "-" + this .destinationNode;
460:                ArrayList content = new ArrayList();
461:
462:                String height1 = heightMargin + "";
463:                String height2 = this .transitionThickness + "";
464:                String height3 = heightMargin + "";
465:                String width1 = this .transitionThickness + "";
466:                String width2 = widthMargin + "";
467:                String width3 = this .transitionThickness + "";
468:
469:                //first row
470:                content.add(new String[] { height1, width1, VERTICAL, height1,
471:                        width2, BLANK, height1, width3, BLANK });
472:                //second row
473:                content.add(new String[] { height2, width1, RIGHT_UP, height2,
474:                        width2, HORIZONTAL, height2, width3, LEFT_DOWN });
475:                //third row
476:                content.add(new String[] { height3, width1, BLANK, height3,
477:                        width2, BLANK, height3, width3, VERTICAL });
478:
479:                renderTable(inCpc, id, top, left, height, width, content,
480:                        "createUpperLowerZigZagTable");
481:            }
482:
483:            private void createLowerUpperZigZagTable(ConsolePageContext inCpc)
484:                    throws IOException {
485:
486:                int sourceAdjustX = this .sourceX
487:                        + ((int) (this .sourceDisplacement * this .sideLength));
488:                int destinationAdjustX = this .destinationX
489:                        + ((int) (this .destinationDisplacement * this .sideLength));
490:
491:                int left = Math.min(sourceAdjustX, destinationAdjustX);
492:                int width = Math.abs(sourceAdjustX - destinationAdjustX)
493:                        + this .transitionThickness;
494:                int top = Math.min(this .sourceY, this .destinationY)
495:                        + this .sideHeight;
496:                int height = Math.abs(this .sourceY - this .destinationY)
497:                        - this .sideHeight;
498:
499:                int heightMargin = (height - this .transitionThickness) / 2;
500:                int widthMargin = (width - (2 * this .transitionThickness));
501:
502:                String id = this .sourceNode + "-" + this .destinationNode;
503:                ArrayList content = new ArrayList();
504:
505:                String height1 = heightMargin + "";
506:                String height2 = this .transitionThickness + "";
507:                String height3 = heightMargin + "";
508:                String width1 = this .transitionThickness + "";
509:                String width2 = widthMargin + "";
510:                String width3 = this .transitionThickness + "";
511:
512:                //first row
513:                content.add(new String[] { height1, width1, BLANK, height1,
514:                        width2, BLANK, height1, width3, VERTICAL });
515:                //second row
516:                content
517:                        .add(new String[] { height2, width1, RIGHT_DOWN,
518:                                height2, width2, HORIZONTAL, height2, width3,
519:                                LEFT_UP });
520:                //third row
521:                content.add(new String[] { height3, width1, VERTICAL, height3,
522:                        width2, BLANK, height3, width3, BLANK });
523:
524:                renderTable(inCpc, id, top, left, height, width, content,
525:                        "createUpperLowerZigZagTable");
526:
527:            }
528:
529:            private void createLeftRightZigZagTable(ConsolePageContext inCpc)
530:                    throws IOException {
531:
532:                int sourceAdjustY = this .sourceY
533:                        + ((int) (this .sourceDisplacement * this .sideHeight));
534:                int destinationAdjustY = this .destinationY
535:                        + ((int) (this .destinationDisplacement * this .sideHeight));
536:
537:                int top = Math.min(sourceAdjustY, destinationAdjustY);
538:                int height = Math.abs(sourceAdjustY - destinationAdjustY)
539:                        + this .transitionThickness;
540:                int left = Math.min(this .sourceX, this .destinationX)
541:                        + this .sideLength;
542:                int width = Math.abs(this .sourceX - this .destinationX)
543:                        - this .sideLength;
544:
545:                int widthMargin = (width - this .transitionThickness) / 2;
546:                int heightMargin = (height - (2 * this .transitionThickness));
547:
548:                String id = this .sourceNode + "-" + this .destinationNode;
549:                ArrayList content = new ArrayList();
550:
551:                String height1 = this .transitionThickness + "";
552:                String height2 = heightMargin + "";
553:                String height3 = this .transitionThickness + "";
554:                String width1 = widthMargin + "";
555:                String width2 = this .transitionThickness + "";
556:                String width3 = widthMargin + "";
557:
558:                //first row
559:                content.add(new String[] { height1, width1, HORIZONTAL,
560:                        height1, width2, LEFT_DOWN, height1, width3, BLANK });
561:                //second row
562:                content.add(new String[] { height2, width1, BLANK, height2,
563:                        width2, VERTICAL, height2, width3, BLANK });
564:                //third row
565:                content.add(new String[] { height3, width1, BLANK, height3,
566:                        width2, RIGHT_UP, height3, width3, HORIZONTAL });
567:
568:                renderTable(inCpc, id, top, left, height, width, content,
569:                        "createUpperLowerZigZagTable");
570:            }
571:
572:            private void createRightLeftZigZagTable(ConsolePageContext inCpc)
573:                    throws IOException {
574:
575:                int sourceAdjustY = this .sourceY
576:                        + ((int) (this .sourceDisplacement * this .sideHeight));
577:                int destinationAdjustY = this .destinationY
578:                        + ((int) (this .destinationDisplacement * this .sideHeight));
579:
580:                int top = Math.min(sourceAdjustY, destinationAdjustY);
581:                int height = Math.abs(sourceAdjustY - destinationAdjustY)
582:                        + this .transitionThickness;
583:                int left = Math.min(this .sourceX, this .destinationX)
584:                        + this .sideLength;
585:                int width = Math.abs(this .sourceX - this .destinationX)
586:                        - this .sideLength;
587:
588:                int widthMargin = (width - this .transitionThickness) / 2;
589:                int heightMargin = (height - (2 * this .transitionThickness));
590:
591:                String id = this .sourceNode + "-" + this .destinationNode;
592:                ArrayList content = new ArrayList();
593:
594:                String height1 = this .transitionThickness + "";
595:                String height2 = heightMargin + "";
596:                String height3 = this .transitionThickness + "";
597:                String width1 = widthMargin + "";
598:                String width2 = this .transitionThickness + "";
599:                String width3 = widthMargin + "";
600:
601:                content.add(new String[] { height1, width1, BLANK, height1,
602:                        width2, RIGHT_DOWN, height1, width3, HORIZONTAL });
603:                //second row
604:                content.add(new String[] { height2, width1, BLANK, height2,
605:                        width2, VERTICAL, height2, width3, BLANK });
606:                //third row
607:                content.add(new String[] { height3, width1, HORIZONTAL,
608:                        height3, width2, LEFT_UP, height3, width3, BLANK });
609:
610:                renderTable(inCpc, id, top, left, height, width, content,
611:                        "createUpperLowerZigZagTable");
612:            }
613:
614:            public String getSourceNode() {
615:                return this .sourceNode;
616:            }
617:
618:            public void setSourceNode(String inNodeName) {
619:                this .sourceNode = inNodeName;
620:            }
621:
622:            public String getDestinationNode() {
623:                return this .destinationNode;
624:            }
625:
626:            public void setDestinationNode(String inNodeName) {
627:                this .destinationNode = inNodeName;
628:            }
629:
630:            public void setSideLength(int inSideLength) {
631:                this .sideLength = inSideLength;
632:            }
633:
634:            public void setSideHeight(int inSideHeight) {
635:                this .sideHeight = inSideHeight;
636:            }
637:
638:            public void setTransitionThickness(int inTransitionThickness) {
639:                this .transitionThickness = inTransitionThickness;
640:            }
641:
642:            public void setSourceDisplacement(double inSourceDisplacement) {
643:                this .sourceDisplacement = inSourceDisplacement;
644:            }
645:
646:            public void setDestinationDisplacement(
647:                    double inDestinationDisplacement) {
648:                this .destinationDisplacement = inDestinationDisplacement;
649:            }
650:
651:            public void setBranchNumber(int inBranchNumber) {
652:                this .branchNumber = inBranchNumber;
653:            }
654:
655:            public void setTransitionNumber(int inTransitionNumber) {
656:                this .transitionNumber = inTransitionNumber;
657:            }
658:
659:            public void setSourceX(int inSourceX) {
660:                this .sourceX = inSourceX;
661:            }
662:
663:            public void setSourceY(int inSourceY) {
664:                this .sourceY = inSourceY;
665:            }
666:
667:            public void setDestinationX(int inDestinationX) {
668:                this .destinationX = inDestinationX;
669:            }
670:
671:            public void setDestinationY(int inDestinationY) {
672:                this .destinationY = inDestinationY;
673:            }
674:
675:            private boolean isNodeUpperLeftOfOtherNode() {
676:                boolean nodeUpperLeftOfOtherNode = false;
677:                if ((this .sourceX < this .destinationX)
678:                        && (this .sourceY < this .destinationY)) {
679:                    nodeUpperLeftOfOtherNode = true;
680:                }
681:                if ((this .sourceX > this .destinationX)
682:                        && (this .sourceY > this .destinationY)) {
683:                    nodeUpperLeftOfOtherNode = true;
684:                }
685:                return nodeUpperLeftOfOtherNode;
686:            }
687:
688:            private void renderTable(ConsolePageContext inCpc, String inId,
689:                    int inTop, int inLeft, int inHeight, int inWidth,
690:                    ArrayList inContent, String inComment) throws IOException {
691:
692:                inCpc.simpleAndPrint("<!-- " + inComment + " -->");
693:
694:                inCpc
695:                        .simpleAndPrint("<table onclick=\"this.style.display = 'none'\" id=\""
696:                                + inId
697:                                + "\" style=\"z-index: "
698:                                + CommonSeparators.Z_INDEX__WORKFLOW_TEMPLATE_TRANSITION
699:                                + "; display: 'block'; position: absolute; top: "
700:                                + (inTop + (this .sideHeight / 2))
701:                                + "px; left: "
702:                                + (inLeft + (this .sideLength / 2))
703:                                + "px;\" height=\""
704:                                + inHeight
705:                                + "\" width=\""
706:                                + inWidth
707:                                + "\" cellspacing=\"0\" cellpadding=\"0\">");
708:                inCpc.justIndent();
709:
710:                for (int i = 0; i < inContent.size(); i++) {
711:
712:                    inCpc.simpleAndPrint("<tr style=\"border-width: 0px\">");
713:                    inCpc.justIndent();
714:
715:                    String nextRow[] = (String[]) inContent.get(i);
716:                    int rowIndex = 0;
717:
718:                    while (rowIndex < nextRow.length) {
719:                        String cellHeight = nextRow[rowIndex];
720:                        String cellWidth = nextRow[rowIndex + 1];
721:                        String cellContent = nextRow[rowIndex + 2];
722:                        String cellTitle = "";
723:                        if (!cellContent.equals(BLANK)) {
724:                            cellTitle = "title=\"" + inId + "\" ";
725:                        }
726:                        inCpc
727:                                .simpleAndPrint("<td "
728:                                        + cellTitle
729:                                        + "width=\""
730:                                        + cellWidth
731:                                        + "px\" height=\""
732:                                        + cellHeight
733:                                        + "px\" style=\"border-width: 0px\">"
734:                                        + getGraphic(cellContent, cellHeight,
735:                                                cellWidth) + "</td>");
736:                        rowIndex = rowIndex + 3;
737:                    }
738:
739:                    inCpc.revertAndPrint("</tr>");
740:                }
741:
742:                inCpc.revertAndPrint("</table>");
743:            }
744:
745:            private String getGraphic(String inName, String inHeight,
746:                    String inWidth) {
747:
748:                String outValue = null;
749:
750:                outValue = "<img src=\"" + inName + "\" height=\"" + inHeight
751:                        + "\" width=\"" + inWidth + "\"/>";
752:
753:                return outValue;
754:            }
755:
756:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.