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