use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.
the class PocketTopoTxtExporter method exportStationCoords.
public static String exportStationCoords(Space<Coord2D> space) {
List<String> lines = new ArrayList<>();
lines.add("STATIONS");
for (Map.Entry<Station, Coord2D> entry : space.getStationMap().entrySet()) {
Coord2D coords = entry.getValue();
Station station = entry.getKey();
lines.add(coords.getX() + "\t" + coords.getY() + "\t" + station.getName());
}
lines.add("SHOTS");
for (Line<Coord2D> line : space.getLegMap().values()) {
Coord2D start = line.getStart();
Coord2D end = line.getEnd();
lines.add(start.getX() + "\t" + start.getY() + "\t" + end.getX() + "\t" + end.getY());
}
return TextTools.join("\n", lines);
}
use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.
the class XviExporter method getSketchLineText.
private static String getSketchLineText(PathDetail pathDetail, double scale) {
List<Object> fields = new LinkedList<>();
fields.add(pathDetail.getColour().toString());
for (Coord2D coord2D : pathDetail.getPath()) {
String x = TextTools.formatTo2dp(coord2D.getX() * scale);
// +0.0 to avoid -0.0
String y = TextTools.formatTo2dp((-coord2D.getY() + 0.0) * scale);
fields.add(x);
fields.add(y);
}
return field("\t", TextTools.join(" ", fields));
}
use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.
the class Space2DUtils method transform.
public static Space<Coord2D> transform(Space<Coord2D> space, Coord2D point) {
Space<Coord2D> newSpace = new Space<>();
Map<Station, Coord2D> stations = space.getStationMap();
for (Station station : stations.keySet()) {
Coord2D coord = stations.get(station);
Coord2D newCoord = coord.plus(point);
newSpace.addStation(station, newCoord);
}
Map<Leg, Line<Coord2D>> legs = space.getLegMap();
for (Leg leg : legs.keySet()) {
Line<Coord2D> line = legs.get(leg);
Line<Coord2D> newLine = transformLine(line, point);
newSpace.addLeg(leg, newLine);
}
return newSpace;
}
use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.
the class ConnectedSurveysTest method testConnectedSurveySketchGetsTranslatedCorrectly.
@Test
public void testConnectedSurveySketchGetsTranslatedCorrectly() {
Survey currentSurvey = getBasicSurvey("current");
Survey joinedSurvey = getBasicSurvey("joined");
Sketch sketch = joinedSurvey.getPlanSketch();
PathDetail pathDetail = sketch.startNewPath(new Coord2D(0, 0));
pathDetail.lineTo(new Coord2D(0, 1));
sketch.finishPath();
connectTwoSurveys(currentSurvey, currentSurvey.getActiveStation(), joinedSurvey, joinedSurvey.getOrigin());
GraphActivity activity = new PlanActivity();
Space<Coord2D> planProjection = Projection2D.PLAN.project(currentSurvey);
Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(activity, currentSurvey, planProjection);
Sketch translatedSketch = translated.keySet().iterator().next().getPlanSketch();
PathDetail translatedPathDetail = translatedSketch.getPathDetails().toArray(new PathDetail[] {})[0];
List<Coord2D> coords = translatedPathDetail.getPath();
Assert.assertEquals(new Coord2D(0, 1), coords.get(0));
Assert.assertEquals(new Coord2D(0, 2), coords.get(1));
}
use of org.hwyl.sexytopo.model.graph.Coord2D in project sexytopo by richsmith.
the class BasicTestSketchCreator method drawOneHorizontalLine.
public static void drawOneHorizontalLine(Sketch sketch) {
sketch.startNewPath(new Coord2D(5, 0));
sketch.getActivePath().lineTo(new Coord2D(10, 0));
sketch.finishPath();
}
Aggregations