Esempio n. 1
0
  /**
   * Initializes the <code>ViewAppState</code>.
   *
   * <p><b>Note:</b> If this method is overridden, then the first call from the sub-class should be
   * <code>super.initAppState();</code> in order to properly initialize the default <code>
   * SimpleAppState</code> and <code>ViewAppState</code> features.
   */
  @Override
  protected void initAppState() {
    // Proceed with the default initialize method.
    super.initAppState();

    // If the app should display the axes by default, attach the axes to the
    // scene graph.
    if (getDisplayAxes()) {
      rootNode.attachChild(axes);
    }
    // Create the axes.
    initAxes();

    // If the app should display the HUD by default, attach the guiNode to
    // the Application.
    if (getDisplayHUD()) {
      rootGuiNode.attachChild(guiNode);
    }

    // Attach this view's root node and GUI node to the application's
    // respective nodes.
    this.app.getRootNode().attachChild(rootNode);
    this.app.getGuiNode().attachChild(rootGuiNode);

    return;
  }
Esempio n. 2
0
  /**
   * This method detaches from the {@link #embeddedView} before performing the default stop
   * operation.
   */
  @Override
  public void stop() {

    if (isInitialized()) {
      // If the EmbeddedView exists, we should disconnect from it first so
      // the AwtPanelsContext does not try to update/render this
      // ViewAppState's scene.
      disposeView(embeddedView);
      // Continue with the default stop operation.
      super.stop();
    }

    return;
  }
Esempio n. 3
0
  /**
   * Disconnects the <code>ViewAppState</code> from the associated {@link Application}.
   *
   * <p><b>Note:</b> If this method is overridden, then the first call from the sub-class should be
   * <code>super.cleanupAppState();</code> in order to properly clean up the default <code>
   * SimpleAppState</code> and <code>ViewAppState</code> features.
   */
  @Override
  public void cleanupAppState() {

    // Detach this view's root node and GUI node from the application's
    // respective nodes.
    app.getRootNode().detachChild(rootNode);
    app.getGuiNode().detachChild(rootGuiNode);

    // Un-initialize all of the initialized components of the ViewAppState.
    clearAxes();

    // Unset the reference to the MasterApplication.
    app = null;

    // Proceed with the default cleanup last.
    super.cleanupAppState();
  }
Esempio n. 4
0
  /**
   * Starts the <code>ViewAppState</code> by attaching it to the specified <code>MasterApplication
   * </code>.
   *
   * @param app The jME-based <code>MasterApplication</code> that will be hosting this <code>
   *     ViewAppState</code>.
   */
  public void start(MasterApplication app) {

    // Do not proceed if the AppState is initialized or the parameter is
    // null.
    if (!isInitialized() && app != null) {
      // Set the app and get the next available ID.
      this.app = app;
      this.id = app.getNextId();

      // Update the names of the root and GUI Node in the
      // MasterApplication's scene graph.
      rootNode.setName("root-" + id);
      guiNode.setName("gui-" + id);

      // Now proceed with the normal start procedure.
      super.start(app);
    }

    return;
  }