//
  //  Initialize the GUI (application and applet)
  //
  public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D Light Scoping Example");

    //
    //  Add a menubar menu to change node parameters
    //    Use bounding leaf
    //

    Menu m = new Menu("DirectionalLights");

    light1OnOffMenu = new CheckboxMenuItem("Red light with sphere set 1 scope", light1OnOff);
    light1OnOffMenu.addItemListener(this);
    m.add(light1OnOffMenu);

    light2OnOffMenu = new CheckboxMenuItem("Blue light with sphere set 2 scope", light2OnOff);
    light2OnOffMenu.addItemListener(this);
    m.add(light2OnOffMenu);

    light3OnOffMenu = new CheckboxMenuItem("White light with universal scope", light3OnOff);
    light3OnOffMenu.addItemListener(this);
    m.add(light3OnOffMenu);

    exampleMenuBar.add(m);
  }
Beispiel #2
0
  public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    // Check if it is the coupled background choice
    if (src == coupledBackgroundOnOffMenu) {
      coupledBackgroundOnOff = coupledBackgroundOnOffMenu.getState();
      if (coupledBackgroundOnOff) {
        currentBackgroundColor = currentColor;
        backgroundColorMenu.setCurrent(currentColor);
        Color3f color = (Color3f) colors[currentColor].value;
        background.setColor(color);
        backgroundColorMenu.setEnabled(false);
      } else {
        backgroundColorMenu.setEnabled(true);
      }
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
  }
  //
  //  Handle checkboxes and menu choices
  //
  public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();
    if (src == light1OnOffMenu) {
      light1OnOff = light1OnOffMenu.getState();
      light1.setEnable(light1OnOff);
      return;
    }
    if (src == light2OnOffMenu) {
      light2OnOff = light2OnOffMenu.getState();
      light2.setEnable(light2OnOff);
      return;
    }
    if (src == light3OnOffMenu) {
      light3OnOff = light3OnOffMenu.getState();
      light3.setEnable(light3OnOff);
      return;
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
  }
Beispiel #4
0
  //
  //  Handle checkboxes and menu choices
  //
  public void checkboxChanged(CheckboxMenu menu, int check) {
    if (menu == backgroundColorMenu) {
      // Change the background color
      currentBackgroundColor = check;
      Color3f color = (Color3f) colors[check].value;
      background.setColor(color);
      return;
    }
    if (menu == colorMenu) {
      // Change the fog color
      currentColor = check;
      Color3f color = (Color3f) colors[check].value;
      fog.setColor(color);

      // If background is coupled, set the background color
      if (coupledBackgroundOnOff) {
        currentBackgroundColor = currentColor;
        backgroundColorMenu.setCurrent(check);
        background.setColor(color);
      }
      return;
    }
    if (menu == frontMenu) {
      // Change the fog front distance
      currentFront = check;
      float front = ((Float) fronts[currentFront].value).floatValue();
      fog.setFrontDistance(front);
      return;
    }
    if (menu == backMenu) {
      // Change the fog back distance
      currentBack = check;
      float back = ((Float) backs[currentBack].value).floatValue();
      fog.setBackDistance(back);
      return;
    }

    // Handle all other checkboxes
    super.checkboxChanged(menu, check);
  }
Beispiel #5
0
  //
  //  Initialize the GUI (application and applet)
  //
  public void initialize(String[] args) {
    // Initialize the window, menubar, etc.
    super.initialize(args);
    exampleFrame.setTitle("Java 3D LinearFog Example");

    //
    //  Add a menubar menu to change node parameters
    //    Coupled background color
    //    Background color -->
    //    Fog color -->
    //    Fog front distance -->
    //    Fog back distance -->
    //

    Menu m = new Menu("LinearFog");

    coupledBackgroundOnOffMenu =
        new CheckboxMenuItem("Couple background color", coupledBackgroundOnOff);
    coupledBackgroundOnOffMenu.addItemListener(this);
    m.add(coupledBackgroundOnOffMenu);

    backgroundColorMenu =
        new CheckboxMenu("Background color", colors, currentBackgroundColor, this);
    m.add(backgroundColorMenu);
    backgroundColorMenu.setEnabled(!coupledBackgroundOnOff);

    colorMenu = new CheckboxMenu("Fog color", colors, currentColor, this);
    m.add(colorMenu);

    frontMenu = new CheckboxMenu("Fog front distance", fronts, currentFront, this);
    m.add(frontMenu);

    backMenu = new CheckboxMenu("Fog back distance", backs, currentBack, this);
    m.add(backMenu);

    exampleMenuBar.add(m);
  }