Source Code Cross Referenced for StyleUtil.java in  » Ajax » NextApp-Echo2 » nextapp » echo2 » testapp » interactive » 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 » Ajax » NextApp Echo2 » nextapp.echo2.testapp.interactive 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003:         * Copyright (C) 2002-2005 NextApp, Inc.
004:         *
005:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version
008:         * 1.1 (the "License"); you may not use this file except in compliance with
009:         * the License. You may obtain a copy of the License at
010:         * http://www.mozilla.org/MPL/
011:         *
012:         * Software distributed under the License is distributed on an "AS IS" basis,
013:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014:         * for the specific language governing rights and limitations under the
015:         * License.
016:         *
017:         * Alternatively, the contents of this file may be used under the terms of
018:         * either the GNU General Public License Version 2 or later (the "GPL"), or
019:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020:         * in which case the provisions of the GPL or the LGPL are applicable instead
021:         * of those above. If you wish to allow use of your version of this file only
022:         * under the terms of either the GPL or the LGPL, and not to allow others to
023:         * use your version of this file under the terms of the MPL, indicate your
024:         * decision by deleting the provisions above and replace them with the notice
025:         * and other provisions required by the GPL or the LGPL. If you do not delete
026:         * the provisions above, a recipient may use your version of this file under
027:         * the terms of any one of the MPL, the GPL or the LGPL.
028:         */
029:
030:        package nextapp.echo2.testapp.interactive;
031:
032:        import nextapp.echo2.app.Alignment;
033:        import nextapp.echo2.app.Border;
034:        import nextapp.echo2.app.Color;
035:        import nextapp.echo2.app.Extent;
036:        import nextapp.echo2.app.Font;
037:
038:        /**
039:         * 
040:         */
041:        public class StyleUtil {
042:
043:            public static final String QUASI_LATIN_TEXT_1 = "Ymo, lobortis camur qui typicus voco.  Jugis similis wisi singularis dolor suscipit.  "
044:                    + "Fatua premo regula fatua huic, vereor dolus aptent tego, quidne vero valetudo esse enim exerci.  "
045:                    + "Refero quae ut importunus si sit.  Aliquam illum, nostrud qui duis nimis refero esse jugis "
046:                    + "sit jus, duis, tum vel capio.  Quadrum pertineo dignissim diam in ut adipiscing magna eros "
047:                    + "neque exerci vulputate commodo indoles.  Sed dolor, oppeto pala eu veniam.  Ullamcorper typicus "
048:                    + "hos erat neque suscipere defui feugiat velit acsi pneum vel comis luptatum."
049:                    + "Zelus quidem, natu, delenit, veniam, tristique eligo transverbero.  Ea, plaga vel et illum "
050:                    + "sed diam quia iriure.  Ludus quidem, tation pecus, interdico quis sit mos cui ideo feugait nutus "
051:                    + "utinam at iriure.  Secundum vulputate inhibeo wisi pneum fatua facilisi fatua consequat facilisi "
052:                    + "lucidus.  Validus verto vel sudo letalis molior eum exerci epulae nostrud haero esse.  Utrum "
053:                    + "aliquip, pneum typicus similis minim sed laoreet, quidem.  Oppeto ille nutus neque veniam, et, "
054:                    + "abdo, conventio sit, ea wisi neo dolore. At, inhibeo laoreet validus nulla, delenit nimis et "
055:                    + "quis turpis neo dignissim abigo adsum.  Aliquam illum, nostrud qui duis nimis refero esse jugis "
056:                    + "sit jus, duis, tum vel capio.  Nobis vero refero valetudo huic enim nobis wisi comis haero "
057:                    + "validus.  Consequat foras, opto torqueo illum, adipiscing nobis.  Te patria, feugiat, feugiat ut "
058:                    + "tincidunt ventosus nisl amet lucidus, premo vel illum exerci.  Exerci imputo meus ut ingenium "
059:                    + "tincidunt vulpes, multo ut, vindico luptatum.  Duis hendrerit brevitas tristique esse abluo in "
060:                    + "persto praesent, in ibidem augue melior delenit quadrum.  Veniam lobortis duis wisi gilvus immitto "
061:                    + "defui amet importunus indoles pneum odio hos minim.  Olim nimis suscipere ullamcorper, utinam ut "
062:                    + "odio, praemitto, praesent facilisi ad consequat facilisi.  Duis hendrerit brevitas tristique esse "
063:                    + "abluo in persto praesent, in ibidem augue melior delenit quadrum.  Sudo bis, inhibeo exerci proprius "
064:                    + "magna macto feugiat autem vel veniam vulputate ut.  Aliquip, multo tego, esse letalis similis, "
065:                    + "abbas abluo elit aliquam qui olim ymo, torqueo.  Jus suscipit valetudo velit virtus dolore autem "
066:                    + "nulla imputo nostrud minim.  Nisl vero sino paratus acsi similis epulae odio euismod refero "
067:                    + "tation.  Autem conventio regula accumsan fatua virtus.";
068:
069:            // Everyone shares the "next" constants.
070:            private static int nextBorderStyle = 0;
071:            private static int nextBorderSize = 0;
072:
073:            private static Font.Typeface[] TYPEFACES = new Font.Typeface[] {
074:                    Font.COURIER_NEW, Font.VERDANA, Font.TIMES_NEW_ROMAN };
075:
076:            private static int[] BORDER_SIZES = new int[] { 0, 1, 2, 3, 4, 5,
077:                    10, 15, 20, 40, 80 };
078:
079:            private static int[] FONT_SIZES = new int[] { 6, 8, 10, 12, 16, 24,
080:                    48, 72 };
081:
082:            private static final int[] BORDER_STYLES = new int[] {
083:                    Border.STYLE_NONE, Border.STYLE_INSET, Border.STYLE_OUTSET,
084:                    Border.STYLE_SOLID, Border.STYLE_DASHED,
085:                    Border.STYLE_DOTTED, Border.STYLE_DOUBLE,
086:                    Border.STYLE_RIDGE, Border.STYLE_GROOVE };
087:
088:            /**
089:             * Choices for random horizontal layout data. <code>Alignment.DEFAULT</code>
090:             * listed multiple times to create bias.
091:             */
092:            private static final int[] HORIZONTAL_ALIGNMENT_VALUES = new int[] {
093:                    Alignment.DEFAULT, Alignment.DEFAULT, Alignment.DEFAULT,
094:                    Alignment.LEADING, Alignment.LEFT, Alignment.CENTER,
095:                    Alignment.RIGHT, Alignment.TRAILING };
096:
097:            /**
098:             * Choices for random vertical layout data. <code>Alignment.DEFAULT</code>
099:             * listed multiple times to create bias.
100:             */
101:            private static final int[] VERTICAL_ALIGNMENT_VALUES = new int[] {
102:                    Alignment.DEFAULT, Alignment.DEFAULT, Alignment.TOP,
103:                    Alignment.CENTER, Alignment.BOTTOM };
104:
105:            public static Alignment randomAlignmentHV() {
106:                return new Alignment(
107:                        HORIZONTAL_ALIGNMENT_VALUES[(int) (Math.random() * HORIZONTAL_ALIGNMENT_VALUES.length)],
108:                        VERTICAL_ALIGNMENT_VALUES[(int) (Math.random() * VERTICAL_ALIGNMENT_VALUES.length)]);
109:            }
110:
111:            public static Border randomBorder() {
112:                return new Border(randomExtent(25), randomColor(),
113:                        randomBorderStyle());
114:            }
115:
116:            public static int randomBorderStyle() {
117:                return BORDER_STYLES[(int) (Math.random() * BORDER_STYLES.length)];
118:            }
119:
120:            public static Color randomBrightColor() {
121:                return new Color(((int) (16777216 * Math.random())) | 0xb0b0b0);
122:            }
123:
124:            public static Color randomColor() {
125:                return new Color((int) (16777216 * Math.random()));
126:            }
127:
128:            public static Extent randomExtent(int max) {
129:                return new Extent((int) (Math.random() * max), Extent.PX);
130:            }
131:
132:            public static Font randomFont() {
133:                Font.Typeface typeface = TYPEFACES[(int) (Math.random() * TYPEFACES.length)];
134:                Extent size = new Extent(
135:                        FONT_SIZES[(int) (Math.random() * FONT_SIZES.length)]);
136:
137:                // 1-in-4 chance of each style flag being set:
138:                int style = 0;
139:                style |= (((int) (Math.random() * 4)) == 0) ? Font.BOLD : 0;
140:                style |= (((int) (Math.random() * 4)) == 0) ? Font.ITALIC : 0;
141:                style |= (((int) (Math.random() * 4)) == 0) ? Font.UNDERLINE
142:                        : 0;
143:                style |= (((int) (Math.random() * 4)) == 0) ? Font.OVERLINE : 0;
144:                style |= (((int) (Math.random() * 4)) == 0) ? Font.LINE_THROUGH
145:                        : 0;
146:
147:                return new Font(typeface, style, size);
148:            }
149:
150:            public static Border nextBorderStyle(Border border) {
151:                if (border == null) {
152:                    return new Border(1, Color.BLACK, Border.STYLE_SOLID);
153:                } else {
154:                    return new Border(border.getSize(), border.getColor(),
155:                            BORDER_STYLES[nextBorderStyle++
156:                                    % BORDER_STYLES.length]);
157:                }
158:            }
159:
160:            public static Border nextBorderSize(Border border) {
161:                if (border == null) {
162:                    return new Border(1, Color.BLACK, Border.STYLE_SOLID);
163:                } else {
164:                    return new Border(BORDER_SIZES[nextBorderSize++
165:                            % BORDER_SIZES.length], border.getColor(), border
166:                            .getStyle());
167:                }
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.