root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / CreateSpatialIndexMonitorableTask.java @ 21299
History | View | Annotate | Download (4.5 KB)
1 |
/*
|
---|---|
2 |
* Created on 03-may-2006
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id: CreateSpatialIndexMonitorableTask.java 21299 2008-06-06 10:23:57Z vcaballero $
|
47 |
* $Log$
|
48 |
* Revision 1.4 2007-07-30 12:56:04 jaume
|
49 |
* organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
|
50 |
*
|
51 |
* Revision 1.3 2007/05/15 07:22:56 cesar
|
52 |
* Add the finished method for execution from Event Dispatch Thread
|
53 |
*
|
54 |
* Revision 1.2 2007/03/06 16:37:08 caballero
|
55 |
* Exceptions
|
56 |
*
|
57 |
* Revision 1.1 2006/09/15 10:41:30 caballero
|
58 |
* extensibilidad de documentos
|
59 |
*
|
60 |
* Revision 1.2 2006/05/22 10:35:41 fjp
|
61 |
* Monitorable tasks easy
|
62 |
*
|
63 |
* Revision 1.1 2006/05/08 15:41:06 azabala
|
64 |
* added rtree spatial indexing capabilities
|
65 |
*
|
66 |
*
|
67 |
*/
|
68 |
package com.iver.cit.gvsig.project.documents.view.legend; |
69 |
|
70 |
import org.gvsig.data.ReadException; |
71 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
72 |
|
73 |
import com.iver.andami.PluginServices; |
74 |
import com.iver.utiles.swing.threads.CancellableMonitorable; |
75 |
import com.iver.utiles.swing.threads.DefaultCancellableMonitorable; |
76 |
import com.iver.utiles.swing.threads.IMonitorableTask; |
77 |
|
78 |
public class CreateSpatialIndexMonitorableTask implements IMonitorableTask{ |
79 |
|
80 |
String MAIN_MESSAGE;
|
81 |
String HULL_MESSAGE = PluginServices.getText(this, "Indexando"); |
82 |
String OF = "de"; |
83 |
|
84 |
FLyrVect layer; |
85 |
/**
|
86 |
* It monitors advance of indexing process
|
87 |
*/
|
88 |
private CancellableMonitorable cancelMonitor = null; |
89 |
/**
|
90 |
* flag to tell if the process is finished
|
91 |
*/
|
92 |
private boolean finished = false; |
93 |
|
94 |
/**
|
95 |
* Default constructor
|
96 |
* @throws DriverIOException
|
97 |
* @throws DriverException
|
98 |
*/
|
99 |
public CreateSpatialIndexMonitorableTask(FLyrVect layer) throws ReadException{ |
100 |
this.layer = layer;
|
101 |
MAIN_MESSAGE = PluginServices.getText(this, "Indexando_espacialmente") + |
102 |
layer.getName(); |
103 |
cancelMonitor = createCancelMonitor(); |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Creates a CancellableMonitorable instance to monitor
|
108 |
* progress and to cancel the process.
|
109 |
* @return
|
110 |
* @throws DriverIOException
|
111 |
* @throws DriverException
|
112 |
*/
|
113 |
private CancellableMonitorable createCancelMonitor()
|
114 |
throws ReadException {
|
115 |
DefaultCancellableMonitorable monitor = |
116 |
new DefaultCancellableMonitorable();
|
117 |
monitor.setInitialStep(0);
|
118 |
monitor.setDeterminatedProcess(true);
|
119 |
int numSteps = ((FLyrVect)layer).getSource().getShapeCount();
|
120 |
monitor.setFinalStep(numSteps); |
121 |
return monitor;
|
122 |
} |
123 |
|
124 |
public void run() throws Exception { |
125 |
((FLyrVect)layer).createSpatialIndex(cancelMonitor); |
126 |
finished = true;
|
127 |
} |
128 |
|
129 |
public int getInitialStep() { |
130 |
return cancelMonitor.getInitialStep();
|
131 |
} |
132 |
|
133 |
public int getFinishStep() { |
134 |
return cancelMonitor.getFinalStep();
|
135 |
} |
136 |
|
137 |
public int getCurrentStep() { |
138 |
return cancelMonitor.getCurrentStep();
|
139 |
} |
140 |
|
141 |
public String getStatusMessage() { |
142 |
return MAIN_MESSAGE;
|
143 |
} |
144 |
|
145 |
public String getNote() { |
146 |
return HULL_MESSAGE + " " + |
147 |
getCurrentStep()+ " " +
|
148 |
OF + " "+
|
149 |
getFinishStep(); |
150 |
} |
151 |
//FIXME Borrar los ficheros de indice en caso de cancelacion
|
152 |
public void cancel() { |
153 |
((DefaultCancellableMonitorable) cancelMonitor).setCanceled(true);
|
154 |
} |
155 |
/**
|
156 |
* Tells if it is a defined process (we know its number of steps)
|
157 |
*/
|
158 |
public boolean isDefined() { |
159 |
return true; |
160 |
} |
161 |
public boolean isCanceled() { |
162 |
return cancelMonitor.isCanceled();
|
163 |
} |
164 |
|
165 |
public boolean isFinished() { |
166 |
return finished;
|
167 |
} |
168 |
|
169 |
/* (non-Javadoc)
|
170 |
* @see com.iver.utiles.swing.threads.IMonitorableTask#finished()
|
171 |
*/
|
172 |
public void finished() { |
173 |
// TODO Auto-generated method stub
|
174 |
|
175 |
} |
176 |
}//CreateSpatialIndexMonitorableTask
|
177 |
|
178 |
|