Example usage for javax.media.j3d Canvas3D setSize

List of usage examples for javax.media.j3d Canvas3D setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:MixedTest.java

protected Canvas3D createCanvas3D() {
    GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
    gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
    GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

    Canvas3D c3d = new Canvas3D(gd[0].getBestConfiguration(gc3D));
    c3d.setSize(getCanvas3dWidth(c3d), getCanvas3dHeight(c3d));

    return c3d;/*  ww w  .j av a2  s.c  om*/
}

From source file:SwingTest.java

/**
 * Create a Canvas3D.//from ww  w.  j  av a2s  .  c o  m
 * 
 * @param offscreen
 *            true to specify an offscreen canvas
 */
protected Canvas3D createCanvas3D(boolean offscreen) {
    GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D();
    gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
    GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

    Canvas3D c3d = new Canvas3D(gd[0].getBestConfiguration(gc3D), offscreen);
    c3d.setSize(500, 500);

    return c3d;
}

From source file:PlatformTest.java

public PlatformTest() {
    m_KeyHashtable = new Hashtable();
    m_Bounds = new BoundingSphere(new Point3d(0, 0, 0), 100);
    // get the graphics configuration for the graphics device
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    // create the first canvas, this is the top-down view
    Canvas3D c = new Canvas3D(config);
    c.setSize(m_kWidth, m_kHeight);
    add(c);/*from  w ww  .j  a va2s  .  c o m*/

    // create the second canvas, this is used for "Jim's" Viewer
    Canvas3D c2 = new Canvas3D(config);
    c2.setSize(m_kWidth, m_kHeight);
    add(c2);

    // create the third canvas, this is used for "Dan's" Viewer
    Canvas3D c3 = new Canvas3D(config);
    c3.setSize(m_kWidth, m_kHeight);
    add(c3);

    // Create the simple environment
    BranchGroup scene = createSceneGraph();

    // create the first Viewer, this is a static top-down view
    // create a ViewingPlatform with 2 TransformGroups above the
    // ViewPlatform
    ViewingPlatform vp = new ViewingPlatform(2);

    // create the Viewer and attach to the first canvas
    Viewer viewer = new Viewer(c);

    // rotate and position the first Viewer above the environment
    Transform3D t3d = new Transform3D();
    t3d.rotX(Math.PI / 2.0);
    t3d.setTranslation(new Vector3d(0, 0, -40));
    t3d.invert();

    MultiTransformGroup mtg = vp.getMultiTransformGroup();
    mtg.getTransformGroup(0).setTransform(t3d);

    // create a SimpleUniverse from the ViewingPlatform and Viewer
    SimpleUniverse u = new SimpleUniverse(vp, viewer);

    // add the geometry to the scenegraph
    u.addBranchGraph(scene);

    // add two more Viewers to the scenegraph
    u.getLocale().addBranchGraph(createViewer(c2, "Jim", new Color3f(0.1f, 1.0f, 1.0f), -5, 8));
    u.getLocale().addBranchGraph(createViewer(c3, "Dan", new Color3f(1.0f, 0.1f, 0.1f), 2, -8));

}