Beispiel #1
0
    public VertexShapeSizeAspect(Functionality.Graph graphIn) {
      for (int i = 0; i < graphIn.getNodes().size(); i++) {
        if (graphIn.getNodes().get(i).GetRelevance() > maxRelevance
            && graphIn.getNodes().get(i).GetRelevance() < 1.1)
          maxRelevance = graphIn.getNodes().get(i).GetRelevance();
      }

      this.graph = graphIn;
      setSizeTransformer(
          new Transformer<V, Integer>() {

            public Integer transform(V v) {
              if (scale) {
                // return 20;
                double rel = ((Functionality.Node) v).GetRelevance();
                if (rel > 1.1) rel = 1.1;
                int retScale = (int) ((rel / maxRelevance) * 30) + 20;
                if (retScale > 80) {
                  retScale = 80;
                }
                return retScale;
              } else return 20;
            }
          });
      setAspectRatioTransformer(
          new Transformer<V, Float>() {

            public Float transform(V v) {
              return 1.0f;
            }
          });
    }
Beispiel #2
0
  public void CenterGraph(int borderSpacing, boolean _repaint) {
    List<Functionality.Node> ln = myGraph.getNodes();

    double xsum = 0;
    double ysum = 0;

    for (int i = 0; i < ln.size(); i++) {
      xsum += layout.getX(ln.get(i));
      ysum += layout.getY(ln.get(i));
    }

    double xmean = xsum / ln.size();
    double ymean = ysum / ln.size();

    double xcoef = (layout_width - borderSpacing * 2) / (double) layout_width;
    double ycoef = (layout_height - borderSpacing * 2) / (double) layout_height;

    for (int i = 0; i < ln.size(); i++) {
      double xnew = layout.getX(ln.get(i)) + (layout_width / 2 - xmean);
      double ynew = layout.getY(ln.get(i)) + (layout_height / 2 - ymean);

      layout.setLocation(ln.get(i), xnew, ynew);
    }

    for (int i = 0; i < ln.size(); i++) {
      double xnew = borderSpacing + layout.getX(ln.get(i)) * xcoef;
      double ynew = borderSpacing + layout.getY(ln.get(i)) * ycoef;

      layout.setLocation(ln.get(i), xnew, ynew);
    }

    if (_repaint == true) vv.repaint();
  }
Beispiel #3
0
  private void InitializeClusterGraphLayout() {
    int numClusters = myGraph.GetNumberOfClusters();
    double radius = Math.min(layout_width, layout_height) / 3.5;
    double angleShift = (2 * Math.PI) / numClusters;

    List<Functionality.Node> ln = myGraph.getNodes();

    Node n;
    int clusterID;
    for (int i = 0; i < ln.size(); i++) {
      n = ln.get(i);
      clusterID = n.GetCluster();

      if (clusterID == -1) continue;

      double xnew =
          (layout_width / 2)
              + Math.cos(angleShift * clusterID) * radius
              + (50 - Math.random() * 100);
      double ynew =
          (layout_height / 2)
              + Math.sin(angleShift * clusterID) * radius
              + (50 - Math.random() * 100);

      layout.setLocation(n, xnew, ynew);
    }
  }
Beispiel #4
0
  public void init(Functionality.Graph g, int _layout_width, int _layout_height) {
    myGraph = g;
    layout_width = _layout_width;
    layout_height = _layout_height;
    qt = new UndirectedSparseGraph();

    Iterator<Functionality.Node> nodeIterator = g.getNodes().iterator();
    while (nodeIterator.hasNext()) {
      qt.addVertex(nodeIterator.next());
    }

    Iterator<Functionality.Edge> edgeIterator = g.getEdges().iterator();
    while (edgeIterator.hasNext()) {
      Functionality.Edge currEdge = edgeIterator.next();
      qt.addEdge(currEdge, currEdge.getNode1(), currEdge.getNode2());
    }

    vv = null;
    layout = null;
  }