From e8f8d3d85f2332e73e54bfa04e763a4860fa297b Mon Sep 17 00:00:00 2001 From: Kevin Milner Date: Tue, 15 Aug 2023 15:30:21 -0700 Subject: [PATCH] more map making options --- .../commons/gui/plot/GeographicMapMaker.java | 59 +++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/opensha/commons/gui/plot/GeographicMapMaker.java b/src/main/java/org/opensha/commons/gui/plot/GeographicMapMaker.java index ee9438b79..896c362c0 100644 --- a/src/main/java/org/opensha/commons/gui/plot/GeographicMapMaker.java +++ b/src/main/java/org/opensha/commons/gui/plot/GeographicMapMaker.java @@ -129,6 +129,7 @@ public class GeographicMapMaker { */ protected List scatterLocs; protected List scatterScalars; + protected List scatterChars; protected CPT scatterScalarCPT; protected String scatterScalarLabel; protected Color scatterColor; @@ -170,10 +171,12 @@ public class GeographicMapMaker { protected List surfMiddles; public GeographicMapMaker(Region region) { + this(region, PoliticalBoundariesData.loadDefaultOutlines(region)); + } + + public GeographicMapMaker(Region region, XY_DataSet[] politicalBoundaries) { this.region = region; - - // political boundary special cases - politicalBoundaries = PoliticalBoundariesData.loadDefaultOutlines(region); + this.politicalBoundaries = politicalBoundaries; } public static Region buildBufferedRegion(Collection sects) { @@ -471,6 +474,22 @@ public void plotScatters(List locs, Color color) { this.scatterColor = color; } + public void plotScatters(List locs, List chars, String label) { + clearScatters(); + Preconditions.checkState(locs.size() == chars.size()); + this.scatterLocs = locs; + this.scatterChars = chars; + this.scatterScalarLabel = label; + } + + public void plotScatters(List locs, List chars, PlotSymbol outlineSymbol, String label) { + clearScatters(); + Preconditions.checkState(locs.size() == chars.size()); + this.scatterLocs = locs; + this.scatterChars = chars; + this.scatterScalarLabel = label; + } + public void plotScatterScalars(List locs, List values, CPT cpt, String label) { clearScatters(); Preconditions.checkState(locs.size() == values.size()); @@ -484,6 +503,7 @@ public void plotScatterScalars(List locs, List values, CPT cpt public void clearScatters() { this.scatterLocs = null; this.scatterScalars = null; + this.scatterChars = null; this.scatterScalarCPT = null; this.scatterScalarLabel = null; this.scatterColor = null; @@ -782,7 +802,7 @@ protected void plotSects() { // we'll plot fault traces if we don't have scalar values boolean doTraces = sectScalars == null && sectColors == null; - if (!doTraces && skipNaNs && + if (!doTraces && !skipNaNs && (sectScalars != null && Double.isNaN(sectScalars[s]) || sectColors != null && sectColors.get(s) == null)) doTraces = true; @@ -1059,8 +1079,8 @@ protected void plotJumps() { protected void plotScatters() { if (scatterLocs == null || scatterLocs.isEmpty()) return; - XY_DataSet outlines = scatterOutline == null ? null : new DefaultXY_DataSet(); if (scatterScalars != null) { + XY_DataSet outlines = scatterOutline == null ? null : new DefaultXY_DataSet(); List> sortables = new ArrayList<>(); for (int j=0; j 4f) chars.add(new PlotCurveCharacterstics(scatterOutline, scatterSymbolWidth, scatterOutlineColor)); } + if (scatterScalarLabel != null) + cptLegend.add(buildCPTLegend(scatterScalarCPT, scatterScalarLabel)); + } else if (scatterChars != null) { + for (int j=0; j 8f) + props.set(FeatureProperties.MARKER_SIZE_PROP, FeatureProperties.MARKER_SIZE_LARGE); + else if (width > 4f) + props.set(FeatureProperties.MARKER_SIZE_PROP, FeatureProperties.MARKER_SIZE_MEDIUM); + else + props.set(FeatureProperties.MARKER_SIZE_PROP, FeatureProperties.MARKER_SIZE_SMALL); + features.add(new Feature(new Geometry.Point(loc), props)); + } + } + if (scatterScalarLabel != null) cptLegend.add(buildCPTLegend(scatterScalarCPT, scatterScalarLabel)); } else { + XY_DataSet outlines = scatterOutline == null ? null : new DefaultXY_DataSet(); Preconditions.checkNotNull(scatterColor); XY_DataSet xy = new DefaultXY_DataSet(); LocationList locs = new LocationList();