use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.
the class GraphView method drawLegs.
private void drawLegs(Canvas canvas, Space<Coord2D> space, int baseAlpha) {
boolean showSplays = getDisplayPreference(GraphActivity.DisplayPreference.SHOW_SPLAYS);
boolean highlightLatestLeg = PreferenceAccess.getBoolean(getContext(), "pref_key_highlight_latest_leg", true);
boolean fadingNonActive = getDisplayPreference(GraphActivity.DisplayPreference.FADE_NON_ACTIVE);
Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
for (Leg leg : legMap.keySet()) {
if (!showSplays && !leg.hasDestination()) {
continue;
}
Line<Coord2D> line = legMap.get(leg);
// noinspection ConstantConditions
Coord2D start = surveyCoordsToViewCoords(line.getStart());
Coord2D end = surveyCoordsToViewCoords(line.getEnd());
if (!isLineOnCanvas(start, end)) {
continue;
}
boolean fade = baseAlpha == FADED_ALPHA || (fadingNonActive && !isAttachedToActive(leg));
Paint paint;
if (highlightLatestLeg && survey.getMostRecentLeg() == leg) {
paint = fade ? fadedLatestLegPaint : latestLegPaint;
} else if (!leg.hasDestination()) {
paint = fade ? fadedSplayPaint : splayPaint;
} else {
paint = fade ? fadedLegPaint : legPaint;
}
if (projectionType.isLegInPlane(leg)) {
canvas.drawLine(start.x, start.y, end.x, end.y, paint);
} else {
drawDashedLine(canvas, start, end, DASHED_LINE_INTERVAL, paint);
}
}
}
use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.
the class ExtendedElevationProjectionTest method testProject1MNorth1MEast.
@Test
public void testProject1MNorth1MEast() {
Survey survey = BasicTestSurveyCreator.create5MEast();
Space<Coord2D> space = Projection2D.EXTENDED_ELEVATION.project(survey);
Map<Station, Coord2D> stationMap = space.getStationMap();
Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
Station two = survey.getStationByName("2");
Coord2D twoCoord = stationMap.get(two);
Coord2D expected = new Coord2D(5, 0);
Assert.assertEquals(expected, twoCoord);
Leg splayLeft = two.getUnconnectedOnwardLegs().get(0);
Line<Coord2D> splayLeftLine = legMap.get(splayLeft);
expected = new Coord2D(5, 0);
assert splayLeftLine != null;
Assert.assertEquals(expected, splayLeftLine.getEnd());
Leg splayRight = two.getUnconnectedOnwardLegs().get(1);
Line<Coord2D> splayRightLine = legMap.get(splayRight);
expected = new Coord2D(5, 0);
assert splayRightLine != null;
Assert.assertEquals(expected, splayRightLine.getEnd());
}
use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.
the class Space2DUtils method transformLine.
public static Line<Coord2D> transformLine(Line<Coord2D> line, Coord2D point) {
Coord2D start = line.getStart();
Coord2D end = line.getEnd();
return new Line<>(start.plus(point), end.plus(point));
}
use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.
the class Space3DTransformerForElevation method updateLeg.
protected void updateLeg(Space<Coord3D> space, Leg leg, Coord3D start) {
Leg adjustedLeg;
if (leg.getDestination().getExtendedElevationDirection() == Direction.LEFT) {
adjustedLeg = leg.adjustAzimuth(180);
} else {
adjustedLeg = leg.adjustAzimuth(0);
}
float delta = adjustedLeg.getAzimuth() - leg.getAzimuth();
Coord3D end = Space3DUtils.toCartesian(start, adjustedLeg);
Line<Coord3D> line = new Line<>(start, end);
space.addLeg(leg, line);
if (leg.hasDestination()) {
update(space, leg.getDestination(), end, delta);
}
}
use of org.hwyl.sexytopo.model.graph.Line in project sexytopo by richsmith.
the class Space3DTransformerForElevation method updateSplay.
protected void updateSplay(Space<Coord3D> space, Leg leg, Coord3D start, float rotation) {
Leg adjustedLeg = leg.rotate(rotation);
Coord3D end = Space3DUtils.toCartesian(start, adjustedLeg);
Line<Coord3D> line = new Line<>(start, end);
space.addLeg(leg, line);
}
Aggregations