Package net.wigis.graph.dnv

Examples of net.wigis.graph.dnv.DNVNode


   * @param nodes
   *            the nodes
   */
  public static void applyForces( Iterator<DNVNode> nodes )
  {
    DNVNode tempDNV;
    // float tempDiff;
    while( nodes.hasNext() )
    {
      tempDNV = nodes.next();
      forceStrength.add( tempDNV.getForce() );
      if( !tempDNV.hasProperty( "pinned" ) )
      {
        tempDNV.applyForce( 0.7f, true );
      }
    }
  }
View Full Code Here


   * @param level
   *            the level
   */
  public static void accumulateForces( DNVGraph graph, Iterator<DNVNode> nodes, int level )
  {
    DNVNode tempDNV;
    while( nodes.hasNext() )
    {
      tempDNV = nodes.next();
      accumulateForce( graph, tempDNV, level );
    }
View Full Code Here

   * @return the vector2 d
   */
  private static Vector2D accumulateRepellingForce( DNVGraph graph, DNVNode dnvNode, Integer level, Vector2D tempForce, Vector2D source,
      List<DNVNode> allNodes )
  {
    DNVNode tempNode;
    for( int i = 0; i < allNodes.size(); i++ )
    {
      tempNode = allNodes.get( i );
      if( tempNode != dnvNode /* && !tempNode.isAnchor() */)
      {
        tempForce = getRepellingForce( tempNode.getPosition(), source );
        tempForce.dotProduct( tempNode.getMass() );
        if( tempForce.length() > MIN_STRENGTH && tempNode.canRevive() )
          graph.setNodeActive( level, tempNode.getId(), tempNode );
        dnvNode.addForce( tempForce );
      }
    }
    return tempForce;
  }
View Full Code Here

      }
    }

    Map<Integer, DNVNode> nodeToParent = new HashMap<Integer, DNVNode>();
    Map<Integer, List<DNVNode>> parentToNode = new HashMap<Integer, List<DNVNode>>();
    DNVNode newNode;
    Vector2D position;
    Vector3D color;
    for( String neighborListId : nodesByNeighborlist.keySet() )
    {
      tempList = nodesByNeighborlist.get( neighborListId );
      position = new Vector2D( 0, 0 );
      color = new Vector3D( 0, 0, 0 );
      if( tempList != null && tempList.size() > 0 )
      {
        newNode = new DNVNode( graph );
        newNode.setFirstChild( tempList.get( 0 ) );
        newNode.setSubNodes( tempList );
        graph.addNode( currentLevel + 1, newNode );
        parentToNode.put( newNode.getId(), tempList );
        for( DNVNode childNode : tempList )
        {
          nodeToParent.put( childNode.getId(), newNode );
          position.add( childNode.getPosition() );
          color.add( childNode.getColor() );
          childNode.setParentNode( newNode );
        }
        position.dotProduct( 1.0f / (float)tempList.size() );
        color.dotProduct( 1.0f / (float)tempList.size() );
        if( tempList.size() == 1 )
        {
          newNode.setLabel( tempList.get( 0 ).getLabel() );
          newNode.setIcon( tempList.get( 0 ).getIcon() );
          newNode.setLabelColor( tempList.get( 0 ).getLabelColor() );
          newNode.setLabelOutlineColor( tempList.get( 0 ).getLabelOutlineColor() );
          newNode.setForceLabel( tempList.get( 0 ).isForceLabel() );
        }
        else
        {
          newNode.setLabel( "" + tempList.size() );
        }
        newNode.setColor( color );
        newNode.setPosition( position );
      }
    }

    for( DNVNode tempNode : currentNodes )
    {
      DNVNode parentNode = tempNode.getParentNode();
      DNVNode parentNode2;
      // DNVEdge newEdge;
      DNVNode tempNode2;
      List<DNVEdge> edgeList = tempNode.getFromEdges();
      for( DNVEdge tempEdge : edgeList )
      {
        tempNode2 = tempEdge.getTo();
        parentNode2 = tempNode2.getParentNode();
        if( parentNode2 != null && !parentNode2.getId().equals( parentNode.getId() ) && parentNode != parentNode2 )
        {
          if( !parentNode.isNeighbor( parentNode2 ) )
          {
            createEdge( graph, currentLevel, parentNode, parentNode2, tempEdge );
          }
        }
      }

      edgeList = tempNode.getToEdges();
      for( DNVEdge tempEdge : edgeList )
      {
        tempNode2 = tempEdge.getFrom();
        parentNode2 = tempNode2.getParentNode();
        if( parentNode2 != null && !parentNode2.getId().equals( parentNode.getId() ) && parentNode != parentNode2 )
        {
          if( !parentNode.isNeighbor( parentNode2 ) )
          {
            createEdge( graph, currentLevel, parentNode2, parentNode, tempEdge );
View Full Code Here

   * @return the vector2 d
   */
  private static Vector2D accumulateEdgeForce( DNVGraph graph, DNVNode dnvNode, Integer level, List<DNVEdge> fromEdges, List<DNVEdge> toEdges,
      Vector2D tempForce, Vector2D source )
  {
    DNVNode tempNeighbor;
    DNVEdge tempEdge;
    for( int i = 0; i < fromEdges.size(); i++ )
    {
      tempEdge = fromEdges.get( i );
      tempNeighbor = tempEdge.getTo();
      tempForce = getSpringForce( tempNeighbor.getPosition(), source, tempEdge.getRestingDistance(), tempEdge.getK() );
      if( tempForce.length() > MIN_SPRING_STRENGTH && tempNeighbor.canRevive() )
        graph.setNodeActive( level, tempNeighbor.getId(), tempNeighbor );
      dnvNode.addForce( tempForce );
    }

    for( int i = 0; i < toEdges.size(); i++ )
    {
      tempEdge = toEdges.get( i );
      tempNeighbor = tempEdge.getFrom();
      tempForce = getSpringForce( tempNeighbor.getPosition(), source, tempEdge.getRestingDistance(), tempEdge.getK() );
      if( tempForce.length() > MIN_SPRING_STRENGTH && tempNeighbor.canRevive() )
        graph.setNodeActive( level, tempNeighbor.getId(), tempNeighbor );
      dnvNode.addForce( tempForce );
    }
    return tempForce;
  }
View Full Code Here

    String line;
    String from;
    String to;

    DNVGraph graph = new DNVGraph();
    DNVNode fromNode;
    DNVNode toNode;
    DNVEdge edge;

    while( ( line = br.readLine() ) != null )
    {
      if( line.indexOf( "->" ) != -1 )
View Full Code Here

        Object key = degreeOrderedListDK2.get(0);
        degreeOrderedListDK2.remove(0);
       
        ArrayList<Tuple<Integer, Integer, DNVEdge>> nodeEdgeIndex = degreeNodeEdgeIndexTableDK2.get(key);
        for(Tuple<Integer, Integer, DNVEdge> tuple : nodeEdgeIndex){
          DNVNode node1 = graph.getNode(0, tuple.getLeft());
          impNodes.add(node1);
          DNVNode node2 = graph.getNode(0, tuple.getMiddle());
          nodes.add(node1);
          nodes.add(node2);         
          //nodes.add(node2);
          DNVEdge edge = tuple.getRight();
          edges.add(edge);   
View Full Code Here

  private static DNVEntity getNode( String bbid, DNVGraph graph )
  {
    DNVEntity node = graph.getNodeByBbId( bbid );
    if( node == null )
    {
      node = new DNVNode( graph );
      node.setLabel( bbid );
      node.setBbId( bbid );
      ( (DNVNode)node ).setPosition( (float)( Math.random() * 100.0 ), (float)( Math.random() * 100.0 ) );
      graph.addNode( 0, node );
    }
View Full Code Here

    makeLetter( graph, nodeColor, "i1_dot", i1_dotPositions );
    makeLetter( graph, nodeColor, "i2", i2Positions );
    makeLetter( graph, nodeColor, "i2_dot", i2_dotPositions );
    makeLetter( graph, nodeColor, "s", sPositions );
    List<DNVNode> nodes = generateSeries( graph, 7, nodeColor, "G" );
    DNVNode node = addNode( graph, nodeColor, "G", nodes );
    addEdge( graph, "G", nodes.get( 5 ), node );
    applyPositions( gPositions, nodes );
   
    graph.writeGraph( Settings.GRAPHS_PATH + "WiGis.dnv" );
  }
View Full Code Here

   * @param graph
   * @param length
   */
  private static List<DNVNode> generateSeries( DNVGraph graph, int length, String nodeColor, String type )
  {
    DNVNode previousNode = null;
    List<DNVNode> list = new ArrayList<DNVNode>();
    for( int i = 0; i < length; i++ )
    {
      DNVNode node = addNode( graph, nodeColor, type, list );
      if( previousNode != null )
      {
        addEdge( graph, type, previousNode, node );
      }
     
View Full Code Here

TOP

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

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.