Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java @ 9123:1cc7653ca84f
Cleanup of ChartGenerator and ChartGenerator2 code. Put some of the copy/pasted code into a common abstraction.
author | gernotbelger |
---|---|
date | Tue, 05 Jun 2018 19:21:16 +0200 |
parents | 5e38e2924c07 |
children | 094ed9d1f2ad |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Tue Jun 05 19:10:38 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Tue Jun 05 19:21:16 2018 +0200 @@ -28,6 +28,7 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.StaticWKmsArtifact; import org.dive4elements.river.artifacts.WINFOArtifact; @@ -115,7 +116,7 @@ /** Returns value != 0 if the current km is not at a gauge. */ public double getCurrentGaugeDatum() { - Object ckm = context.getContextValue(CURRENT_KM); + Object ckm = getContext().getContextValue(CURRENT_KM); if (ckm != null) { return DischargeCurveGenerator.getCurrentGaugeDatum( (Double) ckm, @@ -210,6 +211,8 @@ this.artifact = (D4EArtifact) aaf.getArtifact(); + final CallContext context = getContext(); + if(name.startsWith(FIX_SECTOR_AVERAGE_WQ)) { doSectorAverageOut(aaf, doc, visible); } @@ -286,7 +289,7 @@ ) { log.debug("doSectorAverageOut"); - QWDDateRange qwdd = (QWDDateRange) aaf.getData(context); + QWDDateRange qwdd = (QWDDateRange) aaf.getData(getContext()); QWD qwd = qwdd != null ? qwdd.getQWD() : null; if(qwd != null) { @@ -305,7 +308,7 @@ ) { log.debug("doAnalysisEventsOut"); - QWD qwd = (QWD)aaf.getData(context); + QWD qwd = (QWD)aaf.getData(getContext()); if (qwd == null) { log.debug("doAnalysisEventsOut: qwd == null"); @@ -365,7 +368,7 @@ ) { log.debug("doReferenceEventsOut"); - QWI qwd = (QWI)aaf.getData(context); + QWI qwd = (QWI)aaf.getData(getContext()); if (qwd == null) { log.debug("doReferenceEventsOut: qwds == null"); return; @@ -421,7 +424,7 @@ boolean visible ) { XYSeries series = new StyledXYSeries(title, theme); - Double ckm = (Double) context.getContextValue(CURRENT_KM); + Double ckm = (Double) getContext().getContextValue(CURRENT_KM); if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { log.info("addPointFromWQKms: No event data to show."); return; @@ -458,7 +461,7 @@ ) { log.debug("doEventsOut"); // Find W/Q at km. - addPointFromWQKms((WQKms) aaf.getData(context), + addPointFromWQKms((WQKms) aaf.getData(getContext()), aaf.getFacetDescription(), doc, visible); } @@ -472,7 +475,7 @@ FixWQCurveFacet facet = (FixWQCurveFacet)aaf.getFacet(); FixFunction func = (FixFunction)facet.getData( - aaf.getArtifact(), context); + aaf.getArtifact(), getContext()); if (func == null) { log.warn("doWQCurveOut: Facet does not contain FixFunction"); @@ -527,7 +530,7 @@ ) { log.debug("doOutlierOut"); - QWI[] qws = (QWI[])aaf.getData(context); + QWI[] qws = (QWI[])aaf.getData(getContext()); addQWSeries(qws, aaf, doc, visible); } @@ -543,7 +546,7 @@ return; } - Object qsectorsObj = aaf.getData(context); + Object qsectorsObj = aaf.getData(getContext()); if (qsectorsObj == null || !(qsectorsObj instanceof List)) { log.warn("No QSectors coming from data."); return; @@ -631,7 +634,7 @@ log.debug("Got WKms"); WKms data = (WKms) wqkms; - Double ckm = (Double) context.getContextValue(CURRENT_KM); + Double ckm = (Double) getContext().getContextValue(CURRENT_KM); double location = (ckm != null) ? ckm.doubleValue() : getRange()[0]; @@ -709,7 +712,7 @@ // be delivered by the facet already (instead of in the Generator). log.debug("FixWQCurveGenerator: doWQOut: WQKms"); - addPointFromWQKms((WQKms)aaf.getData(context), + addPointFromWQKms((WQKms)aaf.getData(getContext()), aaf.getFacetDescription(), theme, visible); } else { @@ -773,7 +776,7 @@ } @Override - protected String getChartTitle() { + protected String getChartTitle(final CallContext context) { return Resources.format( context.getMeta(), I18N_CHART_TITLE, @@ -782,12 +785,12 @@ } @Override - protected String getDefaultChartTitle() { + protected String getDefaultChartTitle(final CallContext context) { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); } @Override - protected String getDefaultChartSubtitle() { + protected String getDefaultChartSubtitle(final CallContext context) { FixAnalysisAccess access = new FixAnalysisAccess(artifact); DateRange dateRange = access.getDateRange(); DateRange refRange = access.getReferencePeriod(); @@ -808,8 +811,8 @@ } @Override - protected void addSubtitles(JFreeChart chart) { - String defaultSubtitle = getDefaultChartSubtitle(); + protected void addSubtitles(final CallContext context, final JFreeChart chart) { + String defaultSubtitle = getDefaultChartSubtitle(getContext()); if (defaultSubtitle == null || defaultSubtitle.length() == 0) { return; @@ -841,13 +844,13 @@ } @Override - protected String getDefaultXAxisLabel() { + protected String getDefaultXAxisLabel(final CallContext context) { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); } @Override protected String getDefaultYAxisLabel(int pos) { - D4EArtifact flys = (D4EArtifact) master; + D4EArtifact flys = getArtifact(); String unit = pos == 0 ? "cm"