Example usage for javax.media.j3d Switch CHILD_NONE

List of usage examples for javax.media.j3d Switch CHILD_NONE

Introduction

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

Prototype

int CHILD_NONE

To view the source code for javax.media.j3d Switch CHILD_NONE.

Click Source Link

Document

Specifies that no children are rendered.

Usage

From source file:EnvironmentExplorer.java

JPanel configPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 0));

    String[] dataTypeValues = { "Spheres", "Grid", };
    IntChooser dataTypeChooser = new IntChooser("Data:", dataTypeValues);
    dataTypeChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            switch (value) {
            case 0:
                spheresSwitch.setWhichChild(Switch.CHILD_ALL);
                gridSwitch.setWhichChild(Switch.CHILD_NONE);
                break;
            case 1:
                gridSwitch.setWhichChild(Switch.CHILD_ALL);
                spheresSwitch.setWhichChild(Switch.CHILD_NONE);
                break;
            }//  ww  w.  java  2s .c om
        }
    });
    panel.add(dataTypeChooser);

    if (isApplication) {
        JButton snapButton = new JButton("Snap Image");
        snapButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Point loc = canvas.getLocationOnScreen();
                offScreenCanvas.setOffScreenLocation(loc);
                Dimension dim = canvas.getSize();
                dim.width *= OFF_SCREEN_SCALE;
                dim.height *= OFF_SCREEN_SCALE;
                nf.setMinimumIntegerDigits(3);
                offScreenCanvas.snapImageFile(outFileBase + nf.format(outFileSeq++), dim.width, dim.height);
                nf.setMinimumIntegerDigits(0);
            }
        });
        panel.add(snapButton);
    }

    return panel;
}

From source file:AppearanceExplorer.java

JPanel setupPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(0, 1));

    // This order of the names must match the cases in the Switch in
    // setupSceneSwitch
    String[] dataNames = { "Point Array", "Line Array", "Triangle Array", "Line Strip Array",
            "Triangle Strip Array", "Triangle Fan Array", "Textured Triangles", "Textured Square",
            "Large Texture Square", "Color Cube", "Norm Gen Cube - Crease", "Norm Gen Cube - Smooth",
            "Tri with hole", "Sphere", "Low-res Sphere", "High-res Sphere", "Text 3D", galleonString,
            beethovenString, };/*from  w  ww .  j a  v  a2  s  .com*/

    IntChooser dataChooser = new IntChooser("Data:", dataNames);
    dataChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            if (sceneSwitch.getChild(value) == beethovenPlaceholder) {
                beethoven = createBeethoven();
                sceneSwitch.setChild(beethoven, beethovenIndex);
            } else if (sceneSwitch.getChild(value) == galleonPlaceholder) {
                galleon = createGalleon();
                sceneSwitch.setChild(galleon, galleonIndex);
            }
            sceneSwitch.setWhichChild(value);
        }
    });
    dataChooser.setValueByName("Sphere");

    panel.add(dataChooser);

    panel.add(bgChooser);

    String[] lightNames = { "Ambient Only", "Directional", "Point Light 1", "Point Light 2", };
    int[] lightValues = { Switch.CHILD_NONE, 0, 1, 2 };

    IntChooser lightChooser = new IntChooser("Light:", lightNames, lightValues, 0);
    lightChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            lightSwitch.setWhichChild(value);
        }
    });
    lightChooser.setValueByName("Point Light 1");

    panel.add(lightChooser);

    panel.add(new JLabel(""));

    if (isApplication) {
        JButton snapButton = new JButton(snapImageString);
        snapButton.setActionCommand(snapImageString);
        snapButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                doSnapshot();
            }
        });
        panel.add(snapButton);
    }

    return panel;
}

From source file:TransformExplorer.java

RotAxis(float axisLength) {
    super(Switch.CHILD_NONE);
    setCapability(Switch.ALLOW_SWITCH_READ);
    setCapability(Switch.ALLOW_SWITCH_WRITE);

    // set up the proportions for the arrow
    float axisRadius = axisLength / 120.0f;
    float arrowRadius = axisLength / 50.0f;
    float arrowHeight = axisLength / 30.0f;

    // create the TransformGroup which will be used to orient the axis
    axisTG = new TransformGroup();
    axisTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    axisTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    addChild(axisTG);//from  w w w.j  ava  2s  . co  m

    // Set up an appearance to make the Axis have 
    // blue ambient, black emmissive, blue diffuse and white specular 
    // coloring.  
    Material material = new Material(blue, black, blue, white, 64);
    Appearance appearance = new Appearance();
    appearance.setMaterial(material);

    // create a cylinder for the central line of the axis
    Cylinder cylinder = new Cylinder(axisRadius, axisLength, appearance);
    // cylinder goes from -length/2 to length/2 in y
    axisTG.addChild(cylinder);

    // create a SharedGroup for the arrowHead
    Cone arrowHead = new Cone(arrowRadius, arrowHeight, appearance);
    SharedGroup arrowHeadSG = new SharedGroup();
    arrowHeadSG.addChild(arrowHead);

    // Create a TransformGroup to move the cone to the top of the 
    // cylinder
    tmpVector.set(0.0f, axisLength / 2 + arrowHeight / 2, 0.0f);
    tmpTrans.set(tmpVector);
    TransformGroup topTG = new TransformGroup();
    topTG.setTransform(tmpTrans);
    topTG.addChild(new Link(arrowHeadSG));
    axisTG.addChild(topTG);

    // create the bottom of the arrow
    // Create a TransformGroup to move the cone to the bottom of the 
    // axis so that its pushes into the bottom of the cylinder
    tmpVector.set(0.0f, -(axisLength / 2), 0.0f);
    tmpTrans.set(tmpVector);
    TransformGroup bottomTG = new TransformGroup();
    bottomTG.setTransform(tmpTrans);
    bottomTG.addChild(new Link(arrowHeadSG));
    axisTG.addChild(bottomTG);

    updateAxisTransform();
}

From source file:ffx.potential.MolecularAssembly.java

/**
 * {@inheritDoc}//from  w ww .  j  av a2 s.  co  m
 */
@Override
public void setView(RendererCache.ViewModel newViewModel, List<BranchGroup> newShapes) {
    // Just Detach the whole system branch group
    if (newViewModel == RendererCache.ViewModel.DESTROY) {
        if (switchGroup != null) {
            switchGroup.setWhichChild(Switch.CHILD_NONE);
        }
        visible = false;
    } else if (newViewModel == RendererCache.ViewModel.SHOWVRML) {
        switchGroup.setWhichChild(Switch.CHILD_ALL);
    } else if (newViewModel == RendererCache.ViewModel.HIDEVRML) {
        switchGroup.setWhichChild(0);
    } else {
        setWireWidth(RendererCache.bondwidth);
        if (newViewModel == RendererCache.ViewModel.DETAIL && childNodes.isLive()) {
            childNodes.detach();
        }
        /**
         * We'll collect new Scenegraph Shapes in our newShapeNode This is
         * to avoid the case where setView is called from the root node and
         * all new shapes for every MolecularAssembly would then be put into
         * the same ArrayList.
         */
        super.setView(newViewModel, myNewShapes);
        ArrayList<ROLS> moleculeList = getList(Molecule.class, new ArrayList<ROLS>());
        for (ROLS m : moleculeList) {
            m.setView(newViewModel, myNewShapes);
        }
        for (MSNode m : molecules.getChildList()) {
            m.setView(newViewModel, myNewShapes);
        }
        for (MSNode m : water.getChildList()) {
            m.setView(newViewModel, myNewShapes);
        }
        for (MSNode m : ions.getChildList()) {
            m.setView(newViewModel, myNewShapes);
        }
        if (newViewModel == RendererCache.ViewModel.INVISIBLE) {
            switchGroup.setWhichChild(0);
        }
        if (newViewModel == RendererCache.ViewModel.DETAIL) {
            childNodes.compile();
            base.addChild(childNodes);
        }
    }
}

From source file:AppearanceExplorer.java

BackgroundTool(String codeBaseString) {

    bgSwitch = new Switch(Switch.CHILD_NONE);
    bgSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    // set up the dark grey BG color node
    Background bgDarkGrey = new Background(darkGrey);
    bgDarkGrey.setApplicationBounds(infiniteBounds);
    bgSwitch.addChild(bgDarkGrey);/*  w ww  .  j ava  2 s  . c  om*/

    // set up the grey BG color node
    Background bgGrey = new Background(grey);
    bgGrey.setApplicationBounds(infiniteBounds);
    bgSwitch.addChild(bgGrey);

    // set up the light grey BG color node
    Background bgLightGrey = new Background(lightGrey);
    bgLightGrey.setApplicationBounds(infiniteBounds);
    bgSwitch.addChild(bgLightGrey);

    // set up the white BG color node
    Background bgWhite = new Background(white);
    bgWhite.setApplicationBounds(infiniteBounds);
    bgSwitch.addChild(bgWhite);

    // set up the blue BG color node
    Background bgBlue = new Background(skyBlue);
    bgBlue.setApplicationBounds(infiniteBounds);
    bgSwitch.addChild(bgBlue);

    // set up the image
    java.net.URL bgImageURL = null;
    try {
        bgImageURL = new java.net.URL(codeBaseString + "bg.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }
    if (bgImageURL == null) { // application, try file URL
        try {
            bgImageURL = new java.net.URL("file:./bg.jpg");
        } catch (java.net.MalformedURLException ex) {
            System.out.println(ex.getMessage());
            System.exit(1);
        }
    }
    TextureLoader bgTexture = new TextureLoader(bgImageURL, null);

    // Create a background with the static image
    Background bgImage = new Background(bgTexture.getImage());
    bgImage.setApplicationBounds(infiniteBounds);
    bgSwitch.addChild(bgImage);

    // create a background with the image mapped onto a sphere which
    // will enclose the world
    Background bgGeo = new Background();
    bgGeo.setApplicationBounds(infiniteBounds);
    BranchGroup bgGeoBG = new BranchGroup();
    Appearance bgGeoApp = new Appearance();
    bgGeoApp.setTexture(bgTexture.getTexture());
    Sphere sphereObj = new Sphere(1.0f,
            Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, 45,
            bgGeoApp);
    bgGeoBG.addChild(sphereObj);
    bgGeo.setGeometry(bgGeoBG);
    bgSwitch.addChild(bgGeo);

    // Create the chooser GUI
    String[] bgNames = { "No Background (Black)", "Dark Grey", "Grey", "Light Grey", "White", "Blue",
            "Sky Image", "Sky Geometry", };
    int[] bgValues = { Switch.CHILD_NONE, 0, 1, 2, 3, 4, 5, 6 };

    bgChooser = new IntChooser("Background:", bgNames, bgValues, 0);
    bgChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            bgSwitch.setWhichChild(value);
        }
    });
    bgChooser.setValue(Switch.CHILD_NONE);
}