コード例 #1
0
ファイル: GraphWindow.java プロジェクト: djw1149/cougaar-cui
  private void applyAlgorithm_(GraphAlgorithm alg) {
    if (graph_.numberOfNodes() < 1) new MessageDialog(this, "Error", "Graph is empty.", true);
    else {
      graph_.removeGroups(); // Remove group nodes.
      graph_.pack(); // Pack the indexes.

      String msg;
      graphCanvas_.setWireframe(true);
      msg = alg.compute(graph_, graphCanvas_);
      graphCanvas_.setWireframe(false);

      if (msg != null) new MessageDialog(this, "Message", msg, true);

      graphCanvas_.update(true);
    }
  }
コード例 #2
0
ファイル: GraphWindow.java プロジェクト: djw1149/cougaar-cui
  public boolean handleEvent(Event event) {
    if (event.target instanceof ScrolledPanel) {
      if (event.id == ScrolledPanel.RESIZE)
      // RESIZE event from panel.
      {
        DDimension tmp_dim;

        tmp_dim = viewingPanel_.getPortSize();
        portScroller_.setPortSize(tmp_dim.width, tmp_dim.height);

        tmp_dim = viewingPanel_.getContentSize();
        portScroller_.setContentSize(tmp_dim.width, tmp_dim.height);

        tmp_dim = viewingPanel_.getOffset();
        portScroller_.setOffset(tmp_dim.width, tmp_dim.height);

        return true;
      } else if (event.id == ScrolledPanel.OFFSET) {
        DDimension tmp_dim = viewingPanel_.getOffset();
        portScroller_.setOffset(tmp_dim.width, tmp_dim.height);

        return true;
      }
    } else if (event.target instanceof ViewportScroller) {
      if (event.id == ViewportScroller.SCROLL) {
        graphCanvas_.setWireframe(true);
        viewingPanel_.scrollTo((int) portScroller_.getOffsetX(), (int) portScroller_.getOffsetY());
      }
      if (event.id == ViewportScroller.DONE) {
        graphCanvas_.setWireframe(false);
        viewingPanel_.scrollTo((int) portScroller_.getOffsetX(), (int) portScroller_.getOffsetY());
      }
    } else if (event.target instanceof AngleControlPanel) {
      if (event.id == AngleControlPanel.ANGLE) {
        DPoint angles = (DPoint) event.arg;

        graphCanvas_.setWireframe(true);
        graphCanvas_.setViewAngles(angles.x, angles.y);
      }
      if (event.id == AngleControlPanel.DONE) {
        DPoint angles = (DPoint) event.arg;

        graphCanvas_.setWireframe(false);
        graphCanvas_.setViewAngles(angles.x, angles.y);
      }
    } else if (event.target instanceof GraphCanvas)
    // Graph has changed.
    {
      if (event.id == GraphCanvas.UPDATE) {
        cbmiDirected_.setState(graph_.isDirected());
      }
    }
    // quit from Window Manager menu
    else if (event.id == Event.WINDOW_DESTROY) {
      Destroy();
      return false;
    }

    // call inherited handler
    return super.handleEvent(event);
  }