use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class TableActivity method onResume.
@Override
protected void onResume() {
super.onResume();
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
broadcastManager.registerReceiver(receiver, new IntentFilter(SexyTopo.SURVEY_UPDATED_EVENT));
syncTableWithSurvey();
Bundle bundle = getIntent().getExtras();
if (bundle != null && bundle.getString(SexyTopo.JUMP_TO_STATION) != null) {
String requestedStationName = bundle.getString(SexyTopo.JUMP_TO_STATION);
Station requestedStation = getSurvey().getStationByName(requestedStationName);
jumpToStation(requestedStation);
} else {
final ScrollView scrollView = findViewById(R.id.BodyTableScrollView);
scrollView.fullScroll(View.FOCUS_DOWN);
}
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class TableActivity method requestMoveLeg.
@SuppressLint("InflateParams")
private void requestMoveLeg(final Leg toMove) {
View stationView = getLayoutInflater().inflate(R.layout.select_station_dialog, null);
List<String> spinnerArray = new ArrayList<>();
List<Station> stations = LegMover.getValidDestinations(getSurvey(), toMove);
if (stations.isEmpty()) {
showSimpleToast(R.string.move_leg_no_valid_move);
return;
}
for (Station station : stations) {
spinnerArray.add(station.getName());
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, spinnerArray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
final Spinner spinner = stationView.findViewById(R.id.stationSpinner);
spinner.setAdapter(adapter);
new AlertDialog.Builder(this).setMessage(R.string.move_leg_select_station_title).setView(stationView).setPositiveButton(R.string.move, (dialog, which) -> {
String selectedName = spinner.getSelectedItem().toString();
Station newStation = getSurvey().getStationByName(selectedName);
SurveyUpdater.moveLeg(getSurvey(), toMove, newStation);
syncTableWithSurvey();
}).setNegativeButton(R.string.cancel, null).show();
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class OldStyleLoader method addLegToSurvey.
private static void addLegToSurvey(Survey survey, Map<String, Station> nameToStation, String[] fields, String comment) throws Exception {
Station from = retrieveOrCreateStation(nameToStation, fields[0], comment);
Station to = retrieveOrCreateStation(nameToStation, fields[1], comment);
float distance = Float.parseFloat(fields[2]);
float azimuth = Float.parseFloat(fields[3]);
float inclination = Float.parseFloat(fields[4]);
List<Station> stationsSoFar = survey.getAllStations();
if (!stationsSoFar.contains(from) && !stationsSoFar.contains(to)) {
throw new Exception("Stations are out of order in file");
} else if (stationsSoFar.contains(from) && stationsSoFar.contains(to)) {
throw new Exception("Duplicate leg encountered");
} else if (stationsSoFar.contains(from)) {
// forward leg
Leg leg = (to == Survey.NULL_STATION) ? new Leg(distance, azimuth, inclination) : new Leg(distance, azimuth, inclination, to, new Leg[] {});
from.addOnwardLeg(leg);
} else if (stationsSoFar.contains(to)) {
// backwards leg
Leg leg = (from == Survey.NULL_STATION) ? new Leg(distance, azimuth, inclination) : new Leg(distance, azimuth, inclination, from, new Leg[] {});
to.addOnwardLeg(leg.reverse());
}
// Bit of a hack; hopefully the last station processed will be the active one
// (should probably record the active station in the file somewhere)
survey.setActiveStation(from);
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SexyTopoActivity method chooseSurveyToUnlink.
private void chooseSurveyToUnlink(final Survey survey, final Station station) {
AlertDialog.Builder builderSingle = new AlertDialog.Builder(this);
builderSingle.setTitle(getString(R.string.unlink_survey));
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_item);
final Set<SurveyConnection> connections = survey.getSurveysConnectedTo(station);
for (SurveyConnection connection : connections) {
arrayAdapter.add(connection.otherSurvey.getName());
}
builderSingle.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.dismiss());
builderSingle.setAdapter(arrayAdapter, (dialog, which) -> {
String surveyName = arrayAdapter.getItem(which);
try {
for (SurveyConnection connection : connections) {
if (connection.otherSurvey.getName().equals(surveyName)) {
Survey to = connection.otherSurvey;
Station stationTo = connection.stationInOtherSurvey;
unlinkSurveyConnection(survey, station, to, stationTo);
return;
}
}
throw new Exception("Couldn't find linked survey");
} catch (Exception exception) {
showException(exception);
}
});
builderSingle.show();
}
use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.
the class SurvexExporterTest method testCommentsAreIncluded.
@Test
public void testCommentsAreIncluded() {
SurvexExporter survexExporter = new SurvexExporter();
Survey oneNorth = BasicTestSurveyCreator.createStraightNorthThroughRepeats();
Station latest = oneNorth.getActiveStation();
String testComment = "Comment McComment Face";
latest.setComment(testComment);
String content = survexExporter.getContent(oneNorth);
Assert.assertTrue(content.contains(testComment));
}
Aggregations