root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / operations / strategies / SelectedZoomVisitor.java @ 10627
History | View | Annotate | Download (3.27 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
* 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 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.operations.strategies; |
42 |
|
43 |
import java.awt.geom.Rectangle2D; |
44 |
|
45 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
46 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
47 |
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException; |
48 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
49 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
50 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
52 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
53 |
|
54 |
|
55 |
/**
|
56 |
* Visitor de zoom a lo seleccionado.
|
57 |
*
|
58 |
* @author Vicente Caballero Navarro
|
59 |
*/
|
60 |
public class SelectedZoomVisitor implements FeatureVisitor { |
61 |
private Rectangle2D rectangle = null; |
62 |
private FBitSet bitset = null; |
63 |
|
64 |
/**
|
65 |
* Inicializa el visitor.
|
66 |
*
|
67 |
* @param layer Capa.
|
68 |
*
|
69 |
* @return True si se inicializa correctamente.
|
70 |
*/
|
71 |
public boolean start(FLayer layer) throws StartVisitorException { |
72 |
if (layer instanceof AlphanumericData) {//TODO Esta comprobaci?n se hacia con Selectable |
73 |
try {
|
74 |
bitset = ((AlphanumericData) layer).getRecordset().getSelection(); |
75 |
} catch (ReadDriverException e) {
|
76 |
e.printStackTrace(); |
77 |
} |
78 |
|
79 |
return true; |
80 |
} |
81 |
|
82 |
return false; |
83 |
} |
84 |
|
85 |
/**
|
86 |
* Finaliza el visitor.
|
87 |
*
|
88 |
* @param layer Capa.
|
89 |
*/
|
90 |
public void stop(FLayer layer) throws VisitorException { |
91 |
} |
92 |
|
93 |
/**
|
94 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor#visit(com.iver.cit.gvsig.fmap.core.IGeometry,
|
95 |
* int)
|
96 |
*/
|
97 |
public void visit(IGeometry g, int index) throws VisitorException, ProcessVisitorException { |
98 |
if (bitset.get(index)) {
|
99 |
if (rectangle == null) { |
100 |
rectangle = (Rectangle2D) g.getBounds2D().clone();
|
101 |
} else {
|
102 |
rectangle.add(g.getBounds2D()); |
103 |
} |
104 |
} |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Devuelve el Extent de los shapes seleccionados, y si no hay ning?n shape
|
109 |
* seleccionado devuelve null.
|
110 |
*
|
111 |
* @return Extent de los shapes seleccionados.
|
112 |
*/
|
113 |
public Rectangle2D getSelectBound() { |
114 |
return rectangle;
|
115 |
} |
116 |
|
117 |
public String getProcessDescription() { |
118 |
return "Defining rectangle to zoom from selected geometries"; |
119 |
} |
120 |
} |