Package lupos.gui.operatorgraph

Examples of lupos.gui.operatorgraph.GraphBox


   * nodes which are connected by an edge. The result
   * will be stored in force.
   */
  private static double computeAttractionForce(GraphWrapper a, GraphWrapper b, OperatorGraph op, Force attraction){
    HashMap<GraphWrapper, GraphBox> boxes = op.getBoxes();
    GraphBox boxA = boxes.get(a); GraphBox boxB = boxes.get(b);
   
    int x = boxA.getX() - boxB.getX(); int y = boxA.getY() - boxB.getY();
   
    // compute distance between a and b
    double distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
   
    // compute unit vector with direction from a to b
View Full Code Here


      }
     
      // set boxes on display
      for (GraphWrapper u : nodes.keySet()) {
       
        GraphBox box = nodes.get(u);
        int x = (int)(box.getX()+((repforces.get(u).getX_Force()>=0)?Math.ceil(SpringEmbedder.DAMPER * repforces.get(u).getX_Force()):Math.floor(SpringEmbedder.DAMPER * repforces.get(u).getX_Force())));
              int y = (int)(box.getY()+((repforces.get(u).getY_Force()>=0)?Math.ceil(SpringEmbedder.DAMPER * repforces.get(u).getY_Force()):Math.floor(SpringEmbedder.DAMPER * repforces.get(u).getY_Force())));
       
        box.setXWithoutUpdatingParentsSize(x);
        box.setYWithoutUpdatingParentsSize(y);
     
       
        box = nodes.get(u);
        x = (int)(box.getX()+((attforces.get(u).getX_Force()>=0)?Math.ceil(SpringEmbedder.DAMPER * attforces.get(u).getX_Force()):Math.floor(SpringEmbedder.DAMPER * attforces.get(u).getX_Force())));
              y = (int)(box.getY()+((attforces.get(u).getY_Force()>=0)?Math.ceil(SpringEmbedder.DAMPER * attforces.get(u).getY_Force()):Math.floor(SpringEmbedder.DAMPER * attforces.get(u).getY_Force())));
       
        box.setXWithoutUpdatingParentsSize(x);
        box.setYWithoutUpdatingParentsSize(y);  
      }
     
      final long time2 = System.currentTimeMillis();
      if(time2-time1>TIMEINTERVAL){ // algo already took too long => abort!
        break;
View Full Code Here

  @Override
  public synchronized void arrange(final Arrange arrange) {
    final GraphWrapper prefixGW = new GraphWrapperPrefixNonEditable(this.prefix);

    if (this.boxes.containsKey(prefixGW)) {
      final GraphBox oldBox = this.boxes.remove(prefixGW);
      this.remove(oldBox.getElement());
    }

    super.arrange(arrange);

    if (this.prefix == null
        || !this.prefix.isActive()
        || (this.rootList.size() > 0 && !this.rootList.get(0).usePrefixesActive())) {
      return;
    }

    final GraphBox prefixBox = this.graphBoxCreator.createGraphBox(this, prefixGW);
    prefixBox.setX(2 * (int) Math.ceil(this.PADDING));
    prefixBox.setY(this.getMaxY()
        + (int) Math.ceil(this.SPACING_Y));
    prefixBox.arrange(arrange);

    this.boxes.put(prefixGW, prefixBox);

    this.updateSize();
  }
View Full Code Here

  private static int infinitSlope(Edge edge, LinkedList<Edge> edges, OperatorGraph op) {
    int crossings = 0;
   
    HashMap<GraphWrapper, GraphBox> boxes = op.getBoxes();
   
    GraphBox source1 = boxes.get(edge.getSource());
    GraphBox target1 = boxes.get(edge.getTarget());
    for (Edge edge2 : edges) {
      GraphBox source2 = boxes.get(edge2.getSource());
      GraphBox target2 = boxes.get(edge2.getTarget());
      if (target2.getX() == source2.getX()) {
        double m = ((double)target2.getY() - (double)source2.getY())/((double)target2.getX() - (double)source2.getX()); // slope of line 2
        double b = target2.getY() - (m * target2.getX()); // crossing with y-axis off line 2
       
        double y = m * source1.getX() + b;
        double minY = Math.min(source1.getY(), target1.getY());
        double maxY = Math.max(source1.getY(), target1.getY());
       
View Full Code Here

  private static int infinitSlope(Edge edge1, Edge edge2, OperatorGraph op) {
    int crossings = 0;
   
    HashMap<GraphWrapper, GraphBox> boxes = op.getBoxes();
   
    GraphBox source1 = boxes.get(edge1.getSource());
    GraphBox target1 = boxes.get(edge1.getTarget());
    GraphBox source2 = boxes.get(edge2.getSource());
    GraphBox target2 = boxes.get(edge2.getTarget());
    if (target2.getX() == source2.getX())  {
      double m = ((double)target2.getY() - (double)source2.getY())/((double)target2.getX() - (double)source2.getX()); // slope of line 2
      double b = target2.getY() - (m * target2.getX()); // crossing with y-axis off line 2
     
      double y = m * source1.getX() + b;
      double minY = Math.min(source1.getY(), target1.getY());
      double maxY = Math.max(source1.getY(), target1.getY());
     
View Full Code Here

    int edgecount = 0;
    LinkedList <Edge> visited = new LinkedList <Edge>();
    for (int i = 0; i < edges.size(); i++/**Edge edge1 : edges**/) {
      Edge edge1 = edges.get(i);
      edgecount ++;
      GraphBox sourceE1 = boxes.get(edge1.getSource());
      GraphBox targetE1 = boxes.get(edge1.getTarget());
      // edge 1 is vertical
      if((targetE1.getX() == sourceE1.getX())) {
        crossCounter = infinitSlope(edge1, edges, graph);
      }
      else
        double m1 = ((double)targetE1.getY() - (double)sourceE1.getY())/((double)targetE1.getX() - (double)sourceE1.getX()); // slope of line 1
        double b1 = (targetE1.getY()) - (m1 * targetE1.getX()); // slope of line 1
        for (int j = 0; j < edges.size(); j++/**Edge edge2 : edges**/) {
          Edge edge2 = edges.get(j);
         
          if ((!edge2.equals(edge1)) && (!visited.contains(edge2)) && (m1 != 0.0)){
            GraphBox sourceE2 = boxes.get(edge2.getSource());
            GraphBox targetE2 = boxes.get(edge2.getTarget());         
            // edge 2 is vertical
            if(targetE2.getX() == sourceE2.getX() ) {
              crossCounter += infinitSlope(edge2, edge1, graph);
             
            } else {
              double m2 = ((double)targetE2.getY() - (double)sourceE2.getY())/((double)targetE2.getX() - (double)sourceE2.getX()); // slope of line 2
              double b2 = (targetE2.getY()) - (m2 * targetE2.getX()); // crossing with y-axis of line 2
              double x = ((b2-b1)/(m1-m2)); double y = ((m1*x) + b1); // cross-point-coordinates of the 2 lines
              double maxXe1 = Math.max(sourceE1.getX(), targetE1.getX()); double maxXe2 = Math.max(sourceE2.getX(), targetE2.getX());
              double minXe1 = Math.min(sourceE1.getX(), targetE1.getX()); double minXe2 = Math.min(sourceE2.getX(), targetE2.getX());
              double maxYe1 = Math.max(sourceE1.getY(), targetE1.getY()); double maxYe2 = Math.max(sourceE2.getY(), targetE2.getY());
              double minYe1 = Math.min(sourceE1.getY(), targetE1.getY()); double minYe2 = Math.min(sourceE2.getY(), targetE2.getY());
             
             
              // test if cross-point is part of edge 1
              if ((x < maxXe1) && (x > minXe1) && (y < maxYe1) && (y > minYe1)) {
                if ((x < maxXe2) && (x > minXe2) && (y < maxYe2) && (y > minYe2)) {
View Full Code Here

   */
  private static double edgeLength(OperatorGraph graph, GraphWrapper a, GraphWrapper b) {
    double length = 0.0;
    HashMap<GraphWrapper, GraphBox> boxes = graph.getBoxes();
   
    GraphBox boxA = boxes.get(a); GraphBox boxB = boxes.get(b);
    double x = boxA.getX()-boxB.getX(); double y = boxA.getY()-boxB.getY();
    length = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
   
    return length;
  }
View Full Code Here

      LinkedList <GraphWrapperIDTuple> childrenTuple = node1.getSucceedingElements();
      LinkedList <GraphWrapper> children = new LinkedList <GraphWrapper>();
      for (GraphWrapperIDTuple child : childrenTuple) {
        children.add(child.getOperator());
      }
      GraphBox box1 = boxes.get(node1);
      for (GraphWrapper node2 : boxes.keySet()) {
        if ((!node2.equals(node1))) {
          GraphBox box2 = boxes.get(node2);
          // compute distance between node1 and node 2
          int x = box2.getX() - box1.getX(); int y = box2.getY() - box1.getY();
          double distance = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
          distances.add(distance);
          avrDist += distance;
        }
      }
View Full Code Here

    box.setX(x);

    // --- update position of subtree - begin ---
    for (final Object o : box.getOp().getSucceedingElements()) {
      final GraphWrapperIDTuple gwIDt = (GraphWrapperIDTuple) o;
      final GraphBox box2 = operatorgraph.getBoxes().get(
          gwIDt.getOperator());
      if (levels.get(box2.getOp()) > level) {
        updateX(operatorgraph, box2, levels, level, box2.getX()
            + offset, visited);
      }
    }
    // --- update position of subtree - end ---
  }
View Full Code Here

    box.setXWithoutUpdatingParentsSize(x);

    // --- update position of subtree - begin ---
    for (final Object o : box.getOp().getSucceedingElements()) {
      final GraphWrapperIDTuple gwIDt = (GraphWrapperIDTuple) o;
      final GraphBox box2 = operatorgraph.getBoxes().get(
          gwIDt.getOperator());
      if (levels.get(box2.getOp()) > level) {
        updateXWithoutUpdatingParentsSize(operatorgraph, box2, levels,
            level, box2.getX() + offset, visited);
      }
    }
    // --- update position of subtree - end ---
  }
View Full Code Here

TOP

Related Classes of lupos.gui.operatorgraph.GraphBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.