[PATCH 1 of 2] More Processor refactoring
Wald Commits
scm-commit at wald.intevation.org
Fri Sep 20 16:33:48 CEST 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1379687143 -7200
# Branch generator-refactoring
# Node ID 253d80af5b7f85ffdb15720b0a92acd3d400f6c4
# Parent a2abd87c0d3b0e44a4c8fdcdd7d21769c51a0b39
More Processor refactoring
- Unify aandf aaf and bundle variable names to bundle
- Factor out diagram inversion code
- Add function with new signature to BedDiffYear and QOut processors
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -32,7 +32,7 @@
@Override
public void doOut(
DiagramGenerator generator,
- ArtifactAndFacet aaf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible) {
if (!visible) {
@@ -40,21 +40,21 @@
return;
}
CallContext context = generator.getCallContext();
- if (!(aaf.getData(context) instanceof RiverAnnotation)) {
+ if (!(bundle.getData(context) instanceof RiverAnnotation)) {
// Just a bit defensive should not happen
logger.error("Incompatible facet in doOut");
return;
}
- RiverAnnotation ra = (RiverAnnotation)aaf.getData(context);
+ RiverAnnotation ra = (RiverAnnotation)bundle.getData(context);
ra.setTheme(theme);
- ra.setLabel(aaf.getFacetDescription());
+ ra.setLabel(bundle.getFacetDescription());
generator.addAnnotations(ra);
}
@Override
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aaf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index)
@@ -64,14 +64,14 @@
return;
}
CallContext context = generator.getCallContext();
- if (!(aaf.getData(context) instanceof RiverAnnotation)) {
+ if (!(bundle.getData(context) instanceof RiverAnnotation)) {
// Just a bit defensive should not happen
logger.error("Incompatible facet in doOut");
return;
}
- RiverAnnotation ra = (RiverAnnotation)aaf.getData(context);
+ RiverAnnotation ra = (RiverAnnotation)bundle.getData(context);
ra.setTheme(theme);
- ra.setLabel(aaf.getFacetDescription());
+ ra.setLabel(bundle.getFacetDescription());
generator.addAnnotations(ra);
}
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffHeightYearProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -16,6 +16,7 @@
import org.dive4elements.river.artifacts.model.FacetTypes;
import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.exports.DiagramGenerator;
import org.dive4elements.river.exports.XYChartGenerator;
import org.dive4elements.river.jfree.StyledXYSeries;
import org.dive4elements.river.themes.ThemeDocument;
@@ -31,21 +32,43 @@
@Override
public void doOut(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible) {
+ CallContext context = generator.getCallContext();
+ Object data = bundle.getData(context);
+ if (data instanceof BedDiffYearResult) {
+ BedDiffYearResult bData = (BedDiffYearResult) data;
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+ StyledSeriesBuilder.addPoints(series, bData.getHeightPerYearData(), false, GAP_TOLERANCE);
+
+ generator.addAxisSeries(series, axisName, visible);
+ return;
+ }
+ // Should not happen if canHandle is correct
+ logger.error("Can't process " + data.getClass().getName() + " objects");
+ }
+
+ @Override
+ public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index
) {
CallContext context = generator.getCallContext();
- Object data = aandf.getData(context);
+ Object data = bundle.getData(context);
if (data instanceof BedDiffYearResult) {
- doBedDifferenceYearOut(
- generator,
- (BedDiffYearResult) data,
- aandf, theme, visible, index);
+ BedDiffYearResult bData = (BedDiffYearResult) data;
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+ StyledSeriesBuilder.addPoints(series, bData.getHeightPerYearData(), false, GAP_TOLERANCE);
+
+ generator.addAxisSeries(series, index, visible);
return;
}
+ // Should not happen if canHandle is correct
logger.error("Can't process " + data.getClass().getName() + " objects");
}
@@ -59,12 +82,12 @@
protected void doBedDifferenceYearOut(XYChartGenerator generator,
BedDiffYearResult data,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int axidx) {
- XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), false, GAP_TOLERANCE);
generator.addAxisSeries(series, axidx, visible);
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -32,22 +32,32 @@
@Override
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int axidx
) {
CallContext context = generator.getCallContext();
- Object data = aandf.getData(context);
+ Object data = bundle.getData(context);
if (data instanceof BedDiffYearResult) {
- String facetType = aandf.getFacetName();
- int index =
- (BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)
- || BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType))?0:1;
- doBedDifferenceHeightsOut(
- generator,
- (BedDiffYearResult) data,
- aandf, theme, visible, index, axidx);
+ String facetType = bundle.getFacetName();
+ BedDiffYearResult bData = (BedDiffYearResult) data;
+
+ double[][] points;
+ if (BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)) {
+ points = bData.getHeights1Data();
+ } else {
+ points = bData.getHeights2Data();
+ }
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+ StyledSeriesBuilder.addPointsFactorY(series,
+ points,
+ false,
+ GAP_TOLERANCE,
+ 100d);
+
+ generator.addAxisSeries(series, axidx, visible);
+
return;
}
logger.error("Can't process " + data.getClass().getName() + " objects");
@@ -61,33 +71,5 @@
|| BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType)
|| BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED.equals(facetType);
}
-
- private void doBedDifferenceHeightsOut(
- XYChartGenerator generator,
- BedDiffYearResult data,
- ArtifactAndFacet bundle,
- ThemeDocument attr,
- boolean visible,
- int idx,
- int axidx) {
- logger.debug("doBedDifferenceHeightsOut()");
-
- XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr);
- double[][] points;
- if (idx == 0) {
- points = data.getHeights1Data();
- }
- else {
- points = data.getHeights2Data();
- }
-
- StyledSeriesBuilder.addPointsFactorY(series,
- points,
- false,
- GAP_TOLERANCE,
- 100d);
-
- generator.addAxisSeries(series, axidx, visible);
- }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -31,30 +31,30 @@
@Override
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index
) {
CallContext context = generator.getCallContext();
- Object data = aandf.getData(context);
+ Object data = bundle.getData(context);
if (data instanceof BedHeightSingle) {
- doBedheightSingleOut(generator, aandf, theme, index, visible,
+ doBedheightSingleOut(generator, bundle, theme, index, visible,
(BedHeightSingle)data);
}
else if (data instanceof List<?>) {
- doBedheightSingeValuesOut(generator, aandf, theme, index, visible,
+ doBedheightSingeValuesOut(generator, bundle, theme, index, visible,
(List<BedHeightSingleValue>)data);
}
logger.error("Can't process " + data.getClass().getName() + " objects");
}
private void doBedheightSingeValuesOut(XYChartGenerator generator,
- ArtifactAndFacet aandf, ThemeDocument theme, int index, boolean visible,
+ ArtifactAndFacet bundle, ThemeDocument theme, int index, boolean visible,
List<BedHeightSingleValue> data) {
logger.debug("doBedheightSingeValuesOut");
- XYSeries series = new StyledXYSeries(aandf.getFacetDescription(),
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
theme);
for(BedHeightSingleValue bvalue: data) {
series.add(bvalue.getStation(), bvalue.getSoundingWidth());
@@ -68,14 +68,14 @@
}
public void doBedheightSingleOut(XYChartGenerator generator,
- ArtifactAndFacet aandf, ThemeDocument theme, int index, boolean visible,
+ ArtifactAndFacet bundle, ThemeDocument theme, int index, boolean visible,
BedHeightSingle data) {
double[] width = data.getMorphWidths();
double[] stations = data.getStations().toNativeArray();
logger.debug("doBedheightSingleOut");
- XYSeries series = new StyledXYSeries(aandf.getFacetDescription(),
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
theme);
for (int i = 0; i < width.length; i++) {
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DefaultProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -31,7 +31,7 @@
* Processes data to generate e.g. a chart.
*
* @param generator XYChartGenerator to add output on.
- * @param aandf The artifact and facet
+ * @param bundle The artifact and facet
* @param theme The theme that contains styling information.
* @param visible The visibility of the curve.
* @param index The index of the curve
@@ -39,7 +39,7 @@
@Override
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index) {
@@ -49,7 +49,7 @@
@Override
public void doOut(
DiagramGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible) {
return;
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -58,32 +58,32 @@
@Override
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int axisIndex
) {
CallContext context = generator.getCallContext();
- Object data = aandf.getData(context);
+ Object data = bundle.getData(context);
if (false && data instanceof WQKms) {
doWQKmsPointOut(
- generator, (WQKms) data, aandf, theme, visible, axisIndex);
+ generator, (WQKms) data, bundle, theme, visible, axisIndex);
return;
}
else if (data instanceof RiverAnnotation) {
doRiverAnnotationOut(
- generator, (RiverAnnotation) data, aandf, theme, visible);
+ generator, (RiverAnnotation) data, bundle, theme, visible);
return;
}
else if (data instanceof double[][]) {
doMarksOut(
- generator, (double[][]) data, aandf, theme, visible);
+ generator, (double[][]) data, bundle, theme, visible);
return;
}
else {
logger.error("Can't process "
+ data.getClass().getName() + " objects of facet "
- + aandf.getFacetName());
+ + bundle.getFacetName());
}
}
@@ -109,13 +109,13 @@
/** Handle WQKms data by finding w/q values at given km. */
protected void doWQKmsPointOut(XYChartGenerator generator,
WQKms wqkms,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int axidx
) {
logger.debug("doWQKmsPointOut");
- String title = aandf.getFacetDescription();
+ String title = bundle.getFacetDescription();
XYSeries series = new StyledXYSeries(
title,
theme);
@@ -147,7 +147,7 @@
protected void doRiverAnnotationOut(XYChartGenerator generator,
RiverAnnotation annotations,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible
) {
@@ -163,7 +163,7 @@
dGenerator.translateRiverAnnotation(annotations);
dGenerator.doAnnotations(
annotations,
- aandf, theme, visible);
+ bundle, theme, visible);
}
@@ -173,7 +173,7 @@
*/
protected void doMarksOut(XYChartGenerator generator,
double[][] data,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible
) {
@@ -184,7 +184,7 @@
}
// TODO subtract gauge null point if at gauge.
- String title = aandf.getFacetDescription();
+ String title = bundle.getFacetDescription();
List<StickyAxisAnnotation> yMarks = new ArrayList<StickyAxisAnnotation>();
for (double yPos: data[1]) {
@@ -195,7 +195,7 @@
}
generator.doAnnotations(new RiverAnnotation(title, yMarks),
- aandf, theme, visible);
+ bundle, theme, visible);
}
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -27,17 +27,17 @@
private static final Logger logger = Logger.getLogger(KMIndexProcessor.class);
@Override
- public void doOut(XYChartGenerator generator, ArtifactAndFacet aandf,
+ public void doOut(XYChartGenerator generator, ArtifactAndFacet bundle,
ThemeDocument theme, boolean visible, int index) {
- String facettype = aandf.getFacetName();
+ String facettype = bundle.getFacetName();
if (facettype.contains(FacetTypes.FIX_SECTOR_AVERAGE_LS)) {
- doSectorAverageOut(generator, aandf, theme, visible, index);
+ doSectorAverageOut(generator, bundle, theme, visible, index);
}
else if (facettype.equals(FacetTypes.FIX_REFERENCE_EVENTS_LS)) {
- doReferenceEventsOut(generator, aandf, theme, visible, index);
+ doReferenceEventsOut(generator, bundle, theme, visible, index);
}
else if (facettype.equals(FacetTypes.FIX_ANALYSIS_EVENTS_LS)) {
- doAnalysisEventsOut(generator, aandf, theme, visible, index);
+ doAnalysisEventsOut(generator, bundle, theme, visible, index);
}
}
@@ -57,23 +57,23 @@
return false;
}
- private void doSectorAverageOut(XYChartGenerator generator, ArtifactAndFacet aaf,
+ private void doSectorAverageOut(XYChartGenerator generator, ArtifactAndFacet bundle,
ThemeDocument doc, boolean visible, int idx) {
- logger.debug("doSectorAverageOut" + aaf.getFacet().getIndex());
+ logger.debug("doSectorAverageOut" + bundle.getFacet().getIndex());
CallContext context = generator.getCallContext();
- int index = aaf.getFacet().getIndex();
+ int index = bundle.getFacet().getIndex();
int sectorNdx = index & 3;
@SuppressWarnings("unchecked")
KMIndex<AnalysisPeriod> kms =
- (KMIndex<AnalysisPeriod>)aaf.getData(context);
+ (KMIndex<AnalysisPeriod>)bundle.getData(context);
if(kms == null) {
return;
}
- XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), doc);
for (KMIndex.Entry<AnalysisPeriod> entry: kms) {
double km = entry.getKm();
@@ -90,14 +90,14 @@
}
private void doReferenceEventsOut(XYChartGenerator generator,
- ArtifactAndFacet aaf, ThemeDocument doc, boolean visible, int idx) {
+ ArtifactAndFacet bundle, ThemeDocument doc, boolean visible, int idx) {
logger.debug("doReferenceEventOut");
CallContext context = generator.getCallContext();
@SuppressWarnings("unchecked")
KMIndex<QWD> kms =
- (KMIndex<QWD>)aaf.getData(context);
+ (KMIndex<QWD>)bundle.getData(context);
if(kms == null) {
return;
@@ -105,7 +105,7 @@
XYSeriesCollection col = new XYSeriesCollection();
- StyledXYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false,
+ StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false,
doc);
for (KMIndex.Entry<QWD> entry: kms) {
@@ -120,14 +120,14 @@
}
private void doAnalysisEventsOut(XYChartGenerator generator,
- ArtifactAndFacet aaf, ThemeDocument doc, boolean visible, int idx) {
+ ArtifactAndFacet bundle, ThemeDocument doc, boolean visible, int idx) {
logger.debug("doAnalysisEventsOut");
CallContext context = generator.getCallContext();
@SuppressWarnings("unchecked")
KMIndex<QWD> kms =
- (KMIndex<QWD>)aaf.getData(context);
+ (KMIndex<QWD>)bundle.getData(context);
if(kms == null) {
return;
@@ -135,7 +135,7 @@
XYSeriesCollection col = new XYSeriesCollection();
- StyledXYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false, doc);
+ StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false, doc);
for (KMIndex.Entry<QWD> entry: kms) {
double km = entry.getKm();
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/Processor.java Fri Sep 20 16:25:43 2013 +0200
@@ -39,13 +39,13 @@
* Processes data to generate e.g. a chart.
*
* @param generator XYChartGenerator to add output on.
- * @param aandf The artifact and facet
+ * @param bundle The artifact and facet
* @param theme The theme that contains styling information.
* @param visible The visibility of the curve.
*/
public void doOut(
DiagramGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible);
@@ -53,7 +53,7 @@
* Processes data to generate e.g. a chart.
*
* @param generator DiagramGenerator to add output on.
- * @param aandf The artifact and facet
+ * @param bundle The artifact and facet
* @param theme The theme that contains styling information.
* @param visible The visibility of the curve.
* @param index The index of the curve
@@ -61,7 +61,7 @@
@Deprecated
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aandf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index);
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -19,6 +19,7 @@
import org.dive4elements.river.exports.StyledSeriesBuilder;
import org.dive4elements.river.exports.XYChartGenerator;
+import org.dive4elements.river.exports.DiagramGenerator;
import org.dive4elements.river.jfree.StyledXYSeries;
import org.dive4elements.river.themes.ThemeDocument;
import org.dive4elements.river.utils.DataUtil;
@@ -36,16 +37,40 @@
@Override
public void doOut(
+ DiagramGenerator generator,
+ ArtifactAndFacet bundle,
+ ThemeDocument theme,
+ boolean visible) {
+ CallContext context = generator.getCallContext();
+ WQKms wqkms = (WQKms) bundle.getData(context);
+
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+
+ StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
+
+ generator.addAxisSeries(series, axisName, visible);
+
+ generator.handleLTRWaterFlowInversion(wqkms);
+ }
+
+ @Override
+ public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aaf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index)
{
CallContext context = generator.getCallContext();
- WQKms wqkms = (WQKms) aaf.getData(context);
+ WQKms wqkms = (WQKms) bundle.getData(context);
- doQOut(generator, wqkms, aaf, theme, visible, index);
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
+
+ StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
+
+ generator.addAxisSeries(series, index, visible);
+
+ invertAxis(generator, wqkms);
}
/**
@@ -65,38 +90,6 @@
return false;
}
-
- /**
- * Process the output for Q facets in a longitudinal section curve.
- *
- * @param generator Generator to use.
- * @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.
- * @param index Axis index to add data to.
- */
- protected void doQOut(
- XYChartGenerator generator,
- WQKms wqkms,
- ArtifactAndFacet aaf,
- ThemeDocument theme,
- boolean visible,
- int index
- ) {
- logger.debug("QProcessor.doOut");
-
- XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
-
- StyledSeriesBuilder.addStepPointsKmQ(series, wqkms);
-
- generator.addAxisSeries(series, index, visible);
-
- invertAxis(generator, wqkms);
- }
-
/**
* This method determines - taking JFreeCharts auto x value ordering into
* account - if the x axis need to be inverted. Waterlines in these charts
diff -r a2abd87c0d3b -r 253d80af5b7f artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java Fri Sep 20 15:44:39 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java Fri Sep 20 16:25:43 2013 +0200
@@ -37,15 +37,15 @@
@Override
public void doOut(
DiagramGenerator generator,
- ArtifactAndFacet aaf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible) {
CallContext context = generator.getCallContext();
- WKms wkms = (WKms) aaf.getData(context);
+ WKms wkms = (WKms) bundle.getData(context);
logger.debug("doOut");
- XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
StyledSeriesBuilder.addPoints(series, wkms);
generator.addAxisSeries(series, axisName, visible);
@@ -54,9 +54,9 @@
double bandWidth = theme.parseBandWidth();
if (bandWidth > 0 ) {
XYSeries seriesDown = new StyledXYSeries(
- "band " + aaf.getFacetDescription(), false, theme);
+ "band " + bundle.getFacetDescription(), false, theme);
XYSeries seriesUp = new StyledXYSeries(
- aaf.getFacetDescription()+"+/-"+bandWidth, false, theme);
+ bundle.getFacetDescription()+"+/-"+bandWidth, false, theme);
StyledSeriesBuilder.addUpperBand(seriesUp, wkms, bandWidth);
StyledSeriesBuilder.addLowerBand(seriesDown, wkms, bandWidth);
@@ -67,29 +67,29 @@
generator.addAreaSeries(area, axisName, visible);
}
- if (aaf.getFacetName().equals(FacetTypes.LONGITUDINAL_W) ||
- aaf.getFacetName().equals(FacetTypes.DISCHARGE_LONGITUDINAL_W) ||
- aaf.getFacetName().equals(FacetTypes.STATIC_WQKMS_W)) {
+ if (bundle.getFacetName().equals(FacetTypes.LONGITUDINAL_W) ||
+ bundle.getFacetName().equals(FacetTypes.DISCHARGE_LONGITUDINAL_W) ||
+ bundle.getFacetName().equals(FacetTypes.STATIC_WQKMS_W)) {
/* Only use W values to check if the diagram should be inverted
* see flys/issue1290 for details */
- invertAxis(generator, wkms);
+ generator.handleLTRWaterFlowInversion(wkms);
}
}
@Override
public void doOut(
XYChartGenerator generator,
- ArtifactAndFacet aaf,
+ ArtifactAndFacet bundle,
ThemeDocument theme,
boolean visible,
int index)
{
CallContext context = generator.getCallContext();
- WKms wkms = (WKms) aaf.getData(context);
+ WKms wkms = (WKms) bundle.getData(context);
logger.debug("doOut");
- XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
+ XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
StyledSeriesBuilder.addPoints(series, wkms);
generator.addAxisSeries(series, index, visible);
@@ -98,9 +98,9 @@
double bandWidth = theme.parseBandWidth();
if (bandWidth > 0 ) {
XYSeries seriesDown = new StyledXYSeries(
- "band " + aaf.getFacetDescription(), false, theme);
+ "band " + bundle.getFacetDescription(), false, theme);
XYSeries seriesUp = new StyledXYSeries(
- aaf.getFacetDescription()+"+/-"+bandWidth, false, theme);
+ bundle.getFacetDescription()+"+/-"+bandWidth, false, theme);
StyledSeriesBuilder.addUpperBand(seriesUp, wkms, bandWidth);
StyledSeriesBuilder.addLowerBand(seriesDown, wkms, bandWidth);
@@ -111,9 +111,9 @@
generator.addAreaSeries(area, index, visible);
}
- if (aaf.getFacetName().equals(FacetTypes.LONGITUDINAL_W) ||
- aaf.getFacetName().equals(FacetTypes.DISCHARGE_LONGITUDINAL_W) ||
- aaf.getFacetName().equals(FacetTypes.STATIC_WQKMS_W)) {
+ if (bundle.getFacetName().equals(FacetTypes.LONGITUDINAL_W) ||
+ bundle.getFacetName().equals(FacetTypes.DISCHARGE_LONGITUDINAL_W) ||
+ bundle.getFacetName().equals(FacetTypes.STATIC_WQKMS_W)) {
/* Only use W values to check if the diagram should be inverted
* see flys/issue1290 for details */
invertAxis(generator, wkms);
@@ -171,26 +171,5 @@
}
generator.setInverted(inv);
}
- public void invertAxis(DiagramGenerator generator, WKms wkms) {
- boolean wsUp = wkms.guessWaterIncreasing();
- boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms());
- int size = wkms.size();
- boolean inv = ((wsUp && kmUp) || (!wsUp && !kmUp)) && size > 1;
-
- 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);
- if (size == 1) {
- logger.debug("InvertAxis not inverting because we have just one km");
- }
- logger.debug("inv: " + inv);
- }
- generator.setInverted(inv);
- }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list