Source Code Cross Referenced for Raster.java in  » 6.0-JDK-Modules » java-3d » javax » media » j3d » 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 » java 3d » javax.media.j3d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $RCSfile: Raster.java,v $
003:         *
004:         * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006:         *
007:         * This code is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU General Public License version 2 only, as
009:         * published by the Free Software Foundation.  Sun designates this
010:         * particular file as subject to the "Classpath" exception as provided
011:         * by Sun in the LICENSE file that accompanied this code.
012:         *
013:         * This code is distributed in the hope that it will be useful, but WITHOUT
014:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:         * version 2 for more details (a copy is included in the LICENSE file that
017:         * accompanied this code).
018:         *
019:         * You should have received a copy of the GNU General Public License version
020:         * 2 along with this work; if not, write to the Free Software Foundation,
021:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022:         *
023:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024:         * CA 95054 USA or visit www.sun.com if you need additional information or
025:         * have any questions.
026:         *
027:         * $Revision: 1.7 $
028:         * $Date: 2008/02/28 20:17:28 $
029:         * $State: Exp $
030:         */
031:
032:        package javax.media.j3d;
033:
034:        import javax.vecmath.*;
035:        import java.awt.Point;
036:        import java.awt.Dimension;
037:
038:        /**
039:         * The Raster object extends Geometry to allow drawing a raster image
040:         * that is attached to a 3D location in the virtual world.
041:         * It contains a 3D point that is defined in the local object
042:         * coordinate system of the Shape3D node that references the Raster.
043:         * It also contains a type specifier, a clipping mode, a reference to
044:         * a ImageComponent2D object and/or a DepthComponent object, an
045:         * integer x,y source offset and a size (width, height) to allow
046:         * reading or writing a portion of the referenced image, and an
047:         * integer x,y destination offset to position the raster relative to
048:         * the transformed 3D point.
049:         * In addition to being used as a type of geometry for drawing,
050:         * a Raster may be used to readback pixel data (color and/or z-buffer)
051:         * from the frame buffer in immediate mode.
052:         * <p>
053:         * The geometric extent of a Raster object is a single 3D point, specified
054:         * by the raster position.  This means that geometry-based picking or
055:         * collision with a Raster object will only intersect the object at
056:         * this single point; the 2D raster image is neither pickable
057:         * nor collidable.
058:         */
059:
060:        public class Raster extends Geometry {
061:            /**
062:             * Specifies a Raster object with color data.
063:             * In this mode, the image reference must point to
064:             * a valid ImageComponent object.
065:             *
066:             * @see #setType
067:             */
068:            public static final int RASTER_COLOR = 0x1;
069:
070:            /**
071:             * Specifies a Raster object with depth (z-buffer) data.
072:             * In this mode, the depthImage reference must point to
073:             * a valid DepthComponent object.
074:             *
075:             * @see #setType
076:             */
077:            public static final int RASTER_DEPTH = 0x2;
078:
079:            /**
080:             * Specifies a Raster object with both color and depth (z-buffer) data.
081:             * In this mode, the image reference must point to
082:             * a valid ImageComponent object, and the depthImage reference
083:             * must point to a valid DepthComponent object.
084:             *
085:             * @see #setType
086:             */
087:            public static final int RASTER_COLOR_DEPTH = RASTER_COLOR
088:                    | RASTER_DEPTH;
089:
090:            /**
091:             * Specifies that this raster object is not drawn
092:             * if the raster position is outside the viewing volume.
093:             * In this mode, the raster is not drawn when the transformed
094:             * raster position is clipped out, even if part of the raster would
095:             * have been visible.  This is the default mode.
096:             *
097:             * @see #setClipMode
098:             *
099:             * @since Java 3D 1.3
100:             */
101:            public static final int CLIP_POSITION = 0;
102:
103:            /**
104:             * Specifies that the raster object is clipped as an image after
105:             * the raster position has been transformed.  In this mode, part
106:             * of the raster may be drawn even when the transformed raster
107:             * position is clipped out.
108:             *
109:             * @see #setClipMode
110:             *
111:             * @since Java 3D 1.3
112:             */
113:            public static final int CLIP_IMAGE = 1;
114:
115:            /**
116:             * Specifies that this Raster allows reading the position.
117:             */
118:            public static final int ALLOW_POSITION_READ = CapabilityBits.RASTER_ALLOW_POSITION_READ;
119:
120:            /**
121:             * Specifies that this Raster allows writing the position.
122:             */
123:            public static final int ALLOW_POSITION_WRITE = CapabilityBits.RASTER_ALLOW_POSITION_WRITE;
124:
125:            /** 
126:             * Specifies that this Raster allows reading the source or
127:             * destination offset.
128:             */
129:            public static final int ALLOW_OFFSET_READ = CapabilityBits.RASTER_ALLOW_OFFSET_READ;
130:
131:            /** 
132:             * Specifies that this Raster allows writing the source or
133:             * destination offset.
134:             */
135:            public static final int ALLOW_OFFSET_WRITE = CapabilityBits.RASTER_ALLOW_OFFSET_WRITE;
136:
137:            /**  
138:             * Specifies that this Raster allows reading the image.
139:             */
140:            public static final int ALLOW_IMAGE_READ = CapabilityBits.RASTER_ALLOW_IMAGE_READ;
141:
142:            /**  
143:             * Specifies that this Raster allows writing the image. 
144:             */
145:            public static final int ALLOW_IMAGE_WRITE = CapabilityBits.RASTER_ALLOW_IMAGE_WRITE;
146:
147:            /**  
148:             * Specifies that this Raster allows reading the depth component.
149:             */
150:            public static final int ALLOW_DEPTH_COMPONENT_READ = CapabilityBits.RASTER_ALLOW_DEPTH_COMPONENT_READ;
151:
152:            /**  
153:             * Specifies that this Raster allows writing the depth component. 
154:             */
155:            public static final int ALLOW_DEPTH_COMPONENT_WRITE = CapabilityBits.RASTER_ALLOW_DEPTH_COMPONENT_WRITE;
156:
157:            /**  
158:             * Specifies that this Raster allows reading the size.
159:             */
160:            public static final int ALLOW_SIZE_READ = CapabilityBits.RASTER_ALLOW_SIZE_READ;
161:
162:            /**                                                        
163:             * Specifies that this Raster allows writing the size.
164:             */
165:            public static final int ALLOW_SIZE_WRITE = CapabilityBits.RASTER_ALLOW_SIZE_WRITE;
166:
167:            /**  
168:             * Specifies that this Raster allows reading the type. 
169:             */
170:            public static final int ALLOW_TYPE_READ = CapabilityBits.RASTER_ALLOW_TYPE_READ;
171:
172:            /**  
173:             * Specifies that this Raster allows reading the clip mode.
174:             *
175:             * @since Java 3D 1.3
176:             */
177:            public static final int ALLOW_CLIP_MODE_READ = CapabilityBits.RASTER_ALLOW_CLIP_MODE_READ;
178:
179:            /**                                                        
180:             * Specifies that this Raster allows writing the clip mode.
181:             *
182:             * @since Java 3D 1.3
183:             */
184:            public static final int ALLOW_CLIP_MODE_WRITE = CapabilityBits.RASTER_ALLOW_CLIP_MODE_WRITE;
185:
186:            // Array for setting default read capabilities
187:            private static final int[] readCapabilities = {
188:                    ALLOW_POSITION_READ, ALLOW_OFFSET_READ, ALLOW_IMAGE_READ,
189:                    ALLOW_DEPTH_COMPONENT_READ, ALLOW_SIZE_READ,
190:                    ALLOW_TYPE_READ, ALLOW_CLIP_MODE_READ };
191:
192:            /**
193:             * Constructs a Raster object with default parameters.
194:             * The default values are as follows:
195:             * <ul>
196:             * type : RASTER_COLOR<br>
197:             * clipMode : CLIP_POSITION<br>
198:             * position : (0,0,0)<br>
199:             * srcOffset : (0,0)<br>
200:             * size : (0,0)<br>
201:             * dstOffset : (0,0)<br>
202:             * image : null<br>
203:             * depth component : null<br>
204:             * </ul>
205:             */
206:            public Raster() {
207:                // set default read capabilities
208:                setDefaultReadCapabilities(readCapabilities);
209:            }
210:
211:            /**
212:             * Constructs a new Raster object with the specified values.
213:             * @param pos the position in object coordinates of the upper-left
214:             * corner of the raster
215:             * @param type the type of raster object, one of: RASTER_COLOR,
216:             * RASTER_DEPTH, or RASTER_COLOR_DEPTH
217:             * @param xSrcOffset the x offset within the source array of pixels
218:             * at which to start copying
219:             * @param ySrcOffset the y offset within the source array of pixels
220:             * at which to start copying
221:             * @param width the number of columns of pixels to copy
222:             * @param height the number of rows of pixels to copy
223:             * @param image the ImageComponent2D object containing the
224:             * color data
225:             * @param depthComponent the DepthComponent object containing the depth
226:             * (z-buffer) data
227:             *
228:             * @exception IllegalArgumentException if the image class of the specified
229:             * ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
230:             */
231:            public Raster(Point3f pos, int type, int xSrcOffset,
232:                    int ySrcOffset, int width, int height,
233:                    ImageComponent2D image, DepthComponent depthComponent) {
234:
235:                // set default read capabilities
236:                setDefaultReadCapabilities(readCapabilities);
237:
238:                ((RasterRetained) this .retained).setPosition(pos);
239:                ((RasterRetained) this .retained).setType(type);
240:                ((RasterRetained) this .retained).setSrcOffset(xSrcOffset,
241:                        ySrcOffset);
242:                ((RasterRetained) this .retained).setSize(width, height);
243:                ((RasterRetained) this .retained).setImage(image);
244:                ((RasterRetained) this .retained)
245:                        .setDepthComponent(depthComponent);
246:            }
247:
248:            /**
249:             * Constructs a new Raster object with the specified values.
250:             * @param pos the position in object coordinates of the upper-left
251:             * corner of the raster
252:             * @param type the type of raster object, one of: RASTER_COLOR,
253:             * RASTER_DEPTH, or RASTER_COLOR_DEPTH
254:             * @param srcOffset the offset within the source array of pixels
255:             * at which to start copying
256:             * @param size the width and height of the image to be copied
257:             * @param image the ImageComponent2D object containing the
258:             * color data
259:             * @param depthComponent the DepthComponent object containing the depth
260:             * (z-buffer) data 
261:             *
262:             * @exception IllegalArgumentException if the image class of the specified
263:             * ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
264:             */
265:            public Raster(Point3f pos, int type, Point srcOffset,
266:                    Dimension size, ImageComponent2D image,
267:                    DepthComponent depthComponent) {
268:
269:                // set default read capabilities
270:                setDefaultReadCapabilities(readCapabilities);
271:
272:                ((RasterRetained) this .retained).setPosition(pos);
273:                ((RasterRetained) this .retained).setType(type);
274:                ((RasterRetained) this .retained).setSrcOffset(srcOffset.x,
275:                        srcOffset.y);
276:                ((RasterRetained) this .retained).setSize(size.width,
277:                        size.height);
278:                ((RasterRetained) this .retained).setImage(image);
279:                ((RasterRetained) this .retained)
280:                        .setDepthComponent(depthComponent);
281:            }
282:
283:            /**
284:             * Constructs a new Raster object with the specified values.
285:             * @param pos the position in object coordinates of the upper-left
286:             * corner of the raster
287:             * @param type the type of raster object, one of: RASTER_COLOR,
288:             * RASTER_DEPTH, or RASTER_COLOR_DEPTH
289:             * @param clipMode the clipping mode of the raster object, one of:
290:             * CLIP_POSITION or CLIP_IMAGE
291:             * @param srcOffset the offset within the source array of pixels
292:             * at which to start copying
293:             * @param size the width and height of the image to be copied
294:             * @param dstOffset the destination pixel offset of the upper-left
295:             * corner of the rendered image relative to the transformed position
296:             * @param image the ImageComponent2D object containing the
297:             * color data
298:             * @param depthComponent the DepthComponent object containing the depth
299:             * (z-buffer) data
300:             *
301:             * @exception IllegalArgumentException if the image class of the specified
302:             * ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
303:             *
304:             * @since Java 3D 1.3
305:             */
306:            public Raster(Point3f pos, int type, int clipMode, Point srcOffset,
307:                    Dimension size, Point dstOffset, ImageComponent2D image,
308:                    DepthComponent depthComponent) {
309:
310:                // set default read capabilities
311:                setDefaultReadCapabilities(readCapabilities);
312:
313:                ((RasterRetained) this .retained).setPosition(pos);
314:                ((RasterRetained) this .retained).setType(type);
315:                ((RasterRetained) this .retained).setClipMode(clipMode);
316:                ((RasterRetained) this .retained).setSrcOffset(srcOffset.x,
317:                        srcOffset.y);
318:                ((RasterRetained) this .retained).setSize(size.width,
319:                        size.height);
320:                ((RasterRetained) this .retained).setDstOffset(dstOffset.x,
321:                        dstOffset.y);
322:                ((RasterRetained) this .retained).setImage(image);
323:                ((RasterRetained) this .retained)
324:                        .setDepthComponent(depthComponent);
325:            }
326:
327:            /**
328:             * Creates the retained mode Raster object that this
329:             * Raster object will point to.
330:             */
331:            void createRetained() {
332:                retained = new RasterRetained();
333:                retained.setSource(this );
334:            }
335:
336:            /**
337:             * Sets the position in object coordinates of this raster.  This
338:             * position is transformed into device coordinates and is used as
339:             * the upper-left corner of the raster.
340:             * @param pos the new position of this raster
341:             * @exception CapabilityNotSetException if appropriate capability is
342:             * not set and this object is part of live or compiled scene graph
343:             */
344:            public void setPosition(Point3f pos) {
345:                if (isLiveOrCompiled())
346:                    if (!this .getCapability(ALLOW_POSITION_WRITE))
347:                        throw new CapabilityNotSetException(J3dI18N
348:                                .getString("Raster0"));
349:                ((RasterRetained) this .retained).setPosition(pos);
350:            }
351:
352:            /**
353:             * Retrieves the current position in object coordinates of this raster.
354:             * @param pos the vector that will receive the current position
355:             * @exception CapabilityNotSetException if appropriate capability is
356:             * not set and this object is part of live or compiled scene graph
357:             */
358:            public void getPosition(Point3f pos) {
359:                if (isLiveOrCompiled())
360:                    if (!this .getCapability(ALLOW_POSITION_READ))
361:                        throw new CapabilityNotSetException(J3dI18N
362:                                .getString("Raster1"));
363:
364:                ((RasterRetained) this .retained).getPosition(pos);
365:            }
366:
367:            /**
368:             * Sets the type of this raster object to one of: RASTER_COLOR,
369:             * RASTER_DEPTH, or RASTER_COLOR_DEPTH.
370:             * @param type the new type of this raster
371:             * @exception RestrictedAccessException if the method is called
372:             * when this object is part of live or compiled scene graph.
373:             */
374:            public void setType(int type) {
375:                checkForLiveOrCompiled();
376:                ((RasterRetained) this .retained).setType(type);
377:            }
378:
379:            /**
380:             * Retrieves the current type of this raster object, one of: RASTER_COLOR,
381:             * RASTER_DEPTH, or RASTER_COLOR_DEPTH.
382:             * @return type the type of this raster
383:             * @exception CapabilityNotSetException if appropriate capability is
384:             * not set and this object is part of live or compiled scene graph
385:             */
386:            public int getType() {
387:                if (isLiveOrCompiled())
388:                    if (!this .getCapability(ALLOW_TYPE_READ))
389:                        throw new CapabilityNotSetException(J3dI18N
390:                                .getString("Raster2"));
391:                return (((RasterRetained) this .retained).getType());
392:            }
393:
394:            /**
395:             * Sets the clipping mode of this raster object.
396:             * @param clipMode the new clipping mode of this raster,
397:             * one of: CLIP_POSITION or CLIP_IMAGE.  The default mode
398:             * is CLIP_POSITION.
399:             * @exception CapabilityNotSetException if appropriate capability is
400:             * not set and this object is part of live or compiled scene graph
401:             *
402:             * @since Java 3D 1.3
403:             */
404:            public void setClipMode(int clipMode) {
405:                if (isLiveOrCompiled())
406:                    if (!this .getCapability(ALLOW_CLIP_MODE_WRITE))
407:                        throw new CapabilityNotSetException(J3dI18N
408:                                .getString("Raster10"));
409:
410:                ((RasterRetained) this .retained).setClipMode(clipMode);
411:            }
412:
413:            /**
414:             * Retrieves the current clipping mode of this raster object.
415:             * @return clipMode the clipping mode of this raster,
416:             * one of: CLIP_POSITION or CLIP_IMAGE.
417:             * @exception CapabilityNotSetException if appropriate capability is
418:             * not set and this object is part of live or compiled scene graph
419:             *
420:             * @since Java 3D 1.3
421:             */
422:            public int getClipMode() {
423:                if (isLiveOrCompiled())
424:                    if (!this .getCapability(ALLOW_CLIP_MODE_READ))
425:                        throw new CapabilityNotSetException(J3dI18N
426:                                .getString("Raster11"));
427:
428:                return (((RasterRetained) this .retained).getClipMode());
429:            }
430:
431:            /**
432:             * @deprecated As of Java 3D version 1.3, replaced by
433:             * <code>setSrcOffset(int,int)</code>
434:             */
435:            public void setOffset(int xSrcOffset, int ySrcOffset) {
436:                setSrcOffset(xSrcOffset, ySrcOffset);
437:            }
438:
439:            /**
440:             * @deprecated As of Java 3D version 1.3, replaced by
441:             * <code>setSrcOffset(java.awt.Point)</code>
442:             */
443:            public void setOffset(Point srcOffset) {
444:                setSrcOffset(srcOffset);
445:            }
446:
447:            /**
448:             * @deprecated As of Java 3D version 1.3, replaced by
449:             * <code>getSrcOffset(java.awt.Point)</code>
450:             */
451:            public void getOffset(Point srcOffset) {
452:                getSrcOffset(srcOffset);
453:            }
454:
455:            /**
456:             * Sets the offset within the source array of pixels
457:             * at which to start copying.
458:             * @param xSrcOffset the x offset within the source array of pixels
459:             * at which to start copying
460:             * @param ySrcOffset the y offset within the source array of pixels
461:             * at which to start copying
462:             * @exception CapabilityNotSetException if appropriate capability is
463:             * not set and this object is part of live or compiled scene graph
464:             *
465:             * @since Java 3D 1.3
466:             */
467:            public void setSrcOffset(int xSrcOffset, int ySrcOffset) {
468:
469:                if (isLiveOrCompiled())
470:                    if (!this .getCapability(ALLOW_OFFSET_WRITE))
471:                        throw new CapabilityNotSetException(J3dI18N
472:                                .getString("Raster7"));
473:
474:                ((RasterRetained) this .retained).setSrcOffset(xSrcOffset,
475:                        ySrcOffset);
476:            }
477:
478:            /**
479:             * Sets the offset within the source array of pixels
480:             * at which to start copying.
481:             * @param srcOffset the new source pixel offset
482:             * @exception CapabilityNotSetException if appropriate capability is
483:             * not set and this object is part of live or compiled scene graph
484:             *
485:             * @since Java 3D 1.3
486:             */
487:            public void setSrcOffset(Point srcOffset) {
488:                if (isLiveOrCompiled())
489:                    if (!this .getCapability(ALLOW_OFFSET_WRITE))
490:                        throw new CapabilityNotSetException(J3dI18N
491:                                .getString("Raster7"));
492:
493:                ((RasterRetained) this .retained).setSrcOffset(srcOffset.x,
494:                        srcOffset.y);
495:            }
496:
497:            /**
498:             * Retrieves the current source pixel offset.
499:             * @param srcOffset the object that will receive the source offset
500:             * @exception CapabilityNotSetException if appropriate capability is
501:             * not set and this object is part of live or compiled scene graph
502:             *
503:             * @since Java 3D 1.3
504:             */
505:            public void getSrcOffset(Point srcOffset) {
506:                if (isLiveOrCompiled())
507:                    if (!this .getCapability(ALLOW_OFFSET_READ))
508:                        throw new CapabilityNotSetException(J3dI18N
509:                                .getString("Raster8"));
510:
511:                ((RasterRetained) this .retained).getSrcOffset(srcOffset);
512:            }
513:
514:            /**
515:             * Sets the number of pixels to be copied from the pixel array.
516:             * @param width the number of columns in the array of pixels to copy
517:             * @param height the number of rows in the array of pixels to copy
518:             * @exception CapabilityNotSetException if appropriate capability is
519:             * not set and this object is part of live or compiled scene graph
520:             */
521:            public void setSize(int width, int height) {
522:                if (isLiveOrCompiled())
523:                    if (!this .getCapability(ALLOW_SIZE_WRITE))
524:                        throw new CapabilityNotSetException(J3dI18N
525:                                .getString("Raster9"));
526:
527:                ((RasterRetained) this .retained).setSize(width, height);
528:            }
529:
530:            /**
531:             * Sets the size of the array of pixels to be copied.
532:             * @param size the new size
533:             * @exception CapabilityNotSetException if appropriate capability is
534:             * not set and this object is part of live or compiled scene graph
535:             */
536:            public void setSize(Dimension size) {
537:                if (isLiveOrCompiled())
538:                    if (!this .getCapability(ALLOW_SIZE_WRITE))
539:                        throw new CapabilityNotSetException(J3dI18N
540:                                .getString("Raster9"));
541:
542:                ((RasterRetained) this .retained).setSize(size.width,
543:                        size.height);
544:            }
545:
546:            /**
547:             * Retrieves the current raster size.
548:             * @param size the object that will receive the size
549:             * @exception CapabilityNotSetException if appropriate capability is
550:             * not set and this object is part of live or compiled scene graph
551:             */
552:            public void getSize(Dimension size) {
553:                if (isLiveOrCompiled())
554:                    if (!this .getCapability(ALLOW_SIZE_READ))
555:                        throw new CapabilityNotSetException(J3dI18N
556:                                .getString("Raster1"));
557:
558:                ((RasterRetained) this .retained).getSize(size);
559:            }
560:
561:            /**
562:             * Sets the destination pixel offset of the upper-left corner of
563:             * the rendered image relative to the transformed position.  This
564:             * pixel offset is added to the transformed raster position prior
565:             * to rendering the image.
566:             *
567:             * @param xDstOffset the x coordinate of the new offset
568:             * @param yDstOffset the y coordinate of the new offset
569:             * @exception CapabilityNotSetException if appropriate capability is
570:             * not set and this object is part of live or compiled scene graph
571:             *
572:             * @since Java 3D 1.3
573:             */
574:            public void setDstOffset(int xDstOffset, int yDstOffset) {
575:
576:                if (isLiveOrCompiled())
577:                    if (!this .getCapability(ALLOW_OFFSET_WRITE))
578:                        throw new CapabilityNotSetException(J3dI18N
579:                                .getString("Raster7"));
580:
581:                ((RasterRetained) this .retained).setDstOffset(xDstOffset,
582:                        yDstOffset);
583:            }
584:
585:            /**
586:             * Sets the destination pixel offset of the upper-left corner of
587:             * the rendered image relative to the transformed position.  This
588:             * pixel offset is added to the transformed raster position prior
589:             * to rendering the image.
590:             *
591:             * @param dstOffset the new destination pixel offset
592:             * @exception CapabilityNotSetException if appropriate capability is
593:             * not set and this object is part of live or compiled scene graph
594:             *
595:             * @since Java 3D 1.3
596:             */
597:            public void setDstOffset(Point dstOffset) {
598:                if (isLiveOrCompiled())
599:                    if (!this .getCapability(ALLOW_OFFSET_WRITE))
600:                        throw new CapabilityNotSetException(J3dI18N
601:                                .getString("Raster7"));
602:
603:                ((RasterRetained) this .retained).setDstOffset(dstOffset.x,
604:                        dstOffset.y);
605:            }
606:
607:            /**
608:             * Retrieves the current destination pixel offset.
609:             * @param dstOffset the object that will receive the destination offset
610:             * @exception CapabilityNotSetException if appropriate capability is
611:             * not set and this object is part of live or compiled scene graph
612:             *
613:             * @since Java 3D 1.3
614:             */
615:            public void getDstOffset(Point dstOffset) {
616:                if (isLiveOrCompiled())
617:                    if (!this .getCapability(ALLOW_OFFSET_READ))
618:                        throw new CapabilityNotSetException(J3dI18N
619:                                .getString("Raster8"));
620:
621:                ((RasterRetained) this .retained).getDstOffset(dstOffset);
622:            }
623:
624:            /**
625:             * Sets the pixel array used to copy pixels to/from a Canvas3D.
626:             * This is used when the type is RASTER_COLOR or RASTER_COLOR_DEPTH.
627:             *
628:             * @param image the ImageComponent2D object containing the
629:             * color data
630:             *
631:             * @exception CapabilityNotSetException if appropriate capability is
632:             * not set and this object is part of live or compiled scene graph
633:             *
634:             * @exception IllegalSharingException if this Raster is live and
635:             * the specified image is being used by a Canvas3D as an off-screen buffer.
636:             *
637:             * @exception IllegalArgumentException if the image class of the specified
638:             * ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
639:             *
640:             */
641:            public void setImage(ImageComponent2D image) {
642:
643:                if (isLiveOrCompiled())
644:                    if (!this .getCapability(ALLOW_IMAGE_WRITE))
645:                        throw new CapabilityNotSetException(J3dI18N
646:                                .getString("Raster3"));
647:
648:                // Do illegal sharing check
649:                if (image != null) {
650:                    ImageComponent2DRetained imageRetained = (ImageComponent2DRetained) image.retained;
651:                    if (imageRetained.getUsedByOffScreen()) {
652:                        if (isLive()) {
653:                            throw new IllegalSharingException(J3dI18N
654:                                    .getString("Raster12"));
655:                        }
656:                    }
657:                }
658:
659:                ((RasterRetained) this .retained).setImage(image);
660:            }
661:
662:            /**
663:             * Retrieves the current pixel array object.
664:             * @return image the ImageComponent2D object containing the
665:             * color data
666:             * @exception CapabilityNotSetException if appropriate capability is
667:             * not set and this object is part of live or compiled scene graph
668:             */
669:            public ImageComponent2D getImage() {
670:                if (isLiveOrCompiled())
671:                    if (!this .getCapability(ALLOW_IMAGE_READ))
672:                        throw new CapabilityNotSetException(J3dI18N
673:                                .getString("Raster4"));
674:                return (((RasterRetained) this .retained).getImage());
675:            }
676:
677:            /**
678:             * Sets the depth image used to copy pixels to/from a Canvas3D.
679:             * This is used when the type is RASTER_DEPTH or RASTER_COLOR_DEPTH.
680:             * @param depthComponent the DepthComponent object containing the
681:             * depth (z-buffer) data
682:             * @exception CapabilityNotSetException if appropriate capability is
683:             * not set and this object is part of live or compiled scene graph
684:             */
685:            public void setDepthComponent(DepthComponent depthComponent) {
686:                if (isLiveOrCompiled())
687:                    if (!this .getCapability(ALLOW_DEPTH_COMPONENT_WRITE))
688:                        throw new CapabilityNotSetException(J3dI18N
689:                                .getString("Raster5"));
690:                ((RasterRetained) this .retained)
691:                        .setDepthComponent(depthComponent);
692:            }
693:
694:            /**
695:             * Retrieves the current depth image object.
696:             * @return depthImage DepthComponent containing the
697:             * depth (z-buffer) data
698:             * @exception CapabilityNotSetException if appropriate capability is
699:             * not set and this object is part of live or compiled scene graph
700:             */
701:            public DepthComponent getDepthComponent() {
702:                if (isLiveOrCompiled())
703:                    if (!this .getCapability(ALLOW_DEPTH_COMPONENT_READ))
704:                        throw new CapabilityNotSetException(J3dI18N
705:                                .getString("Raster6"));
706:                return (((RasterRetained) this .retained).getDepthComponent());
707:            }
708:
709:            /**
710:             * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
711:             */
712:            public NodeComponent cloneNodeComponent() {
713:                Raster r = new Raster();
714:                r.duplicateNodeComponent(this );
715:                return r;
716:            }
717:
718:            /**
719:             * NOTE: Applications should <i>not</i> call this method directly.
720:             * It should only be called by the cloneNode method.
721:             *
722:             * @deprecated replaced with duplicateNodeComponent(
723:             *  NodeComponent originalNodeComponent, boolean forceDuplicate)
724:             */
725:            public void duplicateNodeComponent(
726:                    NodeComponent originalNodeComponent) {
727:                checkDuplicateNodeComponent(originalNodeComponent);
728:            }
729:
730:            /**
731:             * Copies all node information from <code>originalNodeComponent</code> into
732:             * the current node.  This method is called from the
733:             * <code>duplicateNode</code> method. This routine does
734:             * the actual duplication of all "local data" (any data defined in
735:             * this object). 
736:             *
737:             * @param originalNodeComponent the original node to duplicate.
738:             * @param forceDuplicate when set to <code>true</code>, causes the
739:             *  <code>duplicateOnCloneTree</code> flag to be ignored.  When
740:             *  <code>false</code>, the value of each node's
741:             *  <code>duplicateOnCloneTree</code> variable determines whether
742:             *  NodeComponent data is duplicated or copied.
743:             *
744:             * @see Node#cloneTree
745:             * @see NodeComponent#setDuplicateOnCloneTree
746:             */
747:            void duplicateAttributes(NodeComponent originalNodeComponent,
748:                    boolean forceDuplicate) {
749:                super 
750:                        .duplicateAttributes(originalNodeComponent,
751:                                forceDuplicate);
752:
753:                RasterRetained raster = (RasterRetained) originalNodeComponent.retained;
754:                RasterRetained rt = (RasterRetained) retained;
755:
756:                Point3f p = new Point3f();
757:                raster.getPosition(p);
758:                rt.setPosition(p);
759:                rt.setType(raster.getType());
760:                rt.setClipMode(raster.getClipMode());
761:                Point offset = new Point();
762:                raster.getSrcOffset(offset);
763:                rt.setSrcOffset(offset.x, offset.y);
764:                raster.getDstOffset(offset);
765:                rt.setDstOffset(offset.x, offset.y);
766:                Dimension dim = new Dimension();
767:                raster.getSize(dim);
768:                rt.setSize(dim.width, dim.height);
769:                rt.setImage((ImageComponent2D) getNodeComponent(raster
770:                        .getImage(), forceDuplicate,
771:                        originalNodeComponent.nodeHashtable));
772:                rt.setDepthComponent((DepthComponent) getNodeComponent(raster
773:                        .getDepthComponent(), forceDuplicate,
774:                        originalNodeComponent.nodeHashtable));
775:            }
776:
777:            /** 
778:             *  This function is called from getNodeComponent() to see if any of
779:             *  the sub-NodeComponents  duplicateOnCloneTree flag is true. 
780:             *  If it is the case, current NodeComponent needs to 
781:             *  duplicate also even though current duplicateOnCloneTree flag is false. 
782:             *  This should be overwrite by NodeComponent which contains sub-NodeComponent.
783:             */
784:            boolean duplicateChild() {
785:                if (getDuplicateOnCloneTree())
786:                    return true;
787:                RasterRetained rt = (RasterRetained) retained;
788:
789:                NodeComponent nc = rt.getImage();
790:                if ((nc != null) && nc.getDuplicateOnCloneTree())
791:                    return true;
792:
793:                nc = rt.getDepthComponent();
794:                if ((nc != null) && nc.getDuplicateOnCloneTree())
795:                    return true;
796:
797:                return false;
798:            }
799:
800:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.