# HG changeset patch # User Christian Lins # Date 1343036232 0 # Node ID b9aff8d6ff741638631515f9c25749cce526a413 # Parent e111902834d335200bde932d46b8e91f0495a078 Simplify annotation code flys-artifacts/trunk@5101 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e111902834d3 -r b9aff8d6ff74 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Jul 23 09:09:49 2012 +0000 +++ b/flys-artifacts/ChangeLog Mon Jul 23 09:37:12 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-23 Christian Lins + + * src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java: + Simplify annotation code. + 2012-07-22 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java: diff -r e111902834d3 -r b9aff8d6ff74 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java Mon Jul 23 09:09:49 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDeltaWtGenerator.java Mon Jul 23 09:37:12 2012 +0000 @@ -247,18 +247,24 @@ logger.debug("doAnalysisEventsOut: desc = " + desc); QWD[] qwds = (QWD[]) data; + doQWDEventsOut(qwds, desc, theme, visible); + } + + + protected void doQWDEventsOut(QWD[] qwds, String desc, Document theme, boolean visible) + { TimeSeriesCollection tsc = new TimeSeriesCollection(); TimeSeries series = new StyledTimeSeries(desc, theme); TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme); if (qwds == null) { - logger.debug("doAnalysisEventsOut: qwds == null"); + logger.debug("doQWDEventsOut: qwds == null"); return; } if (qwds.length == 0) { - logger.debug("doAnalysisEventsOut: qwds.length == 0"); + logger.debug("doQWDEventsOut: qwds.length == 0"); return; } @@ -268,96 +274,7 @@ int idxRegular = 0; for (int i = 0; i < qwds.length; i++) { if (qwds[i] == null) { - logger.debug("doAnalysisEventsOut: qwds[" + i + "] == null"); - continue; - } - RegularTimePeriod rtp = new Day(qwds[i].getDate()); - double value = qwds[i].getDeltaW(); - boolean interpolate = qwds[i].getInterpolated(); - if (interpolate) { - interpol.add(rtp, value); - annoIdxMap.put( - i, - new int[]{1, idxInterpol++}); - } - else { - series.add(rtp, value); - annoIdxMap.put( - i, - new int[]{0, idxRegular++}); - } - } - tsc.addSeries(series); - tsc.addSeries(interpol); - addAxisDataset(tsc, 0, visible); - addAttribute(desc + "interpol", "interpolate"); - addAttribute(desc, "outline"); - - if (visible) { - doQWDTextAnnotations(annoIdxMap, tsc, qwds, theme, visible); - } - } - - - /** - * @param annoIdxMap map of index in qwds to series/dataitem indices in tsc. - */ - protected void doQWDTextAnnotations(Map annoIdxMap, - TimeSeriesCollection tsc, QWD[] qwds, Document theme, - boolean visible) { - logger.debug("doQWDTextAnnotation()"); - - if (!visible || !ThemeUtil.parseShowPointLabel(theme)) { - logger.debug("doQWDTextAnnotation: annotation not visible"); - return; - } - - List textAnnos = new ArrayList(); - Set> entries = annoIdxMap.entrySet(); - - for(Map.Entry entry : entries) { - QWD qwd = qwds[entry.getKey()]; - int[] idxs = entry.getValue(); - double x = tsc.getXValue(idxs[0], idxs[1]); - XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( - qwd.getQ() + " m\u00B3/s", - x, - qwd.getDeltaW()); - textAnnos.add(anno); - logger.debug("annotation: " + x + "/" + qwd.getDeltaW()); - } - - FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, theme); - flysAnno.setTextAnnotations(textAnnos); - addAnnotations(flysAnno); - } - - - protected void doReferenceEventsOut( - FLYSArtifact artifact, - Object data, - String desc, - Document theme, - boolean visible - ) { - logger.debug("doReferenceEventsOut: desc = " + desc); - - QWD[] qwds = (QWD[]) data; - TimeSeriesCollection tsc = new TimeSeriesCollection(); - - TimeSeries series = new StyledTimeSeries(desc, theme); - TimeSeries interpol = new StyledTimeSeries(desc + "interpol", theme); - - if (qwds == null) { - return; - } - - Map annoIdxMap = new HashMap(); - - int idxInterpol = 0; - int idxRegular = 0; - for (int i = 0; i < qwds.length; i++) { - if (qwds[i] == null) { + logger.debug("doQWDEventsOut: qwds[" + i + "] == null"); continue; } RegularTimePeriod rtp = new Day(qwds[i].getDate()); @@ -382,7 +299,6 @@ } tsc.addSeries(series); tsc.addSeries(interpol); - addAxisDataset(tsc, 0, visible); addAttribute(desc + "interpol", "interpolate"); addAttribute(desc, "outline"); @@ -391,6 +307,53 @@ } + /** + * @param annoIdxMap map of index in qwds to series/data item indices in tsc. + */ + protected void doQWDTextAnnotations(Map annoIdxMap, + TimeSeriesCollection tsc, QWD[] qwds, Document theme, + boolean visible) { + logger.debug("doQWDTextAnnotation()"); + + if (!visible || !ThemeUtil.parseShowPointLabel(theme)) { + logger.debug("doQWDTextAnnotation: annotation not visible"); + return; + } + + List textAnnos = new ArrayList(); + Set> entries = annoIdxMap.entrySet(); + + for(Map.Entry entry : entries) { + QWD qwd = qwds[entry.getKey()]; + int[] idxs = entry.getValue(); + double x = tsc.getXValue(idxs[0], idxs[1]); + XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( + qwd.getQ() + " m\u00B3/s", + x, + qwd.getDeltaW()); + textAnnos.add(anno); + } + + FLYSAnnotation flysAnno = new FLYSAnnotation(null, null, null, theme); + flysAnno.setTextAnnotations(textAnnos); + addAnnotations(flysAnno); + } + + + protected void doReferenceEventsOut( + FLYSArtifact artifact, + Object data, + String desc, + Document theme, + boolean visible + ) { + logger.debug("doReferenceEventsOut: desc = " + desc); + + QWD[] qwds = (QWD[]) data; + doQWDEventsOut(qwds, desc, theme, visible); + } + + protected void doDeviationOut( FLYSArtifact artifact, Object data,