Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRemoteSensing / src / es / idr / teledeteccion / tasseledcap / GenerateResultMonitorableTask.java @ 12096

History | View | Annotate | Download (3.71 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
         *
3
         * Copyright (C) 2006 Instituto de Desarrollo Regional 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
         * For more information, contact:
20
         *
21
         *  Generalitat Valenciana
22
         *   Conselleria d'Infraestructures i Transport
23
         *   Av. Blasco Iba?ez, 50
24
         *   46010 VALENCIA
25
         *   SPAIN
26
         *
27
         *      +34 963862235
28
         *   gvsig@gva.es
29
         *      www.gvsig.gva.es
30
         *
31
         *    or
32
         *
33
         *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
         *   Campus Universitario s/n
35
         *   02071 Alabacete
36
         *   Spain
37
         *
38
         *   +34 967 599 200
39
         */
40

    
41

    
42
package es.idr.teledeteccion.tasseledcap;
43

    
44
import com.iver.andami.PluginServices;
45
import com.iver.cit.gvsig.fmap.MapContext;
46
import com.iver.utiles.swing.threads.CancellableMonitorable;
47
import com.iver.utiles.swing.threads.DefaultCancellableMonitorable;
48
import com.iver.utiles.swing.threads.IMonitorableTask;
49

    
50
import es.idr.teledeteccion.tasseledcap.gui.TasseledCapPanel;
51

    
52

    
53
public class GenerateResultMonitorableTask implements IMonitorableTask{
54

    
55
        private CancellableMonitorable         cancellableMonitorable                 = null;        
56
        private boolean                                                 finished                         = false;
57
        private TasseledCap tc                                                                                = null;
58
        private MapContext m_MapContext                                                                = null;        
59
        int type;
60
        private String nameLayer= "";
61
        public GenerateResultMonitorableTask(MapContext mapContext, TasseledCap tC, int tipo, String namelayer){
62
                
63
                cancellableMonitorable = createCancelMonitor();
64
                m_MapContext=mapContext;
65
                tc = tC;
66
                type= tipo;
67
                nameLayer=namelayer;
68
                        
69
        }
70
        
71
        
72
        public int getCurrentStep() {
73
                return cancellableMonitorable.getCurrentStep();
74
        
75
        }
76

    
77
        public int getFinishStep() {
78
                return cancellableMonitorable.getFinalStep();
79
                
80
        }
81

    
82
        public int getInitialStep() {
83
                // TODO Auto-generated method stub
84
                return 0;
85
        }
86

    
87
        public String getNote() {
88
                // TODO Auto-generated method stub
89
                return null;
90
        }
91

    
92
        public String getStatusMessage() {
93
                return "En Proceso..";
94
        }
95

    
96
        public boolean isDefined() {
97
                return cancellableMonitorable.isDeterminatedProcess();
98
                //return false;
99
        }
100

    
101
        public void cancel() {
102
                cancellableMonitorable.setCanceled(true);
103

    
104
        }
105
        public void run() throws Exception {
106
                tc.calculate(m_MapContext,this,type, nameLayer);
107
                finished = true;
108
        }
109
        
110
        public boolean isCanceled() {
111
                return false;
112
        }
113

    
114
        public boolean isFinished() {
115
                return finished;
116
        }
117
        
118
        
119
        
120

    
121
        public void setCurrentStep(int iStep, int iTotalNumberOfSteps){
122
                
123
                double dPercent;
124
                int iCurrentStep;
125
                
126
                if (iTotalNumberOfSteps != 0){
127
                        dPercent = (double) iStep / (double) iTotalNumberOfSteps ;
128
                        dPercent = Math.min(Math.max(0,dPercent), 1);
129
                        iCurrentStep = (int) Math.min((int)(dPercent * 100), 100);
130
                        cancellableMonitorable.setCurrentStep(iCurrentStep);
131
                }
132
        }
133
        
134
        
135
        
136
        
137
        private CancellableMonitorable createCancelMonitor(){
138
                
139
                DefaultCancellableMonitorable monitor = new DefaultCancellableMonitorable();
140
                monitor.setInitialStep(0);                
141
                monitor.setDeterminatedProcess(true);
142
                monitor.setFinalStep(100);
143
                
144
                return monitor;
145
        }
146

    
147

    
148
        public void finished() {
149
                // TODO Auto-generated method stub
150
                
151
        }
152

    
153
}