public static NearestPoint findFromPickedLine(PaintContext context) {
    NearestPoint nearestPosition;

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

    return nearestPosition;
  }
  @Override
  public void onResult(PaintContext context) {
    ORIPA.doc.pushCachedUndoInfo();

    Vector2d first = context.getVertex(0);
    Vector2d second = context.getVertex(1);
    Vector2d third = context.getVertex(2);

    if (doSpecial) {
      ORIPA.doc.addSymmetricLineAutoWalk(first, second, third, 0, first);
    } else {
      ORIPA.doc.addSymmetricLine(first, second, third);
    }

    doingFirstAction = true;
    context.clear(false);
  }
  /**
   * 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;
  }
  @Override
  protected boolean onAct(PaintContext context, Double currentPoint, boolean doSpecial) {

    if (doingFirstAction) {
      ORIPA.doc.cacheUndoInfo();
      doingFirstAction = false;
    }

    boolean result = super.onAct(context, currentPoint, doSpecial);

    if (result == true) {
      if (context.getVertexCount() < 3) {
        result = false;
      }
    }

    this.doSpecial = doSpecial;

    return result;
  }