Source Code Cross Referenced for CursorProxy.java in  » GIS » udig-1.1 » net » refractions » udig » project » ui » internal » tool » display » 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 » GIS » udig 1.1 » net.refractions.udig.project.ui.internal.tool.display 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.refractions.udig.project.ui.internal.tool.display;
002:
003:        import net.refractions.udig.project.ui.tool.ModalTool;
004:
005:        import org.eclipse.core.runtime.IConfigurationElement;
006:        import org.eclipse.jface.resource.ImageDescriptor;
007:        import org.eclipse.swt.SWT;
008:        import org.eclipse.swt.graphics.Cursor;
009:        import org.eclipse.swt.widgets.Display;
010:        import org.eclipse.ui.PlatformUI;
011:        import org.eclipse.ui.plugin.AbstractUIPlugin;
012:
013:        /**
014:         * The cursor proxy allows for tool cursor images  to be loaded lazily. It acts as a proxy
015:         * for cursor image of the tool until the image is really needed to be displayed.
016:         * 
017:         * @author Vitalus
018:         * @since UDIG 1.1
019:         *
020:         */
021:        public class CursorProxy {
022:
023:            private volatile Cursor cursor;
024:            private String imagePath;
025:            private String hotspotX;
026:            private String hotspotY;
027:            private String cursorID;
028:            private String pluginID;
029:
030:            /**
031:             * The constructor to create custom cursor proxy from extention.
032:             * 
033:             * @param configuration
034:             */
035:            public CursorProxy(IConfigurationElement configuration) {
036:                if (configuration != null) {
037:                    imagePath = configuration.getAttribute("image"); //$NON-NLS-1$
038:                    hotspotX = configuration.getAttribute("hotspotX"); //$NON-NLS-1$
039:                    hotspotY = configuration.getAttribute("hotspotY"); //$NON-NLS-1$
040:                    cursorID = configuration.getAttribute("id"); //$NON-NLS-1$
041:                    pluginID = configuration.getNamespace();
042:                } else {
043:                    cursorID = ModalTool.DEFAULT_CURSOR;
044:                }
045:            }
046:
047:            /**
048:             * Returns cursor ID declared in extention point. 
049:             * ID is unique in extention registry.
050:             * 
051:             * @return
052:             */
053:            public String getID() {
054:                return cursorID;
055:            }
056:
057:            /**
058:             * @return Returns the SWT cursor object.
059:             */
060:            public Cursor getCursor() {
061:                if (cursor == null) {
062:                    synchronized (this ) {
063:                        if (cursor == null) {
064:                            if (imagePath == null) {
065:                                cursor = getSystemCursor(cursorID);
066:                            } else {
067:                                ImageDescriptor imageDescriptor = AbstractUIPlugin
068:                                        .imageDescriptorFromPlugin(pluginID,
069:                                                imagePath);
070:                                int x;
071:                                try {
072:                                    x = Integer.parseInt(hotspotX);
073:                                } catch (Exception e) {
074:                                    x = 0;
075:                                }
076:                                int y;
077:                                try {
078:                                    y = Integer.parseInt(hotspotY);
079:                                } catch (Exception e) {
080:                                    y = 0;
081:                                }
082:                                if (imageDescriptor == null
083:                                        || imageDescriptor.getImageData() == null)
084:                                    cursor = getSystemCursor(cursorID);
085:                                else
086:                                    cursor = new Cursor(Display.getDefault(),
087:                                            imageDescriptor.getImageData(), x,
088:                                            y);
089:                            }
090:                        }
091:                    }
092:                }
093:
094:                return cursor;
095:            }
096:
097:            /**
098:             * Returns system cursor object based on constants from <code>ModalTool</code>
099:             * interface. These constants are mapped to SWT cursor constants.
100:             * 
101:             * @param systemCursorID
102:             * @return
103:             */
104:            static Cursor getSystemCursor(String systemCursorID) {
105:                Display display = PlatformUI.getWorkbench().getDisplay();
106:                if (systemCursorID == null)
107:                    return display.getSystemCursor(SWT.CURSOR_ARROW);
108:
109:                if (systemCursorID.equals(ModalTool.CROSSHAIR_CURSOR))
110:                    return display.getSystemCursor(SWT.CURSOR_CROSS);
111:                if (systemCursorID.equals(ModalTool.E_RESIZE_CURSOR))
112:                    return display.getSystemCursor(SWT.CURSOR_SIZEE);
113:                if (systemCursorID.equals(ModalTool.HAND_CURSOR))
114:                    return display.getSystemCursor(SWT.CURSOR_HAND);
115:                if (systemCursorID.equals(ModalTool.MOVE_CURSOR))
116:                    return display.getSystemCursor(SWT.CURSOR_SIZEALL);
117:                if (systemCursorID.equals(ModalTool.N_RESIZE_CURSOR))
118:                    return display.getSystemCursor(SWT.CURSOR_SIZEN);
119:                if (systemCursorID.equals(ModalTool.NE_RESIZE_CURSOR))
120:                    return display.getSystemCursor(SWT.CURSOR_SIZENE);
121:                if (systemCursorID.equals(ModalTool.NW_RESIZE_CURSOR))
122:                    return display.getSystemCursor(SWT.CURSOR_SIZENW);
123:                if (systemCursorID.equals(ModalTool.S_RESIZE_CURSOR))
124:                    return display.getSystemCursor(SWT.CURSOR_SIZES);
125:                if (systemCursorID.equals(ModalTool.SE_RESIZE_CURSOR))
126:                    return display.getSystemCursor(SWT.CURSOR_SIZESE);
127:                if (systemCursorID.equals(ModalTool.SW_RESIZE_CURSOR))
128:                    return display.getSystemCursor(SWT.CURSOR_SIZESW);
129:                if (systemCursorID.equals(ModalTool.TEXT_CURSOR))
130:                    return display.getSystemCursor(SWT.CURSOR_IBEAM);
131:                if (systemCursorID.equals(ModalTool.W_RESIZE_CURSOR))
132:                    return display.getSystemCursor(SWT.CURSOR_SIZESW);
133:                if (systemCursorID.equals(ModalTool.WAIT_CURSOR))
134:                    return display.getSystemCursor(SWT.CURSOR_WAIT);
135:
136:                if (systemCursorID.equals(ModalTool.NO_CURSOR))
137:                    return display.getSystemCursor(SWT.CURSOR_NO);
138:
139:                return display.getSystemCursor(SWT.CURSOR_ARROW);
140:            }
141:
142:            /**
143:             * Dispose the cursor.
144:             */
145:            public void dispose() {
146:                if (cursor != null)
147:                    cursor.dispose();
148:                cursor = null;
149:            }
150:        }
w_ww.__j___a__v_a2s__.___c___om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.