Search in sources :

Example 6 with Colour

use of org.hwyl.sexytopo.model.sketch.Colour 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 : Util.toList(array)) {
        path.add(toCoord2D(object));
    }
    PathDetail pathDetail = new PathDetail(path, colour);
    float epsilon = Space2DUtils.simplificationEpsilon(pathDetail);
    List<Coord2D> simplifiedPath = Space2DUtils.simplify(path, epsilon);
    pathDetail.setPath(simplifiedPath);
    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 7 with Colour

use of org.hwyl.sexytopo.model.sketch.Colour 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);
    float scale = (float) (json.has(SIZE_TAG) ? json.getDouble(SIZE_TAG) : 0);
    TextDetail textDetail = new TextDetail(location, text, colour, scale);
    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)

Aggregations

Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)7 Colour (org.hwyl.sexytopo.model.sketch.Colour)7 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)5 ArrayList (java.util.ArrayList)3 BrushColour (org.hwyl.sexytopo.model.sketch.BrushColour)2 SymbolDetail (org.hwyl.sexytopo.model.sketch.SymbolDetail)2 TextDetail (org.hwyl.sexytopo.model.sketch.TextDetail)2 SuppressLint (android.annotation.SuppressLint)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 HashSet (java.util.HashSet)1 Symbol (org.hwyl.sexytopo.model.sketch.Symbol)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1