コード例 #1
0
  // must be called on AWT event thread
  private void setWindowVisible(boolean visible) {
    if (visible) {
      if (entity != null) {
        throw new IllegalStateException("Entity already created");
      }

      // create the image
      Canvas canvas = JmeClientMain.getFrame().getCanvas();

      synchronized (this) {
        entity = new StereoViewEntity(canvas.getWidth(), canvas.getHeight());
        frame = new StereoViewFrame(createImage(entity, canvas.getWidth(), canvas.getHeight()));
      }

      entity.setDistance(getDistance());
      entity.setAngle(getAngle());
      entity.setEnabled(true);

      frame.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
              LOGGER.warning("Stereo window closing");

              // uncheck the checkbox, which should also dispose of
              // the frame
              if (stereoMI != null) {
                stereoMI.setSelected(false);
              }

              if (entity != null) {
                setWindowVisible(false);
              }
            }
          });

      frame.setSize(JmeClientMain.getFrame().getFrame().getSize());
      frame.setVisible(true);
    } else {
      if (entity == null) {
        // already disposed
        return;
      }

      frame.dispose();
      entity.dispose();

      synchronized (this) {
        frame = null;
        entity = null;
      }
    }
  }
コード例 #2
0
  synchronized void setAngle(float angle) {
    this.angle = angle;

    if (entity != null) {
      entity.setAngle(angle);
    }
  }
コード例 #3
0
  synchronized void setDistance(float dist) {
    this.dist = dist;

    if (entity != null) {
      entity.setDistance(dist);
    }
  }