Source Code Cross Referenced for GraphSelectionEvent.java in  » Graphic-Library » jgraph » org » jgraph » event » 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 » jgraph » org.jgraph.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)GraphSelectionEvent.java	1.0 03-JUL-04
003:         * 
004:         * Copyright (c) 2001-2005 Gaudenz Alder
005:         *  
006:         * See LICENSE file in distribution for licensing details of this source file
007:         */
008:        package org.jgraph.event;
009:
010:        import java.util.EventObject;
011:
012:        /**
013:         * An event that characterizes a change in the current selection. The change is
014:         * based on any number of cells. GraphSelectionListeners will generally query
015:         * the source of the event for the new selected status of each potentially
016:         * changed cell.
017:         * 
018:         * @see GraphSelectionListener
019:         * @see org.jgraph.graph.GraphSelectionModel
020:         * 
021:         * @version 1.0 1/1/02
022:         * @author Gaudenz Alder
023:         */
024:        public class GraphSelectionEvent extends EventObject {
025:            /** Cells this event represents. */
026:            protected Object[] cells;
027:
028:            /**
029:             * For each cell identifies whether or not that cell is newly selected.
030:             */
031:            protected boolean[] areNew;
032:
033:            /**
034:             * Represents a change in the selection of a GraphSelectionModel.
035:             * <code>cells</code> identifies the cells that have been either added or
036:             * removed from the selection.
037:             * 
038:             * @param source
039:             *            source of event
040:             * @param cells
041:             *            the paths that have changed in the selection
042:             * @param areNew
043:             *            for each cell, defines whether or not that cell is newly
044:             *            selected
045:             */
046:            public GraphSelectionEvent(Object source, Object[] cells,
047:                    boolean[] areNew) {
048:                super (source);
049:                this .cells = cells;
050:                this .areNew = areNew;
051:            }
052:
053:            /**
054:             * Returns the cells that have been added or removed from the selection.
055:             * 
056:             * @return added or removed cells
057:             */
058:            public Object[] getCells() {
059:                int numCells;
060:                Object[] retCells;
061:
062:                numCells = cells.length;
063:                retCells = new Object[numCells];
064:                System.arraycopy(cells, 0, retCells, 0, numCells);
065:                return retCells;
066:            }
067:
068:            /**
069:             * Returns the first cell.
070:             * 
071:             * @return the first selected cell
072:             */
073:            public Object getCell() {
074:                return cells[0];
075:            }
076:
077:            /**
078:             * Returns true if the first cell has been added to the selection, a return
079:             * value of false means the first cell has been removed from the selection.
080:             * 
081:             * @return whether or not the first cell has been added or removed
082:             */
083:            public boolean isAddedCell() {
084:                return areNew[0];
085:            }
086:
087:            /**
088:             * Returns true if the cell identified by cell was added to the selection. A
089:             * return value of false means the cell was in the selection but is no
090:             * longer in the selection. This will raise if cell is not one of the cells
091:             * identified by this event.
092:             * 
093:             * @param cell
094:             *            the cell that is to be indicated as newly selected or not
095:             * @return <code>true</code> if the specified cell is newly selected
096:             */
097:            public boolean isAddedCell(Object cell) {
098:                for (int counter = cells.length - 1; counter >= 0; counter--)
099:                    if (cells[counter].equals(cell))
100:                        return areNew[counter];
101:                throw new IllegalArgumentException(
102:                        "cell is not a cell identified by the GraphSelectionEvent");
103:            }
104:
105:            /**
106:             * Returns true if the cell identified by <code>index</code> was added to
107:             * the selection. A return value of false means the cell was in the
108:             * selection but is no longer in the selection. This will raise an exception
109:             * if index < 0 || >=<code>getPaths</code> .length.
110:             * 
111:             * @param index
112:             *            the index of <code>areNew</code> of the cell that is to be
113:             *            indicated as newly selected or not
114:             * @return whether or not the cell is newly selected or not
115:             */
116:            public boolean isAddedCell(int index) {
117:                if (cells == null || index < 0 || index >= cells.length) {
118:                    throw new IllegalArgumentException(
119:                            "index is beyond range of added cells identified by GraphSelectionEvent");
120:                }
121:                return areNew[index];
122:            }
123:
124:            /**
125:             * Returns a copy of the receiver, but with the source being newSource.
126:             * 
127:             * @param newSource
128:             *            the new event source
129:             * @return the cloned event with the specified source
130:             */
131:            public Object cloneWithSource(Object newSource) {
132:                // Fix for IE bug - crashing
133:                return new GraphSelectionEvent(newSource, cells, areNew);
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.