001: /*
002: * $RCSfile: TransparencyAttributes.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.6 $
028: * $Date: 2008/02/28 20:17:32 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The TransparencyAttributes object defines all attributes affecting
036: * transparency of the object. The transparency attributes are:<p>
037: * <ul>
038: * <li>Transparency mode - defines how transparency is applied to
039: * this Appearance component object:</li><p>
040: * <ul>
041: * <li>FASTEST - uses the fastest available method for transparency.</li><p>
042: * <li>NICEST - uses the nicest available method for transparency.</li><p>
043: * <li>SCREEN_DOOR - uses screen-door transparency. This is done using
044: * an on/off stipple pattern in which the percentage of transparent pixels
045: * is approximately equal to the value specified by the transparency
046: * parameter.</li><p>
047: * <li>BLENDED - uses alpha blended transparency. The blend equation is
048: * specified by the srcBlendFunction and dstBlendFunction attributes.
049: * The default equation is:
050: * <ul>
051: * <code>alpha<sub><font size=-1>src</font></sub>*src +
052: * (1-alpha<sub><font size=-1>src</font></sub>)*dst</code>
053: * </ul>
054: * where <code>alpha<sub><font size=-1>src</font></sub></code> is
055: * <code>1-transparency</code>.
056: * When this mode is used with a Raster object or with a Geometry
057: * that contains per-vertex colors with alpha, the alpha values in
058: * the Raster's image or in the Geometry's per-vertex colors are
059: * combined with the transparency value in this TransparencyAttributes
060: * object to perform blending. In this case, the alpha value used for
061: * blending at each pixel is:
062: * <ul>
063: * <code>alpha<sub><font size=-1>src</font></sub> =
064: * alpha<sub><font size=-1>pix</font></sub> *
065: * (1-transparency)</code>.
066: * </ul>
067: * </li><p>
068: * <li>NONE - no transparency; opaque object.</li><p>
069: * </ul>
070: * <li>Transparency value - the amount of transparency to be applied to this
071: * Appearance component object. The transparency values are in the
072: * range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being
073: * fully transparent.</li><p>
074: * <li>Blend function - used in blended transparency and antialiasing
075: * operations. The source function specifies the factor that is
076: * multiplied by the source color. This value is added to the product
077: * of the destination factor and the destination color. The default
078: * source blend function is BLEND_SRC_ALPHA. The source blend function
079: * is one of the following:</li><p>
080: * <ul>
081: * <li>BLEND_ZERO - the blend function is <code>f = 0</code></li>
082: * <li>BLEND_ONE - the blend function is <code>f = 1</code></li>
083: * <li>BLEND_SRC_ALPHA - the blend function is <code>f =
084: * alpha<sub><font size=-1>src</font></sub></code></li>
085: * <li>BLEND_ONE_MINUS_SRC_ALPHA - the blend function is <code>f =
086: * 1 - alpha<sub><font size=-1>src</font></sub></code></li>
087: * <li>BLEND_DST_COLOR - the blend function is <code>f =
088: * color<sub><font size=-1>dst</font></sub></code></li>
089: * <li>BLEND_ONE_MINUS_DST_COLOR - the blend function is <code>f =
090: * 1 - color<sub><font size=-1>dst</font></sub></code></li>
091: * <li>BLEND_SRC_COLOR - the blend function is <code>f =
092: * color<sub><font size=-1>src</font></sub></code></li>
093: * <li>BLEND_ONE_MINUS_SRC_COLOR - the blend function is <code>f =
094: * 1 - color<sub><font size=-1>src</font></sub></code></li>
095: * </ul>
096: * </ul>
097: */
098: public class TransparencyAttributes extends NodeComponent {
099: /**
100: * Specifies that this TransparencyAttributes object
101: * allows reading its transparency mode component information.
102: */
103: public static final int ALLOW_MODE_READ = CapabilityBits.TRANSPARENCY_ATTRIBUTES_ALLOW_MODE_READ;
104:
105: /**
106: * Specifies that this TransparencyAttributes object
107: * allows writing its transparency mode component information.
108: */
109: public static final int ALLOW_MODE_WRITE = CapabilityBits.TRANSPARENCY_ATTRIBUTES_ALLOW_MODE_WRITE;
110:
111: /**
112: * Specifies that this TransparencyAttributes object
113: * allows reading its transparency value.
114: */
115: public static final int ALLOW_VALUE_READ = CapabilityBits.TRANSPARENCY_ATTRIBUTES_ALLOW_VALUE_READ;
116:
117: /**
118: * Specifies that this TransparencyAttributes object
119: * allows writing its transparency value.
120: */
121: public static final int ALLOW_VALUE_WRITE = CapabilityBits.TRANSPARENCY_ATTRIBUTES_ALLOW_VALUE_WRITE;
122:
123: /**
124: * Specifies that this TransparencyAttributes object
125: * allows reading its blend function.
126: *
127: * @since Java 3D 1.2
128: */
129: public static final int ALLOW_BLEND_FUNCTION_READ = CapabilityBits.TRANSPARENCY_ATTRIBUTES_ALLOW_BLEND_FUNCTION_READ;
130:
131: /**
132: * Specifies that this TransparencyAttributes object
133: * allows writing its blend function.
134: *
135: * @since Java 3D 1.2
136: */
137: public static final int ALLOW_BLEND_FUNCTION_WRITE = CapabilityBits.TRANSPARENCY_ATTRIBUTES_ALLOW_BLEND_FUNCTION_WRITE;
138:
139: /**
140: * Use the fastest available method for transparency.
141: * @see #setTransparencyMode
142: */
143: public static final int FASTEST = 0;
144:
145: /**
146: * Use the nicest available method for transparency.
147: * @see #setTransparencyMode
148: */
149: public static final int NICEST = 1;
150:
151: /**
152: * Use alpha blended transparency. The blend equation is
153: * specified by the srcBlendFunction and dstBlendFunction attributes.
154: * The default equation is:
155: * <ul>
156: * <code>alpha<sub><font size=-1>src</font></sub>*src +
157: * (1-alpha<sub><font size=-1>src</font></sub>)*dst</code>
158: * </ul>
159: * where <code>alpha<sub><font size=-1>src</font></sub></code> is
160: * <code>1-transparency</code>.
161: * When this mode is used with a Raster object or with a Geometry
162: * that contains per-vertex colors with alpha, the alpha values in
163: * the Raster's image or in the Geometry's per-vertex colors are
164: * combined with the transparency value in this TransparencyAttributes
165: * object to perform blending. In this case, the alpha value used for
166: * blending at each pixel is:
167: * <ul>
168: * <code>alpha<sub><font size=-1>src</font></sub> =
169: * alpha<sub><font size=-1>pix</font></sub> *
170: * (1-transparency)</code>.
171: * </ul>
172: *
173: * @see #setTransparencyMode
174: * @see #setSrcBlendFunction
175: * @see #setDstBlendFunction
176: */
177: public static final int BLENDED = 2;
178:
179: /**
180: * Use screen-door transparency. This is done using an on/off stipple
181: * pattern where the percentage of pixels that are transparent is
182: * approximately equal to the value specified by the transparency
183: * parameter.
184: * @see #setTransparencyMode
185: */
186: public static final int SCREEN_DOOR = 3;
187:
188: /**
189: * No transparency, opaque object.
190: * @see #setTransparencyMode
191: */
192: public static final int NONE = 4;
193:
194: /**
195: * Blend function: <code>f = 0</code>.
196: * @see #setSrcBlendFunction
197: * @see #setDstBlendFunction
198: *
199: * @since Java 3D 1.2
200: */
201: public static final int BLEND_ZERO = 0;
202:
203: /**
204: * Blend function: <code>f = 1</code>.
205: * @see #setSrcBlendFunction
206: * @see #setDstBlendFunction
207: *
208: * @since Java 3D 1.2
209: */
210: public static final int BLEND_ONE = 1;
211:
212: /**
213: * Blend function:
214: * <code>f = alpha<sub><font size=-1>src</font></sub></code>.
215: * @see #setSrcBlendFunction
216: * @see #setDstBlendFunction
217: *
218: * @since Java 3D 1.2
219: */
220: public static final int BLEND_SRC_ALPHA = 2;
221:
222: /**
223: * Blend function:
224: * <code>f = 1-alpha<sub><font size=-1>src</font></sub></code>.
225: * @see #setSrcBlendFunction
226: * @see #setDstBlendFunction
227: *
228: * @since Java 3D 1.2
229: */
230: public static final int BLEND_ONE_MINUS_SRC_ALPHA = 3;
231:
232: /**
233: * Blend function:
234: * <code>f = color<sub><font size=-1>dst</font></sub></code>.
235: * <p>Note that this function may <i>only</i> be used as a source
236: * blend function.</p>
237: * @see #setSrcBlendFunction
238: *
239: * @since Java 3D 1.4
240: */
241: public static final int BLEND_DST_COLOR = 4;
242:
243: /**
244: * Blend function:
245: * <code>f = 1-color<sub><font size=-1>dst</font></sub></code>.
246: * <p>Note that this function may <i>only</i> be used as a source
247: * blend function.</p>
248: * @see #setSrcBlendFunction
249: *
250: * @since Java 3D 1.4
251: */
252: public static final int BLEND_ONE_MINUS_DST_COLOR = 5;
253:
254: /**
255: * Blend function:
256: * <code>f = color<sub><font size=-1>src</font></sub></code>.
257: * <p>Note that this function may <i>only</i> be used as a destination
258: * blend function.</p>
259: * @see #setDstBlendFunction
260: *
261: * @since Java 3D 1.4
262: */
263: public static final int BLEND_SRC_COLOR = 6;
264:
265: /**
266: * Blend function:
267: * <code>f = 1-color<sub><font size=-1>src</font></sub></code>.
268: * <p>Note that this function may <i>only</i> be used as a destination
269: * blend function.</p>
270: * @see #setDstBlendFunction
271: *
272: * @since Java 3D 1.4
273: */
274: public static final int BLEND_ONE_MINUS_SRC_COLOR = 7;
275:
276: static final int BLEND_CONSTANT_COLOR = 8;
277:
278: static final int MAX_BLEND_FUNC_TABLE_SIZE = 9;
279:
280: // Array for setting default read capabilities
281: private static final int[] readCapabilities = {
282: ALLOW_BLEND_FUNCTION_READ, ALLOW_MODE_READ,
283: ALLOW_VALUE_READ };
284:
285: /**
286: * Constructs a TransparencyAttributes object with default parameters.
287: * The default values are as follows:
288: * <ul>
289: * transparency mode : <code>NONE</code><br>
290: * transparency value : 0.0<br>
291: * source blend function : <code>BLEND_SRC_ALPHA</code><br>
292: * destination blend function : <code>BLEND_ONE_MINUS_SRC_ALPHA</code><br>
293: * </ul>
294: */
295: public TransparencyAttributes() {
296: // Just use the default for all attributes
297: // set default read capabilities
298: setDefaultReadCapabilities(readCapabilities);
299: }
300:
301: /**
302: * Construct TransparencyAttributes object with specified values.
303: * @param tMode the transparency mode
304: * @param tVal the transparency value
305: * @exception IllegalArgumentException if
306: * <code>tMode</code> is a value other than
307: * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>,
308: * <code>SCREEN_DOOR</code>, or <code>BLENDED</code>
309: *
310: */
311: public TransparencyAttributes(int tMode, float tVal) {
312: this (tMode, tVal, BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
313: }
314:
315: /**
316: * Construct TransparencyAttributes object with specified values.
317: * @param tMode the transparency mode
318: * @param tVal the transparency value
319: * @param srcBlendFunction the blend function to be used for the source
320: * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>,
321: * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>,
322: * <code>BLEND_DST_COLOR</code>, or <code>BLEND_ONE_MINUS_DST_COLOR</code>.
323: * @param dstBlendFunction the blend function to be used for the
324: * destination
325: * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>,
326: * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>,
327: * <code>BLEND_SRC_COLOR</code>, or <code>BLEND_ONE_MINUS_SRC_COLOR</code>.
328: * @exception IllegalArgumentException if
329: * <code>tMode</code> is a value other than
330: * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>,
331: * <code>SCREEN_DOOR</code>, or <code>BLENDED</code>
332: * @exception IllegalArgumentException if
333: * <code>srcBlendFunction</code> or <code>dstBlendFunction</code>
334: * is a value other than one of the supported functions listed above.
335: *
336: * @since Java 3D 1.2
337: */
338: public TransparencyAttributes(int tMode, float tVal,
339: int srcBlendFunction, int dstBlendFunction) {
340: if ((tMode < FASTEST) || (tMode > NONE)) {
341: throw new IllegalArgumentException(J3dI18N
342: .getString("TransparencyAttributes6"));
343: }
344:
345: switch (srcBlendFunction) {
346: case BLEND_ZERO:
347: case BLEND_ONE:
348: case BLEND_SRC_ALPHA:
349: case BLEND_ONE_MINUS_SRC_ALPHA:
350: case BLEND_DST_COLOR:
351: case BLEND_ONE_MINUS_DST_COLOR:
352: break;
353: default:
354: throw new IllegalArgumentException(J3dI18N
355: .getString("TransparencyAttributes7"));
356: }
357:
358: switch (dstBlendFunction) {
359: case BLEND_ZERO:
360: case BLEND_ONE:
361: case BLEND_SRC_ALPHA:
362: case BLEND_ONE_MINUS_SRC_ALPHA:
363: case BLEND_SRC_COLOR:
364: case BLEND_ONE_MINUS_SRC_COLOR:
365: break;
366: default:
367: throw new IllegalArgumentException(J3dI18N
368: .getString("TransparencyAttributes8"));
369: }
370:
371: // set default read capabilities
372: setDefaultReadCapabilities(readCapabilities);
373:
374: ((TransparencyAttributesRetained) this .retained)
375: .initTransparencyMode(tMode);
376: ((TransparencyAttributesRetained) this .retained)
377: .initTransparency(tVal);
378: ((TransparencyAttributesRetained) this .retained)
379: .initSrcBlendFunction(srcBlendFunction);
380: ((TransparencyAttributesRetained) this .retained)
381: .initDstBlendFunction(dstBlendFunction);
382: }
383:
384: /**
385: * Sets the transparency mode for this
386: * appearance component object.
387: * @param transparencyMode the transparency mode to be used, one of
388: * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>,
389: * <code>SCREEN_DOOR</code>, or <code>BLENDED</code>
390: * @exception CapabilityNotSetException if appropriate capability is
391: * not set and this object is part of live or compiled scene graph
392: * @exception IllegalArgumentException if
393: * <code>transparencyMode</code> is a value other than
394: * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>,
395: * <code>SCREEN_DOOR</code>, or <code>BLENDED</code>
396: */
397: public void setTransparencyMode(int transparencyMode) {
398: if (isLiveOrCompiled())
399: if (!this .getCapability(ALLOW_MODE_WRITE))
400: throw new CapabilityNotSetException(J3dI18N
401: .getString("TransparencyAttributes0"));
402:
403: if ((transparencyMode < FASTEST) || (transparencyMode > NONE)) {
404: throw new IllegalArgumentException(J3dI18N
405: .getString("TransparencyAttributes6"));
406: }
407:
408: if (isLive())
409: ((TransparencyAttributesRetained) this .retained)
410: .setTransparencyMode(transparencyMode);
411: else
412: ((TransparencyAttributesRetained) this .retained)
413: .initTransparencyMode(transparencyMode);
414: }
415:
416: /**
417: * Gets the transparency mode for this
418: * appearance component object.
419: * @return transparencyMode the transparency mode
420: * @exception CapabilityNotSetException if appropriate capability is
421: * not set and this object is part of live or compiled scene graph
422: */
423: public int getTransparencyMode() {
424: if (isLiveOrCompiled())
425: if (!this .getCapability(ALLOW_MODE_READ))
426: throw new CapabilityNotSetException(J3dI18N
427: .getString("TransparencyAttributes1"));
428:
429: return ((TransparencyAttributesRetained) this .retained)
430: .getTransparencyMode();
431: }
432:
433: /**
434: * Sets this appearance's transparency.
435: * @param transparency the appearance's transparency
436: * in the range [0.0, 1.0] with 0.0 being
437: * fully opaque and 1.0 being fully transparent
438: * @exception CapabilityNotSetException if appropriate capability is
439: * not set and this object is part of live or compiled scene graph
440: */
441: public void setTransparency(float transparency) {
442: if (isLiveOrCompiled())
443: if (!this .getCapability(ALLOW_VALUE_WRITE))
444: throw new CapabilityNotSetException(J3dI18N
445: .getString("TransparencyAttributes2"));
446:
447: if (isLive())
448: ((TransparencyAttributesRetained) this .retained)
449: .setTransparency(transparency);
450: else
451: ((TransparencyAttributesRetained) this .retained)
452: .initTransparency(transparency);
453:
454: }
455:
456: /**
457: * Retrieves this appearance's transparency.
458: * @return the appearance's transparency
459: * @exception CapabilityNotSetException if appropriate capability is
460: * not set and this object is part of live or compiled scene graph
461: */
462: public float getTransparency() {
463: if (isLiveOrCompiled())
464: if (!this .getCapability(ALLOW_VALUE_READ))
465: throw new CapabilityNotSetException(J3dI18N
466: .getString("TransparencyAttributes3"));
467:
468: return ((TransparencyAttributesRetained) this .retained)
469: .getTransparency();
470: }
471:
472: /**
473: * Sets the source blend function used in blended transparency
474: * and antialiasing operations. The source function specifies the
475: * factor that is multiplied by the source color; this value is
476: * added to the product of the destination factor and the
477: * destination color. The default source blend function is
478: * <code>BLEND_SRC_ALPHA</code>.
479: *
480: * @param blendFunction the blend function to be used for the source
481: * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>,
482: * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>,
483: * <code>BLEND_DST_COLOR</code>, or <code>BLEND_ONE_MINUS_DST_COLOR</code>.
484: *
485: * @exception CapabilityNotSetException if appropriate capability is
486: * not set and this object is part of live or compiled scene graph
487: * @exception IllegalArgumentException if <code>blendFunction</code>
488: * is a value other than one of the supported functions listed above.
489: *
490: * @since Java 3D 1.2
491: */
492: public void setSrcBlendFunction(int blendFunction) {
493: if (isLiveOrCompiled())
494: if (!this .getCapability(ALLOW_BLEND_FUNCTION_WRITE))
495: throw new CapabilityNotSetException(J3dI18N
496: .getString("TransparencyAttributes4"));
497:
498: switch (blendFunction) {
499: case BLEND_ZERO:
500: case BLEND_ONE:
501: case BLEND_SRC_ALPHA:
502: case BLEND_ONE_MINUS_SRC_ALPHA:
503: case BLEND_DST_COLOR:
504: case BLEND_ONE_MINUS_DST_COLOR:
505: break;
506: default:
507: throw new IllegalArgumentException(J3dI18N
508: .getString("TransparencyAttributes7"));
509: }
510:
511: if (isLive())
512: ((TransparencyAttributesRetained) this .retained)
513: .setSrcBlendFunction(blendFunction);
514: else
515: ((TransparencyAttributesRetained) this .retained)
516: .initSrcBlendFunction(blendFunction);
517: }
518:
519: /**
520: * Gets the source blend function for this
521: * TransparencyAttributes object.
522: * @return the source blend function.
523: * @exception CapabilityNotSetException if appropriate capability is
524: * not set and this object is part of live or compiled scene graph
525: *
526: * @since Java 3D 1.2
527: */
528: public int getSrcBlendFunction() {
529: if (isLiveOrCompiled())
530: if (!this .getCapability(ALLOW_BLEND_FUNCTION_READ))
531: throw new CapabilityNotSetException(J3dI18N
532: .getString("TransparencyAttributes5"));
533: return ((TransparencyAttributesRetained) this .retained)
534: .getSrcBlendFunction();
535: }
536:
537: /**
538: * Sets the destination blend function used in blended transparency
539: * and antialiasing operations. The destination function specifies the
540: * factor that is multiplied by the destination color; this value is
541: * added to the product of the source factor and the
542: * source color. The default destination blend function is
543: * <code>BLEND_ONE_MINUS_SRC_ALPHA</code>.
544: *
545: * @param blendFunction the blend function to be used for the destination
546: * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>,
547: * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>,
548: * <code>BLEND_SRC_COLOR</code>, or <code>BLEND_ONE_MINUS_SRC_COLOR</code>.
549: *
550: * @exception CapabilityNotSetException if appropriate capability is
551: * not set and this object is part of live or compiled scene graph
552: * @exception IllegalArgumentException if <code>blendFunction</code>
553: * is a value other than one of the supported functions listed above.
554: *
555: * @since Java 3D 1.2
556: */
557: public void setDstBlendFunction(int blendFunction) {
558: if (isLiveOrCompiled())
559: if (!this .getCapability(ALLOW_BLEND_FUNCTION_WRITE))
560: throw new CapabilityNotSetException(J3dI18N
561: .getString("TransparencyAttributes4"));
562:
563: switch (blendFunction) {
564: case BLEND_ZERO:
565: case BLEND_ONE:
566: case BLEND_SRC_ALPHA:
567: case BLEND_ONE_MINUS_SRC_ALPHA:
568: case BLEND_SRC_COLOR:
569: case BLEND_ONE_MINUS_SRC_COLOR:
570: break;
571: default:
572: throw new IllegalArgumentException(J3dI18N
573: .getString("TransparencyAttributes8"));
574: }
575:
576: if (isLive())
577: ((TransparencyAttributesRetained) this .retained)
578: .setDstBlendFunction(blendFunction);
579: else
580: ((TransparencyAttributesRetained) this .retained)
581: .initDstBlendFunction(blendFunction);
582: }
583:
584: /**
585: * Gets the destination blend function for this
586: * TransparencyAttributes object.
587: * @return the destination blend function.
588: * @exception CapabilityNotSetException if appropriate capability is
589: * not set and this object is part of live or compiled scene graph
590: *
591: * @since Java 3D 1.2
592: */
593: public int getDstBlendFunction() {
594: if (isLiveOrCompiled())
595: if (!this .getCapability(ALLOW_BLEND_FUNCTION_READ))
596: throw new CapabilityNotSetException(J3dI18N
597: .getString("TransparencyAttributes5"));
598:
599: return ((TransparencyAttributesRetained) this .retained)
600: .getDstBlendFunction();
601: }
602:
603: /**
604: * Creates a retained mode TransparencyAttributesRetained object that this
605: * TransparencyAttributes component object will point to.
606: */
607: void createRetained() {
608: this .retained = new TransparencyAttributesRetained();
609: this .retained.setSource(this );
610: }
611:
612: /**
613: * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
614: */
615: public NodeComponent cloneNodeComponent() {
616: TransparencyAttributes transa = new TransparencyAttributes();
617: transa.duplicateNodeComponent(this );
618: return transa;
619: }
620:
621: /**
622: * Copies all node information from <code>originalNodeComponent</code> into
623: * the current node. This method is called from the
624: * <code>duplicateNode</code> method. This routine does
625: * the actual duplication of all "local data" (any data defined in
626: * this object).
627: *
628: * @param originalNodeComponent the original node to duplicate.
629: * @param forceDuplicate when set to <code>true</code>, causes the
630: * <code>duplicateOnCloneTree</code> flag to be ignored. When
631: * <code>false</code>, the value of each node's
632: * <code>duplicateOnCloneTree</code> variable determines whether
633: * NodeComponent data is duplicated or copied.
634: *
635: * @see Node#cloneTree
636: * @see NodeComponent#setDuplicateOnCloneTree
637: */
638: void duplicateAttributes(NodeComponent originalNodeComponent,
639: boolean forceDuplicate) {
640: super
641: .duplicateAttributes(originalNodeComponent,
642: forceDuplicate);
643:
644: TransparencyAttributesRetained attr = (TransparencyAttributesRetained) originalNodeComponent.retained;
645: TransparencyAttributesRetained rt = (TransparencyAttributesRetained) retained;
646:
647: rt.initTransparencyMode(attr.getTransparencyMode());
648: rt.initTransparency(attr.getTransparency());
649: rt.initSrcBlendFunction(attr.getSrcBlendFunction());
650: rt.initDstBlendFunction(attr.getDstBlendFunction());
651: }
652:
653: }
|