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