Package net.wigis.graph.dnv.utilities

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


    }
  }

  private static String getKey( DNVNode node, double nodeSize, PaintBean pb )
  {
    Vector2D screenPosition = getScreenPosition( node, pb );

    return "" + (int)Math.round( screenPosition.getX() / nodeSize ) + "," + (int)Math.round( screenPosition.getY() / nodeSize );
  }
View Full Code Here


    return "" + (int)Math.round( screenPosition.getX() / nodeSize ) + "," + (int)Math.round( screenPosition.getY() / nodeSize );
  }

  private static Vector2D getScreenPosition( DNVNode node, PaintBean pb )
  {
    Vector2D screenPos;
    if( node.hasAttribute( "screenPosition" ) )
    {
      screenPos = (Vector2D)node.getAttribute( "screenPosition" );
    }
    else
View Full Code Here

    Timer interpolationTimer = new Timer( Timer.MILLISECONDS );
    interpolationTimer.setStart();
    Map<Integer, DNVNode> selectedNodes = graph.getSelectedNodes( level );

    // transform mouseUp from screen to world (new x = 0)
    Vector2D mouseUpWorld = ImageRenderer.transformScreenToWorld( mouseUpX, mouseUpY, minX, maxX, minY, maxY, globalMinX, globalMaxX, globalMinY, globalMaxY, width, height );

    Vector2D zeroPixels = ImageRenderer.transformScreenToWorld( 0, 0, minX, maxX, minY, maxY, globalMinX, globalMaxX, globalMinY, globalMaxY, width, height );

    Vector2D fivePixels = ImageRenderer.transformScreenToWorld( 5, 5, minX, maxX, minY, maxY, globalMinX, globalMaxX, globalMinY, globalMaxY, width, height );

    fivePixels.subtract( zeroPixels );

    Vector2D movement = new Vector2D( 0, 0 );
    if( selectedNode == null && sameNode )
    {
      selectedNode = pb.getSelectedNode();
    }
View Full Code Here

  public Vector2D performInteraction( PaintBean pb, DNVGraph graph, int width, int height, double minX, double minY, double maxX, double maxY, int mouseUpX, int mouseUpY,
      boolean sameNode, int level, double globalMinX, double globalMaxX, double globalMinY, double globalMaxY, DNVNode selectedNode, boolean released )
  {
    if( selectedNode != null )
    {
      Vector2D mouseUpWorld = ImageRenderer.transformScreenToWorld( mouseUpX, mouseUpY, minX, maxX, minY, maxY, globalMinX, globalMaxX, globalMinY,
          globalMaxY, width, height );
      Vector2D movement = ImageRenderer.getMovement( selectedNode, mouseUpWorld );
      InteractionFunctions.moveNode( selectedNode, movement );
     
      selectedNode.setProperty( "fixed", "true" );
     
      for( int i = 5; i > 0; i-- )
View Full Code Here

{
  @Override
  public Vector2D performInteraction( PaintBean pb, DNVGraph graph, int width, int height, double minX, double minY, double maxX, double maxY, int mouseUpX, int mouseUpY,
      boolean sameNode, int level, double globalMinX, double globalMaxX, double globalMinY, double globalMaxY, DNVNode selectedNode, boolean released )
  {
    Vector2D mouseUpWorld = ImageRenderer.transformScreenToWorld( mouseUpX, mouseUpY, pb.getMinX(), pb.getMaxX(), pb.getMinY(), pb.getMaxY(), pb.getGlobalMinX(), pb.getGlobalMaxX(), pb.getGlobalMinY(),
        pb.getGlobalMaxY(), pb.getWidthInt(), pb.getHeightInt() );
    Vector2D movement = ImageRenderer.getMovement( selectedNode, mouseUpWorld );
    for( DNVNode node : pb.getGraph().getSelectedNodes( (int)pb.getLevel() ).values() )
    {
      if( node != null )
      {
        synchronized( pb.getGraph() )
View Full Code Here

      float kPower2 = k * k;

      // System.out.println( "Temperature : " + temperature + " Level : "
      // + level + " Number of Nodes: " + graph.getGraphSize( level ) );

      Vector2D difference = new Vector2D();
      float length;

      Grid grid = new Grid( k * 2, graph, level );
      List<DNVNode> potentialNodes;

      // float maxYAtDistance1 = Float.NEGATIVE_INFINITY;
      // float minYAtDistance1 = Float.POSITIVE_INFINITY;
      // float tempY;
      // float distance;
      // repulsive forces
      for( DNVNode v : graph.getNodes( level ) )
      {
        v.setForce( 0, 0 );
        potentialNodes = grid.getPotentialNodes( v );
        for( DNVNode u : potentialNodes )
        {
          if( u != v )
          {
            difference.set( v.getPosition() );
            difference.subtract( u.getPosition() );
            length = difference.length();
            if( length == 0 )
            {
              difference.set( (float)Math.random() - 0.5f, (float)Math.random() - 0.5f );
              length = difference.length();
            }
            if( length < k * 2 )
            {
              difference.normalize();
              difference.dotProduct( repel( length, kPower2 * u.getRadius() ) );
              v.getForce().add( difference );
            }
          }
        }
      }

      // attractive forces
      for( DNVEdge e : graph.getEdges( level ) )
      {
        difference.set( e.getFrom().getPosition() );
        difference.subtract( e.getTo().getPosition() );
        length = difference.length();
        difference.normalize();
        difference.dotProduct( attract( length, k ) );
        e.getFrom().getForce().subtract( difference );
        e.getTo().getForce().add( difference );
      }

      // apply the forces
      for( DNVNode v : graph.getNodes( level ) )
      {
        difference.set( v.getForce() );
        length = difference.length();
        difference.normalize();
        difference.dotProduct( Math.min( length, temperature ) );
        v.move( difference, true, false );
        if( counter % 5 == 0 )
        {
          forceToShape( v, center, circle, maxDistance );
        }
View Full Code Here

    float kPower2 = k * k;

    // System.out.println( "Temperature : " + temperature + " Level : " +
    // level + " Number of Nodes: " + graph.getGraphSize( level ) );

    Vector2D difference = new Vector2D();
    float length;

    Grid grid = new Grid( k * 2, nodes );
    List<DNVNode> potentialNodes;

    // repulsive forces
    for( DNVNode v : nodes )
    {
      v.setForce( 0, 0 );
      potentialNodes = grid.getPotentialNodes( v );
      for( DNVNode u : potentialNodes )
      {
        if( u != v )
        {
          difference.set( v.getPosition() );
          difference.subtract( u.getPosition() );
          length = difference.length();
          // If two nodes are in exact same position
          // then we need to do something to move them apart.
          // Give them a small repelling force in random direction.
          if( length == 0 )
          {
            difference.set( (float)Math.random(), (float)Math.random() );
            length = difference.length();
          }
          if( length < k * 2 )
          {
            difference.normalize();
            if( useNodeSize )
            {
              difference.dotProduct( repel( length, kPower2 * u.getRadius() ) );
            }
            else
            {
              difference.dotProduct( repel( length, kPower2 ) );
            }
            if( useNumberOfSubnodes )
            {
              difference.dotProduct( Math.max( u.getSubNodes().size(), 1 ) );
              difference.dotProduct( Math.max( v.getSubNodes().size(), 1 ) );
            }
            v.getForce().add( difference );
          }
        }
      }
    }

    // attractive forces
    for( DNVEdge e : edges )
    {
      difference.set( e.getFrom().getPosition() );
      difference.subtract( e.getTo().getPosition() );
      length = difference.length();
      if( useRestingDistance )
      {
        length = length - e.getRestingDistance();
        length = length * e.getK();
        difference.normalize();
        difference.dotProduct( attract( length, k ) );
      }
      else
      {
        difference.dotProduct( attract( length, k ) );
      }
      if( e.getTo().getType().equals( "topic" ) || !e.getFrom().getType().equals( "topic" ) )
        e.getFrom().getForce().subtract( difference );
      if( !e.getTo().getType().equals( "topic" ) || e.getFrom().getType().equals( "topic" ) )
        e.getTo().getForce().add( difference );
    }
    /*
     * Vector2D center = GraphFunctions.getCenterOfGravity( nodes.iterator()
     * ); for( DNVNode v : nodes ) { difference.set( center );
     * difference.subtract( v.getPosition() ); v.getForce().add( difference
     * ); }
     */
    // apply the forces
    for( DNVNode v : nodes )
    {
      if( v.getProperty( "pinned" ) == null ||  v.getProperty( "pinned" ).equals("false"))
      {
        difference.set( v.getForce() );
        length = difference.length();
        difference.normalize();
        difference.dotProduct( Math.min( length, temperature ) );
        v.move( difference, true, false );
        // v.getPosition().setX( Math.min( width / 2.0f, Math.max(
        // -width / 2.0f, v.getPosition().getX() ) ) );
        // v.getPosition().setY( Math.min( height / 2.0f, Math.max(
        // -height / 2.0f, v.getPosition().getY() ) ) );
View Full Code Here

   * @return the dNV node
   */
  public static DNVNode createParentNode( DNVNode tempNode, Integer newLevel, DNVGraph graph, 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 );
    Vector3D color = new Vector3D( tempNode.getColor() );
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

    DNVNode subNode;
    // float sum = 0;
    float count = 0;
    // float temp;
    // Vector3D tempColor;
    Vector2D tempPosition;
    position = new Vector2D();
    List<DNVNode> subNodes = subGraph.getNodesList();
    for( int i = 0; i < subNodes.size(); i++ )
    {
      subNode = subNodes.get( i );
      // temp = subNode.getTotalNumberOfSubNodes();
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.