Revision 19378 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/enhanced/graphics/HistogramGraphicBase.java
HistogramGraphicBase.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package org.gvsig.rastertools.enhanced.graphics; |
20 | 20 |
|
21 |
import java.awt.BorderLayout; |
|
21 | 22 |
import java.awt.Color; |
22 | 23 |
import java.awt.Dimension; |
23 | 24 |
import java.awt.event.ComponentEvent; |
... | ... | |
25 | 26 |
import java.util.ArrayList; |
26 | 27 |
|
27 | 28 |
import javax.swing.JFormattedTextField; |
29 |
import javax.swing.JLabel; |
|
28 | 30 |
import javax.swing.JPanel; |
29 | 31 |
import javax.swing.JSlider; |
30 | 32 |
|
... | ... | |
32 | 34 |
import org.gvsig.raster.beans.canvas.layers.Border; |
33 | 35 |
import org.gvsig.raster.beans.canvas.layers.GraphicHistogram; |
34 | 36 |
import org.gvsig.raster.datastruct.Histogram; |
35 |
|
|
36 | 37 |
/** |
37 | 38 |
* Clase base para los gr?ficos de histogramas de entrada y salida. |
38 | 39 |
* |
... | ... | |
75 | 76 |
|
76 | 77 |
private double[] minList = null; |
77 | 78 |
private double[] maxList = null; |
79 |
|
|
80 |
private JLabel labelStatus = null; |
|
78 | 81 |
|
79 | 82 |
public HistogramGraphicBase(Histogram hist, int[] renderBands, double[] minList, double[] maxList) { |
80 | 83 |
this.hist = hist; |
81 | 84 |
this.renderBands = renderBands; |
82 | 85 |
this.minList = minList; |
83 | 86 |
this.maxList = maxList; |
87 |
initialize(); |
|
84 | 88 |
} |
85 | 89 |
|
90 |
private void initialize() { |
|
91 |
init(); |
|
92 |
this.setLayout(new BorderLayout()); |
|
93 |
this.add(getCanvas(), BorderLayout.CENTER); |
|
94 |
this.add(getLabelStatus(), BorderLayout.SOUTH); |
|
95 |
} |
|
96 |
|
|
86 | 97 |
/** |
87 | 98 |
* Obtiene el campo de texto con el valor m?ximo |
88 | 99 |
* @return DataInputField |
89 | 100 |
*/ |
90 | 101 |
public JFormattedTextField getMaxValue() { |
91 |
if(maxValue == null) { |
|
102 |
if (maxValue == null) {
|
|
92 | 103 |
maxValue = new JFormattedTextField(String.valueOf(maxList[0])); |
93 | 104 |
maxValue.setPreferredSize(new Dimension(54, 20)); |
94 | 105 |
} |
... | ... | |
100 | 111 |
* @return DataInputField |
101 | 112 |
*/ |
102 | 113 |
public JFormattedTextField getMinValue() { |
103 |
if(minValue == null) { |
|
114 |
if (minValue == null) {
|
|
104 | 115 |
minValue = new JFormattedTextField(String.valueOf(minList[0])); |
105 | 116 |
minValue.setPreferredSize(new Dimension(54, 20)); |
106 | 117 |
} |
... | ... | |
112 | 123 |
* @return JSlider |
113 | 124 |
*/ |
114 | 125 |
public JSlider getSlider() { |
115 |
if(slider == null) { |
|
126 |
if (slider == null) {
|
|
116 | 127 |
slider = new JSlider(); |
117 | 128 |
} |
118 | 129 |
return slider; |
... | ... | |
125 | 136 |
*/ |
126 | 137 |
public void setHistogram(double[] hist, int colorInterp) { |
127 | 138 |
switch (colorInterp) { |
128 |
case RED: histogramRed = hist; break; |
|
129 |
case GREEN: histogramGreen = hist; break; |
|
130 |
case BLUE: histogramBlue = hist; break; |
|
131 |
case GRAY: histogramGray = hist; break; |
|
139 |
case RED: |
|
140 |
histogramRed = hist; |
|
141 |
break; |
|
142 |
case GREEN: |
|
143 |
histogramGreen = hist; |
|
144 |
break; |
|
145 |
case BLUE: |
|
146 |
histogramBlue = hist; |
|
147 |
break; |
|
148 |
case GRAY: |
|
149 |
histogramGray = hist; |
|
150 |
break; |
|
132 | 151 |
} |
133 |
if(histogramDrawed == null) |
|
152 |
if (histogramDrawed == null)
|
|
134 | 153 |
histogramDrawed = hist; |
135 | 154 |
} |
136 | 155 |
|
... | ... | |
171 | 190 |
* @param type Tipo de histograma. El valor est? definido en las constantes de esta clase |
172 | 191 |
*/ |
173 | 192 |
public void setHistogramType(int type) { |
174 |
//TODO: FUNCIONALIDAD: Sin implementar el tipo de histograma |
|
193 |
// TODO: FUNCIONALIDAD: Sin implementar el tipo de histograma
|
|
175 | 194 |
switch (type) { |
176 |
case STANDARD: break; |
|
177 |
case CUMULATIVE: break; |
|
195 |
case STANDARD: |
|
196 |
break; |
|
197 |
case CUMULATIVE: |
|
198 |
break; |
|
178 | 199 |
} |
179 | 200 |
} |
180 | 201 |
|
... | ... | |
184 | 205 |
*/ |
185 | 206 |
public Border getGraphicBorder() { |
186 | 207 |
for (int i = 0; i < canvas.getDrawableElements().size(); i++) { |
187 |
if(canvas.getDrawableElements().get(i) instanceof Border) |
|
188 |
return (Border)canvas.getDrawableElements().get(i); |
|
208 |
if (canvas.getDrawableElements().get(i) instanceof Border)
|
|
209 |
return (Border) canvas.getDrawableElements().get(i);
|
|
189 | 210 |
} |
190 | 211 |
return null; |
191 | 212 |
} |
... | ... | |
209 | 230 |
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent) |
210 | 231 |
*/ |
211 | 232 |
public void componentResized(ComponentEvent e) { |
212 |
if(canvas != null) { |
|
233 |
if (canvas != null) {
|
|
213 | 234 |
getGraphicBorder().assignVisibleSize(); |
214 | 235 |
canvas.execFirstDrawActions(); |
215 | 236 |
canvas.repaint(); |
... | ... | |
274 | 295 |
} |
275 | 296 |
|
276 | 297 |
/** |
277 |
* Obtiene el panel con las entradas de texto para los valores |
|
278 |
* m?ximo y m?nimo |
|
298 |
* Obtiene el panel del sur, que contendr? inicialmente un label informativo |
|
279 | 299 |
* @return JPanel |
280 | 300 |
*/ |
281 |
public abstract JPanel getSouthPanel(); |
|
301 |
public JLabel getLabelStatus() { |
|
302 |
if (labelStatus == null) { |
|
303 |
labelStatus = new JLabel(); |
|
304 |
} |
|
305 |
return labelStatus; |
|
306 |
} |
|
282 | 307 |
|
283 | 308 |
/** |
284 | 309 |
* Obtiene el lienzo donde se dibujan las gr?ficas |
285 | 310 |
* @return GCanvas |
286 | 311 |
*/ |
287 | 312 |
public abstract GCanvas getCanvas(); |
288 |
|
|
289 |
} |
|
313 |
} |
Also available in: Unified diff