Package net.wigis.graph.dnv.utilities

Examples of net.wigis.graph.dnv.utilities.Vector2D


   */
  @Override
  public void runLayout( DNVGraph graph, int level, String sort )
  {
    List<DNVNode> nodes = graph.getNodes( level );
    Vector2D center = new Vector2D( 0, 0 );

    if( sort.equals( RANDOM_SORT ) )
    {
      Collections.sort( nodes, random );
    }
View Full Code Here


   */
  private static void forceToCircle( List<DNVNode> nodes, Vector2D center, int radius )
  {
    for( DNVNode v : nodes )
    {
      Vector2D newPos = new Vector2D( v.getPosition() );
      newPos.subtract( center );
      newPos.normalize();
      newPos.dotProduct( radius );
      newPos.add( center );
      v.setPosition( newPos );
    }
  }
View Full Code Here

    double radians = startAt + 2.0 * Math.PI / size * i;

    float x_pos = (float)( Math.cos( radians ) * radius );
    float y_pos = (float)( Math.sin( radians ) * radius );

    return new Vector2D( center.getX() + x_pos, center.getY() + y_pos );
  }
View Full Code Here

   * @return the dNV node
   */
  public static DNVNode createParentNode( DNVNode tempNode, Integer newLevel, DNVGraph graph, Map<Integer, Integer> nodeDistance,
      Map<Integer, DNVNode> nodeToParent, Map<Integer, List<DNVNode>> parentToNodes )
  {
    DNVNode newNode = new DNVNode( new Vector2D( tempNode.getPosition() ), graph );
    newNode.setColor( tempNode.getColor() );
    newNode.setLevel( newLevel.intValue() );
    newNode.setFirstChild( tempNode );
    graph.addNode( newLevel, newNode );
    if( multicolor && newLevel == 1 )
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() );
View Full Code Here

//      }

      List<DNVEdge> fromEdges = dnvNode.getFromEdges();
      List<DNVEdge> toEdges = dnvNode.getToEdges();
      // DNVNode tempNeighbor;
      Vector2D tempForce = null;
      Vector2D source = dnvNode.getPosition();

      // Accumulate Spring Force
      // springForceTimer.setStart();
      tempForce = accumulateEdgeForce( graph, dnvNode, level, fromEdges, toEdges, tempForce, source );
      // springForceTimer.setEnd();

      List<DNVNode> allNodes;

      // Accumulate Repelling Force
      // repellingTimer.setStart();

      // if( graphSize > 2 )
      // {
      // if( repellingTimer.getAverageTime( Timer.MILLISECONDS ) > 0.3 &&
      // repellingMethod == REPEL_ALL )
      // toggleRepelMethod();

      if( repellingMethod == REPEL_ALL || level.equals( graph.getMaxLevel() ) )
      {
        // repellingOctreeTimer.setStart();
        // dnvNode.updateRepelledNodes();
        // numberRepelled.add( dnvNode.getRepelledNodes().size() );
        // repellingOctreeTimer.setEnd();
        // allNodes = dnvNode.getRepelledNodes();
        allNodes = graph.getNodes( level );
      }
      else
      {
        // if( repellingMethod == REPEL_SIBLINGS_ONLY )
        allNodes = dnvNode.getSiblings();
      }
     
      tempForce = accumulateRepellingForce( graph, dnvNode, level, tempForce, source, allNodes );
      // }

      // repellingTimer.setEnd();

      Vector2D centerOfGravity = graph.getCenterOfGravity();
      // accumulate force towards center of gravity
      // centerTimer.setStart();
      accumulateForceToCenterOfGravity( dnvNode, tempForce, source, centerOfGravity );
      // centerTimer.setEnd();
View Full Code Here

   *            the center of gravity
   */
  private static void accumulateForceToCenterOfGravity( DNVNode dnvNode, Vector2D tempForce, Vector2D source, Vector2D centerOfGravity )
  {
    if( tempForce == null )
      tempForce = new Vector2D();

    tempForce.setX( centerOfGravity.getX() - source.getX() );
    tempForce.setY( centerOfGravity.getY() - source.getY() );

    tempForce.dotProduct( gravity_intensity * tempForce.length() );
View Full Code Here

  private static Vector2D getRepellingForce( Vector2D target, Vector2D source )
  {
    float dx = source.getX() - target.getX();
    float dy = source.getY() - target.getY();

    Vector2D repellingForce = new Vector2D();
    repellingForce.setX( dx );
    repellingForce.setY( dy );
    float distance = repellingForce.length();

    if( distance < TOLERANCE )
    {
      repellingForce.setX( (float)Math.random() );
      repellingForce.setY( (float)Math.random() );
    }
    else
    {
      float intensity = repelling_intensity / ( distance * distance );
      // Normalize and Multiply by the intensity
      repellingForce.dotProduct( intensity / distance );
    }

    return repellingForce;
  }
View Full Code Here

  private static Vector2D getSpringForce( Vector2D source, Vector2D target, float restingDistance, float k )
  {
    float dx = source.getX() - target.getX();
    float dy = source.getY() - target.getY();

    Vector2D springForce = new Vector2D();
    springForce.setX( dx );
    springForce.setY( dy );
    float distance = springForce.length();
   
    if( distance < TOLERANCE )
    {
      // Set force to 0
      springForce.setX( (float)Math.random() );
      springForce.setY( (float)Math.random() );
    }
    else
    {
      springForce.normalize();
      float delta;
      float intensity;
      delta = distance;// - restingDistance;
      intensity = k * delta;
      springForce.dotProduct( intensity );
    }

    return springForce;
  }
View Full Code Here

      // if( octree == null )
      // octree = new Octree( null );
      // octree.buildTree( bb, 8, graph.getNodes( level ), 2.0f );
      // octreeTimer.setEnd();

      Vector2D centerOfGravity = GraphFunctions.getCenterOfGravity( graph.getNodes( level ).iterator() );
      graph.setCenterOfGravity( centerOfGravity );
      initializeConditions();
    }
  }
View Full Code Here

TOP

Related Classes of net.wigis.graph.dnv.utilities.Vector2D

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.