Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/CompactXYItems.java @ 782:725f7573b6ea
Added package description with text 'DOCUMENT ME!'.
gnv-artifacts/trunk@861 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 10:28:32 +0000 |
parents | c4156275c1e1 |
children | cdade5005cba |
line wrap: on
line source
package de.intevation.gnv.jfreechart; import java.io.Serializable; /** * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha Teichmann</a> * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ 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 :