Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/CompactXYItems.java @ 795:cdade5005cba
Added javadoc in jfreechart package.
gnv-artifacts/trunk@877 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 31 Mar 2010 13:48:07 +0000 |
parents | c4156275c1e1 |
children | 22c18083225e |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/CompactXYItems.java Wed Mar 31 12:18:03 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/jfreechart/CompactXYItems.java Wed Mar 31 13:48:07 2010 +0000 @@ -3,43 +3,93 @@ import java.io.Serializable; /** + * This class is used to represent geometries (e.g. point, line, polygon). Each + * geometry is made up of multiple xy points stored in a single array. A line + * composed by start- and endpoint is stored in the following order in that + * array: [x1, y1, x2, y2]. + * * @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 { + /** + * Array storing the xy items. + */ protected double [] data; + /** + * Constructs a new CompactXYItems object with the given data. + * + * @param data An array with xy values. + */ public CompactXYItems(double [] data) { this.data = data; } + /** + * Retrieves the x coordinate of the point with the given index. + * + * @param index Index + * @return X coordinate. + */ public double getX(int index) { return data[index << 1]; } + /** + * Retrieves the y coordinate of the point with the given index. + * + * @param index Index + * @return Y coordinate. + */ public double getY(int index) { return data[(index << 1)+1]; } + /** + * Write the tupel of xy-values at a specific index into the given array. + * + * @param index Index used to specify the xy-value. + * @param xy the xy coordinate is written into this array with the following + * order: [x,y] + */ public void get(int index, double [] xy) { xy[0] = data[index = (index << 1) + 1]; xy[1] = data[index + 1]; } + /** + * + * @return the data array. + */ public double [] getData() { return data; } + /** + * + * @param data + */ public void setData(double [] data) { this.data = data; } + /** + * + * @return + */ public int size() { return data.length >> 1; } + /** + * Retrieves the bounding box spaned by the coordinates in the data array. + * + * @param bbox + * @return + */ public double [] calculateBoundingBox(double [] bbox) { for (int i = 0; i < data.length;) { double x = data[i++]; @@ -52,6 +102,11 @@ return bbox; } + /** + * + * @return the coordinates as string. + */ + @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < data.length;) { @@ -66,6 +121,10 @@ } + /** + * + * @return the lowest x value. + */ public double getMinX() { double lower = Double.POSITIVE_INFINITY; @@ -81,6 +140,10 @@ } + /** + * + * @return the highest x value. + */ public double getMaxX() { double upper = Double.NEGATIVE_INFINITY; @@ -96,6 +159,10 @@ } + /** + * + * @return the lowest y value. + */ public double getMinY() { double lower = Double.POSITIVE_INFINITY; @@ -111,6 +178,10 @@ } + /** + * + * @return the highest y value. + */ public double getMaxY() { double upper = Double.NEGATIVE_INFINITY; @@ -125,4 +196,4 @@ return upper; } } -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : \ No newline at end of file