Package net.wigis.graph.dnv.utilities

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


          value = "getWindowPosition();"; // needed for calculation of
          // label positions
          Collection<DNVNode> nodes = subGraph.getNodes().values();
          HashMap<Integer, Integer> realIdToId = new HashMap<Integer, Integer>();
          DNVNode tempNode = new DNVNode( graph );
          Vector2D position;
          int radius = ImageRenderer.getNodeWidth( getNodeSize(), getMinX(), getMaxX(), 1 );
          int j = 0;
          String imageFile;
          int tempRadius;
          String label;
          for( Iterator<DNVNode> i = nodes.iterator(); i.hasNext(); )
          {
            tempNode = i.next();
            label = tempNode.getLabel( interpolationLabels ).replaceAll( "'", "`" ).replaceAll( "\n", " " ).replaceAll( "\r", " " )
                .trim();
            position = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, getMinX(), getMaxX(), getMinY(),
                getMaxY(), getWidth(), getHeight(), tempNode.getPosition( true ) );
            tempRadius = (int)( radius * tempNode.getRadius() );

            imageFile = ImageRenderer.getURL( tempRadius, tempNode.getIcon(), tempNode.getColor(), showIcons, tempNode.isSelected(),
                tempNode.getId() );
            if( isShowLabels() && isCurvedLabels() )
            {
              imageFile += "&l=" + label + "&ls=" + labelSize + "&sl=" + curvedLabels + "&o=" + outlinedLabels;
            }
            value += "addNode(" + (int)position.getX() + "," + (int)position.getY() + "," + tempRadius + "," + tempNode.getId() + "," + j
                + ",'" + imageFile + "','" + label + "'," + ( showLabels && !curvedLabels ) + "," + tempNode.isSelected() + ");";
            realIdToId.put( tempNode.getId(), j );
            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 );

View Full Code Here


   * @param selectedNode
   *            the selected node
   */
  private void dragNode( DNVNode selectedNode )
  {
    Vector2D worldPos = new Vector2D( selectedNode.getPosition() );
    worldPos.setX( worldPos.getX() + 2 * (float)( globalMaxX - globalMinX ) );
    setSelectedNode( selectedNode, true );
    InterpolationMethod.selectNode( this, graph, (float)numberAffected, level, selectedNode );
    Vector2D screenPos = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, minX, maxX, minY, maxY, width, height,
        worldPos );
    // System.out.println( "Moving node '" + selectedNode.getLabel() +
    // "' to " + screenPos );
    new InterpolationMethod().performInteraction( this, graph, width, height, minX, minY, maxX, maxY, (int)screenPos.getX(), (int)screenPos.getY(), false,
        level, globalMinX, globalMaxX, globalMinY, globalMaxY, selectedNode, false );
    // GraphServlet.moveNode( graph, level, selectedNode, worldPos );
  }
View Full Code Here

 
     
     
      if( allTimes.size() > 0 )
      {
        timeText = new Text( getMinTimeValue() + " - " + getMaxTimeValue(), new Vector2D( width / 2, 12 ), new Vector3D(1,1,1), new Vector3D(0,0,0), 18, true, true, false, false, false, false, true );
      }
      else
      {
        timeText = null;
      }
View Full Code Here

 
     
     
      if( allDKTimes.size() > 0 )
      {
        timeText = new Text( getMinDKTimeValue() + " - " + getMaxDKTimeValue(), new Vector2D( width / 2, 12 ), new Vector3D(1,1,1), new Vector3D(0,0,0), 18, true, true, false, false, false, false, true );
      }
      else
      {
        timeText = null;
      }
View Full Code Here

 
     
     
      if( allTimes.size() > 0 )
      {
        timeText = new Text( getMinTimeValue() + " - " + getMaxTimeValue(), new Vector2D( width / 2, 12 ), new Vector3D(1,1,1), new Vector3D(0,0,0), 18, true, true, false, false, false, false, true );
      }
      else
      {
        timeText = null;
      }
View Full Code Here

 
     
     
      if( allDKTimes.size() > 0 )
      {
        timeText = new Text( getMinDKTimeValue() + " - " + getMaxDKTimeValue(), new Vector2D( width / 2, 12 ), new Vector3D(1,1,1), new Vector3D(0,0,0), 18, true, true, false, false, false, false, true );
      }
      else
      {
        timeText = null;
      }
View Full Code Here

  }

  public boolean doesOverlap( DNVNode node1, DNVNode node2 )
  {
    int nodeWidth = ImageRenderer.getNodeWidth( nodeSize, minX, maxX, 1 );
    Vector2D difference = getScreenPosDifference( node1, node2 );
    float overlap = getOverlapAmount( node1, node2, nodeWidth, difference );

    return overlap > 0;
  }
View Full Code Here

   */
  public Vector2D getOverlapVector( DNVNode node1, DNVNode node2 )
  {
    // refreshGlobalBoundaries( level );
    int nodeWidth = ImageRenderer.getNodeWidth( nodeSize, minX, maxX, 1 );
    Vector2D difference = getScreenPosDifference( node1, node2 );
    float overlap = getOverlapAmount( node1, node2, nodeWidth, difference );
    if( overlap > 0 )
    {
      // System.out.println( node1.getLabel() + " - " + node2.getLabel()
      // );
      // System.out.println( "overlap : " + overlap );
      difference.normalize();
      difference.dotProduct( overlap );
      // System.out.println( "Diff:" + difference );
      // Vector2D overlapV = ImageRenderer.transformScreenToWorld(
      // difference.getX(), difference.getY(), minX, maxX, minY, maxY,
      // globalMinX,
      // globalMaxX, globalMinY, globalMaxY, width, height );
View Full Code Here

   * @param node2
   * @return
   */
  public Vector2D getScreenPosDifference( DNVNode node1, DNVNode node2 )
  {
    Vector2D node1ScreenPos;
    Vector2D node2ScreenPos;
    if( node1.hasAttribute( "screenPosition" ) )
    {
      node1ScreenPos = (Vector2D)node1.getAttribute( "screenPosition" );
    }
    else
    {
      node1ScreenPos = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, minX, maxX, minY, maxY, width, height, node1.getPosition() );
      node1.setAttribute( "screenPosition", node1ScreenPos );
    }
    if( node2.hasAttribute( "screenPosition" ) )
    {
      node2ScreenPos = (Vector2D)node2.getAttribute( "screenPosition" );
    }
    else
    {
      node2ScreenPos = ImageRenderer.transformPosition( globalMinX, globalMaxX, globalMinY, globalMaxY, minX, maxX, minY, maxY, width, height, node2.getPosition() );
      node2.setAttribute( "screenPosition", node2ScreenPos );
    }

    Vector2D difference = new Vector2D( node1ScreenPos ).subtract( node2ScreenPos );
    return difference;
  }
View Full Code Here

  // Computes overlap between two nodes in image space and returns the amount
  // of overlap in image space
  public float getOverlap( DNVNode node1, DNVNode node2 )
  {
    Vector2D v = getOverlapVector( node1, node2 );
    if( v != null )
    {
      return v.length();
    }

    return 0;
  }
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.