/**
   * Create an instance of the panel configured to show or hide the controls and only shows VRML97
   * content.
   *
   * @param showDash true to show the navigation bar
   * @param dashTop true to put the nav bar at the top
   * @param showUrl true to show the URL location bar
   * @param urlTop true to put the location bar at the top
   * @param urlReadOnly true to make the location bar read only
   * @param showConsole true if the console should be shown immediately
   * @param showOpenButton true to put an open button with the URL location bar
   * @param showReloadButton true to put a reload button with the URL location bar
   * @param showStatusBar true to show a status bar
   * @param showFPS true to show the current FPS
   * @param contentDirectory initial directory to load content from. Must be a full path.
   * @param antialiased true to turn on antialiasing
   * @param antialiasingQuality low, medium, high, antialiasing must be turned on for this to
   *     matter.
   * @param primitiveQuality low, medium, high.
   * @param textureQuality low, medium, high.
   * @param skinProperties Customisation of the browser buttons etc
   * @param serverPortNumber The port to listen for incoming data on
   * @throws IOException
   */
  public BrowserJPanel(
      boolean showDash,
      boolean dashTop,
      boolean showUrl,
      boolean urlTop,
      boolean urlReadOnly,
      boolean showConsole,
      boolean showOpenButton,
      boolean showReloadButton,
      boolean showStatusBar,
      boolean showFPS,
      String contentDirectory,
      boolean antialiased,
      String antialiasingQuality,
      String primitiveQuality,
      String textureQuality,
      Properties skinProperties,
      int serverPortNumber)
      throws IOException {

    this(
        showDash,
        dashTop,
        showUrl,
        urlTop,
        urlReadOnly,
        showConsole,
        showOpenButton,
        showReloadButton,
        showStatusBar,
        showFPS,
        contentDirectory,
        antialiased,
        antialiasingQuality,
        primitiveQuality,
        textureQuality,
        skinProperties);

    // And now the three most difficult lines
    ServerSocket s = new ServerSocket(serverPortNumber);
    NetworkBrowserServer browser =
        new NetworkBrowserServer(s, mainCanvas.getUniverse(), browserImpl, clock);
  }
 /**
  * Called to instruct the component instance to destroy itself and any used resources. It will not
  * be used again.
  */
 public void destroy() {
   mainCanvas.setEnabled(false);
   mainCanvas.browserShutdown();
 }
 /**
  * Called to instruct the component instance to stop and suspend its state. The renderer should
  * stop at this point.
  */
 public void stop() {
   mainCanvas.setEnabled(false);
 }
 /** Called to instruct the component instance to start rendering now. */
 public void start() {
   mainCanvas.setEnabled(true);
 }
 /**
  * Set the minimum frame interval time to limit the CPU resources taken up by the 3D renderer. By
  * default it will use all of them. The second parameter is used to control whether this is a
  * user-set hard minimum or something set by the browser internals. User set values are always
  * treated as the minimum unless the browser internals set a value that is a slower framerate than
  * the user set. If the browser then sets a faster framerate than the user set value, the user
  * value is used instead.
  *
  * @param millis The minimum time in milleseconds.
  * @param userSet true if this is an end-user set minimum
  */
 public void setMinimumFrameInterval(int millis, boolean userSet) {
   mainCanvas.setMinimumFrameInterval(millis, userSet);
 }
 /**
  * Invoked when the component has been made visible.
  *
  * @param evt The event
  */
 public void componentShown(ComponentEvent evt) {
   if (frameCycleTime < 0) mainCanvas.setMinimumFrameInterval(0, false);
   else mainCanvas.setMinimumFrameInterval(frameCycleTime, false);
 }
 /**
  * Invoked when the component has been made invisible.
  *
  * @param evt The event
  */
 public void componentHidden(ComponentEvent evt) {
   mainCanvas.setMinimumFrameInterval(1000 / PAUSED_FPS, false);
 }
 /**
  * Invoked when a window is changed from a normal state to minimzed.
  *
  * @param evt The window event that caused the method to be called.
  */
 public void windowIconified(WindowEvent evt) {
   mainCanvas.setMinimumFrameInterval(1000 / PAUSED_FPS, false);
 }
  /**
   * Invoked when a window is changed from a minimized to a normal state.
   *
   * @param evt The window event that caused the method to be called.
   */
  public void windowDeiconified(WindowEvent evt) {
    if (frameMillis < 0) mainCanvas.setMinimumFrameInterval(0, false);
    else mainCanvas.setMinimumFrameInterval(frameMillis, false);

    j3dCanvas.requestFocusInWindow();
  }
示例#10
0
  /**
   * Create an instance of the panel configured to show or hide the controls and only shows VRML97
   * content.
   *
   * @param showDash true to show the navigation bar
   * @param dashTop true to put the nav bar at the top
   * @param showUrl true to show the URL location bar
   * @param urlTop true to put the location bar at the top
   * @param urlReadOnly true to make the location bar read only
   * @param showConsole true if the console should be shown immediately
   * @param skinProperties The properties object to configure appearance with
   * @param showStatusBar true to show a status bar
   * @param showFPS true to show the current FPS
   * @param contentDirectory initial directory to load content from. Must be a full path.
   * @param antialiased true to turn on antialiasing
   * @param antialiasingQuality low, medium, high, antialiasing must be turned on for this to
   *     matter.
   * @param primitiveQuality low, medium, high.
   * @param textureQuality low, medium, high.
   * @param skinProperties Customisation of the browser buttons etc
   */
  public BrowserJPanel(
      boolean showDash,
      boolean dashTop,
      boolean showUrl,
      boolean urlTop,
      boolean urlReadOnly,
      boolean showConsole,
      boolean showOpenButton,
      boolean showReloadButton,
      boolean showStatusBar,
      boolean showFPS,
      String contentDirectory,
      boolean antialiased,
      String antialiasingQuality,
      String primitiveQuality,
      String textureQuality,
      Properties skinProperties) {

    super(new BorderLayout());

    setSize(800, 600);

    numSamples = 1;
    frameCycleTime = -1;
    wireframe = false;
    elumensMode = false;

    // JC: Copied from the OpenGL code, so does nothing right now.
    if (antialiased) {
      if (antialiasingQuality.equals("low")) {
        numSamples = 2;
        //                caps.setNumSamples(numSamples);
      } else if (antialiasingQuality.equals("medium")) {
        // TODO: Really need to find the max allowable.  But JOGL startup issues make this a problem
        System.out.println("Trying for 4 samples of antialiasing.");
        numSamples = 4;
        //                caps.setNumSamples(numSamples);
      } else if (antialiasingQuality.equals("high")) {
        System.out.println("Trying for 8 samples of antialiasing.");
        numSamples = 8;
        //                caps.setNumSamples(numSamples);
      }
    }

    console = new SwingConsoleWindow();
    console.messageReport("Initializing Java3D VRML browser.\n");

    addComponentListener(this);

    // We also need a canvas to display stuff with and a universe to set
    // the content in.
    GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
    template.setDoubleBuffer(GraphicsConfigTemplate3D.REQUIRED);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();

    GraphicsConfiguration gfx_cfg = dev.getBestConfiguration(template);

    mainCanvas = new VRMLBrowserCanvas(gfx_cfg, true);
    mainCanvas.initialize();
    mainCanvas.setErrorReporter(console);

    j3dCanvas = mainCanvas;

    CursorManager cm = new CursorManager(mainCanvas, skinProperties, console);

    universe = mainCanvas.getUniverse();
    universe.addSensorStatusListener(cm);
    universe.addNavigationStateListener(cm);

    vpManager = mainCanvas.getViewpointManager();

    setupProperties(textureQuality);

    eaiBrowser = new EAIBrowser(universe, browserImpl, eventQueue, console);

    add(mainCanvas, BorderLayout.CENTER);

    // Create these all the time
    statusLabel = new JLabel();
    fpsLabel = new JLabel();
    SwingLocationToolbar tb = null;

    if (showUrl) {
      tb =
          new SwingLocationToolbar(
              universe,
              mainCanvas.getWorldLoaderManager(),
              urlReadOnly,
              showOpenButton,
              showReloadButton,
              contentDirectory,
              skinProperties,
              console);

      if (urlTop) add(tb, BorderLayout.NORTH);
      else add(tb, BorderLayout.SOUTH);
    }

    // Need to fix this as this panel will trash the existing one if they are
    // both at the top or bottom.

    if (showDash) {
      JPanel p2 = new JPanel(new BorderLayout());

      if (dashTop) add(p2, BorderLayout.NORTH);
      else add(p2, BorderLayout.SOUTH);

      navToolbar = new SwingNavigationToolbar(universe, skinProperties, console);
      // navToolbar.setAllowUserStateChange(true);
      SwingViewpointToolbar vp_tb =
          new SwingViewpointToolbar(universe, vpManager, skinProperties, console);

      SwingConsoleButton console_button = new SwingConsoleButton(console, skinProperties);

      p2.add(navToolbar, BorderLayout.WEST);
      p2.add(vp_tb, BorderLayout.CENTER);
      p2.add(console_button, BorderLayout.EAST);

      if (showFPS || showStatusBar) {
        statusBar = new SwingStatusBar(universe, showStatusBar, showFFS, skinProperties, console);

        if (tb != null) {
          tb.setProgressListener(statusBar.getProgressListener());
        }

        p2.add(statusBar, BorderLayout.SOUTH);
      }
    }

    if (showConsole) console.setVisible(true);
  }