Source Code Cross Referenced for MatteBorderTest.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » border » 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.border 
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 Alexander T. Simbirtsev
019:         * @version $Revision$
020:         * Created on 03.12.2004
021:
022:         */package javax.swing.border;
023:
024:        import java.awt.Color;
025:        import java.awt.Insets;
026:        import java.awt.image.BufferedImage;
027:        import javax.swing.Icon;
028:        import javax.swing.ImageIcon;
029:        import javax.swing.JPanel;
030:        import javax.swing.SwingTestCase;
031:
032:        public class MatteBorderTest extends SwingTestCase {
033:            public static void main(final String[] args) {
034:                junit.textui.TestRunner.run(MatteBorderTest.class);
035:            }
036:
037:            /*
038:             * Class under test for void MatteBorder(Insets, Icon)
039:             */
040:            public void testMatteBorderInsetsIcon() {
041:                Icon icon = new ImageIcon(new BufferedImage(20, 20,
042:                        BufferedImage.TYPE_BYTE_GRAY));
043:                int top = 100;
044:                int left = 200;
045:                int right = 300;
046:                int bottom = 400;
047:                MatteBorder border = new MatteBorder(new Insets(top, left,
048:                        bottom, right), icon);
049:                assertEquals(border.getBorderInsets(), new Insets(top, left,
050:                        bottom, right));
051:                assertEquals("icon value coinsides", icon, border.getTileIcon());
052:                icon = new ImageIcon(new BufferedImage(30, 40,
053:                        BufferedImage.TYPE_4BYTE_ABGR));
054:                top = 200;
055:                left = 300;
056:                right = 200;
057:                bottom = 300;
058:                border = new MatteBorder(new Insets(top, left, bottom, right),
059:                        icon);
060:                assertEquals(border.getBorderInsets(), new Insets(top, left,
061:                        bottom, right));
062:                assertEquals("icon value coinsides", icon, border.getTileIcon());
063:            }
064:
065:            /*
066:             * Class under test for void MatteBorder(Insets, Color)
067:             */
068:            public void testMatteBorderInsetsColor() {
069:                Color color = Color.RED;
070:                int top = 100;
071:                int left = 200;
072:                int right = 300;
073:                int bottom = 400;
074:                MatteBorder border = new MatteBorder(new Insets(top, left,
075:                        bottom, right), color);
076:                assertEquals(border.getBorderInsets(), new Insets(top, left,
077:                        bottom, right));
078:                assertEquals("color value coinsides", color, border
079:                        .getMatteColor());
080:                color = Color.YELLOW;
081:                top = 200;
082:                left = 300;
083:                right = 200;
084:                bottom = 300;
085:                border = new MatteBorder(new Insets(top, left, bottom, right),
086:                        color);
087:                assertEquals(border.getBorderInsets(), new Insets(top, left,
088:                        bottom, right));
089:                assertEquals("color value coinsides", color, border
090:                        .getMatteColor());
091:            }
092:
093:            /*
094:             * Class under test for void MatteBorder(Icon)
095:             */
096:            public void testMatteBorderIcon() {
097:                Icon icon = new ImageIcon(new BufferedImage(20, 20,
098:                        BufferedImage.TYPE_BYTE_GRAY));
099:                MatteBorder border = new MatteBorder(icon);
100:                Insets insets;
101:
102:                assertEquals("icon value coinsides", icon, border.getTileIcon());
103:                icon = new ImageIcon(new BufferedImage(30, 40,
104:                        BufferedImage.TYPE_4BYTE_ABGR));
105:                border = new MatteBorder(icon);
106:                assertEquals("icon value coinsides", icon, border.getTileIcon());
107:
108:                //Regression test for HARMONY-2589
109:                border = new MatteBorder(null);
110:                insets = border.getBorderInsets();
111:                assertEquals(-1, insets.top);
112:                assertEquals(-1, insets.bottom);
113:                assertEquals(-1, insets.left);
114:                assertEquals(-1, insets.right);
115:            }
116:
117:            /*
118:             * Class under test for void MatteBorder(int, int, int, int, Icon)
119:             */
120:            public void testMatteBorderintintintintIcon() {
121:                Icon icon = new ImageIcon(new BufferedImage(20, 20,
122:                        BufferedImage.TYPE_BYTE_GRAY));
123:                int top = 100;
124:                int left = 200;
125:                int right = 300;
126:                int bottom = 400;
127:                MatteBorder border = new MatteBorder(top, left, bottom, right,
128:                        icon);
129:                assertEquals(border.getBorderInsets(), new Insets(top, left,
130:                        bottom, right));
131:                assertEquals("icon value coinsides", icon, border.getTileIcon());
132:                icon = new ImageIcon(new BufferedImage(30, 40,
133:                        BufferedImage.TYPE_4BYTE_ABGR));
134:                top = 200;
135:                left = 300;
136:                right = 200;
137:                bottom = 300;
138:                border = new MatteBorder(top, left, bottom, right, icon);
139:                assertEquals(border.getBorderInsets(), new Insets(top, left,
140:                        bottom, right));
141:                assertEquals("icon value coinsides", icon, border.getTileIcon());
142:            }
143:
144:            /*
145:             * Class under test for void MatteBorder(int, int, int, int, Color)
146:             */
147:            public void testMatteBorderintintintintColor() {
148:                Color color = Color.RED;
149:                int top = 100;
150:                int left = 200;
151:                int right = 300;
152:                int bottom = 400;
153:                MatteBorder border = new MatteBorder(top, left, bottom, right,
154:                        color);
155:                assertEquals(border.getBorderInsets(), new Insets(top, left,
156:                        bottom, right));
157:                assertEquals("color value coinsides", color, border
158:                        .getMatteColor());
159:                color = Color.YELLOW;
160:                top = 200;
161:                left = 300;
162:                right = 200;
163:                bottom = 300;
164:                border = new MatteBorder(top, left, bottom, right, color);
165:                assertEquals(border.getBorderInsets(), new Insets(top, left,
166:                        bottom, right));
167:                assertEquals("color value coinsides", color, border
168:                        .getMatteColor());
169:            }
170:
171:            public void testPaintBorder() {
172:                //        JPanel panel1 = new JPanel();
173:                //        JPanel panel2 = new JPanel();
174:                //        JPanel panel3 = new JPanel();
175:                //
176:                //        Color color1 = Color.GREEN;
177:                //        Icon icon = null;
178:                //        icon = new ImageIcon(DefaultMetalTheme.class.getResource("icons/Error.gif"));
179:                //        Color shadowOuterColor = Color.BLACK;
180:                //        Color highlightedInnerColor = Color.RED;
181:                //        Color highlightedOuterColor = Color.BLUE;
182:                //
183:                //        Border border1 = new MatteBorder(10, 20, 30, 50, color1);
184:                //        Border border2 = new MatteBorder(10, 20, 30, 50, icon);
185:                //        panel2.setBorder(border1);
186:                //        panel3.setBorder(border2);
187:                //        panel2.setPreferredSize(new Dimension(200, 150));
188:                //        panel3.setPreferredSize(new Dimension(200, 150));
189:                //
190:                //        panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
191:                //        panel1.add(panel2);
192:                //        panel1.add(panel3);
193:                //
194:                //        JFrame frame = new JFrame();
195:                //        frame.getContentPane().add(panel1);
196:                //        frame.pack();
197:                //        frame.show();
198:                //        while(!frame.isActive());
199:                //        while(frame.isActive());
200:            }
201:
202:            public void testIsBorderOpaque() {
203:                int top = 100;
204:                int left = 200;
205:                int right = 300;
206:                int bottom = 400;
207:                Color color = Color.RED;
208:                MatteBorder border = new MatteBorder(top, left, bottom, right,
209:                        color);
210:                assertTrue("MatteBorder without tiles is opaque", border
211:                        .isBorderOpaque());
212:                Icon icon = new ImageIcon(new BufferedImage(20, 20,
213:                        BufferedImage.TYPE_BYTE_GRAY));
214:                border = new MatteBorder(top, left, bottom, right, icon);
215:                assertFalse("MatteBorder with tiles is not opaque", border
216:                        .isBorderOpaque());
217:            }
218:
219:            /*
220:             * Class under test for Insets getBorderInsets(Component, Insets)
221:             */
222:            public void testGetBorderInsetsComponentInsets() {
223:                int top = 10;
224:                int left = 20;
225:                int right = 30;
226:                int bottom = 40;
227:                Icon icon = new ImageIcon(new BufferedImage(200, 200,
228:                        BufferedImage.TYPE_BYTE_GRAY));
229:                MatteBorder border = new MatteBorder(top, left, bottom, right,
230:                        icon);
231:                Insets insets = new Insets(1, 1, 1, 1);
232:                JPanel panel = new JPanel();
233:                border.getBorderInsets(panel, insets);
234:                assertEquals("insets values coinside", top, insets.top);
235:                assertEquals("insets values coinside", left, insets.left);
236:                assertEquals("insets values coinside", right, insets.right);
237:                assertEquals("insets values coinside", bottom, insets.bottom);
238:                panel.setBorder(new LineBorder(Color.black, 100));
239:                border.getBorderInsets(panel, insets);
240:                assertEquals("insets values coinside", top, insets.top);
241:                assertEquals("insets values coinside", left, insets.left);
242:                assertEquals("insets values coinside", right, insets.right);
243:                assertEquals("insets values coinside", bottom, insets.bottom);
244:                insets = new Insets(2 * top, 2 * left, 2 * bottom, 2 * right);
245:                panel.setBorder(new BevelBorder(BevelBorder.LOWERED));
246:                Insets newInsets = border.getBorderInsets(panel, insets);
247:                assertEquals("insets values coinside", top, newInsets.top);
248:                assertEquals("insets values coinside", left, newInsets.left);
249:                assertEquals("insets values coinside", right, newInsets.right);
250:                assertEquals("insets values coinside", bottom, newInsets.bottom);
251:                assertEquals("insets values coinside", top, insets.top);
252:                assertEquals("insets values coinside", left, insets.left);
253:                assertEquals("insets values coinside", right, insets.right);
254:                assertEquals("insets values coinside", bottom, insets.bottom);
255:            }
256:
257:            /*
258:             * Class under test for Insets getBorderInsets(Component)
259:             */
260:            public void testGetBorderInsetsComponent() {
261:                int top = 10;
262:                int left = 20;
263:                int right = 30;
264:                int bottom = 40;
265:                Icon icon = new ImageIcon(new BufferedImage(200, 200,
266:                        BufferedImage.TYPE_BYTE_GRAY));
267:                MatteBorder border = new MatteBorder(top, left, bottom, right,
268:                        icon);
269:                Insets insets = new Insets(1, 1, 1, 1);
270:                JPanel panel = new JPanel();
271:                border.getBorderInsets(panel, insets);
272:                assertEquals("insets values coinside", top, insets.top);
273:                assertEquals("insets values coinside", left, insets.left);
274:                assertEquals("insets values coinside", right, insets.right);
275:                assertEquals("insets values coinside", bottom, insets.bottom);
276:                panel.setBorder(new LineBorder(Color.black, 100));
277:                insets = border.getBorderInsets(panel);
278:                assertEquals("insets values coinside", top, insets.top);
279:                assertEquals("insets values coinside", left, insets.left);
280:                assertEquals("insets values coinside", right, insets.right);
281:                assertEquals("insets values coinside", bottom, insets.bottom);
282:                insets = new Insets(2 * top, 2 * left, 2 * bottom, 2 * right);
283:                panel.setBorder(new EmptyBorder(insets));
284:                insets = border.getBorderInsets(panel);
285:                assertEquals("insets values coinside", top, insets.top);
286:                assertEquals("insets values coinside", left, insets.left);
287:                assertEquals("insets values coinside", right, insets.right);
288:                assertEquals("insets values coinside", bottom, insets.bottom);
289:            }
290:
291:            /*
292:             * Class under test for Insets getBorderInsets()
293:             */
294:            public void testGetBorderInsets() {
295:                int top = 10;
296:                int left = 20;
297:                int right = 30;
298:                int bottom = 40;
299:                int tileHeight = 30;
300:                int tileWidth = 40;
301:                Color color = Color.RED;
302:                MatteBorder border = new MatteBorder(top, left, bottom, right,
303:                        color);
304:                Icon icon = new ImageIcon(new BufferedImage(tileWidth,
305:                        tileHeight, BufferedImage.TYPE_BYTE_GRAY));
306:                top = left = bottom = right = 30;
307:                border = new MatteBorder(top, left, bottom, right, icon);
308:                assertEquals("Insets coinside ", new Insets(top, left, bottom,
309:                        right), border.getBorderInsets());
310:                top = left = bottom = right = 10;
311:                border = new MatteBorder(top, left, bottom, right, icon);
312:                assertEquals("Insets coinside ", new Insets(top, left, bottom,
313:                        right), border.getBorderInsets());
314:                border = new MatteBorder(icon);
315:                assertEquals("Insets coinside ", new Insets(tileHeight,
316:                        tileWidth, tileHeight, tileWidth), border
317:                        .getBorderInsets());
318:                top = left = bottom = right = 1;
319:                border = new MatteBorder(top, left, bottom, right, icon);
320:                assertEquals("Insets coinside ", new Insets(top, left, bottom,
321:                        right), border.getBorderInsets());
322:                top = left = bottom = right = 0;
323:                border = new MatteBorder(top, left, bottom, right, icon);
324:                assertEquals("Insets coinside ", new Insets(top, left, bottom,
325:                        right), border.getBorderInsets());
326:            }
327:
328:            public void testGetTileIcon() {
329:                int top = 100;
330:                int left = 200;
331:                int right = 300;
332:                int bottom = 400;
333:                Color color = Color.RED;
334:                Icon icon = null;
335:                MatteBorder border = new MatteBorder(top, left, bottom, right,
336:                        color);
337:                assertEquals("Icon coinsides", icon, border.getTileIcon());
338:                icon = new ImageIcon(new BufferedImage(20, 20,
339:                        BufferedImage.TYPE_BYTE_GRAY));
340:                border = new MatteBorder(top, left, bottom, right, icon);
341:                assertEquals("Icon coinsides", icon, border.getTileIcon());
342:            }
343:
344:            public void testGetMatteColor() {
345:                int top = 100;
346:                int left = 200;
347:                int right = 300;
348:                int bottom = 400;
349:                Color color = Color.RED;
350:                MatteBorder border = new MatteBorder(top, left, bottom, right,
351:                        color);
352:                assertEquals("Colors coinside ", color, border.getMatteColor());
353:                color = Color.YELLOW;
354:                border = new MatteBorder(top, left, bottom, right, color);
355:                assertEquals("Colors coinside ", color, border.getMatteColor());
356:            }
357:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.