root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / overviews / OverviewsProcess.java @ 20913
History | View | Annotate | Download (3.79 KB)
1 | 17219 | nbrodin | /* 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 | 17329 | bsanchez | import org.gvsig.addo.BuildingOverviewsException; |
22 | import org.gvsig.addo.IOverviewIncrement; |
||
23 | import org.gvsig.addo.Jaddo; |
||
24 | import org.gvsig.addo.WritingException; |
||
25 | 17610 | nbrodin | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
26 | 18014 | bsanchez | import org.gvsig.raster.Configuration; |
27 | 18573 | nbrodin | import org.gvsig.raster.RasterProcess; |
28 | 20913 | bsanchez | import org.gvsig.raster.util.RasterToolsUtil; |
29 | 17329 | bsanchez | |
30 | 17219 | nbrodin | import com.iver.andami.PluginServices; |
31 | |||
32 | /**
|
||
33 | * Proceso para la generaci?n de overviews.
|
||
34 | 17329 | bsanchez | *
|
35 | 17219 | nbrodin | * 10/12/2007
|
36 | * @author Nacho Brodin nachobrodin@gmail.com
|
||
37 | */
|
||
38 | 17610 | nbrodin | public class OverviewsProcess extends RasterProcess implements IOverviewIncrement { |
39 | 20834 | bsanchez | 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 | 17329 | bsanchez | |
44 | 17610 | nbrodin | /*
|
45 | * (non-Javadoc)
|
||
46 | * @see org.gvsig.rastertools.RasterProcess#init()
|
||
47 | 17219 | nbrodin | */
|
48 | 17610 | nbrodin | public void init() { |
49 | rasterSE = getLayerParam("layer");
|
||
50 | 20834 | bsanchez | |
51 | 17219 | nbrodin | 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 | 17329 | bsanchez | |
57 | 20834 | bsanchez | // 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 | 17329 | bsanchez | |
60 | 17219 | nbrodin | overviews = new int[nOverviews]; |
61 | 17329 | bsanchez | for (int i = 0; i < nOverviews; i++) |
62 | 17219 | nbrodin | overviews[i] = overviewsRate * (i + 1);
|
63 | } |
||
64 | |||
65 | /**
|
||
66 | 17329 | bsanchez | * M?todo donde se ejecutar? el Thread, aqu? se generaran las
|
67 | 17219 | nbrodin | * overviews
|
68 | */
|
||
69 | 17610 | nbrodin | public void process() { |
70 | 17219 | nbrodin | insertLineLog(PluginServices.getText(this, "overviews_generating")); |
71 | 17329 | bsanchez | |
72 | 17219 | nbrodin | Jaddo build = new Jaddo();
|
73 | build.setIncrementListener(this);
|
||
74 | try {
|
||
75 | for (int i = 0; i < rasterSE.getFileCount(); i++) { |
||
76 | 17253 | nbrodin | insertLineLog(" Dataset: " + i);
|
77 | 17329 | bsanchez | build.buildOverviews(resamplingAlg, rasterSE.getFileName()[i], overviews); |
78 | 17219 | nbrodin | } |
79 | 20840 | bsanchez | if (externalActions != null) |
80 | externalActions.end(rasterSE); |
||
81 | 17219 | nbrodin | } catch (BuildingOverviewsException e) {
|
82 | 20913 | bsanchez | if (incrementableTask != null) |
83 | incrementableTask.hideWindow(); |
||
84 | RasterToolsUtil.messageBoxError("error_create_overviews", this); |
||
85 | 17219 | nbrodin | } catch (WritingException e) {
|
86 | 20913 | bsanchez | if (incrementableTask != null) |
87 | incrementableTask.hideWindow(); |
||
88 | RasterToolsUtil.messageBoxError("error_write_overviews", this); |
||
89 | 17219 | nbrodin | } |
90 | } |
||
91 | 17329 | bsanchez | |
92 | 17219 | nbrodin | /*
|
93 | * (non-Javadoc)
|
||
94 | * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent()
|
||
95 | */
|
||
96 | public int getPercent() { |
||
97 | return value;
|
||
98 | } |
||
99 | 17329 | bsanchez | |
100 | 17219 | nbrodin | /*
|
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 | } |