📄 transparencyattributes.java
字号:
* <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, * <code>BLEND_SRC_COLOR</code>, or <code>BLEND_ONE_MINUS_SRC_COLOR</code>. * @exception IllegalArgumentException if * <code>tMode</code> is a value other than * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>, * <code>SCREEN_DOOR</code>, or <code>BLENDED</code> * @exception IllegalArgumentException if * <code>srcBlendFunction</code> or <code>dstBlendFunction</code> * is a value other than one of the supported functions listed above. * * @since Java 3D 1.2 */ public TransparencyAttributes(int tMode, float tVal, int srcBlendFunction, int dstBlendFunction) { if ((tMode < FASTEST) ||(tMode > NONE)) { throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes6")); } switch (srcBlendFunction) { case BLEND_ZERO: case BLEND_ONE: case BLEND_SRC_ALPHA: case BLEND_ONE_MINUS_SRC_ALPHA: case BLEND_DST_COLOR: case BLEND_ONE_MINUS_DST_COLOR: break; default: throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes7")); } switch (dstBlendFunction) { case BLEND_ZERO: case BLEND_ONE: case BLEND_SRC_ALPHA: case BLEND_ONE_MINUS_SRC_ALPHA: case BLEND_SRC_COLOR: case BLEND_ONE_MINUS_SRC_COLOR: break; default: throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes8")); } // set default read capabilities setDefaultReadCapabilities(readCapabilities); ((TransparencyAttributesRetained)this.retained).initTransparencyMode(tMode); ((TransparencyAttributesRetained)this.retained).initTransparency(tVal); ((TransparencyAttributesRetained)this.retained).initSrcBlendFunction(srcBlendFunction); ((TransparencyAttributesRetained)this.retained).initDstBlendFunction(dstBlendFunction); } /** * Sets the transparency mode for this * appearance component object. * @param transparencyMode the transparency mode to be used, one of * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>, * <code>SCREEN_DOOR</code>, or <code>BLENDED</code> * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if * <code>transparencyMode</code> is a value other than * <code>NONE</code>, <code>FASTEST</code>, <code>NICEST</code>, * <code>SCREEN_DOOR</code>, or <code>BLENDED</code> */ public void setTransparencyMode(int transparencyMode) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_MODE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes0")); if ((transparencyMode < FASTEST) || (transparencyMode > NONE)) { throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes6")); } if (isLive()) ((TransparencyAttributesRetained)this.retained).setTransparencyMode(transparencyMode); else ((TransparencyAttributesRetained)this.retained).initTransparencyMode(transparencyMode); } /** * Gets the transparency mode for this * appearance component object. * @return transparencyMode the transparency mode * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public int getTransparencyMode() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_MODE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes1")); return ((TransparencyAttributesRetained)this.retained).getTransparencyMode(); } /** * Sets this appearance's transparency. * @param transparency the appearance's transparency * in the range [0.0, 1.0] with 0.0 being * fully opaque and 1.0 being fully transparent * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public void setTransparency(float transparency) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_VALUE_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes2")); if (isLive()) ((TransparencyAttributesRetained)this.retained).setTransparency(transparency); else ((TransparencyAttributesRetained)this.retained).initTransparency(transparency); } /** * Retrieves this appearance's transparency. * @return the appearance's transparency * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph */ public float getTransparency() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_VALUE_READ)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes3")); return ((TransparencyAttributesRetained)this.retained).getTransparency(); } /** * Sets the source blend function used in blended transparency * and antialiasing operations. The source function specifies the * factor that is multiplied by the source color; this value is * added to the product of the destination factor and the * destination color. The default source blend function is * <code>BLEND_SRC_ALPHA</code>. * * @param blendFunction the blend function to be used for the source * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, * <code>BLEND_DST_COLOR</code>, or <code>BLEND_ONE_MINUS_DST_COLOR</code>. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if <code>blendFunction</code> * is a value other than one of the supported functions listed above. * * @since Java 3D 1.2 */ public void setSrcBlendFunction(int blendFunction) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_BLEND_FUNCTION_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes4")); switch (blendFunction) { case BLEND_ZERO: case BLEND_ONE: case BLEND_SRC_ALPHA: case BLEND_ONE_MINUS_SRC_ALPHA: case BLEND_DST_COLOR: case BLEND_ONE_MINUS_DST_COLOR: break; default: throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes7")); } if (isLive()) ((TransparencyAttributesRetained)this.retained).setSrcBlendFunction(blendFunction); else ((TransparencyAttributesRetained)this.retained).initSrcBlendFunction(blendFunction); } /** * Gets the source blend function for this * TransparencyAttributes object. * @return the source blend function. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.2 */ public int getSrcBlendFunction() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_BLEND_FUNCTION_READ)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes5")); return ((TransparencyAttributesRetained)this.retained).getSrcBlendFunction(); } /** * Sets the destination blend function used in blended transparency * and antialiasing operations. The destination function specifies the * factor that is multiplied by the destination color; this value is * added to the product of the source factor and the * source color. The default destination blend function is * <code>BLEND_ONE_MINUS_SRC_ALPHA</code>. * * @param blendFunction the blend function to be used for the destination * color, one of <code>BLEND_ZERO</code>, <code>BLEND_ONE</code>, * <code>BLEND_SRC_ALPHA</code>, <code>BLEND_ONE_MINUS_SRC_ALPHA</code>, * <code>BLEND_SRC_COLOR</code>, or <code>BLEND_ONE_MINUS_SRC_COLOR</code>. * * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * @exception IllegalArgumentException if <code>blendFunction</code> * is a value other than one of the supported functions listed above. * * @since Java 3D 1.2 */ public void setDstBlendFunction(int blendFunction) { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_BLEND_FUNCTION_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes4")); switch (blendFunction) { case BLEND_ZERO: case BLEND_ONE: case BLEND_SRC_ALPHA: case BLEND_ONE_MINUS_SRC_ALPHA: case BLEND_SRC_COLOR: case BLEND_ONE_MINUS_SRC_COLOR: break; default: throw new IllegalArgumentException(J3dI18N.getString("TransparencyAttributes8")); } if (isLive()) ((TransparencyAttributesRetained)this.retained).setDstBlendFunction(blendFunction); else ((TransparencyAttributesRetained)this.retained).initDstBlendFunction(blendFunction); } /** * Gets the destination blend function for this * TransparencyAttributes object. * @return the destination blend function. * @exception CapabilityNotSetException if appropriate capability is * not set and this object is part of live or compiled scene graph * * @since Java 3D 1.2 */ public int getDstBlendFunction() { if (isLiveOrCompiled()) if (!this.getCapability(ALLOW_BLEND_FUNCTION_READ)) throw new CapabilityNotSetException(J3dI18N.getString("TransparencyAttributes5")); return ((TransparencyAttributesRetained)this.retained).getDstBlendFunction(); } /** * Creates a retained mode TransparencyAttributesRetained object that this * TransparencyAttributes component object will point to. */ void createRetained() { this.retained = new TransparencyAttributesRetained(); this.retained.setSource(this); } /** * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate) */ public NodeComponent cloneNodeComponent() { TransparencyAttributes transa = new TransparencyAttributes(); transa.duplicateNodeComponent(this); return transa; } /** * Copies all node information from <code>originalNodeComponent</code> into * the current node. This method is called from the * <code>duplicateNode</code> method. This routine does * the actual duplication of all "local data" (any data defined in * this object). * * @param originalNodeComponent the original node to duplicate. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(NodeComponent originalNodeComponent, boolean forceDuplicate) { super.duplicateAttributes(originalNodeComponent, forceDuplicate); TransparencyAttributesRetained attr = (TransparencyAttributesRetained) originalNodeComponent.retained; TransparencyAttributesRetained rt = (TransparencyAttributesRetained) retained; rt.initTransparencyMode(attr.getTransparencyMode()); rt.initTransparency(attr.getTransparency()); rt.initSrcBlendFunction(attr.getSrcBlendFunction()); rt.initDstBlendFunction(attr.getDstBlendFunction()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -