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;
}
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);
}
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;
}
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;
}
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));
}
Aggregations