Exemplo n.º 1
0
 public LinkedList<LineWorldObject> getLineWorldObjectsInSelection(Rectangle2D selectionInCM) {
   LinkedList<LineWorldObject> objectsInSelection = new LinkedList<LineWorldObject>();
   for (LineWorldObject o : lineObjects) {
     if (selectionInCM.intersectsLine(o.getXInCM(), o.getYInCM(), o.getX2InCM(), o.getY2InCM())) {
       objectsInSelection.add(o);
     }
   }
   return objectsInSelection;
 }
Exemplo n.º 2
0
  /**
   * Determines if a way lies within the bounding box.
   *
   * @param boundingBox The bounding box.
   * @param nodes The ordered nodes of the way in order.
   * @return True if the way is at least partially within the box.
   */
  private boolean isWayInsideBox(Rectangle2D boundingBox, List<Node> nodes) {
    // If at least one node lies within the box, the way is inside the box.
    for (Node node : nodes) {
      if (isNodeInsideBox(boundingBox, node)) {
        return true;
      }
    }

    // Now we need to check if any of the segments cross the box.
    for (int i = 0; i < nodes.size() - 1; i++) {
      Node nodeA;
      Node nodeB;

      nodeA = nodes.get(i);
      nodeB = nodes.get(i + 1);

      if (boundingBox.intersectsLine(
          nodeA.getLongitude(), nodeA.getLatitude(), nodeB.getLongitude(), nodeB.getLatitude())) {
        return true;
      }
    }

    return false;
  }
Exemplo n.º 3
0
 /**
  * Checks if a line with given start and end point intersects with the rectangle represented by
  * the stone.
  *
  * @param x1 x-coordinate of starting point
  * @param y1 y-coordinate of starting point
  * @param x2 x-coordinate of ending point
  * @param y2 y-coordinate of ending point
  * @return true if line intersects with stone
  */
 public boolean contains(float x1, float y1, float x2, float y2) {
   Rectangle2D rect = new Rectangle.Float(getxLocation(), getyLocation(), getWidth(), getHeight());
   return rect.intersectsLine(new Line2D.Float(x1, y1, x2, y2));
 }