use of org.hwyl.sexytopo.model.sketch.CrossSectionDetail in project sexytopo by richsmith.
the class GraphView method drawCrossSections.
private void drawCrossSections(Canvas canvas, Set<CrossSectionDetail> crossSectionDetails, int alpha) {
for (CrossSectionDetail sectionDetail : crossSectionDetails) {
Coord2D centreOnSurvey = sectionDetail.getPosition();
Coord2D centreOnView = surveyCoordsToViewCoords(centreOnSurvey);
drawStationCross(canvas, stationPaint, (float) centreOnView.getX(), (float) centreOnView.getY(), STATION_DIAMETER, alpha);
String description = sectionDetail.getCrossSection().getStation().getName() + " X-section";
if (getDisplayPreference(GraphActivity.DisplayPreference.SHOW_STATION_LABELS)) {
stationPaint.setAlpha(alpha);
canvas.drawText(description, (float) centreOnView.getX(), (float) centreOnView.getY(), stationPaint);
}
Space<Coord2D> projection = sectionDetail.getProjection();
drawLegs(canvas, projection, alpha);
}
}
use of org.hwyl.sexytopo.model.sketch.CrossSectionDetail 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.sketch.CrossSectionDetail 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.sketch.CrossSectionDetail in project sexytopo by richsmith.
the class SketchJsonTranslater method toCrossSectionDetail.
public static CrossSectionDetail toCrossSectionDetail(Survey survey, JSONObject json) throws JSONException {
Coord2D position = toCoord2D(json.getJSONObject(POSITION_TAG));
float angle = (float) json.getDouble(ANGLE_TAG);
String stationdId = json.getString(STATION_ID_TAG);
Station station = survey.getStationByName(stationdId);
CrossSectionDetail crossSectionDetail = new CrossSectionDetail(new CrossSection(station, angle), position);
return crossSectionDetail;
}
use of org.hwyl.sexytopo.model.sketch.CrossSectionDetail in project sexytopo by richsmith.
the class SketchJsonTranslater method toSketch.
public static Sketch toSketch(Survey survey, JSONObject json) {
Sketch sketch = new Sketch();
try {
JSONArray pathsArray = json.getJSONArray(PATHS_TAG);
List<PathDetail> pathDetails = new ArrayList<>();
for (JSONObject object : Util.toList(pathsArray)) {
pathDetails.add(toPathDetail(object));
}
sketch.setPathDetails(pathDetails);
} catch (JSONException e) {
Log.e("Failed to load sketch paths: " + e);
}
try {
JSONArray symbolsArray = json.getJSONArray(SYMBOLS_TAG);
List<SymbolDetail> symbolDetails = new ArrayList<>();
for (JSONObject object : Util.toList(symbolsArray)) {
symbolDetails.add(toSymbolDetail(object));
}
sketch.setSymbolDetails(symbolDetails);
} catch (JSONException e) {
Log.e("Failed to load symbols: " + e);
}
try {
JSONArray labelsArray = json.getJSONArray(LABELS_TAG);
List<TextDetail> textDetails = new ArrayList<>();
for (JSONObject object : Util.toList(labelsArray)) {
textDetails.add(toTextDetail(object));
}
sketch.setTextDetails(textDetails);
} catch (JSONException e) {
Log.e("Failed to load sketch labels: " + e);
}
try {
JSONArray crossSectionsArray = json.getJSONArray(CROSS_SECTIONS_TAG);
List<CrossSectionDetail> crossSectionDetails = new ArrayList<>();
for (JSONObject object : Util.toList(crossSectionsArray)) {
crossSectionDetails.add(toCrossSectionDetail(survey, object));
}
sketch.setCrossSectionDetails(crossSectionDetails);
} catch (JSONException e) {
Log.e("Failed to load cross-sections: " + e);
}
return sketch;
}
Aggregations