From 9002d864c729f1a1fa5f95c6dab39be5d26aa46b Mon Sep 17 00:00:00 2001 From: Oakley Jurgens Date: Wed, 22 May 2024 16:17:29 +1200 Subject: [PATCH] Customize section render characteristics --- .../ruptures/util/RupCartoonGenerator.java | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/opensha/sha/earthquake/faultSysSolution/ruptures/util/RupCartoonGenerator.java b/src/main/java/org/opensha/sha/earthquake/faultSysSolution/ruptures/util/RupCartoonGenerator.java index 2ea784c61..085f434af 100644 --- a/src/main/java/org/opensha/sha/earthquake/faultSysSolution/ruptures/util/RupCartoonGenerator.java +++ b/src/main/java/org/opensha/sha/earthquake/faultSysSolution/ruptures/util/RupCartoonGenerator.java @@ -103,9 +103,33 @@ public class RupCartoonGenerator { private static boolean write_pdfs = false; + public interface SectionCharacteristicsFunction { + List 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 chars = new ArrayList<>(); + chars.add(traceChar); + chars.add(outlineChar); + chars.add(null); + return chars; + }; + private static void plotSection(FaultSection sect, List funcs, List chars, PlotCurveCharacterstics traceChar, PlotCurveCharacterstics outlineChar) { + + List 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(); @@ -113,15 +137,23 @@ private static void plotSection(FaultSection sect, List funcs, 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 line(FaultSection from, FaultSection to, boolean arrow, double lenScale) {