[PATCH] issue1558: Allow fixed axis for timeseries-diagrams
Wald Commits
scm-commit at wald.intevation.org
Thu Nov 21 17:32:16 CET 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1385051234 -3600
# Node ID ce1b8a59934ecec59fd7ebaabb981185f3a69623
# Parent eb4ca9a7eaca5b79d44c4a6656954b081bf53258
issue1558: Allow fixed axis for timeseries-diagrams.
diff -r eb4ca9a7eaca -r ce1b8a59934e artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java Thu Nov 21 15:40:05 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/TimeseriesChartGenerator.java Thu Nov 21 17:27:14 2013 +0100
@@ -122,6 +122,8 @@
applySeriesAttributes(plot);
+ consumeAxisSettings(plot);
+
addAnnotationsToRenderer(plot);
addLogo(plot);
aggregateLegendEntries(plot);
@@ -262,6 +264,56 @@
plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND);
}
+ /**
+ * This method zooms the plot to the specified ranges in the attribute
+ * document or to the ranges specified by the min/max values in the
+ * datasets. <b>Note:</b> We determine the range manually if no zoom ranges
+ * are given, because JFreeCharts auto-zoom adds a margin to the left and
+ * right of the data area.
+ *
+ * Copy of implementation in XYChartGenerator.
+ *
+ * @param plot The XYPlot.
+ */
+ protected void consumeAxisSettings(XYPlot plot) {
+ logger.debug("Zoom to specified ranges.");
+
+ Bounds xrange = getDomainAxisRange();
+ Bounds yrange = getValueAxisRange();
+
+ ValueAxis xAxis = plot.getDomainAxis();
+
+ Range fixedXRange = getRangeForAxisFromSettings("X");
+ if (fixedXRange != null) {
+ xAxis.setRange(fixedXRange);
+ }
+ else {
+ zoomX(plot, xAxis, getXBounds(0), xrange);
+ }
+
+ for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) {
+ ValueAxis yaxis = plot.getRangeAxis(i);
+
+ if (yaxis instanceof IdentifiableNumberAxis) {
+ IdentifiableNumberAxis idAxis = (IdentifiableNumberAxis) yaxis;
+
+ Range fixedRange = getRangeForAxisFromSettings(idAxis.getId());
+ if (fixedRange != null) {
+ yaxis.setRange(fixedRange);
+ continue;
+ }
+ }
+
+ if (yaxis == null) {
+ logger.debug("Zoom problem: no Y Axis for index: " + i);
+ continue;
+ }
+
+ logger.debug("Prepare zoom settings for y axis at index: " + i);
+ zoomY(plot, yaxis, getYBounds(Integer.valueOf(i)), yrange);
+ }
+ }
+
@Override
protected Series getSeriesOf(XYDataset dataset, int idx) {
@@ -528,7 +580,7 @@
/**
- * Adjusts the axes of a plot. This method sets the <i>labelFont</i> of the
+ * Adjusts the (look of) axes of a plot. This method sets the <i>labelFont</i> of the
* X axis.
*
* (Duplicate in XYChartGenerator).
More information about the Dive4elements-commits
mailing list