com.sun.electric.plugins.j3d.utils
Class J3DUtils

java.lang.Object
  extended by com.sun.electric.plugins.j3d.utils.J3DUtils

public final class J3DUtils
extends java.lang.Object

Utility class for 3D module

Version:
0.1
Author:
Gilda Garreton

Nested Class Summary
static class J3DUtils.OffScreenCanvas3D
          Class to create offscreen from canvas 3D
static class J3DUtils.ThreeDDemoKnot
          This class is @serial
 
Field Summary
static Color3f black
          standard colors to be used by materials
static BoundingSphere infiniteBounds
           
static J3DAlpha jAlpha
           
static Color3f plastic
          standard colors to be used by materials
 
Constructor Summary
J3DUtils()
           
 
Method Summary
static Node addCylinder(java.awt.geom.Point2D[] points, double distance, double thickness, Appearance ap, TransformGroup objTrans)
          Method to add a cylindrical shaped element
static Shape3D addPolyhedron(java.awt.geom.PathIterator pIt, double distance, double thickness, Appearance ap, TransformGroup objTrans)
           
static Shape3D addPolyhedron(java.awt.geom.Rectangle2D bounds, double distance, double thickness, Appearance ap, TransformGroup objTrans)
          Method to add a polyhedron to the transformation group
static Shape3D addShape3D(Point3d[] pts, int listLen, Appearance ap, TransformGroup objTrans)
          Simple method to generate polyhedra
static double convertToRadiant(double degrees)
           
static double[] convertValues(java.lang.String[] stringValues)
           
static void correctNormals(java.util.List<Point3d> topList, java.util.List<Point3d> bottomList)
          Method to correct points sequence to obtain valid normals
static void createBackground(BranchGroup scene)
          Create the background node based on given background color
static void createLights(BranchGroup scene)
          Create the lights (directional and ambiental) for the given scene graph based on User's data
static Quat4f createQuaternionFromEuler(double angleX, double angleY, double angleZ)
          Convert three rotations about the Euler axes to a Quaternion.
static int get3DAlpha()
          Method to get current alpha speed for 3D demos The default is 1000
static int get3DColorAmbientLight()
          Method to get the ambiental color on the 3D display.
static Pref get3DColorAmbientLightPref()
           
static int[] get3DColorAxes()
          Method to get the color of the axes on the 3D display.
static int get3DColorDirectionalLight()
          Method to get the color of directional light on the 3D display.
static Pref get3DColorDirectionalLightPref()
           
static int get3DColorHighlighted()
          Method to get the color of the highlighted instance on the 3D display.
static Pref get3DColorHighlightedPref()
           
static int get3DColorInstanceCell()
          Method to get the color of the cell instance on the 3D display.
static Pref get3DColorInstanceCellPref()
           
static void get3DColorsInTab(java.util.Map<java.lang.String,ColorPatternPanel.Info> transAndSpecialMap)
          Color Tab SECTION
static double get3DFactor()
          Method to get current scale factor for Z values.
static java.lang.String get3DLightDirs()
          Method to return the first light direction.
static int get3DMaxNumNodes()
          Method to get maximum number of nodes to consider a scene graph.
static double get3DOrigZoom()
          Method to get original zoom factor for the view The default is 1
static java.lang.String get3DRotation()
          Method to get default rotation for the view along X, Y and Z The default is (0 0 0) and values are in radiant
static int getFactory3DAlpha()
          Method to get current alpha speed for 3D demos, by default.
static double getFactory3DFactor()
          Method to get current scale factor for Z values, by default.
static java.lang.String getFactory3DLightDirs()
          Method to return the first light direction, by default.
static int getFactory3DMaxNumNodes()
          Method to get maximum number of nodes to consider a scene graph, by default.
static double getFactory3DOrigZoom()
          Method to get original zoom factor for the view, by default.
static java.lang.String getFactory3DRotation()
          Method to get factory default rotation for the view along X, Y and Z
static KBKeyFrame getNextKBKeyFrame(float ratio, J3DUtils.ThreeDDemoKnot knot)
          Method to generate each individual frame key for the interporlation based on Poly information
static TCBKeyFrame getNextTCBKeyFrame(float ratio, J3DUtils.ThreeDDemoKnot knot)
           
static boolean is3DAntialiasing()
          Method to tell whether to use antialiasing in 3D view.
static boolean is3DAxesOn()
          Method to tell whether to draw 3D axes or not.
static boolean is3DCellBndOn()
          Method to tell whether to draw bounding box for the cells.
static boolean is3DPerspective()
          Method to tell whether to draw 3D views with perspective.
static boolean isFactory3DAntialiasing()
          Method to tell whether to use antialiasing in 3D view, by default.
static boolean isFactory3DAxesOn()
          Method to tell whether to draw 3D axes or not, by default.
static boolean isFactory3DCellBndOn()
          Method to tell whether to draw bounding box for the cells, by default.
static boolean isFactory3DPerspective()
          Method to tell whether to draw 3D views with perspective, by default.
static java.lang.String[] parseValues(java.lang.String line, int lineNumner)
          To parse capacitance data from line Format: posX posY posZ rotX rotY rotZ rotPosX rotPosY rotPosZ capacitance radius error
static java.util.List<J3DUtils.ThreeDDemoKnot> readDemoDataFromFile(View3DWindow view3D)
          Method to generate knots for interpolator from a file
static void set3DAlpha(int value)
          Method to set 3D alpha speed
static void set3DAntialiasing(boolean on)
          Method to set whether to draw 3D views with perspective.
static void set3DAxesOn(boolean on)
          Method to set whether to draw 3D axes or not.
static void set3DCellBndOn(boolean on)
          Method to set whether to draw bounding box for the cells.
static void set3DColorAmbientLight(int c)
          Method to set the ambiental color on the 3D display.
static void set3DColorDirectionalLight(int c)
          Method to set the color of directional light on the 3D display.
static void set3DColorHighlighted(int c)
          Method to set the color of the highlighted instance on the 3D display.
static void set3DColorInstanceCell(int c)
          Method to set the color of the cell instance on the 3D display.
static java.lang.Boolean set3DColorsInTab(LayersTab tab)
           
static void set3DFactor(double value)
          Method to set 3D scale factor
static void set3DLightDirs(java.lang.String c)
          Method to set the first light direction.
static void set3DMaxNumNodes(int num)
          Method to set maximum number of nodes to display in 3D view.
static void set3DOrigZoom(double value)
          Method to set default zoom factor
static void set3DPerspective(boolean on)
          Method to set whether to draw 3D views with perspective.
static void set3DRotation(java.lang.String value)
          Method to set default rotation angles along X, Y and Z.
static void setAlpha(int speed)
          Create alpha according to given interval time in miliseconds
static void setAmbientalColor(java.lang.Object initValue)
          Method to set ambiental color
static void setBackgroundColor(java.lang.Object initValue)
          Method to set background color
static void setDirectionalColor(java.lang.Object initValue)
          Method to set directional color
static void setDirections(java.lang.Object initValue)
          Method to set direction in directional light
static void setViewPoint(SimpleUniverse u, Canvas3D canvas, BranchGroup scene, java.awt.geom.Rectangle2D cellBnd)
           
static Vector3f[] transformIntoVectors(java.lang.String dir)
           
static boolean updateZValues(Shape3D shape, float origZ1, float origZ2, float z1, float z2)
          Method to reset z values of shapes created with addPolyhedron
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

black

public static final Color3f black
standard colors to be used by materials


plastic

public static final Color3f plastic
standard colors to be used by materials


infiniteBounds

public static final BoundingSphere infiniteBounds

jAlpha

public static J3DAlpha jAlpha
Constructor Detail

J3DUtils

public J3DUtils()
Method Detail

get3DColorDirectionalLight

public static int get3DColorDirectionalLight()
Method to get the color of directional light on the 3D display. The default is "gray".

Returns:
the color of directional light on the 3D display.

get3DColorDirectionalLightPref

public static Pref get3DColorDirectionalLightPref()

set3DColorDirectionalLight

public static void set3DColorDirectionalLight(int c)
Method to set the color of directional light on the 3D display.

Parameters:
c - the color of directional light on the 3D display.

get3DLightDirs

public static java.lang.String get3DLightDirs()
Method to return the first light direction. The default is the X axis.

Returns:
the company name to use in schematic frames.

set3DLightDirs

public static void set3DLightDirs(java.lang.String c)
Method to set the first light direction. It is stored as string

Parameters:
c - the company name to use in schematic frames.

getFactory3DLightDirs

public static java.lang.String getFactory3DLightDirs()
Method to return the first light direction, by default.

Returns:
the company name to use in schematic frames, by default.

get3DColorAxes

public static int[] get3DColorAxes()
Method to get the color of the axes on the 3D display. The default values are "red", "blue" and "green"..

Returns:
the color of the axes on the 3D display.

get3DMaxNumNodes

public static int get3DMaxNumNodes()
Method to get maximum number of nodes to consider a scene graph. The default is "1000".

Returns:
maximim number of nodes.

set3DMaxNumNodes

public static void set3DMaxNumNodes(int num)
Method to set maximum number of nodes to display in 3D view.

Parameters:
num - maximim number of nodes.

getFactory3DMaxNumNodes

public static int getFactory3DMaxNumNodes()
Method to get maximum number of nodes to consider a scene graph, by default.

Returns:
maximim number of nodes, by default.

is3DAxesOn

public static boolean is3DAxesOn()
Method to tell whether to draw 3D axes or not. The default is "true".

Returns:
true to draw 3D axes.

set3DAxesOn

public static void set3DAxesOn(boolean on)
Method to set whether to draw 3D axes or not.

Parameters:
on - true to draw 3D axes.

isFactory3DAxesOn

public static boolean isFactory3DAxesOn()
Method to tell whether to draw 3D axes or not, by default.

Returns:
true to draw 3D axes, by default.

is3DCellBndOn

public static boolean is3DCellBndOn()
Method to tell whether to draw bounding box for the cells. The default is "true".

Returns:
true to draw bounding box for the cells.

set3DCellBndOn

public static void set3DCellBndOn(boolean on)
Method to set whether to draw bounding box for the cells.

Parameters:
on - true to draw bounding box for the cells.

isFactory3DCellBndOn

public static boolean isFactory3DCellBndOn()
Method to tell whether to draw bounding box for the cells, by default.

Returns:
true to draw bounding box for the cells, by default.

is3DPerspective

public static boolean is3DPerspective()
Method to tell whether to draw 3D views with perspective. The default is "true".

Returns:
true to draw 3D views with perspective.

set3DPerspective

public static void set3DPerspective(boolean on)
Method to set whether to draw 3D views with perspective.

Parameters:
on - true to draw 3D views with perspective.

isFactory3DPerspective

public static boolean isFactory3DPerspective()
Method to tell whether to draw 3D views with perspective, by default.

Returns:
true to draw 3D views with perspective, by default.

is3DAntialiasing

public static boolean is3DAntialiasing()
Method to tell whether to use antialiasing in 3D view. The default is "false" due to performance.

Returns:
true to draw 3D views with perspective.

set3DAntialiasing

public static void set3DAntialiasing(boolean on)
Method to set whether to draw 3D views with perspective.

Parameters:
on - true to draw 3D views with perspective.

isFactory3DAntialiasing

public static boolean isFactory3DAntialiasing()
Method to tell whether to use antialiasing in 3D view, by default.

Returns:
true to draw 3D views with perspective, by default.

get3DOrigZoom

public static double get3DOrigZoom()
Method to get original zoom factor for the view The default is 1

Returns:
original zoom factor

set3DOrigZoom

public static void set3DOrigZoom(double value)
Method to set default zoom factor

Parameters:
value - zoom factor

getFactory3DOrigZoom

public static double getFactory3DOrigZoom()
Method to get original zoom factor for the view, by default.

Returns:
original zoom factor, by default.

get3DRotation

public static java.lang.String get3DRotation()
Method to get default rotation for the view along X, Y and Z The default is (0 0 0) and values are in radiant

Returns:
rotation along X, y and Z axes.

set3DRotation

public static void set3DRotation(java.lang.String value)
Method to set default rotation angles along X, Y and Z. Values are in radiant

Parameters:
value - angles on X, Y and Z

getFactory3DRotation

public static java.lang.String getFactory3DRotation()
Method to get factory default rotation for the view along X, Y and Z

Returns:
factory default rotation along X, y and Z axes.

get3DFactor

public static double get3DFactor()
Method to get current scale factor for Z values. The default is 1.0

Returns:
scale factor along Z.

set3DFactor

public static void set3DFactor(double value)
Method to set 3D scale factor

Parameters:
value - 3D scale factor to set.

getFactory3DFactor

public static double getFactory3DFactor()
Method to get current scale factor for Z values, by default.

Returns:
scale factor along Z, by default.

get3DAlpha

public static int get3DAlpha()
Method to get current alpha speed for 3D demos The default is 1000

Returns:
alpha speed.

set3DAlpha

public static void set3DAlpha(int value)
Method to set 3D alpha speed

Parameters:
value - 3D alpha to set.

getFactory3DAlpha

public static int getFactory3DAlpha()
Method to get current alpha speed for 3D demos, by default.

Returns:
alpha speed, by default.

readDemoDataFromFile

public static java.util.List<J3DUtils.ThreeDDemoKnot> readDemoDataFromFile(View3DWindow view3D)
Method to generate knots for interpolator from a file

Parameters:
view3D -
Returns:
list with knot points. Null if operation was cancelled

convertValues

public static double[] convertValues(java.lang.String[] stringValues)

parseValues

public static java.lang.String[] parseValues(java.lang.String line,
                                             int lineNumner)
To parse capacitance data from line Format: posX posY posZ rotX rotY rotZ rotPosX rotPosY rotPosZ capacitance radius error

Parameters:
line -
lineNumner -

get3DColorInstanceCell

public static int get3DColorInstanceCell()
Method to get the color of the cell instance on the 3D display. The default is "gray".

Returns:
the color of the cell instance on the 3D display.

get3DColorInstanceCellPref

public static Pref get3DColorInstanceCellPref()

set3DColorInstanceCell

public static void set3DColorInstanceCell(int c)
Method to set the color of the cell instance on the 3D display.

Parameters:
c - the color of the cell instance on the 3D display.

get3DColorHighlighted

public static int get3DColorHighlighted()
Method to get the color of the highlighted instance on the 3D display. The default is "gray".

Returns:
the color of the highlighted instance on the 3D display.

get3DColorHighlightedPref

public static Pref get3DColorHighlightedPref()

set3DColorHighlighted

public static void set3DColorHighlighted(int c)
Method to set the color of the highlighted instance on the 3D display.

Parameters:
c - the color of the highlighted instance on the 3D display.

get3DColorAmbientLight

public static int get3DColorAmbientLight()
Method to get the ambiental color on the 3D display. The default is "gray".

Returns:
the ambiental color on the 3D display.

get3DColorAmbientLightPref

public static Pref get3DColorAmbientLightPref()

set3DColorAmbientLight

public static void set3DColorAmbientLight(int c)
Method to set the ambiental color on the 3D display.

Parameters:
c - the ambiental color on the 3D display.

transformIntoVectors

public static Vector3f[] transformIntoVectors(java.lang.String dir)

setDirections

public static void setDirections(java.lang.Object initValue)
Method to set direction in directional light

Parameters:
initValue -

setAmbientalColor

public static void setAmbientalColor(java.lang.Object initValue)
Method to set ambiental color

Parameters:
initValue - null if value has to be redone from user data

setDirectionalColor

public static void setDirectionalColor(java.lang.Object initValue)
Method to set directional color

Parameters:
initValue - null if value has to be redone from user data

setBackgroundColor

public static void setBackgroundColor(java.lang.Object initValue)
Method to set background color

Parameters:
initValue - null if value has to be redone from user data

createBackground

public static void createBackground(BranchGroup scene)
Create the background node based on given background color

Parameters:
scene -

setAlpha

public static void setAlpha(int speed)
Create alpha according to given interval time in miliseconds

Parameters:
speed -

createLights

public static void createLights(BranchGroup scene)
Create the lights (directional and ambiental) for the given scene graph based on User's data

Parameters:
scene -

setViewPoint

public static void setViewPoint(SimpleUniverse u,
                                Canvas3D canvas,
                                BranchGroup scene,
                                java.awt.geom.Rectangle2D cellBnd)

convertToRadiant

public static double convertToRadiant(double degrees)

updateZValues

public static boolean updateZValues(Shape3D shape,
                                    float origZ1,
                                    float origZ2,
                                    float z1,
                                    float z2)
Method to reset z values of shapes created with addPolyhedron

Parameters:
shape -
origZ1 -
origZ2 -
z1 -
z2 -
Returns:
true if values were valid

addCylinder

public static Node addCylinder(java.awt.geom.Point2D[] points,
                               double distance,
                               double thickness,
                               Appearance ap,
                               TransformGroup objTrans)
Method to add a cylindrical shaped element

Parameters:
points -
distance -
thickness -
ap -
objTrans -
Returns:

addPolyhedron

public static Shape3D addPolyhedron(java.awt.geom.Rectangle2D bounds,
                                    double distance,
                                    double thickness,
                                    Appearance ap,
                                    TransformGroup objTrans)
Method to add a polyhedron to the transformation group

Parameters:
objTrans -

addShape3D

public static Shape3D addShape3D(Point3d[] pts,
                                 int listLen,
                                 Appearance ap,
                                 TransformGroup objTrans)
Simple method to generate polyhedra

Parameters:
pts -
listLen -
ap -
Returns:

addPolyhedron

public static Shape3D addPolyhedron(java.awt.geom.PathIterator pIt,
                                    double distance,
                                    double thickness,
                                    Appearance ap,
                                    TransformGroup objTrans)

correctNormals

public static void correctNormals(java.util.List<Point3d> topList,
                                  java.util.List<Point3d> bottomList)
Method to correct points sequence to obtain valid normals

Parameters:
topList -
bottomList -

getNextKBKeyFrame

public static KBKeyFrame getNextKBKeyFrame(float ratio,
                                           J3DUtils.ThreeDDemoKnot knot)
Method to generate each individual frame key for the interporlation based on Poly information

Parameters:
ratio -
knot -
Returns:

getNextTCBKeyFrame

public static TCBKeyFrame getNextTCBKeyFrame(float ratio,
                                             J3DUtils.ThreeDDemoKnot knot)

createQuaternionFromEuler

public static Quat4f createQuaternionFromEuler(double angleX,
                                               double angleY,
                                               double angleZ)
Convert three rotations about the Euler axes to a Quaternion. From Selman's book

Parameters:
angleX -
angleY -
angleZ -
Returns:

get3DColorsInTab

public static void get3DColorsInTab(java.util.Map<java.lang.String,ColorPatternPanel.Info> transAndSpecialMap)
Color Tab SECTION


set3DColorsInTab

public static java.lang.Boolean set3DColorsInTab(LayersTab tab)