comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/XYColumn.java @ 431:422275fc9927

Refactored the XYColumn and Point2d code a bit to be more reusable in 3D. gnv-artifacts/trunk@479 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 23 Dec 2009 06:53:46 +0000
parents bed9735adf84
children 6a70e8883307
comparison
equal deleted inserted replaced
430:23e9352df09b 431:422275fc9927
1 package de.intevation.gnv.math; 1 package de.intevation.gnv.math;
2 2
3 import java.io.Serializable;
4 import java.util.ArrayList; 3 import java.util.ArrayList;
5 import java.util.List; 4 import java.util.List;
6 5
7 /** 6 /**
8 * @author Ingo Weinzierl <ingo.weinzierl@intevation.de> 7 * @author Ingo Weinzierl <ingo.weinzierl@intevation.de>
8 * @author Sascha L. Teichmann <sascha.teichmann@intevation.de>
9 */ 9 */
10 public class XYColumn 10 public class XYColumn
11 implements Serializable 11 extends Point2d
12 { 12 {
13 protected List values;
13 14
14 private double x; 15 public XYColumn() {
15 private double y; 16 }
16
17 private int i;
18 private int j;
19
20 private List values;
21 17
22 public XYColumn(double x, double y, int i, int j) { 18 public XYColumn(double x, double y, int i, int j) {
23 this.x = x; 19 super(x, y, i, j);
24 this.y = y;
25 this.i = i;
26 this.j = j;
27 } 20 }
28
29 21
30 public void add(HeightValue value) { 22 public void add(HeightValue value) {
31 if (values == null) { 23 if (values == null) {
32 values = new ArrayList(); 24 values = new ArrayList();
33 } 25 }
34 values.add(value); 26 values.add(value);
35 } 27 }
36 28
37
38 public HeightValue[] getValues() { 29 public HeightValue[] getValues() {
39 return (HeightValue[]) values.toArray(new HeightValue[values.size()]); 30 return (HeightValue[]) values.toArray(new HeightValue[values.size()]);
40 } 31 }
41
42
43 public int hashCode() {
44 return (i << 16) | j;
45 }
46
47
48 public boolean equals(Object obj) {
49 XYColumn other = (XYColumn) obj;
50
51 return i == other.i && j == other.j && x == other.x && y == other.y;
52 }
53 } 32 }
33 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org