Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/CompactXYItems.java @ 638:c580666a843f
Removed CallMeta object from state which should not be serialized. Implemented a little workarround instead to save localized strings for axes descriptions of horizontal profile charts (issue180).
gnv-artifacts/trunk@721 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 02 Mar 2010 08:43:50 +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 :