Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Mon Oct 22 18:26:05 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Tue Oct 23 16:26:48 2018 +0200 @@ -170,8 +170,9 @@ adjustPlot(plot); //debugAxis(plot); + final LegendAggregator legendBuilder = createLegendBuilder(); - addDatasets(plot); + addDatasets(plot, legendBuilder); //debugDatasets(plot); @@ -199,13 +200,13 @@ //debugAxis(plot); // These have to go after the autozoom. - addAnnotationsToRenderer(plot); - addYAnnotationsToRenderer(plot); + addAnnotationsToRenderer(plot, legendBuilder); + addYAnnotationsToRenderer(plot, legendBuilder); // Add a logo (maybe). addLogo(plot); - aggregateLegendEntries(plot); + legendBuilder.apply( context, plot ); /* allow extenders to do some work */ final Collection<ChartExtender> extenders = this.diagramAttributes.getExtenders(); @@ -383,14 +384,6 @@ return ((XYSeriesCollection) dataset).getSeries(idx); } - - @Override - protected AxisDataset createAxisDataset(int idx) { - log.debug("Create new AxisDataset for index: " + idx); - return new AxisDataset(idx); - } - - /** * Put debug output about datasets. */ @@ -961,50 +954,11 @@ ((NumberAxis) rangeAxis).setNumberFormatOverride(nf); } - - /** - * Create a hash from a legenditem. - * This hash can then be used to merge legend items labels. - * @return hash for given legenditem to identify mergeables. - */ - public static String legendItemHash(LegendItem li) { - // TODO Do proper implementation. - // Ensure that only mergable sets are created. - // getFillPaint() - // getFillPaintTransformer() - // getLabel() - // getLine() - // getLinePaint() - // getLineStroke() - // getOutlinePaint() - // getOutlineStroke() - // Shape getShape() - // String getToolTipText() - // String getURLText() - // boolean isLineVisible() - // boolean isShapeFilled() - // boolean isShapeOutlineVisible() - // boolean isShapeVisible() - 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; - } - /** True if x axis has been inverted. */ public boolean isInverted() { return inverted; } - /** Set to true if x axis should be inverted. * This can not be set to false afterwards. */ public void setInverted(boolean value) {