Example usage for javax.media.j3d FontExtrusion FontExtrusion

List of usage examples for javax.media.j3d FontExtrusion FontExtrusion

Introduction

In this page you can find the example usage for javax.media.j3d FontExtrusion FontExtrusion.

Prototype

public FontExtrusion(Shape extrusionShape) 

Source Link

Document

Constructs a FontExtrusion object with the specified shape, using the default tessellation tolerance.

Usage

From source file:Text3DTest.java

TransformGroup createText3D(TornadoRotation rotator, String szText, int nSize, float scale, float trans,
        int nPath) {
    TransformGroup tg = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(scale);// w w w.j a va2  s.  c  o  m
    t3d.setTranslation(new Vector3d(0.0, trans, -10.0));
    tg.setTransform(t3d);

    // use a customized FontExtrusion object to control the depth of the
    // text
    double X1 = 0;
    double Y1 = 0;
    double X2 = 3;
    double Y2 = 0;
    Shape extrusionShape = new java.awt.geom.Line2D.Double(X1, Y1, X2, Y2);

    FontExtrusion fontEx = new FontExtrusion(extrusionShape);

    Font3D f3d = new Font3D(new Font("TimesRoman", Font.PLAIN, nSize), fontEx);

    TornadoText3D text3D = new TornadoText3D(f3d, szText, new Point3f(0.0f, 0.0f, 0.0f), Text3D.ALIGN_CENTER,
            nPath);

    rotator.addTornadoText3D(text3D);

    // create an appearance
    Color3f black = new Color3f(0.1f, 0.1f, 0.1f);
    Color3f objColor = new Color3f(0.2f, 0.2f, 0.2f);

    Appearance app = new Appearance();
    app.setMaterial(new Material(objColor, black, objColor, black, 90.0f));

    // render as a wireframe
    PolygonAttributes polyAttrbutes = new PolygonAttributes();
    polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
    app.setPolygonAttributes(polyAttrbutes);

    tg.addChild(new Shape3D(text3D, app));
    return tg;
}