Source Code Cross Referenced for GraphTransferable.java in  » Graphic-Library » jgraph » org » jgraph » graph » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Graphic Library » jgraph » org.jgraph.graph 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)GraphTransferable.java	1.0 03-JUL-04
003:         * 
004:         * Copyright (c) 2001-2004 Gaudenz Alder
005:         *  
006:         */
007:        package org.jgraph.graph;
008:
009:        import java.awt.datatransfer.Clipboard;
010:        import java.awt.datatransfer.ClipboardOwner;
011:        import java.awt.datatransfer.DataFlavor;
012:        import java.awt.datatransfer.Transferable;
013:        import java.awt.datatransfer.UnsupportedFlavorException;
014:        import java.awt.geom.Rectangle2D;
015:        import java.io.Serializable;
016:        import java.util.Map;
017:
018:        import org.jgraph.plaf.basic.BasicGraphTransferable;
019:
020:        /**
021:         * An object that represents the clipboard contents for a graph selection.
022:         * The object has three representations:
023:         * <p>
024:         * 1. Richer: The cells, view attributes and connections for this selection are
025:         * stored as separate datastructures, which can be inserted using
026:         * the GraphModel.insert() method.
027:         * 2. HTML: If one cell is selected, the userObject is returned as HTML.
028:         * 3. Plain: The userObject of the selected cell is returned as plain text.
029:         *
030:         * @author Gaudenz Alder
031:         * @version 1.0 1/1/02
032:         *
033:         */
034:
035:        public class GraphTransferable extends BasicGraphTransferable implements 
036:                Serializable, ClipboardOwner {
037:
038:            /** Local Machine Reference Data Flavor. */
039:            public static DataFlavor dataFlavor;
040:
041:            /** Selected cells. */
042:            protected Object[] cells;
043:
044:            /** Object that describes the connection between cells. */
045:            protected ConnectionSet cs;
046:
047:            /** Object that describes the group structure between cells. */
048:            protected ParentMap pm;
049:
050:            /** (Cell, Map) entries that hold the view attributes for the cells. */
051:            protected Map attributeMap;
052:
053:            /** Rectangle that defines the former bounds of the views. */
054:            protected Rectangle2D bounds;
055:
056:            /**
057:             * Constructs a new transferable selection for <code>cells</code>,
058:             * <code>cs</code>and <code>attrMap</code>.
059:             */
060:            public GraphTransferable(Object[] cells, Map attrMap,
061:                    Rectangle2D bounds, ConnectionSet cs, ParentMap pm) {
062:
063:                attributeMap = attrMap;
064:                this .bounds = bounds;
065:                this .cells = cells;
066:                this .cs = cs;
067:                this .pm = pm;
068:            }
069:
070:            /**
071:             * Returns the <code>cells</code> that represent the selection.
072:             */
073:            public Object[] getCells() {
074:                return cells;
075:            }
076:
077:            /**
078:             * Returns the connections between <code>cells</code> (and possibly
079:             * other, unselected cells).
080:             */
081:            public ConnectionSet getConnectionSet() {
082:                return cs;
083:            }
084:
085:            public ParentMap getParentMap() {
086:                return pm;
087:            }
088:
089:            /**
090:             * Returns a map of (GraphCell, Map)-pairs that represent the
091:             * view attributes for the respecive cells.
092:             */
093:            public Map getAttributeMap() {
094:                return attributeMap;
095:            }
096:
097:            public Rectangle2D getBounds() {
098:                return bounds;
099:            }
100:
101:            // from ClipboardOwner
102:            public void lostOwnership(Clipboard clip, Transferable contents) {
103:                // do nothing
104:            }
105:
106:            // --- Richer ----------------------------------------------------------
107:
108:            /**
109:             * Returns the jvm-localreference flavors of the transferable.
110:             */
111:            public DataFlavor[] getRicherFlavors() {
112:                return new DataFlavor[] { dataFlavor };
113:            }
114:
115:            /**
116:             * Fetch the data in a jvm-localreference format.
117:             */
118:            public Object getRicherData(DataFlavor flavor)
119:                    throws UnsupportedFlavorException {
120:                if (flavor.equals(dataFlavor))
121:                    return this ;
122:                else
123:                    throw new UnsupportedFlavorException(flavor);
124:            }
125:
126:            // --- Plain ----------------------------------------------------------
127:
128:            /**
129:             * Returns true if the transferable support a text/plain format.
130:             */
131:            public boolean isPlainSupported() {
132:                return (cells != null && cells.length == 1);
133:            }
134:
135:            /**
136:             * Fetch the data in a text/plain format.
137:             */
138:            public String getPlainData() {
139:                if (cells[0] instanceof  DefaultGraphCell) {
140:                    Object obj = ((DefaultGraphCell) cells[0]).getUserObject();
141:                    if (obj != null)
142:                        return obj.toString();
143:                }
144:                return cells[0].toString();
145:            }
146:
147:            // --- HTML ---------------------------------------------------------
148:
149:            /**
150:             * Returns true if the transferable support a text/html format.
151:             */
152:            public boolean isHTMLSupported() {
153:                return isPlainSupported();
154:            }
155:
156:            /**
157:             * Fetch the data in a text/html format.
158:             */
159:            public String getHTMLData() {
160:                StringBuffer buf = new StringBuffer();
161:                buf.append("<html><body><p>");
162:                buf.append(getPlainData());
163:                buf.append("</p></body></html>");
164:                return buf.toString();
165:            }
166:
167:            /* Local Machine Reference Data Flavor. */
168:            static {
169:                DataFlavor localDataFlavor;
170:                try {
171:                    localDataFlavor = new DataFlavor(
172:                            DataFlavor.javaJVMLocalObjectMimeType
173:                                    + "; class=org.jgraph.graph.GraphTransferable");
174:                } catch (ClassNotFoundException cnfe) {
175:                    localDataFlavor = null;
176:                }
177:                dataFlavor = localDataFlavor;
178:            }
179:
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.