edu.uthscsa.ric.visualization
Class SurfaceShape

java.lang.Object
  extended by edu.uthscsa.ric.visualization.SurfaceShape
All Implemented Interfaces:
OverlayListener

public class SurfaceShape
extends Object
implements OverlayListener

SurfaceShape, like SurfaceData, is a container for surface-related data and is intended to store shapes that have been added to the base image surface. In addition to SurfaceData, it contains methods to set lighting and color parameters, visibility, and transparency of the shape.


Field Summary
static float DEFAULT_AMBIENT
           
static float DEFAULT_AMBIENT_D3D
           
static float DEFAULT_BRIGHTNESS
           
static float DEFAULT_DIFFUSE
           
static float DEFAULT_DIFFUSE_D3D
           
static float DEFAULT_EMISSIVE
           
static float DEFAULT_EMISSIVE_D3D
           
static float DEFAULT_SHININESS
           
static float DEFAULT_SHININESS_D3D
           
static float DEFAULT_SPECULAR
           
static float DEFAULT_SPECULAR_D3D
           
static float TRANSPARENCY_LEVEL
           
 
Constructor Summary
SurfaceShape(Shape3D shape, SurfaceController sc, Color3f col, String name)
          Constructor.
 
Method Summary
 void addSurfaceOverlay(SurfaceOverlay so)
          This will add a SurfaceOverlay to this shape.
 void clear()
          Clears data contained in this shape.
 float getAmbient()
          Returns the ambient level (0.0 - 1.0).
 BranchGroup getBranch()
          Returns the BranchGroup that contains this shape.
 String getBuildString()
          Returns the build string (a description of the build parameters)
 double getBuildTime()
          Returns the build time (for info purposes) in seconds.
 Color3f getColor()
          Returns the color.
 double getDecimationPercent()
          Returns the amount of decimation (smoothing) used in building this shape (default = 0).
 Color3f getDefaultColor()
          Returns the color initialized in the constructor.
 float getDiffuse()
          Returns the diffuse level (0.0 - 1.0).
 float getEmissive()
          Returns the emissive level (0.0 - 1.0).
 String getName()
          Returns the name of the shape.
 int getNumTriangles()
          Returns the number of triangles in this shape (default = 0).
 int getPolygonType()
          Returns the polygon type (fill, line, or point).
 Shape3D getShape()
          Returns the Shape3D object containing the geometry of this shape.
 float getShininess()
          Returns the shininess (specular scattering exponent) level (0.0 - 128.0).
 float getSpecular()
          Returns the specular (highlights) level (0.0 - 1.0).
 SurfaceData getSurfaceData()
          Returns the SurfaceData for this shape.
 Vector<SurfaceOverlay> getSurfaceOverlays()
          Returns the SurfaceOverlay collection.
 TransformGroup getTransformGroup()
          Returns the TransformGroup that contains this shape.
 boolean isIgnoringVertexColors()
          Returns true if this shape is not using vertex colors.
 boolean isSmoothShading()
          Returns true if using Gouraud (smooth) shading or false if using flat shading.
 boolean isUsingOverlayTransform()
          Returns true if the shape responds to changes in the viewer transform.
 boolean isUsingTransparency()
          Returns the transparency mode.
 boolean isVisible()
          Returns true if the shape visibility flag is set.
 void overlayChanged(Object image)
          If registered with a ScreenImage, this method notifies the shape when the overlay has been changed.
 void overlayColorTableChanged(Object overlay)
           
 void overlayRemoved(Object image)
          If registered with a ScreenImage, this method notifies the shape when the overlay has been removed from the viewer.
 void overlayTransformChanged(Object image)
          If registered with a ScreenImage, this method notifies the shape when the overlay has been removed from the viewer.
 void removeAllSurfaceOverlays()
          This will remove all SurfaceOverlays from this shape.
 void removeSurfaceOverlay(SurfaceOverlay so)
          This will remove a SurfaceOverlay from this shape.
 void setBranch(BranchGroup group)
          Sets the BranchGroup that contains this shape.
 void setBuildString(String string)
          Sets build string (a description of the build parameters)
 void setBuildTime(long val)
          Sets the build time (for info purposes) in milliseconds.
 void setColor(Color3f col)
          Sets the color.
 void setDecimationPercent(double val)
          Sets the amount of decimation (smoothing) used in building this shape.
 void setIgnoreVertexColors(boolean bool)
          Set to true to ignore vertex colors and render shape with solid color.
 void setLightingParameters(float ambientVal, float diffuseVal, float emissiveVal, float specularVal, float shininessVal)
          Sets the lighting parameters (ambient, diffuse, emissive, specular, shininess).
 void setName(String name)
          Sets the name of the shape.
 void setNumTriangles(int num)
          Sets the number of triangles in this shape.
 void setPolygonType(int type)
          Sets the polygon type (fill, line, or point).
 void setTransformGroup(TransformGroup group)
          Sets the TransformGroup that contains this shape.
 void setTransparency(boolean doTransparency)
          Sets the transparency mode.
 void setUseSmoothShading(boolean useSmooth)
          Sets the smooth shading state.
 void setUsesOverlayTransform(boolean use)
          Sets the shape flag for responding to viewer transforms.
 void setVisible(boolean vis)
          Sets the shape visibility flag.
protected  void updateVisible()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_AMBIENT

public static final float DEFAULT_AMBIENT
See Also:
Constant Field Values

DEFAULT_DIFFUSE

public static final float DEFAULT_DIFFUSE
See Also:
Constant Field Values

DEFAULT_SPECULAR

public static final float DEFAULT_SPECULAR
See Also:
Constant Field Values

DEFAULT_EMISSIVE

public static final float DEFAULT_EMISSIVE
See Also:
Constant Field Values

DEFAULT_SHININESS

public static final float DEFAULT_SHININESS
See Also:
Constant Field Values

DEFAULT_AMBIENT_D3D

public static final float DEFAULT_AMBIENT_D3D
See Also:
Constant Field Values

DEFAULT_DIFFUSE_D3D

public static final float DEFAULT_DIFFUSE_D3D
See Also:
Constant Field Values

DEFAULT_SPECULAR_D3D

public static final float DEFAULT_SPECULAR_D3D
See Also:
Constant Field Values

DEFAULT_EMISSIVE_D3D

public static final float DEFAULT_EMISSIVE_D3D
See Also:
Constant Field Values

DEFAULT_SHININESS_D3D

public static final float DEFAULT_SHININESS_D3D
See Also:
Constant Field Values

DEFAULT_BRIGHTNESS

public static final float DEFAULT_BRIGHTNESS
See Also:
Constant Field Values

TRANSPARENCY_LEVEL

public static final float TRANSPARENCY_LEVEL
See Also:
Constant Field Values
Constructor Detail

SurfaceShape

public SurfaceShape(Shape3D shape,
                    SurfaceController sc,
                    Color3f col,
                    String name)
Constructor.

Parameters:
shape - contains shape geometry
sc - the SurfaceController associated with this shape
col - the color of the shape; default color is set to col as well
name - the name of the shape
Method Detail

clear

public void clear()
Clears data contained in this shape.


getName

public String getName()
Returns the name of the shape.

Returns:
the name of the shape

setName

public void setName(String name)
Sets the name of the shape.

Parameters:
name - the name of the shape

getBuildTime

public double getBuildTime()
Returns the build time (for info purposes) in seconds. A negative number indicates the shape was loaded from file.

Returns:
the build time in seconds

setBuildTime

public void setBuildTime(long val)
Sets the build time (for info purposes) in milliseconds. Setting val to a negative number indicates the shape was loaded from file.

Parameters:
val - the build time in milliseconds

getColor

public Color3f getColor()
Returns the color.

Returns:
the color

setColor

public void setColor(Color3f col)
Sets the color.

Parameters:
col - the color

getAmbient

public float getAmbient()
Returns the ambient level (0.0 - 1.0).

Returns:
the ambient level

getDiffuse

public float getDiffuse()
Returns the diffuse level (0.0 - 1.0).

Returns:
the diffuse level

getSpecular

public float getSpecular()
Returns the specular (highlights) level (0.0 - 1.0).

Returns:
the specular (highlights) level

getShininess

public float getShininess()
Returns the shininess (specular scattering exponent) level (0.0 - 128.0).

Returns:
the shininess (specular scattering exponent) level

getEmissive

public float getEmissive()
Returns the emissive level (0.0 - 1.0).

Returns:
the emissive level

setLightingParameters

public void setLightingParameters(float ambientVal,
                                  float diffuseVal,
                                  float emissiveVal,
                                  float specularVal,
                                  float shininessVal)
Sets the lighting parameters (ambient, diffuse, emissive, specular, shininess).

Parameters:
ambientVal - the ambient level (0.0 - 1.0)
diffuseVal - the diffuse level (0.0 - 1.0)
emissiveVal - the emissive level (0.0 - 1.0)
specularVal - the specular level (0.0 - 1.0)
shininessVal - the shininess level (0.0 - 128.0)

isUsingTransparency

public boolean isUsingTransparency()
Returns the transparency mode.

Returns:
true if transparency is used, false otherwise

setTransparency

public void setTransparency(boolean doTransparency)
Sets the transparency mode.

Parameters:
doTransparency - true if transparency is used, false otherwise

isSmoothShading

public boolean isSmoothShading()
Returns true if using Gouraud (smooth) shading or false if using flat shading.

Returns:
true if using Gouraud (smooth) shading or false if using flat shading

setUseSmoothShading

public void setUseSmoothShading(boolean useSmooth)
Sets the smooth shading state.

Parameters:
useSmooth - set to true to use Gouraud (smooth) shading or false to use flat shading

isVisible

public boolean isVisible()
Returns true if the shape visibility flag is set. Note, the SurfaceController may override and set all shapes as not visible.

Returns:
true if the shape visibility flag is set

setVisible

public void setVisible(boolean vis)
Sets the shape visibility flag. Note, the SurfaceController may override and set all shapes as not visible.

Parameters:
vis - set to true to set the visibility flag, or false to unset the flag

isUsingOverlayTransform

public boolean isUsingOverlayTransform()
Returns true if the shape responds to changes in the viewer transform.

Returns:
true if the shape responds to changes in the viewer transform

setUsesOverlayTransform

public void setUsesOverlayTransform(boolean use)
Sets the shape flag for responding to viewer transforms.

Parameters:
use - setting to true will make this shape respond to changes in the viewer transform

getBranch

public BranchGroup getBranch()
Returns the BranchGroup that contains this shape.

Returns:
the BranchGroup that contains this shape

setBranch

public void setBranch(BranchGroup group)
Sets the BranchGroup that contains this shape.

Parameters:
group - the BranchGroup that contains this shape

getTransformGroup

public TransformGroup getTransformGroup()
Returns the TransformGroup that contains this shape.

Returns:
the TransformGroup that contains this shape

setTransformGroup

public void setTransformGroup(TransformGroup group)
Sets the TransformGroup that contains this shape.

Parameters:
group - the TransformGroup that contains this shape

getShape

public Shape3D getShape()
Returns the Shape3D object containing the geometry of this shape.

Returns:
the Shape3D object

getDefaultColor

public Color3f getDefaultColor()
Returns the color initialized in the constructor.

Returns:
the color initialized in the constructor

getSurfaceData

public SurfaceData getSurfaceData()
Returns the SurfaceData for this shape. It contains points, normals, triangles (strip counts), name, and color.

Returns:
the SurfaceData for this shape

getNumTriangles

public int getNumTriangles()
Returns the number of triangles in this shape (default = 0).

Returns:
the number of triangles in this shape

setNumTriangles

public void setNumTriangles(int num)
Sets the number of triangles in this shape.

Parameters:
num - the number of triangles

setDecimationPercent

public void setDecimationPercent(double val)
Sets the amount of decimation (smoothing) used in building this shape.

Parameters:
val - the amount of decimation

getDecimationPercent

public double getDecimationPercent()
Returns the amount of decimation (smoothing) used in building this shape (default = 0).

Returns:
the amount of decimation

setBuildString

public void setBuildString(String string)
Sets build string (a description of the build parameters)

Parameters:
string - the build string

getBuildString

public String getBuildString()
Returns the build string (a description of the build parameters)

Returns:
the build string

getPolygonType

public int getPolygonType()
Returns the polygon type (fill, line, or point). See javax.media.j3d.PolygonAttributes.

Returns:
the polygon type

setPolygonType

public void setPolygonType(int type)
Sets the polygon type (fill, line, or point). See javax.media.j3d.PolygonAttributes.

Parameters:
type - the polygon type

isIgnoringVertexColors

public boolean isIgnoringVertexColors()
Returns true if this shape is not using vertex colors.

Returns:
true if this shape is not using vertex colors

setIgnoreVertexColors

public void setIgnoreVertexColors(boolean bool)
Set to true to ignore vertex colors and render shape with solid color.

Parameters:
bool - true to ignore vertex colors, false to use vertex colors

overlayChanged

public void overlayChanged(Object image)
If registered with a ScreenImage, this method notifies the shape when the overlay has been changed.

Specified by:
overlayChanged in interface OverlayListener
Parameters:
image - the overlay

overlayRemoved

public void overlayRemoved(Object image)
If registered with a ScreenImage, this method notifies the shape when the overlay has been removed from the viewer.

Specified by:
overlayRemoved in interface OverlayListener
Parameters:
image - the overlay

overlayTransformChanged

public void overlayTransformChanged(Object image)
If registered with a ScreenImage, this method notifies the shape when the overlay has been removed from the viewer.

Parameters:
image - the overlay

addSurfaceOverlay

public void addSurfaceOverlay(SurfaceOverlay so)
This will add a SurfaceOverlay to this shape.

Parameters:
so - the SurfaceOverlay to add

removeSurfaceOverlay

public void removeSurfaceOverlay(SurfaceOverlay so)
This will remove a SurfaceOverlay from this shape.

Parameters:
so - the SurfaceOverlay to remove

removeAllSurfaceOverlays

public void removeAllSurfaceOverlays()
This will remove all SurfaceOverlays from this shape.


getSurfaceOverlays

public Vector<SurfaceOverlay> getSurfaceOverlays()
Returns the SurfaceOverlay collection.

Returns:
the SurfaceOverlay collection

updateVisible

protected void updateVisible()

overlayColorTableChanged

public void overlayColorTableChanged(Object overlay)