Exemplo n.º 1
0
      private VisualGroupNode createNode(final int i, boolean useAuto) {
        if (useAuto) {
          newGroups[i] = new VisualGroupNodeAutoEdges(vgn);
        } else {

          newGroups[i] =
              new VisualGroupNode(vgn) {
                @Override
                public void createEdges() {
                  ArrayList<Integer> ns = new ArrayList<Integer>(neighbors(i));
                  ns.add(i);
                  for (int j : ns) {
                    // for (int j : neighbors.get(i)) {
                    VisualNode vj = newGroups[j];
                    EdgeCost ec = superEdgeCost(i, j);
                    if (ec.goodness != 0.0) {
                      // adding edges
                      // System.err.println("ec.goodness = " +
                      // ec.goodness);
                      GroupEdgeUtils.makeGroupEdge((VisualGroupNode) newGroups[i], vj, ec.goodness);
                    }
                  }
                }
              }; // anonymous visualgroupnode end
        }
        VisualGroupNode ret = (VisualGroupNode) newGroups[i];
        for (int j : groups.get(i)) {
          sg.getVisualNode(j).setParent(ret);
          // nodes.get(j
        }
        ret.setName("Compressed Group " + ret.getChildren().size());
        return ret;
      }
Exemplo n.º 2
0
  public void performGrouping(boolean useAuto) {
    final int n = groups.size();

    class GroupClosure {
      VisualNode[] newGroups = new VisualNode[n];

      private VisualGroupNode createNode(final int i, boolean useAuto) {
        if (useAuto) {
          newGroups[i] = new VisualGroupNodeAutoEdges(vgn);
        } else {

          newGroups[i] =
              new VisualGroupNode(vgn) {
                @Override
                public void createEdges() {
                  ArrayList<Integer> ns = new ArrayList<Integer>(neighbors(i));
                  ns.add(i);
                  for (int j : ns) {
                    // for (int j : neighbors.get(i)) {
                    VisualNode vj = newGroups[j];
                    EdgeCost ec = superEdgeCost(i, j);
                    if (ec.goodness != 0.0) {
                      // adding edges
                      // System.err.println("ec.goodness = " +
                      // ec.goodness);
                      GroupEdgeUtils.makeGroupEdge((VisualGroupNode) newGroups[i], vj, ec.goodness);
                    }
                  }
                }
              }; // anonymous visualgroupnode end
        }
        VisualGroupNode ret = (VisualGroupNode) newGroups[i];
        for (int j : groups.get(i)) {
          sg.getVisualNode(j).setParent(ret);
          // nodes.get(j
        }
        ret.setName("Compressed Group " + ret.getChildren().size());
        return ret;
      }
    }
    try {
      vgn.getGraph().disableObservers();
      GroupClosure cl = new GroupClosure();
      for (int i = 0; i < n; i++) {
        int g = i;
        if (groups.get(g).size() > 1) {
          VisualGroupNode nn = cl.createNode(g, useAuto);
        } else if (groups.get(g).size() == 1) {
          cl.newGroups[i] = sg.getVisualNode(i);
        }
      }
    } finally {
      vgn.getGraph().enableObservers();
    }
  }