Source Code Cross Referenced for ADGraphWindow.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » ui » swing » drawingarea » 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 » IDE Netbeans » uml » org.netbeans.modules.uml.ui.swing.drawingarea 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s):
0025:         *
0026:         * The Original Software is NetBeans. The Initial Developer of the Original
0027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028:         * Microsystems, Inc. All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         */
0041:
0042:        package org.netbeans.modules.uml.ui.swing.drawingarea;
0043:
0044:        import org.netbeans.modules.uml.ui.products.ad.viewfactory.IETGraphObjectUI;
0045:        import java.awt.Color;
0046:        import java.awt.Cursor;
0047:        import java.awt.Dimension;
0048:        import java.awt.Graphics;
0049:        import java.awt.Font;
0050:        import java.awt.Rectangle;
0051:        import java.awt.event.ActionEvent;
0052:        import java.awt.event.ActionListener;
0053:        import java.awt.event.ComponentAdapter;
0054:        import java.awt.event.ComponentEvent;
0055:        import java.awt.event.MouseEvent;
0056:        import java.util.ArrayList;
0057:        import java.util.Iterator;
0058:        import java.util.List;
0059:        import java.util.Locale;
0060:        import java.util.WeakHashMap;
0061:
0062:        import javax.accessibility.Accessible;
0063:        import javax.accessibility.AccessibleAction;
0064:        import javax.accessibility.AccessibleContext;
0065:        import javax.accessibility.AccessibleComponent;
0066:        import javax.accessibility.AccessibleSelection;
0067:        import javax.accessibility.AccessibleRole;
0068:        import javax.accessibility.AccessibleState;
0069:        import javax.accessibility.AccessibleStateSet;
0070:
0071:        import org.netbeans.modules.uml.common.ETSystem;
0072:        import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
0073:        import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagram;
0074:        import org.netbeans.modules.uml.core.metamodel.diagrams.IGraphEventKind;
0075:        import org.netbeans.modules.uml.core.support.umlutils.ETArrayList;
0076:        import org.netbeans.modules.uml.core.support.umlutils.ETList;
0077:        import org.netbeans.modules.uml.ui.products.ad.drawengines.ETClassDrawEngine;
0078:        import org.netbeans.modules.uml.ui.products.ad.graphobjects.ETGraph;
0079:        import org.netbeans.modules.uml.ui.products.ad.graphobjects.ETGraphManager;
0080:        import org.netbeans.modules.uml.ui.support.accessibility.AccessibleSelectionParent;
0081:        import org.netbeans.modules.uml.ui.support.helpers.ETSmartWaitCursor;
0082:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment;
0083:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IDrawEngine;
0084:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETGraphObject;
0085:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETLabel;
0086:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.ILabelManager;
0087:        import org.netbeans.modules.uml.ui.support.viewfactorysupport.TypeConversions;
0088:        import com.tomsawyer.drawing.TSLabel;
0089:        import com.tomsawyer.drawing.command.TSDeleteNodeCommand;
0090:        import com.tomsawyer.drawing.geometry.TSConstRect;
0091:        import com.tomsawyer.editor.TSEGraph;
0092:        import com.tomsawyer.editor.TSEGraphManager;
0093:        import com.tomsawyer.editor.TSEGraphWindow;
0094:        import com.tomsawyer.editor.TSEHitTesting;
0095:        import com.tomsawyer.editor.TSENode;
0096:        import com.tomsawyer.editor.TSEObjectUI;
0097:        import com.tomsawyer.editor.TSEPreferences; //import com.tomsawyer.editor.TSEWindowState;
0098:        import com.tomsawyer.editor.TSEWindowTool;
0099:        import com.tomsawyer.editor.event.TSEEventManager;
0100:        import com.tomsawyer.editor.event.TSESelectionChangeEvent;
0101:        import com.tomsawyer.editor.event.TSESelectionChangeEventData;
0102:        import com.tomsawyer.editor.event.TSESelectionChangeListener;
0103:        import com.tomsawyer.editor.event.TSEViewportChangeEvent;
0104:        import com.tomsawyer.editor.event.TSEViewportChangeListener;
0105:        import com.tomsawyer.editor.graphics.TSEGraphics;
0106:        import com.tomsawyer.editor.ui.TSEGraphUI;
0107:        import com.tomsawyer.graph.TSGraphObject;
0108:        import com.tomsawyer.graph.event.TSGraphChangeEvent;
0109:        import com.tomsawyer.graph.event.TSGraphChangeListener; //import com.tomsawyer.util.TSConstRect;
0110:        import com.tomsawyer.util.TSObject;
0111:        import com.tomsawyer.util.command.TSCommand;
0112:        import com.tomsawyer.util.command.TSGroupCommand;
0113:        import com.tomsawyer.editor.TSEInnerCanvas;
0114:        import java.awt.Image;
0115:        import java.awt.image.BufferedImage;
0116:
0117:        /**
0118:         * This class extends the main toolkit class TSEGraphWindow.
0119:         */
0120:        public class ADGraphWindow extends TSEGraphWindow implements 
0121:                ActionListener, Accessible {
0122:            String status;
0123:            boolean changed;
0124:
0125:            String graphFileName;
0126:            protected boolean hasFileName;
0127:            ADMoveSelectedKeyAdapter moveAdapter;
0128:            boolean needsFitInWindow = true;
0129:            IDrawingAreaControl m_drawingAreaCtrl = null;
0130:            public static final int MAX_ZOOM = 5000;
0131:            public static final double MIN_ZOOM = 0.01;
0132:            private boolean allowRedraw = true;
0133:            private boolean bUpdatingScrollBars = false;
0134:
0135:            private TSEHitTesting m_hitTesting;
0136:
0137:            protected class ADDrawingPreferences extends
0138:                    com.tomsawyer.editor.TSEPreferences {
0139:                ADDrawingPreferences(TSEGraphWindow graphWindow) {
0140:                    super (graphWindow);
0141:                }
0142:
0143:                protected void modifyDefaults() {
0144:                    super .modifyDefaults();
0145:                }
0146:
0147:                public void setDefaults() {
0148:                    super .setDefaults();
0149:                    // this is causing exceptions.
0150:                    //setDrawFullUIOnDragging(true);
0151:                    //setAutoHidingScrollBars(true);
0152:
0153:                    //         setValue(DRAW_INVISIBLE, true);
0154:                    //         setValue(AUTO_HIDE_SCROLLBARS, true);
0155:                }
0156:            }
0157:
0158:            public ADGraphWindow(IDrawingAreaControl drawingArea) {
0159:                this (drawingArea, null, true);
0160:
0161:            }
0162:
0163:            public ADGraphWindow(IDrawingAreaControl drawingArea,
0164:                    ETGraphManager graphMgr) {
0165:                this (drawingArea, graphMgr, true);
0166:            }
0167:
0168:            public ADGraphWindow(IDrawingAreaControl drawingArea,
0169:                    ETGraphManager graphMgr, boolean withScrollbars) {
0170:                this (graphMgr, withScrollbars);
0171:
0172:                this .setDrawFullUIOnDragging(false);
0173:
0174:                //JM: Fix for Bug#6315533 - Provide vicinity feature for connector/relationship/link elements in drawing area  
0175:                this .setHitTolerance(5);
0176:                m_drawingAreaCtrl = drawingArea;
0177:            }
0178:
0179:            public TSEPreferences newPreferences(TSEGraphWindow graphWindow) {
0180:                return new ADDrawingPreferences(graphWindow);
0181:            }
0182:
0183:            protected ADGraphWindow(ETGraphManager graphManager,
0184:                    boolean withScrollbars) {
0185:                super (graphManager, withScrollbars);
0186:
0187:                //JM: Temp Fix for #6412795 (till we move to the next version of TomSawyer) 
0188:                //- Provide a fix for UML drawing slownes without the sun.java2d.pmoffscreen flag.
0189:                TSEInnerCanvas canvas = new TSEInnerCanvas(this ) {
0190:                    public Image createImage(int width, int height) {
0191:                        return new BufferedImage(width, height,
0192:                                BufferedImage.TYPE_INT_RGB);
0193:                    }
0194:                };
0195:                this .setCanvas(canvas);
0196:
0197:                // vlv: print
0198:                canvas.putClientProperty(java.awt.print.Printable.class, ""); // NOI18N
0199:
0200:                this .moveAdapter = new ADMoveSelectedKeyAdapter(this );
0201:
0202:                this .addComponentListener(new ComponentAdapter() {
0203:                    /**
0204:                     * This method makes sure fitInWindow is called
0205:                     * when the graph window is resized and auto fit in
0206:                     * window is on.
0207:                     */
0208:                    public void componentResized(ComponentEvent e) {
0209:                        if (getDrawingArea() != null
0210:                                && getDrawingArea().isAutoFitInWindow()) {
0211:                            ADGraphWindow.this .fitInWindow(true);
0212:                        }
0213:
0214:                        // This is a work-around to get rid of repaint problem
0215:                        // of scroll bars when the component is resized.
0216:
0217:                        if (ADGraphWindow.this .isAutoHidingScrollBars()) {
0218:                            if (ADGraphWindow.this .getHorizontalScrollBar()
0219:                                    .isVisible()) {
0220:                                ADGraphWindow.this .getHorizontalScrollBar()
0221:                                        .revalidate();
0222:                            }
0223:
0224:                            if (ADGraphWindow.this .getVerticalScrollBar()
0225:                                    .isVisible()) {
0226:                                ADGraphWindow.this .getVerticalScrollBar()
0227:                                        .revalidate();
0228:                            }
0229:                        }
0230:                    }
0231:                });
0232:
0233:                m_hitTesting = new TSEHitTesting(this );
0234:                setToolTipShown(true);
0235:            }
0236:
0237:            /**
0238:             * This overide protects our wait cursor from going away during CDFS
0239:             */
0240:            public void setCursorOnCanvas(Cursor cursor) {
0241:                if (!ETSmartWaitCursor.inWaitState()) {
0242:                    super .setCursorOnCanvas(cursor);
0243:                }
0244:            }
0245:
0246:            public void setupETDefaultDrawingPreferences() {
0247:                ETSystem.out
0248:                        .println("ADGraphWindow setupETDefaultDrawingPreferences");
0249:                getPreferences()
0250:                        .setValue(
0251:                                com.tomsawyer.editor.TSEPreferences.RECONNECT_EDGE_SENSITIVITY,
0252:                                10.0);
0253:
0254:                // limit the max zoom level to the current value set in Tomahawk
0255:                setMaxZoomLevel(MAX_ZOOM / 100);
0256:
0257:                // limit the min zoom level to the current value set in Tomahawk
0258:                setMinZoomLevel(MIN_ZOOM / 100);
0259:
0260:                this .setupCommonLayoutProperties();
0261:            }
0262:
0263:            /*
0264:             * Layout properties that all diagrams share.
0265:             */
0266:            protected void setupCommonLayoutProperties() {
0267:                // Orthongonal layout will resize nodes by default, tell the layout engine to
0268:                // respect the shape of our nodes.
0269:                setOrthogonalKeepNodeSizes(true);
0270:            }
0271:
0272:            /*
0273:             * Sets the OrthogonalKeepNodeSizes layout property, 
0274:             */
0275:            public void setOrthogonalKeepNodeSizes(boolean value) {
0276:                TSEGraph graph = this .getGraph();
0277:                if (graph != null) {/*
0278:                         TSBooleanLayoutProperty property = new TSBooleanLayoutProperty(TSTailorProperties.ORTHOGONAL_KEEP_NODE_SIZES);
0279:                         property.setCurrentValue(value);
0280:                         graph.setTailorProperty(property);
0281:                 *///JM - to be done
0282:                }
0283:            }
0284:
0285:            /*
0286:             * intercept the call to inject taking the lock to avoid 
0287:             * the IZ 127274
0288:             */
0289:            public void transmit(
0290:                    com.tomsawyer.editor.command.TSERoutingCommand command) {
0291:                synchronized (getTreeLock()) {
0292:                    super .transmit(command);
0293:                }
0294:            }
0295:
0296:            public void reshape(int x, int y, int width, int height) {
0297:                super .reshape(x, y, width, height);
0298:            }
0299:
0300:            public IDrawingAreaControl getDrawingArea() {
0301:                return m_drawingAreaCtrl;
0302:            }
0303:
0304:            public TSEGraphManager newGraphManager() {
0305:                return (new ETGraphManager());
0306:
0307:            }
0308:
0309:            /**
0310:             * This method expands all the selected nodes of the graphs
0311:             * which are owned by the current graph manager.
0312:             */
0313:            public void expandSelected() {
0314:            }
0315:
0316:            /**
0317:             * This method expands all the nodes of the graphs which are owned
0318:             * by the current graph manager.
0319:             */
0320:            public void expandAll() {
0321:            }
0322:
0323:            /**
0324:             * This method collapses all the selected nodes of the graphs
0325:             * which are owned by the current graph manager.
0326:             */
0327:            public void collapseSelected() {
0328:            }
0329:
0330:            /**
0331:             * This method collapses all the nodes of the graphs which are owned
0332:             * by the current graph manager.
0333:             */
0334:            public void collapseAll() {
0335:            }
0336:
0337:            /**
0338:             * This method hides all selected objects in the current graph
0339:             * and nested graphs.
0340:             */
0341:            public void hideSelected() {
0342:            }
0343:
0344:            /**
0345:             * This method unhides all hidden objects in the current graph
0346:             * and nested graphs.
0347:             */
0348:            public void unhideAll() {
0349:            }
0350:
0351:            /**
0352:             * This method folds selected objects into new folders in owner
0353:             * graphs.
0354:             */
0355:            public void foldSelected() {
0356:            }
0357:
0358:            /**
0359:             * This method unfolds all folders.
0360:             */
0361:            public void unfoldAll() {
0362:            }
0363:
0364:            /**
0365:             * This method unfolds selected folders.
0366:             */
0367:            public void unfoldSelected() {
0368:            }
0369:
0370:            /**
0371:             * This method sets the status of this graph window.
0372:             */
0373:            public void setStatus(String status) {
0374:                this .status = status;
0375:            }
0376:
0377:            /**
0378:             * This method returns the status of this graph window.
0379:             */
0380:            public String getStatus() {
0381:                return this .status;
0382:            }
0383:
0384:            /**
0385:             * This method sets the flag that stores whether this graph window
0386:             * is displaying a graph that has changed since it was last saved.
0387:             */
0388:            public void setChanged(boolean changed) {
0389:                this .changed = changed;
0390:            }
0391:
0392:            /**
0393:             * This method returns whether this graph window is displaying a graph
0394:             * that has changed since it was last saved.
0395:             */
0396:            public boolean isChanged() {
0397:                return this .changed;
0398:            }
0399:
0400:            /**
0401:             * This method sets the absolute pathname of the graph manager being
0402:             * displayed by this graph window.
0403:             */
0404:            public void setGraphFileName(String filename) {
0405:                this .graphFileName = filename;
0406:            }
0407:
0408:            /**
0409:             * This method gets the absolute pathname of the graph file displayed
0410:             * by this graph window.
0411:             */
0412:            public String getGraphFileName() {
0413:                return this .graphFileName;
0414:            }
0415:
0416:            /**
0417:             * This method returns the boolean value indicating whether the given
0418:             * file is the same file as this graph window's graph file
0419:             */
0420:            protected boolean ownsSameGraphFile(String file) {
0421:                if (this .hasFileName == false) {
0422:                    return false;
0423:                } else if (this .graphFileName == null) {
0424:                    return (file == null);
0425:                } else {
0426:                    return (this .graphFileName.equalsIgnoreCase(file));
0427:                }
0428:            }
0429:
0430:            /**
0431:             * This method moves the selected objects in the specified <code>
0432:             * direction</code>.
0433:             */
0434:            public void move(int direction) {
0435:                if (this .moveAdapter != null) {
0436:                    this .moveAdapter.move(direction);
0437:                }
0438:            }
0439:
0440:            /**
0441:             * This method finalizes the movement of selected objects
0442:             */
0443:            public void finalizeMove() {
0444:                if (this .moveAdapter != null) {
0445:                    this .moveAdapter.finalizeState();
0446:                }
0447:            }
0448:
0449:            public void actionPerformed(ActionEvent event) {
0450:                String action = event.getActionCommand();
0451:
0452:                ETSystem.out.println("ADGraphWindow - " + action);
0453:            }
0454:
0455:            //   public void switchState(TSEWindowState newState)
0456:            //   public void switchState(TSEWindowTool newState)
0457:            public void switchTool(TSEWindowTool newState) {
0458:                //super.switchState(newState);
0459:                super .switchTool(newState);
0460:            }
0461:
0462:            /* (non-Javadoc)
0463:             * @see com.tomsawyer.util.command.TSCommandListener#listen(com.tomsawyer.util.command.TSCommand)
0464:             */
0465:            public int listen(TSCommand cmd) {
0466:                if (cmd instanceof  TSGroupCommand) {
0467:                    TSGroupCommand groupCmd = (TSGroupCommand) cmd;
0468:                    List cmds = groupCmd.getCommandList();
0469:                    for (Iterator iter = cmds.iterator(); iter.hasNext();) {
0470:                        TSCommand curCommand = (TSCommand) iter.next();
0471:                        handleCommandEvent(curCommand);
0472:                    }
0473:                } else {
0474:                    handleCommandEvent(cmd);
0475:                }
0476:
0477:                int retval = 0;
0478:                try {
0479:                    retval = super .listen(cmd);
0480:                } catch (Exception e) {
0481:                    // Fix J2221:  This code still throws an exception in TS when the message-to-self is involved.
0482:                    //             So, we catch the exception here.
0483:                    //             The use case comes from SmartDragTool.onMouseReleased() when the user
0484:                    //             moves the top of the messagee-to-self.
0485:                    // UPDATE:  We should probably figure out why the exception is being thrown in TS.
0486:                }
0487:
0488:                return retval;
0489:            }
0490:
0491:            protected void handleCommandEvent(TSCommand cmd) {
0492:                if (cmd instanceof  TSDeleteNodeCommand) {
0493:                    TSDeleteNodeCommand command = (TSDeleteNodeCommand) cmd;
0494:
0495:                    ETList<IETGraphObject> deletedObject = new ETArrayList<IETGraphObject>();
0496:
0497:                    deletedObject.add(TypeConversions.getETGraphObject(command
0498:                            .getNode()));
0499:                    getDrawingArea().onGraphEvent(
0500:                            IGraphEventKind.GEK_POST_DELETE, null, null,
0501:                            deletedObject);
0502:                }
0503:            }
0504:
0505:            /* (non-Javadoc)
0506:             * @see com.tomsawyer.editor.TSEGraphWindow#deleteSelected()
0507:             */
0508:            public void deleteSelected() {
0509:                TSEGraph graph = this .getGraph();
0510:                if (graph != null && graph.hasSelected())
0511:                    super .deleteSelected();
0512:            }
0513:
0514:            /* (non-Javadoc)
0515:             * @see java.awt.Component#getBackground()
0516:             */
0517:            public Color getBackground() {
0518:                TSEGraph graph = this .getGraph();
0519:                if (graph != null && graph.getUI() instanceof  TSEGraphUI) {
0520:                    TSEGraphUI ui = (TSEGraphUI) graph.getUI();
0521:                    return ui.getBackgroundColor().getColor();
0522:                }
0523:                return super .getBackground();
0524:            }
0525:
0526:            /*
0527:             *  (non-Javadoc)
0528:             * @see com.tomsawyer.editor.TSEGraphWindow#isAutoHidingScrollBarsByDefault()
0529:             */
0530:            public boolean isAutoHidingScrollBarsByDefault() {
0531:                return true;
0532:            }
0533:
0534:            /*
0535:             *  (non-Javadoc)
0536:             * @see com.tomsawyer.editor.TSEGraphWindow#updateScrollBarValues()
0537:             */
0538:            public synchronized void updateScrollBarValues() {
0539:                // Only update the scroll bars if the autoUpdateBounds are enabled.
0540:                if (getAllowRedraw() && isVisible() && getDrawingArea() != null
0541:                        && getDrawingArea().getGraphWindow() == this ) {
0542:                    bUpdatingScrollBars = true;
0543:                    super .updateScrollBarValues();
0544:                    bUpdatingScrollBars = false;
0545:                }
0546:            }
0547:
0548:            /* (non-Javadoc)
0549:             * @see com.tomsawyer.editor.TSEGraphWindow#fitInWindow(boolean)
0550:             */
0551:            public void fitInWindow(boolean arg0) {
0552:                // Only Fit in the window if the bounds are known, otherwise its a useless.
0553:                if (getGraph().isBoundsUpdatingEnabled())
0554:                    super .fitInWindow(arg0);
0555:                else
0556:                    ETSystem.out
0557:                            .println("Warning: your are calling fitInWindow when the graph bounds are unknown.");
0558:            }
0559:
0560:            /* (non-Javadoc)
0561:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph()
0562:             */
0563:            public void drawGraph() {
0564:                if (getAllowRedraw())
0565:                    super .drawGraph();
0566:            }
0567:
0568:            /* (non-Javadoc)
0569:             * @see com.tomsawyer.editor.TSEGraphWindow#drawEntireGraph(com.tomsawyer.editor.graphics.TSEGraphics, int, boolean, boolean, int, int)
0570:             */
0571:            public void drawEntireGraph(TSEGraphics arg0, int arg1,
0572:                    boolean arg2, boolean arg3, int arg4, int arg5) {
0573:                if (getAllowRedraw())
0574:                    super .drawEntireGraph(arg0, arg1, arg2, arg3, arg4, arg5);
0575:            }
0576:
0577:            /* (non-Javadoc)
0578:             * @see com.tomsawyer.editor.TSEGraphWindow#drawEntireGraph(com.tomsawyer.editor.graphics.TSEGraphics, int, boolean, boolean)
0579:             */
0580:            public void drawEntireGraph(TSEGraphics arg0, int arg1,
0581:                    boolean arg2, boolean arg3) {
0582:                if (getAllowRedraw())
0583:                    super .drawEntireGraph(arg0, arg1, arg2, arg3);
0584:            }
0585:
0586:            /* (non-Javadoc)
0587:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(boolean)
0588:             */
0589:            public void drawGraph(boolean arg0) {
0590:                if (getAllowRedraw())
0591:                    super .drawGraph(arg0);
0592:            }
0593:
0594:            /* (non-Javadoc)
0595:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(java.awt.Graphics, boolean, boolean, boolean, boolean, boolean)
0596:             */
0597:            public void drawGraph(Graphics arg0, boolean arg1, boolean arg2,
0598:                    boolean arg3, boolean arg4, boolean arg5) {
0599:                if (getAllowRedraw())
0600:                    super .drawGraph(arg0, arg1, arg2, arg3, arg4, arg5);
0601:            }
0602:
0603:            /* (non-Javadoc)
0604:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(java.awt.Graphics, boolean, boolean, boolean)
0605:             */
0606:            public void drawGraph(Graphics arg0, boolean arg1, boolean arg2,
0607:                    boolean arg3) {
0608:                if (getAllowRedraw())
0609:                    super .drawGraph(arg0, arg1, arg2, arg3);
0610:            }
0611:
0612:            /* (non-Javadoc)
0613:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(java.awt.Graphics, boolean, boolean)
0614:             */
0615:            public void drawGraph(Graphics arg0, boolean arg1, boolean arg2) {
0616:                if (getAllowRedraw())
0617:                    super .drawGraph(arg0, arg1, arg2);
0618:            }
0619:
0620:            /* (non-Javadoc)
0621:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(java.awt.Graphics, boolean)
0622:             */
0623:            public void drawGraph(Graphics arg0, boolean arg1) {
0624:                if (getAllowRedraw())
0625:                    super .drawGraph(arg0, arg1);
0626:            }
0627:
0628:            /* (non-Javadoc)
0629:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(java.awt.Graphics)
0630:             */
0631:            public void drawGraph(Graphics arg0) {
0632:                if (getAllowRedraw())
0633:                    super .drawGraph(arg0);
0634:            }
0635:
0636:            /* (non-Javadoc)
0637:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(com.tomsawyer.util.TSConstRect, boolean, boolean)
0638:             */
0639:            public void drawGraph(TSConstRect arg0, boolean arg1, boolean arg2) {
0640:                if (getAllowRedraw())
0641:                    super .drawGraph(arg0, arg1, arg2);
0642:            }
0643:
0644:            /* (non-Javadoc)
0645:             * @see com.tomsawyer.editor.TSEGraphWindow#drawGraph(com.tomsawyer.util.TSConstRect)
0646:             */
0647:            public void drawGraph(TSConstRect arg0) {
0648:                if (getAllowRedraw())
0649:                    super .drawGraph(arg0);
0650:            }
0651:
0652:            /* (non-Javadoc)
0653:             * @see com.tomsawyer.editor.TSEGraphWindow#updateInvalidRegions()
0654:             */
0655:            public void updateInvalidRegion() {
0656:                if (getAllowRedraw())
0657:                    super .updateInvalidRegion();
0658:            }
0659:
0660:            /* (non-Javadoc)
0661:             * @see com.tomsawyer.editor.TSEGraphWindow#updateInvalidRegions(boolean)
0662:             */
0663:            public synchronized void updateInvalidRegion(boolean arg0) {
0664:                if (getAllowRedraw())
0665:                    super .updateInvalidRegion(arg0);
0666:            }
0667:
0668:            /*
0669:             * Returns we we can draw on the graph window
0670:             */
0671:            public boolean getAllowRedraw() {
0672:                return allowRedraw && getGraph() != null
0673:                        && getGraph().isBoundsUpdatingEnabled();
0674:            }
0675:
0676:            /*
0677:             * Sets if we can draw on the graph window.
0678:             */
0679:            public void setAllowRedraw(boolean allow) {
0680:                allowRedraw = allow;
0681:            }
0682:
0683:            /* (non-Javadoc)
0684:             * @see com.tomsawyer.editor.TSEGraphWindow#getMaxZoomLevel()
0685:             */
0686:            public double getMaxZoomLevel() {
0687:                if (m_drawingAreaCtrl != null) {
0688:                    return m_drawingAreaCtrl.getExtremeZoomValues()
0689:                            .getParamTwo().doubleValue();
0690:                } else
0691:                    return super .getMaxZoomLevel();
0692:            }
0693:
0694:            /* (non-Javadoc)
0695:             * @see com.tomsawyer.editor.TSEGraphWindow#getMinZoomLevel()
0696:             */
0697:            public double getMinZoomLevel() {
0698:                if (m_drawingAreaCtrl != null) {
0699:                    return m_drawingAreaCtrl.getExtremeZoomValues()
0700:                            .getParamOne().doubleValue();
0701:                } else
0702:                    return super .getMinZoomLevel();
0703:            }
0704:
0705:            /* (non-Javadoc)
0706:             * @see java.awt.Component#doLayout()
0707:             */
0708:            public void doLayout() {
0709:                try {
0710:                    if (bUpdatingScrollBars == false)
0711:                        super .doLayout();
0712:                } catch (Exception e) {
0713:                    // For some reason TS is throwing an array out of bounds exception.
0714:                    // Just check the exception and move on.
0715:                }
0716:            }
0717:
0718:            //JM : writing this method for debugging purposes only.. can be deleted later...
0719:            public void setZoomLevel(double zoomLevel, boolean redraw) {
0720:                //       Debug.out.println("Old zoom level: " + this.getZoomLevel());       
0721:                super .setZoomLevel(zoomLevel, redraw);
0722:                //       Debug.out.println("New zoom level: " + this.getZoomLevel());
0723:            }
0724:
0725:            public String getToolTipText(MouseEvent event) {
0726:
0727:                TSENode node = m_hitTesting.getNodeAt(
0728:                        getNonalignedWorldPoint(event.getPoint()), getGraph(),
0729:                        true);
0730:
0731:                if (node == null)
0732:                    return null;
0733:
0734:                TSEObjectUI nodeUI = node.getUI();
0735:
0736:                if (nodeUI == null)
0737:                    return null;
0738:                if (!(nodeUI instanceof  IETGraphObjectUI))
0739:                    return null;
0740:
0741:                IDrawEngine engine = ((IETGraphObjectUI) nodeUI)
0742:                        .getDrawEngine();
0743:
0744:                if (engine == null)
0745:                    return null;
0746:
0747:                if (engine instanceof  ETClassDrawEngine) {
0748:                    return ((ETClassDrawEngine) engine).getToolTipText(event);
0749:                }
0750:
0751:                return null;
0752:            }
0753:
0754:            //JM: Fix for Bug#6315533 - Provide vicinity feature for connector/relationship/link elements in drawing area   
0755:            public int getHitTolerance() {
0756:                //       Debug.out.println("...............get hit tolerance = "+super.getHitTolerance()+" this = "+this.hashCode());
0757:                return super .getHitTolerance();
0758:            }
0759:
0760:            public void setHitTolerance(int tolerance) {
0761:                super .setHitTolerance(tolerance);
0762:                //       Debug.out.println("...............in set method... hit tolerance = "+super.getHitTolerance()+" this = "+this.hashCode());        
0763:            }
0764:
0765:            public void scrollBy(int dx, int dy, boolean redraw) {
0766:                //       System.err.println("  ADGraphWindow : scrollBy .. dx = "+dx+" dy = "+dy+" redraw = "+redraw);
0767:                super .scrollBy(dx, dy, redraw);
0768:                drawGraph();
0769:                repaint();
0770:            }
0771:
0772:            /////////////
0773:            // Accessible
0774:            /////////////
0775:
0776:            AccessibleContext accessibleContext;
0777:
0778:            public AccessibleContext getAccessibleContext() {
0779:                if (accessibleContext == null) {
0780:                    accessibleContext = new AccessibleGraphWindow();
0781:                }
0782:                return accessibleContext;
0783:            }
0784:
0785:            public class AccessibleGraphWindow extends AccessibleJComponent
0786:                    implements  AccessibleSelection {
0787:
0788:                WeakHashMap<IDrawEngine, AccessibleEngineAndLabelsPanel> panels = new WeakHashMap<IDrawEngine, AccessibleEngineAndLabelsPanel>();
0789:
0790:                public AccessibleGraphWindow() {
0791:                    super ();
0792:                    registerAsGraphListener();
0793:                }
0794:
0795:                public String getAccessibleName() {
0796:                    return getDrawingArea().getName();
0797:                }
0798:
0799:                public int getAccessibleChildrenCount() {
0800:                    List<Accessible> children = getAccessibleChildren();
0801:                    if (children != null) {
0802:                        return children.size();
0803:                    }
0804:                    return 0;
0805:                }
0806:
0807:                public Accessible getAccessibleChild(int i) {
0808:                    List<Accessible> children = getAccessibleChildren();
0809:                    if (children != null && i < children.size()) {
0810:                        return children.get(i);
0811:                    }
0812:                    return null;
0813:                }
0814:
0815:                public AccessibleRole getAccessibleRole() {
0816:                    return AccessibleRole.PANEL;
0817:                }
0818:
0819:                public AccessibleSelection getAccessibleSelection() {
0820:                    return this ;
0821:                }
0822:
0823:                public AccessibleComponent getAccessibleComponent() {
0824:                    return this ;
0825:                }
0826:
0827:                ////////////////////////////////
0828:                // interface AccessibleComponent
0829:                ////////////////////////////////
0830:
0831:                public javax.accessibility.Accessible getAccessibleAt(
0832:                        java.awt.Point point) {
0833:                    return null;
0834:                }
0835:
0836:                ////////////////////////////////
0837:                // interface AccessibleSelection
0838:                ////////////////////////////////
0839:
0840:                public int getAccessibleSelectionCount() {
0841:                    List<Accessible> selected = getSelectedAccessibleChildren();
0842:                    if (selected != null) {
0843:                        return selected.size();
0844:                    }
0845:                    return 0;
0846:                }
0847:
0848:                public Accessible getAccessibleSelection(int i) {
0849:                    List<Accessible> selected = getSelectedAccessibleChildren();
0850:                    if (selected != null && i < selected.size()) {
0851:                        return selected.get(i);
0852:                    }
0853:                    return null;
0854:                }
0855:
0856:                public boolean isAccessibleChildSelected(int i) {
0857:                    Accessible child = getAccessibleChild(i);
0858:                    if (child != null) {
0859:                        return isSelected(child);
0860:                    }
0861:                    return false;
0862:                }
0863:
0864:                public void addAccessibleSelection(int i) {
0865:                    Accessible child = getAccessibleChild(i);
0866:                    if (child != null) {
0867:                        selectChild(child, true, false);
0868:                    }
0869:                }
0870:
0871:                public void removeAccessibleSelection(int i) {
0872:                    List<Accessible> selected = getSelectedAccessibleChildren();
0873:                    List<Accessible> children = getAccessibleChildren();
0874:                    if (children != null && i < children.size()) {
0875:                        //if (isSelected(children.get(i))) {
0876:                        selectChild(children.get(i), false, true);
0877:                        //}
0878:                    }
0879:                }
0880:
0881:                public void selectAllAccessibleSelection() {
0882:                    List<Accessible> children = getAccessibleChildren();
0883:                    if (children != null) {
0884:                        for (int i = 0; i < children.size(); i++) {
0885:                            selectChild(children.get(i), true, false);
0886:                        }
0887:                    }
0888:                }
0889:
0890:                public void clearAccessibleSelection() {
0891:                    List<Accessible> selected = getSelectedAccessibleChildren();
0892:                    if (selected != null) {
0893:                        for (int i = 0; i < selected.size(); i++) {
0894:                            selectChild(selected.get(i), false, true);
0895:                        }
0896:                    }
0897:                }
0898:
0899:                /////////////////
0900:                // Helper methods
0901:                /////////////////
0902:
0903:                public void selectChild(Accessible child, boolean select,
0904:                        boolean replaceSelection) {
0905:                    AccessibleSelection childSelection = child
0906:                            .getAccessibleContext().getAccessibleSelection();
0907:                    if (childSelection != null) {
0908:                        if (select) {
0909:                            childSelection.selectAllAccessibleSelection();
0910:                        } else {
0911:                            childSelection.clearAccessibleSelection();
0912:                        }
0913:                    }
0914:                }
0915:
0916:                public boolean isSelectable(Accessible child) {
0917:                    return true;
0918:                }
0919:
0920:                /**
0921:                 *  a panel for node/edge with labels is considered selected if the node/engine is selected
0922:                 */
0923:                public boolean isSelected(Accessible child) {
0924:                    if (child instanceof  AccessibleEngineAndLabelsPanel) {
0925:                        AccessibleEngineAndLabelsPanel panel = (AccessibleEngineAndLabelsPanel) child;
0926:                        return panel.isSelected(panel.engine);
0927:                    }
0928:                    return false;
0929:                }
0930:
0931:                public List<Accessible> getAccessibleChildren() {
0932:                    ArrayList<Accessible> children = new ArrayList<Accessible>();
0933:                    if (m_drawingAreaCtrl != null) {
0934:                        ETList<TSGraphObject> nodesAndEdges = new ETArrayList<TSGraphObject>();
0935:                        nodesAndEdges.addAll(getGraph().edges());
0936:                        nodesAndEdges.addAll(getGraph().nodes());
0937:                        Iterator<TSGraphObject> iter = nodesAndEdges.iterator();
0938:                        while (iter.hasNext()) {
0939:                            TSGraphObject obj = iter.next();
0940:                            IDrawEngine eng = TypeConversions
0941:                                    .getDrawEngine(obj);
0942:                            if (eng instanceof  Accessible) {
0943:                                if (eng != null && eng instanceof  Accessible) {
0944:                                    AccessibleEngineAndLabelsPanel panel = panels
0945:                                            .get(eng);
0946:                                    if (panel == null) {
0947:                                        panel = new AccessibleEngineAndLabelsPanel(
0948:                                                (Accessible) eng);
0949:                                        panel.getAccessibleContext()
0950:                                                .setAccessibleParent(
0951:                                                        ADGraphWindow.this );
0952:                                        panels.put(eng, panel);
0953:                                    }
0954:                                    children.add(panel);
0955:                                }
0956:                            }
0957:                        }
0958:                    }
0959:                    return children;
0960:                }
0961:
0962:                public List<Accessible> getSelectedAccessibleChildren() {
0963:                    ArrayList<Accessible> selected = new ArrayList<Accessible>();
0964:                    List<Accessible> children = getAccessibleChildren();
0965:                    for (int i = 0; i < children.size(); i++) {
0966:                        Accessible child = children.get(i);
0967:                        if (isSelected(child)) {
0968:                            selected.add(child);
0969:                        }
0970:                    }
0971:                    return selected;
0972:                }
0973:
0974:                public Accessible getAccessibleChild(Object obj) {
0975:                    if (obj instanceof  TSObject) {
0976:                        IDrawEngine eng = TypeConversions
0977:                                .getDrawEngine((TSObject) obj);
0978:                        if (eng != null && eng instanceof  Accessible) {
0979:                            AccessibleEngineAndLabelsPanel panel = panels
0980:                                    .get(eng);
0981:                            if (panel == null) {
0982:                                panel = new AccessibleEngineAndLabelsPanel(
0983:                                        (Accessible) eng);
0984:                                panel
0985:                                        .getAccessibleContext()
0986:                                        .setAccessibleParent(ADGraphWindow.this );
0987:                                panels.put(eng, panel);
0988:                            }
0989:                            return panel;
0990:                        }
0991:                    }
0992:                    return null;
0993:                }
0994:
0995:                ////////////////////////////////
0996:                // Property Change Notifications
0997:                ////////////////////////////////
0998:
0999:                public void registerAsGraphListener() {
1000:
1001:                    ACS_GraphListener listener = new ACS_GraphListener();
1002:                    getGraphManager().getEventManager().addGraphChangeListener(
1003:                            getGraphManager(), listener);
1004:                    ((TSEEventManager) getGraphManager().getEventManager())
1005:                            .addSelectionChangeListener(getGraphManager(),
1006:                                    listener);
1007:                    ((TSEEventManager) getGraphManager().getEventManager())
1008:                            .addViewportChangeListener(ADGraphWindow.this ,
1009:                                    listener);
1010:                }
1011:
1012:                public class ACS_GraphListener implements 
1013:                        TSGraphChangeListener, TSESelectionChangeListener,
1014:                        TSEViewportChangeListener {
1015:
1016:                    public void graphChanged(TSGraphChangeEvent event) {
1017:
1018:                        if ((event.getType() == TSGraphChangeEvent.NODE_INSERTED)
1019:                                || (event.getType() == TSGraphChangeEvent.EDGE_INSERTED)) {
1020:                            Accessible child = getAccessibleChild(event
1021:                                    .getSource());
1022:                            firePropertyChange(ACCESSIBLE_CHILD_PROPERTY, null,
1023:                                    child);
1024:                        } else if ((event.getType() == TSGraphChangeEvent.NODE_REMOVED)
1025:                                || (event.getType() == TSGraphChangeEvent.NODE_DISCARDED)
1026:                                || (event.getType() == TSGraphChangeEvent.EDGE_REMOVED)
1027:                                || (event.getType() == TSGraphChangeEvent.EDGE_DISCARDED)) {
1028:                            Accessible child = getAccessibleChild(event
1029:                                    .getSource());
1030:                            firePropertyChange(ACCESSIBLE_CHILD_PROPERTY,
1031:                                    child, null);
1032:                        } else if ((event.getType() == TSGraphChangeEvent.NODE_RENAMED)
1033:                                || (event.getType() == TSGraphChangeEvent.EDGE_RENAMED)) {
1034:
1035:                            ;
1036:                        }
1037:
1038:                    }
1039:
1040:                    public void selectionChanged(TSESelectionChangeEvent event) {
1041:                        Object source = event.getSource();
1042:                        Object oldValue = null;
1043:                        Object newValue = null;
1044:
1045:                        if (event.getData() instanceof  TSESelectionChangeEventData) {
1046:                            TSESelectionChangeEventData data = (TSESelectionChangeEventData) event
1047:                                    .getData();
1048:                            if (data != null) {
1049:                                if (data.isSelected()) {
1050:                                    newValue = source;
1051:                                } else if (data.wasSelected()) {
1052:                                    oldValue = source;
1053:                                }
1054:                            }
1055:                        }
1056:
1057:                        firePropertyChange(ACCESSIBLE_SELECTION_PROPERTY,
1058:                                oldValue, newValue);
1059:
1060:                        if (source != null) {
1061:                            Accessible child;
1062:                            if (source instanceof  TSLabel) {
1063:                                child = getAccessibleChild(((TSGraphObject) event
1064:                                        .getSource()).getOwner());
1065:                            } else {
1066:                                child = getAccessibleChild(event.getSource());
1067:                            }
1068:                            if (child != null) {
1069:                                child.getAccessibleContext()
1070:                                        .firePropertyChange(
1071:                                                ACCESSIBLE_SELECTION_PROPERTY,
1072:                                                oldValue, newValue);
1073:                            }
1074:                        }
1075:
1076:                    }
1077:
1078:                    public void viewportChanged(TSEViewportChangeEvent event) {
1079:                        ;
1080:                    }
1081:
1082:                }
1083:
1084:                public void firePropertyChange(String propertyName,
1085:                        Object oldValue, Object newValue) {
1086:                    //System.out.println("\nFIRED : AccessibleADGraphWindow \n propertyName = "+propertyName+"\n oldValue = "+oldValue+"\n newValue = "+newValue);
1087:                    super .firePropertyChange(propertyName, oldValue, newValue);
1088:                }
1089:
1090:            }
1091:
1092:            ////////////////////////////////////////////////
1093:            // Artificial panel for an engine and its labels
1094:            ////////////////////////////////////////////////
1095:
1096:            public class AccessibleEngineAndLabelsPanel extends
1097:                    AccessibleContext implements  Accessible,
1098:                    AccessibleComponent, AccessibleSelection,
1099:                    AccessibleSelectionParent {
1100:
1101:                public void firePropertyChange(String propertyName,
1102:                        Object oldValue, Object newValue) {
1103:                    //System.out.println("\nFIRED : AccessibleEngineAndLabelsPanel \n propertyName = "+propertyName+"\n oldValue = "+oldValue+"\n newValue = "+newValue);
1104:                    super .firePropertyChange(propertyName, oldValue, newValue);
1105:                }
1106:
1107:                public AccessibleContext getAccessibleContext() {
1108:                    return this ;
1109:                }
1110:
1111:                public Accessible engine;
1112:
1113:                public AccessibleEngineAndLabelsPanel(Accessible eng) {
1114:                    this .engine = eng;
1115:                }
1116:
1117:                public Locale getLocale() {
1118:                    return Locale.US;
1119:                }
1120:
1121:                public int getAccessibleIndexInParent() {
1122:                    return 0;
1123:                }
1124:
1125:                public AccessibleStateSet getAccessibleStateSet() {
1126:                    return new AccessibleStateSet(new AccessibleState[] {
1127:                            AccessibleState.SHOWING, AccessibleState.VISIBLE,
1128:                            AccessibleState.ENABLED, AccessibleState.FOCUSABLE,
1129:                            AccessibleState.SELECTABLE });
1130:                }
1131:
1132:                public String getAccessibleName() {
1133:                    return engine.getAccessibleContext().getAccessibleName();
1134:                }
1135:
1136:                public String getAccessibleDescription() {
1137:                    return engine.getAccessibleContext()
1138:                            .getAccessibleDescription();
1139:                }
1140:
1141:                public int getAccessibleChildrenCount() {
1142:                    List<Accessible> children = getAccessibleChildren();
1143:                    if (children != null) {
1144:                        return children.size();
1145:                    }
1146:                    return 0;
1147:                }
1148:
1149:                public Accessible getAccessibleChild(int i) {
1150:                    List<Accessible> children = getAccessibleChildren();
1151:                    if (children != null && i < children.size()) {
1152:                        return children.get(i);
1153:                    }
1154:                    return null;
1155:                }
1156:
1157:                public AccessibleRole getAccessibleRole() {
1158:                    return AccessibleRole.PANEL;
1159:                }
1160:
1161:                public AccessibleSelection getAccessibleSelection() {
1162:                    return this ;
1163:                }
1164:
1165:                public AccessibleComponent getAccessibleComponent() {
1166:                    return this ;
1167:                }
1168:
1169:                ////////////////////////////////
1170:                // interface AccessibleComponent
1171:                ////////////////////////////////
1172:
1173:                public java.awt.Color getBackground() {
1174:                    return null;
1175:                }
1176:
1177:                public void setBackground(java.awt.Color color) {
1178:                    ;
1179:                }
1180:
1181:                public java.awt.Color getForeground() {
1182:                    return null;
1183:                }
1184:
1185:                public void setForeground(java.awt.Color color) {
1186:                    ;
1187:                }
1188:
1189:                public java.awt.Cursor getCursor() {
1190:                    return null; //getGraphWindow().getCursor();
1191:                }
1192:
1193:                public void setCursor(java.awt.Cursor cursor) {
1194:                    ;
1195:                }
1196:
1197:                public java.awt.Font getFont() {
1198:                    return null;
1199:                }
1200:
1201:                public void setFont(java.awt.Font font) {
1202:                    ;
1203:                }
1204:
1205:                public java.awt.FontMetrics getFontMetrics(java.awt.Font font) {
1206:                    return null; //getGraphWindow().getFontMetrics(font);
1207:                }
1208:
1209:                public boolean isEnabled() {
1210:                    return true;
1211:                }
1212:
1213:                public void setEnabled(boolean enabled) {
1214:
1215:                }
1216:
1217:                public boolean isVisible() {
1218:                    return true;
1219:                }
1220:
1221:                public void setVisible(boolean visible) {
1222:                    ;
1223:                }
1224:
1225:                public boolean isShowing() {
1226:                    return true;
1227:                }
1228:
1229:                public boolean contains(java.awt.Point point) {
1230:                    Rectangle r = getBounds();
1231:                    return r.contains(point);
1232:                }
1233:
1234:                public java.awt.Point getLocationOnScreen() {
1235:                    java.awt.Point p = null;
1236:                    List<Accessible> children = getAccessibleChildren();
1237:                    if (children != null) {
1238:                        for (int i = 0; i < children.size(); i++) {
1239:                            Accessible child = children.get(i);
1240:                            if (child != null) {
1241:                                java.awt.Point pc = child
1242:                                        .getAccessibleContext()
1243:                                        .getAccessibleComponent()
1244:                                        .getLocationOnScreen();
1245:                                if (pc != null) {
1246:                                    if (p == null) {
1247:                                        p = pc;
1248:                                    } else {
1249:                                        if (pc.x < p.x) {
1250:                                            p.setLocation(pc.x, p.y);
1251:                                        }
1252:                                        if (pc.y < p.y) {
1253:                                            p.setLocation(p.x, pc.y);
1254:                                        }
1255:                                    }
1256:                                }
1257:                            }
1258:                        }
1259:                    }
1260:                    return p;
1261:                }
1262:
1263:                public java.awt.Point getLocation() {
1264:                    java.awt.Point p = null;
1265:                    List<Accessible> children = getAccessibleChildren();
1266:                    if (children != null) {
1267:                        for (int i = 0; i < children.size(); i++) {
1268:                            Accessible child = children.get(i);
1269:                            if (child != null) {
1270:                                java.awt.Point pc = child
1271:                                        .getAccessibleContext()
1272:                                        .getAccessibleComponent().getLocation();
1273:                                if (pc != null) {
1274:                                    if (p == null) {
1275:                                        p = pc;
1276:                                    } else {
1277:                                        if (pc.x < p.x) {
1278:                                            p.setLocation(pc.x, p.y);
1279:                                        }
1280:                                        if (pc.y < p.y) {
1281:                                            p.setLocation(p.x, pc.y);
1282:                                        }
1283:                                    }
1284:                                }
1285:                            }
1286:                        }
1287:                    }
1288:                    return p;
1289:                }
1290:
1291:                public void setLocation(java.awt.Point point) {
1292:                    ;
1293:                }
1294:
1295:                public java.awt.Rectangle getBounds() {
1296:                    java.awt.Rectangle bounds = null;
1297:                    List<Accessible> children = getAccessibleChildren();
1298:                    if (children != null) {
1299:                        for (int i = 0; i < children.size(); i++) {
1300:                            Accessible child = children.get(i);
1301:                            if (child != null) {
1302:                                java.awt.Rectangle bc = child
1303:                                        .getAccessibleContext()
1304:                                        .getAccessibleComponent().getBounds();
1305:                                if (bc != null) {
1306:                                    if (bounds == null) {
1307:                                        bounds = bc;
1308:                                    } else {
1309:                                        bounds = bounds.union(bc);
1310:                                    }
1311:                                }
1312:                            }
1313:                        }
1314:                    }
1315:                    return bounds;
1316:                }
1317:
1318:                public void setBounds(java.awt.Rectangle bounds) {
1319:                    ;
1320:                }
1321:
1322:                public java.awt.Dimension getSize() {
1323:                    Rectangle r = getBounds();
1324:                    return new Dimension(r.width, r.height);
1325:                }
1326:
1327:                public void setSize(java.awt.Dimension dim) {
1328:                    ;
1329:                }
1330:
1331:                public javax.accessibility.Accessible getAccessibleAt(
1332:                        java.awt.Point point) {
1333:                    return null;
1334:                }
1335:
1336:                public boolean isFocusTraversable() {
1337:                    return true;
1338:                }
1339:
1340:                public void requestFocus() {
1341:                    ;
1342:                }
1343:
1344:                public void addFocusListener(
1345:                        java.awt.event.FocusListener listener) {
1346:                    ;
1347:                }
1348:
1349:                public void removeFocusListener(
1350:                        java.awt.event.FocusListener listener) {
1351:                    ;
1352:                }
1353:
1354:                ////////////////////////////////
1355:                // interface AccessibleSelection
1356:                ////////////////////////////////
1357:
1358:                public int getAccessibleSelectionCount() {
1359:                    List<Accessible> selected = getSelectedAccessibleChildren();
1360:                    if (selected != null) {
1361:                        return selected.size();
1362:                    }
1363:                    return 0;
1364:                }
1365:
1366:                public Accessible getAccessibleSelection(int i) {
1367:                    List<Accessible> selected = getSelectedAccessibleChildren();
1368:                    if (selected != null && i < selected.size()) {
1369:                        return selected.get(i);
1370:                    }
1371:                    return null;
1372:                }
1373:
1374:                public boolean isAccessibleChildSelected(int i) {
1375:                    Accessible child = getAccessibleChild(i);
1376:                    if (child != null) {
1377:                        return isSelected(child);
1378:                    }
1379:                    return false;
1380:                }
1381:
1382:                public void addAccessibleSelection(int i) {
1383:                    Accessible child = getAccessibleChild(i);
1384:                    if (child != null) {
1385:                        selectChild(child, true, false);
1386:                    }
1387:                }
1388:
1389:                public void removeAccessibleSelection(int i) {
1390:                    List<Accessible> selected = getSelectedAccessibleChildren();
1391:                    List<Accessible> children = getAccessibleChildren();
1392:                    if (children != null && i < children.size()) {
1393:                        //if (isSelected(children.get(i))) {
1394:                        selectChild(children.get(i), false, true);
1395:                        //}
1396:                    }
1397:                }
1398:
1399:                public void selectAllAccessibleSelection() {
1400:                    List<Accessible> children = getAccessibleChildren();
1401:                    if (children != null) {
1402:                        for (int i = 0; i < children.size(); i++) {
1403:                            selectChild(children.get(i), true, false);
1404:                        }
1405:                    }
1406:                }
1407:
1408:                public void clearAccessibleSelection() {
1409:                    List<Accessible> selected = getSelectedAccessibleChildren();
1410:                    if (selected != null) {
1411:                        for (int i = 0; i < selected.size(); i++) {
1412:                            selectChild(selected.get(i), false, true);
1413:                        }
1414:                    }
1415:                }
1416:
1417:                /////////////////
1418:                // Helper methods
1419:                /////////////////
1420:
1421:                public void selectChild(Accessible child, boolean select,
1422:                        boolean replaceSelection) {
1423:                    if (child instanceof  IDrawEngine) {
1424:                        if (replaceSelection) {
1425:                            deselectAll(false);
1426:                        }
1427:                        if (!select) {
1428:                            ((IDrawEngine) child).selectAllCompartments(false);
1429:                        }
1430:                        ((IDrawEngine) child).getParent().getTSObject()
1431:                                .setSelected(select);
1432:                        getDrawingArea().onGraphEvent(
1433:                                IGraphEventKind.GEK_POST_SELECT, null, null,
1434:                                null);
1435:                        ETGraph etGraph = getGraph() instanceof  ETGraph ? (ETGraph) getGraph()
1436:                                : null;
1437:                        getDrawingArea().fireSelectEvent(
1438:                                etGraph != null ? etGraph.getSelectedObjects(
1439:                                        false, false) : null);
1440:                        getDrawingArea().refresh(true);
1441:                    }
1442:
1443:                }
1444:
1445:                public boolean isSelectable(Accessible child) {
1446:                    return true;
1447:                }
1448:
1449:                public boolean isSelected(Accessible child) {
1450:                    if (child instanceof  IDrawEngine) {
1451:                        ETGraph etGraph = getGraph() instanceof  ETGraph ? (ETGraph) getGraph()
1452:                                : null;
1453:                        if (etGraph != null) {
1454:                            List<TSGraphObject> selected = etGraph
1455:                                    .getSelectedObjects(false, false);
1456:                            if (selected != null
1457:                                    && selected.contains(((IDrawEngine) child)
1458:                                            .getParent().getTSObject())) {
1459:                                return true;
1460:                            }
1461:                        }
1462:                    }
1463:                    return false;
1464:                }
1465:
1466:                public List<Accessible> getAccessibleChildren() {
1467:                    ArrayList<Accessible> children = new ArrayList<Accessible>();
1468:                    if (engine != null) {
1469:                        engine.getAccessibleContext().setAccessibleParent(this );
1470:                        children.add(engine);
1471:                        ILabelManager labelMgr = ((IDrawEngine) engine)
1472:                                .getLabelManager();
1473:                        if (labelMgr != null) {
1474:                            for (int lIndx = 0; /* break below */; lIndx++) {
1475:                                IETLabel label = null;
1476:                                label = labelMgr.getLabelByIndex(lIndx);
1477:                                if (label != null) {
1478:                                    IDrawEngine eng = label.getEngine();
1479:                                    if (eng instanceof  Accessible) {
1480:                                        ((Accessible) eng)
1481:                                                .getAccessibleContext()
1482:                                                .setAccessibleParent(this );
1483:                                        children.add((Accessible) eng);
1484:                                    }
1485:                                } else {
1486:                                    break;
1487:                                }
1488:                            }
1489:                        }
1490:                    }
1491:                    return children;
1492:                }
1493:
1494:                public List<Accessible> getSelectedAccessibleChildren() {
1495:                    ArrayList<Accessible> selected = new ArrayList<Accessible>();
1496:                    List<Accessible> children = getAccessibleChildren();
1497:                    for (int i = 0; i < children.size(); i++) {
1498:                        Accessible child = children.get(i);
1499:                        if (isSelected(child)) {
1500:                            selected.add(child);
1501:                        }
1502:                    }
1503:                    return selected;
1504:                }
1505:
1506:            }
1507:
1508:        }
w__w__w___.j__a__va__2___s._c_o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.