Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 2050:c4e0e433f825
Use axes ranges specified in ChartSettings for zooming in charts.
flys-artifacts/trunk@3540 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 27 Dec 2011 07:17:07 +0000 |
parents | 2d5f2bc68cc6 |
children | 4ba5036109d2 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Fri Dec 23 15:10:13 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Dec 27 07:17:07 2011 +0000 @@ -663,14 +663,27 @@ Range xrange = getDomainAxisRange(); Range yrange = getValueAxisRange(); - zoomX(plot, plot.getDomainAxis(), xRanges.get(0), xrange); + ValueAxis xAxis = plot.getDomainAxis(); + + Range fixedXRange = getRangeForAxisFromSettings("X"); + if (fixedXRange != null) { + xAxis.setRange(fixedXRange); + } + else { + zoomX(plot, xAxis, xRanges.get(0), xrange); + } for (int i = 0, num = plot.getRangeAxisCount(); i < num; i++) { ValueAxis yaxis = plot.getRangeAxis(i); if (yaxis instanceof IdentifiableNumberAxis) { - logger.info("!!! IdentifiableNumberAxis found !!!"); - // TODO Watch for fixed axes and the specified range + IdentifiableNumberAxis idAxis = (IdentifiableNumberAxis) yaxis; + + Range fixedRange = getRangeForAxisFromSettings(idAxis.getId()); + if (fixedRange != null) { + yaxis.setRange(fixedRange); + continue; + } } if (yaxis == null) { @@ -749,6 +762,41 @@ /** + * This method searches for a specific axis in the <i>settings</i> if + * <i>settings</i> is set. If the axis was found, this method returns the + * specified axis range if the axis range is fixed. Otherwise, this method + * returns null. + * + * @param axisId The identifier of an axis. + * + * @return the specified axis range from <i>settings</i> if the axis is + * fixed, otherwise null. + */ + public Range getRangeForAxisFromSettings(String axisId) { + ChartSettings chartSettings = getChartSettings(); + if (chartSettings == null) { + return null; + } + + AxisSection as = chartSettings.getAxisSection(axisId); + Boolean fixed = as.isFixed(); + + if (fixed != null && fixed) { + Double upper = as.getUpperRange(); + Double lower = as.getLowerRange(); + + if (upper != null && lower != null) { + return lower < upper + ? new Range(lower, upper) + : new Range(upper, lower); + } + } + + return null; + } + + + /** * Add annotations to Renderer. */ protected void addAnnotationsToRenderer(XYPlot plot) { @@ -1105,8 +1153,8 @@ settings.setChartSection(chartSection); settings.setLegendSection(legendSection); - List<Section> axisSections = buildAxisSections(); - for (Section axisSection: axisSections) { + List<AxisSection> axisSections = buildAxisSections(); + for (AxisSection axisSection: axisSections) { settings.addAxisSection(axisSection); } @@ -1147,8 +1195,8 @@ * * @return a list of Sections for each axis in this chart. */ - protected List<Section> buildAxisSections() { - List<Section> axisSections = new ArrayList<Section>(); + protected List<AxisSection> buildAxisSections() { + List<AxisSection> axisSections = new ArrayList<AxisSection>(); axisSections.addAll(buildXAxisSections()); axisSections.addAll(buildYAxisSections()); @@ -1162,8 +1210,8 @@ * * @return a List that contains a Section for the X axis. */ - protected List<Section> buildXAxisSections() { - List<Section> axisSections = new ArrayList<Section>(); + protected List<AxisSection> buildXAxisSections() { + List<AxisSection> axisSections = new ArrayList<AxisSection>(); String identifier = "X"; @@ -1191,8 +1239,8 @@ * * @return a list of Y axis sections. */ - protected List<Section> buildYAxisSections() { - List<Section> axisSections = new ArrayList<Section>(); + protected List<AxisSection> buildYAxisSections() { + List<AxisSection> axisSections = new ArrayList<AxisSection>(); YAxisWalker walker = getYAxisWalker(); for (int i = 0, n = walker.length(); i < n; i++) {