12 |
12 |
|
13 |
13 |
import com.hardcode.driverManager.DriverLoadException;
|
14 |
14 |
import com.hardcode.gdbms.engine.data.DataSource;
|
15 |
|
import com.hardcode.gdbms.engine.data.NoSuchTableException;
|
16 |
15 |
import com.iver.cit.gvsig.fmap.ViewPort;
|
17 |
16 |
import com.iver.cit.gvsig.fmap.core.IGeometry;
|
18 |
17 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
|
... | ... | |
21 |
20 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
|
22 |
21 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
|
23 |
22 |
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
|
|
23 |
import com.iver.cit.gvsig.fmap.rendering.Legend;
|
|
24 |
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent;
|
24 |
25 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
|
25 |
|
import com.iver.cit.gvsig.fmap.rendering.Legend;
|
26 |
26 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
|
27 |
27 |
import com.iver.utiles.XMLEntity;
|
28 |
28 |
|
... | ... | |
38 |
38 |
listeners.remove(listener);
|
39 |
39 |
}
|
40 |
40 |
|
|
41 |
public void addSelectionListener(SelectionListener listener) {
|
|
42 |
selectionSupport.addSelectionListener(listener);
|
|
43 |
}
|
|
44 |
|
|
45 |
public void removeSelectionListener(SelectionListener listener) {
|
|
46 |
selectionSupport.removeSelectionListener(listener);
|
|
47 |
}
|
|
48 |
|
41 |
49 |
/**
|
42 |
50 |
* Cuando ocurre un evento de cambio en la selecci?n, ?ste puede ser uno de una gran cantidad de eventos. Con el fin de no propagar todos estos eventos, se realiza la propagaci?n de manera manual al final de la "r?faga" de eventos
|
43 |
51 |
*/
|
44 |
52 |
public void fireSelectionEvents() {
|
45 |
|
LayerEvent e = new LayerEvent();
|
46 |
|
e.setLayer(this);
|
|
53 |
selectionSupport.fireSelectionEvents();
|
|
54 |
}
|
|
55 |
|
|
56 |
private void callLegendChanged(LegendChangedEvent e){
|
47 |
57 |
for (Iterator iter = listeners.iterator(); iter.hasNext();) {
|
48 |
58 |
LayerListener listener = (LayerListener) iter.next();
|
49 |
59 |
|
50 |
|
listener.selectionChanged(e);
|
|
60 |
listener.legendChanged(e);
|
51 |
61 |
}
|
52 |
62 |
}
|
53 |
63 |
|
... | ... | |
59 |
69 |
source = va;
|
60 |
70 |
}
|
61 |
71 |
|
62 |
|
private BitSet selected = new BitSet();
|
63 |
|
|
64 |
72 |
/**
|
65 |
73 |
* @supplierCardinality 0..*
|
66 |
74 |
*/
|
67 |
75 |
private ArrayList listeners = new ArrayList();
|
68 |
76 |
|
|
77 |
private SelectionSupport selectionSupport = new SelectionSupport();
|
|
78 |
|
69 |
79 |
/**
|
70 |
80 |
* @clientCardinality 0..*
|
71 |
81 |
*/
|
... | ... | |
120 |
130 |
* @see com.iver.cit.gvsig.fmap.layers.CommonOperations#setSelection(com.iver.cit.gvsig.fmap.operations.selection.VectorialSubSet)
|
121 |
131 |
*/
|
122 |
132 |
public void setSelection(BitSet selection) {
|
123 |
|
selected = selection;
|
|
133 |
selectionSupport.setSelection(selection);
|
124 |
134 |
}
|
125 |
135 |
|
126 |
136 |
/**
|
127 |
137 |
* @see com.iver.cit.gvsig.fmap.layers.CommonOperations#isSelected(int)
|
128 |
138 |
*/
|
129 |
139 |
public boolean isSelected(int index) {
|
130 |
|
return selected.get(index);
|
|
140 |
return selectionSupport.isSelected(index);
|
131 |
141 |
}
|
132 |
142 |
|
133 |
143 |
/**
|
134 |
144 |
* @see com.iver.cit.gvsig.fmap.layers.CommonOperations#getSelection()
|
135 |
145 |
*/
|
136 |
146 |
public BitSet getSelection() {
|
137 |
|
return selected;
|
|
147 |
return selectionSupport.getSelection();
|
138 |
148 |
}
|
139 |
149 |
|
140 |
150 |
/**
|
141 |
151 |
* @see com.iver.cit.gvsig.fmap.layers.CommonOperations#clearSelection()
|
142 |
152 |
*/
|
143 |
153 |
public void clearSelection() {
|
144 |
|
selected.clear();
|
|
154 |
selectionSupport.clearSelection();
|
145 |
155 |
}
|
146 |
156 |
|
147 |
157 |
/**
|
... | ... | |
196 |
206 |
* @throws DriverLoadException
|
197 |
207 |
* @see com.iver.cit.gvsig.fmap.layers.CommonOperations#getRecordset()
|
198 |
208 |
*/
|
199 |
|
public DataSource getRecordset() throws DriverLoadException {
|
200 |
|
try {
|
201 |
|
return source.getRecordset(getName() + "Table");
|
202 |
|
} catch (NoSuchTableException e) {
|
203 |
|
throw new RuntimeException("Error de implementaci?n, se ha a?adido una tabla y luego esa tabla no ha podido ser cargada");
|
204 |
|
}
|
|
209 |
public SelectableDataSource getRecordset() throws DriverLoadException {
|
|
210 |
DataSource ds = source.getRecordset(getName() + "Table");
|
|
211 |
SelectableDataSource sds = new SelectableDataSource(ds);
|
|
212 |
sds.setSelectionSupport(selectionSupport);
|
|
213 |
return sds;
|
205 |
214 |
}
|
206 |
215 |
|
207 |
216 |
/**
|
208 |
217 |
* @see com.iver.cit.gvsig.fmap.layers.CommonOperations#setLegend(int, com.iver.cit.gvsig.fmap.rendering.Legend)
|
209 |
218 |
*/
|
210 |
219 |
public void setLegend(VectorialLegend r) {
|
|
220 |
VectorialLegend oldLegend = legend;
|
211 |
221 |
legend = r;
|
|
222 |
|
|
223 |
LegendChangedEvent e = new LegendChangedEvent(oldLegend, r);
|
|
224 |
callLegendChanged(e);
|
212 |
225 |
}
|
213 |
226 |
|
214 |
227 |
public VectorialLegend getLegend() {
|
... | ... | |
234 |
247 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties()
|
235 |
248 |
*/
|
236 |
249 |
public XMLEntity getXMLEntity() {
|
|
250 |
BitSet selected = selectionSupport.getSelection();
|
237 |
251 |
XMLEntity xml=super.getXMLEntity();
|
238 |
252 |
xml.addChild(legend.getXMLEntity());
|
239 |
253 |
if (selected!=null){
|
... | ... | |
273 |
287 |
legend=LegendFactory.createFromXML(xml.getChild(0));
|
274 |
288 |
int numBitSet=xml.getIntProperty("numBitSet");
|
275 |
289 |
if (numBitSet!=0){
|
|
290 |
BitSet selected = new BitSet();
|
276 |
291 |
selected=new BitSet();
|
277 |
292 |
for(int i=0;i<numBitSet;i++){
|
278 |
293 |
selected.set(xml.getIntProperty(String.valueOf(i)));
|
279 |
294 |
}
|
|
295 |
selectionSupport.setSelection(selected);
|
280 |
296 |
}
|
281 |
297 |
//TODO source.setDriver(nameDriver);
|
282 |
298 |
|