home *** CD-ROM | disk | FTP | other *** search
- // VRML Generator
- // (c) Justin Couch
- //
- // From Chapter 13: Late Night VRML 2.0 and Java
- //
- // The Group node dialog. Only needs to get the bounding box size
- // and center as well as a DEF name.
-
- package ui.dialogs;
-
- import java.awt.*;
- import ui.dialogs.VrmlBaseDialog;
- import geometry.Box;
- import ui.VrmlTree;
- import VrmlScene;
- import VrmlTypes;
- import exceptions.NoSelectedNodeException;
-
-
- public class BoxDialog extends VrmlBaseDialog
- {
- private TextField size_x, size_y, size_z;
-
- public BoxDialog(Frame parent, VrmlTree tree, VrmlScene data)
- {
- super(parent, "Edit Box Node");
-
- vrml_data = data;
- screen_data = tree;
-
- content_panel.setLayout(new BorderLayout(15, 10));
-
- content_panel.add("West", new Label("Size", Label.LEFT));
-
- Panel p2 = new Panel();
- p2.setLayout(new GridLayout(1, 6));
-
- // the 3 components.
- size_x = new TextField("2", 4);
- size_y = new TextField("2", 4);
- size_z = new TextField("2", 4);
-
- p2.add(new Label("x: ", Label.RIGHT));
- p2.add(size_x);
- p2.add(new Label("y: ", Label.RIGHT));
- p2.add(size_y);
- p2.add(new Label("z: ", Label.RIGHT));
- p2.add(size_z);
-
- content_panel.add("East", p2);
-
- pack();
- }
-
- // read all the information back out of the panel and pass it
- // to the appropriate place.
- public boolean applyInformation()
- {
- String str;
-
- float x, y, z;
-
- Box box;
-
- x = Float.valueOf(size_x.getText()).floatValue();
- y = Float.valueOf(size_y.getText()).floatValue();
- z = Float.valueOf(size_z.getText()).floatValue();
-
- // are we creating a default node? This test for a yes
- if((x != 2) || (y != 2) || (z != 2))
- box = new Box(browser, x, y, z);
- else
- box = new Box(browser);
-
- System.out.println("node is " + box.node);
-
- str = name.getText();
- if(str.equals(""))
- box.name = null;
- else
- box.name = new String(str);
-
- try
- {
- vrml_data.addNode(VrmlTypes.Box, box);
- }
- catch (NoSelectedNodeException e)
- {
- System.out.println("No node selected");
- }
-
- return false;
- }
-
- }