Skip to content

Commit

Permalink
Merge pull request opensha#117 from GNS-Science/feature/section-chars
Browse files Browse the repository at this point in the history
Customize section render characteristics
  • Loading branch information
kevinmilner authored May 24, 2024
2 parents b4c3366 + 9002d86 commit 6b24a24
Showing 1 changed file with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,57 @@ public class RupCartoonGenerator {

private static boolean write_pdfs = false;

public interface SectionCharacteristicsFunction {
List<PlotCurveCharacterstics> getChars(FaultSection section,
PlotCurveCharacterstics traceChar,
PlotCurveCharacterstics outlineChar);
}

/**
* Override this function to change section characteristics based on the section.
* This function is called in plotSection()
*/
public static SectionCharacteristicsFunction sectCharFun = (section, traceChar, outlineChar) -> {
List<PlotCurveCharacterstics> chars = new ArrayList<>();
chars.add(traceChar);
chars.add(outlineChar);
chars.add(null);
return chars;
};

private static void plotSection(FaultSection sect, List<XY_DataSet> funcs,
List<PlotCurveCharacterstics> chars, PlotCurveCharacterstics traceChar,
PlotCurveCharacterstics outlineChar) {

List<PlotCurveCharacterstics> charOverrides = sectCharFun.getChars(sect, traceChar, outlineChar);
traceChar = charOverrides.get(0);
outlineChar = charOverrides.get(1);
PlotCurveCharacterstics fillChar = charOverrides.get(2);

if (sect.getAveDip() < 90d) {
RuptureSurface surf = sect.getFaultSurface(1d, false, false);
LocationList perimeter = surf.getPerimeter();
DefaultXY_DataSet xy = new DefaultXY_DataSet();
for (Location loc : perimeter)
xy.set(loc.getLongitude(), loc.getLatitude());
xy.set(xy.get(0));
if (fillChar != null) {
funcs.add(xy);
chars.add(fillChar);
}
if (outlineChar != null) {
funcs.add(xy);
chars.add(outlineChar);
}
}

if (traceChar != null) {
DefaultXY_DataSet xy = new DefaultXY_DataSet();
for (Location loc : sect.getFaultTrace())
xy.set(loc.getLongitude(), loc.getLatitude());
funcs.add(xy);
chars.add(outlineChar);
chars.add(traceChar);
}

DefaultXY_DataSet xy = new DefaultXY_DataSet();
for (Location loc : sect.getFaultTrace())
xy.set(loc.getLongitude(), loc.getLatitude());
funcs.add(xy);
chars.add(traceChar);
}

private static List<XY_DataSet> line(FaultSection from, FaultSection to, boolean arrow, double lenScale) {
Expand Down

0 comments on commit 6b24a24

Please sign in to comment.