# HG changeset patch # User gernotbelger # Date 1518628228 -3600 # Node ID e5f688820951171ceeff137fee2ad855ded28eae # Parent 7a8c127068340b73d2b8572bda7c5684c3bc6975 Some minor changes on chart: allow area-themes to consider range; allow for axis-margins diff -r 7a8c12706834 -r e5f688820951 artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Tue Feb 13 14:53:23 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator2.java Wed Feb 14 18:10:28 2018 +0100 @@ -1485,6 +1485,9 @@ axis.setAutoRangeIncludesZero(false); axis.setLabelFont(labelFont); axis.setTickLabelFont(labelFont); + // REMARK: we overwrite the default values to 0.0, because in earlier version margins were never applied. + axis.setLowerMargin(0); + axis.setUpperMargin(0); return axis; } diff -r 7a8c12706834 -r e5f688820951 artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Tue Feb 13 14:53:23 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Wed Feb 14 18:10:28 2018 +0100 @@ -392,7 +392,11 @@ if (logarithmic) { return new LogarithmicAxis(label); } - return new NumberAxis(label); + final NumberAxis axis = new NumberAxis(label); + // REMARK: we overwrite the default values to 0.0, because in earlier version margins were never applied. + axis.setLowerMargin(0); + axis.setUpperMargin(0); + return axis; } diff -r 7a8c12706834 -r e5f688820951 artifacts/src/main/java/org/dive4elements/river/jfree/AxisDataset.java --- a/artifacts/src/main/java/org/dive4elements/river/jfree/AxisDataset.java Tue Feb 13 14:53:23 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/AxisDataset.java Wed Feb 14 18:10:28 2018 +0100 @@ -71,10 +71,15 @@ for (XYDataset dataset: datasets) { Range newRange = null; if (dataset instanceof StyledAreaSeriesCollection) { - /* We do not include areas in the range calculation because - * they are used with very large / small values to draw areas - * with axis boundaries */ - continue; + final StyledAreaSeriesCollection areaSeries = (StyledAreaSeriesCollection) dataset; + if( areaSeries.shouldCalculateRange() ) + newRange = areaSeries.getRangeBounds(false); + else { + /* For most area themes, we do not include areas in the range calculation because + * they are used with very large / small values to draw areas + * with axis boundaries */ + continue; + } } else if (dataset instanceof RangeInfo) { /* The usual case for most series */ newRange = ((RangeInfo) dataset).getRangeBounds(false); diff -r 7a8c12706834 -r e5f688820951 artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java --- a/artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java Tue Feb 13 14:53:23 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/DoubleBounds.java Wed Feb 14 18:10:28 2018 +0100 @@ -51,7 +51,7 @@ @Override public void applyBounds(ValueAxis axis) { - axis.setRange(new Range(lower, upper)); + axis.setRangeWithMargins(new Range(lower, upper)); } @@ -67,7 +67,7 @@ axis.setRange(new Range(Math.max(lower-space, 0.0001), Math.max(upper+space, 0.0002))); } else { - axis.setRange(new Range(lower-space, upper+space)); + axis.setRangeWithMargins(new Range(lower-space, upper+space)); } } diff -r 7a8c12706834 -r e5f688820951 artifacts/src/main/java/org/dive4elements/river/jfree/StyledAreaSeriesCollection.java --- a/artifacts/src/main/java/org/dive4elements/river/jfree/StyledAreaSeriesCollection.java Tue Feb 13 14:53:23 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StyledAreaSeriesCollection.java Wed Feb 14 18:10:28 2018 +0100 @@ -27,14 +27,13 @@ private static final long serialVersionUID = 5274940965666948237L; /** Mode, how to draw/which areas to fill. */ - public enum FILL_MODE {UNDER, ABOVE, BETWEEN}; + public enum FILL_MODE {UNDER, ABOVE, BETWEEN} /** MODE in use. */ - protected FILL_MODE mode; + private FILL_MODE mode; /** Theme-document with attributes about actual visual representation. */ - protected ThemeDocument theme; - + private ThemeDocument theme; /** * @param theme the theme-document. @@ -70,6 +69,7 @@ applyShowShape(renderer); applyOutlineColor(renderer); applyOutlineStyle(renderer); + applyShowLine(renderer); applyShowAreaLabel(renderer); if (mode == FILL_MODE.UNDER) { renderer.setAreaCalculationMode( @@ -90,7 +90,7 @@ } - protected void applyFillColor(StableXYDifferenceRenderer renderer) { + private void applyFillColor(StableXYDifferenceRenderer renderer) { Color paint = theme.parseAreaBackgroundColor(); int transparency = theme.parseAreaTransparency(); @@ -119,34 +119,28 @@ } - protected void applyShowShape(StableXYDifferenceRenderer renderer) { + private void applyShowShape(StableXYDifferenceRenderer renderer) { boolean show = theme.parseAreaShowBorder(); renderer.setDrawOutline(show); } - protected void applyShowLine(StableXYDifferenceRenderer renderer) { + private void applyShowLine(StableXYDifferenceRenderer renderer) { boolean show = theme.parseShowLine(); renderer.setShapesVisible(show); } - - protected void applyOutlineColor(StableXYDifferenceRenderer renderer) { + private void applyOutlineColor(StableXYDifferenceRenderer renderer) { Color c = theme.parseLineColorField(); renderer.setOutlinePaint(c); } - protected void applyOutlineWidth(StableXYDifferenceRenderer renderer) { - // int size = theme.parseLineWidth(); - // XXX: Why is this not set? - } - /** Inform renderer whether it should draw a label. */ - protected void applyShowAreaLabel(StableXYDifferenceRenderer renderer) { + private void applyShowAreaLabel(StableXYDifferenceRenderer renderer) { renderer.setLabelArea(theme.parseShowAreaLabel()); } - protected void applyOutlineStyle(StableXYDifferenceRenderer renderer) { + private void applyOutlineStyle(StableXYDifferenceRenderer renderer) { float[] dashes = theme.parseLineStyle(); int size = theme.parseLineWidth(); @@ -166,5 +160,9 @@ renderer.setOutlineStroke(stroke); } + + public boolean shouldCalculateRange() { + return theme.parseCalculateRange(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 7a8c12706834 -r e5f688820951 artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java --- a/artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java Tue Feb 13 14:53:23 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/themes/ThemeDocument.java Wed Feb 14 18:10:28 2018 +0100 @@ -120,6 +120,9 @@ public final static String USE_FILL_PAINT = "usefillpaint"; + /* boolean parameter if the range of this theme should be considered when auto-zooming. Only works for area-series at the moment */ + private static final String CALCULATE_RANGE = "calculateRange"; + private Map values; public ThemeDocument() { @@ -608,7 +611,7 @@ return parseColor(lineColorStr); } - + // FIXME: check, this is defined in default.xml, but never used. Instead the StyledAreaSeriesCollection used lineColor etc public Color parseAreaLineColorField() { String lineColorStr = getAreaLineColorString(); if (log.isDebugEnabled()) { @@ -812,5 +815,15 @@ private String getAreaShowBorderString() { return getValue(AREA_SHOW_BORDER); } + + + public boolean parseCalculateRange() { + return parseBoolean(getCalculateRangeString(), false); + } + + + private String getCalculateRangeString() { + return getValue(CALCULATE_RANGE); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :