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


001:        /*
002:         * Copyright 2005-2008 Kirill Grouchnikov, based on work by
003:         * Sun Microsystems, Inc. All rights reserved.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
018:         */
019:        package org.jvnet.substance.swingx;
020:
021:        import java.awt.*;
022:        import java.awt.event.MouseEvent;
023:
024:        import javax.swing.*;
025:        import javax.swing.border.*;
026:        import javax.swing.plaf.ComponentUI;
027:
028:        import org.jdesktop.swingx.JXTaskPane;
029:        import org.jdesktop.swingx.icon.EmptyIcon;
030:        import org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI;
031:        import org.jvnet.lafwidget.animation.*;
032:        import org.jvnet.substance.SubstanceImageCreator;
033:        import org.jvnet.substance.painter.highlight.SubstanceHighlightUtils;
034:        import org.jvnet.substance.theme.SubstanceTheme;
035:        import org.jvnet.substance.utils.*;
036:        import org.jvnet.substance.utils.icon.TransitionAwareIcon;
037:
038:        /**
039:         * Substance-consistent UI delegate for {@link JXTaskPane}.
040:         * 
041:         * @author Kirill Grouchnikov
042:         */
043:        public class SubstanceTaskPaneUI extends BasicTaskPaneUI implements 
044:                Trackable {
045:            /**
046:             * Background delegate.
047:             */
048:            private SubstanceSwingxFillBackgroundDelegate bgDelegate;
049:
050:            // /**
051:            // * Delegate for painting the background.
052:            // */
053:            // private SubstanceHighlightUtils headerGradientDelegate;
054:
055:            /**
056:             * Listener for thumb fade animations.
057:             */
058:            private RolloverControlListener substanceRolloverListener;
059:
060:            /**
061:             * Listener for fade animations.
062:             */
063:            protected FadeStateListener substanceFadeStateListener;
064:
065:            /**
066:             * Surrogate model for the fade effects on the title pane border.
067:             */
068:            protected ButtonModel taskPaneModel;
069:
070:            // private static int CONTROL_HEIGHT = 22;
071:
072:            public static ComponentUI createUI(JComponent c) {
073:                return new SubstanceTaskPaneUI();
074:            }
075:
076:            /**
077:             * Creates a new UI delegate.
078:             */
079:            public SubstanceTaskPaneUI() {
080:                super ();
081:                this .bgDelegate = new SubstanceSwingxFillBackgroundDelegate();
082:                // this.headerGradientDelegate = new SubstanceHighlightUtils();
083:
084:                this .taskPaneModel = new DefaultButtonModel();
085:                this .taskPaneModel.setArmed(false);
086:                this .taskPaneModel.setSelected(false);
087:                this .taskPaneModel.setPressed(false);
088:                this .taskPaneModel.setRollover(false);
089:
090:            }
091:
092:            /*
093:             * (non-Javadoc)
094:             * 
095:             * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI#installListeners()
096:             */
097:            @Override
098:            protected void installListeners() {
099:                super .installListeners();
100:
101:                this .substanceRolloverListener = new RolloverControlListener(
102:                        this , this .taskPaneModel);
103:                this .group.addMouseListener(this .substanceRolloverListener);
104:                this .group
105:                        .addMouseMotionListener(this .substanceRolloverListener);
106:
107:                this .substanceFadeStateListener = new FadeStateListener(
108:                        this .group, this .taskPaneModel, SubstanceCoreUtilities
109:                                .getFadeCallback(this .group,
110:                                        this .taskPaneModel, true, false));
111:                this .substanceFadeStateListener.registerListeners(false);
112:            }
113:
114:            /*
115:             * (non-Javadoc)
116:             * 
117:             * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI#uninstallListeners()
118:             */
119:            @Override
120:            protected void uninstallListeners() {
121:                this .group.removeMouseListener(this .substanceRolloverListener);
122:                this .group
123:                        .removeMouseMotionListener(this .substanceRolloverListener);
124:                this .substanceRolloverListener = null;
125:
126:                this .substanceFadeStateListener.unregisterListeners();
127:                this .substanceFadeStateListener = null;
128:
129:                super .uninstallListeners();
130:            }
131:
132:            /*
133:             * (non-Javadoc)
134:             * 
135:             * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI#createPaneBorder()
136:             */
137:            @Override
138:            protected Border createPaneBorder() {
139:                return new SubstancePaneBorder();
140:            }
141:
142:            /*
143:             * (non-Javadoc)
144:             * 
145:             * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI#createContentPaneBorder()
146:             */
147:            @Override
148:            protected Border createContentPaneBorder() {
149:                return new CompoundBorder(new LineBorder(
150:                        SubstanceThemeUtilities.getTheme(group,
151:                                ComponentState.DEFAULT).getColorScheme()
152:                                .getMidColor()), new EmptyBorder(1, 2, 2, 2));
153:            }
154:
155:            /**
156:             * Pane border for task pane.
157:             * 
158:             * @author Kirill Grouchnikov
159:             */
160:            protected class SubstancePaneBorder extends PaneBorder {
161:                protected Icon expandedIcon;
162:
163:                protected Icon collapsedIcon;
164:
165:                /**
166:                 * Creates a new pane border.
167:                 */
168:                public SubstancePaneBorder() {
169:                    this .borderColor = SubstanceThemeUtilities.getTheme(group,
170:                            ComponentState.DEFAULT).getColorScheme()
171:                            .getMidColor();
172:                    this .expandedIcon = new TransitionAwareIcon(group,
173:                            taskPaneModel, new TransitionAwareIcon.Delegate() {
174:                                public Icon getThemeIcon(SubstanceTheme theme) {
175:                                    return SubstanceImageCreator
176:                                            .getDoubleArrowIcon(
177:                                                    SubstanceSizeUtils
178:                                                            .getComponentFontSize(group),
179:                                                    0, 2, 0,
180:                                                    SwingConstants.NORTH, theme);
181:                                }
182:                            });
183:                    this .collapsedIcon = new TransitionAwareIcon(group,
184:                            taskPaneModel, new TransitionAwareIcon.Delegate() {
185:                                public Icon getThemeIcon(SubstanceTheme theme) {
186:                                    return SubstanceImageCreator
187:                                            .getDoubleArrowIcon(
188:                                                    SubstanceSizeUtils
189:                                                            .getComponentFontSize(group),
190:                                                    0, 2, 0,
191:                                                    SwingConstants.SOUTH, theme);
192:                                }
193:                            });
194:                }
195:
196:                /*
197:                 * (non-Javadoc)
198:                 * 
199:                 * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI$PaneBorder#paintTitleBackground(org.jdesktop.swingx.JXTaskPane,
200:                 *      java.awt.Graphics)
201:                 */
202:                @Override
203:                protected void paintTitleBackground(JXTaskPane group, Graphics g) {
204:                    // boolean isPaintedActive = /* group.isSpecial() || */mouseOver;
205:
206:                    // boolean isUnderFade = FadeTracker.getInstance().isTracked(group,
207:                    // FadeKind.ROLLOVER);
208:                    // SubstanceTheme defaultTheme = SubstanceCoreUtilities
209:                    // .getDefaultTheme(group, true, true);
210:                    // SubstanceTheme activeTheme =
211:                    // SubstanceCoreUtilities.getActiveTheme(
212:                    // group, true, true);
213:                    Graphics2D graphics = (Graphics2D) g.create();
214:                    ComponentState currState = ComponentState.getState(
215:                            taskPaneModel, group);
216:                    ComponentState prevState = SubstanceCoreUtilities
217:                            .getPrevComponentState(group);
218:                    SubstanceTheme currTheme = SubstanceThemeUtilities
219:                            .getTheme(group, currState);
220:                    SubstanceTheme prevTheme = SubstanceThemeUtilities
221:                            .getTheme(group, prevState);
222:
223:                    FadeState state = SubstanceFadeUtilities.getFadeState(
224:                            group, FadeKind.ROLLOVER);
225:                    float fadeCoef = 0.0f;
226:                    if (state != null) {
227:                        fadeCoef = state.getFadePosition();
228:
229:                        if (state.isFadingIn())
230:                            fadeCoef = 10.0f - fadeCoef;
231:                    }
232:                    SubstanceHighlightUtils.paintHighlight(g, group,
233:                            new Rectangle(0, 0, group.getWidth(),
234:                                    getTitleHeight()), 0.5f, null, currTheme
235:                                    .getColorScheme(), prevTheme
236:                                    .getColorScheme(), fadeCoef);
237:                    graphics.dispose();
238:                }
239:
240:                /*
241:                 * (non-Javadoc)
242:                 * 
243:                 * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI$PaneBorder#getPaintColor(org.jdesktop.swingx.JXTaskPane)
244:                 */
245:                @Override
246:                protected Color getPaintColor(JXTaskPane group) {
247:                    ComponentState state = ComponentState.getState(
248:                            taskPaneModel, group);
249:                    ComponentState prevState = SubstanceCoreUtilities
250:                            .getPrevComponentState(group);
251:
252:                    return SubstanceCoreUtilities
253:                            .getInterpolatedForegroundColor(group, null,
254:                                    SubstanceThemeUtilities.getTheme(group,
255:                                            state), state, prevState,
256:                                    FadeKind.ROLLOVER, FadeKind.SELECTION,
257:                                    FadeKind.PRESS);
258:                }
259:
260:                /*
261:                 * (non-Javadoc)
262:                 * 
263:                 * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI$PaneBorder#paintExpandedControls(org.jdesktop.swingx.JXTaskPane,
264:                 *      java.awt.Graphics, int, int, int, int)
265:                 */
266:                @Override
267:                protected void paintExpandedControls(JXTaskPane group,
268:                        Graphics g, int x, int y, int width, int height) {
269:                    Icon arrowIcon = group.isExpanded() ? expandedIcon
270:                            : collapsedIcon;
271:                    int arrowIconHeight = arrowIcon.getIconHeight();
272:                    arrowIcon.paintIcon(group, g, x + 3, y
273:                            + (height - arrowIconHeight) / 2);
274:                }
275:
276:                /*
277:                 * (non-Javadoc)
278:                 * 
279:                 * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI$PaneBorder#isMouseOverBorder()
280:                 */
281:                @Override
282:                protected boolean isMouseOverBorder() {
283:                    return true;
284:                }
285:
286:                /*
287:                 * (non-Javadoc)
288:                 * 
289:                 * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI$PaneBorder#paintFocus(java.awt.Graphics,
290:                 *      java.awt.Color, int, int, int, int)
291:                 */
292:                @Override
293:                protected void paintFocus(Graphics g, Color paintColor, int x,
294:                        int y, int width, int height) {
295:                    SubstanceCoreUtilities.paintFocus(g, group, group,
296:                            new Rectangle(x, y, width - 1, height - 1), label
297:                                    .getBounds(), 1.0f, 0);
298:                }
299:
300:                /*
301:                 * (non-Javadoc)
302:                 * 
303:                 * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI$PaneBorder#configureLabel(org.jdesktop.swingx.JXTaskPane)
304:                 */
305:                @Override
306:                protected void configureLabel(JXTaskPane group) {
307:                    label.applyComponentOrientation(group
308:                            .getComponentOrientation());
309:                    label.setFont(group.getFont());
310:                    label.setText(group.getTitle());
311:                    label.setIcon(group.getIcon() == null ? new EmptyIcon()
312:                            : group.getIcon());
313:                }
314:            }
315:
316:            /*
317:             * (non-Javadoc)
318:             * 
319:             * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics,
320:             *      javax.swing.JComponent)
321:             */
322:            @Override
323:            public void paint(Graphics g, JComponent c) {
324:                this .bgDelegate.paint(c, (Graphics2D) g, false);
325:                super .paint(g, c);
326:            }
327:
328:            /*
329:             * (non-Javadoc)
330:             * 
331:             * @see org.jvnet.substance.utils.Trackable#isInside(java.awt.event.MouseEvent)
332:             */
333:            public boolean isInside(MouseEvent me) {
334:                return this .isInBorder(me);
335:            }
336:
337:            /*
338:             * (non-Javadoc)
339:             * 
340:             * @see org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI#getTitleHeight()
341:             */
342:            @Override
343:            protected int getTitleHeight() {
344:                return SubstanceSizeUtils.getAdjustedSize(SubstanceSizeUtils
345:                        .getComponentFontSize(this .group), super 
346:                        .getTitleHeight(), 2, 3, false);
347:            }
348:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.