Search in sources :

Example 11 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 focusOnScreen) {
    if (MIN_ZOOM >= newZoom || newZoom >= MAX_ZOOM) {
        return;
    }
    Coord2D focusInSurveyCoords = viewCoordsToSurveyCoords(focusOnScreen);
    Coord2D delta = focusInSurveyCoords.minus(viewpointOffset);
    Coord2D scaledDelta = delta.scale(surveyToViewScale / newZoom);
    viewpointOffset = focusInSurveyCoords.minus(scaledDelta);
    surveyToViewScale = newZoom;
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 12 with Coord2D

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

the class GraphView method couldBeOnScreen.

private boolean couldBeOnScreen(SketchDetail sketchDetail) {
    Coord2D topLeft = viewCoordsToSurveyCoords(Coord2D.ORIGIN);
    Coord2D bottomRight = viewCoordsToSurveyCoords(new Coord2D(getWidth(), getHeight()));
    return sketchDetail.intersectsRectangle(topLeft, bottomRight);
}
Also used : Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 13 with Coord2D

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

the class GraphView method handleSelect.

private boolean handleSelect(MotionEvent event) {
    Coord2D touchPointOnView = new Coord2D(event.getX(), event.getY());
    Coord2D touchPointOnSurvey = viewCoordsToSurveyCoords(touchPointOnView);
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            double selectionTolerance = SELECTION_SENSITIVITY_IN_PIXELS / surveyToViewScale;
            Station newSelectedStation = findNearestStationWithinDelta(projection, touchPointOnSurvey, selectionTolerance);
            if (newSelectedStation == null) {
                return false;
            } else if (newSelectedStation != survey.getActiveStation()) {
                survey.setActiveStation(newSelectedStation);
                invalidate();
                return true;
            } else {
                // double selection opens context menu
                showContextMenu(event, newSelectedStation);
            }
        case MotionEvent.ACTION_MOVE:
            break;
        case MotionEvent.ACTION_UP:
            break;
        default:
            return false;
    }
    return true;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D)

Example 14 with Coord2D

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

the class PocketTopoTxtImporter method parsePolylines.

public static Set<PathDetail> parsePolylines(String text) {
    Set<PathDetail> paths = new HashSet<>();
    boolean inPolyline = false;
    Colour currentPathColour = null;
    PathDetail currentPathDetail = null;
    for (String line : TextTools.toArrayOfLines(text)) {
        if (line.startsWith("POLYLINE")) {
            if (inPolyline) {
                paths.add(currentPathDetail);
                currentPathDetail = null;
            }
            String colourText = line.substring("POLYLINE ".length());
            if (colourText.equals("RED")) {
                colourText = "PURPLE";
            }
            currentPathColour = Colour.valueOf(colourText);
            inPolyline = true;
            continue;
        }
        if (!inPolyline) {
            continue;
        }
        String[] coords = line.split("\t");
        double x = Double.parseDouble(coords[0]);
        double y = Double.parseDouble(coords[1]);
        Coord2D coord = new Coord2D(x, -y);
        if (currentPathDetail == null) {
            currentPathDetail = new PathDetail(coord, currentPathColour);
        } else {
            currentPathDetail.lineTo(coord);
        }
    }
    if (currentPathDetail != null) {
        paths.add(currentPathDetail);
    }
    return paths;
}
Also used : PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) HashSet(java.util.HashSet) Colour(org.hwyl.sexytopo.model.sketch.Colour)

Example 15 with Coord2D

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

the class XviExporter method getLegText.

private static String getLegText(Line<Coord2D> line, double scale) {
    Coord2D start = line.getStart();
    String startX = TextTools.formatTo2dp(start.getX() * scale);
    String startY = TextTools.formatTo2dp(start.getY() * scale);
    Coord2D end = line.getEnd();
    String endX = TextTools.formatTo2dp(end.getX() * scale);
    String endY = TextTools.formatTo2dp(end.getY() * scale);
    return field("\t", TextTools.joinAll(" ", startX, startY, endX, endY));
}
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