Package edu.stanford.hci.flowmap.structure

Examples of edu.stanford.hci.flowmap.structure.Edge


            //System.out.println("n1.outEdges: " + n1.getOutEdges().size());
            double avgX, avgY;
            int count = 0;
            avgX = avgY = 0;
            while (gpIter.hasNext()) {
                Edge e2 = (Edge) gpIter.next();
                Point2D e2Pt = e2.getSecondNode()
                        .getLocation();
                //System.out.println("averaging points: " + e2Pt);
                avgX += e2Pt.getX();
                avgY += e2Pt.getY();
                count++;
            }

            avgX /= count;
            avgY /= count;
            Vector2D gpVec = new Vector2D(n1Pt, new Point2D.Double(avgX, avgY));
            Point2D gpVecNorm = gpVec.getNormalized();
            gpVecNorm.setLocation(-1 * gpVecNorm.getX(), -1 * gpVecNorm.getY());
            grandParent = new Point2D.Double(n1Pt.getX() + 10
                    * gpVecNorm.getX(), n1Pt.getY() + 10 * gpVecNorm.getY());
           

        } else {
            //System.out.println("n2 is not null");
            grandParent = n1.getPrevControlPoint();
            //System.out.println("Prev Control Point for " +
            // ((FlowNode)n1.getEntity()).toStringId() + " has prev control
            // point: " + grandParent);
        }
        //System.out.println("grandparent: " + grandParent);

        // 2. the parent catmull-rom point is n1, since we want it to
        // go through this point
        parent = n1.getLocation();
       
        Point2D shiftPoint = null;
        // additive edge code
        // only shift edges if we are not at the root
        // relies on the fact that there only 2 edges per node
        if (m_additiveEdges && (n1.getRoutingParent() != null)) {

            n2 = n1.getRoutingParent(); //redundant, but who cares
           
            // get the other edge that starts from n1
            Edge otherEdgeItem = null;
            //System.out.println("n1.getOutEdges().size() " + n1.getOutEdges().size());
            for (Edge other: n1.getOutEdges()) {
                if ((otherEdgeItem = other) != edge) break;
            }
            assert(otherEdgeItem != null);
           
//          find the parent edge from n2 to n1
            Edge parentEdgeItem = null;
            for (Edge parent: n2.getOutEdges()) {
                parentEdgeItem = parent;
                if (parentEdgeItem.isIncident(n1) && (parentEdgeItem.isIncident(n2))) {
                    break;               
                }
            }
            assert(parentEdgeItem != null);
           
            Node item1;
            Node item2;
            // get vectors for both edges
            item1 = edge.getFirstNode();
            item2 = edge.getSecondNode();
            Vector2D thisEdgeVec = new Vector2D(item1.getLocation(), item2.getLocation());
           
            item1 = otherEdgeItem.getFirstNode();
            item2 = otherEdgeItem.getSecondNode();
            Vector2D otherEdgeVec = new Vector2D(item1.getLocation(), item2.getLocation());
           
            // now do the cross product of thisEdgeVec
           
//            do not use Vector3d but own implementation that gets rid of this dependency
//            Vector3d thisEdgeVector = new Vector3d(thisEdgeVec.getNormalized().getX(), -1*thisEdgeVec.getNormalized().getY(), 0);
//            Vector3d otherEdgeVector = new Vector3d(otherEdgeVec.getNormalized().getX(), -1*otherEdgeVec.getNormalized().getY(), 0);
//           
//            Vector3d result = new Vector3d();
//
//            result.cross(thisEdgeVector, otherEdgeVector);
            double[] cross = computeCrossProduct(thisEdgeVec.getNormalized().getX(), -1*thisEdgeVec.getNormalized().getY(),
                    otherEdgeVec.getNormalized().getX(), -1*otherEdgeVec.getNormalized().getY());
            //System.out.println("edges: " + parentEdgeItem + ", " + edgeItem + " , " + otherEdgeItem);
            //System.out.println(result);
           
            // compute the perpendicular vector, the direction to shift
            // we will get a vector that points to the right
            Vector2D grandToParent = new Vector2D(grandParent, parent);
            Point2D shiftDir = new Point2D.Double(-grandToParent.getNormalized().getY(),
                    -grandToParent.getNormalized().getX());
           
//            if (result.z < 0) {
            if (cross[2] < 0 ) {
            // if z > 0 then we know that thisEdge is to the right of otherEdge
            // so we push this in the direction of shiftDir

            // else we know that thisEdge is to the left of otherEdge
            // so we push this up, or in the negative direction of shiftDir
                shiftDir.setLocation(shiftDir.getX()*-1, shiftDir.getY()*-1);
            }
           
            double parentWidth = scale.getDisplayWidth(parentEdgeItem.getWeight());
            double otherWidth = scale.getDisplayWidth(otherEdgeItem.getWeight());
            parentWidth = Math.round(parentWidth);
            otherWidth = Math.round(otherWidth);
    /*
            System.out.println("edges: par: " + parentEdgeItem + ", edge:" + edgeItem + " , other:" + otherEdgeItem);
View Full Code Here


   
    // simple node, just add an edge. Shouldn't happen too often
    if ( clus.isNodeCluster()) {
      //System.out.println("SimpleNode case");
      Node clusNode = clus.getRenderedNode();
      Edge e = new Edge(parent, clusNode, clus.getWeight());
     
      parent.addOutEdge(e);
      clusNode.addInEdge(e);
      clusNode.setRoutingParent(parent);
View Full Code Here

        Node newNode = new Node(x, y);
        newNode.setChildCluster(clus);
        clus.setRenderedNode(newNode);   
   
    // update the edge information
    Edge parent2New, new2Big, new2Small;
   
    parent2New = new Edge(parent, newNode, clus.getWeight());
    new2Big = new Edge(newNode, biggerClus.getRenderedNode(), biggerClus.getWeight());
    new2Small = new Edge(newNode, smallerClus.getRenderedNode(), smallerClus.getWeight());
       
    parent.addOutEdge(parent2New);
    newNode.addInEdge(parent2New);
    newNode.addOutEdge(new2Small);
    smallerClus.getRenderedNode().addInEdge(new2Small);
View Full Code Here

      //System.out.println("MixedCluster1: x: " + x + " y:" + y + " "+ newNode);
     
     
      // update the edge information
      Edge parent2New = new Edge(parent, newNode, parentCluster.getWeight());
     
 
      //FlowEdgeItem new2Leaf = FlowEdgeItem.getNewItem(registry,parent, leafCluster.node, leafCluster.weight, null);
 
     
      // dphan. this is a weird error. Shouldn't this be from newNode to Leaf? we have parent to leaf here)
      Edge new2Leaf = new Edge(newNode, leafCluster.getRenderedNode(), leafCluster.getWeight());
   
      //System.out.println("MixedCluster wants to add: p2n " + parent2New);
      //System.out.println("MixedCluster wants to add: n2L " + new2Leaf);
      parent.addOutEdge(parent2New);
      newNode.addInEdge(parent2New);
View Full Code Here

      double y = parentPt.getY()*parentFraction+biggerPt.getY()*bigFraction;
        Node newNode = new Node(x, y);
 
     
      // update the edge information
      Edge parent2New = new Edge(parent, newNode, parentCluster.getWeight());
   
      //System.out.println(parent2New);
      parent.addOutEdge(parent2New);
      newNode.addInEdge(parent2New);
     
View Full Code Here

TOP

Related Classes of edu.stanford.hci.flowmap.structure.Edge

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.