Revision 11187
trunk/extensions/extRasterTools-SE/config/text.properties | ||
---|---|---|
67 | 67 |
imagen_completa=Completo |
68 | 68 |
normal=Normal |
69 | 69 |
accumulated=Acumulado |
70 |
logaritmic=Logar?tmico |
|
70 |
logaritmic=Logar?tmico |
|
71 |
band=Banda |
|
72 |
generando_histograma=Generando histograma, por favor, espere |
|
73 |
calculando_histograma=Calculando histograma |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramPersistence.java | ||
---|---|---|
1 |
package org.gvsig.rastertools.histogram; |
|
2 |
|
|
3 |
import java.io.BufferedReader; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileInputStream; |
|
6 |
import java.io.FileWriter; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStreamReader; |
|
9 |
import java.io.Writer; |
|
10 |
|
|
11 |
/** |
|
12 |
* Clase con herramientas la persistencia de los histogramas calculados. |
|
13 |
* Se implementan m?todos para ecribir y leer en los ficheros .rmf correspondientes |
|
14 |
* los histogramas calculados. |
|
15 |
* @author Miguel ?ngel Querol Carratal? <querol_mig@gva.es> |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class HistogramPersistence { |
|
19 |
|
|
20 |
|
|
21 |
public HistogramPersistence(){ |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* Crea o modifica el archivo .rmf asociado al GeoRasterFile del que le pasamos |
|
26 |
* el nombre con los valores del histograma. |
|
27 |
* @param histogram |
|
28 |
* @param grfName |
|
29 |
* @throws IOException |
|
30 |
*/ |
|
31 |
public void makeRMFHistogram(int histogram[][], String grfName, int numBands)throws IOException{ |
|
32 |
File rmfFile = null; |
|
33 |
File rmfAux = null; |
|
34 |
Writer writer = null; |
|
35 |
boolean copy = true; |
|
36 |
|
|
37 |
rmfFile = new File(grfName.substring(0, grfName.lastIndexOf(".") + 1) + "rmf"); |
|
38 |
if(rmfFile.exists()){ |
|
39 |
BufferedReader inGrf = new BufferedReader(new InputStreamReader(new FileInputStream(rmfFile))); |
|
40 |
String str = inGrf.readLine(); |
|
41 |
rmfAux = new File(grfName.substring(0, grfName.lastIndexOf(".") + 1) + "aux.rmf"); |
|
42 |
rmfAux.createNewFile(); |
|
43 |
writer = new FileWriter(rmfAux); |
|
44 |
|
|
45 |
while(str != null){ |
|
46 |
if(!str.equals("</RasterMetaFile>")){ |
|
47 |
if(str.equals("<Histogram>")) |
|
48 |
copy = false; |
|
49 |
if(str.equals("</Histogram>")) |
|
50 |
copy = true; |
|
51 |
if(copy && (!str.equals("</Histogram>"))) |
|
52 |
writer.write(str + "\n"); |
|
53 |
}else{ |
|
54 |
writer.write(getRMFHistogramHeader()); |
|
55 |
for (int i = 0; i < numBands ; i++){ |
|
56 |
writer.write(getXMLRasterBandHistogram(histogram, i)); |
|
57 |
} |
|
58 |
writer.write(getRMFHistogramEnd()); |
|
59 |
writer.write(str + "\n"); |
|
60 |
} |
|
61 |
str = inGrf.readLine(); |
|
62 |
} |
|
63 |
writer.close(); |
|
64 |
|
|
65 |
rmfAux.renameTo(rmfFile); |
|
66 |
|
|
67 |
|
|
68 |
}else{ |
|
69 |
rmfFile.createNewFile(); |
|
70 |
writer = new FileWriter(rmfFile); |
|
71 |
writer.write(getRMFHeader()); |
|
72 |
writer.write(getRMFHistogramHeader()); |
|
73 |
for (int i = 0; i < numBands ; i++){ |
|
74 |
writer.write(getXMLRasterBandHistogram(histogram, i)); |
|
75 |
} |
|
76 |
writer.write(getRMFHistogramEnd()); |
|
77 |
writer.write(getRMFEnd()); |
|
78 |
writer.close(); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
/** |
|
85 |
* Calcula la cabecera del archivo .rmf asociado a la imagen en el caso |
|
86 |
* de que ?ste no exista. |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
private String getRMFHeader(){ |
|
90 |
StringBuffer buffer = new StringBuffer(); |
|
91 |
|
|
92 |
buffer.append("<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n"); |
|
93 |
buffer.append("<RasterMetaFile xmlns=\"http://www.gvsig.org\">\n"); |
|
94 |
|
|
95 |
return buffer.toString(); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Crea el final del archivo .rmf asociado a la imagen en el caso de que |
|
100 |
* ?ste no exista. |
|
101 |
* @return |
|
102 |
*/ |
|
103 |
private String getRMFEnd(){ |
|
104 |
StringBuffer buffer = new StringBuffer(); |
|
105 |
|
|
106 |
buffer.append("</RasterMetaFile>\n"); |
|
107 |
|
|
108 |
return buffer.toString(); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Crea la cabecera en XML para el bloque del histograma completo de la |
|
113 |
* imagen. |
|
114 |
* @return |
|
115 |
*/ |
|
116 |
private String getRMFHistogramHeader(){ |
|
117 |
StringBuffer buffer = new StringBuffer(); |
|
118 |
|
|
119 |
buffer.append("<Histogram>\n"); |
|
120 |
buffer.append("\t<FullHistogram>\n"); |
|
121 |
|
|
122 |
return buffer.toString(); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Crea el final en XML para el bloque del histograma completo de la |
|
127 |
* imagen. |
|
128 |
* @return |
|
129 |
*/ |
|
130 |
private String getRMFHistogramEnd(){ |
|
131 |
StringBuffer buffer = new StringBuffer(); |
|
132 |
|
|
133 |
buffer.append("\t</FullHistogram>\n"); |
|
134 |
buffer.append("</Histogram>\n"); |
|
135 |
|
|
136 |
return buffer.toString(); |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Crea el c?digo XML correspondiendte a los datos del histograma de la |
|
141 |
* imagen de la banda correspondiente. |
|
142 |
* @param n_band: banda de la que crear el XML con los datos de su histograma. |
|
143 |
* @return |
|
144 |
*/ |
|
145 |
private String getXMLRasterBandHistogram(int histogram[][], int n_band){ |
|
146 |
StringBuffer buffer = new StringBuffer(); |
|
147 |
|
|
148 |
buffer.append("\t\t<Band>\n"); |
|
149 |
buffer.append("\t\t\t<Values>"); |
|
150 |
for (int i = 0 ; i <= 255 ; i++) |
|
151 |
buffer.append(histogram[n_band][i] + " "); |
|
152 |
buffer.append("</Values>\n"); |
|
153 |
buffer.append("\t\t</Band>\n"); |
|
154 |
|
|
155 |
return buffer.toString(); |
|
156 |
} |
|
157 |
|
|
158 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramProcess.java | ||
---|---|---|
26 | 26 |
import org.gvsig.raster.util.HistogramException; |
27 | 27 |
import org.gvsig.raster.util.IHistogramable; |
28 | 28 |
|
29 |
import com.iver.andami.PluginServices; |
|
30 |
|
|
29 | 31 |
public class HistogramProcess implements Runnable, IIncrementable, IncrementableListener { |
30 | 32 |
IHistogramable iHistogramable = null; |
31 | 33 |
HistogramPanelListener hpl = null; |
... | ... | |
78 | 80 |
* @see org.gvsig.gui.beans.IncrementableTask.IIncrementable#getLabel() |
79 | 81 |
*/ |
80 | 82 |
public String getLabel() { |
81 |
return "Generando histograma, por favor, espere...";
|
|
83 |
return PluginServices.getText(this, "generando_histograma") + "...";
|
|
82 | 84 |
} |
83 | 85 |
|
84 | 86 |
/* |
... | ... | |
86 | 88 |
* @see org.gvsig.gui.beans.IncrementableTask.IIncrementable#getLog() |
87 | 89 |
*/ |
88 | 90 |
public String getLog() { |
89 |
return "Calculando histograma...";
|
|
91 |
return PluginServices.getText(this, "calculando_histograma") + "...";
|
|
90 | 92 |
} |
91 | 93 |
|
92 | 94 |
/* |
... | ... | |
102 | 104 |
* @see org.gvsig.gui.beans.IncrementableTask.IIncrementable#getTitle() |
103 | 105 |
*/ |
104 | 106 |
public String getTitle() { |
105 |
return "Calculando histograma";
|
|
107 |
return PluginServices.getText(this, "calculando_histograma");
|
|
106 | 108 |
} |
107 | 109 |
|
108 | 110 |
/* |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/ui/HistogramTocMenuEntry.java | ||
---|---|---|
11 | 11 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
12 | 12 |
|
13 | 13 |
public class HistogramTocMenuEntry extends AbstractTocContextMenuAction { |
14 |
private FLayer lyr = null; |
|
15 |
// private HistogramDialog histogramDialog = null; |
|
16 |
private HistogramDialog histogramDialog = null; |
|
17 |
private ArrayList listeners = new ArrayList(); |
|
18 |
// private RasterFilterStackManager stackManager = null; |
|
14 |
private FLayer lyr = null; |
|
15 |
private HistogramDialog histogramDialog = null; |
|
16 |
private ArrayList listeners = new ArrayList(); |
|
19 | 17 |
private int width = 650; |
20 | 18 |
private int height = 500; |
21 | 19 |
|
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/ui/HistogramPanel.java | ||
---|---|---|
31 | 31 |
import javax.swing.table.DefaultTableModel; |
32 | 32 |
|
33 | 33 |
import org.cresques.filter.RasterBuf; |
34 |
import org.cresques.i18n.Messages; |
|
35 | 34 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
36 | 35 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
37 | 36 |
import org.gvsig.gui.beans.graphic.GraphicContainer; |
... | ... | |
41 | 40 |
import org.gvsig.raster.util.Histogram; |
42 | 41 |
import org.gvsig.raster.util.IHistogramable; |
43 | 42 |
import org.gvsig.rastertools.histogram.HistogramPanelListener; |
43 |
|
|
44 |
import com.iver.andami.PluginServices; |
|
44 | 45 |
/** |
45 | 46 |
* <code>HistogramPanel</code>. Interfaz de usuario para la representaci?n de |
46 | 47 |
* histogramas. |
... | ... | |
152 | 153 |
*/ |
153 | 154 |
public TableContainer getTableContainer(){ |
154 | 155 |
if(tableContainer == null){ |
155 |
String[] columnNames = {Messages.getText("banda"), Messages.getText("minimo"), Messages.getText("maximo"), Messages.getText("media"), Messages.getText("mediana"), Messages.getText("npixeles")};
|
|
156 |
String[] columnNames = {PluginServices.getText(this, "banda"), PluginServices.getText(this, "minimo"), PluginServices.getText(this, "maximo"), PluginServices.getText(this, "media"), PluginServices.getText(this, "mediana"), PluginServices.getText(this, "npixeles")};
|
|
156 | 157 |
int[] columnWidths = {50, 65, 65, 65, 65, 115}; |
157 | 158 |
tableContainer = new TableContainer(columnNames, columnWidths); |
158 | 159 |
tableContainer.setControlVisible(true); |
... | ... | |
195 | 196 |
jPanel3.add(jPanel5, BorderLayout.SOUTH); |
196 | 197 |
|
197 | 198 |
jPanel4.setLayout(new FlowLayout()); |
198 |
jPanel4.add(new JLabel(Messages.getText("origen")+":"));
|
|
199 |
jPanel4.add(new JLabel(PluginServices.getText(this, "origen")+":"));
|
|
199 | 200 |
jPanel4.add(getJComboBoxOrigen()); |
200 | 201 |
|
201 | 202 |
jPanel5.setLayout(new FlowLayout()); |
202 |
jPanel5.add(new JLabel(Messages.getText("tipo")+":"));
|
|
203 |
jPanel5.add(new JLabel(PluginServices.getText(this, "tipo")+":"));
|
|
203 | 204 |
jPanel5.add(getJComboBoxTipo()); |
204 | 205 |
} |
205 | 206 |
return panelNorth; |
... | ... | |
213 | 214 |
if (jComboBoxTipo == null) { |
214 | 215 |
String lista [] = new String[Histogram.getHistogramTypesCount()]; |
215 | 216 |
for (int i = 0; i < lista.length; i++) { |
216 |
lista[i] = Messages.getText(Histogram.getType(i));
|
|
217 |
lista[i] = PluginServices.getText(this, Histogram.getType(i));
|
|
217 | 218 |
} |
218 | 219 |
jComboBoxTipo = new JComboBox(lista); |
219 | 220 |
jComboBoxTipo.addActionListener(getHistogramPanelListener()); |
... | ... | |
243 | 244 |
public void setOnlyViewValue(){ |
244 | 245 |
getHistogramPanelListener().eventsEnabled = false; |
245 | 246 |
getJComboBoxOrigen().removeAllItems(); |
246 |
getJComboBoxOrigen().addItem(Messages.getText("vista"));
|
|
247 |
getJComboBoxOrigen().addItem(PluginServices.getText(this, "vista"));
|
|
247 | 248 |
getHistogramPanelListener().eventsEnabled = panelInizialited; |
248 | 249 |
} |
249 | 250 |
|
... | ... | |
256 | 257 |
if (bTable == null) { |
257 | 258 |
bTable = new JButton(); |
258 | 259 |
bTable.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); |
259 |
bTable.setText(Messages.getText("crear_tabla"));
|
|
260 |
bTable.setText(PluginServices.getText(this, "crear_tabla"));
|
|
260 | 261 |
bTable.setName("bTable"); |
261 | 262 |
bTable.addActionListener(getHistogramPanelListener()); |
262 | 263 |
bTable.setPreferredSize(new java.awt.Dimension(150,25)); |
... | ... | |
276 | 277 |
jTableBands.setModel(new javax.swing.table.DefaultTableModel( |
277 | 278 |
new Object [][] {}, |
278 | 279 |
new String [] { |
279 |
" ", Messages.getText("bandas")
|
|
280 |
" ", PluginServices.getText(this, "bandas")
|
|
280 | 281 |
} |
281 | 282 |
) { |
282 | 283 |
private static final long serialVersionUID = 0L; |
... | ... | |
311 | 312 |
getHistogramPanelListener().eventsEnabled = false; |
312 | 313 |
((DefaultTableModel) getJTableBands().getModel()).setRowCount(0); |
313 | 314 |
for(int i = 0; i < bands; i++){ |
314 |
((DefaultTableModel) getJTableBands().getModel()).addRow(new Object[] { new Boolean(true), "Band "+String.valueOf(i)});
|
|
315 |
((DefaultTableModel) getJTableBands().getModel()).addRow(new Object[] { new Boolean(true), PluginServices.getText(this, "band") + " " + String.valueOf(i)});
|
|
315 | 316 |
} |
316 | 317 |
getHistogramPanelListener().eventsEnabled = panelInizialited; |
317 | 318 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/RasterSEAdapterModule.java | ||
---|---|---|
55 | 55 |
* @see com.iver.andami.plugins.IExtension#initialize() |
56 | 56 |
*/ |
57 | 57 |
public void initialize() { |
58 |
DiagSignalHandler.install("ALRM"); |
|
58 |
// DiagSignalHandler.install("ALRM");
|
|
59 | 59 |
|
60 | 60 |
InfoPanel info = new InfoPanel(); |
61 | 61 |
BandSetupPanel bandSetup = new BandSetupPanel(); |
Also available in: Unified diff