gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.swing / org.gvsig.raster.swing.impl / src / main / java / org / gvsig / raster / swing / impl / tool / infobypoint / DefaultInfoByPointDataModel.java @ 2500
History | View | Annotate | Download (3.44 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.swing.impl.tool.infobypoint; |
23 |
|
24 |
import java.awt.geom.Point2D; |
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
import java.util.Observable; |
28 |
|
29 |
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel; |
30 |
|
31 |
public class DefaultInfoByPointDataModel extends Observable implements InfoByPointDataModel { |
32 |
private static final int LONG_STRING = 26; |
33 |
public int bands = 0; |
34 |
public List<Double> bandsValues = new ArrayList<Double>(); |
35 |
public Point2D pixelPoint = new Point2D.Double(); |
36 |
public Point2D worldPoint = new Point2D.Double(); |
37 |
public Point2D viewPoint = new Point2D.Double(); |
38 |
public int[] rgb = new int[3]; |
39 |
public double[] cmyk = new double[4]; |
40 |
public double[] hsl = new double[3]; |
41 |
public List<String> layers = null; |
42 |
public boolean projected = true; |
43 |
|
44 |
public DefaultInfoByPointDataModel() {
|
45 |
setARGB(0, 0, 0); |
46 |
setCMYK(new double[]{0, 0, 0, 0}); |
47 |
setHSL(0, 0, 0); |
48 |
setBandValues(new double[]{Double.NaN}); |
49 |
setNumberOfBands(0);
|
50 |
setPixelPoint(-1, -1); |
51 |
setViewPoint(Double.NaN, Double.NaN); |
52 |
setWorldPoint(Double.NaN, Double.NaN); |
53 |
List<String> list = new ArrayList<String>(); |
54 |
list.add("...");
|
55 |
setLayerList(list); |
56 |
} |
57 |
|
58 |
public void setProjected(boolean projected) { |
59 |
this.projected = projected;
|
60 |
} |
61 |
|
62 |
public void setBandValues(double[] list) { |
63 |
bandsValues.clear(); |
64 |
for (int i = 0; i < list.length; i++) { |
65 |
bandsValues.add(list[i]); |
66 |
} |
67 |
} |
68 |
|
69 |
public void setNumberOfBands(int n) { |
70 |
this.bands = n;
|
71 |
} |
72 |
|
73 |
public void setLayerList(List<String> list) { |
74 |
layers = list; |
75 |
} |
76 |
|
77 |
public void setARGB(int r, int g, int b) { |
78 |
rgb[0] = r;
|
79 |
rgb[1] = g;
|
80 |
rgb[2] = b;
|
81 |
} |
82 |
|
83 |
public void setCMYK(double[] cmyk) { |
84 |
this.cmyk = cmyk;
|
85 |
} |
86 |
|
87 |
public void setHSL(double h, double s, double l) { |
88 |
hsl[0] = h;
|
89 |
hsl[1] = s;
|
90 |
hsl[2] = l;
|
91 |
} |
92 |
|
93 |
public void setPixelPoint(double x, double y) { |
94 |
pixelPoint.setLocation(x, y); |
95 |
} |
96 |
|
97 |
public void setWorldPoint(double x, double y) { |
98 |
worldPoint.setLocation(x, y); |
99 |
} |
100 |
|
101 |
public void setViewPoint(double x, double y) { |
102 |
viewPoint.setLocation(x, y); |
103 |
} |
104 |
|
105 |
public String getFormatedLayerName(int i) { |
106 |
if(LONG_STRING < layers.get(i).length())
|
107 |
return "..." + layers.get(i).substring(layers.get(i).length() - LONG_STRING, layers.get(i).length()); |
108 |
return layers.get(i);
|
109 |
} |
110 |
|
111 |
public void notifyObservers() { |
112 |
setChanged(); |
113 |
super.notifyObservers();
|
114 |
} |
115 |
} |