Search in sources :

Example 46 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method moveLeg.

public static void moveLeg(Survey survey, Leg leg, Station newSource) {
    Station originating = survey.getOriginatingStation(leg);
    originating.getOnwardLegs().remove(leg);
    newSource.addOnwardLeg(leg);
    survey.setSaved(false);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station)

Example 47 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method renameStation.

public static void renameStation(Survey survey, Station station, String name) {
    Station existing = survey.getStationByName(name);
    if (existing != null) {
        throw new IllegalArgumentException("New station name is not unique");
    }
    station.setName(name);
    Log.d("Renamed station " + station.getName() + " -> " + name);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station)

Example 48 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method update.

public static synchronized boolean update(Survey survey, Leg leg, InputMode inputMode) {
    Station activeStation = survey.getActiveStation();
    Log.d("Adding leg " + leg);
    activeStation.getOnwardLegs().add(leg);
    survey.setSaved(false);
    survey.addLegRecord(leg);
    boolean justCreatedNewStation = false;
    switch(inputMode) {
        case FORWARD:
            justCreatedNewStation = createNewStationIfTripleShot(survey, false);
            break;
        case BACKWARD:
            justCreatedNewStation = createNewStationIfTripleShot(survey, true);
            break;
        case COMBO:
            justCreatedNewStation = createNewStationIfBacksight(survey) || createNewStationIfTripleShot(survey, false);
        case CALIBRATION_CHECK:
            // do nothing :)
            break;
    }
    if (justCreatedNewStation) {
        Log.d("Created new station " + survey.getActiveStation().getName());
    }
    return justCreatedNewStation;
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station)

Example 49 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class SurveyUpdater method editStation.

public static void editStation(Survey survey, Station toEdit, Station edited) {
    boolean weAreRenamingAStation = !edited.getName().equals(toEdit);
    if (weAreRenamingAStation) {
        Station existing = survey.getStationByName(edited.getName());
        if (existing != null) {
            throw new IllegalArgumentException("New station name is not unique");
        }
    }
    if (toEdit == survey.getOrigin()) {
        survey.setOrigin(edited);
    } else {
        Leg referringLeg = survey.getReferringLeg(toEdit);
        Leg editedLeg = new Leg(referringLeg, edited);
        editLeg(survey, referringLeg, editedLeg);
    }
    if (survey.getActiveStation() == toEdit) {
        survey.setActiveStation(edited);
    }
    survey.setSaved(false);
}
Also used : Station(org.hwyl.sexytopo.model.survey.Station) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 50 with Station

use of org.hwyl.sexytopo.model.survey.Station in project sexytopo by richsmith.

the class GraphView method openCommentDialog.

private void openCommentDialog(final Station station) {
    final EditText input = new EditText(getContext());
    input.setLines(8);
    input.setGravity(Gravity.START | Gravity.TOP);
    input.setText(station.getComment());
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setView(input).setTitle(station.getName()).setPositiveButton(R.string.save, (dialog, which) -> station.setComment(input.getText().toString())).setNegativeButton("Cancel", (dialog, which) -> {
    /* Do nothing */
    });
    AlertDialog dialog = builder.create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    dialog.show();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) Rect(android.graphics.Rect) WindowManager(android.view.WindowManager) R(org.hwyl.sexytopo.R) Colour(org.hwyl.sexytopo.model.sketch.Colour) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) AttributeSet(android.util.AttributeSet) Map(java.util.Map) View(android.view.View) Canvas(android.graphics.Canvas) SketchDetail(org.hwyl.sexytopo.model.sketch.SketchDetail) SymbolDetail(org.hwyl.sexytopo.model.sketch.SymbolDetail) Projection2D(org.hwyl.sexytopo.model.graph.Projection2D) TextTools(org.hwyl.sexytopo.control.util.TextTools) CrossSection(org.hwyl.sexytopo.model.sketch.CrossSection) TableActivity(org.hwyl.sexytopo.control.activity.TableActivity) Set(java.util.Set) SketchTool(org.hwyl.sexytopo.model.sketch.SketchTool) ScaleGestureDetector(android.view.ScaleGestureDetector) Direction(org.hwyl.sexytopo.model.graph.Direction) AlertDialog(android.app.AlertDialog) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) List(java.util.List) SurveyManager(org.hwyl.sexytopo.control.SurveyManager) CrossSectioner(org.hwyl.sexytopo.control.util.CrossSectioner) Symbol(org.hwyl.sexytopo.model.sketch.Symbol) Paint(android.graphics.Paint) Context(android.content.Context) Path(android.graphics.Path) GestureDetector(android.view.GestureDetector) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) SurveyConnection(org.hwyl.sexytopo.model.survey.SurveyConnection) BitmapFactory(android.graphics.BitmapFactory) HashMap(java.util.HashMap) Station(org.hwyl.sexytopo.model.survey.Station) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SuppressLint(android.annotation.SuppressLint) SurveyUpdater(org.hwyl.sexytopo.control.util.SurveyUpdater) MotionEvent(android.view.MotionEvent) Line(org.hwyl.sexytopo.model.graph.Line) CrossSectionDetail(org.hwyl.sexytopo.model.sketch.CrossSectionDetail) Leg(org.hwyl.sexytopo.model.survey.Leg) Survey(org.hwyl.sexytopo.model.survey.Survey) PreferenceAccess(org.hwyl.sexytopo.control.util.PreferenceAccess) Space2DUtils(org.hwyl.sexytopo.control.util.Space2DUtils) PopupWindow(android.widget.PopupWindow) Log(org.hwyl.sexytopo.control.Log) BrushColour(org.hwyl.sexytopo.model.sketch.BrushColour) ExtendedElevationActivity(org.hwyl.sexytopo.control.activity.ExtendedElevationActivity) SurveyStats(org.hwyl.sexytopo.control.util.SurveyStats) Space(org.hwyl.sexytopo.model.graph.Space) TextDetail(org.hwyl.sexytopo.model.sketch.TextDetail) Gravity(android.view.Gravity) PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) SharedPreferences(android.content.SharedPreferences) CohenSutherlandAlgorithm(org.hwyl.sexytopo.control.util.CohenSutherlandAlgorithm) Bitmap(android.graphics.Bitmap) EditText(android.widget.EditText)

Aggregations

Station (org.hwyl.sexytopo.model.survey.Station)85 Leg (org.hwyl.sexytopo.model.survey.Leg)32 Survey (org.hwyl.sexytopo.model.survey.Survey)30 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)20 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 SuppressLint (android.annotation.SuppressLint)8 AlertDialog (android.app.AlertDialog)8 JSONException (org.json.JSONException)7 Line (org.hwyl.sexytopo.model.graph.Line)6 SurveyConnection (org.hwyl.sexytopo.model.survey.SurveyConnection)6 JSONObject (org.json.JSONObject)6 View (android.view.View)5 Set (java.util.Set)5 Direction (org.hwyl.sexytopo.model.graph.Direction)5 Space (org.hwyl.sexytopo.model.graph.Space)5 JSONArray (org.json.JSONArray)5 Context (android.content.Context)4 HashSet (java.util.HashSet)4