Search in sources :

Example 31 with Coord2D

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

the class GraphView method drawCrossSections.

private void drawCrossSections(Canvas canvas, Set<CrossSectionDetail> crossSectionDetails, int alpha) {
    for (CrossSectionDetail sectionDetail : crossSectionDetails) {
        Coord2D centreOnSurvey = sectionDetail.getPosition();
        Coord2D centreOnView = surveyCoordsToViewCoords(centreOnSurvey);
        drawStationCross(canvas, stationPaint, (float) centreOnView.getX(), (float) centreOnView.getY(), STATION_DIAMETER, alpha);
        String description = sectionDetail.getCrossSection().getStation().getName() + " X-section";
        if (getDisplayPreference(GraphActivity.DisplayPreference.SHOW_STATION_LABELS)) {
            stationPaint.setAlpha(alpha);
            canvas.drawText(description, (float) centreOnView.getX(), (float) centreOnView.getY(), stationPaint);
        }
        Space<Coord2D> projection = sectionDetail.getProjection();
        drawLegs(canvas, projection, alpha);
    }
}
Also used : CrossSectionDetail(org.hwyl.sexytopo.model.sketch.CrossSectionDetail) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 32 with Coord2D

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

the class SketchJsonTranslater method toPathDetail.

public static PathDetail toPathDetail(JSONObject json) throws JSONException {
    Colour colour = Colour.valueOf(json.getString(COLOUR_TAG));
    JSONArray array = json.getJSONArray(POINTS_TAG);
    List<Coord2D> path = new ArrayList<>();
    for (JSONObject object : toList(array)) {
        path.add(toCoord2D(object));
    }
    PathDetail pathDetail = new PathDetail(path, colour);
    return pathDetail;
}
Also used : JSONObject(org.json.JSONObject) PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Colour(org.hwyl.sexytopo.model.sketch.Colour)

Example 33 with Coord2D

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

the class SketchJsonTranslater method toJson.

public static JSONObject toJson(PathDetail pathDetail) throws JSONException {
    JSONObject json = new JSONObject();
    json.put(COLOUR_TAG, pathDetail.getColour().toString());
    JSONArray points = new JSONArray();
    for (Coord2D coord : pathDetail.getPath()) {
        points.put(toJson(coord));
    }
    json.put(POINTS_TAG, points);
    return json;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 34 with Coord2D

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

the class SketchJsonTranslater method toTextDetail.

public static TextDetail toTextDetail(JSONObject json) throws JSONException {
    Colour colour = Colour.valueOf(json.getString(COLOUR_TAG));
    Coord2D location = toCoord2D(json.getJSONObject(POSITION_TAG));
    String text = json.getString(TEXT_TAG);
    TextDetail textDetail = new TextDetail(location, text, colour);
    return textDetail;
}
Also used : TextDetail(org.hwyl.sexytopo.model.sketch.TextDetail) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Colour(org.hwyl.sexytopo.model.sketch.Colour)

Example 35 with Coord2D

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

the class SketchJsonTranslater method toCrossSectionDetail.

public static CrossSectionDetail toCrossSectionDetail(Survey survey, JSONObject json) throws JSONException {
    Coord2D position = toCoord2D(json.getJSONObject(POSITION_TAG));
    double angle = json.getDouble(ANGLE_TAG);
    String stationdId = json.getString(STATION_ID_TAG);
    Station station = survey.getStationByName(stationdId);
    CrossSectionDetail crossSectionDetail = new CrossSectionDetail(new CrossSection(station, angle), position);
    return crossSectionDetail;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) CrossSectionDetail(org.hwyl.sexytopo.model.sketch.CrossSectionDetail) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection)

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