Class Text2D


  • public class Text2D
    extends Shape3D
    A Text2D object is a representation of a string as a texture mapped rectangle. The texture for the rectangle shows the string as rendered in the specified color with a transparent background. The appearance of the characters is specified using the font indicated by the font name, size and style (see java.awt.Font). The approximate height of the rendered string will be the font size times the rectangle scale factor, which has a default value of 1/256. For example, a 12 point font will produce characters that are about 12/256 = 0.047 meters tall. The lower left corner of the rectangle is located at (0,0,0) with the height extending along the positive y-axis and the width extending along the positive x-axis.
    • Constructor Detail

      • Text2D

        public Text2D​(java.lang.String text,
                      javax.vecmath.Color3f color,
                      java.lang.String fontName,
                      int fontSize,
                      int fontStyle)
        Creates a Shape3D object which holds a rectangle that is texture-mapped with an image that has the specified text written with the specified font parameters.
        Parameters:
        text - The string to be written into the texture map.
        color - The color of the text string.
        fontName - The name of the Java font to be used for the text string.
        fontSize - The size of the Java font to be used.
        fontStyle - The style of the Java font to be used.
    • Method Detail

      • setString

        public void setString​(java.lang.String text)
      • setRectangleScaleFactor

        public void setRectangleScaleFactor​(float newScaleFactor)
        Sets the scale factor used in converting the image width/height to width/height values in 3D.
        Parameters:
        newScaleFactor - The new scale factor.
      • getRectangleScaleFactor

        public float getRectangleScaleFactor()
        Gets the current scale factor being used in converting the image width/height to width/height values in 3D.
        Returns:
        The current scale factor.
      • getString

        public java.lang.String getString()
        Returns the text string
        Since:
        Java 3D 1.2.1
      • getColor

        public javax.vecmath.Color3f getColor()
        Returns the color of the text
        Since:
        Java 3D 1.2.1
      • getFontName

        public java.lang.String getFontName()
        Returns the font
        Since:
        Java 3D 1.2.1
      • getFontSize

        public int getFontSize()
        Returns the font size
        Since:
        Java 3D 1.2.1
      • getFontStyle

        public int getFontStyle()
        Returns the font style
        Since:
        Java 3D 1.2.1