Search in sources :

Example 1 with SketchDetail

use of org.hwyl.sexytopo.model.sketch.SketchDetail in project sexytopo by richsmith.

the class GraphView method handleErase.

private boolean handleErase(MotionEvent event) {
    Coord2D touchPointOnView = new Coord2D(event.getX(), event.getY());
    Coord2D touchPointOnSurvey = viewCoordsToSurveyCoords(touchPointOnView);
    boolean deleteLineFragments = PreferenceAccess.getBoolean(getContext(), "pref_delete_path_fragments", true);
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            SketchDetail closestDetail = sketch.findNearestDetailWithin(touchPointOnSurvey, DELETE_PATHS_WITHIN_N_PIXELS);
            // you missed, try again :P
            if (closestDetail == null) {
                return true;
            // you got part of the line
            } else if (deleteLineFragments && closestDetail instanceof PathDetail) {
                List<SketchDetail> fragments = ((PathDetail) closestDetail).getPathFragmentsOutsideRadius(touchPointOnSurvey, DELETE_PATHS_WITHIN_N_PIXELS / 4);
                sketch.deleteDetail(closestDetail, fragments);
                invalidate();
            // bullseye!
            } else {
                sketch.deleteDetail(closestDetail);
                invalidate();
            }
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
            break;
        default:
            return false;
    }
    return true;
}
Also used : PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) List(java.util.List) ArrayList(java.util.ArrayList) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) SketchDetail(org.hwyl.sexytopo.model.sketch.SketchDetail)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)1 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)1 SketchDetail (org.hwyl.sexytopo.model.sketch.SketchDetail)1