Revision 165
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/raster/process/HistogramProcess.java | ||
---|---|---|
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.app.extension.raster.process; |
|
23 |
|
|
24 |
import javax.swing.SwingUtilities; |
|
25 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.andami.messages.NotificationManager; |
|
28 |
import org.gvsig.fmap.dal.coverage.exception.HistogramException; |
|
29 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
30 |
import org.gvsig.fmap.dal.coverage.store.props.Histogram; |
|
31 |
import org.gvsig.fmap.dal.coverage.store.props.Histogramable; |
|
32 |
|
|
33 |
/** |
|
34 |
* Process to calculate a Histogram using a IHistogramable object. A IHistogramable object |
|
35 |
* has its own method to build an histogram an this process will call to this function. |
|
36 |
* |
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
38 |
*/ |
|
39 |
public class HistogramProcess extends RasterProcess { |
|
40 |
private Histogram lastHistogram = null; |
|
41 |
private Histogramable histogramable = null; |
|
42 |
|
|
43 |
/* |
|
44 |
* (non-Javadoc) |
|
45 |
* @see org.gvsig.rastertools.RasterProcess#init() |
|
46 |
*/ |
|
47 |
public void init() { |
|
48 |
histogramable = (Histogramable) getParam("histogramable"); |
|
49 |
} |
|
50 |
|
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see org.gvsig.rastertools.RasterProcess#process() |
|
54 |
*/ |
|
55 |
public void process() throws ProcessInterruptedException { |
|
56 |
try { |
|
57 |
// Proceso duro de obtener un histograma. Puede durar bastante tiempo. |
|
58 |
lastHistogram = histogramable.getHistogram(); |
|
59 |
// Ya tenemos el histograma y lo representamos en la ventana |
|
60 |
|
|
61 |
SwingUtilities.invokeLater(new Runnable() { |
|
62 |
public void run() { |
|
63 |
if ((externalActions != null) && (lastHistogram != null)) |
|
64 |
externalActions.end(lastHistogram); |
|
65 |
} |
|
66 |
}); |
|
67 |
|
|
68 |
} catch (HistogramException e) { |
|
69 |
NotificationManager.addError("Error calculando el histograma.", e); |
|
70 |
} catch (InterruptedException e) { |
|
71 |
throw new ProcessInterruptedException(e); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
/* |
|
76 |
* (non-Javadoc) |
|
77 |
* @see org.gvsig.raster.RasterProcess#getResult() |
|
78 |
*/ |
|
79 |
public Object getResult() { |
|
80 |
return lastHistogram; |
|
81 |
} |
|
82 |
|
|
83 |
/* |
|
84 |
* (non-Javadoc) |
|
85 |
* @see org.gvsig.rastertools.RasterProcess#getLog() |
|
86 |
*/ |
|
87 |
public String getLog() { |
|
88 |
return PluginServices.getText(this, "calculando_histograma") + "...\n"; |
|
89 |
} |
|
90 |
|
|
91 |
/* |
|
92 |
* (non-Javadoc) |
|
93 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent() |
|
94 |
*/ |
|
95 |
public int getPercent() { |
|
96 |
if (histogramable != null) |
|
97 |
return histogramable.getPercent(); |
|
98 |
return 0; |
|
99 |
} |
|
100 |
|
|
101 |
/* |
|
102 |
* (non-Javadoc) |
|
103 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle() |
|
104 |
*/ |
|
105 |
public String getTitle() { |
|
106 |
return PluginServices.getText(this, "calculando_histograma"); |
|
107 |
} |
|
108 |
} |
|
0 | 109 |
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/tool/filter/regionalpha/RegionAlphaListManager.java | ||
---|---|---|
53 | 53 |
ExtensionPoint point=extensionPoints.add("RasterFilter"); |
54 | 54 |
point.append("RegionAlpha", "", RegionAlphaListManager.class); |
55 | 55 |
} |
56 |
|
|
57 |
/* |
|
58 |
* (non-Javadoc) |
|
59 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#containsFilter(java.lang.String) |
|
60 |
*/ |
|
61 |
@SuppressWarnings("unchecked") |
|
62 |
public Class getFilterClassByID(String id) { |
|
63 |
if( id.compareTo("regionalpha") == 0) |
|
64 |
return RegionAlphaFilter.class; |
|
65 |
return null; |
|
66 |
} |
|
56 | 67 |
|
57 |
|
|
58 | 68 |
public void addRegionAlphaFilter(ArrayList<ROI> rois, int alpha, Boolean inverse) throws FilterTypeException { |
59 | 69 |
RasterFilter filter = new RegionAlphaByteFilter(); |
60 | 70 |
|
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/tool/filter/grayscale/GrayScaleManager.java | ||
---|---|---|
47 | 47 |
ExtensionPoint point = extensionPoints.get("RasterFilter"); |
48 | 48 |
point.append("GrayScale", "", GrayScaleManager.class); |
49 | 49 |
} |
50 |
|
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#containsFilter(java.lang.String) |
|
54 |
*/ |
|
55 |
@SuppressWarnings("unchecked") |
|
56 |
public Class getFilterClassByID(String id) { |
|
57 |
if( id.compareTo("grayscale") == 0) |
|
58 |
return GrayScaleFilter.class; |
|
59 |
return null; |
|
60 |
} |
|
50 | 61 |
|
51 | 62 |
/** |
52 | 63 |
* Constructor. |
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/tool/filter/mask/MaskListManager.java | ||
---|---|---|
62 | 62 |
ExtensionPoint point=extensionPoints.add("RasterFilter"); |
63 | 63 |
point.append("Mask", "", MaskListManager.class); |
64 | 64 |
} |
65 |
|
|
66 |
/* |
|
67 |
* (non-Javadoc) |
|
68 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#containsFilter(java.lang.String) |
|
69 |
*/ |
|
70 |
@SuppressWarnings("unchecked") |
|
71 |
public Class getFilterClassByID(String id) { |
|
72 |
if( id.compareTo("mask") == 0) |
|
73 |
return MaskFilter.class; |
|
74 |
return null; |
|
75 |
} |
|
65 | 76 |
|
66 | 77 |
/** |
67 | 78 |
* A?ade un filtro de m?scara |
Also available in: Unified diff