javax.media.j3d
Class Font3D

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.NodeComponent
          extended by javax.media.j3d.Font3D

public class Font3D
extends NodeComponent

The Font3D object is used to store extruded 2D glyphs. These 3D glyphs can then be used to construct Text3D NodeComponent objects.

A 3D Font consists of a Java 2D font, a tesellation tolerance, and an extrusion path. The extrusion path creates depth by describing how the edge of a glyph varies in the Z axis.

The construction of a Text3D object requires a Font3D object. The Font3D object describes the style of the text, such as its depth. The text also needs other classes, such as java.awt.Font and FontExtrusion. The Font object describes the font name (Helvetica, Courier, etc.), the font style (bold, Italic, etc.), and point size. The FontExtrusion object extends Font3D by describing the extrusion path for the Font3D object (how the edge of the font glyph varies in the Z axis).

To ensure correct rendering, the 2D Font object should be created with the default AffineTransform. The point size of the 2D font will be used as a rough measure of how fine a tesselation to use when creating the Font3D object: the larger the point size, in general, the finer the tesselation.

Custom 3D fonts as well as methods to store 3D fonts to disk will be addressed in a future release.

See Also:
Font, FontExtrusion, Text3D

Nested Class Summary
private static class Font3D.IslandsNode
           
 
Field Summary
(package private) static float EPS
           
(package private)  java.awt.Font font
           
(package private)  FontExtrusion fontExtrusion
           
(package private)  java.awt.font.FontRenderContext frc
           
(package private)  java.util.Hashtable geomHash
           
(package private)  double tessellationTolerance
           
 
Fields inherited from class javax.media.j3d.NodeComponent
forceDuplicate
 
Fields inherited from class javax.media.j3d.SceneGraphObject
nodeHashtable, retained
 
Constructor Summary
Font3D(java.awt.Font font, double tessellationTolerance, FontExtrusion extrudePath)
          Constructs a Font3D object from the specified Font and FontExtrusion objects, using the specified tessellation tolerance.
Font3D(java.awt.Font font, FontExtrusion extrudePath)
          Constructs a Font3D object from the specified Font and FontExtrusion objects, using the default value for the tessellation tolerance.
 
Method Summary
(package private) static int check2Contours(int begin1, int end1, int begin2, int end2, Point3f[] vertices)
           
 void getBoundingBox(int glyphCode, BoundingBox bounds)
          Returns the 3D bounding box of the specified glyph code.
 java.awt.Font getFont()
          Returns the Java 2D Font used to create this Font3D object.
 void getFontExtrusion(FontExtrusion extrudePath)
          Copies the FontExtrusion object used to create this Font3D object into the specified parameter.
 GeometryArray getGlyphGeometry(char c)
          Returns a GeometryArray of a glyph in this Font3D.
(package private) static boolean getNormal(Point3f p1, Point3f p2, Point3f p3, Vector3f normal)
           
 double getTessellationTolerance()
          Returns the tessellation tolerance with which this Font3D was created.
(package private) static boolean normalize(Vector3f v)
           
(package private) static boolean pointInPolygon2D(float x, float y, int begIdx, int endIdx, Point3f[] verts)
           
(package private)  GeometryArrayRetained triangulateGlyphs(java.awt.font.GlyphVector gv, char c)
           
 
Methods inherited from class javax.media.j3d.NodeComponent
checkDuplicateNodeComponent, cloneNodeComponent, cloneNodeComponent, createRetained, duplicateAttributes, duplicateChild, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree, validateImageIllegalSharing
 
Methods inherited from class javax.media.j3d.SceneGraphObject
capabilityBitsEmpty, checkForLiveOrCompiled, clearCapability, clearCapabilityIsFrequent, clearLive, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getNamePrefix, getNodeComponent, getUserData, isCompiled, isLive, isLiveOrCompiled, setCapability, setCapabilityIsFrequent, setCompiled, setDefaultReadCapabilities, setLive, setName, setUserData, toString, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

font

java.awt.Font font

tessellationTolerance

double tessellationTolerance

fontExtrusion

FontExtrusion fontExtrusion

frc

java.awt.font.FontRenderContext frc

EPS

static final float EPS
See Also:
Constant Field Values

geomHash

java.util.Hashtable geomHash
Constructor Detail

Font3D

public Font3D(java.awt.Font font,
              FontExtrusion extrudePath)
Constructs a Font3D object from the specified Font and FontExtrusion objects, using the default value for the tessellation tolerance. The default value is as follows:

The FontExtrusion object contains the extrusion path to use on the 2D Font glyphs. To ensure correct rendering the font must be created with the default AffineTransform. Passing null for the FontExtrusion parameter results in no extrusion being done.

Parameters:
font - the Java 2D font used to create the 3D font object
extrudePath - the extrusion path used to describe how the edge of the font varies along the Z axis

Font3D

public Font3D(java.awt.Font font,
              double tessellationTolerance,
              FontExtrusion extrudePath)
Constructs a Font3D object from the specified Font and FontExtrusion objects, using the specified tessellation tolerance. The FontExtrusion object contains the extrusion path to use on the 2D Font glyphs. To ensure correct rendering, the font must be created with the default AffineTransform. Passing null for the FontExtrusion parameter results in no extrusion being done.

Parameters:
font - the Java 2D font used to create the 3D font object.
tessellationTolerance - the tessellation tolerance value used in tessellating the glyphs of the 2D Font. This corresponds to the flatness parameter in the java.awt.Shape.getPathIterator method.
extrudePath - the extrusion path used to describe how the edge of the font varies along the Z axis.
Since:
Java 3D 1.2
Method Detail

getFont

public java.awt.Font getFont()
Returns the Java 2D Font used to create this Font3D object.

Returns:
Font object used by this Font3D

getTessellationTolerance

public double getTessellationTolerance()
Returns the tessellation tolerance with which this Font3D was created.

Returns:
the tessellation tolerance used by this Font3D
Since:
Java 3D 1.2

getFontExtrusion

public void getFontExtrusion(FontExtrusion extrudePath)
Copies the FontExtrusion object used to create this Font3D object into the specified parameter.

Parameters:
extrudePath - object that will receive the FontExtrusion information for this Font3D object

getBoundingBox

public void getBoundingBox(int glyphCode,
                           BoundingBox bounds)
Returns the 3D bounding box of the specified glyph code.

Parameters:
glyphCode - the glyphCode from the original 2D Font
bounds - the 3D glyph's bounds

getGlyphGeometry

public GeometryArray getGlyphGeometry(char c)
Returns a GeometryArray of a glyph in this Font3D.

Parameters:
c - character from which to generate a tessellated glyph.
Returns:
a GeometryArray
Since:
Java 3D 1.4

triangulateGlyphs

GeometryArrayRetained triangulateGlyphs(java.awt.font.GlyphVector gv,
                                        char c)

getNormal

static boolean getNormal(Point3f p1,
                         Point3f p2,
                         Point3f p3,
                         Vector3f normal)

check2Contours

static int check2Contours(int begin1,
                          int end1,
                          int begin2,
                          int end2,
                          Point3f[] vertices)

pointInPolygon2D

static boolean pointInPolygon2D(float x,
                                float y,
                                int begIdx,
                                int endIdx,
                                Point3f[] verts)

normalize

static final boolean normalize(Vector3f v)


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.