Source Code Cross Referenced for WinXPEditorTabDisplayerUI.java in  » IDE-Netbeans » library » org » netbeans » swing » tabcontrol » plaf » 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 » IDE Netbeans » library » org.netbeans.swing.tabcontrol.plaf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.swing.tabcontrol.plaf;
043:
044:        import java.awt.Dimension;
045:        import java.awt.Font;
046:        import java.awt.FontMetrics;
047:        import java.awt.Graphics;
048:        import java.awt.Insets;
049:        import java.awt.Rectangle;
050:        import org.netbeans.swing.tabcontrol.TabDisplayer;
051:
052:        import javax.swing.plaf.ComponentUI;
053:        import java.util.HashMap;
054:        import java.util.Map;
055:        import javax.swing.Icon;
056:        import javax.swing.JComponent;
057:        import javax.swing.UIManager;
058:
059:        /**
060:         * Windows xp impl of tabs ui
061:         *
062:         * @author Tim Boudreau
063:         */
064:        public final class WinXPEditorTabDisplayerUI extends
065:                BasicScrollingTabDisplayerUI {
066:
067:            private static final Rectangle scratch5 = new Rectangle();
068:            private static Map<Integer, String[]> buttonIconPaths;
069:
070:            public WinXPEditorTabDisplayerUI(TabDisplayer displayer) {
071:                super (displayer);
072:            }
073:
074:            public static ComponentUI createUI(JComponent c) {
075:                return new WinXPEditorTabDisplayerUI((TabDisplayer) c);
076:            }
077:
078:            @Override
079:            public Dimension getPreferredSize(JComponent c) {
080:                int prefHeight = 24;
081:                Graphics g = BasicScrollingTabDisplayerUI
082:                        .getOffscreenGraphics();
083:                if (g != null) {
084:                    FontMetrics fm = g.getFontMetrics(displayer.getFont());
085:                    Insets ins = getTabAreaInsets();
086:                    prefHeight = fm.getHeight() + ins.top + ins.bottom + 8;
087:                }
088:                return new Dimension(displayer.getWidth(), prefHeight);
089:            }
090:
091:            @Override
092:            protected Font createFont() {
093:                return UIManager.getFont("Label.font"); //NOI18N
094:            }
095:
096:            @Override
097:            public void paintBackground(Graphics g) {
098:                g.setColor(displayer.getBackground());
099:                g.fillRect(0, 0, displayer.getWidth(), displayer.getHeight());
100:            }
101:
102:            @Override
103:            protected void paintAfterTabs(Graphics g) {
104:                Rectangle r = new Rectangle();
105:                getTabsVisibleArea(r);
106:                r.width = displayer.getWidth();
107:
108:                Insets ins = getTabAreaInsets();
109:
110:                int y = displayer.getHeight()
111:                        - WinXPEditorTabCellRenderer.BOTTOM_INSET;
112:                //Draw the fill line that will be under the white highlight line - this
113:                //goes across the whole component.
114:                int selEnd = 0;
115:                int i = selectionModel.getSelectedIndex();
116:                g.setColor(WinXPEditorTabCellRenderer
117:                        .getSelectedTabBottomLineColor());
118:                g.drawLine(0, y + 1, displayer.getWidth(), y + 1);
119:
120:                //Draw the white highlight under all tabs but the selected one:
121:
122:                //Check if we will need to draw a white line from the left edge to the 
123:                //selection, and another from the left edge of the selection to the
124:                //end of the control, skipping the selection area.  If the selection is
125:                //visible we should skip it.
126:                int tabsWidth = getTabsAreaWidth();
127:                boolean needSplitLine = i != -1
128:                        && ((i < scroll().getLastVisibleTab(tabsWidth) || i <= scroll()
129:                                .getLastVisibleTab(tabsWidth)
130:                                && !scroll().isLastTabClipped()) && i >= scroll()
131:                                .getFirstVisibleTab(tabsWidth));
132:
133:                g.setColor(UIManager.getColor("controlLtHighlight"));
134:                if (needSplitLine) {
135:                    //Find the rectangle of the selection to skip it
136:                    getTabRect(i, scratch5);
137:                    //Make sure it's not offscreen
138:                    if (scratch5.width != 0) {
139:                        //draw the first part of the line
140:                        if (r.x < scratch5.x) {
141:                            g.drawLine(r.x, y, scratch5.x + 1, y);
142:                        }
143:                        //Now draw the second part out to the right edge
144:                        if (scratch5.x + scratch5.width < r.x + r.width) {
145:                            //Find the right edge of the selected tab rectangle
146:                            selEnd = scratch5.x + scratch5.width;
147:                            //If the last tab is not clipped, the final tab is one
148:                            //pixel smaller; we need to overwrite one pixel of the
149:                            //border or there will be a small stub sticking down
150:                            if (!scroll().isLastTabClipped()) {
151:                                selEnd--;
152:                            }
153:                            //Really draw the second part, now that we know where to
154:                            //start
155:                            g.drawLine(selEnd, y, r.x + r.width, y);
156:                        }
157:                    }
158:                } else {
159:                    //The selection is not visible - draw the white highlight line
160:                    //across the entire width of the container
161:                    g.drawLine(r.x, y, r.x + r.width, y);
162:                }
163:
164:                //Draw the left and right edges so the area below the tabs looks 
165:                //closed
166:                g.setColor(WinXPEditorTabCellRenderer.getBorderColor());
167:                g.drawLine(0, y - 1, 0, displayer.getHeight());
168:                g.drawLine(displayer.getWidth() - 1, y - 1, displayer
169:                        .getWidth() - 1, displayer.getHeight());
170:
171:                //Draw a line tracking the bottom of the tabs under the control
172:                //buttons, out to the right edge of the control
173:
174:                //Find the last visible tab
175:                int last = scroll().getLastVisibleTab(tabsWidth);
176:                int l = 0;
177:                if (last >= 0) {
178:                    //If it's onscreen (usually will be unless there are no tabs,
179:                    //find the edge of the last tab - it may be scrolled)
180:                    getTabRect(last, scratch5);
181:                    last = scratch5.x + scratch5.width;
182:                }
183:                //Draw the dark line under the controls button area that closes the
184:                //tabs bottom margin on top
185:                g.drawLine(last, y - 1, displayer.getWidth(), y - 1);
186:            }
187:
188:            protected TabCellRenderer createDefaultRenderer() {
189:                return new WinXPEditorTabCellRenderer();
190:            }
191:
192:            private static void initIcons() {
193:                if (null == buttonIconPaths) {
194:                    buttonIconPaths = new HashMap<Integer, String[]>(7);
195:
196:                    //left button
197:                    String[] iconPaths = new String[4];
198:                    iconPaths[TabControlButton.STATE_DEFAULT] = "org/netbeans/swing/tabcontrol/resources/xp_scrollleft_enabled.png"; // NOI18N
199:                    iconPaths[TabControlButton.STATE_DISABLED] = "org/netbeans/swing/tabcontrol/resources/xp_scrollleft_disabled.png"; // NOI18N
200:                    iconPaths[TabControlButton.STATE_ROLLOVER] = "org/netbeans/swing/tabcontrol/resources/xp_scrollleft_rollover.png"; // NOI18N
201:                    iconPaths[TabControlButton.STATE_PRESSED] = "org/netbeans/swing/tabcontrol/resources/xp_scrollleft_pressed.png"; // NOI18N
202:                    buttonIconPaths.put(TabControlButton.ID_SCROLL_LEFT_BUTTON,
203:                            iconPaths);
204:
205:                    //right button
206:                    iconPaths = new String[4];
207:                    iconPaths[TabControlButton.STATE_DEFAULT] = "org/netbeans/swing/tabcontrol/resources/xp_scrollright_enabled.png"; // NOI18N
208:                    iconPaths[TabControlButton.STATE_DISABLED] = "org/netbeans/swing/tabcontrol/resources/xp_scrollright_disabled.png"; // NOI18N
209:                    iconPaths[TabControlButton.STATE_ROLLOVER] = "org/netbeans/swing/tabcontrol/resources/xp_scrollright_rollover.png"; // NOI18N
210:                    iconPaths[TabControlButton.STATE_PRESSED] = "org/netbeans/swing/tabcontrol/resources/xp_scrollright_pressed.png"; // NOI18N
211:                    buttonIconPaths.put(
212:                            TabControlButton.ID_SCROLL_RIGHT_BUTTON, iconPaths);
213:
214:                    //drop down button
215:                    iconPaths = new String[4];
216:                    iconPaths[TabControlButton.STATE_DEFAULT] = "org/netbeans/swing/tabcontrol/resources/xp_popup_enabled.png"; // NOI18N
217:                    iconPaths[TabControlButton.STATE_DISABLED] = "org/netbeans/swing/tabcontrol/resources/xp_popup_disabled.png"; // NOI18N
218:                    iconPaths[TabControlButton.STATE_ROLLOVER] = "org/netbeans/swing/tabcontrol/resources/xp_popup_rollover.png"; // NOI18N
219:                    iconPaths[TabControlButton.STATE_PRESSED] = "org/netbeans/swing/tabcontrol/resources/xp_popup_pressed.png"; // NOI18N
220:                    buttonIconPaths.put(TabControlButton.ID_DROP_DOWN_BUTTON,
221:                            iconPaths);
222:
223:                    //maximize/restore button
224:                    iconPaths = new String[4];
225:                    iconPaths[TabControlButton.STATE_DEFAULT] = "org/netbeans/swing/tabcontrol/resources/xp_maximize_enabled.png"; // NOI18N
226:                    iconPaths[TabControlButton.STATE_DISABLED] = "org/netbeans/swing/tabcontrol/resources/xp_maximize_disabled.png"; // NOI18N
227:                    iconPaths[TabControlButton.STATE_ROLLOVER] = "org/netbeans/swing/tabcontrol/resources/xp_maximize_rollover.png"; // NOI18N
228:                    iconPaths[TabControlButton.STATE_PRESSED] = "org/netbeans/swing/tabcontrol/resources/xp_maximize_pressed.png"; // NOI18N
229:                    buttonIconPaths.put(TabControlButton.ID_MAXIMIZE_BUTTON,
230:                            iconPaths);
231:
232:                    iconPaths = new String[4];
233:                    iconPaths[TabControlButton.STATE_DEFAULT] = "org/netbeans/swing/tabcontrol/resources/xp_restore_enabled.png"; // NOI18N
234:                    iconPaths[TabControlButton.STATE_DISABLED] = "org/netbeans/swing/tabcontrol/resources/xp_restore_disabled.png"; // NOI18N
235:                    iconPaths[TabControlButton.STATE_ROLLOVER] = "org/netbeans/swing/tabcontrol/resources/xp_restore_rollover.png"; // NOI18N
236:                    iconPaths[TabControlButton.STATE_PRESSED] = "org/netbeans/swing/tabcontrol/resources/xp_restore_pressed.png"; // NOI18N
237:                    buttonIconPaths.put(TabControlButton.ID_RESTORE_BUTTON,
238:                            iconPaths);
239:                }
240:            }
241:
242:            @Override
243:            public Icon getButtonIcon(int buttonId, int buttonState) {
244:                Icon res = null;
245:                initIcons();
246:                String[] paths = buttonIconPaths.get(buttonId);
247:                if (null != paths && buttonState >= 0
248:                        && buttonState < paths.length) {
249:                    res = TabControlButtonFactory.getIcon(paths[buttonState]);
250:                }
251:                return res;
252:            }
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.