Source Code Cross Referenced for PiscesShapeRenderer.java in  » 6.0-JDK-Modules » j2me » com » sun » pisces » 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 » 6.0 JDK Modules » j2me » com.sun.pisces 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
004:         * 
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License version
007:         * 2 only, as published by the Free Software Foundation. 
008:         * 
009:         * This program is distributed in the hope that it will be useful, but
010:         * WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * General Public License version 2 for more details (a copy is
013:         * included at /legal/license.txt). 
014:         * 
015:         * You should have received a copy of the GNU General Public License
016:         * version 2 along with this work; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
018:         * 02110-1301 USA 
019:         * 
020:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
021:         * Clara, CA 95054 or visit www.sun.com if you need additional
022:         * information or have any questions. 
023:         *
024:         */
025:
026:        package com.sun.pisces;
027:
028:        import com.sun.me.gci.renderer.GCIAdvancedShapeRenderer;
029:        import com.sun.me.gci.renderer.GCIRenderContext;
030:        import com.sun.me.gci.renderer.GCIRenderer;
031:        import com.sun.me.gci.renderer.GCIShapeRenderer;
032:        import com.sun.me.gci.surface.GCIDrawingSurface;
033:        import com.sun.me.gci.surface.GCISurfaceInfo;
034:
035:        /**
036:         * <code>PiscesShapeRenderer</code>
037:         */
038:        public class PiscesShapeRenderer implements  GCIShapeRenderer {
039:            protected PiscesRenderer piscesRenderer;
040:
041:            // 1.0 in Fixed point 16.16 notation.
042:            static final float FIXED_1_0 = 65536.0f;
043:
044:            GCIRenderContext context;
045:            int[] clip = new int[4];
046:
047:            private static final int[] GCI_TO_PISCES_COMPOSITE = {
048:                    RendererBase.COMPOSITE_SRC_OVER,
049:                    RendererBase.COMPOSITE_CLEAR, RendererBase.COMPOSITE_SRC,
050:                    RendererBase.COMPOSITE_SRC_OVER };
051:
052:            /**
053:             * Factory method as mandated by GCI.
054:             */
055:            public static GCIShapeRenderer newInstance(
056:                    GCIDrawingSurface surface, boolean lcduiGraphics,
057:                    boolean useContextTransform) {
058:                if (surface.isSurfaceInfoDynamic()) {
059:                    return new PiscesShapeRenderer.DynamicSurface(surface);
060:                } else {
061:                    return new PiscesShapeRenderer(surface);
062:                }
063:            }
064:
065:            /**
066:             * Factory method as mandated by GCI.
067:             */
068:            public static GCIAdvancedShapeRenderer newAdvancedInstance(
069:                    GCIDrawingSurface surface) {
070:                if (surface.isSurfaceInfoDynamic()) {
071:                    return new PiscesAdvancedShapeRenderer.DynamicSurface(
072:                            surface);
073:                } else {
074:                    return new PiscesAdvancedShapeRenderer(surface);
075:                }
076:            }
077:
078:            public GCIRenderer create() {
079:                return new PiscesShapeRenderer(this .context.getDrawingSurface());
080:            }
081:
082:            protected static int getByteShiftForPixelArrayCount(int arrayType) {
083:                int denom = 1;
084:                switch (arrayType) {
085:                case GCISurfaceInfo.TYPE_JAVA_ARRAY_BYTE:
086:                    denom = 0;
087:                    break;
088:                case GCISurfaceInfo.TYPE_JAVA_ARRAY_SHORT:
089:                    denom = 1;
090:                    break;
091:                default:
092:                    denom = 2;
093:                    break;
094:                }
095:                return denom;
096:            }
097:
098:            /** Creates a new instance of PiscesShapeRenderer */
099:            protected PiscesShapeRenderer(GCIDrawingSurface surface) {
100:                piscesRenderer = new PiscesRenderer(new PiscesGCISurface(
101:                        surface));
102:
103:                this .clip[0] = 0;
104:                this .clip[1] = 0;
105:                this .clip[2] = surface.getWidth();
106:                this .clip[3] = surface.getHeight();
107:            }
108:
109:            /**
110:             * Notifies the renderer that a render context is created
111:             * for this renderer. The context must be initialized with all the
112:             * attributes when this method is invoked.
113:             */
114:            public void contextCreated(GCIRenderContext context) {
115:                GCIDrawingSurface surface = context.getDrawingSurface();
116:                this .context = context;
117:                clipModified();
118:                paintModified();
119:                strokeModified();
120:                compositeModified();
121:                transformModified();
122:            }
123:
124:            /**
125:             * Notifies the renderer that the render context is disposed. The
126:             * renderer implementation can free any resources allocated for
127:             * servicing the context.
128:             */
129:            public void contextDisposed() {
130:                releaseSurface();
131:                this .context = null;
132:            }
133:
134:            /**
135:             * Notifies the renderer that some of the attribute[s] in the
136:             * render context has been modified. 
137:             *
138:             * @param attribute one of the constant specified in the <b>see also</b>
139:             *        section should be passed.
140:             *
141:             * @see com.sun.me.gci.renderer.GCIRenderContext#ATTRIBUTE_CLIP
142:             * 
143:             */
144:            public void attributesModified(int attribute) {
145:                if ((attribute & GCIRenderContext.ATTRIBUTE_CLIP) != 0) {
146:                    this .clipModified();
147:                }
148:                if ((attribute & GCIRenderContext.ATTRIBUTE_PAINT) != 0) {
149:                    this .paintModified();
150:                }
151:                if ((attribute & GCIRenderContext.ATTRIBUTE_COMPOSITE) != 0) {
152:                    this .compositeModified();
153:                }
154:                if ((attribute & GCIRenderContext.ATTRIBUTE_STROKE) != 0) {
155:                    this .strokeModified();
156:                }
157:            }
158:
159:            void acquireSurface() {
160:                ((PiscesGCISurface) piscesRenderer.surface).acquireSurface();
161:            }
162:
163:            void releaseSurface() {
164:                ((PiscesGCISurface) piscesRenderer.surface).releaseSurface();
165:            }
166:
167:            public void drawPolyline(int xPoints[], int yPoints[], int nPoints,
168:                    boolean close) {
169:                fillOrDrawPolyline(xPoints, yPoints, nPoints, close, true /* stroke the polyline */
170:                );
171:            }
172:
173:            public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {
174:                fillOrDrawPolyline(xPoints, yPoints, nPoints, true, /* close the path */
175:                false /* fill the polyline */
176:                );
177:            }
178:
179:            private void fillOrDrawPolyline(int xPoints[], int yPoints[],
180:                    int nPoints, boolean close, boolean stroke) {
181:                this .context.getDrawingSurface().renderingBegin();
182:                piscesRenderer.beginRendering(RendererBase.WIND_NON_ZERO);
183:
184:                // path begin
185:                if (!stroke)
186:                    piscesRenderer.setFill();
187:                piscesRenderer.moveTo((xPoints[0] << 16), (yPoints[0] << 16));
188:                for (int i = 1; i < nPoints; i++) {
189:                    piscesRenderer.lineTo((xPoints[i] << 16),
190:                            (yPoints[i] << 16));
191:                }
192:                if (close) {
193:                    piscesRenderer.close();
194:                }
195:                piscesRenderer.end(); // path end
196:                piscesRenderer.endRendering();
197:                this .context.getDrawingSurface().renderingEnd(this .clip);
198:            }
199:
200:            public void drawArc(int x, int y, int width, int height,
201:                    int startAngle, int arcAngle) {
202:                this .context.getDrawingSurface().renderingBegin();
203:                piscesRenderer.drawArc(x << 16, y << 16, width << 16,
204:                        height << 16, startAngle << 16, arcAngle << 16,
205:                        PiscesRenderer.ARC_OPEN);
206:                this .context.getDrawingSurface().renderingEnd(this .clip);
207:            }
208:
209:            public void fillArc(int x, int y, int width, int height,
210:                    int startAngle, int arcAngle) {
211:                this .context.getDrawingSurface().renderingBegin();
212:                piscesRenderer.fillArc(x << 16, y << 16, width << 16,
213:                        height << 16, startAngle << 16, arcAngle << 16,
214:                        PiscesRenderer.ARC_PIE);
215:                this .context.getDrawingSurface().renderingEnd(this .clip);
216:
217:            }
218:
219:            public void fillOval(int x, int y, int w, int h) {
220:                this .context.getDrawingSurface().renderingBegin();
221:                piscesRenderer.fillOval(x << 16, y << 16, w << 16, h << 16);
222:                this .context.getDrawingSurface().renderingEnd(this .clip);
223:            }
224:
225:            public void fillRoundRect(int x, int y, int w, int h, int aw, int ah) {
226:                this .context.getDrawingSurface().renderingBegin();
227:                piscesRenderer.fillRoundRect(x << 16, y << 16, w << 16,
228:                        h << 16, aw << 16, ah << 16);
229:                this .context.getDrawingSurface().renderingEnd(this .clip);
230:            }
231:
232:            public void fillRect(int x, int y, int w, int h) {
233:                this .context.getDrawingSurface().renderingBegin();
234:                piscesRenderer.fillRect(x << 16, y << 16, w << 16, h << 16);
235:                this .context.getDrawingSurface().renderingEnd(this .clip);
236:            }
237:
238:            public void fillRect2(int x, int y, int w, int h) {
239:                this .context.getDrawingSurface().renderingBegin();
240:                piscesRenderer.fillRect(x, y, w, h);
241:                this .context.getDrawingSurface().renderingEnd(this .clip);
242:            }
243:
244:            public void drawRoundRect(int x, int y, int w, int h, int aw, int ah) {
245:                this .context.getDrawingSurface().renderingBegin();
246:                piscesRenderer.drawRoundRect(x << 16, y << 16, w << 16,
247:                        h << 16, aw << 16, ah << 16);
248:                this .context.getDrawingSurface().renderingEnd(this .clip);
249:            }
250:
251:            public void drawRect(int x, int y, int w, int h) {
252:                this .context.getDrawingSurface().renderingBegin();
253:                piscesRenderer.drawRect(x << 16, y << 16, w << 16, h << 16);
254:                this .context.getDrawingSurface().renderingEnd(this .clip);
255:            }
256:
257:            public void drawOval(int x, int y, int w, int h) {
258:                this .context.getDrawingSurface().renderingBegin();
259:                piscesRenderer.drawOval(x << 16, y << 16, w << 16, h << 16);
260:                this .context.getDrawingSurface().renderingEnd(this .clip);
261:            }
262:
263:            public void drawLine(int x0, int y0, int x1, int y1) {
264:                this .context.getDrawingSurface().renderingBegin();
265:                piscesRenderer.drawLine(x0 << 16, y0 << 16, x1 << 16, y1 << 16);
266:                this .context.getDrawingSurface().renderingEnd(this .clip);
267:            }
268:
269:            public void paintModified() {
270:                int paintMode = context.getPaintMode();
271:                if (paintMode == GCIRenderContext.PAINT_MODE_COLOR) {
272:                    int color = context.getPaintColor();
273:                    piscesRenderer.setColor((color >> 16) & 0xFF, // red
274:                            (color >> 8) & 0xFF, // green
275:                            (color) & 0xFF, // blue
276:                            (color >> 24) & 0xFF); // alpha
277:                } else if (paintMode == GCIRenderContext.PAINT_MODE_XOR) {
278:
279:                } else if (paintMode == GCIRenderContext.PAINT_MODE_LINEAR_GRADIENT) {
280:                    // for agui
281:                }
282:            }
283:
284:            public void clipModified() {
285:                context.getClip(this .clip);
286:                piscesRenderer.setClip(this .clip[0], this .clip[1],
287:                        this .clip[2], this .clip[3]);
288:            }
289:
290:            public void strokeModified() {
291:                float[] floatDash = this .context.getDashPattern();
292:                int dashPhase = 0;
293:                int[] fpDash = null;
294:
295:                if (floatDash != null) {
296:                    fpDash = new int[floatDash.length];
297:                    for (int i = 0; i < fpDash.length; i++) {
298:                        fpDash[i] = (int) (floatDash[i] * FIXED_1_0);
299:                    }
300:                    dashPhase = (int) (this .context.getDashPhase() * FIXED_1_0);
301:                }
302:                piscesRenderer.setStroke(
303:                        (int) (this .context.getLineWidth() * FIXED_1_0),
304:                        this .context.getCapStyle(),
305:                        this .context.getJoinStyle(), (int) (this .context
306:                                .getMiterLimit() * FIXED_1_0), fpDash,
307:                        dashPhase);
308:            }
309:
310:            public void transformModified() {
311:            }
312:
313:            public void compositeModified() {
314:                piscesRenderer
315:                        .setComposite(GCI_TO_PISCES_COMPOSITE[this .context
316:                                .getCompositeRule()], this .context
317:                                .getCompositeAlpha());
318:            }
319:
320:            public final void fontModified() {
321:            }
322:
323:            public void hintsModified() {
324:                piscesRenderer.setAntialiasing(this .context.isAntiAliasingOn());
325:            }
326:
327:            static class DynamicSurface extends PiscesShapeRenderer {
328:                DynamicSurface(GCIDrawingSurface surface) {
329:                    super (surface);
330:                }
331:
332:                public GCIRenderer create() {
333:                    return new DynamicSurface(this .context.getDrawingSurface());
334:                }
335:
336:                public void fillPolygon(int[] xPoints, int[] yPoints,
337:                        int nPoints) {
338:                    this .acquireSurface();
339:                    super .fillPolygon(xPoints, yPoints, nPoints);
340:                    this .releaseSurface();
341:                }
342:
343:                public void drawPolyline(int[] xPoints, int[] yPoints,
344:                        int nPoints, boolean close) {
345:                    this .acquireSurface();
346:                    super .drawPolyline(xPoints, yPoints, nPoints, close);
347:                    this .releaseSurface();
348:                }
349:
350:                public void fillRoundRect(int x, int y, int w, int h, int aw,
351:                        int ah) {
352:                    this .acquireSurface();
353:                    super .fillRoundRect(x, y, w, h, aw, ah);
354:                    this .releaseSurface();
355:                }
356:
357:                public void fillRect(int x, int y, int w, int h) {
358:                    this .acquireSurface();
359:                    super .fillRect(x, y, w, h);
360:                    this .releaseSurface();
361:                }
362:
363:                public void fillOval(int x, int y, int w, int h) {
364:                    this .acquireSurface();
365:                    super .fillOval(x, y, w, h);
366:                    this .releaseSurface();
367:                }
368:
369:                public void fillArc(int x, int y, int width, int height,
370:                        int startAngle, int arcAngle) {
371:                    this .acquireSurface();
372:                    super .fillArc(x, y, width, height, startAngle, arcAngle);
373:                    this .releaseSurface();
374:                }
375:
376:                public void drawRoundRect(int x, int y, int w, int h, int aw,
377:                        int ah) {
378:                    this .acquireSurface();
379:                    super .drawRoundRect(x, y, w, h, aw, ah);
380:                    this .releaseSurface();
381:                }
382:
383:                public void drawRect(int x, int y, int w, int h) {
384:                    this .acquireSurface();
385:                    super .drawRect(x, y, w, h);
386:                    this .releaseSurface();
387:                }
388:
389:                public void drawOval(int x, int y, int w, int h) {
390:                    this .acquireSurface();
391:                    super .drawOval(x, y, w, h);
392:                    this .releaseSurface();
393:                }
394:
395:                public void drawLine(int x0, int y0, int x1, int y1) {
396:                    this .acquireSurface();
397:                    super .drawLine(x0, y0, x1, y1);
398:                    this .releaseSurface();
399:                }
400:
401:                public void drawArc(int x, int y, int width, int height,
402:                        int startAngle, int arcAngle) {
403:                    this .acquireSurface();
404:                    super .drawArc(x, y, width, height, startAngle, arcAngle);
405:                    this .releaseSurface();
406:                }
407:            }
408:        }
409:
410:        class PiscesAdvancedShapeRenderer extends PiscesShapeRenderer implements 
411:                GCIAdvancedShapeRenderer {
412:            PiscesAdvancedShapeRenderer(GCIDrawingSurface surface) {
413:                super (surface);
414:            }
415:
416:            public GCIRenderer create() {
417:                return new PiscesAdvancedShapeRenderer(this .context
418:                        .getDrawingSurface());
419:            }
420:
421:            public void transformModified() {
422:                float[] tx = new float[6];
423:                this .context.getTransformMatrix(tx);
424:                piscesRenderer.setTransform(new Transform6(
425:                        (int) (tx[0] * FIXED_1_0), (int) (tx[1] * FIXED_1_0),
426:                        (int) (tx[2] * FIXED_1_0), (int) (tx[3] * FIXED_1_0),
427:                        (int) (tx[4] * FIXED_1_0), (int) (tx[5] * FIXED_1_0)));
428:            }
429:
430:            public void drawLine(float x0, float y0, float x1, float y1) {
431:                //this.context.getDrawingSurface().renderingBegin();
432:                super .drawLine((int) (x0), (int) (y0), (int) (x1), (int) (y1));
433:                //this.context.getDrawingSurface().renderingEnd(this.clip);
434:            }
435:
436:            public void fillRect(float x, float y, float width, float height) {
437:                //this.context.getDrawingSurface().renderingBegin();
438:                super .fillRect((int) (x), (int) (y), (int) (width),
439:                        (int) (height));
440:                //this.context.getDrawingSurface().renderingEnd(this.clip);
441:            }
442:
443:            public void drawRect(float x, float y, float width, float height) {
444:                //this.context.getDrawingSurface().renderingBegin();
445:                super .drawRect((int) (x), (int) (y), (int) (width),
446:                        (int) (height));
447:                //this.context.getDrawingSurface().renderingEnd(this.clip);
448:            }
449:
450:            public void drawRoundRect(float x, float y, float width,
451:                    float height, float arcWidth, float arcHeight) {
452:                //this.context.getDrawingSurface().renderingBegin();
453:                super .drawRoundRect((int) (x), (int) (y), (int) (width),
454:                        (int) (height), (int) (arcWidth), (int) (arcHeight));
455:                //this.context.getDrawingSurface().renderingEnd(this.clip);
456:            }
457:
458:            public void fillRoundRect(float x, float y, float width,
459:                    float height, float arcWidth, float arcHeight) {
460:                //this.context.getDrawingSurface().renderingBegin();
461:                super .fillRoundRect((int) (x), (int) (y), (int) (width),
462:                        (int) (height), (int) (arcWidth), (int) (arcHeight));
463:                //this.context.getDrawingSurface().renderingEnd(this.clip);
464:            }
465:
466:            public void drawOval(float x, float y, float width, float height) {
467:                //this.context.getDrawingSurface().renderingBegin();
468:                super .drawOval((int) (x), (int) (y), (int) (width),
469:                        (int) (height));
470:                //this.context.getDrawingSurface().renderingEnd(this.clip);
471:            }
472:
473:            public void fillOval(float x, float y, float width, float height) {
474:                //this.context.getDrawingSurface().renderingBegin();
475:                super .fillOval((int) (x), (int) (y), (int) (width),
476:                        (int) (height));
477:                //this.context.getDrawingSurface().renderingEnd(this.clip);
478:            }
479:
480:            public void drawArc(float x, float y, float width, float height,
481:                    float startAngle, float arcAngle, int arcType) {
482:                this .context.getDrawingSurface().renderingBegin();
483:                piscesRenderer.drawArc((int) (x * FIXED_1_0),
484:                        (int) (y * FIXED_1_0), (int) (width * FIXED_1_0),
485:                        (int) (height * FIXED_1_0),
486:                        (int) (startAngle * FIXED_1_0),
487:                        (int) (arcAngle * FIXED_1_0), arcType);
488:                this .context.getDrawingSurface().renderingEnd(this .clip);
489:            }
490:
491:            public void fillArc(float x, float y, float width, float height,
492:                    float startAngle, float arcAngle, int arcType) {
493:                this .context.getDrawingSurface().renderingBegin();
494:                piscesRenderer.fillArc((int) (x * FIXED_1_0),
495:                        (int) (y * FIXED_1_0), (int) (width * FIXED_1_0),
496:                        (int) (height * FIXED_1_0),
497:                        (int) (startAngle * FIXED_1_0),
498:                        (int) (arcAngle * FIXED_1_0), arcType);
499:                this .context.getDrawingSurface().renderingEnd(this .clip);
500:            }
501:
502:            public void beginRendering(int[] outputRegion, int windingRule) {
503:                this .context.getDrawingSurface().renderingBegin();
504:                piscesRenderer.beginRendering(outputRegion[0], outputRegion[1],
505:                        outputRegion[2], outputRegion[3], windingRule);
506:            }
507:
508:            public void beginRendering(int windingRule) {
509:                piscesRenderer.beginRendering(windingRule);
510:            }
511:
512:            public void endRendering(int[] affectedRegion) {
513:                piscesRenderer.endRendering();
514:                piscesRenderer.getBoundingBox(affectedRegion);
515:                this .context.getDrawingSurface().renderingEnd(affectedRegion);
516:            }
517:
518:            public void pathBegin(float pathMinX, float pathMinY,
519:                    float pathMaxX, float pathMaxY, boolean strokePath) {
520:                pathBegin(strokePath);
521:            }
522:
523:            public void pathBegin(boolean strokePath) {
524:                if (strokePath) {
525:                    piscesRenderer.setStroke();
526:                } else {
527:                    piscesRenderer.setFill();
528:                }
529:            }
530:
531:            public void pathMoveTo(float x0, float y0) {
532:                piscesRenderer.moveTo((int) (x0 * FIXED_1_0),
533:                        (int) (y0 * FIXED_1_0));
534:            }
535:
536:            public void pathLineTo(float x1, float y1) {
537:                piscesRenderer.lineTo((int) (x1 * FIXED_1_0),
538:                        (int) (y1 * FIXED_1_0));
539:            }
540:
541:            public void pathQuadTo(float x1, float y1, float x2, float y2) {
542:                piscesRenderer.quadTo((int) (x1 * FIXED_1_0),
543:                        (int) (y1 * FIXED_1_0), (int) (x2 * FIXED_1_0),
544:                        (int) (y2 * FIXED_1_0));
545:            }
546:
547:            public void pathCubicTo(float x1, float y1, float x2, float y2,
548:                    float x3, float y3) {
549:                piscesRenderer.cubicTo((int) (x1 * FIXED_1_0),
550:                        (int) (y1 * FIXED_1_0), (int) (x2 * FIXED_1_0),
551:                        (int) (y2 * FIXED_1_0), (int) (x3 * FIXED_1_0),
552:                        (int) (y3 * FIXED_1_0));
553:            }
554:
555:            public void pathClose() {
556:                piscesRenderer.close();
557:            }
558:
559:            public void pathEnd() {
560:                piscesRenderer.end();
561:            }
562:
563:            static class DynamicSurface extends PiscesAdvancedShapeRenderer {
564:                DynamicSurface(GCIDrawingSurface surface) {
565:                    super (surface);
566:                }
567:
568:                public GCIRenderer create() {
569:                    return new DynamicSurface(this .context.getDrawingSurface());
570:                }
571:
572:                public void fillPolygon(int[] xPoints, int[] yPoints,
573:                        int nPoints) {
574:                    this .acquireSurface();
575:                    super .fillPolygon(xPoints, yPoints, nPoints);
576:                    this .releaseSurface();
577:                }
578:
579:                public void drawPolyline(int[] xPoints, int[] yPoints,
580:                        int nPoints, boolean close) {
581:                    this .acquireSurface();
582:                    super .drawPolyline(xPoints, yPoints, nPoints, close);
583:                    this .releaseSurface();
584:                }
585:
586:                public void fillRoundRect(int x, int y, int w, int h, int aw,
587:                        int ah) {
588:                    this .acquireSurface();
589:                    super .fillRoundRect(x, y, w, h, aw, ah);
590:                    this .releaseSurface();
591:                }
592:
593:                public void fillRect(int x, int y, int w, int h) {
594:                    this .acquireSurface();
595:                    super .fillRect(x, y, w, h);
596:                    this .releaseSurface();
597:                }
598:
599:                public void fillOval(int x, int y, int w, int h) {
600:                    this .acquireSurface();
601:                    super .fillOval(x, y, w, h);
602:                    this .releaseSurface();
603:                }
604:
605:                public void fillArc(int x, int y, int width, int height,
606:                        int startAngle, int arcAngle) {
607:                    this .acquireSurface();
608:                    super .fillArc(x, y, width, height, startAngle, arcAngle);
609:                    this .releaseSurface();
610:                }
611:
612:                public void drawRoundRect(int x, int y, int w, int h, int aw,
613:                        int ah) {
614:                    this .acquireSurface();
615:                    super .drawRoundRect(x, y, w, h, aw, ah);
616:                    this .releaseSurface();
617:                }
618:
619:                public void drawRect(int x, int y, int w, int h) {
620:                    this .acquireSurface();
621:                    super .drawRect(x, y, w, h);
622:                    this .releaseSurface();
623:                }
624:
625:                public void drawOval(int x, int y, int w, int h) {
626:                    this .acquireSurface();
627:                    super .drawOval(x, y, w, h);
628:                    this .releaseSurface();
629:                }
630:
631:                public void drawLine(int x0, int y0, int x1, int y1) {
632:                    this .acquireSurface();
633:                    super .drawLine(x0, y0, x1, y1);
634:                    this .releaseSurface();
635:                }
636:
637:                public void drawArc(int x, int y, int width, int height,
638:                        int startAngle, int arcAngle) {
639:                    this .acquireSurface();
640:                    super .drawArc(x, y, width, height, startAngle, arcAngle);
641:                    this .releaseSurface();
642:                }
643:
644:                public void beginRendering(int[] outputRegion, int windingRule) {
645:                    this .acquireSurface();
646:                    super .beginRendering(outputRegion, windingRule);
647:                }
648:
649:                public void endRendering(int[] affectedRegion) {
650:                    super .endRendering(affectedRegion);
651:                    this .releaseSurface();
652:                }
653:
654:                public void fillArc(float x, float y, float width,
655:                        float height, float startAngle, float arcAngle,
656:                        int arcType) {
657:                    this .acquireSurface();
658:                    super .fillArc(x, y, width, height, startAngle, arcAngle,
659:                            arcType);
660:                    this .releaseSurface();
661:                }
662:
663:                public void drawArc(float x, float y, float width,
664:                        float height, float startAngle, float arcAngle,
665:                        int arcType) {
666:                    this .acquireSurface();
667:                    super .drawArc(x, y, width, height, startAngle, arcAngle,
668:                            arcType);
669:                    this .releaseSurface();
670:                }
671:
672:                public void fillRoundRect(float x, float y, float width,
673:                        float height, float arcWidth, float arcHeight) {
674:                    this .acquireSurface();
675:                    super .fillRoundRect(x, y, width, height, arcWidth,
676:                            arcHeight);
677:                    this .releaseSurface();
678:                }
679:
680:                public void fillRect(float x, float y, float width, float height) {
681:                    this .acquireSurface();
682:                    super .fillRect(x, y, width, height);
683:                    this .releaseSurface();
684:                }
685:
686:                public void fillOval(float x, float y, float width, float height) {
687:                    this .acquireSurface();
688:                    super .fillOval(x, y, width, height);
689:                    this .releaseSurface();
690:                }
691:
692:                public void drawRoundRect(float x, float y, float width,
693:                        float height, float arcWidth, float arcHeight) {
694:                    this .acquireSurface();
695:                    super .drawRoundRect(x, y, width, height, arcWidth,
696:                            arcHeight);
697:                    this .releaseSurface();
698:                }
699:
700:                public void drawRect(float x, float y, float width, float height) {
701:                    this .acquireSurface();
702:                    super .drawRect(x, y, width, height);
703:                    this .releaseSurface();
704:                }
705:
706:                public void drawOval(float x, float y, float width, float height) {
707:                    this .acquireSurface();
708:                    super .drawOval(x, y, width, height);
709:                    this .releaseSurface();
710:                }
711:
712:                public void drawLine(float x0, float y0, float x1, float y1) {
713:                    this.acquireSurface();
714:                    super.drawLine(x0, y0, x1, y1);
715:                    this.releaseSurface();
716:                }
717:
718:            }
719:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.