# HG changeset patch # User Felix Wolfsteller # Date 1337199809 0 # Node ID fa8ae7dbcb72239f67283179e8b6193cf00a4c50 # Parent 013882485011efb4992b18f38e3abbe10bc6ea19 More stable legend item aggregation. flys-artifacts/trunk@4433 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 013882485011 -r fa8ae7dbcb72 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed May 16 20:17:24 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed May 16 20:23:29 2012 +0000 @@ -1,3 +1,8 @@ +2012-05-16 Felix Wolfsteller + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + Stabilized legend item aggregation. + 2012-05-16 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: diff -r 013882485011 -r fa8ae7dbcb72 flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Wed May 16 20:17:24 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Wed May 16 20:23:29 2012 +0000 @@ -1097,7 +1097,18 @@ // boolean isShapeFilled() // boolean isShapeOutlineVisible() // boolean isShapeVisible() - return li.getLinePaint().toString(); + String hash = li.getLinePaint().toString(); + String label = li.getLabel(); + if (label.startsWith("W (") || label.startsWith("W(")) { + hash += "-W-"; + } + else if (label.startsWith("Q(") || label.startsWith("Q (")) { + hash += "-Q-"; + } + + // WQ.java holds example of using regex Matcher/Pattern. + + return hash; } @@ -1150,8 +1161,17 @@ else { first = false; } - name += item.getLabel().substring(startPattern.length(), - item.getLabel().length() - endPattern.length()); + // Possible case in differences + if (startPattern.length() + endPattern.length() < item.getLabel().length()) { + // Note that we do not really want this. + logger.error("Legend aggregation does not cover case: " + + startPattern + " -- " + item.getLabel() + " -- " + endPattern); + name += item.getLabel(); + } + else { + name += item.getLabel().substring(startPattern.length(), + item.getLabel().length() - endPattern.length()); + } } name += "} "; name += endPattern;