Package net.wigis.graph.dnv

Examples of net.wigis.graph.dnv.DNVEdge


            j++;
          }
          value += "nNodes = " + j + ";";

          Collection<DNVEdge> edges = subGraph.getEdges().values();
          DNVEdge tempEdge;
          DNVNode fromNode;
          DNVNode toNode;
          int fromId;
          int toId;
          j = 0;
          position = new Vector2D( tempNode.getPosition( true ) );
          Vector2D originalPosition = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, getMinX(),
              getMaxX(), getMinY(), getMaxY(), getWidth(), getHeight(), position );
          position.setX( position.getX() + DNVEdge.DEFAULT_RESTING_DISTANCE );
          position = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, getMinX(), getMaxX(), getMinY(),
              getMaxY(), getWidth(), getHeight(), position );

          position = position.subtract( originalPosition );
          // float ratio = position.length() /
          // DNVEdge.DEFAULT_RESTING_DISTANCE;

          // value += "repellingIntensity = " +
          // Springs.getRepelling_intensity() * ratio + ";";
          // value += "springConstant = " + DNVEdge.DEFAULT_K / (ratio
          // *
          // ratio) + ";";
          for( Iterator<DNVEdge> i = edges.iterator(); i.hasNext(); )
          {
            tempEdge = i.next();
            fromNode = tempEdge.getFrom();
            toNode = tempEdge.getTo();
            fromId = realIdToId.get( fromNode.getId() );
            toId = realIdToId.get( toNode.getId() );
            value += "addEdge(" + j + "," + fromId + "," + toId + "," + position.length() + ");";
            j++;
          }
View Full Code Here


          if( selectedNode == null )
          {
            minDistance = Integer.MAX_VALUE;
            List<DNVEdge> edges = graph.getEdges( level );
            DNVEdge edge;
            Vector2D screenPosition2;
            int edgeI = 0;
            for( int i = 0; i < edges.size(); i++ )
            {
              edge = edges.get( i );
              if( edge.isVisible() )
              {
                screenPosition = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, minX, maxX, minY,
                    maxY, width, height, edge.getFrom().getPosition( true ) );
                screenPosition2 = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, minX, maxX, minY,
                    maxY, width, height, edge.getTo().getPosition( true ) );
                distance = getPointLineDistance( screenPosition, screenPosition2, mouseDownX, mouseDownY );
                if( distance < minDistance )
                {
                  minDistance = distance;
                  edgeI = i;
                }
              }
            }

            if( edges.size() > 0 )
            {
              edge = edges.get( edgeI );

              double edgeWidth = Math.max( edge.getThickness(), 4 );
              // check if selected node is close enough to
              // mouseDown
              if( Settings.DEBUG )
                System.out.println( "Minimum distance was " + Math.sqrt( minDistance ) );
              if( Math.sqrt( minDistance ) < edgeWidth / 2.0 )
              {
                if( edge.isSelected() )
                {
                  sameNode = true;
                }
                pb.setSelectedEdge( edge, ctrlPressed );
              }
View Full Code Here

  private Publication generateGraphFromPublicationsArray( Publication p, DNVGraph g, int count )
  {
    Author a = null;
    DNVNode pub = null;
    DNVNode aut = null;
    DNVEdge edge = null;
    Iterator<Publication> iterator = this.searchResults.iterator();
    while( iterator.hasNext() )
    {
      p = iterator.next();

      if( p.selected )
      {
        pub = new DNVNode( g );
        pub.setLabel( p.getTitle() );
        pub.setRadius( PUBLICATION_NODE_RADIUS );
        pub.setPosition( (float)Math.random(), (float)Math.random() );
        pub.setColor( new Vector3D( 0.2f, 0.2f, 0.8f ) );
        g.addNode( 0, pub );

        // iterate for all authors in this result
        Iterator<Author> aiterator = p.getAuthors().iterator();
        aut = null;
        while( aiterator.hasNext() )
        {
          // check if the author already exists in the graph
          a = aiterator.next();
          if( g.getNodeById( a.getId() ) != null )
          {
            aut = (DNVNode)g.getNodeById( a.getId() );
          }
          else
          {
            aut = new DNVNode( g );
            aut.setId( a.getId() );
            aut.setLabel( a.getName() );
            aut.setRadius( AUTHOR_NODE_RADIUS );
            aut.setPosition( (float)Math.random(), (float)Math.random() );
            aut.setColor( new Vector3D( 0.5f, 0.7f, 0.4f ) );
            g.addNode( 0, aut );
          }

          edge = new DNVEdge( 0, DNVEdge.DEFAULT_RESTING_DISTANCE, false, aut, pub, g );
          edge.setId( count );
          g.addNode( 0, edge );
          log( "adding node and title: " + pub.getLabel() + " author: " + aut.getLabel() );
          count++;
        }
      }
View Full Code Here

            for(int j = i + 1; j < neighbors.size(); j++){
              Integer degree1 = neighbors.get(i).getConnectivity();
              Integer degree2 = neighbors.get(j).getConnectivity();             
              Integer leftNodeId, rightNodeId;
              DNVNode leftNode, rightNode;
              DNVEdge leftEdge, rightEdge, middleEdge;
              Tuple<Integer, Integer, Integer> degreeTuple;
              //for each node tuple, the left node degree should be no smaller than the right one
              if(degree1 >= degree2){
                leftNode = neighbors.get(i);
                rightNode = neighbors.get(j);             
                degreeTuple = new Tuple<Integer, Integer, Integer>(degree1, highDegree,degree2);
              }else{
                leftNode = neighbors.get(j);
                rightNode = neighbors.get(i);
                degreeTuple = new Tuple<Integer, Integer, Integer>(degree2, highDegree,degree1);
              }
              leftNodeId = leftNode.getId();
              rightNodeId = rightNode.getId();
              leftEdge = middlenode.getEdgeToNeighbor(leftNodeId);
              rightEdge = middlenode.getEdgeToNeighbor(rightNodeId);
             
              if(!degreeOccurTableDK3.containsKey(degreeTuple)){
                degreeOccurTableDK3.put(degreeTuple, 0)
                degreeUniqueEdgeTableDK3.put(degreeTuple, new HashSet<DNVEdge>());
                degreeUniqueNodeTableDK3.put(degreeTuple, new HashSet<DNVNode>());
              }         
              degreeOccurTableDK3.put(degreeTuple, degreeOccurTableDK3.get(degreeTuple) + 1);
              degreeUniqueEdgeTableDK3.get(degreeTuple).add(leftEdge);
              degreeUniqueEdgeTableDK3.get(degreeTuple).add(rightEdge);
              degreeUniqueNodeTableDK3.get(degreeTuple).add(middlenode);
              degreeUniqueNodeTableDK3.get(degreeTuple).add(leftNode);
              degreeUniqueNodeTableDK3.get(degreeTuple).add(rightNode);
             
              if(leftNode.getNeighbors().contains(rightNode) || rightNode.getNeighbors().contains(leftNode)){
                middleEdge = leftNode.getEdgeToNeighbor(rightNodeId);
                Triangle triangle = new Triangle(leftNode, middlenode, rightNode, leftEdge, middleEdge, rightEdge);
                triangles.add(triangle);
                degreeUniqueEdgeTableDK3.get(degreeTuple).add(middleEdge);
                triangleCnt++;
              }else{
                Line line = new Line(leftNode, middlenode, rightNode, leftEdge, rightEdge);
                lines.add(line);
                lineCnt++;
              }
              cnt++;
            }
          }
        }
       
        if(traveledNodesId.contains(lowDegreeNodeId)){
          continue;
        }
        //next get all the tuple nodes with the lower degree node in the center and the higher degree node at one end
        DNVNode middlenode = graph.getNode(level, lowDegreeNodeId);
        DNVNode leftNode = graph.getNode(level, highDegreeNodeId);
        DNVEdge leftEdge = tuple.getRight();
        DNVEdge rightEdge, middleEdge;
        //get all the neighbors of the lower degree node which haven't been traveled
        ArrayList<DNVNode> neighbors = new ArrayList<DNVNode>();
        for(DNVEdge edge : middlenode.getFromEdges()){
          if(!traveledNodesId.contains(edge.getToId())){
            neighbors.add(graph.getNode(level, edge.getToId()));
View Full Code Here

    DNVNode tempNode;
    float actualDistance;
    int maxDistance = 0;
    int distance;
    float maxActualDistance = 0;
    DNVEdge tempEdge;
    if( maxDepth > 0 )
    {
      while( queue.size() > 0 )
      {
        tempNode = queue.remove( 0 );
        distance = tempNode.getDistanceFromNodeWithId( selectedNode.getId() );
        actualDistance = tempNode.getActualDistanceFromSelectedNode();
        if( actualDistance > maxActualDistance )
        {
          maxActualDistance = actualDistance;
        }

        if( distance > maxDistance )
        {
          maxDistance = distance;
        }

        if( distance < maxDepth )
        {
          // From edges
          edges = tempNode.getFromEdges().iterator();
          while( edges.hasNext() )
          {
            tempEdge = edges.next();
            if( tempEdge.isVisible() )
            {
              addNode( selectedNode, distance + 1, actualDistance + tempEdge.getRestingDistance(), queue, tempEdge.getTo() );
            }
          }

          // To edges
          edges = tempNode.getToEdges().iterator();
          while( edges.hasNext() )
          {
            tempEdge = edges.next();
            if( tempEdge.isVisible() )
            {
              addNode( selectedNode, distance + 1, actualDistance + tempEdge.getRestingDistance(), queue, tempEdge.getFrom() );
            }
          }
        }
      }
    }
View Full Code Here

        //Get the current node's previous node
        DNVNode previousNode = currentNode.getPreviousNode();
        DNVNode nodeVisited = currentNode.getSource();
       
       
        DNVEdge edge = nodeVisited.getEdgeToNeighbor(previousNode.getId());
        edge.setHighlighted(true);
       
       
       
        previousNode.setHighlighted(true);
        previousNode.setLabelColor("#FFFFFF");
View Full Code Here

        for (Pair<DNVNode, DNVNode> pair : added_pairs) {
          DNVNode v1 = pair.getFirst();
          DNVNode v2 = pair.getSecond();
            if (!v1.getNeighbors().contains(v2)){
              DNVEdge edge = new DNVEdge(mGraph);
              edge.setFrom(v1);
              edge.setTo(v2);
                mGraph.addEdge(0, edge);
            }
        }
        // now that we're done attaching edges to this new vertex,
        // add it to the index
View Full Code Here

   */
  private static void addEdge( String[] line, DNVGraph graph, String currentYear, String labelPrefix )
  {
    DNVEntity fromNode = getNode( line, graph, 0, currentYear );
    DNVEntity toNode = getNode( line, graph, 1, currentYear );
    DNVEdge edge = new DNVEdge( graph );
    edge.setFrom( (DNVNode)fromNode );
    edge.setTo( (DNVNode)toNode );
    edge.setLabel( labelPrefix + line[2].trim() );
    String score[] = line[2].trim().split( ":" );
    if( !score[0].equals( score[1] ) )
    {
      edge.setDirectional( true );
      if( !almostWhite( edge.getFrom().getColor() ) )
      {
        edge.setColor( edge.getFrom().getColor() );
      }
      else
      {
        edge.setColor( edge.getFrom().getOutlineColor() );
      }
      edge.setThickness( 3 );
      edge.setLabelColor( edge.getFrom().getLabelColor() );
      edge.setLabelOutlineColor( edge.getFrom().getLabelOutlineColor() );
      edge.getFrom().setRadius( edge.getFrom().getRadius() + 0.02f );
    }
    else
    {
      edge.setDirectional( false );
    }
    edge.setProperty( "time", currentYear );
    graph.addNode( 0, edge );
  }
View Full Code Here

    // Create the edges and set the connections from parent to subnodes
    List<DNVEdge> edgeList;
    ids = parentToNodes.keySet().iterator();
    DNVNode tempParent;
    DNVNode tempParent2;
    DNVEdge tempEdge;
    while( ids.hasNext() )
    {
      tempId = ids.next();
      tempParent2 = (DNVNode)graph.getNodeById( tempId );
      tempList = parentToNodes.get( tempId );
      tempParent2.setSubNodes( tempList );
      for( int i = 0; i < tempList.size(); i++ )
      {
        tempNode = tempList.get( i );
        edgeList = tempNode.getFromEdges();
        for( int j = 0; j < edgeList.size(); j++ )
        {
          tempEdge = edgeList.get( j );
          tempNode2 = tempEdge.getTo();
          tempParent = nodeToParent.get( tempNode2.getId() );
          if( tempParent != null && !tempParent.getId().equals( tempId ) && tempParent != tempParent2 )
          {
            if( !tempParent.getNeighbors().contains( tempParent2 ) )
            {
              tempEdge = new DNVEdge( newLevel.intValue(), DNVEdge.DEFAULT_RESTING_DISTANCE, false, tempParent2, tempParent, graph );
              tempParent2.addFromEdge( tempEdge );
              tempParent.addToEdge( tempEdge );
              graph.addNode( newLevel, tempEdge );
            }
          }
        }

        edgeList = tempNode.getToEdges();
        for( int j = 0; j < edgeList.size(); j++ )
        {
          tempEdge = edgeList.get( j );
          tempNode2 = tempEdge.getFrom();
          tempParent = nodeToParent.get( tempNode2.getId() );

          if( tempParent != null && !tempParent.getId().equals( tempId ) && tempParent != tempParent2 )
          {
            tempParent2 = (DNVNode)graph.getNodeById( tempId );
            if( !tempParent.getNeighbors().contains( tempParent2 ) )
            {
              tempEdge = new DNVEdge( newLevel.intValue(), DNVEdge.DEFAULT_RESTING_DISTANCE, false, tempParent, tempParent2, graph );
              tempParent2.addToEdge( tempEdge );
              tempParent.addFromEdge( tempEdge );
              graph.addNode( newLevel, tempEdge );
            }
          }
View Full Code Here

    }
    for( int i = 0; i < input.length; i++ )
    {
      for( int j = 0; j < i; j++ )
      {
        DNVEdge edge = new DNVEdge( graph );
        DNVNode from = (DNVNode)graph.getNodeByBbId( "" + i );
        DNVNode to = (DNVNode)graph.getNodeByBbId( "" + j );
        edge.setFrom( from );
        edge.setTo( to );
        edge.setLabel( "" + Math.round( 100.0 * input[i][j] ) / 100.0 );
        edge.setRestingDistance( (float)input[i][j] );
        edge.setK( 1 );
        graph.addNode( 0, edge );
      }
    }
    return graph;
  }
View Full Code Here

TOP

Related Classes of net.wigis.graph.dnv.DNVEdge

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.