root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / overviews / OverviewsProcess.java @ 20913
History | View | Annotate | Download (3.79 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.overviews; |
20 |
|
21 |
import org.gvsig.addo.BuildingOverviewsException; |
22 |
import org.gvsig.addo.IOverviewIncrement; |
23 |
import org.gvsig.addo.Jaddo; |
24 |
import org.gvsig.addo.WritingException; |
25 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
26 |
import org.gvsig.raster.Configuration; |
27 |
import org.gvsig.raster.RasterProcess; |
28 |
import org.gvsig.raster.util.RasterToolsUtil; |
29 |
|
30 |
import com.iver.andami.PluginServices; |
31 |
|
32 |
/**
|
33 |
* Proceso para la generaci?n de overviews.
|
34 |
*
|
35 |
* 10/12/2007
|
36 |
* @author Nacho Brodin nachobrodin@gmail.com
|
37 |
*/
|
38 |
public class OverviewsProcess extends RasterProcess implements IOverviewIncrement { |
39 |
private FLyrRasterSE rasterSE = null; |
40 |
private int value = 0; |
41 |
private int resamplingAlg = Jaddo.AVERAGE; |
42 |
private int[] overviews = new int[] { 2, 4, 8, 16 }; |
43 |
|
44 |
/*
|
45 |
* (non-Javadoc)
|
46 |
* @see org.gvsig.rastertools.RasterProcess#init()
|
47 |
*/
|
48 |
public void init() { |
49 |
rasterSE = getLayerParam("layer");
|
50 |
|
51 |
int overviewsRate = 2; |
52 |
int nOverviews = 4; |
53 |
overviewsRate = Configuration.getValue("overviews_rate", new Integer(overviewsRate)).intValue(); |
54 |
nOverviews = Configuration.getValue("overviews_number", new Integer(nOverviews)).intValue(); |
55 |
resamplingAlg = Configuration.getValue("overviews_resampling_algorithm", new Integer(resamplingAlg)).intValue(); |
56 |
|
57 |
// Leemos de la configuraci?n los valores de algoritmo a usar,
|
58 |
// n?mero de overviews a generar y proporci?n de la primera overview
|
59 |
|
60 |
overviews = new int[nOverviews]; |
61 |
for (int i = 0; i < nOverviews; i++) |
62 |
overviews[i] = overviewsRate * (i + 1);
|
63 |
} |
64 |
|
65 |
/**
|
66 |
* M?todo donde se ejecutar? el Thread, aqu? se generaran las
|
67 |
* overviews
|
68 |
*/
|
69 |
public void process() { |
70 |
insertLineLog(PluginServices.getText(this, "overviews_generating")); |
71 |
|
72 |
Jaddo build = new Jaddo();
|
73 |
build.setIncrementListener(this);
|
74 |
try {
|
75 |
for (int i = 0; i < rasterSE.getFileCount(); i++) { |
76 |
insertLineLog(" Dataset: " + i);
|
77 |
build.buildOverviews(resamplingAlg, rasterSE.getFileName()[i], overviews); |
78 |
} |
79 |
if (externalActions != null) |
80 |
externalActions.end(rasterSE); |
81 |
} catch (BuildingOverviewsException e) {
|
82 |
if (incrementableTask != null) |
83 |
incrementableTask.hideWindow(); |
84 |
RasterToolsUtil.messageBoxError("error_create_overviews", this); |
85 |
} catch (WritingException e) {
|
86 |
if (incrementableTask != null) |
87 |
incrementableTask.hideWindow(); |
88 |
RasterToolsUtil.messageBoxError("error_write_overviews", this); |
89 |
} |
90 |
} |
91 |
|
92 |
/*
|
93 |
* (non-Javadoc)
|
94 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent()
|
95 |
*/
|
96 |
public int getPercent() { |
97 |
return value;
|
98 |
} |
99 |
|
100 |
/*
|
101 |
* (non-Javadoc)
|
102 |
* @see org.gvsig.addo.IOverviewIncrement#setPercent(int)
|
103 |
*/
|
104 |
public void setPercent(int value) { |
105 |
this.value = value;
|
106 |
} |
107 |
|
108 |
/*
|
109 |
* (non-Javadoc)
|
110 |
* @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle()
|
111 |
*/
|
112 |
public String getTitle() { |
113 |
return PluginServices.getText(this, "incremento_overview"); |
114 |
} |
115 |
} |