Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java @ 9555:ef5754ba5573
Implemented legend aggregation based on type of themes.
Added theme-editor style configuration for aggregated legend entries.
Only configured themes get aggregated.
author | gernotbelger |
---|---|
date | Tue, 23 Oct 2018 16:26:48 +0200 |
parents | d8e753d0fdb9 |
children |
comparison
equal
deleted
inserted
replaced
9554:33ce8eba9806 | 9555:ef5754ba5573 |
---|---|
168 chart.setBackgroundPaint(Color.WHITE); | 168 chart.setBackgroundPaint(Color.WHITE); |
169 plot.setBackgroundPaint(Color.WHITE); | 169 plot.setBackgroundPaint(Color.WHITE); |
170 adjustPlot(plot); | 170 adjustPlot(plot); |
171 | 171 |
172 //debugAxis(plot); | 172 //debugAxis(plot); |
173 | 173 final LegendAggregator legendBuilder = createLegendBuilder(); |
174 addDatasets(plot); | 174 |
175 addDatasets(plot, legendBuilder); | |
175 | 176 |
176 //debugDatasets(plot); | 177 //debugDatasets(plot); |
177 | 178 |
178 addMarkers(plot); | 179 addMarkers(plot); |
179 | 180 |
197 } | 198 } |
198 | 199 |
199 //debugAxis(plot); | 200 //debugAxis(plot); |
200 | 201 |
201 // These have to go after the autozoom. | 202 // These have to go after the autozoom. |
202 addAnnotationsToRenderer(plot); | 203 addAnnotationsToRenderer(plot, legendBuilder); |
203 addYAnnotationsToRenderer(plot); | 204 addYAnnotationsToRenderer(plot, legendBuilder); |
204 | 205 |
205 // Add a logo (maybe). | 206 // Add a logo (maybe). |
206 addLogo(plot); | 207 addLogo(plot); |
207 | 208 |
208 aggregateLegendEntries(plot); | 209 legendBuilder.apply( context, plot ); |
209 | 210 |
210 /* allow extenders to do some work */ | 211 /* allow extenders to do some work */ |
211 final Collection<ChartExtender> extenders = this.diagramAttributes.getExtenders(); | 212 final Collection<ChartExtender> extenders = this.diagramAttributes.getExtenders(); |
212 for (final ChartExtender extender : extenders) { | 213 for (final ChartExtender extender : extenders) { |
213 extender.afterGenerateChart(this, plot); | 214 extender.afterGenerateChart(this, plot); |
381 @Override | 382 @Override |
382 protected Series getSeriesOf(XYDataset dataset, int idx) { | 383 protected Series getSeriesOf(XYDataset dataset, int idx) { |
383 return ((XYSeriesCollection) dataset).getSeries(idx); | 384 return ((XYSeriesCollection) dataset).getSeries(idx); |
384 } | 385 } |
385 | 386 |
386 | |
387 @Override | |
388 protected AxisDataset createAxisDataset(int idx) { | |
389 log.debug("Create new AxisDataset for index: " + idx); | |
390 return new AxisDataset(idx); | |
391 } | |
392 | |
393 | |
394 /** | 387 /** |
395 * Put debug output about datasets. | 388 * Put debug output about datasets. |
396 */ | 389 */ |
397 public void debugDatasets(XYPlot plot) { | 390 public void debugDatasets(XYPlot plot) { |
398 log.debug("Number of datasets: " + plot.getDatasetCount()); | 391 log.debug("Number of datasets: " + plot.getDatasetCount()); |
959 protected void localizeRangeAxis(ValueAxis rangeAxis) { | 952 protected void localizeRangeAxis(ValueAxis rangeAxis) { |
960 NumberFormat nf = NumberFormat.getInstance(getLocale()); | 953 NumberFormat nf = NumberFormat.getInstance(getLocale()); |
961 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf); | 954 ((NumberAxis) rangeAxis).setNumberFormatOverride(nf); |
962 } | 955 } |
963 | 956 |
964 | |
965 /** | |
966 * Create a hash from a legenditem. | |
967 * This hash can then be used to merge legend items labels. | |
968 * @return hash for given legenditem to identify mergeables. | |
969 */ | |
970 public static String legendItemHash(LegendItem li) { | |
971 // TODO Do proper implementation. | |
972 // Ensure that only mergable sets are created. | |
973 // getFillPaint() | |
974 // getFillPaintTransformer() | |
975 // getLabel() | |
976 // getLine() | |
977 // getLinePaint() | |
978 // getLineStroke() | |
979 // getOutlinePaint() | |
980 // getOutlineStroke() | |
981 // Shape getShape() | |
982 // String getToolTipText() | |
983 // String getURLText() | |
984 // boolean isLineVisible() | |
985 // boolean isShapeFilled() | |
986 // boolean isShapeOutlineVisible() | |
987 // boolean isShapeVisible() | |
988 String hash = li.getLinePaint().toString(); | |
989 String label = li.getLabel(); | |
990 if (label.startsWith("W (") || label.startsWith("W(")) { | |
991 hash += "-W-"; | |
992 } | |
993 else if (label.startsWith("Q(") || label.startsWith("Q (")) { | |
994 hash += "-Q-"; | |
995 } | |
996 | |
997 // WQ.java holds example of using regex Matcher/Pattern. | |
998 | |
999 return hash; | |
1000 } | |
1001 | |
1002 /** True if x axis has been inverted. */ | 957 /** True if x axis has been inverted. */ |
1003 public boolean isInverted() { | 958 public boolean isInverted() { |
1004 return inverted; | 959 return inverted; |
1005 } | 960 } |
1006 | |
1007 | 961 |
1008 /** Set to true if x axis should be inverted. | 962 /** Set to true if x axis should be inverted. |
1009 * This can not be set to false afterwards. */ | 963 * This can not be set to false afterwards. */ |
1010 public void setInverted(boolean value) { | 964 public void setInverted(boolean value) { |
1011 /* One request to invert dominates. */ | 965 /* One request to invert dominates. */ |