svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / selectionByTheme / MySelectionByThemeListener.java @ 10626
History | View | Annotate | Download (5.87 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.gui.selectionByTheme; |
42 |
|
43 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
44 |
import com.iver.andami.messages.NotificationManager; |
45 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
46 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
47 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
48 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
49 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
50 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
51 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Selectable; |
52 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData; |
53 |
import com.iver.cit.gvsig.fmap.operations.strategies.QueryByThemeVisitor; |
54 |
|
55 |
/**
|
56 |
* DOCUMENT ME!
|
57 |
*
|
58 |
* @author Fernando Gonz?lez Cort?s
|
59 |
*/
|
60 |
public class MySelectionByThemeListener implements SelectionByThemeListener { |
61 |
/**
|
62 |
* @see com.iver.cit.gvsig.gui.selectionByTheme.SelectionByThemeListener#newSet(int,
|
63 |
* int, int)
|
64 |
*/
|
65 |
public void newSet(FLayer[] toSelect, FLayer selectionLayer, int action) { |
66 |
long t1 = System.currentTimeMillis(); |
67 |
if (selectionLayer instanceof FLyrVect) { |
68 |
try {
|
69 |
Selectable selected = ((FLyrVect) selectionLayer) |
70 |
.getRecordset(); |
71 |
for (int i = 0; i < toSelect.length; i++) { |
72 |
if (toSelect[i] instanceof FLyrVect) { |
73 |
Selectable capa = ((FLyrVect) toSelect[i]) |
74 |
.getRecordset(); |
75 |
QueryByThemeVisitor visitor = new QueryByThemeVisitor(
|
76 |
toSelect[i], selectionLayer, action); |
77 |
capa.clearSelection(); |
78 |
|
79 |
((VectorialData) selectionLayer).process(visitor, |
80 |
selected.getSelection()); |
81 |
capa.setSelection(visitor.getBitset()); |
82 |
} |
83 |
} |
84 |
} catch (ProcessVisitorException e) {
|
85 |
NotificationManager.addError("Error leyendo las capas", e);
|
86 |
} catch (ReadDriverException e) {
|
87 |
NotificationManager.addError("Error leyendo las capas", e);
|
88 |
} catch (ExpansionFileReadException e) {
|
89 |
NotificationManager.addError("Error leyendo las capas", e);
|
90 |
} catch (VisitorException e) {
|
91 |
NotificationManager.addError("Error leyendo las capas", e);
|
92 |
} |
93 |
|
94 |
} |
95 |
long t2 = System.currentTimeMillis(); |
96 |
System.out
|
97 |
.println("Tiempo de consulta: " + (t2 - t1) + " milisegundos"); |
98 |
// doSelection(toSelect, selectionLayer, action, false);
|
99 |
} |
100 |
|
101 |
/**
|
102 |
* @see com.iver.cit.gvsig.gui.selectionByTheme.SelectionByThemeListener#addToSet(int,
|
103 |
* int, int)
|
104 |
*/
|
105 |
public void addToSet(FLayer[] toSelect, FLayer selectionLayer, int action) { |
106 |
if (selectionLayer instanceof FLyrVect) { |
107 |
try {
|
108 |
Selectable selected = ((FLyrVect) selectionLayer) |
109 |
.getRecordset(); |
110 |
for (int i = 0; i < toSelect.length; i++) { |
111 |
if (toSelect[i] instanceof FLyrVect) { |
112 |
Selectable capa = ((FLyrVect) toSelect[i]) |
113 |
.getRecordset(); |
114 |
QueryByThemeVisitor visitor = new QueryByThemeVisitor(
|
115 |
toSelect[i], selectionLayer, action); |
116 |
FBitSet selection = capa.getSelection(); |
117 |
((VectorialData) selectionLayer).process(visitor, |
118 |
selected.getSelection()); |
119 |
selection.or(visitor.getBitset()); |
120 |
capa.setSelection(selection); |
121 |
} |
122 |
} |
123 |
} catch (ReadDriverException e) {
|
124 |
NotificationManager.addError("Error leyendo las capas", e);
|
125 |
} catch (ProcessVisitorException e) {
|
126 |
NotificationManager.addError("Error leyendo las capas", e);
|
127 |
} catch (ExpansionFileReadException e) {
|
128 |
NotificationManager.addError("Error leyendo las capas", e);
|
129 |
} catch (VisitorException e) {
|
130 |
NotificationManager.addError("Error leyendo las capas", e);
|
131 |
} |
132 |
} |
133 |
} |
134 |
|
135 |
/**
|
136 |
* @see com.iver.cit.gvsig.gui.selectionByTheme.SelectionByThemeListener#fromSet(int,
|
137 |
* int, int)
|
138 |
*/
|
139 |
public void fromSet(FLayer[] toSelect, FLayer selectionLayer, int action) { |
140 |
if (selectionLayer instanceof FLyrVect) { |
141 |
try {
|
142 |
Selectable selected = ((FLyrVect) selectionLayer) |
143 |
.getRecordset(); |
144 |
for (int i = 0; i < toSelect.length; i++) { |
145 |
if (toSelect[i] instanceof FLyrVect) { |
146 |
Selectable capa = ((FLyrVect) toSelect[i]) |
147 |
.getRecordset(); |
148 |
|
149 |
QueryByThemeVisitor visitor = new QueryByThemeVisitor(
|
150 |
toSelect[i], selectionLayer, action); |
151 |
FBitSet selection = capa.getSelection(); |
152 |
((VectorialData) selectionLayer).process(visitor, |
153 |
selected.getSelection()); |
154 |
selection.and(visitor.getBitset()); |
155 |
capa.setSelection(selection); |
156 |
} |
157 |
} |
158 |
} catch (ReadDriverException e) {
|
159 |
NotificationManager.addError("Error leyendo las capas", e);
|
160 |
} catch (ProcessVisitorException e) {
|
161 |
NotificationManager.addError("Error leyendo las capas", e);
|
162 |
} catch (ExpansionFileReadException e) {
|
163 |
NotificationManager.addError("Error leyendo las capas", e);
|
164 |
} catch (VisitorException e) {
|
165 |
NotificationManager.addError("Error leyendo las capas", e);
|
166 |
} |
167 |
|
168 |
} |
169 |
} |
170 |
} |