# HG changeset patch # User Felix Wolfsteller # Date 1340475317 0 # Node ID a08538e21b555bc03072869539e95ba393708f03 # Parent 46b9391b122a3be540abac09a37fdecd20af0c2e Re-enable legend item aggregation. flys-artifacts/trunk@4766 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 46b9391b122a -r a08538e21b55 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sat Jun 23 14:31:02 2012 +0000 +++ b/flys-artifacts/ChangeLog Sat Jun 23 18:15:17 2012 +0000 @@ -1,3 +1,9 @@ +2012-06-23 Felix Wolfsteller + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + Re-enable legend entry aggregation, take the threshold from + settings. + 2012-06-23 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/ChartSettings.java: @@ -359,7 +365,6 @@ src/main/resources/messages_de.properties: Added i18n strings for chart titles and axes labels. ->>>>>>> .r4722 2012-06-19 Felix Wolfsteller Fix issue681 (wrong vertical lines in duration curve q-mainvalues on diff -r 46b9391b122a -r a08538e21b55 flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Sat Jun 23 14:31:02 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Sat Jun 23 18:15:17 2012 +0000 @@ -254,7 +254,7 @@ // These have to go after the autozoom. addAnnotationsToRenderer(plot); - //aggregateLegendEntries(plot); + aggregateLegendEntries(plot); return chart; } @@ -1357,7 +1357,16 @@ // Find "similar" entries if aggregation is enabled. int maxListSize = 0; - int AGGR_THRESHOLD = 2; + int AGGR_THRESHOLD = 0; + + Integer threshold = getChartSettings().getLegendSection() + .getAggregationThreshold(); + + AGGR_THRESHOLD = (threshold != null) ? threshold.intValue() : 0; + + if (AGGR_THRESHOLD > old.getItemCount() || AGGR_THRESHOLD <= 0){ + return; + } HashMap> entries = new LinkedHashMap>(); for (Iterator i = old.iterator(); i.hasNext();) { @@ -1387,22 +1396,24 @@ for (Map.Entry> cursor: entries.entrySet()) { List itemList = cursor.getValue(); if (itemList.size() >= AGGR_THRESHOLD) { - // TODO now do merging + // Now do merging. + LegendItem item = (LegendItem) itemList.get(0); + // Unfortunately we cannot clone and just setDescription, as this + // method was added in JFreeChart 1.0.14 (we are at .13). + LegendItem merged = new LegendItem( + mergeLegendNames(itemList), item.getDescription(), item.getToolTipText(), + item.getURLText(), item.isShapeVisible(), item.getShape(), + item.isShapeFilled(), item.getFillPaint(), item.isShapeOutlineVisible(), + item.getOutlinePaint(), item.getOutlineStroke(), item.isLineVisible(), + item.getLine(), item.getLineStroke(), item.getLinePaint()); + newLegend.add(merged); } else { - // TODO create singular new entry + // Do not merge entries. + for (LegendItem li: itemList) { + newLegend.add(li); + } } - - LegendItem item = (LegendItem) itemList.get(0); - // Unfortunately we cannot clone and just setDescription, as this - // method was added in JFreeChart 1.0.14 (we are at .13). - LegendItem merged = new LegendItem( - mergeLegendNames(itemList), item.getDescription(), item.getToolTipText(), - item.getURLText(), item.isShapeVisible(), item.getShape(), - item.isShapeFilled(), item.getFillPaint(), item.isShapeOutlineVisible(), - item.getOutlinePaint(), item.getOutlineStroke(), item.isLineVisible(), - item.getLine(), item.getLineStroke(), item.getLinePaint()); - newLegend.add(merged); } plot.setFixedLegendItems (newLegend);