Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/LegendProcessor.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | fe32a7f9655e |
children | d8e753d0fdb9 |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
36 * Create a hash from a legenditem. | 36 * Create a hash from a legenditem. |
37 * This hash can then be used to merge legend items labels. | 37 * This hash can then be used to merge legend items labels. |
38 * @return hash for given legenditem to identify mergeables. | 38 * @return hash for given legenditem to identify mergeables. |
39 */ | 39 */ |
40 protected static String legendItemHash(LegendItem li) { | 40 protected static String legendItemHash(LegendItem li) { |
41 // TODO Do proper implementation. Ensure that only mergable sets are created. | 41 // TODO Do proper implementation. |
42 // Ensure that only mergable sets are created. | |
42 // getFillPaint() | 43 // getFillPaint() |
43 // getFillPaintTransformer() | 44 // getFillPaintTransformer() |
44 // getLabel() | 45 // getLabel() |
45 // getLine() | 46 // getLine() |
46 // getLinePaint() | 47 // getLinePaint() |
84 | 85 |
85 if (AGGR_THRESHOLD > old.getItemCount() || AGGR_THRESHOLD <= 0){ | 86 if (AGGR_THRESHOLD > old.getItemCount() || AGGR_THRESHOLD <= 0){ |
86 return; | 87 return; |
87 } | 88 } |
88 | 89 |
89 HashMap<String, List<LegendItem>> entries = new LinkedHashMap<String, List<LegendItem>>(); | 90 HashMap<String, List<LegendItem>> entries = |
91 new LinkedHashMap<String, List<LegendItem>>(); | |
90 for (Iterator<LegendItem> i = old.iterator(); i.hasNext();) { | 92 for (Iterator<LegendItem> i = old.iterator(); i.hasNext();) { |
91 LegendItem item = i.next(); | 93 LegendItem item = i.next(); |
92 String hash = legendItemHash(item); | 94 String hash = legendItemHash(item); |
93 List<LegendItem> itemList = entries.get(hash); | 95 List<LegendItem> itemList = entries.get(hash); |
94 if (itemList == null) { | 96 if (itemList == null) { |
112 LegendItemCollection newLegend = new LegendItemCollection(); | 114 LegendItemCollection newLegend = new LegendItemCollection(); |
113 for (List<LegendItem> itemList: entries.values()) { | 115 for (List<LegendItem> itemList: entries.values()) { |
114 if (itemList.size() >= AGGR_THRESHOLD) { | 116 if (itemList.size() >= AGGR_THRESHOLD) { |
115 // Now do merging. | 117 // Now do merging. |
116 // XXX: DEAD CODE // LegendItem item = itemList.get(0); | 118 // XXX: DEAD CODE // LegendItem item = itemList.get(0); |
117 // Unfortunately we cannot clone and just setDescription, as this | 119 // Unfortunately we cannot clone and just setDescription, |
118 // method was added in JFreeChart 1.0.14 (we are at .13). | 120 // as this method was added in JFreeChart 1.0.14 |
121 // (we are at .13). | |
119 | 122 |
120 // Remove the shapes of all but the first items, | 123 // Remove the shapes of all but the first items, |
121 // to prevent "overfill" of legenditemblock. | 124 // to prevent "overfill" of legenditemblock. |
122 for (int i = 0, I = itemList.size(); i < I; i++) { | 125 for (int i = 0, I = itemList.size(); i < I; i++) { |
123 if (i != 0) { | 126 if (i != 0) { |
124 LegendItem litem = itemList.get(i); | 127 LegendItem litem = itemList.get(i); |
125 | 128 |
126 // Make shape and line really small. | 129 // Make shape and line really small. |
127 LegendItem merged = new LegendItem( | 130 LegendItem merged = new LegendItem( |
128 "," + litem.getLabel(), litem.getDescription(), litem.getToolTipText(), | 131 "," + litem.getLabel(), |
129 litem.getURLText(), false, SPACE, | 132 litem.getDescription(), |
130 false, litem.getFillPaint(), false, | 133 litem.getToolTipText(), |
131 litem.getOutlinePaint(), litem.getOutlineStroke(), false, | 134 litem.getURLText(), |
132 SPACE, litem.getLineStroke(), litem.getLinePaint()); | 135 false, |
136 SPACE, | |
137 false, | |
138 litem.getFillPaint(), | |
139 false, | |
140 litem.getOutlinePaint(), | |
141 litem.getOutlineStroke(), | |
142 false, | |
143 SPACE, | |
144 litem.getLineStroke(), | |
145 litem.getLinePaint()); | |
133 newLegend.add(merged); | 146 newLegend.add(merged); |
134 } | 147 } |
135 else { | 148 else { |
136 newLegend.add(itemList.get(i)); | 149 newLegend.add(itemList.get(i)); |
137 } | 150 } |