Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/CompactXYItems.java @ 522:c896282c2601
Issue 156 solved. Added width, height and points as parameter to svg and pdf output mode. Width and height have an effact on the width and height of the export, points is a boolean property which enables/disables the drawing of data points.
gnv-artifacts/trunk@616 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 25 Jan 2010 09:18:31 +0000 |
parents | f426f55d4f7a |
children | c4156275c1e1 |
line wrap: on
line source
package de.intevation.gnv.jfreechart; import java.io.Serializable; /** * @author Sascha Teichmann <sascha.teichmann@intevation.de> * @author Ingo Weinzierl <ingo.weinzierl@intevation.de> */ public class CompactXYItems implements Serializable { protected double [] data; public CompactXYItems(double [] data) { this.data = data; } public double getX(int index) { return data[index << 1]; } public double getY(int index) { return data[(index << 1)+1]; } public void get(int index, double [] xy) { xy[0] = data[index = (index << 1) + 1]; xy[1] = data[index + 1]; } public double [] getData() { return data; } public void setData(double [] data) { this.data = data; } public int size() { return data.length >> 1; } public double [] calculateBoundingBox(double [] bbox) { for (int i = 0; i < data.length;) { double x = data[i++]; double y = data[i++]; if (x < bbox[0]) bbox[0] = x; if (y < bbox[1]) bbox[1] = y; if (x > bbox[2]) bbox[2] = x; if (y > bbox[3]) bbox[3] = y; } return bbox; } public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.length;) { if (i > 0) sb.append("; "); sb.append('('); sb.append(data[i++]); sb.append(", "); sb.append(data[i++]); sb.append(')'); } return sb.toString(); } public double getMinX() { double lower = Double.POSITIVE_INFINITY; for (int i = 0; i < data.length; i += 2) { double x = data[i]; if (!Double.isNaN(x)) { lower = Math.min(lower, x); } } return lower; } public double getMaxX() { double upper = Double.NEGATIVE_INFINITY; for (int i = 0; i < data.length; i += 2) { double x = data[i]; if (!Double.isNaN(x)) { upper = Math.max(upper, x); } } return upper; } public double getMinY() { double lower = Double.POSITIVE_INFINITY; for (int i = 1; i < data.length; i += 2) { double y = data[i]; if (!Double.isNaN(y)) { lower = Math.min(lower, y); } } return lower; } public double getMaxY() { double upper = Double.NEGATIVE_INFINITY; for (int i = 1; i < data.length; i += 2) { double y = data[i]; if (!Double.isNaN(y)) { upper = Math.max(upper, y); } } return upper; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :