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


001:        /*
002:         * $Id: MorphFillStyle.java,v 1.1 2002/02/15 23:46:26 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.shape;
052:
053:        import java.awt.geom.*;
054:        import java.io.PrintStream;
055:        import org.openlaszlo.iv.flash.util.*;
056:        import org.openlaszlo.iv.flash.api.*;
057:        import org.openlaszlo.iv.flash.parser.*;
058:        import org.openlaszlo.iv.flash.api.image.*;
059:
060:        /**
061:         * FillStyle of MorphShape.
062:         *
063:         * @author Dmitry Skavish
064:         * @see FillStyle
065:         */
066:        public final class MorphFillStyle extends FlashItem {
067:
068:            private int type; // type of this fillstyle
069:            private Color color_start; // start color of this fillstyle
070:            private Color color_end; // end color of this fillstyle
071:            private AffineTransform matrix_start; // start matrix of this fillstyle
072:            private AffineTransform matrix_end; // end matrix of this fillstyle
073:            private MorphGradient gradient; // gradient of this fillstyle
074:            private Bitmap bitmap; // bitmap of this fillstyle
075:
076:            public MorphFillStyle() {
077:            }
078:
079:            public int getType() {
080:                return type;
081:            }
082:
083:            public void setType(int type) {
084:                this .type = type;
085:            }
086:
087:            public Color getColorStart() {
088:                return color_start;
089:            }
090:
091:            public void setColorStart(Color color) {
092:                this .color_start = color;
093:            }
094:
095:            public Color getColorEnd() {
096:                return color_end;
097:            }
098:
099:            public void setColorEnd(Color color) {
100:                this .color_end = color;
101:            }
102:
103:            public AffineTransform getMatrixStart() {
104:                return matrix_start;
105:            }
106:
107:            public void setMatrixStart(AffineTransform matrix) {
108:                this .matrix_start = matrix;
109:            }
110:
111:            public AffineTransform getMatrixEnd() {
112:                return matrix_end;
113:            }
114:
115:            public void setMatrixEnd(AffineTransform matrix) {
116:                this .matrix_end = matrix;
117:            }
118:
119:            public MorphGradient getGraduent() {
120:                return gradient;
121:            }
122:
123:            public void setGradient(MorphGradient gradient) {
124:                this .gradient = gradient;
125:            }
126:
127:            public Bitmap getBitmap() {
128:                return bitmap;
129:            }
130:
131:            public void setBitmap(Bitmap bitmap) {
132:                this .bitmap = bitmap;
133:            }
134:
135:            /**
136:             * Creates new solid fill.
137:             *
138:             * @param color_start start color
139:             * @param color_end end color
140:             * @return solid fillstyle
141:             */
142:            public static MorphFillStyle newSolid(Color color_start,
143:                    Color color_end) {
144:                MorphFillStyle fs = new MorphFillStyle();
145:                fs.setColorStart(color_start);
146:                fs.setColorEnd(color_end);
147:                fs.setType(FillStyle.SOLID);
148:                return fs;
149:            }
150:
151:            /**
152:             * Creates new linear gradient fill.
153:             *
154:             * @param gradient   gradient of gradient fill
155:             * @param matrix_start start matrix
156:             * @param matrix_end end matrix
157:             * @return linear gradient fill
158:             */
159:            public static MorphFillStyle newLinearGradient(
160:                    MorphGradient gradient, AffineTransform matrix_start,
161:                    AffineTransform matrix_end) {
162:                MorphFillStyle fs = new MorphFillStyle();
163:                fs.setGradient(gradient);
164:                fs.setMatrixStart(matrix_start);
165:                fs.setMatrixEnd(matrix_end);
166:                fs.setType(FillStyle.LINEAR_GRADIENT);
167:                return fs;
168:            }
169:
170:            /**
171:             * Creates new radial gradient fill.
172:             *
173:             * @param gradient gradient of gradient fill
174:             * @param matrix_start start matrix
175:             * @param matrix_end end matrix
176:             * @return radial gradient fill
177:             */
178:            public static MorphFillStyle newRadialGradient(
179:                    MorphGradient gradient, AffineTransform matrix_start,
180:                    AffineTransform matrix_end) {
181:                MorphFillStyle fs = new MorphFillStyle();
182:                fs.setGradient(gradient);
183:                fs.setMatrixStart(matrix_start);
184:                fs.setMatrixEnd(matrix_end);
185:                fs.setType(FillStyle.RADIAL_GRADIENT);
186:                return fs;
187:            }
188:
189:            /**
190:             * Creates new tiled bitmap fill.
191:             *
192:             * @param bitmap bitmap of bitmap fill
193:             * @param matrix_start start matrix
194:             * @param matrix_end end matrix
195:             * @return tiled bitmap fill
196:             */
197:            public static MorphFillStyle newTiledBitmap(Bitmap bitmap,
198:                    AffineTransform matrix_start, AffineTransform matrix_end) {
199:                MorphFillStyle fs = new MorphFillStyle();
200:                fs.setBitmap(bitmap);
201:                fs.setMatrixStart(matrix_start);
202:                fs.setMatrixEnd(matrix_end);
203:                fs.setType(FillStyle.TILED_BITMAP);
204:                return fs;
205:            }
206:
207:            /**
208:             * Creates new clipped bitmap fill.
209:             *
210:             * @param bitmap bitmap of bitmap fill
211:             * @param matrix_start start matrix
212:             * @param matrix_end end matrix
213:             * @return clipped bitmap fill
214:             */
215:            public static MorphFillStyle newClippedBitmap(Bitmap bitmap,
216:                    AffineTransform matrix_start, AffineTransform matrix_end) {
217:                MorphFillStyle fs = new MorphFillStyle();
218:                fs.setBitmap(bitmap);
219:                fs.setMatrixStart(matrix_start);
220:                fs.setMatrixEnd(matrix_end);
221:                fs.setType(FillStyle.CLIPPED_BITMAP);
222:                return fs;
223:            }
224:
225:            /**
226:             * Parses morph fill style
227:             *
228:             * @param p      parser
229:             * @return parsed fillstyle
230:             */
231:            public static MorphFillStyle parse(Parser p) {
232:                MorphFillStyle fs = new MorphFillStyle();
233:                int type = fs.type = p.getUByte();
234:
235:                if ((type & 0x10) != 0) { // gradient
236:
237:                    // Get the gradient matrix.
238:                    fs.matrix_start = p.getMatrix();
239:                    fs.matrix_end = p.getMatrix();
240:                    // get gradient itself
241:                    fs.gradient = MorphGradient.parse(p);
242:
243:                } else if ((type & 0x40) != 0) { // bitmap
244:
245:                    int id = p.getUWord(); // id may be equal to 0xffff, I don't know what it means
246:                    fs.bitmap = (Bitmap) p.getDef(id);
247:                    fs.matrix_start = p.getMatrix();
248:                    fs.matrix_end = p.getMatrix();
249:
250:                } else { // A solid color
251:
252:                    fs.color_start = AlphaColor.parse(p);
253:                    fs.color_end = AlphaColor.parse(p);
254:                }
255:
256:                return fs;
257:            }
258:
259:            /**
260:             * Writes fillstyle to flash buffer
261:             *
262:             * @param fob    buffer to write
263:             */
264:            public void write(FlashOutput fob) {
265:                fob.writeByte(type);
266:                switch (type) {
267:                case FillStyle.SOLID:
268:                    color_start.writeRGBA(fob);
269:                    color_end.writeRGBA(fob);
270:                    break;
271:                case FillStyle.LINEAR_GRADIENT:
272:                case FillStyle.RADIAL_GRADIENT:
273:                    fob.write(matrix_start);
274:                    fob.write(matrix_end);
275:                    gradient.write(fob);
276:                    break;
277:                case FillStyle.TILED_BITMAP:
278:                case FillStyle.CLIPPED_BITMAP:
279:                    if (bitmap == null) {
280:                        fob.writeWord(0xffff);
281:                    } else {
282:                        fob.writeDefID(bitmap);
283:                    }
284:                    fob.write(matrix_start);
285:                    fob.write(matrix_end);
286:                    break;
287:                }
288:            }
289:
290:            public void printContent(PrintStream out, String indent) {
291:                switch (type) {
292:                case FillStyle.SOLID:
293:                    out.println(indent + "MorphFillStyle (SOLID):");
294:                    color_start.printContent(out, indent + "       ");
295:                    color_end.printContent(out, indent + "       ");
296:                    break;
297:                case FillStyle.LINEAR_GRADIENT:
298:                    out.println(indent + "MorphFillStyle (LINEAR_GRADIENT):");
299:                    out.println(indent + "       " + matrix_start);
300:                    out.println(indent + "       " + matrix_end);
301:                    gradient.printContent(out, indent + "       ");
302:                    break;
303:                case FillStyle.RADIAL_GRADIENT:
304:                    out.println(indent + "FillStyle (RADIAL_GRADIENT):");
305:                    out.println(indent + "       " + matrix_start);
306:                    out.println(indent + "       " + matrix_end);
307:                    gradient.printContent(out, indent + "       ");
308:                    break;
309:                case FillStyle.TILED_BITMAP:
310:                    out.println(indent + "FillStyle (TILED_BITMAP):");
311:                    out.println(indent + "       " + matrix_start);
312:                    out.println(indent + "       " + matrix_end);
313:                    out.println(indent + "    bitmapID=" + bitmap.getID());
314:                    break;
315:                case FillStyle.CLIPPED_BITMAP:
316:                    out.println(indent + "FillStyle (CLIPPED_BITMAP):");
317:                    out.println(indent + "       " + matrix_start);
318:                    out.println(indent + "       " + matrix_end);
319:                    out.println(indent + "    bitmapID=" + bitmap.getID());
320:                    break;
321:                }
322:            }
323:
324:            protected FlashItem copyInto(FlashItem item, ScriptCopier copier) {
325:                ((MorphFillStyle) item).type = type;
326:                switch (type) {
327:                case FillStyle.SOLID:
328:                    ((MorphFillStyle) item).color_start = (Color) color_start
329:                            .getCopy(copier);
330:                    ((MorphFillStyle) item).color_end = (Color) color_end
331:                            .getCopy(copier);
332:                    break;
333:                case FillStyle.LINEAR_GRADIENT:
334:                case FillStyle.RADIAL_GRADIENT:
335:                    ((MorphFillStyle) item).gradient = (MorphGradient) gradient
336:                            .getCopy(copier);
337:                    ((MorphFillStyle) item).matrix_start = (AffineTransform) matrix_start
338:                            .clone();
339:                    ((MorphFillStyle) item).matrix_end = (AffineTransform) matrix_end
340:                            .clone();
341:                    break;
342:                case FillStyle.TILED_BITMAP:
343:                case FillStyle.CLIPPED_BITMAP:
344:                    ((MorphFillStyle) item).bitmap = (Bitmap) copier
345:                            .copy(bitmap);
346:                    ((MorphFillStyle) item).matrix_start = (AffineTransform) matrix_start
347:                            .clone();
348:                    ((MorphFillStyle) item).matrix_end = (AffineTransform) matrix_end
349:                            .clone();
350:                    break;
351:                }
352:                return item;
353:            }
354:
355:            public FlashItem getCopy(ScriptCopier copier) {
356:                return copyInto(new MorphFillStyle(), copier);
357:            }
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.