Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/LegendProcessor.java @ 4046:ca208b2f35a0
LegendProcessor: avoid redundant hashing. removed dead code.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sat, 06 Oct 2012 10:38:41 +0200 |
parents | 7cc05da7e35c |
children | 3dc26ec2558d |
comparison
equal
deleted
inserted
replaced
4045:de6e2b933f33 | 4046:ca208b2f35a0 |
---|---|
46 // boolean isLineVisible() | 46 // boolean isLineVisible() |
47 // boolean isShapeFilled() | 47 // boolean isShapeFilled() |
48 // boolean isShapeOutlineVisible() | 48 // boolean isShapeOutlineVisible() |
49 // boolean isShapeVisible() | 49 // boolean isShapeVisible() |
50 String hash = li.getLinePaint().toString(); | 50 String hash = li.getLinePaint().toString(); |
51 String label = li.getLabel(); | 51 // XXX: DEAD CODE // String label = li.getLabel(); |
52 /*if (label.startsWith("W (") || label.startsWith("W(")) { | 52 /*if (label.startsWith("W (") || label.startsWith("W(")) { |
53 hash += "-W-"; | 53 hash += "-W-"; |
54 } | 54 } |
55 else if (label.startsWith("Q(") || label.startsWith("Q (")) { | 55 else if (label.startsWith("Q(") || label.startsWith("Q (")) { |
56 hash += "-Q-"; | 56 hash += "-Q-"; |
84 LegendItem item = i.next(); | 84 LegendItem item = i.next(); |
85 String hash = legendItemHash(item); | 85 String hash = legendItemHash(item); |
86 List<LegendItem> itemList = entries.get(hash); | 86 List<LegendItem> itemList = entries.get(hash); |
87 if (itemList == null) { | 87 if (itemList == null) { |
88 itemList = new ArrayList<LegendItem>(); | 88 itemList = new ArrayList<LegendItem>(); |
89 entries.put(hash, itemList); | |
89 } | 90 } |
90 itemList.add(item); | 91 itemList.add(item); |
91 | 92 |
92 if (itemList.size() > maxListSize) { | 93 if (itemList.size() > maxListSize) { |
93 maxListSize = itemList.size(); | 94 maxListSize = itemList.size(); |
94 } | 95 } |
95 | |
96 entries.put(legendItemHash(item), itemList); | |
97 } | 96 } |
98 | 97 |
99 if (maxListSize < AGGR_THRESHOLD) { | 98 if (maxListSize < AGGR_THRESHOLD) { |
100 // No need to do anything. | 99 // No need to do anything. |
101 return; | 100 return; |
102 } | 101 } |
103 | 102 |
104 // Run over collected entries, merge their names and create new | 103 // Run over collected entries, merge their names and create new |
105 // entry if needed. | 104 // entry if needed. |
106 LegendItemCollection newLegend = new LegendItemCollection(); | 105 LegendItemCollection newLegend = new LegendItemCollection(); |
107 for (Map.Entry<String, List<LegendItem>> cursor: entries.entrySet()) { | 106 for (List<LegendItem> itemList: entries.values()) { |
108 List<LegendItem> itemList = cursor.getValue(); | |
109 if (itemList.size() >= AGGR_THRESHOLD) { | 107 if (itemList.size() >= AGGR_THRESHOLD) { |
110 // Now do merging. | 108 // Now do merging. |
111 LegendItem item = itemList.get(0); | 109 // XXX: DEAD CODE // LegendItem item = itemList.get(0); |
112 // Unfortunately we cannot clone and just setDescription, as this | 110 // Unfortunately we cannot clone and just setDescription, as this |
113 // method was added in JFreeChart 1.0.14 (we are at .13). | 111 // method was added in JFreeChart 1.0.14 (we are at .13). |
114 | 112 |
115 // Remove the shapes of all but the first items, | 113 // Remove the shapes of all but the first items, |
116 // to prevent "overfill" of legenditemblock. | 114 // to prevent "overfill" of legenditemblock. |