# HG changeset patch # User Raimund Renkert # Date 1372252514 -7200 # Node ID b02f3a948858c44977b8045c3197d03ab9c3c93a # Parent b9c5bb510b395321f9f127e27628626e521bb9fe Enabled basedata datacage in fix analysis ls. diff -r b9c5bb510b39 -r b02f3a948858 artifacts/doc/conf/artifacts/fixanalysis.xml --- a/artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jun 26 14:54:48 2013 +0200 +++ b/artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jun 26 15:15:14 2013 +0200 @@ -204,6 +204,8 @@ + + @@ -268,6 +270,8 @@ + + diff -r b9c5bb510b39 -r b02f3a948858 artifacts/doc/conf/meta-data.xml --- a/artifacts/doc/conf/meta-data.xml Wed Jun 26 14:54:48 2013 +0200 +++ b/artifacts/doc/conf/meta-data.xml Wed Jun 26 15:15:14 2013 +0200 @@ -164,7 +164,7 @@ - + diff -r b9c5bb510b39 -r b02f3a948858 artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java Wed Jun 26 14:54:48 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixLongitudinalSectionGenerator.java Wed Jun 26 15:15:14 2013 +0200 @@ -12,23 +12,29 @@ import java.awt.Color; import org.apache.log4j.Logger; +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.model.WKms; +import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod; +import org.dive4elements.river.artifacts.model.fixings.QWD; +import org.dive4elements.river.exports.ChartGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.exports.process.KMIndexProcessor; +import org.dive4elements.river.exports.process.Processor; +import org.dive4elements.river.exports.process.WOutProcessor; +import org.dive4elements.river.jfree.RiverAnnotation; +import org.dive4elements.river.jfree.StyledAreaSeriesCollection; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.utils.DataUtil; +import org.dive4elements.river.utils.KMIndex; +import org.dive4elements.river.utils.RiverUtils; import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.ValueMarker; import org.jfree.data.xy.XYSeries; import org.w3c.dom.Document; -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod; -import org.dive4elements.river.artifacts.model.fixings.QWD; -import org.dive4elements.river.exports.ChartGenerator; -import org.dive4elements.river.exports.process.KMIndexProcessor; -import org.dive4elements.river.exports.process.Processor; -import org.dive4elements.river.jfree.RiverAnnotation; -import org.dive4elements.river.jfree.StyledAreaSeriesCollection; -import org.dive4elements.river.jfree.StyledXYSeries; -import org.dive4elements.river.utils.KMIndex; - public class FixLongitudinalSectionGenerator extends FixChartGenerator implements FacetTypes @@ -57,8 +63,17 @@ public static final String I18N_DW_YAXIS_LABEL = "chart.fixings.longitudinalsection.yaxis.label"; + public static final String I18N_W_YAXIS_LABEL = + "chart.longitudinal.section.yaxis.label"; + + public static final String I18N_Q_YAXIS_LABEL = + "chart.longitudinal.section.yaxis.second.label"; + + public static final String I18N_W_YAXIS_LABEL_DEFAULT = "W [NN + m]"; + public static final String I18N_Q_YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; + public static enum YAXIS { - dW(0); + dW(0), W(1), Q(2); public int idx; private YAXIS(int c) { idx = c; @@ -71,12 +86,23 @@ logger.debug("FixLongitudinalSectionGenerator: doOut: " + name); Processor processor = new KMIndexProcessor(); + Processor wProcessor = new WOutProcessor(); if (name.contains(FIX_SECTOR_AVERAGE_LS_DEVIATION)) { doSectorAverageDeviationOut(aaf, doc, visible); } else if (processor.canHandle(name)) { processor.doOut(this, aaf, doc, visible, YAXIS.dW.idx); } + else if (wProcessor.canHandle(name)) { + wProcessor.doOut(this, aaf, doc, visible, YAXIS.W.idx); + } + else if (name.equals(STATIC_WQKMS_Q)) { + doQOut( + (WQKms) aaf.getData(context), + aaf, + doc, + visible); + } else if (name.equals(FIX_DEVIATION_LS)) { doReferenceDeviationOut(aaf, doc, visible); } @@ -97,6 +123,64 @@ } } + /** + * Process the output for Q facets in a longitudinal section curve. + * + * @param wqkms An array of WQKms values. + * @param aandf The facet and artifact. This facet does NOT support any data objects. Use + * D4EArtifact.getNativeFacet() instead to retrieve a Facet which supports + * data. + * @param theme The theme that contains styling information. + * @param visible The visibility of the curve. + */ + protected void doQOut( + WQKms wqkms, + ArtifactAndFacet aandf, + Document theme, + boolean visible + ) { + logger.debug("LongitudinalSectionGenerator.doQOut"); + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); + + StyledSeriesBuilder.addStepPointsKmQ(series, wqkms); + + addAxisSeries(series, YAXIS.Q.idx, visible); + + if (needInvertAxis(wqkms)) { + setInverted(true); + } + } + + /** + * This method determines - taking JFreeCharts auto x value ordering into + * account - if the x axis need to be inverted. Waterlines in these charts + * should decrease. + * + * @param wkms The data object that stores the x and y values used for this + * chart. + */ + public boolean needInvertAxis(WKms wkms) { + boolean wsUp = wkms.guessWaterIncreasing(); + boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms()); + boolean inv = (wsUp && kmUp) || (!wsUp && !kmUp); + + int size = wkms.size(); + + if (logger.isDebugEnabled()) { + logger.debug("(Wkms)Values : " + size); + if (size > 0) { + logger.debug("Start km: " + wkms.getKm(0)); + logger.debug("End km: " + wkms.getKm(size-1)); + } + logger.debug("wsUp: " + wsUp); + logger.debug("kmUp: " + kmUp); + logger.debug("inv: " + inv); + } + + return inv; + } + @SuppressWarnings("unchecked") protected void doSectorAverageDeviationOut( ArtifactAndFacet aaf, @@ -199,7 +283,21 @@ @Override protected String getDefaultYAxisLabel(int pos) { - return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT); + if (pos == YAXIS.dW.idx) { + return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT); + } + else if (pos == YAXIS.W.idx) { + D4EArtifact flys = (D4EArtifact) master; + String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); + return msg( + I18N_W_YAXIS_LABEL, + I18N_W_YAXIS_LABEL_DEFAULT, + new Object[] { unit }); + } + else if (pos == YAXIS.Q.idx) { + return msg(I18N_Q_YAXIS_LABEL, I18N_Q_YAXIS_LABEL_DEFAULT); + } + return ""; } @Override