Source Code Cross Referenced for JideCursors.java in  » Swing-Library » jide-common » com » jidesoft » swing » 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 » Swing Library » jide common » com.jidesoft.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)JideCursors.java
003:         *
004:         * Copyright 2002 JIDE Software Inc. All rights reserved.
005:         */
006:        package com.jidesoft.swing;
007:
008:        import com.jidesoft.plaf.UIDefaultsLookup;
009:
010:        import javax.swing.*;
011:        import java.awt.*;
012:
013:        /**
014:         * A utility class that create additional cursors used by JIDE products.
015:         * <p/>
016:         * Notes: this class has to be public so that JIDE can use it in different packages,
017:         * not meant to release to end user as a public API. JIDE will not gurantee the class
018:         * will remain as it is.
019:         */
020:        public class JideCursors {
021:
022:            /**
023:             * First id of Cursors used in JIDE products.
024:             */
025:            public static final int FIRST_CUSTOM_CURSOR = 20;
026:
027:            /**
028:             * The horizontal split cursor type.
029:             */
030:            public static final int HSPLIT_CURSOR = 20;
031:
032:            /**
033:             * The vertical split cursor type.
034:             */
035:            public static final int VSPLIT_CURSOR = 21;
036:
037:            /**
038:             * The drag cursor type.
039:             */
040:            public static final int DRAG_CURSOR = 22;
041:
042:            /**
043:             * The no-drop cursor type.
044:             */
045:            public static final int DRAG_STOP_CURSOR = 23;
046:
047:            /**
048:             * The cursor point pointing to north side.
049:             */
050:            public static final int NORTH_CURSOR = 24;
051:
052:            /**
053:             * The cursor point pointing to south side.
054:             */
055:            public static final int SOUTH_CURSOR = 25;
056:
057:            /**
058:             * The cursor point pointing to east side.
059:             */
060:            public static final int EAST_CURSOR = 26;
061:
062:            /**
063:             * The cursor point pointing to west side.
064:             */
065:            public static final int WEST_CURSOR = 27;
066:
067:            /**
068:             * The cursor point pointing when dragged item will be in tabbed pane.
069:             */
070:            public static final int TAB_CURSOR = 28;
071:
072:            /**
073:             * The cursor point when dragged item is floating.
074:             */
075:            public static final int FLOAT_CURSOR = 29;
076:
077:            /**
078:             * The cursor point when dragged item will be inserted in between.
079:             */
080:            public static final int VERTICAL_CURSOR = 30;
081:
082:            /**
083:             * The cursor point when dragged item will be inserted in between.
084:             */
085:            public static final int HORIZONTAL_CURSOR = 31;
086:
087:            /**
088:             * The cursor point when dragged item will be inserted in between.
089:             */
090:            public static final int DELETE_CURSOR = 32;
091:
092:            /**
093:             * The drag cursor type for text.
094:             */
095:            public static final int DRAG_TEXT_CURSOR = 33;
096:
097:            /**
098:             * The no-drop cursor type for text.
099:             */
100:            public static final int DRAG_TEXT_STOP_CURSOR = 34;
101:
102:            /**
103:             * Last id of cursor used by JIDE products.
104:             */
105:            public static final int LAST_CUSTOM_CURSOR = 35;
106:
107:            private static final Cursor[] predefined = new Cursor[LAST_CUSTOM_CURSOR
108:                    - FIRST_CUSTOM_CURSOR + 1];
109:
110:            static {
111:                for (int i = FIRST_CUSTOM_CURSOR; i < LAST_CUSTOM_CURSOR; i++)
112:                    getPredefinedCursor(i);
113:            }
114:
115:            /**
116:             * Returns a cursor object with the specified predefined type.
117:             *
118:             * @param type the type of predefined cursor
119:             * @throws IllegalArgumentException if the specified cursor type is
120:             *                                  invalid
121:             */
122:            static public Cursor getPredefinedCursor(int type) {
123:                if (type < FIRST_CUSTOM_CURSOR || type > LAST_CUSTOM_CURSOR) {
124:                    throw new IllegalArgumentException("illegal cursor type");
125:                }
126:                if (predefined[type - FIRST_CUSTOM_CURSOR] == null) {
127:                    predefined[type - FIRST_CUSTOM_CURSOR] = createCursor(type);
128:                }
129:                return predefined[type - FIRST_CUSTOM_CURSOR];
130:            }
131:
132:            /**
133:             * Creates a cursor specified by type.
134:             *
135:             * @param type cursor type
136:             * @return the cursor with that type
137:             */
138:            protected static Cursor createCursor(int type) {
139:                Toolkit toolkit = Toolkit.getDefaultToolkit();
140:                Dimension bestSize = toolkit.getBestCursorSize(32, 32);
141:                int maxColor = toolkit.getMaximumCursorColors();
142:                switch (type) {
143:                case HSPLIT_CURSOR: {
144:                    if (bestSize.width != 0 && maxColor > 3) {
145:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
146:                                .getIcon("Cursor.hsplit");
147:                        if (icon == null)
148:                            return Cursor
149:                                    .getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
150:                        return toolkit.createCustomCursor(icon.getImage(),
151:                                new Point(15, 15), "Horizonal Split");
152:                    }
153:                    return Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
154:                }
155:                case VSPLIT_CURSOR: {
156:                    if (bestSize.width != 0 && maxColor > 3) {
157:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
158:                                .getIcon("Cursor.vsplit");
159:                        if (icon == null)
160:                            return Cursor
161:                                    .getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
162:                        return toolkit.createCustomCursor(icon.getImage(),
163:                                new Point(15, 15), "Vertical Split");
164:                    }
165:                    return Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
166:                }
167:                case DRAG_CURSOR: {
168:                    if (bestSize.width != 0 && maxColor > 3) {
169:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
170:                                .getIcon("Cursor.drag");
171:                        if (icon == null)
172:                            return Cursor.getDefaultCursor();
173:                        return toolkit.createCustomCursor(icon.getImage(),
174:                                new Point(17, 12), "Drag");
175:                    }
176:                    return Cursor.getDefaultCursor();
177:                }
178:                case DRAG_STOP_CURSOR: {
179:                    if (bestSize.width != 0 && maxColor > 3) {
180:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
181:                                .getIcon("Cursor.dragStop");
182:                        if (icon == null)
183:                            return Cursor.getDefaultCursor();
184:                        return toolkit.createCustomCursor(icon.getImage(),
185:                                new Point(17, 12), "Drag Stop");
186:                    }
187:                    return Cursor.getDefaultCursor();
188:                }
189:                case DRAG_TEXT_CURSOR: {
190:                    if (bestSize.width != 0 && maxColor > 3) {
191:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
192:                                .getIcon("Cursor.dragText");
193:                        if (icon == null)
194:                            return Cursor.getDefaultCursor();
195:                        return toolkit.createCustomCursor(icon.getImage(),
196:                                new Point(0, 0), "Drag Text");
197:                    }
198:                    return Cursor.getDefaultCursor();
199:                }
200:                case DRAG_TEXT_STOP_CURSOR: {
201:                    if (bestSize.width != 0 && maxColor > 3) {
202:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
203:                                .getIcon("Cursor.dragTextStop");
204:                        if (icon == null)
205:                            return Cursor.getDefaultCursor();
206:                        return toolkit.createCustomCursor(icon.getImage(),
207:                                new Point(15, 15), "Drag Text Stop");
208:                    }
209:                    return Cursor.getDefaultCursor();
210:                }
211:                case NORTH_CURSOR: {
212:                    if (bestSize.width != 0 && maxColor > 3) {
213:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
214:                                .getIcon("Cursor.north");
215:                        if (icon == null)
216:                            return Cursor.getDefaultCursor();
217:                        return toolkit.createCustomCursor(icon.getImage(),
218:                                new Point(15, 10), "North");
219:                    }
220:                    return Cursor.getDefaultCursor();
221:                }
222:                case SOUTH_CURSOR: {
223:                    if (bestSize.width != 0 && maxColor > 3) {
224:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
225:                                .getIcon("Cursor.south");
226:                        if (icon == null)
227:                            return Cursor.getDefaultCursor();
228:                        return toolkit.createCustomCursor(icon.getImage(),
229:                                new Point(15, 20), "South");
230:                    }
231:                    return Cursor.getDefaultCursor();
232:                }
233:                case EAST_CURSOR: {
234:                    if (bestSize.width != 0 && maxColor > 3) {
235:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
236:                                .getIcon("Cursor.east");
237:                        if (icon == null)
238:                            return Cursor.getDefaultCursor();
239:                        return toolkit.createCustomCursor(icon.getImage(),
240:                                new Point(20, 15), "East");
241:                    }
242:                    return Cursor.getDefaultCursor();
243:                }
244:                case WEST_CURSOR: {
245:                    if (bestSize.width != 0 && maxColor > 3) {
246:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
247:                                .getIcon("Cursor.west");
248:                        if (icon == null)
249:                            return Cursor.getDefaultCursor();
250:                        return toolkit.createCustomCursor(icon.getImage(),
251:                                new Point(10, 15), "West");
252:                    }
253:                    return Cursor.getDefaultCursor();
254:                }
255:                case TAB_CURSOR: {
256:                    if (bestSize.width != 0 && maxColor > 3) {
257:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
258:                                .getIcon("Cursor.tab");
259:                        if (icon == null)
260:                            return Cursor.getDefaultCursor();
261:                        return toolkit.createCustomCursor(icon.getImage(),
262:                                new Point(15, 15), "Tabbed");
263:                    }
264:                    return Cursor.getDefaultCursor();
265:                }
266:                case FLOAT_CURSOR: {
267:                    if (bestSize.width != 0 && maxColor > 3) {
268:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
269:                                .getIcon("Cursor.float");
270:                        if (icon == null)
271:                            return Cursor.getDefaultCursor();
272:                        return toolkit.createCustomCursor(icon.getImage(),
273:                                new Point(15, 15), "Floating");
274:                    }
275:                    return Cursor.getDefaultCursor();
276:                }
277:                case VERTICAL_CURSOR: {
278:                    if (bestSize.width != 0 && maxColor > 3) {
279:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
280:                                .getIcon("Cursor.vertical");
281:                        if (icon == null)
282:                            return Cursor.getDefaultCursor();
283:                        return toolkit.createCustomCursor(icon.getImage(),
284:                                new Point(15, 15), "Vertical");
285:                    }
286:                    return Cursor.getDefaultCursor();
287:                }
288:                case HORIZONTAL_CURSOR: {
289:                    if (bestSize.width != 0 && maxColor > 3) {
290:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
291:                                .getIcon("Cursor.horizontal");
292:                        if (icon == null)
293:                            return Cursor.getDefaultCursor();
294:                        return toolkit.createCustomCursor(icon.getImage(),
295:                                new Point(15, 15), "Horizontal");
296:                    }
297:                    return Cursor.getDefaultCursor();
298:                }
299:                case DELETE_CURSOR: {
300:                    if (bestSize.width != 0 && maxColor > 3) {
301:                        ImageIcon icon = (ImageIcon) UIDefaultsLookup
302:                                .getIcon("Cursor.delete");
303:                        if (icon == null)
304:                            return Cursor.getDefaultCursor();
305:                        return toolkit.createCustomCursor(icon.getImage(),
306:                                new Point(10, 10), "Delete");
307:                    }
308:                    return Cursor.getDefaultCursor();
309:                }
310:                }
311:                return null;
312:            }
313:
314:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.