Source Code Cross Referenced for SubstanceDesktopIconUI.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » 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 » substance look feel » org.jvnet.substance 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         *  o Redistributions of source code must retain the above copyright notice,
008:         *    this list of conditions and the following disclaimer.
009:         *
010:         *  o Redistributions in binary form must reproduce the above copyright notice,
011:         *    this list of conditions and the following disclaimer in the documentation
012:         *    and/or other materials provided with the distribution.
013:         *
014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of
015:         *    its contributors may be used to endorse or promote products derived
016:         *    from this software without specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package org.jvnet.substance;
031:
032:        import java.awt.*;
033:
034:        import javax.swing.JComponent;
035:        import javax.swing.UIManager;
036:        import javax.swing.event.MouseInputListener;
037:        import javax.swing.plaf.ComponentUI;
038:        import javax.swing.plaf.UIResource;
039:        import javax.swing.plaf.basic.BasicDesktopIconUI;
040:
041:        import org.jvnet.substance.utils.*;
042:
043:        /**
044:         * UI for desktop icons in <b>Substance</b> look and feel.
045:         * 
046:         * @author Kirill Grouchnikov
047:         */
048:        public class SubstanceDesktopIconUI extends BasicDesktopIconUI {
049:            /**
050:             * Listener on the title label (for the dragging purposes).
051:             */
052:            private MouseInputListener substanceLabelMouseInputListener;
053:
054:            /**
055:             * Width of minimized component (desktop icon).
056:             */
057:            private int width;
058:
059:            /*
060:             * (non-Javadoc)
061:             * 
062:             * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
063:             */
064:            public static ComponentUI createUI(JComponent c) {
065:                return new SubstanceDesktopIconUI();
066:            }
067:
068:            /*
069:             * (non-Javadoc)
070:             * 
071:             * @see javax.swing.plaf.basic.BasicDesktopIconUI#installDefaults()
072:             */
073:            @Override
074:            protected void installDefaults() {
075:                super .installDefaults();
076:                Font f = this .desktopIcon.getFont();
077:                if ((f == null) || (f instanceof  UIResource)) {
078:                    this .desktopIcon.setFont(UIManager
079:                            .getFont("DesktopIcon.font"));
080:                }
081:                this .width = UIManager.getInt("DesktopIcon.width");
082:                this .desktopIcon.setBackground(SubstanceThemeUtilities
083:                        .getTheme(this .desktopIcon.getInternalFrame(),
084:                                ComponentState.ACTIVE).getBackgroundColor());
085:            }
086:
087:            /*
088:             * (non-Javadoc)
089:             * 
090:             * @see javax.swing.plaf.basic.BasicDesktopIconUI#installComponents()
091:             */
092:            @Override
093:            protected void installComponents() {
094:                this .frame = this .desktopIcon.getInternalFrame();
095:                // this.frame.setOpaque(false);
096:                // Icon icon = this.frame.getFrameIcon();
097:
098:                this .iconPane = new SubstanceInternalFrameTitlePane(this .frame);
099:                this .iconPane.setOpaque(false);
100:                this .desktopIcon.setLayout(new BorderLayout());
101:                this .desktopIcon.add(this .iconPane, BorderLayout.CENTER);
102:            }
103:
104:            /*
105:             * (non-Javadoc)
106:             * 
107:             * @see javax.swing.plaf.basic.BasicDesktopIconUI#uninstallComponents()
108:             */
109:            @Override
110:            protected void uninstallComponents() {
111:                ((SubstanceInternalFrameTitlePane) this .iconPane).uninstall();
112:
113:                this .desktopIcon.setLayout(null);
114:                this .desktopIcon.remove(this .iconPane);
115:
116:                this .frame = null;
117:            }
118:
119:            /*
120:             * (non-Javadoc)
121:             * 
122:             * @see javax.swing.plaf.basic.BasicDesktopIconUI#installListeners()
123:             */
124:            @Override
125:            protected void installListeners() {
126:                super .installListeners();
127:                this .substanceLabelMouseInputListener = this 
128:                        .createMouseInputListener();
129:                this .iconPane
130:                        .addMouseMotionListener(this .substanceLabelMouseInputListener);
131:                this .iconPane
132:                        .addMouseListener(this .substanceLabelMouseInputListener);
133:            }
134:
135:            /*
136:             * (non-Javadoc)
137:             * 
138:             * @see javax.swing.plaf.basic.BasicDesktopIconUI#uninstallListeners()
139:             */
140:            @Override
141:            protected void uninstallListeners() {
142:                ((SubstanceInternalFrameTitlePane) this .iconPane)
143:                        .uninstallListeners();
144:
145:                this .iconPane
146:                        .removeMouseMotionListener(this .substanceLabelMouseInputListener);
147:                this .iconPane
148:                        .removeMouseListener(this .substanceLabelMouseInputListener);
149:                this .substanceLabelMouseInputListener = null;
150:
151:                super .uninstallListeners();
152:            }
153:
154:            /*
155:             * (non-Javadoc)
156:             * 
157:             * @see javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent)
158:             */
159:            @Override
160:            public Dimension getPreferredSize(JComponent c) {
161:                // Desktop icons can not be resized. Their dimensions should
162:                // always be the minimum size. See getMinimumSize(JComponent c).
163:                return this .getMinimumSize(c);
164:            }
165:
166:            /*
167:             * (non-Javadoc)
168:             * 
169:             * @see javax.swing.plaf.ComponentUI#getMinimumSize(javax.swing.JComponent)
170:             */
171:            @Override
172:            public Dimension getMinimumSize(JComponent c) {
173:                // For the desktop icon we will use the layout maanger to
174:                // determine the correct height of the component, but we want to keep
175:                // the width consistent according to the jlf spec.
176:                return new Dimension(this .width, this .desktopIcon.getLayout()
177:                        .minimumLayoutSize(this .desktopIcon).height);
178:            }
179:
180:            /*
181:             * (non-Javadoc)
182:             * 
183:             * @see javax.swing.plaf.ComponentUI#getMaximumSize(javax.swing.JComponent)
184:             */
185:            @Override
186:            public Dimension getMaximumSize(JComponent c) {
187:                // Desktop icons can not be resized. Their dimensions should
188:                // always be the minimum size. See getMinimumSize(JComponent c).
189:                return this .getMinimumSize(c);
190:            }
191:
192:            // /*
193:            // * (non-Javadoc)
194:            // *
195:            // * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics,
196:            // * javax.swing.JComponent)
197:            // */
198:            // @Override
199:            // public void paint(Graphics g, JComponent c) {
200:            // JInternalFrame.JDesktopIcon di = (JInternalFrame.JDesktopIcon) c;
201:            // di.setOpaque(false);
202:            //
203:            // int width = di.getWidth();
204:            // int height = di.getHeight();
205:            //
206:            // Graphics2D graphics = (Graphics2D) g.create();
207:            // // the background is translucent
208:            // // graphics.setComposite(AlphaComposite.getInstance(
209:            // // AlphaComposite.SRC_ATOP, 0.6f));
210:            // //
211:            // // SubstanceImageCreator.paintRectangularBackground(graphics, 0, 0,
212:            // // width,
213:            // // height, SubstanceCoreUtilities.getActiveScheme(this.desktopIcon
214:            // // .getInternalFrame()), false, false);
215:            //
216:            // di.paintComponents(graphics);
217:            //
218:            // graphics.dispose();
219:            // }
220:            //
221:            // /*
222:            // * (non-Javadoc)
223:            // *
224:            // * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics,
225:            // * javax.swing.JComponent)
226:            // */
227:            // @Override
228:            // public void update(Graphics g, JComponent c) {
229:            // this.paint(g, c);
230:            // }
231:            //
232:            /*
233:             * (non-Javadoc)
234:             * 
235:             * @see javax.swing.plaf.basic.BasicDesktopIconUI#installUI(javax.swing.JComponent)
236:             */
237:            @Override
238:            public void installUI(JComponent c) {
239:                super .installUI(c);
240:                c.setOpaque(false);
241:            }
242:
243:            @Override
244:            public void uninstallUI(JComponent c) {
245:                // desktopIcon.remove(this.titleLabel);
246:                // super.uninstallUI(c);
247:
248:                SubstanceInternalFrameTitlePane thePane = (SubstanceInternalFrameTitlePane) this .iconPane;
249:                super .uninstallUI(c);
250:                thePane.uninstallListeners();
251:            }
252:
253:            /**
254:             * Returns the component for desktop icon hover (internal frame preview)
255:             * functionality.
256:             * 
257:             * @return The component for desktop icon hover (internal frame preview)
258:             *         functionality.
259:             */
260:            public JComponent getComponentForHover() {
261:                return this.iconPane;
262:            }
263:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.