home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch12 / ui / dialogs / BoxDialog.bak < prev    next >
Text File  |  1997-01-05  |  2KB  |  95 lines

  1. // VRML Generator
  2. // (c) Justin Couch
  3. //
  4. // From Chapter 13: Late Night VRML 2.0 and Java
  5. //
  6. // The Group node dialog. Only needs to get the bounding box size
  7. // and center as well as a DEF name.
  8.  
  9. package ui.dialogs;
  10.  
  11. import java.awt.*;
  12. import ui.dialogs.VrmlBaseDialog;
  13. import geometry.Box;
  14. import ui.VrmlTree;
  15. import VrmlScene;
  16. import VrmlTypes;
  17. import exceptions.NoSelectedNodeException;
  18.  
  19.  
  20. public class BoxDialog extends VrmlBaseDialog
  21. {
  22.     private TextField    size_x, size_y, size_z;
  23.  
  24.     public BoxDialog(Frame parent, VrmlTree tree, VrmlScene data)
  25.     {
  26.         super(parent, "Edit Box Node");
  27.  
  28.         vrml_data = data;
  29.         screen_data = tree;
  30.  
  31.         content_panel.setLayout(new BorderLayout(15, 10));
  32.  
  33.         content_panel.add("West", new Label("Size", Label.LEFT));
  34.  
  35.         Panel p2 = new Panel();
  36.         p2.setLayout(new GridLayout(1, 6));
  37.  
  38.         // the 3 components.
  39.         size_x = new TextField("2", 4);
  40.         size_y = new TextField("2", 4);
  41.         size_z = new TextField("2", 4);
  42.  
  43.         p2.add(new Label("x: ", Label.RIGHT));
  44.         p2.add(size_x);
  45.         p2.add(new Label("y: ", Label.RIGHT));
  46.         p2.add(size_y);
  47.         p2.add(new Label("z: ", Label.RIGHT));
  48.         p2.add(size_z);
  49.  
  50.         content_panel.add("East", p2);
  51.  
  52.         pack();
  53.     }
  54.  
  55.     // read all the information back out of the panel and pass it
  56.     // to the appropriate place.
  57.     public boolean applyInformation()
  58.     {
  59.         String str;
  60.  
  61.         float x, y, z;
  62.  
  63.         Box box;
  64.  
  65.         x = Float.valueOf(size_x.getText()).floatValue();
  66.         y = Float.valueOf(size_y.getText()).floatValue();
  67.         z = Float.valueOf(size_z.getText()).floatValue();
  68.  
  69.         // are we creating a default node? This test for a yes
  70.         if((x != 2) || (y != 2) || (z != 2))
  71.             box = new Box(browser, x, y, z);
  72.         else
  73.             box = new Box(browser);
  74.  
  75.         System.out.println("node is " + box.node);
  76.         
  77.         str = name.getText();
  78.         if(str.equals(""))
  79.             box.name = null;
  80.         else
  81.             box.name = new String(str);
  82.  
  83.         try
  84.         {
  85.             vrml_data.addNode(VrmlTypes.Box, box);
  86.         }
  87.         catch (NoSelectedNodeException e)
  88.         {
  89.             System.out.println("No node selected");
  90.         }
  91.  
  92.         return false;
  93.     }
  94.  
  95. }