Package java.awt.geom

Examples of java.awt.geom.Point2D$Double


  Node findNearestNode(Point2D mp, boolean bPrint) {
    double minDist = 20;

    if(currentNode != null && currentLinkMap != null && currentLinkMap.size() == 0) {
      Point2D p1 = currentNode.getPoint();
      if(p1 != null) {
        double d = mp.distance(p1);
        if(d <= minDist) {
          return currentNode;
        }
      }
    }

    // Map linkMap = new HashMap();
    // layoutNode(currentNode, linkMap);
    Map linkMap = currentLinkMap != null ? currentLinkMap : Collections.EMPTY_MAP;
   
    Node minNode = null;
    for(Iterator it = linkMap.keySet().iterator(); it.hasNext(); ) {
      Link link = (Link)it.next();
      Node n1 = link.getFrom();
      Node n2 = link.getTo();
     
      Point2D p1 = n1.getPoint();
      if(p1 != null) {
        double d = mp.distance(p1);
        if(d <= minDist) {
          minDist = d;
          minNode = n1;
        }
      }
      Point2D p2 = n2.getPoint();
      if(p2 != null) {
        double d = mp.distance(p2);
        if(d <= minDist) {
          minDist = d;
          minNode = n2;
View Full Code Here


   
   
  }
 
  String toString(Object o) {
    Point2D p = (Point2D)o;
    return p != null
      ? ("[" + (int)p.getX() + ", " + (int)p.getY() + "]")
      : "null";
  }
View Full Code Here

  void updateFade(Map linkMap, Map oldPos, Map newPos, double k) {
   
    for(Iterator it = linkMap.keySet().iterator(); it.hasNext(); ) {
      Link link = (Link)it.next();
      Node node;
      Point2D p1;
      Point2D p2;
     
      node = link.getFrom();
      p1 = (Point2D)oldPos.get(node);
      p2 = (Point2D)newPos.get(node);
      node.setPoint(fade(k, p1, p2, center));
View Full Code Here

      currentLinkMap.clear();
      layoutNode(currentNode, currentLinkMap);
      bNeedLayout = false;
    }
   
    Point2D center = getCenter();

    if(isOpaque()) {
      g.setColor(getBackground());
      g.fillRect(0, 0, size.width, size.height);

     
      float y0 = (float)(0.8 * center.getY());
      float y1 = (float)(size.height);
      GradientPaint painter = new GradientPaint(0.0f, y0,
                                                topColor,
                                                0.0f, y1,
                                                bottomColor);
View Full Code Here

  Map darkColors = new HashMap();
  Set paintedNodes = new HashSet();
 
  void paintLinkMap(Graphics2D g, Map linkMap) {
    paintedNodes.clear();
    Point2D center = getCenter();   
    if(linkMap == null) {
      return;
    }
   
    g.setColor(linkColor);
    Util.setAntialias(g, true);
   
    // paint links
    for(Iterator it = linkMap.keySet().iterator(); it.hasNext(); ) {
      Link link = (Link)it.next();
      Color c1 = fillColor;
      Color c2 = lineColor;
      if(link instanceof DefaultLink) {
        DefaultLink dl = (DefaultLink)link;
        c1 = dl.getColor();
        c2 = (Color)darkColors.get(c1);
        if(c2 == null) {
          c2 = Util.rgbInterpolate(c1, Color.black, .5);
          darkColors.put(c1, c2);
        }
      }
      if(link.getType() < 0) {
        c2 = null;
      }

      paintLink(g, link, c1, c2, true);
    }


    // paint link mirror image
    if(fadestate != STATE_FADE) {
      Composite oldComp = g.getComposite();
      AffineTransform oldTrans = g.getTransform();
      g.scale(1.0, -.5);
      g.translate(center.getY()*.5, -3.1*center.getY());
      g.shear(-0.5, 0);
      g.setComposite(alphaSome);
      int n = 0;
      int n2 = 0;
      Color c1 = Util.rgbInterpolate(bottomColor, Color.black, .1);
View Full Code Here

    Dimension size = getSize();
    Node n1 = link.getFrom();
    Node n2 = link.getTo();
   
   
    Point2D p1 = n1.getPoint();
    Point2D p2 = n2.getPoint();
   
    if(p1 != null && p2 != null) {
      Color c1 = Color.white;
      Color c2 = Color.black;
     
      double cx = (p1.getX() + p2.getX()) / 2;
      double cy = (p1.getY() + p2.getY()) / 2;
     
      // double mx = cx - mousePoint.getX();
      // double my = cy - mousePoint.getY();
      // double dist = Math.sqrt(mx * mx + my * my);
     
View Full Code Here

  void paintLink(Graphics2D g, Link link, Color fillColor, Color lineColor, boolean bFind) {
    Node n1 = link.getFrom();
    Node n2 = link.getTo();
   
    Point2D p1 = n1.getPoint();
    Point2D p2 = n2.getPoint();
   
    if(false && n2.equals(currentNode)) {
      drawLine(g,
               link,
               (int)p1.getX(),
               (int)p1.getY(),
               (int)p2.getX(),
               (int)p2.getY(),
               fillColor,
               fadestate == STATE_FADE ? null : lineColor,
               bFind);
    } else {
      if(p1 != null && p2 != null) {
        Stroke oldStroke = g.getStroke();
       
        double k = 1.0 / (1 + link.getDepth());
        g.setStroke(new BasicStroke((float)k));
        drawArrow(g, 
                  link,
                  (int)p1.getX(),
                  (int)p1.getY(),
                  (int)p2.getX(),
                  (int)p2.getY(),
                  fillColor,
                  lineColor,
                  bFind);
       
       
View Full Code Here

  @Override
  protected void onDragStart(Point point) {
    ignoreClick = false;
    // Find the entity under the starting point
    final Point2D location = screen.convertScreenViewToWorld(point);
    final EntityView view = screen.getMovableEntityViewAt(location.getX(),
        location.getY());

    if (view != null) {
      // Let the DragLayer handle the drawing and dropping.
      DragLayer.get().startDrag(view.getEntity());
    }
View Full Code Here

    final RemovableSprite text = screen.getTextAt(point.x, point.y);
    if (text != null) {
      return StendhalCursor.NORMAL;
    }

    Point2D point2 = screen.convertScreenViewToWorld(point);

    // is the cursor aiming at an entity?
    final EntityView view = screen.getEntityViewAt(point2.getX(), point2.getY());
    if (view != null) {
      cursor = view.getCursor();
    }

    // is the cursor pointing on the ground?
    if (cursor == null) {
      cursor = StendhalCursor.WALK;
      StaticGameLayers layers = client.getStaticGameLayers();
      if ((layers.getCollisionDetection() != null) && layers.getCollisionDetection().collides((int) point2.getX(), (int) point2.getY())) {
        cursor = StendhalCursor.STOP;
      } else if (calculateZoneChangeDirection(point2) != null) {
        cursor = StendhalCursor.WALK_BORDER;         
      }
    }
View Full Code Here

      screen.removeText(text);
      return true;
    }

    // get clicked entity
    final Point2D location = screen.convertScreenViewToWorld(point);

    // for the clicked entity....
    final EntityView view = screen.getEntityViewAt(location.getX(), location.getY());
    boolean doubleClick = Boolean.parseBoolean(WtWindowManager.getInstance().getProperty("ui.doubleclick", "false"));
    if ((view != null) && view.isInteractive()) {
      if (isCtrlDown()) {
        view.onAction();
        return true;
View Full Code Here

TOP

Related Classes of java.awt.geom.Point2D$Double

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.