svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / roi / ui / ROIsTablePanel.java @ 21739
History | View | Annotate | Download (17.3 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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 Ib??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 |
package org.gvsig.rastertools.roi.ui; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.Color; |
45 |
import java.awt.Cursor; |
46 |
import java.awt.FlowLayout; |
47 |
import java.awt.Graphics2D; |
48 |
import java.awt.Image; |
49 |
import java.awt.Point; |
50 |
import java.awt.Toolkit; |
51 |
import java.awt.image.BufferedImage; |
52 |
import java.util.ArrayList; |
53 |
import java.util.HashMap; |
54 |
import java.util.Iterator; |
55 |
import java.util.LinkedHashMap; |
56 |
|
57 |
import javax.swing.ImageIcon; |
58 |
import javax.swing.JButton; |
59 |
import javax.swing.JPanel; |
60 |
import javax.swing.JToggleButton; |
61 |
import javax.swing.border.EmptyBorder; |
62 |
import javax.swing.border.LineBorder; |
63 |
import javax.swing.table.DefaultTableModel; |
64 |
|
65 |
import org.gvsig.fmap.raster.grid.roi.VectorialROI; |
66 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
67 |
import org.gvsig.gui.beans.table.TableContainer; |
68 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
69 |
import org.gvsig.gui.beans.table.models.IModel; |
70 |
import org.gvsig.raster.buffer.BufferFactory; |
71 |
import org.gvsig.raster.buffer.RasterBuffer; |
72 |
import org.gvsig.raster.buffer.RasterBufferInvalidException; |
73 |
import org.gvsig.raster.dataset.IRasterDataSource; |
74 |
import org.gvsig.raster.grid.Grid; |
75 |
import org.gvsig.raster.grid.GridException; |
76 |
import org.gvsig.raster.grid.roi.ROI; |
77 |
import org.gvsig.rastertools.roi.ui.listener.DrawMouseViewListener; |
78 |
import org.gvsig.rastertools.roi.ui.listener.ROIsTablePanelListener; |
79 |
|
80 |
import com.iver.andami.PluginServices; |
81 |
import com.iver.andami.ui.mdiManager.IWindow; |
82 |
import com.iver.cit.gvsig.fmap.MapControl; |
83 |
import com.iver.cit.gvsig.fmap.ViewPort; |
84 |
import com.iver.cit.gvsig.fmap.core.FShape; |
85 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
86 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
87 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
88 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
89 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
90 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
91 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
92 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
93 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
94 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
95 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
96 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior; |
97 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior; |
98 |
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior; |
99 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
100 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
101 |
|
102 |
/**
|
103 |
* Panel con la tabla de ROIs.
|
104 |
*
|
105 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es)
|
106 |
*
|
107 |
*/
|
108 |
public class ROIsTablePanel extends JPanel { |
109 |
private static final long serialVersionUID = 2138437448356198224L; |
110 |
|
111 |
private ROIsTablePanelListener listener = null; |
112 |
|
113 |
private JPanel controlPanel = null; |
114 |
|
115 |
private JPanel tableButtonsPanel = null; |
116 |
|
117 |
private JPanel toolsPanel = null; |
118 |
|
119 |
private TableContainer tableContainer = null; |
120 |
|
121 |
private JButton newButton = null; |
122 |
|
123 |
private JButton deleteButton = null; |
124 |
|
125 |
private JToggleButton pointToolButton = null; |
126 |
|
127 |
private JToggleButton lineToolButton = null; |
128 |
|
129 |
private JToggleButton polygonToolButton = null; |
130 |
|
131 |
private FLayer fLayer = null; |
132 |
|
133 |
private MapControl mapControl = null; |
134 |
|
135 |
private View view = null; |
136 |
|
137 |
private LinkedHashMap rois = null; |
138 |
|
139 |
private HashMap roiGraphics = null; |
140 |
|
141 |
private Grid grid = null; |
142 |
|
143 |
private String pathToImages = "images/"; |
144 |
|
145 |
private Cursor cursor = null; |
146 |
|
147 |
private String previousTool = null; |
148 |
|
149 |
public ROIsTablePanel() {
|
150 |
super();
|
151 |
|
152 |
setBorder(new LineBorder(Color.GRAY)); |
153 |
setLayout(new BorderLayout()); |
154 |
add(getTable(), BorderLayout.CENTER);
|
155 |
add(getControlPanel(), BorderLayout.SOUTH);
|
156 |
|
157 |
initialize(); |
158 |
} |
159 |
|
160 |
private void initialize() { |
161 |
listener = new ROIsTablePanelListener(this); |
162 |
getNewButton().addActionListener(listener); |
163 |
getDeleteButton().addActionListener(listener); |
164 |
getPointToolButton().addActionListener(listener); |
165 |
getLineToolButton().addActionListener(listener); |
166 |
getPolygonToolButton().addActionListener(listener); |
167 |
getTable().getTable().getJTable().getSelectionModel() |
168 |
.addListSelectionListener(listener); |
169 |
getTable().getTable().getJTable().getModel().addTableModelListener( |
170 |
listener); |
171 |
|
172 |
getPolygonToolButton().setSelected(true);
|
173 |
setToolsEnabled(false);
|
174 |
} |
175 |
|
176 |
public void setToolsEnabled(boolean b) { |
177 |
getPointToolButton().setEnabled(b); |
178 |
getLineToolButton().setEnabled(b); |
179 |
getPolygonToolButton().setEnabled(b); |
180 |
} |
181 |
|
182 |
public TableContainer getTable() {
|
183 |
if (tableContainer == null) { |
184 |
String[] columnNames = { PluginServices.getText(this, "nombre"), |
185 |
PluginServices.getText(this, "poligonos"), |
186 |
PluginServices.getText(this, "lineas"), |
187 |
PluginServices.getText(this, "puntos"), |
188 |
PluginServices.getText(this, "color"), |
189 |
PluginServices.getText(this, "pixeles")}; |
190 |
int[] columnWidths = { 50, 25, 25, 25, 45, 50 }; |
191 |
tableContainer = new TableContainer(columnNames, columnWidths);
|
192 |
tableContainer.setModel("ROIsTableModel");
|
193 |
tableContainer.initialize(); |
194 |
tableContainer.setControlVisible(false);
|
195 |
tableContainer.setBorder(new EmptyBorder(5, 5, 0, 5)); |
196 |
} |
197 |
return tableContainer;
|
198 |
} |
199 |
|
200 |
public JPanel getControlPanel() { |
201 |
if (controlPanel == null) { |
202 |
controlPanel = new JPanel(); |
203 |
controlPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
204 |
|
205 |
controlPanel.add(getTableButtonsPanel()); |
206 |
|
207 |
controlPanel.add(getToolsPanel()); |
208 |
// controlPanel.add(getToolBar());
|
209 |
} |
210 |
return controlPanel;
|
211 |
} |
212 |
|
213 |
public JButton getDeleteButton() { |
214 |
if (deleteButton == null) { |
215 |
deleteButton = new JButton(PluginServices.getText(this, "borrar")); |
216 |
} |
217 |
return deleteButton;
|
218 |
} |
219 |
|
220 |
public JButton getNewButton() { |
221 |
if (newButton == null) { |
222 |
newButton = new JButton(PluginServices.getText(this, "nuevo")); |
223 |
} |
224 |
return newButton;
|
225 |
} |
226 |
|
227 |
public FLayer getFLayer() {
|
228 |
return fLayer;
|
229 |
} |
230 |
|
231 |
public void setFLayer(FLayer layer) throws GridException { |
232 |
fLayer = layer; |
233 |
FLyrRasterSE rasterLayer = (FLyrRasterSE) layer; |
234 |
IRasterDataSource dsetCopy = null;
|
235 |
dsetCopy = rasterLayer.getDataSource().newDataset(); |
236 |
BufferFactory bufferFactory = new BufferFactory(dsetCopy);
|
237 |
if (!RasterBuffer.loadInMemory(dsetCopy))
|
238 |
bufferFactory.setReadOnly(true);
|
239 |
bufferFactory.setAllDrawableBands(); |
240 |
|
241 |
int bands[] = null; |
242 |
bands = new int[rasterLayer.getBandCount()]; |
243 |
for (int i = 0; i < rasterLayer.getBandCount(); i++) |
244 |
bands[i] = i; |
245 |
try {
|
246 |
grid = new Grid(bufferFactory, bands);
|
247 |
} catch (RasterBufferInvalidException e) {
|
248 |
e.printStackTrace(); |
249 |
} |
250 |
|
251 |
if (view==null){ |
252 |
IWindow[] list = PluginServices.getMDIManager().getAllWindows();
|
253 |
for (int i = 0; i < list.length; i++) { |
254 |
if(list[i] instanceof View) |
255 |
view = (View)list[i];
|
256 |
} |
257 |
if (view == null) |
258 |
return;
|
259 |
mapControl = view.getMapControl(); |
260 |
|
261 |
/*
|
262 |
* Guardar la herramienta actual para recuperarla m?s tarde, por ejemplo
|
263 |
* al cerrar el contenedor del este panel.
|
264 |
*/
|
265 |
previousTool = mapControl.getCurrentTool(); |
266 |
|
267 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n
|
268 |
// en
|
269 |
// la barra de estado
|
270 |
StatusBarListener sbl = new StatusBarListener(mapControl);
|
271 |
|
272 |
DrawMouseViewListener drawMouseViewListener = new DrawMouseViewListener(
|
273 |
this);
|
274 |
mapControl.addMapTool("drawPolygonROI", new Behavior[] { |
275 |
new PolygonBehavior(drawMouseViewListener),
|
276 |
new MouseMovementBehavior(sbl) });
|
277 |
mapControl.addMapTool("drawLineROI", new Behavior[] { |
278 |
new PolylineBehavior(drawMouseViewListener),
|
279 |
new MouseMovementBehavior(sbl) });
|
280 |
mapControl.addMapTool("drawPointROI", new Behavior[] { |
281 |
new PointBehavior(drawMouseViewListener),
|
282 |
new MouseMovementBehavior(sbl) });
|
283 |
} |
284 |
|
285 |
/*
|
286 |
* Caragar las ROIs asociadas a la capa, si las hay:
|
287 |
*/
|
288 |
clearROIs(); |
289 |
loadROIs(); |
290 |
} |
291 |
|
292 |
/**
|
293 |
* Elimina todas las filas de la tabla de rois as? como la ROI y objetos
|
294 |
* FGraphic asociados (borr?ndolos tambi?n de la vista) a cada una.
|
295 |
*
|
296 |
*/
|
297 |
private void clearROIs() { |
298 |
boolean repaint = false; |
299 |
try {
|
300 |
getTable().removeAllRows(); |
301 |
} catch (NotInitializeException e) {
|
302 |
// TODO Auto-generated catch block
|
303 |
e.printStackTrace(); |
304 |
} |
305 |
for (Iterator iter = getRoiGraphics().values().iterator(); iter.hasNext();) { |
306 |
ArrayList roiGraphics = (ArrayList) iter.next(); |
307 |
for (int i = 0; i < roiGraphics.size(); i++){ |
308 |
getMapControl().getMapContext().getGraphicsLayer().removeGraphic((FGraphic)roiGraphics.get(i)); |
309 |
repaint = true;
|
310 |
} |
311 |
} |
312 |
if (repaint)
|
313 |
getMapControl().rePaintDirtyLayers(); |
314 |
getRoiGraphics().clear(); |
315 |
getRois().clear(); |
316 |
} |
317 |
|
318 |
/**
|
319 |
* Cargar las ROIs asociadas a la capa, si las hay.
|
320 |
* @throws GridException
|
321 |
*
|
322 |
*/
|
323 |
private void loadROIs() throws GridException { |
324 |
ArrayList roisArray = ((FLyrRasterSE) fLayer).getRois();
|
325 |
if (roisArray != null) { |
326 |
GraphicLayer graphicLayer = getMapControl().getMapContext() |
327 |
.getGraphicsLayer(); |
328 |
ISymbol symbol = null;
|
329 |
FGraphic fGraphic = null;
|
330 |
int nPoints, nPolygons, nLines;
|
331 |
|
332 |
for (Iterator iter = roisArray.iterator(); iter.hasNext();) { |
333 |
ROI roi = (ROI) iter.next(); |
334 |
|
335 |
nPoints = 0;
|
336 |
nPolygons = 0;
|
337 |
nLines = 0;
|
338 |
|
339 |
Object row[] = ((IModel) getTable().getModel()).getNewLine(); |
340 |
row[0] = roi.getName();
|
341 |
row[4] = roi.getColor();
|
342 |
|
343 |
addROI(roi); |
344 |
VectorialROI vectorialROI = (VectorialROI) roi; |
345 |
for (Iterator iterator = vectorialROI.getGeometries() |
346 |
.iterator(); iterator.hasNext();) { |
347 |
IGeometry geometry = (IGeometry) iterator.next(); |
348 |
switch (geometry.getGeometryType()) {
|
349 |
case FShape.POINT:
|
350 |
symbol = SymbologyFactory.createDefaultMarkerSymbol(); |
351 |
((IMarkerSymbol) symbol).setColor(roi.getColor()); |
352 |
nPoints++; |
353 |
break;
|
354 |
case FShape.POLYGON:
|
355 |
symbol = SymbologyFactory.createDefaultFillSymbol(); |
356 |
((IFillSymbol) symbol).setFillColor(roi.getColor()); |
357 |
nPolygons++; |
358 |
break;
|
359 |
case FShape.LINE:
|
360 |
symbol = SymbologyFactory.createDefaultLineSymbol(); |
361 |
((ILineSymbol) symbol).setLineColor(roi.getColor()); |
362 |
nLines++; |
363 |
break;
|
364 |
} |
365 |
fGraphic = new FGraphic(geometry, graphicLayer
|
366 |
.addSymbol(symbol)); |
367 |
graphicLayer.addGraphic(fGraphic); |
368 |
getRoiGraphics(roi.getName()).add(fGraphic); |
369 |
} |
370 |
row[1] = new Integer(nPolygons); |
371 |
row[2] = new Integer(nLines); |
372 |
row[3] = new Integer(nPoints); |
373 |
row[5] = new Integer(roi.getValues()); |
374 |
((DefaultTableModel) getTable().getModel()).addRow(row);
|
375 |
} |
376 |
selectDrawRoiTool(); |
377 |
getMapControl().drawGraphics(); |
378 |
} |
379 |
} |
380 |
|
381 |
public MapControl getMapControl() {
|
382 |
return mapControl;
|
383 |
} |
384 |
|
385 |
public void selectDrawRoiTool() { |
386 |
if (mapControl != null) |
387 |
if (getPolygonToolButton().isSelected()) {
|
388 |
Image img = new ImageIcon(getClass().getResource( |
389 |
"images/PoligonCursor.png")).getImage();
|
390 |
cursor = Toolkit.getDefaultToolkit().createCustomCursor(img,
|
391 |
new Point(16, 16), ""); |
392 |
mapControl.setTool("drawPolygonROI");
|
393 |
} else if (getLineToolButton().isSelected()) { |
394 |
Image img = new ImageIcon(getClass().getResource( |
395 |
"images/LineCursor.png")).getImage();
|
396 |
cursor = Toolkit.getDefaultToolkit().createCustomCursor(img,
|
397 |
new Point(16, 16), ""); |
398 |
mapControl.setTool("drawLineROI");
|
399 |
} else if (getPointToolButton().isSelected()) { |
400 |
Image img = new ImageIcon(getClass().getResource( |
401 |
"images/PointCursor.png")).getImage();
|
402 |
cursor = Toolkit.getDefaultToolkit().createCustomCursor(img,
|
403 |
new Point(16, 16), ""); |
404 |
mapControl.setTool("drawPointROI");
|
405 |
} |
406 |
} |
407 |
|
408 |
public Grid getGrid() {
|
409 |
return grid;
|
410 |
} |
411 |
|
412 |
private LinkedHashMap getRois() { |
413 |
if (rois == null) |
414 |
rois = new LinkedHashMap(); |
415 |
return rois;
|
416 |
} |
417 |
|
418 |
public JPanel getToolsPanel() { |
419 |
if (toolsPanel == null) { |
420 |
toolsPanel = new JPanel(); |
421 |
toolsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
422 |
toolsPanel.add(getPointToolButton()); |
423 |
toolsPanel.add(getLineToolButton()); |
424 |
toolsPanel.add(getPolygonToolButton()); |
425 |
} |
426 |
return toolsPanel;
|
427 |
} |
428 |
|
429 |
public JPanel getTableButtonsPanel() { |
430 |
if (tableButtonsPanel == null) { |
431 |
tableButtonsPanel = new JPanel(); |
432 |
tableButtonsPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
433 |
|
434 |
tableButtonsPanel.add(getNewButton()); |
435 |
|
436 |
tableButtonsPanel.add(getDeleteButton()); |
437 |
} |
438 |
return tableButtonsPanel;
|
439 |
} |
440 |
|
441 |
public JToggleButton getPointToolButton() { |
442 |
if (pointToolButton == null) { |
443 |
pointToolButton = new JToggleButton(); |
444 |
pointToolButton.setIcon(new ImageIcon(getClass().getResource( |
445 |
pathToImages + "Point.png")));
|
446 |
} |
447 |
return pointToolButton;
|
448 |
} |
449 |
|
450 |
public JToggleButton getLineToolButton() { |
451 |
if (lineToolButton == null) { |
452 |
lineToolButton = new JToggleButton(); |
453 |
lineToolButton.setIcon(new ImageIcon(getClass().getResource( |
454 |
pathToImages + "Line.png")));
|
455 |
} |
456 |
return lineToolButton;
|
457 |
} |
458 |
|
459 |
public JToggleButton getPolygonToolButton() { |
460 |
if (polygonToolButton == null) { |
461 |
polygonToolButton = new JToggleButton(); |
462 |
polygonToolButton.setIcon(new ImageIcon(getClass().getResource( |
463 |
pathToImages + "Poligon.png")));
|
464 |
} |
465 |
return polygonToolButton;
|
466 |
} |
467 |
|
468 |
public Cursor getToolCursor() { |
469 |
return cursor;
|
470 |
} |
471 |
|
472 |
public View getView() { |
473 |
return view;
|
474 |
} |
475 |
|
476 |
/**
|
477 |
* Dibuja en la vista las ROIs que aparecen en la tabla.
|
478 |
*
|
479 |
*/
|
480 |
public void drawROIs() { |
481 |
Color geometryColor;
|
482 |
|
483 |
BufferedImage img = getMapControl().getImage();
|
484 |
Graphics2D gImag = (Graphics2D) img.getGraphics(); |
485 |
ViewPort vp = getMapControl().getViewPort(); |
486 |
try {
|
487 |
for (int i = 0; i < getTable().getRowCount(); i++) { |
488 |
geometryColor = (Color) getTable().getModel().getValueAt(i, 4); |
489 |
VectorialROI vROI = (VectorialROI) getRois().get( |
490 |
getTable().getTable().getJTable().getValueAt(i, 0));
|
491 |
|
492 |
for (Iterator iter = vROI.getGeometries().iterator(); iter |
493 |
.hasNext();) { |
494 |
IGeometry geometry = (IGeometry) iter.next(); |
495 |
|
496 |
ISymbol sym = SymbologyFactory |
497 |
.createDefaultSymbolByShapeType(geometry |
498 |
.getGeometryType(), geometryColor); |
499 |
geometry.draw(gImag, vp, sym, null);
|
500 |
} |
501 |
} |
502 |
getView().repaint(); |
503 |
} catch (NotInitializeException e) {
|
504 |
// TODO Auto-generated catch block
|
505 |
e.printStackTrace(); |
506 |
} |
507 |
} |
508 |
|
509 |
private HashMap getRoiGraphics() { |
510 |
if (roiGraphics == null) |
511 |
roiGraphics = new HashMap(); |
512 |
return roiGraphics;
|
513 |
} |
514 |
|
515 |
public void addROI(ROI roi) { |
516 |
getRois().put(roi.getName(), roi); |
517 |
getRoiGraphics().put(roi.getName(), new ArrayList()); |
518 |
} |
519 |
|
520 |
public ROI getROI(String roiName) { |
521 |
|
522 |
return (ROI) getRois().get(roiName);
|
523 |
} |
524 |
|
525 |
/**
|
526 |
* Elimina la ROI correspondiente al nombre <code>roiName</code> as?
|
527 |
* como sus objetos FGraphic asociados (borr?ndolos tambi?n de la vista).
|
528 |
* (NO elimina la fila correspondiente en la tabla del panel).
|
529 |
*
|
530 |
* @param roiName Nombre de la ROI a eliminar.
|
531 |
*/
|
532 |
public void removeROI(String roiName) { |
533 |
boolean repaint = false; |
534 |
getRois().remove(roiName); |
535 |
ArrayList roiGraphics = getRoiGraphics(roiName);
|
536 |
if (roiGraphics != null) { |
537 |
for (int i = 0; i < roiGraphics.size(); i++){ |
538 |
getMapControl().getMapContext().getGraphicsLayer().removeGraphic((FGraphic) getRoiGraphics(roiName).get(i)); |
539 |
repaint = true;
|
540 |
} |
541 |
if (repaint)
|
542 |
getMapControl().rePaintDirtyLayers(); |
543 |
getRoiGraphics().remove(roiName); |
544 |
} |
545 |
} |
546 |
|
547 |
public ArrayList getRoiGraphics(String roiName) { |
548 |
return (ArrayList) getRoiGraphics().get(roiName); |
549 |
} |
550 |
|
551 |
/**
|
552 |
* Borra de capa GraphicsLayer de mapContext los gr?ficos pertenecientes a
|
553 |
* las rois del panel. Si la GraphicsLayer se queda sin gr?ficos se eliminan
|
554 |
* tambien los s?mbolos de esta.
|
555 |
*/
|
556 |
public void clearRoiGraphics() { |
557 |
for (Iterator iter = getRoiGraphics().values().iterator(); iter |
558 |
.hasNext();) { |
559 |
ArrayList fGraphics = (ArrayList) iter.next(); |
560 |
|
561 |
for (Iterator iterator = fGraphics.iterator(); iterator.hasNext();) { |
562 |
FGraphic fGraphic = (FGraphic) iterator.next(); |
563 |
getMapControl().getMapContext().getGraphicsLayer() |
564 |
.removeGraphic(fGraphic); |
565 |
} |
566 |
} |
567 |
if (getMapControl().getMapContext().getGraphicsLayer().getNumGraphics() == 0) |
568 |
getMapControl().getMapContext().getGraphicsLayer() |
569 |
.clearSymbolsGraphics(); |
570 |
} |
571 |
|
572 |
public ArrayList getROIs() { |
573 |
return new ArrayList(getRois().values()); |
574 |
} |
575 |
|
576 |
public void setPreviousTool() { |
577 |
if (previousTool != null) |
578 |
getMapControl().setTool(previousTool); |
579 |
} |
580 |
|
581 |
public void changeRoiName(String currentName, String newName) { |
582 |
getROI(currentName).setName(newName); |
583 |
getRois().put(newName, getRois().remove(currentName)); |
584 |
getRoiGraphics().put(newName, getRoiGraphics().remove(currentName)); |
585 |
} |
586 |
|
587 |
public void sortTable(){ |
588 |
|
589 |
} |
590 |
} |