示例#1
0
  private void init() {
    panGraph = new StatMxGraph();
    graphComponent = new mxGraphComponent(panGraph);

    add(graphComponent, BorderLayout.CENTER);
    graphParent = panGraph.getDefaultParent();

    // all of these limit user interaction with graph
    panGraph.setAllowDanglingEdges(false);
    panGraph.setCellsDisconnectable(false);
    panGraph.setCellsCloneable(false);
    panGraph.setCellsEditable(false);
    panGraph.setCellsSelectable(true);
    // Default layout
    layout = new mxFastOrganicLayout(panGraph);
    panGraph.setMultigraph(true);
  }
示例#2
0
 private void morphLayout() {
   panGraph.getModel().beginUpdate();
   layout.execute(graphParent);
   panGraph.getModel().endUpdate();
 }
示例#3
0
  public void updateShVertexList(ArrayList<Stakeholder> SHList) {
    // remove all vertices and edges currently graphed
    panGraph.removeCells(panGraph.getChildVertices(panGraph.getDefaultParent()), true);

    // add all stakeholders to the graph first, no edges
    for (Iterator<Stakeholder> iter = SHList.iterator(); iter.hasNext(); ) {
      Stakeholder s = iter.next();
      Object v = new Object();
      if (s.getPlacementRank() > Stakeholder.UNDEFINED) {
        panGraph.getModel().beginUpdate();
        try {
          v =
              panGraph.insertVertex(
                  graphParent,
                  null,
                  s.getName(),
                  100,
                  100,
                  s.getDiameter(),
                  s.getDiameter(),
                  s.getStyle());
        } finally {
          panGraph.getModel().endUpdate();
        }
        s.setGraphNode(v);
      }
      // What to do if a stakeholder is a "non-stakeholder", currently adds nothing to graph
      else {
        //                v = panGraph.insertVertex(graphParent, null, null, 100, 100,
        // s.getDiameter(), s.getDiameter(), s.getStyle());
        //                s.setGraphNode(v);
      }
    }
    // now add all edges
    for (Iterator<Stakeholder> mainShIter = SHList.iterator(); mainShIter.hasNext(); ) {
      Stakeholder main = mainShIter.next();
      for (Iterator<Relationship> it = main.getInfluences().iterator(); it.hasNext(); ) {
        Relationship r = it.next();
        // If the relationship magnitude is zero, don't graph it.
        if (r.getMagnitude() != 0) {
          for (Iterator<Stakeholder> secondaryShIter = SHList.iterator();
              secondaryShIter.hasNext(); ) {
            Stakeholder secondary = secondaryShIter.next();
            if (secondary.getName().equals(r.getName())) {
              //                            System.out.printf("insertEdge(%s,%s,%s)\n",
              // main.getName(), secondary.getName(), r.getLineStyle());
              panGraph.getModel().beginUpdate();
              try {
                panGraph.insertEdge(
                    graphParent,
                    null,
                    null,
                    main.getGraphNode(),
                    secondary.getGraphNode(),
                    r.getLineStyle());
              } finally {
                panGraph.getModel().endUpdate();
              }
            }
          }
        }
      }
    }
    graph();
  }