Source Code Cross Referenced for AlphaColor.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » iv » flash » api » 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 » Laszlo 4.0.10 » org.openlaszlo.iv.flash.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: AlphaColor.java,v 1.2 2002/02/15 23:44:27 skavish Exp $
003:         *
004:         * ==========================================================================
005:         *
006:         * The JGenerator Software License, Version 1.0
007:         *
008:         * Copyright (c) 2000 Dmitry Skavish (skavish@usa.net). All rights reserved.
009:         *
010:         * Redistribution and use in source and binary forms, with or without
011:         * modification, are permitted provided that the following conditions are met:
012:         *
013:         * 1. Redistributions of source code must retain the above copyright
014:         *    notice, this list of conditions and the following disclaimer.
015:         *
016:         * 2. Redistributions in binary form must reproduce the above copyright
017:         *    notice, this list of conditions and the following disclaimer in
018:         *    the documentation and/or other materials provided with the
019:         *    distribution.
020:         *
021:         * 3. The end-user documentation included with the redistribution, if
022:         *    any, must include the following acknowlegement:
023:         *    "This product includes software developed by Dmitry Skavish
024:         *     (skavish@usa.net, http://www.flashgap.com/)."
025:         *    Alternately, this acknowlegement may appear in the software itself,
026:         *    if and wherever such third-party acknowlegements normally appear.
027:         *
028:         * 4. The name "The JGenerator" must not be used to endorse or promote
029:         *    products derived from this software without prior written permission.
030:         *    For written permission, please contact skavish@usa.net.
031:         *
032:         * 5. Products derived from this software may not be called "The JGenerator"
033:         *    nor may "The JGenerator" appear in their names without prior written
034:         *    permission of Dmitry Skavish.
035:         *
036:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039:         * DISCLAIMED.  IN NO EVENT SHALL DMITRY SKAVISH OR THE OTHER
040:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047:         * SUCH DAMAGE.
048:         *
049:         */
050:
051:        package org.openlaszlo.iv.flash.api;
052:
053:        import java.io.*;
054:        import java.util.*;
055:        import java.lang.Math;
056:        import org.openlaszlo.iv.flash.parser.*;
057:        import org.openlaszlo.iv.flash.util.*;
058:
059:        /**
060:         * Color with alpha value
061:         *
062:         * @author Dmitry Skavish
063:         * @see Color
064:         */
065:        public final class AlphaColor extends Color {
066:
067:            // some predefined colors
068:            public static final AlphaColor white = new AlphaColor(255, 255, 255);
069:            public static final AlphaColor black = new AlphaColor(0, 0, 0);
070:            public static final AlphaColor red = new AlphaColor(255, 0, 0);
071:            public static final AlphaColor blue = new AlphaColor(0, 0, 255);
072:            public static final AlphaColor green = new AlphaColor(0, 255, 0);
073:            public static final AlphaColor lightgray = new AlphaColor(180, 180,
074:                    180);
075:            public static final AlphaColor gray = new AlphaColor(150, 150, 150);
076:            public static final AlphaColor darkgray = new AlphaColor(90, 90, 90);
077:
078:            private int a;
079:
080:            public AlphaColor() {
081:            }
082:
083:            /**
084:             * Creates AlphaColor from int
085:             *
086:             * @param rgba   color encoded as follows: alpha<<24 | red<<16 | green<<8 | blue
087:             */
088:            public AlphaColor(int rgba) {
089:                setRGBA(rgba);
090:            }
091:
092:            /**
093:             * Creates opaque AlphaColor from three components
094:             *
095:             * @param r      red
096:             * @param g      green
097:             * @param b      blue
098:             */
099:            public AlphaColor(int r, int g, int b) {
100:                this (r, g, b, 255);
101:            }
102:
103:            /**
104:             * Creates opaque AlphaColor from three float components
105:             *
106:             * @param r      red
107:             * @param g      green
108:             * @param b      blue
109:             */
110:            public AlphaColor(float r, float g, float b) {
111:                this (r, g, b, 1.0f);
112:            }
113:
114:            /**
115:             * Creates AlphaColor from four components
116:             *
117:             * @param r      red
118:             * @param g      green
119:             * @param b      blue
120:             * @param a      alpha
121:             */
122:            public AlphaColor(int r, int g, int b, int a) {
123:                super (r, g, b);
124:                this .a = a;
125:            }
126:
127:            /**
128:             * Creates AlphaColor from four components
129:             *
130:             * @param r      red
131:             * @param g      green
132:             * @param b      blue
133:             * @param a      alpha
134:             */
135:            public AlphaColor(float r, float g, float b, float a) {
136:                super (r, g, b);
137:                this .a = Math.round(a * 255);
138:            }
139:
140:            public int getAlpha() {
141:                return a;
142:            }
143:
144:            /**
145:             * Returns color encoded into int
146:             *
147:             * @return color encoded as follows: alpha<<24 | red<<16 | green<<8 | blue
148:             */
149:            public int getRGBA() {
150:                return a << 24 | getRGB();
151:            }
152:
153:            public void setAlpha(int a) {
154:                this .a = a;
155:            }
156:
157:            /**
158:             * Sets color encoded into int
159:             *
160:             * @param rgba   color encoded as folows:  alpha<<24 | red<<16 | green<<8 | blue
161:             */
162:            public void setRGBA(int rgba) {
163:                setRGB(rgba);
164:                this .a = (rgba & 0xff000000) >>> 24;
165:            }
166:
167:            /**
168:             * Writes object into flash buffer
169:             *
170:             * @param fob    buffer to write
171:             */
172:            public void write(FlashOutput fob) {
173:                writeRGBA(fob);
174:            }
175:
176:            public void writeRGBA(FlashOutput fob) {
177:                super .writeRGB(fob);
178:                fob.writeByte(a);
179:            }
180:
181:            public void printContent(PrintStream out, String indent) {
182:                out.println(indent + "AlphaColor: (0x" + Util.b2h(r) + ",0x"
183:                        + Util.b2h(g) + ",0x" + Util.b2h(b) + ",0x"
184:                        + Util.b2h(a) + ")");
185:            }
186:
187:            public static AlphaColor parse(Parser p) {
188:                return parseRGBA(p);
189:            }
190:
191:            /**
192:             * Skips color without parsing
193:             *
194:             * @param p      parser to skip in
195:             */
196:            public static void skip(Parser p) {
197:                p.skip(4);
198:            }
199:
200:            protected FlashItem copyInto(FlashItem item, ScriptCopier copier) {
201:                super .copyInto(item, copier);
202:                ((AlphaColor) item).a = a;
203:                return item;
204:            }
205:
206:            public FlashItem getCopy(ScriptCopier copier) {
207:                return copyInto(new AlphaColor(), copier);
208:            }
209:
210:            public boolean equals(Object o) {
211:                if (o instanceof  AlphaColor) {
212:                    AlphaColor c = (AlphaColor) o;
213:                    return r == c.r && g == c.g && b == c.b && a == c.a;
214:                } else
215:                    return a == 255 && super .equals(o);
216:            }
217:
218:            /**
219:             * Returns true if this color has alpha<BR>
220:             * Always returns true
221:             *
222:             * @return true
223:             */
224:            public boolean hasAlpha() {
225:                return true;
226:            }
227:
228:            /**
229:             * Creates new AlphaColor from this one with reduced alpha component by half
230:             *
231:             * @return reduced color
232:             */
233:            public AlphaColor getReducedColor() {
234:                double k = 0.5;
235:                //    return new Color( (int)(r*k), (int)(g*k), (int)(b*k), a );
236:                return new AlphaColor(r, g, b, (int) (a * k));
237:            }
238:
239:            /**
240:             * Returns color by name
241:             *
242:             * @param name   name of the color<BR>
243:             *               see static initalizer
244:             * @return color or null
245:             */
246:            public static AlphaColor getColor(String name) {
247:                return (AlphaColor) colors.get(name.toLowerCase());
248:            }
249:
250:            public static Enumeration getAllColors() {
251:                return colors.elements();
252:            }
253:
254:            // static stuff
255:            private static final Hashtable colors = new Hashtable();
256:
257:            private static void add(String name, int rgb) {
258:                AlphaColor c = new AlphaColor();
259:                c.setRGB(rgb);
260:                c.setAlpha(255);
261:                colors.put(name.toLowerCase(), c);
262:            }
263:
264:            static {
265:                add("black", 0x000000);
266:                add("navy", 0x000080);
267:                add("blue", 0x0000FF);
268:                add("green", 0x008000);
269:                add("dark cyan", 0x008B8B);
270:                add("dark turquoise", 0x00CED1);
271:                add("lime", 0x00FF00);
272:                add("aqua", 0x00FFFF);
273:                add("midnight blue", 0x191970);
274:                add("light seagreen", 0x20B2AA);
275:                add("forest green", 0x228B22);
276:                add("lime green", 0x32CD32);
277:                add("turquoise", 0x40E0D0);
278:                add("dark slateblue", 0x4682B4);
279:                add("medium turquoise", 0x48D1CC);
280:                add("cadet blue", 0x5F9EA0);
281:                add("medium aquamarine", 0x66CDAA);
282:                add("slate blue", 0x6A5ACD);
283:                add("slate gray", 0x708090);
284:                add("medium slateblue", 0x7B68EE);
285:                add("chartreuse", 0x7FFF00);
286:                add("maroon", 0x800000);
287:                add("olive", 0x80800);
288:                add("sky blue", 0x87CEEB);
289:                add("dark red", 0x8B0000);
290:                add("saddle brown", 0x8B4513);
291:                add("light green", 0x90EE90);
292:                add("dark violet", 0x9400D3);
293:                add("dark orchid", 0x9932CC);
294:                add("sienna", 0xA0522D);
295:                add("dark gray", 0xA9A9A9);
296:                add("green yellow", 0xADFF2F);
297:                add("pale turquoise", 0xAFEEEE);
298:                add("firebrick", 0xB22222);
299:                add("dark goldenrod", 0xB8860B);
300:                add("medium orchid", 0xBA55D);
301:                add("medium violetred", 0xC71585);
302:                add("indian red", 0xCD5C5C);
303:                add("peru", 0xCD853F);
304:                add("thistle", 0xD8BFD8);
305:                add("orchid", 0xDA70D6);
306:                add("goldenrod", 0xDAA520);
307:                add("pale violetred", 0xDB7093);
308:                add("crimson", 0xDC143C);
309:                add("dark salmon", 0xE9967A);
310:                add("violet", 0xEE82EE);
311:                add("pale goldenrod", 0xEEE8AA);
312:                add("light coral", 0xF08080);
313:                add("sandy brown", 0xF4A460);
314:                add("wheat", 0xF5DEB3);
315:                add("ghost white", 0xF8F8FF);
316:                add("salmon", 0xFA8072);
317:                add("antique white", 0xFAEBD7);
318:                add("red", 0xFF0000);
319:                add("fuchsia", 0xFF00FF);
320:                add("magenta", 0xFF00FF);
321:                add("hot pink", 0xFF69B4);
322:                add("coral", 0xFF7F50);
323:                add("dark orange", 0xFF8C00);
324:                add("light salmon", 0xFFA07A);
325:                add("orange", 0xFFA500);
326:                add("light pink", 0xFFB6C1);
327:                add("pink", 0xFFC0CB);
328:                add("papaya whip", 0xFFEFD5);
329:                add("lavender blush", 0xFFF0F5);
330:                add("seashel", 0xFFF5EE);
331:                add("snow", 0xFFFAFA);
332:                add("yellow", 0xFFFF00);
333:                add("white", 0xFFFFFF);
334:                add("dark blue", 0x00008B);
335:                add("medium blue", 0x0000CD);
336:                add("dark green", 0x006400);
337:                add("teal", 0x008080);
338:                add("deep skyblue", 0x00BFFF);
339:                add("medium springgreen", 0x00FA9A);
340:                add("spring green", 0x00FF7F);
341:                add("cyan", 0x00FFFF);
342:                add("dodger blue", 0x1E90FF);
343:                add("sea green", 0x2E8B57);
344:                add("dark slategray", 0x2F4F4F);
345:                add("medium seagreen", 0x3CB371);
346:                add("royal blue", 0x4169E1);
347:                add("steel blue", 0x4682B4);
348:                add("indigo", 0x4B0082);
349:                add("cornflower blue", 0x6495ED);
350:                add("dim gray", 0x696969);
351:                add("olive drab", 0x6B8E23);
352:                add("light slategray", 0x778899);
353:                add("lawn green", 0x7CFC00);
354:                add("aquamarine", 0x7FFFD4);
355:                add("purple", 0x800080);
356:                add("gray", 0x808080);
357:                add("blue violet", 0x87CEFA);
358:                add("dark magenta", 0x8B008B);
359:                add("dark seagreen", 0x8FBC8F);
360:                add("medium purple", 0x9370DB);
361:                add("pale green", 0x98FB98);
362:                add("yellow green", 0x9ACD32);
363:                add("brown", 0xA52A2A);
364:                add("light blue", 0xADD8E6);
365:                add("light steelblue", 0xB0C4DE);
366:                add("powder blue", 0xB0E0E6);
367:                add("rosy brown", 0xBC8F8F);
368:                add("dark khaki", 0xBC8F8F);
369:                add("silver", 0xC0C0C0);
370:                add("chocolate", 0xD2691E);
371:                add("tan", 0xD2B48C);
372:                add("light grey", 0xD3D3D3);
373:                add("gainsboro", 0xDCDCDC);
374:                add("plum", 0xDDA0DD);
375:                add("burlywood", 0xDEB887);
376:                add("light cyan", 0xE0FFFF);
377:                add("lavender", 0xE6E6FA);
378:                add("khaki", 0xF0E68C);
379:                add("alice blue", 0xF0F8FF);
380:                add("honeydew", 0xF0FFF0);
381:                add("azure", 0xF0FFFF);
382:                add("white smoke", 0xF5F5F5);
383:                add("mint cream", 0xF5FFFA);
384:                add("linen", 0xFAF0E6);
385:                add("light goldenrodyellow", 0xFAFAD2);
386:                add("old lace", 0xFDF5E6);
387:                add("deep pink", 0xFF1493);
388:                add("orange red", 0xFF4500);
389:                add("tomato", 0xFF6347);
390:                add("gold", 0xFFD700);
391:                add("peach puff", 0xFFDAB9);
392:                add("navajo white", 0xFFDEAD);
393:                add("moccasin", 0xFFE4B5);
394:                add("bisque", 0xFFE4C4);
395:                add("misty rose", 0xFFE4E1);
396:                add("blanched almond", 0xFFEBCD);
397:                add("cornsilk", 0xFFF8DC);
398:                add("lemon chiffon", 0xFFFACD);
399:                add("floral white", 0xFFFAF0);
400:                add("light yellow", 0xFFFFE0);
401:                add("ivory", 0xFFFFF0);
402:            }
403:
404:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.