Source Code Cross Referenced for JGraphpadFormatAction.java in  » Graphic-Library » jgraphpad » com » jgraph » pad » action » 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 » Graphic Library » jgraphpad » com.jgraph.pad.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* 
0002:         * $Id: JGraphpadFormatAction.java,v 1.10 2006/03/15 07:30:06 gaudenz Exp $
0003:         * Copyright (c) 2001-2005, Gaudenz Alder
0004:         * 
0005:         * All rights reserved.
0006:         * 
0007:         * See LICENSE file for license details. If you are unable to locate
0008:         * this file please contact info (at) jgraph (dot) com.
0009:         */
0010:        package com.jgraph.pad.action;
0011:
0012:        import java.awt.Color;
0013:        import java.awt.Component;
0014:        import java.awt.Font;
0015:        import java.awt.event.ActionEvent;
0016:        import java.io.File;
0017:        import java.io.FileNotFoundException;
0018:        import java.io.IOException;
0019:        import java.net.MalformedURLException;
0020:        import java.util.ArrayList;
0021:        import java.util.Hashtable;
0022:        import java.util.List;
0023:        import java.util.Map;
0024:
0025:        import javax.swing.JLabel;
0026:        import javax.swing.JTextPane;
0027:        import javax.swing.SwingConstants;
0028:        import javax.swing.text.BadLocationException;
0029:        import javax.swing.text.SimpleAttributeSet;
0030:        import javax.swing.text.StyleConstants;
0031:        import javax.swing.text.StyledDocument;
0032:
0033:        import org.jgraph.JGraph;
0034:        import org.jgraph.graph.CellView;
0035:        import org.jgraph.graph.Edge;
0036:        import org.jgraph.graph.GraphConstants;
0037:        import org.jgraph.graph.GraphModel;
0038:
0039:        import com.jgraph.JGraphEditor;
0040:        import com.jgraph.editor.JGraphEditorAction;
0041:        import com.jgraph.pad.dialog.JGraphpadDialogs;
0042:        import com.jgraph.pad.graph.JGraphpadBusinessObject;
0043:        import com.jgraph.pad.graph.JGraphpadGraphConstants;
0044:        import com.jgraph.pad.graph.JGraphpadRichTextValue;
0045:        import com.jgraph.pad.graph.JGraphpadVertexRenderer;
0046:        import com.jgraph.pad.util.JGraphpadImageIcon;
0047:
0048:        /**
0049:         * Implements all actions of the format menu.
0050:         */
0051:        public class JGraphpadFormatAction extends JGraphEditorAction {
0052:
0053:            /**
0054:             * Shortcut to the shared JGraphpad dialogs.
0055:             */
0056:            private static JGraphpadDialogs dlgs = JGraphpadDialogs
0057:                    .getSharedInstance();
0058:
0059:            /**
0060:             * Defines the underline font style. This font style is only available for
0061:             * rich text values.
0062:             */
0063:            protected static int FONT_UNDERLINE = -1;
0064:
0065:            /**
0066:             * Specifies the name for the <code>toggleCellMoveable</code> action.
0067:             */
0068:            public static final String NAME_TOGGLECELLMOVEABLE = "toggleCellMoveable";
0069:
0070:            /**
0071:             * Specifies the name for the <code>toggleCellMoveable</code> action.
0072:             */
0073:            public static final String NAME_TOGGLEGROUPREPOSITION = "toggleGroupReposition";
0074:
0075:            /**
0076:             * Specifies the name for the <code>switchLockX</code> action.
0077:             */
0078:            public static final String NAME_SWITCHLOCKX = "switchLockX";
0079:
0080:            /**
0081:             * Specifies the name for the <code>switchLockX</code> action.
0082:             */
0083:            public static final String NAME_SWITCHLOCKY = "switchLockY";
0084:
0085:            /**
0086:             * Specifies the name for the <code>resize</code> action.
0087:             */
0088:            public static final String NAME_RESIZE = "resize";
0089:
0090:            /**
0091:             * Specifies the name for the <code>toggleAutoSize</code> action.
0092:             */
0093:            public static final String NAME_TOGGLEAUTOSIZE = "toggleAutoSize";
0094:
0095:            /**
0096:             * Specifies the name for the <code>toggleCellSizeable</code> action.
0097:             */
0098:            public static final String NAME_TOGGLECELLSIZEABLE = "toggleCellSizeable";
0099:
0100:            /**
0101:             * Specifies the name for the <code>toggleConstrained</code> action.
0102:             */
0103:            public static final String NAME_TOGGLECONSTRAINED = "toggleConstrained";
0104:
0105:            /**
0106:             * Specifies the name for the <code>switchLockWidth</code> action.
0107:             */
0108:            public static final String NAME_SWITCHLOCKWIDTH = "switchLockWidth";
0109:
0110:            /**
0111:             * Specifies the name for the <code>switchLockHeight</code> action.
0112:             */
0113:            public static final String NAME_SWITCHLOCKHEIGHT = "switchLockHeight";
0114:
0115:            /**
0116:             * Specifies the name for the <code>switchShapeRectangle</code> action.
0117:             */
0118:            public static final String NAME_SWITCHSHAPERECTANGLE = "switchShapeRectangle";
0119:
0120:            /**
0121:             * Specifies the name for the <code>switchShapeRounded</code> action.
0122:             */
0123:            public static final String NAME_SWITCHSHAPEROUNDED = "switchShapeRounded";
0124:
0125:            /**
0126:             * Specifies the name for the <code>switchShapeCircle</code> action.
0127:             */
0128:            public static final String NAME_SWITCHSHAPECIRCLE = "switchShapeCircle";
0129:
0130:            /**
0131:             * Specifies the name for the <code>switchShapeDiamond</code> action.
0132:             */
0133:            public static final String NAME_SWITCHSHAPEDIAMOND = "switchShapeDiamond";
0134:
0135:            /**
0136:             * Specifies the name for the <code>switchShapeTriangle</code> action.
0137:             */
0138:            public static final String NAME_SWITCHSHAPETRIANGLE = "switchShapeTriangle";
0139:
0140:            /**
0141:             * Specifies the name for the <code>switchShapeCylinder</code> action.
0142:             */
0143:            public static final String NAME_SWITCHSHAPECYLINDER = "switchShapeCylinder";
0144:
0145:            /**
0146:             * Specifies the name for the <code>cellImage</code> action.
0147:             */
0148:            public static final String NAME_CELLIMAGE = "cellImage";
0149:
0150:            /**
0151:             * Specifies the name for the <code>cellImageURL</code> action.
0152:             */
0153:            public static final String NAME_CELLIMAGEURL = "cellImageURL";
0154:
0155:            /**
0156:             * Specifies the name for the <code>clearCellImage</code> action.
0157:             */
0158:            public static final String NAME_CLEARCELLIMAGE = "clearCellImage";
0159:
0160:            /**
0161:             * Specifies the name for the <code>toggleStretchCellImage</code> action.
0162:             */
0163:            public static final String NAME_TOGGLESTRETCHCELLIMAGE = "toggleStretchCellImage";
0164:
0165:            /**
0166:             * Specifies the name for the <code>cellBackgroundColor</code> action.
0167:             */
0168:            public static final String NAME_CELLBACKGROUNDCOLOR = "cellBackgroundColor";
0169:
0170:            /**
0171:             * Specifies the name for the <code>cellGradientColor</code> action.
0172:             */
0173:            public static final String NAME_CELLGRADIENTCOLOR = "cellGradientColor";
0174:
0175:            /**
0176:             * Specifies the name for the <code>toggleCellOpaque</code> action.
0177:             */
0178:            public static final String NAME_TOGGLECELLOPAQUE = "toggleCellOpaque";
0179:
0180:            /**
0181:             * Specifies the name for the <code>toggleGroupOpaque</code> action.
0182:             */
0183:            public static final String NAME_TOGGLEGROUPOPAQUE = "toggleGroupOpaque";
0184:
0185:            /**
0186:             * Specifies the name for the <code>cellInset</code> action.
0187:             */
0188:            public static final String NAME_CELLINSET = "cellInset";
0189:
0190:            /**
0191:             * Specifies the name for the <code>cellBorderColor</code> action.
0192:             */
0193:            public static final String NAME_CELLBORDERCOLOR = "cellBorderColor";
0194:
0195:            /**
0196:             * Specifies the name for the <code>cellBorderWidth</code> action.
0197:             */
0198:            public static final String NAME_CELLBORDERWIDTH = "cellBorderWidth";
0199:
0200:            /**
0201:             * Specifies the name for the <code>clearCellBorder</code> action.
0202:             */
0203:            public static final String NAME_CLEARCELLBORDER = "clearCellBorder";
0204:
0205:            /**
0206:             * Specifies the name for the <code>font</code> action.
0207:             */
0208:            public static final String NAME_FONT = "font";
0209:
0210:            /**
0211:             * Specifies the name for the <code>fontColor</code> action.
0212:             */
0213:            public static final String NAME_FONTCOLOR = "fontColor";
0214:
0215:            /**
0216:             * Specifies the name for the <code>fontSize</code> action.
0217:             */
0218:            public static final String NAME_FONTSIZE = "fontSize";
0219:
0220:            /**
0221:             * Specifies the name for the <code>fontPlain</code> action.
0222:             */
0223:            public static final String NAME_FONTPLAIN = "fontPlain";
0224:
0225:            /**
0226:             * Specifies the name for the <code>fontBold</code> action.
0227:             */
0228:            public static final String NAME_FONTBOLD = "fontBold";
0229:
0230:            /**
0231:             * Specifies the name for the <code>fontItalic</code> action.
0232:             */
0233:            public static final String NAME_FONTITALIC = "fontItalic";
0234:
0235:            /**
0236:             * Specifies the name for the <code>fontUnderline</code> action.
0237:             */
0238:            public static final String NAME_FONTUNDERLINE = "fontUnderline";
0239:
0240:            /**
0241:             * Specifies the name for the <code>toggleCellEditable</code> action.
0242:             */
0243:            public static final String NAME_TOGGLECELLEDITABLE = "toggleCellEditable";
0244:
0245:            /**
0246:             * Specifies the name for the <code>switchLabelTop</code> action.
0247:             */
0248:            public static final String NAME_SWITCHLABELTOP = "switchLabelTop";
0249:
0250:            /**
0251:             * Specifies the name for the <code>switchLabelMiddle</code> action.
0252:             */
0253:            public static final String NAME_SWITCHLABELMIDDLE = "switchLabelMiddle";
0254:
0255:            /**
0256:             * Specifies the name for the <code>switchLabelBottom</code> action.
0257:             */
0258:            public static final String NAME_SWITCHLABELBOTTOM = "switchLabelBottom";
0259:
0260:            /**
0261:             * Specifies the name for the <code>switchLabelLeft</code> action.
0262:             */
0263:            public static final String NAME_SWITCHLABELLEFT = "switchLabelLeft";
0264:
0265:            /**
0266:             * Specifies the name for the <code>switchLabelCenter</code> action.
0267:             */
0268:            public static final String NAME_SWITCHLABELCENTER = "switchLabelCenter";
0269:
0270:            /**
0271:             * Specifies the name for the <code>switchLabelRight</code> action.
0272:             */
0273:            public static final String NAME_SWITCHLABELRIGHT = "switchLabelRight";
0274:
0275:            /**
0276:             * Specifies the name for the <code>switchAlignTop</code> action.
0277:             */
0278:            public static final String NAME_SWITCHALIGNTOP = "switchAlignTop";
0279:
0280:            /**
0281:             * Specifies the name for the <code>switchAlignMiddle</code> action.
0282:             */
0283:            public static final String NAME_SWITCHALIGNMIDDLE = "switchAlignMiddle";
0284:
0285:            /**
0286:             * Specifies the name for the <code>switchAlignBottom</code> action.
0287:             */
0288:            public static final String NAME_SWITCHALIGNBOTTOM = "switchAlignBottom";
0289:
0290:            /**
0291:             * Specifies the name for the <code>switchAlignLeft</code> action.
0292:             */
0293:            public static final String NAME_SWITCHALIGNLEFT = "switchAlignLeft";
0294:
0295:            /**
0296:             * Specifies the name for the <code>switchAlignCenter</code> action.
0297:             */
0298:            public static final String NAME_SWITCHALIGNCENTER = "switchAlignCenter";
0299:
0300:            /**
0301:             * Specifies the name for the <code>switchAlignRight</code> action.
0302:             */
0303:            public static final String NAME_SWITCHALIGNRIGHT = "switchAlignRight";
0304:
0305:            /**
0306:             * Specifies the name for the <code>lineWidth</code> action.
0307:             */
0308:            public static final String NAME_LINEWIDTH = "lineWidth";
0309:
0310:            /**
0311:             * Specifies the name for the <code>lineColor</code> action.
0312:             */
0313:            public static final String NAME_LINECOLOR = "lineColor";
0314:
0315:            /**
0316:             * Specifies the name for the <code>dashPattern</code> action.
0317:             */
0318:            public static final String NAME_DASHPATTERN = "dashPattern";
0319:
0320:            /**
0321:             * Specifies the name for the <code>dashOffset</code> action.
0322:             */
0323:            public static final String NAME_DASHOFFSET = "dashOffset";
0324:
0325:            /**
0326:             * Specifies the name for the <code>switchStyleOrthogonal</code> action.
0327:             */
0328:            public static final String NAME_SWITCHSTYLEORTHOGONAL = "switchStyleOrthogonal";
0329:
0330:            /**
0331:             * Specifies the name for the <code>switchStyleSpline</code> action.
0332:             */
0333:            public static final String NAME_SWITCHSTYLESPLINE = "switchStyleSpline";
0334:
0335:            /**
0336:             * Specifies the name for the <code>switchStyleBezier</code> action.
0337:             */
0338:            public static final String NAME_SWITCHSTYLEBEZIER = "switchStyleBezier";
0339:
0340:            /**
0341:             * Specifies the name for the <code>toggleEdgeBendable</code> action.
0342:             */
0343:            public static final String NAME_TOGGLEEDGEBENDABLE = "toggleEdgeBendable";
0344:
0345:            /**
0346:             * Specifies the name for the <code>toggleLabelAlongEdge</code> action.
0347:             */
0348:            public static final String NAME_TOGGLELABELALONGEDGE = "toggleLabelAlongEdge";
0349:
0350:            /**
0351:             * Specifies the name for the <code>switchRoutingNone</code> action.
0352:             */
0353:            public static final String NAME_SWITCHROUTINGNONE = "switchRoutingNone";
0354:
0355:            /**
0356:             * Specifies the name for the <code>switchRoutingSimple</code> action.
0357:             */
0358:            public static final String NAME_SWITCHROUTINGSIMPLE = "switchRoutingSimple";
0359:
0360:            /**
0361:             * Specifies the name for the <code>switchRoutingParallel</code> action.
0362:             */
0363:            public static final String NAME_SWITCHROUTINGPARALLEL = "switchRoutingParallel";
0364:
0365:            /**
0366:             * Specifies the name for the <code>switchRoutingParallelSpline</code>
0367:             * action.
0368:             */
0369:            public static final String NAME_SWITCHROUTINGPARALLELSPLINE = "switchRoutingParallelSpline";
0370:
0371:            /**
0372:             * Specifies the name for the <code>beginSize</code> action.
0373:             */
0374:            public static final String NAME_BEGINSIZE = "beginSize";
0375:
0376:            /**
0377:             * Specifies the name for the <code>clearBegin</code> action.
0378:             */
0379:            public static final String NAME_CLEARBEGIN = "clearBegin";
0380:
0381:            /**
0382:             * Specifies the name for the <code>endSize</code> action.
0383:             */
0384:            public static final String NAME_ENDSIZE = "endSize";
0385:
0386:            /**
0387:             * Specifies the name for the <code>clearEnd</code> action.
0388:             */
0389:            public static final String NAME_CLEAREND = "clearEnd";
0390:
0391:            /**
0392:             * Specifies the name for the <code>toggleConnectable</code> action.
0393:             */
0394:            public static final String NAME_TOGGLECONNECTABLE = "toggleConnectable";
0395:
0396:            /**
0397:             * Specifies the name for the <code>toggleDisconnectable</code> action.
0398:             */
0399:            public static final String NAME_TOGGLEDISCONNECTABLE = "toggleDisconnectable";
0400:
0401:            /**
0402:             * Holds the last directory for file operations.
0403:             */
0404:            protected File lastDirectory = null;
0405:
0406:            /**
0407:             * Constructs a new format action for the specified name. If the action name
0408:             * starts with <code>toggle</code> or <code>switch</code> then the
0409:             * action is configured to be a toggle action.
0410:             * 
0411:             * @param name
0412:             *            The name of the action to be created.
0413:             */
0414:            public JGraphpadFormatAction(String name) {
0415:                super (name);
0416:                setToggleAction(name.startsWith("toggle")
0417:                        || name.startsWith("switch"));
0418:            }
0419:
0420:            /**
0421:             * Executes the action based on the action name.
0422:             * 
0423:             * @param event
0424:             *            The object that describes the event.
0425:             */
0426:            public void actionPerformed(ActionEvent event) {
0427:                // Fetch the focus owner before showing any dialogs
0428:                // as showing dialogs transfers the focus.
0429:                Component component = getPermanentFocusOwner();
0430:
0431:                try {
0432:
0433:                    // Actions that work on multiple components
0434:                    if (getName().equals(NAME_FONT))
0435:                        doSetFont(component, fontDialog(component,
0436:                                "Choose Font", null), false, 0, 0);
0437:                    else if (getName().equals(NAME_FONTCOLOR))
0438:                        doSetFont(component, dlgs.colorDialog(component,
0439:                                getString("SelectColor"), null), false, 0, 0);
0440:                    else if (getName().equals(NAME_FONTSIZE))
0441:                        doSetFont(component, null, false, 0, dlgs.intDialog(
0442:                                getString("EnterNumber"), 0, false, false));
0443:                    else if (getName().equals(NAME_FONTPLAIN))
0444:                        doSetFont(component, null, true, Font.PLAIN, 0);
0445:                    else if (getName().equals(NAME_FONTBOLD))
0446:                        doSetFont(component, null, false, Font.BOLD, 0);
0447:                    else if (getName().equals(NAME_FONTITALIC))
0448:                        doSetFont(component, null, false, Font.ITALIC, 0);
0449:                    else if (getName().equals(NAME_FONTUNDERLINE))
0450:                        doSetFont(component, null, false, FONT_UNDERLINE, 0);
0451:
0452:                    // Actions that require a focused graph
0453:                    JGraph graph = getPermanentFocusOwnerGraph();
0454:                    if (graph != null) {
0455:                        if (getName().equals(NAME_TOGGLECELLEDITABLE))
0456:                            doToggleAttribute(graph, GraphConstants.EDITABLE,
0457:                                    false);
0458:
0459:                        // Location
0460:                        else if (getName().equals(NAME_TOGGLECELLMOVEABLE))
0461:                            doToggleAttribute(graph, GraphConstants.MOVEABLE,
0462:                                    false);
0463:                        else if (getName().equals(NAME_TOGGLEGROUPREPOSITION))
0464:                            doToggleAttribute(graph,
0465:                                    JGraphpadGraphConstants.GROUPREPOSITION,
0466:                                    false);
0467:                        else if (getName().equals(NAME_SWITCHLOCKX))
0468:                            setAttribute(graph, GraphConstants.MOVEABLEAXIS,
0469:                                    new Integer(GraphConstants.Y_AXIS));
0470:                        else if (getName().equals(NAME_SWITCHLOCKY))
0471:                            setAttribute(graph, GraphConstants.MOVEABLEAXIS,
0472:                                    new Integer(GraphConstants.X_AXIS));
0473:
0474:                        // Size
0475:                        else if (getName().equals(NAME_RESIZE))
0476:                            setAttribute(graph, GraphConstants.RESIZE,
0477:                                    new Boolean(true));
0478:                        else if (getName().equals(NAME_TOGGLEAUTOSIZE))
0479:                            doToggleAttribute(graph, GraphConstants.AUTOSIZE,
0480:                                    true);
0481:                        else if (getName().equals(NAME_TOGGLECELLSIZEABLE))
0482:                            doToggleAttribute(graph, GraphConstants.SIZEABLE,
0483:                                    false);
0484:                        else if (getName().equals(NAME_TOGGLECONSTRAINED))
0485:                            doToggleAttribute(graph,
0486:                                    GraphConstants.CONSTRAINED, true);
0487:                        else if (getName().equals(NAME_SWITCHLOCKWIDTH))
0488:                            setAttribute(graph, GraphConstants.SIZEABLEAXIS,
0489:                                    new Integer(GraphConstants.Y_AXIS));
0490:                        else if (getName().equals(NAME_SWITCHLOCKHEIGHT))
0491:                            setAttribute(graph, GraphConstants.SIZEABLEAXIS,
0492:                                    new Integer(GraphConstants.X_AXIS));
0493:
0494:                        // Shape
0495:                        else if (getName().equals(NAME_SWITCHSHAPERECTANGLE))
0496:                            setAttribute(
0497:                                    graph,
0498:                                    JGraphpadGraphConstants.VERTEXSHAPE,
0499:                                    new Integer(
0500:                                            JGraphpadVertexRenderer.SHAPE_RECTANGLE));
0501:                        else if (getName().equals(NAME_SWITCHSHAPEROUNDED))
0502:                            setAttribute(
0503:                                    graph,
0504:                                    JGraphpadGraphConstants.VERTEXSHAPE,
0505:                                    new Integer(
0506:                                            JGraphpadVertexRenderer.SHAPE_ROUNDED));
0507:                        else if (getName().equals(NAME_SWITCHSHAPECIRCLE))
0508:                            setAttribute(
0509:                                    graph,
0510:                                    JGraphpadGraphConstants.VERTEXSHAPE,
0511:                                    new Integer(
0512:                                            JGraphpadVertexRenderer.SHAPE_CIRCLE));
0513:                        else if (getName().equals(NAME_SWITCHSHAPEDIAMOND))
0514:                            setAttribute(
0515:                                    graph,
0516:                                    JGraphpadGraphConstants.VERTEXSHAPE,
0517:                                    new Integer(
0518:                                            JGraphpadVertexRenderer.SHAPE_DIAMOND));
0519:                        else if (getName().equals(NAME_SWITCHSHAPETRIANGLE))
0520:                            setAttribute(
0521:                                    graph,
0522:                                    JGraphpadGraphConstants.VERTEXSHAPE,
0523:                                    new Integer(
0524:                                            JGraphpadVertexRenderer.SHAPE_TRIANGLE));
0525:                        else if (getName().equals(NAME_SWITCHSHAPECYLINDER))
0526:                            setAttribute(
0527:                                    graph,
0528:                                    JGraphpadGraphConstants.VERTEXSHAPE,
0529:                                    new Integer(
0530:                                            JGraphpadVertexRenderer.SHAPE_CYLINDER));
0531:
0532:                        // Image
0533:                        else if (getName().equals(NAME_CELLIMAGE))
0534:                            doAskImageAttribute(graph, GraphConstants.ICON,
0535:                                    false);
0536:                        else if (getName().equals(NAME_CELLIMAGEURL))
0537:                            doAskImageAttribute(graph, GraphConstants.ICON,
0538:                                    true);
0539:                        else if (getName().equals(NAME_CLEARCELLIMAGE))
0540:                            setAttribute(graph, GraphConstants.ICON, null);
0541:                        else if (getName().equals(NAME_TOGGLESTRETCHCELLIMAGE))
0542:                            doToggleAttribute(graph,
0543:                                    JGraphpadGraphConstants.STRETCHIMAGE, false);
0544:
0545:                        // Background
0546:                        else if (getName().equals(NAME_CELLBACKGROUNDCOLOR))
0547:                            doAskColorAttribute(graph,
0548:                                    GraphConstants.BACKGROUND, true);
0549:                        else if (getName().equals(NAME_CELLGRADIENTCOLOR))
0550:                            doAskColorAttribute(graph,
0551:                                    GraphConstants.GRADIENTCOLOR, true);
0552:                        else if (getName().equals(NAME_TOGGLECELLOPAQUE))
0553:                            doToggleAttribute(graph, GraphConstants.OPAQUE,
0554:                                    false);
0555:                        else if (getName().equals(NAME_TOGGLEGROUPOPAQUE))
0556:                            doToggleAttribute(graph,
0557:                                    GraphConstants.GROUPOPAQUE, false);
0558:
0559:                        // Border
0560:                        else if (getName().equals(NAME_CELLINSET))
0561:                            doAskIntAttribute(graph, GraphConstants.INSET,
0562:                                    GraphConstants.DEFAULTINSET);
0563:                        else if (getName().equals(NAME_CELLBORDERCOLOR))
0564:                            doAskColorAttribute(graph,
0565:                                    GraphConstants.BORDERCOLOR);
0566:                        else if (getName().equals(NAME_CELLBORDERWIDTH)
0567:                                || getName().equals(NAME_LINEWIDTH))
0568:                            doAskFloatAttribute(graph,
0569:                                    GraphConstants.LINEWIDTH, 1);
0570:                        else if (getName().equals(NAME_CLEARCELLBORDER))
0571:                            setAttribute(graph, GraphConstants.BORDERCOLOR,
0572:                                    null);
0573:
0574:                        // Vertical label position
0575:                        else if (getName().equals(NAME_SWITCHLABELTOP))
0576:                            setAttribute(graph,
0577:                                    GraphConstants.VERTICAL_TEXT_POSITION,
0578:                                    new Integer(JLabel.TOP));
0579:                        else if (getName().equals(NAME_SWITCHLABELMIDDLE))
0580:                            setAttribute(graph,
0581:                                    GraphConstants.VERTICAL_TEXT_POSITION,
0582:                                    new Integer(JLabel.CENTER));
0583:                        else if (getName().equals(NAME_SWITCHLABELBOTTOM))
0584:                            setAttribute(graph,
0585:                                    GraphConstants.VERTICAL_TEXT_POSITION,
0586:                                    new Integer(JLabel.BOTTOM));
0587:                        else if (getName().equals(NAME_SWITCHLABELLEFT))
0588:                            setAttribute(graph,
0589:                                    GraphConstants.HORIZONTAL_TEXT_POSITION,
0590:                                    new Integer(JLabel.LEFT));
0591:                        else if (getName().equals(NAME_SWITCHLABELCENTER))
0592:                            setAttribute(graph,
0593:                                    GraphConstants.HORIZONTAL_TEXT_POSITION,
0594:                                    new Integer(JLabel.CENTER));
0595:                        else if (getName().equals(NAME_SWITCHLABELRIGHT))
0596:                            setAttribute(graph,
0597:                                    GraphConstants.HORIZONTAL_TEXT_POSITION,
0598:                                    new Integer(JLabel.RIGHT));
0599:
0600:                        // Alignment
0601:                        else if (getName().equals(NAME_SWITCHALIGNTOP))
0602:                            setAttribute(graph,
0603:                                    GraphConstants.VERTICAL_ALIGNMENT,
0604:                                    new Integer(JLabel.TOP));
0605:                        else if (getName().equals(NAME_SWITCHALIGNMIDDLE))
0606:                            setAttribute(graph,
0607:                                    GraphConstants.VERTICAL_ALIGNMENT,
0608:                                    new Integer(JLabel.CENTER));
0609:                        else if (getName().equals(NAME_SWITCHALIGNBOTTOM))
0610:                            setAttribute(graph,
0611:                                    GraphConstants.VERTICAL_ALIGNMENT,
0612:                                    new Integer(JLabel.BOTTOM));
0613:                        else if (getName().equals(NAME_SWITCHALIGNLEFT))
0614:                            setAttribute(graph,
0615:                                    GraphConstants.HORIZONTAL_ALIGNMENT,
0616:                                    new Integer(JLabel.LEFT));
0617:                        else if (getName().equals(NAME_SWITCHALIGNCENTER))
0618:                            setAttribute(graph,
0619:                                    GraphConstants.HORIZONTAL_ALIGNMENT,
0620:                                    new Integer(JLabel.CENTER));
0621:                        else if (getName().equals(NAME_SWITCHALIGNRIGHT))
0622:                            setAttribute(graph,
0623:                                    GraphConstants.HORIZONTAL_ALIGNMENT,
0624:                                    new Integer(JLabel.RIGHT));
0625:
0626:                        // Linestyle
0627:                        else if (getName().equals(NAME_LINECOLOR))
0628:                            doAskColorAttribute(graph, GraphConstants.LINECOLOR);
0629:                        else if (getName().equals(NAME_DASHPATTERN))
0630:                            doSetDashPattern(graph);
0631:                        else if (getName().equals(NAME_DASHOFFSET))
0632:                            doAskFloatAttribute(graph,
0633:                                    GraphConstants.DASHOFFSET, 0);
0634:                        else if (getName().equals(NAME_SWITCHSTYLEORTHOGONAL))
0635:                            setAttribute(
0636:                                    graph,
0637:                                    GraphConstants.LINESTYLE,
0638:                                    new Integer(GraphConstants.STYLE_ORTHOGONAL));
0639:                        else if (getName().equals(NAME_SWITCHSTYLESPLINE))
0640:                            setAttribute(graph, GraphConstants.LINESTYLE,
0641:                                    new Integer(GraphConstants.STYLE_SPLINE));
0642:                        else if (getName().equals(NAME_SWITCHSTYLEBEZIER))
0643:                            setAttribute(graph, GraphConstants.LINESTYLE,
0644:                                    new Integer(GraphConstants.STYLE_BEZIER));
0645:                        else if (getName().equals(NAME_TOGGLEEDGEBENDABLE))
0646:                            doToggleAttribute(graph, GraphConstants.BENDABLE,
0647:                                    true);
0648:                        else if (getName().equals(NAME_TOGGLELABELALONGEDGE))
0649:                            doToggleAttribute(graph,
0650:                                    GraphConstants.LABELALONGEDGE, true);
0651:                        else if (getName().equals(NAME_SWITCHROUTINGNONE))
0652:                            setRouting(graph, null);
0653:                        else if (getName().equals(NAME_SWITCHROUTINGSIMPLE))
0654:                            setRouting(graph, GraphConstants.ROUTING_SIMPLE);
0655:                        else if (getName().equals(NAME_SWITCHROUTINGPARALLEL))
0656:                            setRouting(graph,
0657:                                    JGraphpadGraphConstants.ROUTING_PARALLEL);
0658:                        else if (getName().equals(
0659:                                NAME_SWITCHROUTINGPARALLELSPLINE))
0660:                            setRouting(
0661:                                    graph,
0662:                                    JGraphpadGraphConstants.ROUTING_PARALLELSPLINE);
0663:                        else if (getName().equals(NAME_BEGINSIZE))
0664:                            doAskIntAttribute(graph, GraphConstants.BEGINSIZE,
0665:                                    GraphConstants.DEFAULTDECORATIONSIZE);
0666:                        else if (getName().equals(NAME_CLEARBEGIN))
0667:                            setAttribute(graph, GraphConstants.LINEBEGIN, null);
0668:                        else if (getName().equals(NAME_ENDSIZE))
0669:                            doAskIntAttribute(graph, GraphConstants.ENDSIZE,
0670:                                    GraphConstants.DEFAULTDECORATIONSIZE);
0671:                        else if (getName().equals(NAME_CLEAREND))
0672:                            setAttribute(graph, GraphConstants.LINEEND, null);
0673:                        else if (getName().equals(NAME_TOGGLECONNECTABLE))
0674:                            doToggleAttribute(graph,
0675:                                    GraphConstants.CONNECTABLE, false);
0676:                        else if (getName().equals(NAME_TOGGLEDISCONNECTABLE))
0677:                            doToggleAttribute(graph,
0678:                                    GraphConstants.DISCONNECTABLE, false);
0679:                    }
0680:                } catch (JGraphpadDialogs.CancelException e) {
0681:                    // ignore
0682:                } catch (Exception e) {
0683:                    dlgs.errorDialog(component, e.getMessage());
0684:                }
0685:            }
0686:
0687:            /**
0688:             * Displays a font dialog using
0689:             * {@link JGraphpadDialogs#fontDialog(Component, String)}. This hook is
0690:             * overridden in the l2f plugin to provide a better dialog.
0691:             * 
0692:             * @param component
0693:             *            The parent component for the dialog to be displayed.
0694:             * @param title
0695:             *            The title of the dialog to be displayed.
0696:             * @param font
0697:             *            The default font to use in the dialog.
0698:             * @return Returns the selected font.
0699:             */
0700:            public Font fontDialog(Component component, String title, Font font) {
0701:                return JGraphpadDialogs.getSharedInstance().fontDialog(
0702:                        component, title);
0703:            }
0704:
0705:            /**
0706:             * Changes the font style on the specified component to <code>style</code>,
0707:             * which may be one of {@link Font#BOLD}, {@link Font#ITALIC} or
0708:             * {@link #FONT_UNDERLINE}. This implementation changes the style of either
0709:             * the selection cells in {@link JGraph} or the selection text in
0710:             * {@link JTextPane}.
0711:             * 
0712:             * @param graph
0713:             *            The graph to change the font in.
0714:             * @param routing
0715:             *            The routing to use.
0716:             */
0717:            protected void setRouting(JGraph graph, Edge.Routing routing) {
0718:                Object[] cells = graph.getSelectionCells();
0719:
0720:                // Uses the font for each cell to derive a nested map
0721:                Map nested = new Hashtable();
0722:                for (int i = 0; i < cells.length; i++) {
0723:                    CellView view = graph.getGraphLayoutCache().getMapping(
0724:                            cells[i], false);
0725:                    if (view != null && graph.getModel().isEdge(view.getCell())) {
0726:                        Map attr = new Hashtable();
0727:                        if (routing == null)
0728:                            GraphConstants.setRemoveAttributes(attr,
0729:                                    new Object[] { GraphConstants.ROUTING });
0730:                        else
0731:                            GraphConstants.setRouting(attr, routing);
0732:                        nested.put(cells[i], attr);
0733:                    }
0734:                }
0735:                graph.getGraphLayoutCache().edit(nested, null, null, null);
0736:            }
0737:
0738:            /**
0739:             * Changes the dash pattern in the selection edges of the specified graph by
0740:             * displaying a dialog to enter a dash sequence of the form
0741:             * <code>[n[,n[,n]*]]</code> where n is a number.
0742:             * 
0743:             * @param graph
0744:             *            The graph to change the dash pattern in.
0745:             */
0746:            protected void doSetDashPattern(JGraph graph) {
0747:                if (!graph.isSelectionEmpty()) {
0748:                    String pattern = dlgs
0749:                            .valueDialog(getString("EnterDashPattern"));
0750:                    if (pattern != null) {
0751:                        String[] tokens = pattern.split(",");
0752:                        float[] f = new float[tokens.length];
0753:                        for (int i = 0; i < tokens.length; i++)
0754:                            f[i] = Float.parseFloat(tokens[i]);
0755:                        if (f != null) {
0756:                            Map map = new Hashtable();
0757:                            GraphConstants.setDashPattern(map, f);
0758:                            graph.getGraphLayoutCache().edit(
0759:                                    graph.getSelectionCells(), map);
0760:                        }
0761:                    }
0762:                }
0763:            }
0764:
0765:            /**
0766:             * Changes the font on the specified component to <code>change</code>,
0767:             * which may be either a {@link Font} or {@link Color} object, changing the
0768:             * respective font property of either the selection cells in {@link JGraph}
0769:             * or the selection text in {@link JTextPane}.
0770:             * 
0771:             * @param component
0772:             *            The component to change the font in.
0773:             * @param change
0774:             *            The value to change the font to.
0775:             * @throws BadLocationException
0776:             */
0777:            protected void doSetFont(Component component, Object change,
0778:                    boolean plain, int style, float size)
0779:                    throws BadLocationException {
0780:                SimpleAttributeSet sas = new SimpleAttributeSet();
0781:                if (change instanceof  Font) {
0782:                    Font font = (Font) change;
0783:                    StyleConstants.setBold(sas, true);
0784:                    StyleConstants.setFontFamily(sas, font.getFamily());
0785:                    StyleConstants.setFontSize(sas, font.getSize());
0786:                    StyleConstants.setBold(sas, font.isBold());
0787:                    StyleConstants.setItalic(sas, font.isItalic());
0788:                } else if (change instanceof  Color) {
0789:                    StyleConstants.setForeground(sas, (Color) change);
0790:                } else {
0791:                    if (style == Font.BOLD)
0792:                        StyleConstants.setBold(sas, true);
0793:                    else if (style == Font.ITALIC)
0794:                        StyleConstants.setItalic(sas, true);
0795:                    else if (style == FONT_UNDERLINE)
0796:                        StyleConstants.setUnderline(sas, true);
0797:                    else if (plain) {
0798:                        StyleConstants.setItalic(sas, false);
0799:                        StyleConstants.setBold(sas, false);
0800:                        StyleConstants.setUnderline(sas, false);
0801:                    }
0802:                    if (size > 0)
0803:                        StyleConstants.setFontSize(sas, (int) size);
0804:                }
0805:
0806:                // Changes the selection text' font in a text pane
0807:                if (component instanceof  JTextPane) {
0808:                    JTextPane textPane = (JTextPane) component;
0809:                    StyledDocument doc = (StyledDocument) textPane
0810:                            .getDocument();
0811:                    int start = textPane.getSelectionStart();
0812:                    int len = textPane.getSelectionEnd() - start;
0813:                    doc.setCharacterAttributes(start, len, sas, false);
0814:                }
0815:
0816:                // Changes the selection cells' font in a graph. Rich text cells
0817:                // are a special case where the value of the user object needs
0818:                // to be changed.
0819:                else if (component instanceof  JGraph) {
0820:                    JGraph graph = (JGraph) component;
0821:                    GraphModel model = graph.getModel();
0822:                    if (!graph.isSelectionEmpty()) {
0823:                        StyledDocument doc = (StyledDocument) JGraphpadRichTextValue
0824:                                .createDefaultDocument("");
0825:                        Hashtable attrs = new Hashtable();
0826:                        if (change instanceof  Font)
0827:                            GraphConstants.setFont(attrs, (Font) change);
0828:                        else if (change instanceof  Color)
0829:                            GraphConstants.setForeground(attrs, (Color) change);
0830:
0831:                        Hashtable trx = new Hashtable();
0832:                        Object[] cells = graph.getSelectionCells();
0833:                        for (int i = 0; i < cells.length; i++) {
0834:                            Object value = model.getValue(cells[i]);
0835:                            if (value instanceof  JGraphpadBusinessObject
0836:                                    && ((JGraphpadBusinessObject) value)
0837:                                            .isRichText()) {
0838:                                JGraphpadBusinessObject obj = (JGraphpadBusinessObject) value;
0839:                                JGraphpadRichTextValue text = (JGraphpadRichTextValue) obj
0840:                                        .getValue();
0841:                                if (text.toString().length() > 0) {
0842:                                    text.insertInto(doc);
0843:                                    doc.setCharacterAttributes(0, doc
0844:                                            .getLength(), sas, false);
0845:                                    // Removes the trailing newline that has
0846:                                    // been added for some strange reason
0847:                                    doc.remove(doc.getLength() - 1, 1);
0848:                                    Map map = new Hashtable();
0849:                                    GraphConstants.setValue(map,
0850:                                            new JGraphpadRichTextValue(doc));
0851:                                    trx.put(cells[i], map);
0852:                                }
0853:                            } else {
0854:                                if (attrs.isEmpty()) {
0855:                                    CellView view = graph.getGraphLayoutCache()
0856:                                            .getMapping(cells[i], false);
0857:                                    if (view != null) {
0858:                                        Font font = GraphConstants.getFont(view
0859:                                                .getAllAttributes());
0860:                                        Map newMap = new Hashtable();
0861:                                        int tmp = (style == Font.PLAIN) ? (plain) ? 0
0862:                                                : font.getStyle()
0863:                                                : font.getStyle() | style;
0864:                                        GraphConstants.setFont(newMap, font
0865:                                                .deriveFont(tmp,
0866:                                                        (size == 0) ? font
0867:                                                                .getSize2D()
0868:                                                                : size));
0869:                                        trx.put(cells[i], newMap);
0870:                                    }
0871:                                } else {
0872:                                    trx.put(cells[i], attrs);
0873:                                }
0874:                            }
0875:                        }
0876:                        graph.getGraphLayoutCache().edit(trx);
0877:                    }
0878:                }
0879:            }
0880:
0881:            /**
0882:             * Changes the horizontal alignment on the specified component to
0883:             * <code>align</code>, which may be one of {@link SwingConstants#LEFT},
0884:             * {@link SwingConstants#CENTER} or {@link SwingConstants#RIGHT}. This
0885:             * implementation changes the horizontal aligment of either the selection
0886:             * cells in {@link JGraph} or the selection text in {@link JTextPane},
0887:             * however, the alignment in textpanes is not persisted due to a bug in
0888:             * Swing (so end users should align cells, not selection rich text).
0889:             * 
0890:             * @param component
0891:             *            The component to change the font in.
0892:             * @param align
0893:             *            The horizontal alignment to use.
0894:             */
0895:            protected void doSetHorizontalAlignment(Component component,
0896:                    int align) {
0897:
0898:                // Changes the selection text' alignment in text panes
0899:                if (component instanceof  JTextPane) {
0900:                    JTextPane textPane = (JTextPane) component;
0901:                    StyledDocument doc = (StyledDocument) textPane
0902:                            .getDocument();
0903:                    SimpleAttributeSet sas = new SimpleAttributeSet();
0904:                    align = (align == JLabel.CENTER) ? StyleConstants.ALIGN_CENTER
0905:                            : (align == JLabel.RIGHT) ? StyleConstants.ALIGN_RIGHT
0906:                                    : StyleConstants.ALIGN_LEFT;
0907:                    StyleConstants.setAlignment(sas, align);
0908:                    int start = textPane.getSelectionStart();
0909:                    int len = textPane.getSelectionEnd() - start;
0910:                    doc.setParagraphAttributes(start, len, sas, true);
0911:                }
0912:
0913:                // Changes the selection cells' alignment in graphs
0914:                else if (component instanceof  JGraph) {
0915:                    setAttribute((JGraph) component,
0916:                            GraphConstants.HORIZONTAL_ALIGNMENT, new Integer(
0917:                                    align));
0918:                }
0919:            }
0920:
0921:            /**
0922:             * Displays a dialog to ask for a number and uses the number to set the
0923:             * attribute under <code>key</code> for the selected cells in
0924:             * <code>graph</code>. The default value is used in the dialog.
0925:             * 
0926:             * @param graph
0927:             *            The graph to perform the operation in.
0928:             * @param key
0929:             *            The key of the attribute to be changed.
0930:             * @param defaultValue
0931:             *            The default value for the number dialog.
0932:             */
0933:            protected void doAskIntAttribute(JGraph graph, String key,
0934:                    int defaultValue) {
0935:                Integer tmp = (Integer) getAttribute(graph, key);
0936:                int value = (tmp != null) ? tmp.intValue() : defaultValue;
0937:                value = dlgs.intDialog(getString("EnterNumber"), value, false,
0938:                        true);
0939:                setAttribute(graph, key, new Integer(value));
0940:            }
0941:
0942:            /**
0943:             * Displays a dialog to ask for a number and uses the number to set the
0944:             * attribute under <code>key</code> for the selected cells in
0945:             * <code>graph</code>. The default value is used in the dialog.
0946:             * 
0947:             * @param graph
0948:             *            The graph to perform the operation in.
0949:             * @param key
0950:             *            The key of the attribute to be changed.
0951:             * @param defaultValue
0952:             *            The default value for the number dialog.
0953:             */
0954:            protected void doAskFloatAttribute(JGraph graph, String key,
0955:                    float defaultValue) {
0956:                Float tmp = (Float) getAttribute(graph, key);
0957:                float value = (tmp != null) ? tmp.intValue() : defaultValue;
0958:                value = dlgs.floatDialog(getString("EnterNumber"), value,
0959:                        false, true);
0960:                setAttribute(graph, key, new Float(value));
0961:            }
0962:
0963:            /**
0964:             * Shortcut method that invokes
0965:             * {@link #doAskColorAttribute(JGraph, String, boolean)} with setOpaque =
0966:             * false.
0967:             * 
0968:             * @param graph
0969:             *            The graph to perform the operation in.
0970:             * @param key
0971:             *            The key of the attribute to be changed.
0972:             */
0973:            protected void doAskColorAttribute(JGraph graph, String key) {
0974:                doAskColorAttribute(graph, key, false);
0975:            }
0976:
0977:            /**
0978:             * Displays a dialog to ask for a color and uses the color to set the
0979:             * attribute under <code>key</code> for the selected cells in
0980:             * <code>graph</code>. If <code>setOpaque</code> is <code>true</code>
0981:             * then the opaque attribute will be set to true.
0982:             * 
0983:             * @param graph
0984:             *            The graph to perform the operation in.
0985:             * @param key
0986:             *            The key of the attribute to be changed.
0987:             * @param setOpaque
0988:             *            Whether to make the affected cells opaque.
0989:             */
0990:            protected void doAskColorAttribute(JGraph graph, String key,
0991:                    boolean setOpaque) {
0992:                Color color = dlgs.colorDialog(graph, getString("SelectColor"),
0993:                        (Color) getAttribute(graph, key));
0994:                if (color != null) {
0995:                    if (setOpaque)
0996:                        setAttributes(graph, new String[] { key,
0997:                                GraphConstants.OPAQUE }, new Object[] { color,
0998:                                new Boolean(true) }, false);
0999:                    else
1000:                        setAttribute(graph, key, color);
1001:                }
1002:            }
1003:
1004:            /**
1005:             * Displays a dialog to ask for a file or URL depending on
1006:             * <code>urlDialog</code> and uses the filename to set the image attribute
1007:             * under <code>key</code> for the selected cells in <code>graph</code>.
1008:             * 
1009:             * @param graph
1010:             *            The graph to perform the operation in.
1011:             * @param key
1012:             *            The key of the attribute to be changed.
1013:             * @param urlDialog
1014:             *            Whether to ask for an URL instead of a filename.
1015:             */
1016:            protected void doAskImageAttribute(JGraph graph, String key,
1017:                    boolean urlDialog) throws MalformedURLException,
1018:                    FileNotFoundException, IOException {
1019:                String filename = (urlDialog) ? dlgs
1020:                        .valueDialog(getString("EnterURL")) : dlgs
1021:                        .imageFileDialog(getPermanentFocusOwnerOrParent(),
1022:                                getString("SelectImage"), true, lastDirectory);
1023:                if (filename != null) {
1024:                    JGraphpadImageIcon icon = (JGraphEditor.isURL(filename)) ? new JGraphpadImageIcon(
1025:                            JGraphEditor.toURL(filename))
1026:                            : new JGraphpadImageIcon(filename);
1027:                    setAttribute(graph, key, icon);
1028:                    if (!JGraphEditor.isURL(filename))
1029:                        lastDirectory = new File(filename).getParentFile();
1030:                }
1031:            }
1032:
1033:            /**
1034:             * Displays a dialog to ask for a file or URL depending on
1035:             * <code>urlDialog</code> and uses the filename to set the image attribute
1036:             * under <code>key</code> for the selected cells in <code>graph</code>.
1037:             * 
1038:             * @param graph
1039:             *            The graph to perform the operation in.
1040:             * @param key
1041:             *            The key of the attribute to be changed.
1042:             * @param defaultValue
1043:             *            The default value to use.
1044:             */
1045:            protected void doToggleAttribute(JGraph graph, String key,
1046:                    boolean defaultValue) {
1047:                setAttribute(graph, key, new Boolean(!getBooleanAttribute(
1048:                        graph, key, !defaultValue)));
1049:            }
1050:
1051:            /**
1052:             * Sets the value of the attribute under <code>key</code> to
1053:             * <code>value</code> for the selection cells in <code>graph</code>.
1054:             * 
1055:             * @param graph
1056:             *            The graph to perform the operation in.
1057:             * @param key
1058:             *            The name of the attribute to set.
1059:             * @param value
1060:             *            The value of the attribute to set.
1061:             */
1062:            protected void setAttribute(JGraph graph, String key, Object value) {
1063:                setAttributes(graph, new String[] { key },
1064:                        new Object[] { value }, false);
1065:            }
1066:
1067:            /**
1068:             * Sets the value of the attributes under <code>keys</code> to
1069:             * <code>values</code> for the selection or all cells in
1070:             * <code>graph</code> depending on <code>all</code>. For each key[i]
1071:             * the corresponding value[i] is assigned. If value[i] is null then this
1072:             * will add a {@link GraphConstants#REMOVEATTRIBUTES} entry to the nested
1073:             * map and remove the corresponding key. Note: Use only one value of null
1074:             * per array of values, as previous {@link GraphConstants#REMOVEATTRIBUTES}
1075:             * will be overwritten by later ones.
1076:             * 
1077:             * @param graph
1078:             *            The graph to perform the operation in.
1079:             * @param keys
1080:             *            The names of the attributes to set.
1081:             * @param values
1082:             *            The values of the attributes to set.
1083:             * @param all
1084:             *            Whether to apply the change to all or only the selection
1085:             *            cells.
1086:             */
1087:            protected void setAttributes(JGraph graph, String[] keys,
1088:                    Object[] values, boolean all) {
1089:                Map change = new Hashtable(keys.length);
1090:                for (int i = 0; i < keys.length; i++) {
1091:                    if (values[i] != null)
1092:                        change.put(keys[i], values[i]);
1093:                    else
1094:                        GraphConstants.setRemoveAttributes(change,
1095:                                new Object[] { keys[i] });
1096:                }
1097:                Object[] cells = (all) ? graph.getDescendants(graph.getRoots())
1098:                        : graph.getSelectionCells();
1099:                graph.getGraphLayoutCache().edit(cells, change);
1100:            }
1101:
1102:            /**
1103:             * Returns the value of the attribute under <code>key</code> for the first
1104:             * selected cell in the specified graph as a boolean or
1105:             * <code>defaultValue</code> if no such attribute can be found.
1106:             * 
1107:             * @param graph
1108:             *            The graph to perform the operation in.
1109:             * @param key
1110:             *            The name of the attribute to look for.
1111:             * @param defaultValue
1112:             *            The default value to use.
1113:             * @return Returns the value of the <code>key</code> attribute.
1114:             */
1115:            public static boolean getBooleanAttribute(JGraph graph, String key,
1116:                    boolean defaultValue) {
1117:                Object value = getAttribute(graph, key);
1118:                if (value instanceof  Boolean)
1119:                    defaultValue = ((Boolean) value).booleanValue();
1120:                return defaultValue;
1121:            }
1122:
1123:            /**
1124:             * Returns the value of the attribute under <code>key</code> for the first
1125:             * selected cell in the specified graph as an int or
1126:             * <code>defaultValue</code> if no such attribute can be found.
1127:             * 
1128:             * @param graph
1129:             *            The graph to perform the operation in.
1130:             * @param key
1131:             *            The name of the attribute to look for.
1132:             * @param defaultValue
1133:             *            The default value to use.
1134:             * @return Returns the value of the <code>key</code> attribute.
1135:             */
1136:            public static int getIntAttribute(JGraph graph, String key,
1137:                    int defaultValue) {
1138:                Object value = getAttribute(graph, key);
1139:                if (value instanceof  Integer)
1140:                    defaultValue = ((Integer) value).intValue();
1141:                return defaultValue;
1142:            }
1143:
1144:            /**
1145:             * Returns the value of the attribute under <code>key</code> for the first
1146:             * selected cell in the specified graph as an Object or null if no such
1147:             * attribute exists.
1148:             * 
1149:             * @param graph
1150:             *            The graph to perform the operation in.
1151:             * @param key
1152:             *            The name of the attribute to look for.
1153:             * @return Returns the value of the <code>key</code> attribute.
1154:             */
1155:            public static Object getAttribute(JGraph graph, String key) {
1156:                Object cell = graph.getSelectionCell();
1157:                Map attributes = graph.getModel().getAttributes(cell);
1158:                return (attributes != null) ? attributes.get(key) : null;
1159:            }
1160:
1161:            /**
1162:             * Bundle of all actions in this class.
1163:             */
1164:            public static class AllActions implements  Bundle {
1165:
1166:                /**
1167:                 * Holds the actions.
1168:                 */
1169:                public JGraphEditorAction actionToggleCellMoveable = new JGraphpadFormatAction(
1170:                        NAME_TOGGLECELLMOVEABLE),
1171:                        actionToggleGroupReposition = new JGraphpadFormatAction(
1172:                                NAME_TOGGLEGROUPREPOSITION),
1173:                        actionSwitchLockX = new JGraphpadFormatAction(
1174:                                NAME_SWITCHLOCKX),
1175:                        actionSwitchLockY = new JGraphpadFormatAction(
1176:                                NAME_SWITCHLOCKY),
1177:                        actionResize = new JGraphpadFormatAction(NAME_RESIZE),
1178:                        actionToggleAutoSize = new JGraphpadFormatAction(
1179:                                NAME_TOGGLEAUTOSIZE),
1180:                        actionToggleCellSizeable = new JGraphpadFormatAction(
1181:                                NAME_TOGGLECELLSIZEABLE),
1182:                        actionToggleConstrained = new JGraphpadFormatAction(
1183:                                NAME_TOGGLECONSTRAINED),
1184:                        actionSwitchLockWidth = new JGraphpadFormatAction(
1185:                                NAME_SWITCHLOCKWIDTH),
1186:                        actionSwitchLockHeight = new JGraphpadFormatAction(
1187:                                NAME_SWITCHLOCKHEIGHT),
1188:                        actionSwitchShapeRectangle = new JGraphpadFormatAction(
1189:                                NAME_SWITCHSHAPERECTANGLE),
1190:                        actionSwitchShapeRounded = new JGraphpadFormatAction(
1191:                                NAME_SWITCHSHAPEROUNDED),
1192:                        actionSwitchShapeCircle = new JGraphpadFormatAction(
1193:                                NAME_SWITCHSHAPECIRCLE),
1194:                        actionSwitchShapeDiamond = new JGraphpadFormatAction(
1195:                                NAME_SWITCHSHAPEDIAMOND),
1196:                        actionSwitchShapeTriangle = new JGraphpadFormatAction(
1197:                                NAME_SWITCHSHAPETRIANGLE),
1198:                        actionSwitchShapeCylinder = new JGraphpadFormatAction(
1199:                                NAME_SWITCHSHAPECYLINDER),
1200:                        actionCellImage = new JGraphpadFormatAction(
1201:                                NAME_CELLIMAGE),
1202:                        actionCellImageURL = new JGraphpadFormatAction(
1203:                                NAME_CELLIMAGEURL),
1204:                        actionClearCellImage = new JGraphpadFormatAction(
1205:                                NAME_CLEARCELLIMAGE),
1206:                        actionToggleStretchCellImage = new JGraphpadFormatAction(
1207:                                NAME_TOGGLESTRETCHCELLIMAGE),
1208:                        actionCellBackgroundColor = new JGraphpadFormatAction(
1209:                                NAME_CELLBACKGROUNDCOLOR),
1210:                        actionCellGradientColor = new JGraphpadFormatAction(
1211:                                NAME_CELLGRADIENTCOLOR),
1212:                        actionToggleCellOpaque = new JGraphpadFormatAction(
1213:                                NAME_TOGGLECELLOPAQUE),
1214:                        actionToggleGroupOpaque = new JGraphpadFormatAction(
1215:                                NAME_TOGGLEGROUPOPAQUE),
1216:                        actionCellInset = new JGraphpadFormatAction(
1217:                                NAME_CELLINSET),
1218:                        actionCellBorderColor = new JGraphpadFormatAction(
1219:                                NAME_CELLBORDERCOLOR),
1220:                        actionCellBorderWidth = new JGraphpadFormatAction(
1221:                                NAME_CELLBORDERWIDTH),
1222:                        actionClearCellBorder = new JGraphpadFormatAction(
1223:                                NAME_CLEARCELLBORDER),
1224:                        actionFont = new JGraphpadFormatAction(NAME_FONT),
1225:                        actionFontColor = new JGraphpadFormatAction(
1226:                                NAME_FONTCOLOR),
1227:                        actionFontSize = new JGraphpadFormatAction(
1228:                                NAME_FONTSIZE),
1229:                        actionFontPlain = new JGraphpadFormatAction(
1230:                                NAME_FONTPLAIN),
1231:                        actionFontBold = new JGraphpadFormatAction(
1232:                                NAME_FONTBOLD),
1233:                        actionFontItalic = new JGraphpadFormatAction(
1234:                                NAME_FONTITALIC),
1235:                        actionFontUnderline = new JGraphpadFormatAction(
1236:                                NAME_FONTUNDERLINE),
1237:                        actionSwitchLabelTop = new JGraphpadFormatAction(
1238:                                NAME_SWITCHLABELTOP),
1239:                        actionSwitchLabelMiddle = new JGraphpadFormatAction(
1240:                                NAME_SWITCHLABELMIDDLE),
1241:                        actionSwitchLabelBottom = new JGraphpadFormatAction(
1242:                                NAME_SWITCHLABELBOTTOM),
1243:                        actionSwitchLabelLeft = new JGraphpadFormatAction(
1244:                                NAME_SWITCHLABELLEFT),
1245:                        actionSwitchLabelCenter = new JGraphpadFormatAction(
1246:                                NAME_SWITCHLABELCENTER),
1247:                        actionSwitchLabelRight = new JGraphpadFormatAction(
1248:                                NAME_SWITCHLABELRIGHT),
1249:                        actionToggleCellEditable = new JGraphpadFormatAction(
1250:                                NAME_TOGGLECELLEDITABLE),
1251:                        actionSwitchAlignTop = new JGraphpadFormatAction(
1252:                                NAME_SWITCHALIGNTOP),
1253:                        actionSwitchAlignMiddle = new JGraphpadFormatAction(
1254:                                NAME_SWITCHALIGNMIDDLE),
1255:                        actionSwitchAlignBottom = new JGraphpadFormatAction(
1256:                                NAME_SWITCHALIGNBOTTOM),
1257:                        actionSwitchAlignLeft = new JGraphpadFormatAction(
1258:                                NAME_SWITCHALIGNLEFT),
1259:                        actionSwitchAlignCenter = new JGraphpadFormatAction(
1260:                                NAME_SWITCHALIGNCENTER),
1261:                        actionSwitchAlignRight = new JGraphpadFormatAction(
1262:                                NAME_SWITCHALIGNRIGHT),
1263:                        actionLineWidth = new JGraphpadFormatAction(
1264:                                NAME_LINEWIDTH),
1265:                        actionLineColor = new JGraphpadFormatAction(
1266:                                NAME_LINECOLOR),
1267:                        actionDashPattern = new JGraphpadFormatAction(
1268:                                NAME_DASHPATTERN),
1269:                        actionDashOffset = new JGraphpadFormatAction(
1270:                                NAME_DASHOFFSET),
1271:                        actionSwitchStyleOrthogonal = new JGraphpadFormatAction(
1272:                                NAME_SWITCHSTYLEORTHOGONAL),
1273:                        actionSwitchStyleSpline = new JGraphpadFormatAction(
1274:                                NAME_SWITCHSTYLESPLINE),
1275:                        actionSwitchStyleBezier = new JGraphpadFormatAction(
1276:                                NAME_SWITCHSTYLEBEZIER),
1277:                        actionToggleEdgeBendable = new JGraphpadFormatAction(
1278:                                NAME_TOGGLEEDGEBENDABLE),
1279:                        actionToggleLabelAlongEdge = new JGraphpadFormatAction(
1280:                                NAME_TOGGLELABELALONGEDGE),
1281:                        actionSwitchRoutingNone = new JGraphpadFormatAction(
1282:                                NAME_SWITCHROUTINGNONE),
1283:                        actionSwitchRoutingSimple = new JGraphpadFormatAction(
1284:                                NAME_SWITCHROUTINGSIMPLE),
1285:                        actionSwitchRoutingParallel = new JGraphpadFormatAction(
1286:                                NAME_SWITCHROUTINGPARALLEL),
1287:                        actionSwitchRoutingParallelSpline = new JGraphpadFormatAction(
1288:                                NAME_SWITCHROUTINGPARALLELSPLINE),
1289:                        actionBeginSize = new JGraphpadFormatAction(
1290:                                NAME_BEGINSIZE),
1291:                        actionClearBegin = new JGraphpadFormatAction(
1292:                                NAME_CLEARBEGIN),
1293:                        actionEndSize = new JGraphpadFormatAction(NAME_ENDSIZE),
1294:                        actionClearEnd = new JGraphpadFormatAction(
1295:                                NAME_CLEAREND),
1296:                        actionToggleConnectable = new JGraphpadFormatAction(
1297:                                NAME_TOGGLECONNECTABLE),
1298:                        actionToggleDisconnectable = new JGraphpadFormatAction(
1299:                                NAME_TOGGLEDISCONNECTABLE);
1300:
1301:                /*
1302:                 * (non-Javadoc)
1303:                 */
1304:                public JGraphEditorAction[] getActions() {
1305:                    return new JGraphEditorAction[] { actionToggleCellMoveable,
1306:                            actionToggleGroupReposition, actionSwitchLockX,
1307:                            actionSwitchLockY, actionResize,
1308:                            actionToggleAutoSize, actionToggleCellSizeable,
1309:                            actionToggleConstrained, actionSwitchLockWidth,
1310:                            actionSwitchLockHeight, actionSwitchShapeRectangle,
1311:                            actionSwitchShapeRounded, actionSwitchShapeCircle,
1312:                            actionSwitchShapeDiamond,
1313:                            actionSwitchShapeCylinder, actionCellImage,
1314:                            actionCellImageURL, actionClearCellImage,
1315:                            actionToggleStretchCellImage,
1316:                            actionCellBackgroundColor, actionCellGradientColor,
1317:                            actionToggleCellOpaque, actionToggleGroupOpaque,
1318:                            actionCellInset, actionCellBorderColor,
1319:                            actionCellBorderWidth, actionClearCellBorder,
1320:                            actionFont, actionFontColor, actionFontSize,
1321:                            actionFontPlain, actionFontBold, actionFontItalic,
1322:                            actionFontUnderline, actionSwitchLabelTop,
1323:                            actionSwitchLabelMiddle, actionSwitchLabelBottom,
1324:                            actionSwitchLabelLeft, actionSwitchLabelCenter,
1325:                            actionSwitchLabelRight, actionToggleCellEditable,
1326:                            actionSwitchAlignTop, actionSwitchAlignMiddle,
1327:                            actionSwitchAlignBottom, actionSwitchAlignLeft,
1328:                            actionSwitchAlignCenter, actionSwitchAlignRight,
1329:                            actionLineWidth, actionLineColor,
1330:                            actionDashPattern, actionDashOffset,
1331:                            actionSwitchStyleOrthogonal,
1332:                            actionSwitchStyleSpline, actionSwitchStyleBezier,
1333:                            actionToggleEdgeBendable,
1334:                            actionToggleLabelAlongEdge,
1335:                            actionSwitchRoutingNone, actionSwitchRoutingSimple,
1336:                            actionSwitchRoutingParallel,
1337:                            actionSwitchRoutingParallelSpline, actionBeginSize,
1338:                            actionClearBegin, actionEndSize, actionClearEnd,
1339:                            actionToggleConnectable, actionToggleDisconnectable };
1340:                }
1341:
1342:                /*
1343:                 * (non-Javadoc)
1344:                 */
1345:                public void update() {
1346:                    JGraph graph = getPermanentFocusOwnerGraph();
1347:                    boolean isCellsSelected = graph != null
1348:                            && !graph.isSelectionEmpty();
1349:
1350:                    // Checks if there are any cells selected. This implements
1351:                    // a poor man's check for attribute compatiblity with the
1352:                    // selected cells, ie. this edge / rich text attributes
1353:                    // if no respective cells are selected.
1354:                    boolean isEdgesSelected = false;
1355:                    if (isCellsSelected && graph != null) {
1356:                        GraphModel model = graph.getModel();
1357:                        Object[] cells = graph.getSelectionCells();
1358:                        for (int i = 0; i < cells.length; i++)
1359:                            isEdgesSelected = isEdgesSelected
1360:                                    || model.isEdge(cells[i]);
1361:                    }
1362:
1363:                    actionToggleCellMoveable.setEnabled(isCellsSelected);
1364:                    actionToggleGroupReposition.setEnabled(isCellsSelected);
1365:                    actionSwitchLockX.setEnabled(isCellsSelected);
1366:                    actionSwitchLockY.setEnabled(isCellsSelected);
1367:                    actionResize.setEnabled(isCellsSelected);
1368:                    actionToggleAutoSize.setEnabled(isCellsSelected);
1369:                    actionToggleCellSizeable.setEnabled(isCellsSelected);
1370:                    actionToggleConstrained.setEnabled(isCellsSelected);
1371:                    actionSwitchLockWidth.setEnabled(isCellsSelected);
1372:                    actionSwitchLockHeight.setEnabled(isCellsSelected);
1373:                    actionSwitchShapeRectangle.setEnabled(isCellsSelected);
1374:                    actionSwitchShapeRounded.setEnabled(isCellsSelected);
1375:                    actionSwitchShapeCircle.setEnabled(isCellsSelected);
1376:                    actionSwitchShapeDiamond.setEnabled(isCellsSelected);
1377:                    actionSwitchShapeCylinder.setEnabled(isCellsSelected);
1378:                    actionCellImage.setEnabled(isCellsSelected);
1379:                    actionCellImageURL.setEnabled(isCellsSelected);
1380:                    actionClearCellImage.setEnabled(isCellsSelected);
1381:                    actionToggleStretchCellImage.setEnabled(isCellsSelected);
1382:                    actionCellBackgroundColor.setEnabled(isCellsSelected);
1383:                    actionCellGradientColor.setEnabled(isCellsSelected);
1384:                    actionToggleCellOpaque.setEnabled(isCellsSelected);
1385:                    actionToggleGroupOpaque.setEnabled(isCellsSelected);
1386:                    actionCellInset.setEnabled(isCellsSelected);
1387:                    actionCellBorderColor.setEnabled(isCellsSelected);
1388:                    actionCellBorderWidth.setEnabled(isCellsSelected);
1389:                    actionClearCellBorder.setEnabled(isCellsSelected);
1390:
1391:                    actionFont.setEnabled(isCellsSelected);
1392:                    actionFontColor.setEnabled(isCellsSelected);
1393:                    actionFontSize.setEnabled(isCellsSelected);
1394:                    actionFontPlain.setEnabled(isCellsSelected);
1395:                    actionFontBold.setEnabled(isCellsSelected);
1396:                    actionFontItalic.setEnabled(isCellsSelected);
1397:                    actionFontUnderline.setEnabled(isCellsSelected);
1398:
1399:                    actionSwitchLabelTop.setEnabled(isCellsSelected);
1400:                    actionSwitchLabelMiddle.setEnabled(isCellsSelected);
1401:                    actionSwitchLabelBottom.setEnabled(isCellsSelected);
1402:                    actionSwitchLabelLeft.setEnabled(isCellsSelected);
1403:                    actionSwitchLabelCenter.setEnabled(isCellsSelected);
1404:                    actionSwitchLabelRight.setEnabled(isCellsSelected);
1405:                    actionToggleCellEditable.setEnabled(isCellsSelected);
1406:                    actionSwitchAlignTop.setEnabled(isCellsSelected);
1407:                    actionSwitchAlignMiddle.setEnabled(isCellsSelected);
1408:                    actionSwitchAlignBottom.setEnabled(isCellsSelected);
1409:                    actionSwitchAlignLeft.setEnabled(isCellsSelected);
1410:                    actionSwitchAlignCenter.setEnabled(isCellsSelected);
1411:                    actionSwitchAlignRight.setEnabled(isCellsSelected);
1412:                    actionToggleConnectable.setEnabled(isCellsSelected);
1413:                    actionToggleDisconnectable.setEnabled(isCellsSelected);
1414:
1415:                    actionLineWidth.setEnabled(isEdgesSelected);
1416:                    actionLineColor.setEnabled(isEdgesSelected);
1417:                    actionDashPattern.setEnabled(isEdgesSelected);
1418:                    actionDashOffset.setEnabled(isEdgesSelected);
1419:                    actionSwitchStyleOrthogonal.setEnabled(isEdgesSelected);
1420:                    actionSwitchStyleSpline.setEnabled(isEdgesSelected);
1421:                    actionSwitchStyleBezier.setEnabled(isEdgesSelected);
1422:                    actionToggleEdgeBendable.setEnabled(isEdgesSelected);
1423:                    actionToggleLabelAlongEdge.setEnabled(isEdgesSelected);
1424:                    actionSwitchRoutingNone.setEnabled(isEdgesSelected);
1425:                    actionSwitchRoutingSimple.setEnabled(isEdgesSelected);
1426:                    actionSwitchRoutingParallel.setEnabled(isEdgesSelected);
1427:                    actionSwitchRoutingParallelSpline
1428:                            .setEnabled(isEdgesSelected);
1429:                    actionBeginSize.setEnabled(isEdgesSelected);
1430:                    actionClearBegin.setEnabled(isEdgesSelected);
1431:                    actionEndSize.setEnabled(isEdgesSelected);
1432:                    actionClearEnd.setEnabled(isEdgesSelected);
1433:
1434:                    // Sets the toggle states of the toggleable actions
1435:                    if (isCellsSelected) {
1436:                        actionToggleCellMoveable
1437:                                .setSelected(getBooleanAttribute(graph,
1438:                                        GraphConstants.MOVEABLE, true));
1439:                        actionToggleGroupReposition
1440:                                .setSelected(getBooleanAttribute(
1441:                                        graph,
1442:                                        JGraphpadGraphConstants.GROUPREPOSITION,
1443:                                        true));
1444:
1445:                        int moveableAxis = getIntAttribute(graph,
1446:                                GraphConstants.MOVEABLEAXIS, 0);
1447:                        actionSwitchLockX
1448:                                .setSelected(moveableAxis == GraphConstants.Y_AXIS);
1449:                        actionSwitchLockY
1450:                                .setSelected(moveableAxis == GraphConstants.X_AXIS);
1451:
1452:                        actionToggleAutoSize.setSelected(getBooleanAttribute(
1453:                                graph, GraphConstants.AUTOSIZE, false));
1454:                        actionToggleCellSizeable
1455:                                .setSelected(getBooleanAttribute(graph,
1456:                                        GraphConstants.SIZEABLE, true));
1457:                        actionToggleConstrained
1458:                                .setSelected(getBooleanAttribute(graph,
1459:                                        GraphConstants.CONSTRAINED, false));
1460:
1461:                        int sizeableAxis = getIntAttribute(graph,
1462:                                GraphConstants.SIZEABLEAXIS, 0);
1463:                        actionSwitchLockWidth
1464:                                .setSelected(sizeableAxis == GraphConstants.Y_AXIS);
1465:                        actionSwitchLockHeight
1466:                                .setSelected(sizeableAxis == GraphConstants.X_AXIS);
1467:
1468:                        int vertexShape = getIntAttribute(graph,
1469:                                JGraphpadGraphConstants.VERTEXSHAPE,
1470:                                JGraphpadVertexRenderer.SHAPE_RECTANGLE);
1471:                        actionSwitchShapeRectangle
1472:                                .setSelected(vertexShape == JGraphpadVertexRenderer.SHAPE_RECTANGLE);
1473:                        actionSwitchShapeRounded
1474:                                .setSelected(vertexShape == JGraphpadVertexRenderer.SHAPE_ROUNDED);
1475:                        actionSwitchShapeCircle
1476:                                .setSelected(vertexShape == JGraphpadVertexRenderer.SHAPE_CIRCLE);
1477:                        actionSwitchShapeDiamond
1478:                                .setSelected(vertexShape == JGraphpadVertexRenderer.SHAPE_DIAMOND);
1479:                        actionSwitchShapeDiamond
1480:                                .setSelected(vertexShape == JGraphpadVertexRenderer.SHAPE_TRIANGLE);
1481:                        actionSwitchShapeDiamond
1482:                                .setSelected(vertexShape == JGraphpadVertexRenderer.SHAPE_CYLINDER);
1483:
1484:                        actionToggleCellOpaque.setSelected(getBooleanAttribute(
1485:                                graph, GraphConstants.OPAQUE, true));
1486:                        actionToggleGroupOpaque
1487:                                .setSelected(getBooleanAttribute(graph,
1488:                                        GraphConstants.GROUPOPAQUE, true));
1489:                        actionToggleStretchCellImage
1490:                                .setSelected(getBooleanAttribute(graph,
1491:                                        JGraphpadGraphConstants.STRETCHIMAGE,
1492:                                        false));
1493:
1494:                        int verticalTextPosition = getIntAttribute(graph,
1495:                                GraphConstants.VERTICAL_TEXT_POSITION,
1496:                                JLabel.CENTER);
1497:                        actionSwitchLabelTop
1498:                                .setSelected(verticalTextPosition == JLabel.TOP);
1499:                        actionSwitchLabelMiddle
1500:                                .setSelected(verticalTextPosition == JLabel.CENTER);
1501:                        actionSwitchLabelBottom
1502:                                .setSelected(verticalTextPosition == JLabel.BOTTOM);
1503:                        actionSwitchLabelLeft
1504:                                .setSelected(verticalTextPosition == JLabel.LEFT);
1505:                        actionSwitchLabelCenter
1506:                                .setSelected(verticalTextPosition == JLabel.CENTER);
1507:                        actionSwitchLabelRight
1508:                                .setSelected(verticalTextPosition == JLabel.RIGHT);
1509:
1510:                        actionToggleCellEditable
1511:                                .setSelected(getBooleanAttribute(graph,
1512:                                        GraphConstants.EDITABLE, true));
1513:
1514:                        int verticalAlignment = getIntAttribute(graph,
1515:                                GraphConstants.VERTICAL_ALIGNMENT,
1516:                                JLabel.CENTER);
1517:                        actionSwitchAlignTop
1518:                                .setSelected(verticalAlignment == JLabel.TOP);
1519:                        actionSwitchAlignMiddle
1520:                                .setSelected(verticalAlignment == JLabel.CENTER);
1521:                        actionSwitchAlignBottom
1522:                                .setSelected(verticalAlignment == JLabel.BOTTOM);
1523:
1524:                        int horizontalAlignment = getIntAttribute(graph,
1525:                                GraphConstants.HORIZONTAL_ALIGNMENT,
1526:                                JLabel.CENTER);
1527:                        actionSwitchAlignLeft
1528:                                .setSelected(horizontalAlignment == JLabel.LEFT);
1529:                        actionSwitchAlignCenter
1530:                                .setSelected(horizontalAlignment == JLabel.CENTER);
1531:                        actionSwitchAlignRight
1532:                                .setSelected(horizontalAlignment == JLabel.RIGHT);
1533:
1534:                        int lineStyle = getIntAttribute(graph,
1535:                                GraphConstants.LINESTYLE,
1536:                                GraphConstants.STYLE_ORTHOGONAL);
1537:                        actionSwitchStyleOrthogonal
1538:                                .setSelected(lineStyle == GraphConstants.STYLE_ORTHOGONAL);
1539:                        actionSwitchStyleSpline
1540:                                .setSelected(lineStyle == GraphConstants.STYLE_SPLINE);
1541:                        actionSwitchStyleBezier
1542:                                .setSelected(lineStyle == GraphConstants.STYLE_BEZIER);
1543:
1544:                        actionToggleEdgeBendable
1545:                                .setSelected(getBooleanAttribute(graph,
1546:                                        GraphConstants.BENDABLE, true));
1547:                        actionToggleConnectable
1548:                                .setSelected(getBooleanAttribute(graph,
1549:                                        GraphConstants.CONNECTABLE, true));
1550:                        actionToggleDisconnectable
1551:                                .setSelected(getBooleanAttribute(graph,
1552:                                        GraphConstants.DISCONNECTABLE, true));
1553:                        actionToggleLabelAlongEdge
1554:                                .setSelected(getBooleanAttribute(graph,
1555:                                        GraphConstants.LABELALONGEDGE, false));
1556:
1557:                    }
1558:                }
1559:
1560:            }
1561:
1562:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.