Source Code Cross Referenced for MetalTabbedPaneUITest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » metal » 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 » Apache Harmony Java SE » javax package » javax.swing.plaf.metal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Vadim L. Bogdanov
019:         * @version $Revision$
020:         */package javax.swing.plaf.metal;
021:
022:        import java.awt.Color;
023:        import java.awt.FontMetrics;
024:        import java.awt.Rectangle;
025:        import java.awt.image.BufferedImage;
026:        import javax.swing.ImageIcon;
027:        import javax.swing.JFrame;
028:        import javax.swing.JLabel;
029:        import javax.swing.JTabbedPane;
030:        import javax.swing.SwingConstants;
031:        import javax.swing.SwingTestCase;
032:        import javax.swing.UIManager;
033:        import javax.swing.plaf.ComponentUI;
034:
035:        public class MetalTabbedPaneUITest extends SwingTestCase {
036:            private class TestMetalTabbedPaneUI extends MetalTabbedPaneUI {
037:                @Override
038:                protected FontMetrics getFontMetrics() {
039:                    return super .getFontMetrics();
040:                }
041:
042:                @Override
043:                protected int calculateTabWidth(final int tabPlacement,
044:                        final int tabIndex, final FontMetrics fm) {
045:                    return super .calculateTabWidth(tabPlacement, tabIndex, fm);
046:                }
047:
048:                @Override
049:                protected int calculateTabHeight(final int tabPlacement,
050:                        final int tabIndex, final int fontHeight) {
051:                    return super .calculateTabHeight(tabPlacement, tabIndex,
052:                            fontHeight);
053:                }
054:
055:                @Override
056:                protected int getRunForTab(final int tabCount,
057:                        final int tabIndex) {
058:                    return super .getRunForTab(tabCount, tabIndex);
059:                }
060:            }
061:
062:            private JTabbedPane tabbed;
063:
064:            private TestMetalTabbedPaneUI ui;
065:
066:            private JFrame frame;
067:
068:            @Override
069:            protected void setUp() throws Exception {
070:                super .setUp();
071:                tabbed = new JTabbedPane();
072:                ui = new TestMetalTabbedPaneUI();
073:                tabbed.setUI(ui);
074:                tabbed.addTab("tab1", new JLabel());
075:                tabbed.setIconAt(0, new ImageIcon(new BufferedImage(10, 10,
076:                        BufferedImage.TYPE_INT_RGB)));
077:                tabbed.setDisabledIconAt(0, new ImageIcon(new BufferedImage(10,
078:                        10, BufferedImage.TYPE_INT_RGB)));
079:                tabbed.addTab("tabtab2", new JLabel());
080:                FontMetrics fm = ui.getFontMetrics();
081:                tabbed.setSize(ui.calculateTabWidth(tabbed.getTabPlacement(),
082:                        0, fm)
083:                        + ui.calculateTabWidth(tabbed.getTabPlacement(), 1, fm)
084:                        + 10, 100);
085:                tabbed.doLayout();
086:            }
087:
088:            @Override
089:            protected void tearDown() throws Exception {
090:                super .tearDown();
091:                if (frame != null) {
092:                    frame.dispose();
093:                    frame = null;
094:                }
095:            }
096:
097:            public MetalTabbedPaneUITest(final String name) {
098:                super (name);
099:            }
100:
101:            public void testUpdate() {
102:                // Note: painting code, cannot test
103:            }
104:
105:            public void testPaint() {
106:                // Note: painting code, cannot test
107:            }
108:
109:            public void testCreateUI() {
110:                ComponentUI ui = MetalTabbedPaneUI.createUI(tabbed);
111:                assertTrue(ui instanceof  MetalTabbedPaneUI);
112:            }
113:
114:            public void testCalculateMaxTabHeight() {
115:                int tabPlacement = tabbed.getTabPlacement();
116:                int fontHeight = tabbed.getFontMetrics(tabbed.getFont())
117:                        .getHeight();
118:                int height1 = ui
119:                        .calculateTabHeight(tabPlacement, 0, fontHeight);
120:                int height2 = ui
121:                        .calculateTabHeight(tabPlacement, 1, fontHeight);
122:                assertEquals(Math.max(height1, height2), ui
123:                        .calculateMaxTabHeight(tabPlacement));
124:            }
125:
126:            public void testCreateLayoutManager() {
127:                assertTrue(ui.createLayoutManager() instanceof  MetalTabbedPaneUI.TabbedPaneLayout);
128:            }
129:
130:            public void testGetTabLabelShiftX() {
131:                assertEquals(0, ui.getTabLabelShiftX(SwingConstants.TOP, 0,
132:                        true));
133:                assertEquals(0, ui.getTabLabelShiftX(SwingConstants.TOP, 1,
134:                        false));
135:            }
136:
137:            public void testGetTabLabelShiftY() {
138:                assertEquals(0, ui.getTabLabelShiftY(SwingConstants.TOP, 0,
139:                        true));
140:                assertEquals(0, ui.getTabLabelShiftY(SwingConstants.TOP, 1,
141:                        false));
142:            }
143:
144:            public void testGetTabRunOverlay() {
145:                assertTrue(ui.getTabRunOverlay(SwingConstants.TOP) >= 0);
146:                assertTrue(ui.getTabRunOverlay(SwingConstants.LEFT) >= 0);
147:                assertTrue(ui.getTabRunOverlay(SwingConstants.RIGHT) >= 0);
148:                assertTrue(ui.getTabRunOverlay(SwingConstants.BOTTOM) >= 0);
149:            }
150:
151:            public void testInstallDefaults() {
152:                ui.minTabWidth = 1;
153:                ui.selectColor = null;
154:                ui.selectHighlight = null;
155:                ui.tabAreaBackground = null;
156:                ui.installDefaults();
157:                assertEquals(1, ui.minTabWidth);
158:                assertEquals(UIManager.get("TabbedPane.selected"),
159:                        ui.selectColor);
160:                assertEquals(UIManager.get("TabbedPane.selectHighlight"),
161:                        ui.selectHighlight);
162:                assertEquals(UIManager.get("TabbedPane.tabAreaBackground"),
163:                        ui.tabAreaBackground);
164:            }
165:
166:            public void testPaintContentBorderBottomEdge() {
167:                // Note: painting code, cannot test
168:            }
169:
170:            public void testPaintContentBorderLeftEdge() {
171:                // Note: painting code, cannot test
172:            }
173:
174:            public void testPaintContentBorderRightEdge() {
175:                // Note: painting code, cannot test
176:            }
177:
178:            public void testPaintContentBorderTopEdge() {
179:                // Note: painting code, cannot test
180:            }
181:
182:            public void testPaintFocusIndicator() {
183:                // Note: painting code, cannot test
184:            }
185:
186:            public void testPaintTabBackground() {
187:                // Note: painting code, cannot test
188:            }
189:
190:            public void testPaintTabBorder() {
191:                // Note: painting code, cannot test
192:            }
193:
194:            public void testShouldPadTabRun() {
195:                assertFalse(ui.shouldPadTabRun(SwingConstants.TOP, 0));
196:                create3TabRuns();
197:                assertFalse(ui.shouldPadTabRun(SwingConstants.TOP, 2));
198:                assertTrue(ui.shouldPadTabRun(SwingConstants.TOP, 1));
199:                assertTrue(ui.shouldPadTabRun(SwingConstants.TOP, 0));
200:            }
201:
202:            public void testMetalTabbedPaneUI() {
203:                assertEquals(40, ui.minTabWidth);
204:            }
205:
206:            public void testGetColorForGap() {
207:                assertEquals(tabbed.getBackground(), ui.getColorForGap(0, 0, 0));
208:                create3TabRuns();
209:                tabbed.setBackgroundAt(2, Color.green);
210:                tabbed.setBackgroundAt(0, Color.red);
211:                tabbed.setSelectedIndex(3);
212:                int tabCount = tabbed.getTabCount();
213:                Rectangle tabBounds = ui.getTabBounds(tabbed, 0);
214:                assertEquals(tabbed.getBackgroundAt(2), ui.getColorForGap(ui
215:                        .getRunForTab(tabCount, 0), tabBounds.x, tabBounds.y));
216:                tabbed.setSelectedIndex(2);
217:                assertEquals(ui.selectColor, ui.getColorForGap(ui.getRunForTab(
218:                        tabCount, 0), tabBounds.x, tabBounds.y));
219:            }
220:
221:            public void testPaintHighlightBelowTab() {
222:                // Note: painting code, cannot test
223:            }
224:
225:            public void testPaintBottomTabBorder() {
226:                // Note: painting code, cannot test
227:            }
228:
229:            public void testPaintLeftTabBorder() {
230:                // Note: painting code, cannot test
231:            }
232:
233:            public void testPaintRightTabBorder() {
234:                // Note: painting code, cannot test
235:            }
236:
237:            public void testPaintTopTabBorder() {
238:                // Note: painting code, cannot test
239:            }
240:
241:            public void testShouldFillGap() {
242:                assertFalse(ui.shouldFillGap(0, 0, 0, 0));
243:                create3TabRuns();
244:                int tabCount = tabbed.getTabCount();
245:                Rectangle tabBounds = ui.getTabBounds(tabbed, 0);
246:                assertTrue(ui.shouldFillGap(ui.getRunForTab(tabCount, 0), 0,
247:                        tabBounds.x, tabBounds.y));
248:                tabBounds = ui.getTabBounds(tabbed, tabCount - 1);
249:                assertFalse(ui.shouldFillGap(ui.getRunForTab(tabCount,
250:                        tabCount - 1), tabCount - 1, tabBounds.x, tabBounds.y));
251:            }
252:
253:            public void testShouldRotateTabRuns() {
254:                assertFalse(ui.shouldRotateTabRuns(SwingConstants.TOP, 0));
255:                assertFalse(ui.shouldRotateTabRuns(SwingConstants.TOP, 1));
256:            }
257:
258:            private void create3TabRuns() {
259:                tabbed.add("tab4", new JLabel());
260:                tabbed.add("tabtabtabtab5", new JLabel());
261:                tabbed.getLayout().layoutContainer(tabbed);
262:                assertEquals("initialized incorrectly", 3, tabbed
263:                        .getTabRunCount());
264:            }
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.