# Class TransparencyAttributes

java.lang.Object
javax.media.j3d.SceneGraphObject
javax.media.j3d.NodeComponent
javax.media.j3d.TransparencyAttributes

public class TransparencyAttributes extends NodeComponent
The TransparencyAttributes object defines all attributes affecting transparency of the object. The transparency attributes are:

- Transparency mode - defines how transparency is applied to this Appearance component object:

- FASTEST - uses the fastest available method for transparency.

- NICEST - uses the nicest available method for transparency.

- SCREEN_DOOR - uses screen-door transparency. This is done using an on/off stipple pattern in which the percentage of transparent pixels is approximately equal to the value specified by the transparency parameter.

- BLENDED - uses alpha blended transparency. The blend equation is specified by the srcBlendFunction and dstBlendFunction attributes. The default equation is:
  `alphasrc*src + (1-alphasrc)*dst`
  where `alphasrc` is `1-transparency`. When this mode is used with a Raster object or with a Geometry that contains per-vertex colors with alpha, the alpha values in the Raster's image or in the Geometry's per-vertex colors are combined with the transparency value in this TransparencyAttributes object to perform blending. In this case, the alpha value used for blending at each pixel is:
  `alphasrc = alphapix * (1-transparency)`.

- NONE - no transparency; opaque object.

- Transparency value - the amount of transparency to be applied to this Appearance component object. The transparency values are in the range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being fully transparent.

- 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 BLEND_SRC_ALPHA. The source blend function is one of the following:

- BLEND_ZERO - the blend function is `f = 0`
- BLEND_ONE - the blend function is `f = 1`
- BLEND_SRC_ALPHA - the blend function is `f = alphasrc`
- BLEND_ONE_MINUS_SRC_ALPHA - the blend function is `f = 1 - alphasrc`
- BLEND_DST_COLOR - the blend function is `f = colordst`
- BLEND_ONE_MINUS_DST_COLOR - the blend function is `f = 1 - colordst`
- BLEND_SRC_COLOR - the blend function is `f = colorsrc`
- BLEND_ONE_MINUS_SRC_COLOR - the blend function is `f = 1 - colorsrc`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ALLOW_BLEND_FUNCTION_READ`
Specifies that this TransparencyAttributes object allows reading its blend function.
`static final int`
`ALLOW_BLEND_FUNCTION_WRITE`
Specifies that this TransparencyAttributes object allows writing its blend function.
`static final int`
`ALLOW_MODE_READ`
Specifies that this TransparencyAttributes object allows reading its transparency mode component information.
`static final int`
`ALLOW_MODE_WRITE`
Specifies that this TransparencyAttributes object allows writing its transparency mode component information.
`static final int`
`ALLOW_VALUE_READ`
Specifies that this TransparencyAttributes object allows reading its transparency value.
`static final int`
`ALLOW_VALUE_WRITE`
Specifies that this TransparencyAttributes object allows writing its transparency value.
`static final int`
`BLEND_DST_COLOR`
Blend function: `f = colordst`.
`static final int`
`BLEND_ONE`
Blend function: `f = 1`.
`static final int`
`BLEND_ONE_MINUS_DST_COLOR`
Blend function: `f = 1-colordst`.
`static final int`
`BLEND_ONE_MINUS_SRC_ALPHA`
Blend function: `f = 1-alphasrc`.
`static final int`
`BLEND_ONE_MINUS_SRC_COLOR`
Blend function: `f = 1-colorsrc`.
`static final int`
`BLEND_SRC_ALPHA`
Blend function: `f = alphasrc`.
`static final int`
`BLEND_SRC_COLOR`
Blend function: `f = colorsrc`.
`static final int`
`BLEND_ZERO`
Blend function: `f = 0`.
`static final int`
`BLENDED`
Use alpha blended transparency.
`static final int`
`FASTEST`
Use the fastest available method for transparency.
`static final int`
`NICEST`
Use the nicest available method for transparency.
`static final int`
`NONE`
No transparency, opaque object.
`static final int`
`SCREEN_DOOR`
Use screen-door transparency.

## Constructor Summary

Constructors
Constructor
Description
`TransparencyAttributes()`
Constructs a TransparencyAttributes object with default parameters.
`TransparencyAttributes(int tMode, float tVal)`
Construct TransparencyAttributes object with specified values.
`TransparencyAttributes(int tMode, float tVal, int srcBlendFunction, int dstBlendFunction)`
Construct TransparencyAttributes object with specified values.

## Method Summary

Modifier and Type
Method
Description
`NodeComponent`
`cloneNodeComponent()`
Deprecated.
replaced with cloneNodeComponent(boolean forceDuplicate)
`int`
`getDstBlendFunction()`
Gets the destination blend function for this TransparencyAttributes object.
`int`
`getSrcBlendFunction()`
Gets the source blend function for this TransparencyAttributes object.
`float`
`getTransparency()`
Retrieves this appearance's transparency.
`int`
`getTransparencyMode()`
Gets the transparency mode for this appearance component object.
`void`
`setDstBlendFunction(int blendFunction)`
Sets the destination blend function used in blended transparency and antialiasing operations.
`void`
`setSrcBlendFunction(int blendFunction)`
Sets the source blend function used in blended transparency and antialiasing operations.
`void`
`setTransparency(float transparency)`
Sets this appearance's transparency.
`void`
`setTransparencyMode(int transparencyMode)`
Sets the transparency mode for this appearance component object.

### Methods inherited from class NodeComponent

`cloneNodeComponent, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree`

### Methods inherited from class SceneGraphObject

`clearCapability, clearCapabilityIsFrequent, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getUserData, isCompiled, isLive, setCapability, setCapabilityIsFrequent, setName, setUserData, toString, updateNodeReferences`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### ALLOW_MODE_READ

public static final int ALLOW_MODE_READ
Specifies that this TransparencyAttributes object allows reading its transparency mode component information.

See Also:
  - Constant Field Values

### ALLOW_MODE_WRITE

public static final int ALLOW_MODE_WRITE
Specifies that this TransparencyAttributes object allows writing its transparency mode component information.

See Also:
  - Constant Field Values

### ALLOW_VALUE_READ

public static final int ALLOW_VALUE_READ
Specifies that this TransparencyAttributes object allows reading its transparency value.

See Also:
  - Constant Field Values

### ALLOW_VALUE_WRITE

public static final int ALLOW_VALUE_WRITE
Specifies that this TransparencyAttributes object allows writing its transparency value.

See Also:
  - Constant Field Values

### ALLOW_BLEND_FUNCTION_READ

public static final int ALLOW_BLEND_FUNCTION_READ
Specifies that this TransparencyAttributes object allows reading its blend function.

Since:
  Java 3D 1.2
See Also:
  - Constant Field Values

### ALLOW_BLEND_FUNCTION_WRITE

public static final int ALLOW_BLEND_FUNCTION_WRITE
Specifies that this TransparencyAttributes object allows writing its blend function.

Since:
  Java 3D 1.2
See Also:
  - Constant Field Values

### FASTEST

@Native public static final int FASTEST
Use the fastest available method for transparency.

See Also:
  - `setTransparencyMode(int)`
  - Constant Field Values

### NICEST

@Native public static final int NICEST
Use the nicest available method for transparency.

See Also:
  - `setTransparencyMode(int)`
  - Constant Field Values

### BLENDED

@Native public static final int BLENDED
Use alpha blended transparency. The blend equation is specified by the srcBlendFunction and dstBlendFunction attributes. The default equation is:

`alphasrc*src + (1-alphasrc)*dst`

where `alphasrc` is `1-transparency`. When this mode is used with a Raster object or with a Geometry that contains per-vertex colors with alpha, the alpha values in the Raster's image or in the Geometry's per-vertex colors are combined with the transparency value in this TransparencyAttributes object to perform blending. In this case, the alpha value used for blending at each pixel is:

`alphasrc = alphapix * (1-transparency)`.

See Also:
  - `setTransparencyMode(int)`
  - `setSrcBlendFunction(int)`
  - `setDstBlendFunction(int)`
  - Constant Field Values

### SCREEN_DOOR

@Native public static final int SCREEN_DOOR
Use screen-door transparency. This is done using an on/off stipple pattern where the percentage of pixels that are transparent is approximately equal to the value specified by the transparency parameter.

See Also:
  - `setTransparencyMode(int)`
  - Constant Field Values

### NONE

@Native public static final int NONE
No transparency, opaque object.

See Also:
  - `setTransparencyMode(int)`
  - Constant Field Values

### BLEND_ZERO

@Native public static final int BLEND_ZERO
Blend function: `f = 0`.

Since:
  Java 3D 1.2
See Also:
  - `setSrcBlendFunction(int)`
  - `setDstBlendFunction(int)`
  - Constant Field Values

### BLEND_ONE

@Native public static final int BLEND_ONE
Blend function: `f = 1`.

Since:
  Java 3D 1.2
See Also:
  - `setSrcBlendFunction(int)`
  - `setDstBlendFunction(int)`
  - Constant Field Values

### BLEND_SRC_ALPHA

@Native public static final int BLEND_SRC_ALPHA
Blend function: `f = alphasrc`.

Since:
  Java 3D 1.2
See Also:
  - `setSrcBlendFunction(int)`
  - `setDstBlendFunction(int)`
  - Constant Field Values

### BLEND_ONE_MINUS_SRC_ALPHA

@Native public static final int BLEND_ONE_MINUS_SRC_ALPHA
Blend function: `f = 1-alphasrc`.

Since:
  Java 3D 1.2
See Also:
  - `setSrcBlendFunction(int)`
  - `setDstBlendFunction(int)`
  - Constant Field Values

### BLEND_DST_COLOR

@Native public static final int BLEND_DST_COLOR
Blend function: `f = colordst`.

Note that this function may only be used as a source blend function.

Since:
  Java 3D 1.4
See Also:
  - `setSrcBlendFunction(int)`
  - Constant Field Values

### BLEND_ONE_MINUS_DST_COLOR

@Native public static final int BLEND_ONE_MINUS_DST_COLOR
Blend function: `f = 1-colordst`.

Note that this function may only be used as a source blend function.

Since:
  Java 3D 1.4
See Also:
  - `setSrcBlendFunction(int)`
  - Constant Field Values

### BLEND_SRC_COLOR

@Native public static final int BLEND_SRC_COLOR
Blend function: `f = colorsrc`.

Note that this function may only be used as a destination blend function.

Since:
  Java 3D 1.4
See Also:
  - `setDstBlendFunction(int)`
  - Constant Field Values

### BLEND_ONE_MINUS_SRC_COLOR

@Native public static final int BLEND_ONE_MINUS_SRC_COLOR
Blend function: `f = 1-colorsrc`.

Note that this function may only be used as a destination blend function.

Since:
  Java 3D 1.4
See Also:
  - `setDstBlendFunction(int)`
  - Constant Field Values

## Constructor Details

### TransparencyAttributes

public TransparencyAttributes()
Constructs a TransparencyAttributes object with default parameters. The default values are as follows:

transparency mode : `NONE`
transparency value : 0.0
source blend function : `BLEND_SRC_ALPHA`
destination blend function : `BLEND_ONE_MINUS_SRC_ALPHA`

### TransparencyAttributes

public TransparencyAttributes(int tMode, float tVal)
Construct TransparencyAttributes object with specified values.

Parameters:
  `tMode` - the transparency mode
  `tVal` - the transparency value
Throws:
  `IllegalArgumentException` - if `tMode` is a value other than `NONE`, `FASTEST`, `NICEST`, `SCREEN_DOOR`, or `BLENDED`

### TransparencyAttributes

public TransparencyAttributes(int tMode, float tVal, int srcBlendFunction, int dstBlendFunction)
Construct TransparencyAttributes object with specified values.

Parameters:
  `tMode` - the transparency mode
  `tVal` - the transparency value
  `srcBlendFunction` - the blend function to be used for the source color, one of `BLEND_ZERO`, `BLEND_ONE`, `BLEND_SRC_ALPHA`, `BLEND_ONE_MINUS_SRC_ALPHA`, `BLEND_DST_COLOR`, or `BLEND_ONE_MINUS_DST_COLOR`.
  `dstBlendFunction` - the blend function to be used for the destination color, one of `BLEND_ZERO`, `BLEND_ONE`, `BLEND_SRC_ALPHA`, `BLEND_ONE_MINUS_SRC_ALPHA`, `BLEND_SRC_COLOR`, or `BLEND_ONE_MINUS_SRC_COLOR`.
Throws:
  `IllegalArgumentException` - if `tMode` is a value other than `NONE`, `FASTEST`, `NICEST`, `SCREEN_DOOR`, or `BLENDED`
  `IllegalArgumentException` - if `srcBlendFunction` or `dstBlendFunction` is a value other than one of the supported functions listed above.
Since:
  Java 3D 1.2

## Method Details

### setTransparencyMode

public void setTransparencyMode(int transparencyMode)
Sets the transparency mode for this appearance component object.

Parameters:
  `transparencyMode` - the transparency mode to be used, one of `NONE`, `FASTEST`, `NICEST`, `SCREEN_DOOR`, or `BLENDED`
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `IllegalArgumentException` - if `transparencyMode` is a value other than `NONE`, `FASTEST`, `NICEST`, `SCREEN_DOOR`, or `BLENDED`

### getTransparencyMode

public int getTransparencyMode()
Gets the transparency mode for this appearance component object.

Returns:
  transparencyMode the transparency mode
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### setTransparency

public void setTransparency(float transparency)
Sets this appearance's transparency.

Parameters:
  `transparency` - the appearance's transparency in the range [0.0, 1.0] with 0.0 being fully opaque and 1.0 being fully transparent
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### getTransparency

public float getTransparency()
Retrieves this appearance's transparency.

Returns:
  the appearance's transparency
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph

### setSrcBlendFunction

public void setSrcBlendFunction(int blendFunction)
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 `BLEND_SRC_ALPHA`.

Parameters:
  `blendFunction` - the blend function to be used for the source color, one of `BLEND_ZERO`, `BLEND_ONE`, `BLEND_SRC_ALPHA`, `BLEND_ONE_MINUS_SRC_ALPHA`, `BLEND_DST_COLOR`, or `BLEND_ONE_MINUS_DST_COLOR`.
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `IllegalArgumentException` - if `blendFunction` is a value other than one of the supported functions listed above.
Since:
  Java 3D 1.2

### getSrcBlendFunction

public int getSrcBlendFunction()
Gets the source blend function for this TransparencyAttributes object.

Returns:
  the source blend function.
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
  Java 3D 1.2

### setDstBlendFunction

public void setDstBlendFunction(int blendFunction)
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 `BLEND_ONE_MINUS_SRC_ALPHA`.

Parameters:
  `blendFunction` - the blend function to be used for the destination color, one of `BLEND_ZERO`, `BLEND_ONE`, `BLEND_SRC_ALPHA`, `BLEND_ONE_MINUS_SRC_ALPHA`, `BLEND_SRC_COLOR`, or `BLEND_ONE_MINUS_SRC_COLOR`.
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
  `IllegalArgumentException` - if `blendFunction` is a value other than one of the supported functions listed above.
Since:
  Java 3D 1.2

### getDstBlendFunction

public int getDstBlendFunction()
Gets the destination blend function for this TransparencyAttributes object.

Returns:
  the destination blend function.
Throws:
  `CapabilityNotSetException` - if appropriate capability is not set and this object is part of live or compiled scene graph
Since:
  Java 3D 1.2

### cloneNodeComponent

public NodeComponent cloneNodeComponent()
Deprecated.
replaced with cloneNodeComponent(boolean forceDuplicate)

Overrides:
  `cloneNodeComponent` in class `NodeComponent`