Source Code Cross Referenced for JavaSourceStyleTable.java in  » Code-Analyzer » Java2Html » de » java2html » options » 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 » Code Analyzer » Java2Html » de.java2html.options 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.java2html.options;
002:
003:        import java.util.HashMap;
004:        import java.util.Iterator;
005:        import java.util.Map;
006:
007:        import de.java2html.javasource.JavaSourceType;
008:        import de.java2html.util.RGB;
009:
010:        /**
011:         * Table containing style options (
012:         * {@link de.java2html.options.JavaSourceStyleEntry}) for different types of
013:         * source code ({@link de.java2html.javasource.JavaSourceType}).
014:         * 
015:         * @author Markus Gebhard
016:         */
017:        public class JavaSourceStyleTable {
018:            private final Map table = new HashMap();
019:            private static JavaSourceStyleEntry defaultColorEntry = new JavaSourceStyleEntry(
020:                    RGB.BLACK);
021:            private String name;
022:
023:            private JavaSourceStyleTable(String name) {
024:                setName(name);
025:            }
026:
027:            public boolean equals(Object obj) {
028:                if (!(obj instanceof  JavaSourceStyleTable)) {
029:                    return false;
030:                }
031:                JavaSourceStyleTable other = (JavaSourceStyleTable) obj;
032:
033:                if (!name.equals(other.name)) {
034:                    return false;
035:                }
036:                if (other.table.size() != table.size()) {
037:                    return false;
038:                }
039:
040:                Iterator iterator = table.keySet().iterator();
041:                while (iterator.hasNext()) {
042:                    String key = (String) iterator.next();
043:                    JavaSourceStyleEntry value = get(key);
044:                    if (!value.equals(other.table.get(key))) {
045:                        return false;
046:                    }
047:                }
048:                return true;
049:            }
050:
051:            public JavaSourceStyleTable getClone() {
052:                JavaSourceStyleTable clone = new JavaSourceStyleTable(getName());
053:                Iterator iterator = table.keySet().iterator();
054:                while (iterator.hasNext()) {
055:                    String key = (String) iterator.next();
056:                    JavaSourceStyleEntry value = get(key);
057:                    clone.table.put(key, value);
058:                }
059:                return clone;
060:            }
061:
062:            public static JavaSourceStyleTable[] getPredefinedTables() {
063:                return new JavaSourceStyleTable[] {
064:                        createDefaultEclipseStyleTable(),
065:                        createDefaultKawaStyleTable(),
066:                        createDefaultMonochromeStyleTable(), };
067:            }
068:
069:            /**
070:             * Returns the style table with the given name or <code>null</code> if
071:             * there is none having the give name.
072:             * 
073:             * @throws IllegalArgumentException
074:             *           if the name is null.
075:             */
076:            public static JavaSourceStyleTable getPredefinedTable(String name) {
077:                if (name == null) {
078:                    throw new IllegalArgumentException("name is null."); //$NON-NLS-1$
079:                }
080:                JavaSourceStyleTable[] tables = getPredefinedTables();
081:                for (int i = 0; i < tables.length; ++i) {
082:                    if (tables[i].getName().equalsIgnoreCase(name)) {
083:                        return tables[i];
084:                    }
085:                }
086:                return null;
087:            }
088:
089:            private static JavaSourceStyleTable createDefaultKawaStyleTable() {
090:                JavaSourceStyleTable table = new JavaSourceStyleTable("Kawa"); //$NON-NLS-1$
091:                table.put(JavaSourceType.UNDEFINED, new JavaSourceStyleEntry(
092:                        new RGB(255, 97, 0)));
093:                table.put(JavaSourceType.CODE, new JavaSourceStyleEntry(
094:                        RGB.BLACK));
095:                table.put(JavaSourceType.KEYWORD, new JavaSourceStyleEntry(
096:                        new RGB(0, 0, 192), true, false));
097:                table.put(JavaSourceType.CODE_TYPE, new JavaSourceStyleEntry(
098:                        new RGB(192, 0, 0), true, false));
099:                table.put(JavaSourceType.STRING, new JavaSourceStyleEntry(
100:                        new RGB(153, 0, 0))); //darker
101:                // red
102:                table.put(JavaSourceType.COMMENT_LINE,
103:                        new JavaSourceStyleEntry(new RGB(0, 128, 0))); //green
104:                table.put(JavaSourceType.COMMENT_BLOCK,
105:                        new JavaSourceStyleEntry(new RGB(0, 128, 0))); //green
106:                table.put(JavaSourceType.JAVADOC, new JavaSourceStyleEntry(
107:                        new RGB(0, 128, 0))); //green
108:                table.put(JavaSourceType.JAVADOC_KEYWORD,
109:                        new JavaSourceStyleEntry(new RGB(0, 85, 0)));
110:                //dark green
111:                //    set.put(JavaSourceType.BACKGROUND, new JavaSourceStyleEntry(new
112:                // Color(255,251,240)));
113:                table.put(JavaSourceType.BACKGROUND, new JavaSourceStyleEntry(
114:                        new RGB(255, 255, 255)));
115:                table.put(JavaSourceType.NUM_CONSTANT,
116:                        new JavaSourceStyleEntry(new RGB(153, 0, 0)));
117:                //dark red
118:                table.put(JavaSourceType.CHAR_CONSTANT,
119:                        new JavaSourceStyleEntry(new RGB(153, 0, 0)));
120:                //dark red
121:                table.put(JavaSourceType.PARENTHESIS, new JavaSourceStyleEntry(
122:                        RGB.BLACK));
123:                table.put(JavaSourceType.JAVADOC_HTML_TAG,
124:                        new JavaSourceStyleEntry(new RGB(0, 128, 0)));
125:                table.put(JavaSourceType.JAVADOC_LINKS,
126:                        new JavaSourceStyleEntry(new RGB(0, 128, 0)));
127:                table.put(JavaSourceType.LINE_NUMBERS,
128:                        new JavaSourceStyleEntry(new RGB(128, 128, 128)));
129:                table.put(JavaSourceType.ANNOTATION, new JavaSourceStyleEntry(
130:                        new RGB(100, 100, 100)));
131:                return table;
132:            }
133:
134:            private static JavaSourceStyleTable createDefaultEclipseStyleTable() {
135:                JavaSourceStyleTable table = new JavaSourceStyleTable("Eclipse"); //$NON-NLS-1$
136:                table.put(JavaSourceType.CODE, new JavaSourceStyleEntry(
137:                        RGB.BLACK));
138:                table.put(JavaSourceType.KEYWORD, new JavaSourceStyleEntry(
139:                        new RGB(127, 0, 85), true, false));
140:                table.put(JavaSourceType.CODE_TYPE, new JavaSourceStyleEntry(
141:                        new RGB(127, 0, 85), true, false));
142:                table.put(JavaSourceType.STRING, new JavaSourceStyleEntry(
143:                        new RGB(42, 0, 255)));
144:                table.put(JavaSourceType.COMMENT_LINE,
145:                        new JavaSourceStyleEntry(new RGB(63, 127, 95)));
146:                table.put(JavaSourceType.COMMENT_BLOCK,
147:                        new JavaSourceStyleEntry(new RGB(63, 127, 95)));
148:                table.put(JavaSourceType.JAVADOC, new JavaSourceStyleEntry(
149:                        new RGB(63, 95, 191)));
150:                table.put(JavaSourceType.JAVADOC_KEYWORD,
151:                        new JavaSourceStyleEntry(new RGB(127, 159, 191)));
152:                table.put(JavaSourceType.NUM_CONSTANT,
153:                        new JavaSourceStyleEntry(new RGB(153, 0, 0)));
154:                table.put(JavaSourceType.CHAR_CONSTANT,
155:                        new JavaSourceStyleEntry(new RGB(153, 0, 0)));
156:                table.put(JavaSourceType.PARENTHESIS, new JavaSourceStyleEntry(
157:                        new RGB(0, 0, 0)));
158:                table.put(JavaSourceType.JAVADOC_HTML_TAG,
159:                        new JavaSourceStyleEntry(new RGB(127, 127, 159)));
160:                table.put(JavaSourceType.JAVADOC_LINKS,
161:                        new JavaSourceStyleEntry(new RGB(63, 63, 191)));
162:                table.put(JavaSourceType.UNDEFINED, new JavaSourceStyleEntry(
163:                        new RGB(255, 97, 0)));
164:                table.put(JavaSourceType.BACKGROUND, new JavaSourceStyleEntry(
165:                        new RGB(255, 255, 255)));
166:                table.put(JavaSourceType.LINE_NUMBERS,
167:                        new JavaSourceStyleEntry(new RGB(128, 128, 128)));
168:                table.put(JavaSourceType.ANNOTATION, new JavaSourceStyleEntry(
169:                        new RGB(100, 100, 100)));
170:                return table;
171:            }
172:
173:            private static JavaSourceStyleTable createDefaultMonochromeStyleTable() {
174:                JavaSourceStyleTable table = new JavaSourceStyleTable(
175:                        "Monochrome"); //$NON-NLS-1$
176:                table.put(JavaSourceType.CODE, new JavaSourceStyleEntry(
177:                        RGB.BLACK));
178:                table.put(JavaSourceType.KEYWORD, new JavaSourceStyleEntry(
179:                        RGB.BLACK, true, false));
180:                table.put(JavaSourceType.CODE_TYPE, new JavaSourceStyleEntry(
181:                        RGB.BLACK, true, false));
182:                table.put(JavaSourceType.STRING, new JavaSourceStyleEntry(
183:                        RGB.BLACK));
184:                table.put(JavaSourceType.COMMENT_LINE,
185:                        new JavaSourceStyleEntry(RGB.BLACK, false, true));
186:                table.put(JavaSourceType.COMMENT_BLOCK,
187:                        new JavaSourceStyleEntry(RGB.BLACK, false, true));
188:                table.put(JavaSourceType.JAVADOC, new JavaSourceStyleEntry(
189:                        RGB.BLACK, false, true));
190:                table.put(JavaSourceType.JAVADOC_KEYWORD,
191:                        new JavaSourceStyleEntry(RGB.BLACK));
192:                table.put(JavaSourceType.NUM_CONSTANT,
193:                        new JavaSourceStyleEntry(RGB.BLACK));
194:                table.put(JavaSourceType.CHAR_CONSTANT,
195:                        new JavaSourceStyleEntry(RGB.BLACK));
196:                table.put(JavaSourceType.PARENTHESIS, new JavaSourceStyleEntry(
197:                        RGB.BLACK));
198:                table.put(JavaSourceType.JAVADOC_HTML_TAG,
199:                        new JavaSourceStyleEntry(RGB.BLACK));
200:                table.put(JavaSourceType.JAVADOC_LINKS,
201:                        new JavaSourceStyleEntry(RGB.BLACK));
202:                table.put(JavaSourceType.UNDEFINED, new JavaSourceStyleEntry(
203:                        RGB.BLACK));
204:                table.put(JavaSourceType.BACKGROUND, new JavaSourceStyleEntry(
205:                        RGB.WHITE));
206:                table.put(JavaSourceType.LINE_NUMBERS,
207:                        new JavaSourceStyleEntry(RGB.BLACK));
208:                table.put(JavaSourceType.ANNOTATION, new JavaSourceStyleEntry(
209:                        RGB.BLACK));
210:                return table;
211:            }
212:
213:            /**
214:             * Sets the style for the given source type to the given style.
215:             * 
216:             * @see #get(JavaSourceType)
217:             */
218:            public void put(JavaSourceType key,
219:                    JavaSourceStyleEntry javaSourceStyleEntry) {
220:                put(key.getName(), javaSourceStyleEntry);
221:            }
222:
223:            public void put(String key,
224:                    JavaSourceStyleEntry javaSourceStyleEntry) {
225:                table.put(key, javaSourceStyleEntry);
226:            }
227:
228:            /**
229:             * Gets a default style table.
230:             * 
231:             * @see #getDefaultEclipseStyleTable()
232:             * @see #getDefaultKawaStyleTable()
233:             */
234:            public static JavaSourceStyleTable getDefault() {
235:                return createDefaultEclipseStyleTable();
236:            }
237:
238:            /**
239:             * Gets a style table similar to the one from the Kawa IDE.
240:             * 
241:             * @see #getDefault()
242:             * @see #getDefaultEclipseStyleTable()
243:             * @see #getDefaultMonochromeStyleTable()
244:             */
245:            public static JavaSourceStyleTable getDefaultKawaStyleTable() {
246:                return createDefaultKawaStyleTable();
247:            }
248:
249:            /**
250:             * Gets a style table similar to the one from the IBM Eclipse IDE.
251:             * 
252:             * @see #getDefault()
253:             * @see #getDefaultKawaStyleTable()
254:             * @see #getDefaultMonochromeStyleTable()
255:             */
256:            public static JavaSourceStyleTable getDefaultEclipseStyleTable() {
257:                return createDefaultEclipseStyleTable();
258:            }
259:
260:            /**
261:             * Gets a style table for monochromatic output.
262:             * 
263:             * @see #getDefault()
264:             * @see #getDefaultEclipseStyleTable()
265:             * @see #getDefaultKawaStyleTable()
266:             */
267:            public static JavaSourceStyleTable getDefaultMonochromeStyleTable() {
268:                return createDefaultMonochromeStyleTable();
269:            }
270:
271:            /**
272:             * Returns the style for the given source type defined by this styletable.
273:             * 
274:             * @see #put(JavaSourceType, JavaSourceStyleEntry)
275:             * @see #put(JavaSourceType, JavaSourceStyleEntry)
276:             */
277:            public JavaSourceStyleEntry get(JavaSourceType key) {
278:                return get(key.getName());
279:            }
280:
281:            /** @deprecated As of Sep 12, 2004 (Markus Gebhard), replaced by {@link #get(JavaSourceType)} */
282:            public JavaSourceStyleEntry get(String key) {
283:                JavaSourceStyleEntry e = (JavaSourceStyleEntry) table.get(key);
284:                return e == null ? defaultColorEntry : e;
285:            }
286:
287:            public String getName() {
288:                return name;
289:            }
290:
291:            /** @deprecated As of Jan 2, 2004 (Markus Gebhard): Changing the name of a style table is not intended */
292:            public void setName(String name) {
293:                this.name = name;
294:            }
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.