Source Code Cross Referenced for RenderingHints.java in  » Apache-Harmony-Java-SE » java-package » java » awt » 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 » java package » java.awt 
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 Alexey A. Petrenko
019:         * @version $Revision$
020:         */package java.awt;
021:
022:        import java.util.Collection;
023:        import java.util.HashMap;
024:        import java.util.Iterator;
025:        import java.util.Map;
026:        import java.util.Set;
027:
028:        /**
029:         * RenderingHints
030:         *
031:         */
032:        public class RenderingHints implements  Map<Object, Object>, Cloneable {
033:            public static final Key KEY_ALPHA_INTERPOLATION = new KeyImpl(1);
034:            public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT = new KeyValue(
035:                    KEY_ALPHA_INTERPOLATION);
036:            public static final Object VALUE_ALPHA_INTERPOLATION_SPEED = new KeyValue(
037:                    KEY_ALPHA_INTERPOLATION);
038:            public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY = new KeyValue(
039:                    KEY_ALPHA_INTERPOLATION);
040:
041:            public static final Key KEY_ANTIALIASING = new KeyImpl(2);
042:            public static final Object VALUE_ANTIALIAS_DEFAULT = new KeyValue(
043:                    KEY_ANTIALIASING);
044:            public static final Object VALUE_ANTIALIAS_ON = new KeyValue(
045:                    KEY_ANTIALIASING);
046:            public static final Object VALUE_ANTIALIAS_OFF = new KeyValue(
047:                    KEY_ANTIALIASING);
048:
049:            public static final Key KEY_COLOR_RENDERING = new KeyImpl(3);
050:            public static final Object VALUE_COLOR_RENDER_DEFAULT = new KeyValue(
051:                    KEY_COLOR_RENDERING);
052:            public static final Object VALUE_COLOR_RENDER_SPEED = new KeyValue(
053:                    KEY_COLOR_RENDERING);
054:            public static final Object VALUE_COLOR_RENDER_QUALITY = new KeyValue(
055:                    KEY_COLOR_RENDERING);
056:
057:            public static final Key KEY_DITHERING = new KeyImpl(4);
058:            public static final Object VALUE_DITHER_DEFAULT = new KeyValue(
059:                    KEY_DITHERING);
060:            public static final Object VALUE_DITHER_DISABLE = new KeyValue(
061:                    KEY_DITHERING);
062:            public static final Object VALUE_DITHER_ENABLE = new KeyValue(
063:                    KEY_DITHERING);
064:
065:            public static final Key KEY_FRACTIONALMETRICS = new KeyImpl(5);
066:            public static final Object VALUE_FRACTIONALMETRICS_DEFAULT = new KeyValue(
067:                    KEY_FRACTIONALMETRICS);
068:            public static final Object VALUE_FRACTIONALMETRICS_ON = new KeyValue(
069:                    KEY_FRACTIONALMETRICS);
070:            public static final Object VALUE_FRACTIONALMETRICS_OFF = new KeyValue(
071:                    KEY_FRACTIONALMETRICS);
072:
073:            public static final Key KEY_INTERPOLATION = new KeyImpl(6);
074:            public static final Object VALUE_INTERPOLATION_BICUBIC = new KeyValue(
075:                    KEY_INTERPOLATION);
076:            public static final Object VALUE_INTERPOLATION_BILINEAR = new KeyValue(
077:                    KEY_INTERPOLATION);
078:            public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR = new KeyValue(
079:                    KEY_INTERPOLATION);
080:
081:            public static final Key KEY_RENDERING = new KeyImpl(7);
082:            public static final Object VALUE_RENDER_DEFAULT = new KeyValue(
083:                    KEY_RENDERING);
084:            public static final Object VALUE_RENDER_SPEED = new KeyValue(
085:                    KEY_RENDERING);
086:            public static final Object VALUE_RENDER_QUALITY = new KeyValue(
087:                    KEY_RENDERING);
088:
089:            public static final Key KEY_STROKE_CONTROL = new KeyImpl(8);
090:            public static final Object VALUE_STROKE_DEFAULT = new KeyValue(
091:                    KEY_STROKE_CONTROL);
092:            public static final Object VALUE_STROKE_NORMALIZE = new KeyValue(
093:                    KEY_STROKE_CONTROL);
094:            public static final Object VALUE_STROKE_PURE = new KeyValue(
095:                    KEY_STROKE_CONTROL);
096:
097:            public static final Key KEY_TEXT_ANTIALIASING = new KeyImpl(9);
098:            public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT = new KeyValue(
099:                    KEY_TEXT_ANTIALIASING);
100:            public static final Object VALUE_TEXT_ANTIALIAS_ON = new KeyValue(
101:                    KEY_TEXT_ANTIALIASING);
102:            public static final Object VALUE_TEXT_ANTIALIAS_OFF = new KeyValue(
103:                    KEY_TEXT_ANTIALIASING);
104:
105:            private HashMap<Object, Object> map = new HashMap<Object, Object>();
106:
107:            public RenderingHints(Map<Key, ?> map) {
108:                super ();
109:                if (map != null) {
110:                    putAll(map);
111:                }
112:            }
113:
114:            public RenderingHints(Key key, Object value) {
115:                super ();
116:                put(key, value);
117:            }
118:
119:            public void add(RenderingHints hints) {
120:                map.putAll(hints.map);
121:            }
122:
123:            public Object put(Object key, Object value) {
124:                if (!((Key) key).isCompatibleValue(value)) {
125:                    throw new IllegalArgumentException();
126:                }
127:
128:                return map.put(key, value);
129:            }
130:
131:            public Object remove(Object key) {
132:                return map.remove(key);
133:            }
134:
135:            public Object get(Object key) {
136:                return map.get(key);
137:            }
138:
139:            public Set<Object> keySet() {
140:                return map.keySet();
141:            }
142:
143:            public Set<Map.Entry<Object, Object>> entrySet() {
144:                return map.entrySet();
145:            }
146:
147:            public void putAll(Map<?, ?> m) {
148:                if (m instanceof  RenderingHints) {
149:                    map.putAll(((RenderingHints) m).map);
150:                } else {
151:                    Set<?> entries = m.entrySet();
152:
153:                    if (entries != null) {
154:                        Iterator<?> it = entries.iterator();
155:                        while (it.hasNext()) {
156:                            Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
157:                            Key key = (Key) entry.getKey();
158:                            Object val = entry.getValue();
159:                            put(key, val);
160:                        }
161:                    }
162:                }
163:            }
164:
165:            public Collection<Object> values() {
166:                return map.values();
167:            }
168:
169:            public boolean containsValue(Object value) {
170:                return map.containsValue(value);
171:            }
172:
173:            public boolean containsKey(Object key) {
174:                if (key == null) {
175:                    throw new NullPointerException();
176:                }
177:
178:                return map.containsKey(key);
179:            }
180:
181:            public boolean isEmpty() {
182:                return map.isEmpty();
183:            }
184:
185:            public void clear() {
186:                map.clear();
187:            }
188:
189:            public int size() {
190:                return map.size();
191:            }
192:
193:            @Override
194:            public boolean equals(Object o) {
195:                if (!(o instanceof  Map)) {
196:                    return false;
197:                }
198:
199:                Map<?, ?> m = (Map<?, ?>) o;
200:                Set<?> keys = keySet();
201:                if (!keys.equals(m.keySet())) {
202:                    return false;
203:                }
204:
205:                Iterator<?> it = keys.iterator();
206:                while (it.hasNext()) {
207:                    Key key = (Key) it.next();
208:                    Object v1 = get(key);
209:                    Object v2 = m.get(key);
210:                    if (!(v1 == null ? v2 == null : v1.equals(v2))) {
211:                        return false;
212:                    }
213:                }
214:                return true;
215:            }
216:
217:            @Override
218:            public int hashCode() {
219:                return map.hashCode();
220:            }
221:
222:            @SuppressWarnings("unchecked")
223:            @Override
224:            public Object clone() {
225:                RenderingHints clone = new RenderingHints(null);
226:                clone.map = (HashMap<Object, Object>) this .map.clone();
227:                return clone;
228:            }
229:
230:            @Override
231:            public String toString() {
232:                return "RenderingHints[" + map.toString() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
233:            }
234:
235:            /**
236:             * Key
237:             */
238:            public abstract static class Key {
239:                private final int key;
240:
241:                protected Key(int key) {
242:                    this .key = key;
243:                }
244:
245:                @Override
246:                public final boolean equals(Object o) {
247:                    return this  == o;
248:                }
249:
250:                @Override
251:                public final int hashCode() {
252:                    return System.identityHashCode(this );
253:                }
254:
255:                protected final int intKey() {
256:                    return key;
257:                }
258:
259:                public abstract boolean isCompatibleValue(Object val);
260:            }
261:
262:            /**
263:             * Private implementation of Key class
264:             */
265:            private static class KeyImpl extends Key {
266:
267:                protected KeyImpl(int key) {
268:                    super (key);
269:                }
270:
271:                @Override
272:                public boolean isCompatibleValue(Object val) {
273:                    if (!(val instanceof  KeyValue)) {
274:                        return false;
275:                    }
276:
277:                    return ((KeyValue) val).key == this ;
278:                }
279:            }
280:
281:            /**
282:             * Private class KeyValue is used as value for Key class instance.
283:             */
284:            private static class KeyValue {
285:                private final Key key;
286:
287:                protected KeyValue(Key key) {
288:                    this.key = key;
289:                }
290:            }
291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.