Search in sources :

Example 6 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class GraphView method drawLegs.

private void drawLegs(Canvas canvas, Space<Coord2D> space, int alpha) {
    Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
    for (Leg leg : legMap.keySet()) {
        if (!getDisplayPreference(GraphActivity.DisplayPreference.SHOW_SPLAYS) && !leg.hasDestination()) {
            continue;
        }
        Line<Coord2D> line = legMap.get(leg);
        Coord2D start = surveyCoordsToViewCoords(line.getStart());
        Coord2D end = surveyCoordsToViewCoords(line.getEnd());
        if (PreferenceAccess.getBoolean(getContext(), "pref_key_highlight_latest_leg", true) && survey.getMostRecentLeg() == leg) {
            legPaint.setColor(LATEST_LEG_COLOUR.intValue);
        } else if (!leg.hasDestination()) {
            legPaint.setColor(SPLAY_COLOUR.intValue);
        } else {
            legPaint.setColor(LEG_COLOUR.intValue);
        }
        legPaint.setAlpha(alpha);
        if (projectionType.isLegInPlane(leg)) {
            legPaint.setStyle(Paint.Style.STROKE);
            canvas.drawLine((float) (start.getX()), (float) (start.getY()), (float) (end.getX()), (float) (end.getY()), legPaint);
        } else {
            legPaint.setPathEffect(new DashPathEffect(new float[] { 3, 2 }, 0));
            Path path = new Path();
            path.moveTo((float) (start.getX()), (float) (start.getY()));
            path.lineTo((float) (end.getX()), (float) (end.getY()));
            canvas.drawPath(path, legPaint);
        }
    }
}
Also used : Line(org.hwyl.sexytopo.model.graph.Line) Path(android.graphics.Path) DashPathEffect(android.graphics.DashPathEffect) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 7 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D 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);
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            /*SketchDetail closestDetail =
                        sketch.findNearestPathWithin(sketch.getPathDetails(),
                                touchPointOnSurvey, DELETE_PATHS_WITHIN_N_PIXELS);*/
            SketchDetail closestDetail = sketch.findNearestDetailWithin(touchPointOnSurvey, DELETE_PATHS_WITHIN_N_PIXELS);
            if (closestDetail != null) {
                sketch.deleteDetail(closestDetail);
                invalidate();
            }
        case MotionEvent.ACTION_MOVE:
            break;
        case MotionEvent.ACTION_UP:
            break;
        default:
            return false;
    }
    return true;
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) SketchDetail(org.hwyl.sexytopo.model.sketch.SketchDetail)

Example 8 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class GraphView method centreViewOnSurveyPoint.

public void centreViewOnSurveyPoint(Coord2D point) {
    double xDeltaInMetres = ((double) getWidth() / 2) / surveyToViewScale;
    double yDeltaInMetres = ((double) getHeight() / 2) / surveyToViewScale;
    double x = point.getX() - xDeltaInMetres;
    double y = point.getY() - yDeltaInMetres;
    viewpointOffset = new Coord2D(x, y);
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 9 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class GraphView method drawConnectedSurveys.

private void drawConnectedSurveys(Canvas canvas, Space<Coord2D> projection, int alpha) {
    if (doTranslatedConnectedSurveysNeedUpdating()) {
        this.translatedConnectedSurveys = ConnectedSurveys.getTranslatedConnectedSurveys(activity, survey, projection);
    }
    for (Survey translatedConnectedSurvey : translatedConnectedSurveys.keySet()) {
        Space<Coord2D> connectedProjection = translatedConnectedSurveys.get(translatedConnectedSurvey);
        drawSurvey(canvas, translatedConnectedSurvey, connectedProjection, alpha);
    }
}
Also used : Survey(org.hwyl.sexytopo.model.survey.Survey) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 10 with Coord2D

use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.

the class GraphView method setZoom.

public void setZoom(double newZoom) {
    Coord2D centre = new Coord2D((double) getWidth() / 2, (double) getHeight() / 2);
    setZoom(newZoom, centre);
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Aggregations

Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)40 Station (org.hwyl.sexytopo.model.survey.Station)10 Space (org.hwyl.sexytopo.model.graph.Space)8 Line (org.hwyl.sexytopo.model.graph.Line)6 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)6 Survey (org.hwyl.sexytopo.model.survey.Survey)6 Test (org.junit.Test)6 Leg (org.hwyl.sexytopo.model.survey.Leg)5 Colour (org.hwyl.sexytopo.model.sketch.Colour)4 ArrayList (java.util.ArrayList)3 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)3 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)3 Sketch (org.hwyl.sexytopo.model.sketch.Sketch)3 Paint (android.graphics.Paint)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 CrossSection (org.hwyl.sexytopo.model.sketch.CrossSection)2 CrossSectionDetail (org.hwyl.sexytopo.model.sketch.CrossSectionDetail)2 TextDetail (org.hwyl.sexytopo.model.sketch.TextDetail)2 JSONArray (org.json.JSONArray)2