コード例 #1
0
  public static NearestPoint findFromPickedLine(PaintContext context) {
    NearestPoint nearestPosition;

    Point2D.Double currentPoint = context.getLogicalMousePoint();
    nearestPosition = findNearestVertexFromLines(currentPoint, context.getLines());

    return nearestPosition;
  }
コード例 #2
0
  /**
   * find the nearest of current mouse point in the circle whose radius = {@code distance}.
   *
   * @param context
   * @param distance
   * @return nearestPoint in the limit. null if there are no such vertex.
   */
  public static NearestPoint findAround(PaintContext context, double distance) {
    NearestPoint nearestPosition = new NearestPoint();

    Point2D.Double currentPoint = context.getLogicalMousePoint();

    Collection<Collection<Vector2d>> vertices =
        ORIPA.doc.getVerticesArea(currentPoint.x, currentPoint.y, distance);

    for (Collection<Vector2d> locals : vertices) {
      NearestPoint nearest;
      nearest = findNearestVertex(currentPoint, locals);

      if (nearest.distance < nearestPosition.distance) {
        nearestPosition = nearest;
      }
    }

    if (context.dispGrid) {

      NearestPoint nearestGrid =
          findNearestVertex(currentPoint, context.updateGrids(PaintConfig.gridDivNum));

      if (nearestGrid.distance < nearestPosition.distance) {
        nearestPosition = nearestGrid;
      }
    }

    if (nearestPosition.distance >= distance) {
      return null;
    } else {

      //			System.out.println("#area " + vertices.size() +
      //					", #v(area1) " + vertices.iterator().next().size() +
      //					", scaled limit = " + distance);

    }

    return nearestPosition;
  }