use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class GraphView method drawStations.
private void drawStations(Survey survey, Canvas canvas, Space<Coord2D> space, int baseAlpha) {
boolean fadingNonActive = getDisplayPreference(GraphActivity.DisplayPreference.FADE_NON_ACTIVE);
if (fadingNonActive) {
baseAlpha = FADED_ALPHA;
}
int alpha = baseAlpha;
stationPaint.setAlpha(alpha);
boolean showStationLabels = getDisplayPreference(GraphActivity.DisplayPreference.SHOW_STATION_LABELS);
int crossDiameter = PreferenceAccess.getInt(this.getContext(), "pref_station_diameter", CROSS_DIAMETER);
for (Map.Entry<Station, Coord2D> entry : space.getStationMap().entrySet()) {
Station station = entry.getKey();
if (fadingNonActive && (station == survey.getActiveStation())) {
alpha = SOLID_ALPHA;
// setting alpha is measured as a relatively expensive call, so we change this as
// little as possible
stationPaint.setAlpha(alpha);
}
Coord2D translatedStation = surveyCoordsToViewCoords(entry.getValue());
int x = (int) (translatedStation.x);
int y = (int) (translatedStation.y);
drawStationCross(canvas, stationPaint, x, y, crossDiameter, alpha);
if (station == survey.getActiveStation()) {
highlightActiveStation(canvas, x, y);
}
int spacing = crossDiameter / 2;
int nextX = x + crossDiameter;
if (showStationLabels) {
String name = station.getName();
if (station == survey.getOrigin()) {
name = name + " (" + survey.getName() + ")";
}
canvas.drawText(name, nextX, y + STATION_LABEL_OFFSET, stationPaint);
nextX += stationPaint.measureText(name) + spacing;
}
List<Bitmap> icons = new ArrayList<>();
if (station.hasComment()) {
icons.add(commentIcon);
}
if (survey.hasLinkedSurveys(station)) {
icons.add(linkIcon);
}
for (Bitmap icon : icons) {
int yTop = y - crossDiameter / 2;
Rect rect = new Rect(nextX, yTop, nextX + crossDiameter, yTop + crossDiameter);
canvas.drawBitmap(icon, null, rect, stationPaint);
nextX += crossDiameter + spacing;
}
CrossSectionDetail crossSectionDetail = sketch.getCrossSectionDetail(station);
if (crossSectionDetail != null) {
drawCrossSectionIndicator(canvas, crossSectionDetail, x, y, alpha);
}
if (fadingNonActive && (station == survey.getActiveStation())) {
alpha = baseAlpha;
stationPaint.setAlpha(alpha);
}
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class GraphView method drawCrossSections.
private void drawCrossSections(Canvas canvas, List<CrossSectionDetail> crossSectionDetails, int alpha) {
boolean showStationLabels = getDisplayPreference(GraphActivity.DisplayPreference.SHOW_STATION_LABELS);
crossSectionConnectorPaint.setAlpha(alpha);
List<CrossSectionDetail> badXSections = new ArrayList<>();
for (CrossSectionDetail sectionDetail : crossSectionDetails) {
if (!couldBeOnScreen(sectionDetail)) {
continue;
}
CrossSection crossSection = sectionDetail.getCrossSection();
if (crossSection == null) {
badXSections.add(sectionDetail);
continue;
}
Station station = crossSection.getStation();
if (station == null) {
badXSections.add(sectionDetail);
continue;
}
Coord2D surveyStationLocation = this.projection.getStationMap().get(station);
if (surveyStationLocation == null) {
badXSections.add(sectionDetail);
continue;
}
Coord2D centreOnSurvey = sectionDetail.getPosition();
Coord2D centreOnView = surveyCoordsToViewCoords(centreOnSurvey);
drawStationCross(canvas, stationPaint, centreOnView.x, centreOnView.y, STATION_DIAMETER, alpha);
String description = sectionDetail.getCrossSection().getStation().getName() + " X";
if (showStationLabels) {
stationPaint.setAlpha(alpha);
canvas.drawText(description, centreOnView.x, centreOnView.y, stationPaint);
}
Space<Coord2D> projection = sectionDetail.getProjection();
drawLegs(canvas, projection, alpha);
Coord2D viewStationLocation = surveyCoordsToViewCoords(surveyStationLocation);
drawDashedLine(canvas, viewStationLocation, centreOnView, DASHED_LINE_INTERVAL, crossSectionConnectorPaint);
}
for (CrossSectionDetail crossSectionDetail : badXSections) {
Station station = crossSectionDetail.getCrossSection().getStation();
String name = station == null ? "Unknown" : station.getName();
Log.e("Missing station details for cross section on station " + name + "; removing");
crossSectionDetails.remove(crossSectionDetail);
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class GraphView method handlePositionCrossSection.
private boolean handlePositionCrossSection(MotionEvent event) {
Coord2D touchPointOnView = new Coord2D(event.getX(), event.getY());
Coord2D touchPointOnSurvey = viewCoordsToSurveyCoords(touchPointOnView);
final Station station = survey.getActiveStation();
CrossSection crossSection = CrossSectioner.section(survey, station);
sketch.addCrossSection(crossSection, touchPointOnSurvey);
setSketchTool(previousSketchTool);
invalidate();
return true;
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SexyTopoActivity method continueSurvey.
public void continueSurvey(final Station joinPoint) {
final Survey currentSurvey = getSurvey();
if (!currentSurvey.isSaved()) {
showSimpleToast(R.string.cannot_extend_unsaved_survey);
return;
}
final EditText input = new EditText(this);
String defaultName = Util.getNextAvailableName(this, currentSurvey.getName());
input.setText(defaultName);
new AlertDialog.Builder(this).setTitle(getString(R.string.dialog_new_survey_title)).setView(input).setPositiveButton(getString(R.string.ok), (dialog, whichButton) -> {
Editable value = input.getText();
String name = value.toString();
if (Util.isSurveyNameUnique(SexyTopoActivity.this, name)) {
Survey newSurvey = new Survey(name);
newSurvey.getOrigin().setName(joinPoint.getName());
joinSurveys(currentSurvey, joinPoint, newSurvey, newSurvey.getOrigin());
setSurvey(newSurvey);
} else {
showSimpleToast(R.string.dialog_new_survey_name_must_be_unique);
}
}).setNegativeButton(getString(R.string.cancel), (dialog, whichButton) -> {
/* Do nothing. */
}).show();
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class OldStyleLoader method parse.
public static void parse(String text, Survey survey) throws Exception {
Map<String, Station> nameToStation = new HashMap<>();
Station origin = survey.getOrigin();
nameToStation.put(origin.getName(), origin);
String[] lines = text.split("\n");
for (String line : lines) {
line = line.trim();
if (line.equals("") || line.startsWith("*")) {
continue;
}
String comment = "";
if (line.contains("; ")) {
comment = line.substring(line.indexOf("; ") + 2);
comment = comment.replaceAll("\\\\n", "\n");
line = line.substring(0, line.indexOf("; "));
}
String[] fields = line.trim().split("\t");
addLegToSurvey(survey, nameToStation, fields, comment);
}
}
Aggregations