svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / layers / VectorialLayerEdited.java @ 24500
History | View | Annotate | Download (27 KB)
1 | 4144 | fjp | package com.iver.cit.gvsig.layers; |
---|---|---|---|
2 | |||
3 | 4637 | caballero | import java.awt.Graphics2D; |
4 | import java.awt.Image; |
||
5 | 4366 | caballero | import java.awt.geom.Point2D; |
6 | 4637 | caballero | import java.awt.image.BufferedImage; |
7 | 4366 | caballero | import java.util.ArrayList; |
8 | 5018 | caballero | import java.util.EmptyStackException; |
9 | 21668 | vcaballero | import java.util.Iterator; |
10 | 4366 | caballero | |
11 | 12739 | caballero | import org.cresques.cts.ICoordTrans; |
12 | 24500 | jmvivo | import org.gvsig.fmap.dal.exception.DataException; |
13 | import org.gvsig.fmap.dal.exception.ReadException; |
||
14 | 24490 | jmvivo | import org.gvsig.fmap.dal.feature.Feature; |
15 | import org.gvsig.fmap.dal.feature.FeatureSelection; |
||
16 | import org.gvsig.fmap.dal.feature.FeatureSet; |
||
17 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
18 | 21668 | vcaballero | import org.gvsig.fmap.geom.handler.Handler; |
19 | 22025 | jmvivo | import org.gvsig.fmap.geom.operation.Draw; |
20 | import org.gvsig.fmap.geom.operation.DrawOperationContext; |
||
21 | 21668 | vcaballero | import org.gvsig.fmap.geom.operation.GeometryOperationException; |
22 | import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
||
23 | import org.gvsig.fmap.geom.operation.tojts.ToJTS; |
||
24 | 23086 | vcaballero | import org.gvsig.fmap.geom.primitive.DefaultEnvelope; |
25 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
26 | 21668 | vcaballero | import org.gvsig.fmap.mapcontext.ViewPort; |
27 | import org.gvsig.fmap.mapcontext.layers.CancelationException; |
||
28 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
29 | import org.gvsig.fmap.mapcontext.layers.LayerDrawEvent; |
||
30 | import org.gvsig.fmap.mapcontext.layers.LayerDrawingListener; |
||
31 | import org.gvsig.fmap.mapcontext.layers.LayerEvent; |
||
32 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
33 | import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
||
34 | import org.gvsig.fmap.mapcontext.rendering.symbols.FGraphicUtilities; |
||
35 | 23657 | vcaballero | import org.gvsig.fmap.mapcontrol.MapControl; |
36 | 23066 | jmvivo | import org.gvsig.tools.observer.Observable; |
37 | import org.gvsig.tools.observer.Observer; |
||
38 | 24429 | vcaballero | import org.gvsig.tools.observer.WeakReferencingObservable; |
39 | 12739 | caballero | |
40 | 5018 | caballero | import com.iver.andami.PluginServices; |
41 | 12739 | caballero | import com.iver.andami.messages.NotificationManager; |
42 | 10836 | caballero | import com.iver.andami.ui.mdiManager.IWindow; |
43 | 5018 | caballero | import com.iver.cit.gvsig.CADExtension; |
44 | 5208 | caballero | import com.iver.cit.gvsig.StartEditing; |
45 | 5084 | caballero | import com.iver.cit.gvsig.ViewCommandStackExtension; |
46 | 4637 | caballero | import com.iver.cit.gvsig.gui.cad.CADTool; |
47 | 4366 | caballero | import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
48 | 11434 | caballero | import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
49 | 4366 | caballero | import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool; |
50 | 10836 | caballero | import com.iver.cit.gvsig.project.documents.view.gui.View; |
51 | 4717 | caballero | import com.vividsolutions.jts.geom.Geometry; |
52 | 4144 | fjp | |
53 | 23646 | vcaballero | public class VectorialLayerEdited extends DefaultLayerEdited implements |
54 | LayerDrawingListener, Observer {
|
||
55 | 4366 | caballero | private ArrayList selectedHandler = new ArrayList(); |
56 | 4708 | caballero | private Point2D lastPoint; |
57 | private Point2D firstPoint; |
||
58 | 23646 | vcaballero | private CADTool cadtool = null; |
59 | 5906 | caballero | |
60 | 24429 | vcaballero | // private ArrayList snappers = new ArrayList();
|
61 | // private ArrayList layersToSnap = new ArrayList();
|
||
62 | 11558 | jaume | private ILegend legend;
|
63 | 23646 | vcaballero | /** Selecci?n previa* */
|
64 | private ArrayList previousRowSelection = new ArrayList(); |
||
65 | private ArrayList previousHandlerSelection = new ArrayList(); |
||
66 | 21668 | vcaballero | private Image imageSelection; |
67 | private Image imageHandlers; |
||
68 | 23646 | vcaballero | public static final boolean SAVEPREVIOUS = true; |
69 | public static final boolean NOTSAVEPREVIOUS = false; |
||
70 | 4366 | caballero | |
71 | 23646 | vcaballero | public VectorialLayerEdited(FLayer lyr) {
|
72 | 4147 | fjp | super(lyr);
|
73 | 6881 | cesar | lyr.getMapContext().addLayerDrawingListener(this);
|
74 | 5813 | fjp | // Por defecto, siempre hacemos snapping sobre la capa en edici?n.
|
75 | 23646 | vcaballero | lyr.getMapContext().getLayersToSnap().add(lyr); |
76 | 9814 | caballero | try {
|
77 | 23646 | vcaballero | ((FLyrVect) lyr).getFeatureStore().addObserver(this);
|
78 | 21668 | vcaballero | } catch (ReadException e) {
|
79 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
80 | 9814 | caballero | } |
81 | 4144 | fjp | } |
82 | 4366 | caballero | |
83 | public ArrayList getSelectedHandler() { |
||
84 | return selectedHandler;
|
||
85 | } |
||
86 | |||
87 | 24429 | vcaballero | public void clearSelection(boolean savePrevious) throws DataException { |
88 | 23646 | vcaballero | if (getFeatureStore() == null) |
89 | 23086 | vcaballero | return;
|
90 | 24429 | vcaballero | FeatureSelection selection = (FeatureSelection) getFeatureStore().getSelection(); |
91 | |||
92 | // if (!selection.isEmpty() && savePrevious) {
|
||
93 | // previousRowSelection.clear();
|
||
94 | // previousHandlerSelection.clear();
|
||
95 | // }
|
||
96 | // if (savePrevious) {
|
||
97 | // previousRowSelection.addAll(selection);
|
||
98 | // previousHandlerSelection.addAll(selectedHandler);
|
||
99 | // }
|
||
100 | 4366 | caballero | selectedHandler.clear(); |
101 | 24263 | vcaballero | selection.dispose(); |
102 | 4366 | caballero | } |
103 | 23646 | vcaballero | |
104 | 24429 | vcaballero | // public void restorePreviousSelection() throws ReadException {
|
105 | // FeatureSet selection = (FeatureSet) getFeatureStore().getSelection();
|
||
106 | // selection.dispose();
|
||
107 | // selectedHandler.clear();
|
||
108 | // selection.addAll(previousRowSelection);
|
||
109 | // selectedHandler.addAll(previousHandlerSelection);
|
||
110 | // // VectorialEditableAdapter vea=getVEA();
|
||
111 | // // FBitSet selection=vea.getSelection();
|
||
112 | // //
|
||
113 | // // selection.clear();
|
||
114 | // // selectedRow.clear();
|
||
115 | // // selectedHandler.clear();
|
||
116 | // //
|
||
117 | // // selectedRow.addAll(previousRowSelection);
|
||
118 | // // selectedHandler.addAll(previousHandlerSelection);
|
||
119 | // // for (int i = 0;i < selectedRow.size(); i++) {
|
||
120 | // // IRowEdited edRow = (IRowEdited) selectedRow.get(i);
|
||
121 | // // selection.set(edRow.getIndex());
|
||
122 | // // }
|
||
123 | //
|
||
124 | // previousRowSelection.clear();
|
||
125 | // previousHandlerSelection.clear();
|
||
126 | // }
|
||
127 | 8940 | caballero | |
128 | 23646 | vcaballero | public void selectWithPoint(double x, double y, boolean multipleSelection) { |
129 | 21668 | vcaballero | try {
|
130 | 23646 | vcaballero | firstPoint = new Point2D.Double(x, y); |
131 | FeatureStore featureStore = getFeatureStore(); |
||
132 | 24263 | vcaballero | FeatureSelection selection = (FeatureSelection) featureStore |
133 | 23646 | vcaballero | .getSelection(); |
134 | if (!multipleSelection) {
|
||
135 | clearSelection(SAVEPREVIOUS); |
||
136 | } |
||
137 | // Se comprueba si se pincha en una gemometr?a
|
||
138 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
139 | 23657 | vcaballero | double tol = vp.toMapDistance(MapControl.tolerance);
|
140 | 10626 | caballero | |
141 | 24429 | vcaballero | FeatureSet newSelection = ((FLyrVect) getLayer()).queryByPoint( |
142 | firstPoint, tol, getFeatureStore().getDefaultFeatureType()); |
||
143 | 4637 | caballero | |
144 | 23646 | vcaballero | String strEPSG = vp.getProjection().getAbrev();
|
145 | BufferedImage selectionImage = new BufferedImage( |
||
146 | vp.getImageWidth(), vp.getImageHeight(), |
||
147 | BufferedImage.TYPE_INT_ARGB);
|
||
148 | Graphics2D gs = selectionImage.createGraphics();
|
||
149 | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
||
150 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
151 | Graphics2D gh = handlersImage.createGraphics();
|
||
152 | Iterator iterator = newSelection.iterator();
|
||
153 | while (iterator.hasNext()) {
|
||
154 | Feature feature = (Feature) iterator.next(); |
||
155 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
156 | .getDefaultGeometry(); |
||
157 | 14586 | vcaballero | if (geom == null) { |
158 | continue;
|
||
159 | } |
||
160 | 23646 | vcaballero | org.gvsig.fmap.geom.Geometry geomReproject = geom |
161 | .cloneGeometry(); |
||
162 | // if (ct!=null)
|
||
163 | // geomReproject.reProject(ct);
|
||
164 | // if (geomReproject.intersects(new
|
||
165 | // Rectangle2D.Double(rect.getMinimum(0),rect.getMaximum(0),rect.getMinimum(1)-rect.getMinimum(0),rect.getMaximum(1)-rect.getMaximum(0))))
|
||
166 | // { // , 0.1)){
|
||
167 | 24263 | vcaballero | selection.select(feature); |
168 | 23646 | vcaballero | // selection.set(feats[i].getIndex(), true);
|
169 | // selectedRow.add(feats[i]);
|
||
170 | DrawOperationContext doc = new DrawOperationContext();
|
||
171 | doc.setGraphics(gs); |
||
172 | doc.setViewPort(vp); |
||
173 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
174 | drawHandlers(geomReproject.cloneGeometry(), gh, vp); |
||
175 | geomReproject.invokeOperation(Draw.CODE, doc);// cloneGeometry().draw(gs,
|
||
176 | 24429 | vcaballero | // vp,
|
177 | // DefaultCADTool.selectionSymbol);
|
||
178 | 23535 | vcaballero | |
179 | 23646 | vcaballero | } |
180 | 21668 | vcaballero | setSelectionImage(selectionImage); |
181 | setHandlersImage(handlersImage); |
||
182 | } catch (ReadException e) {
|
||
183 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
184 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
185 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
186 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
187 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
188 | 24263 | vcaballero | } catch (DataException e) {
|
189 | NotificationManager.addError(e.getMessage(), e); |
||
190 | 14586 | vcaballero | } |
191 | 4637 | caballero | } |
192 | 21668 | vcaballero | |
193 | 23646 | vcaballero | public void selectWithSecondPoint(double x, double y) { |
194 | 10626 | caballero | try {
|
195 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
196 | 10626 | caballero | |
197 | 23646 | vcaballero | lastPoint = new Point2D.Double(x, y); |
198 | clearSelection(SAVEPREVIOUS); |
||
199 | 21668 | vcaballero | |
200 | 23646 | vcaballero | ViewPort vp = getLayer().getMapContext().getViewPort(); |
201 | double x1;
|
||
202 | double y1;
|
||
203 | double w1;
|
||
204 | double h1;
|
||
205 | 4637 | caballero | |
206 | 23646 | vcaballero | if (firstPoint.getX() < lastPoint.getX()) {
|
207 | x1 = firstPoint.getX(); |
||
208 | w1 = lastPoint.getX() - firstPoint.getX(); |
||
209 | } else {
|
||
210 | x1 = lastPoint.getX(); |
||
211 | w1 = firstPoint.getX() - lastPoint.getX(); |
||
212 | } |
||
213 | 4637 | caballero | |
214 | 23646 | vcaballero | if (firstPoint.getY() < lastPoint.getY()) {
|
215 | y1 = firstPoint.getY(); |
||
216 | h1 = lastPoint.getY() - firstPoint.getY(); |
||
217 | } else {
|
||
218 | y1 = lastPoint.getY(); |
||
219 | h1 = firstPoint.getY() - lastPoint.getY(); |
||
220 | } |
||
221 | 4637 | caballero | |
222 | 23646 | vcaballero | Envelope envelope = new DefaultEnvelope(x1, y1, x1 + w1, y1 + h1);
|
223 | String strEPSG = vp.getProjection().getAbrev();
|
||
224 | BufferedImage selectionImage = new BufferedImage( |
||
225 | vp.getImageWidth(), vp.getImageHeight(), |
||
226 | BufferedImage.TYPE_INT_ARGB);
|
||
227 | 4637 | caballero | Graphics2D gs = selectionImage.createGraphics();
|
228 | 23646 | vcaballero | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
229 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
230 | 4637 | caballero | Graphics2D gh = handlersImage.createGraphics();
|
231 | 23646 | vcaballero | ICoordTrans ct = getLayer().getCoordTrans(); |
232 | |||
233 | Iterator iterator = ((FLyrVect) getLayer()).queryByEnvelope(
|
||
234 | envelope, featureStore.getDefaultFeatureType()).iterator(); |
||
235 | DrawOperationContext doc = new DrawOperationContext();
|
||
236 | 21668 | vcaballero | doc.setGraphics(gs); |
237 | doc.setViewPort(vp); |
||
238 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
239 | while (iterator.hasNext()) {
|
||
240 | 23646 | vcaballero | Feature feature = (Feature) iterator.next(); |
241 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
242 | 21668 | vcaballero | .getDefaultGeometry(); |
243 | |||
244 | 14586 | vcaballero | if (geom == null) { |
245 | continue;
|
||
246 | } |
||
247 | 23646 | vcaballero | org.gvsig.fmap.geom.Geometry geomReproject = geom |
248 | .cloneGeometry(); |
||
249 | if (ct != null) |
||
250 | 12739 | caballero | geomReproject.reProject(ct); |
251 | 21668 | vcaballero | |
252 | 4637 | caballero | if (firstPoint.getX() < lastPoint.getX()) {
|
253 | 23646 | vcaballero | if (envelope.contains(geomReproject.getEnvelope())) {
|
254 | 24429 | vcaballero | ((FeatureSelection) featureStore.getSelection()) |
255 | .select(feature); |
||
256 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
257 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
258 | 4637 | caballero | } |
259 | } else {
|
||
260 | 23646 | vcaballero | if (geomReproject.intersects(envelope.getGeometry()
|
261 | .getBounds2D())) { // , 0.1)){
|
||
262 | 24429 | vcaballero | ((FeatureSelection) featureStore.getSelection()) |
263 | .select(feature); |
||
264 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
265 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
266 | 4637 | caballero | } |
267 | } |
||
268 | } |
||
269 | 21668 | vcaballero | setSelectionImage(selectionImage); |
270 | setHandlersImage(handlersImage); |
||
271 | } catch (ReadException e) {
|
||
272 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
273 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
274 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
275 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
276 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
277 | 24263 | vcaballero | } catch (DataException e) {
|
278 | NotificationManager.addError(e.getMessage(), e); |
||
279 | 14586 | vcaballero | } |
280 | 4637 | caballero | } |
281 | 21668 | vcaballero | |
282 | 23646 | vcaballero | public void selectInsidePolygon(org.gvsig.fmap.geom.Geometry polygon) { |
283 | 10626 | caballero | try {
|
284 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
285 | clearSelection(SAVEPREVIOUS); |
||
286 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
287 | Envelope envelope = polygon.getEnvelope(); |
||
288 | 10626 | caballero | |
289 | 23646 | vcaballero | String strEPSG = vp.getProjection().getAbrev();
|
290 | BufferedImage selectionImage = new BufferedImage( |
||
291 | vp.getImageWidth(), vp.getImageHeight(), |
||
292 | BufferedImage.TYPE_INT_ARGB);
|
||
293 | Graphics2D gs = selectionImage.createGraphics();
|
||
294 | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
||
295 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
296 | Graphics2D gh = handlersImage.createGraphics();
|
||
297 | ICoordTrans ct = getLayer().getCoordTrans(); |
||
298 | Iterator iterator = ((FLyrVect) getLayer()).queryByEnvelope(
|
||
299 | envelope, featureStore.getDefaultFeatureType()).iterator(); |
||
300 | DrawOperationContext doc = new DrawOperationContext();
|
||
301 | doc.setGraphics(gs); |
||
302 | doc.setViewPort(vp); |
||
303 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
304 | while (iterator.hasNext()) {
|
||
305 | Feature feature = (Feature) iterator.next(); |
||
306 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
307 | .getDefaultGeometry(); |
||
308 | 14586 | vcaballero | if (geom == null) { |
309 | continue;
|
||
310 | } |
||
311 | 23646 | vcaballero | org.gvsig.fmap.geom.Geometry geomReproject = geom |
312 | .cloneGeometry(); |
||
313 | if (ct != null) |
||
314 | 12739 | caballero | geomReproject.reProject(ct); |
315 | 23646 | vcaballero | if (contains(polygon, geomReproject)) {
|
316 | 24429 | vcaballero | ((FeatureSelection) featureStore.getSelection()) |
317 | .select(feature); |
||
318 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
319 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
320 | 12739 | caballero | } |
321 | 4708 | caballero | } |
322 | 21668 | vcaballero | setSelectionImage(selectionImage); |
323 | setHandlersImage(handlersImage); |
||
324 | } catch (ReadException e) {
|
||
325 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
326 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
327 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
328 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
329 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
330 | 24263 | vcaballero | } catch (DataException e) {
|
331 | NotificationManager.addError(e.getMessage(), e); |
||
332 | 14586 | vcaballero | } |
333 | 4708 | caballero | } |
334 | |||
335 | 21668 | vcaballero | public void selectCrossPolygon(org.gvsig.fmap.geom.Geometry polygon) { |
336 | 10626 | caballero | try {
|
337 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
338 | clearSelection(SAVEPREVIOUS); |
||
339 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
340 | Envelope envelope = polygon.getEnvelope(); |
||
341 | 10626 | caballero | |
342 | 23646 | vcaballero | String strEPSG = vp.getProjection().getAbrev();
|
343 | BufferedImage selectionImage = new BufferedImage( |
||
344 | vp.getImageWidth(), vp.getImageHeight(), |
||
345 | BufferedImage.TYPE_INT_ARGB);
|
||
346 | Graphics2D gs = selectionImage.createGraphics();
|
||
347 | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
||
348 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
349 | Graphics2D gh = handlersImage.createGraphics();
|
||
350 | ICoordTrans ct = getLayer().getCoordTrans(); |
||
351 | Iterator iterator = ((FLyrVect) getLayer()).queryByEnvelope(
|
||
352 | envelope, featureStore.getDefaultFeatureType()).iterator(); |
||
353 | 4708 | caballero | |
354 | 23646 | vcaballero | DrawOperationContext doc = new DrawOperationContext();
|
355 | doc.setGraphics(gs); |
||
356 | doc.setViewPort(vp); |
||
357 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
358 | while (iterator.hasNext()) {
|
||
359 | Feature feature = (Feature) iterator.next(); |
||
360 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
361 | .getDefaultGeometry(); |
||
362 | 14586 | vcaballero | if (geom == null) { |
363 | continue;
|
||
364 | } |
||
365 | 23646 | vcaballero | org.gvsig.fmap.geom.Geometry geomReproject = geom |
366 | .cloneGeometry(); |
||
367 | if (ct != null) |
||
368 | 12739 | caballero | geomReproject.reProject(ct); |
369 | 23646 | vcaballero | if (contains(polygon, geomReproject)
|
370 | || intersects(polygon, geomReproject)) { |
||
371 | 24429 | vcaballero | ((FeatureSelection) featureStore.getSelection()) |
372 | .select(feature); |
||
373 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
374 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
375 | 12739 | caballero | } |
376 | 4708 | caballero | } |
377 | 21668 | vcaballero | setSelectionImage(selectionImage); |
378 | setHandlersImage(handlersImage); |
||
379 | } catch (ReadException e) {
|
||
380 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
381 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
382 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
383 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
384 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
385 | 24263 | vcaballero | } catch (DataException e) {
|
386 | NotificationManager.addError(e.getMessage(), e); |
||
387 | 14586 | vcaballero | } |
388 | 4708 | caballero | } |
389 | |||
390 | 21668 | vcaballero | public void selectOutPolygon(org.gvsig.fmap.geom.Geometry polygon) { |
391 | 10626 | caballero | try {
|
392 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
393 | clearSelection(SAVEPREVIOUS); |
||
394 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
395 | Envelope envelope = polygon.getEnvelope(); |
||
396 | 4708 | caballero | |
397 | 23646 | vcaballero | String strEPSG = vp.getProjection().getAbrev();
|
398 | BufferedImage selectionImage = new BufferedImage( |
||
399 | vp.getImageWidth(), vp.getImageHeight(), |
||
400 | BufferedImage.TYPE_INT_ARGB);
|
||
401 | Graphics2D gs = selectionImage.createGraphics();
|
||
402 | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
||
403 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
404 | Graphics2D gh = handlersImage.createGraphics();
|
||
405 | ICoordTrans ct = getLayer().getCoordTrans(); |
||
406 | Iterator iterator = ((FLyrVect) getLayer()).queryByEnvelope(
|
||
407 | envelope, featureStore.getDefaultFeatureType()).iterator(); |
||
408 | 21668 | vcaballero | |
409 | 23646 | vcaballero | DrawOperationContext doc = new DrawOperationContext();
|
410 | doc.setGraphics(gs); |
||
411 | doc.setViewPort(vp); |
||
412 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
413 | while (iterator.hasNext()) {
|
||
414 | Feature feature = (Feature) iterator.next(); |
||
415 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
416 | .getDefaultGeometry(); |
||
417 | 14586 | vcaballero | if (geom == null) { |
418 | continue;
|
||
419 | } |
||
420 | 23646 | vcaballero | org.gvsig.fmap.geom.Geometry geomReproject = geom |
421 | .cloneGeometry(); |
||
422 | if (ct != null) |
||
423 | 12739 | caballero | geomReproject.reProject(ct); |
424 | 23646 | vcaballero | if (!contains(polygon, geomReproject)
|
425 | && !intersects(polygon, geomReproject)) { |
||
426 | 24429 | vcaballero | ((FeatureSelection) featureStore.getSelection()) |
427 | .select(feature); |
||
428 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
429 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
430 | 12739 | caballero | } |
431 | 4708 | caballero | } |
432 | 21668 | vcaballero | setSelectionImage(selectionImage); |
433 | setHandlersImage(handlersImage); |
||
434 | } catch (ReadException e) {
|
||
435 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
436 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
437 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
438 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
439 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
440 | 24263 | vcaballero | } catch (DataException e) {
|
441 | NotificationManager.addError(e.getMessage(), e); |
||
442 | 14586 | vcaballero | } |
443 | 4708 | caballero | } |
444 | 21668 | vcaballero | |
445 | 23646 | vcaballero | public void selectAll() { |
446 | 10626 | caballero | try {
|
447 | 23646 | vcaballero | FeatureStore featureStore = getFeatureStore(); |
448 | clearSelection(SAVEPREVIOUS); |
||
449 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
450 | BufferedImage selectionImage = new BufferedImage( |
||
451 | vp.getImageWidth(), vp.getImageHeight(), |
||
452 | BufferedImage.TYPE_INT_ARGB);
|
||
453 | 4708 | caballero | Graphics2D gs = selectionImage.createGraphics();
|
454 | 23646 | vcaballero | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
455 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
456 | 4708 | caballero | Graphics2D gh = handlersImage.createGraphics();
|
457 | 23646 | vcaballero | ICoordTrans ct = getLayer().getCoordTrans(); |
458 | 24429 | vcaballero | FeatureSet fCollection = (FeatureSet) featureStore.getDataSet(); |
459 | 23646 | vcaballero | Iterator iterator = fCollection.iterator();
|
460 | 21668 | vcaballero | featureStore.setSelection(fCollection); |
461 | |||
462 | 23646 | vcaballero | DrawOperationContext doc = new DrawOperationContext();
|
463 | 21668 | vcaballero | doc.setGraphics(gs); |
464 | doc.setViewPort(vp); |
||
465 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
466 | |||
467 | while (iterator.hasNext()) {
|
||
468 | Feature feature = (Feature) iterator.next(); |
||
469 | 23646 | vcaballero | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
470 | .getDefaultGeometry(); |
||
471 | if (ct != null) |
||
472 | 12739 | caballero | geom.reProject(ct); |
473 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
474 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
475 | 4708 | caballero | } |
476 | 21668 | vcaballero | setSelectionImage(selectionImage); |
477 | setHandlersImage(handlersImage); |
||
478 | } catch (ReadException e) {
|
||
479 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
480 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
481 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
482 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
483 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
484 | 22986 | vcaballero | } catch (DataException e) {
|
485 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
486 | 14586 | vcaballero | } |
487 | 4708 | caballero | } |
488 | |||
489 | 23646 | vcaballero | public void refreshSelectionCache(Point2D firstPoint, CADToolAdapter cta) { |
490 | 10626 | caballero | try {
|
491 | clearSelection(SAVEPREVIOUS); |
||
492 | 23646 | vcaballero | double min = java.lang.Double.MAX_VALUE;
|
493 | ViewPort vp = getLayer().getMapContext().getViewPort(); |
||
494 | BufferedImage selectionImage = new BufferedImage( |
||
495 | vp.getImageWidth(), vp.getImageHeight(), |
||
496 | BufferedImage.TYPE_INT_ARGB);
|
||
497 | Graphics2D gs = selectionImage.createGraphics();
|
||
498 | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
||
499 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
500 | Graphics2D gh = handlersImage.createGraphics();
|
||
501 | FeatureStore featureStore = getFeatureStore(); |
||
502 | 21668 | vcaballero | |
503 | 24429 | vcaballero | Iterator iterator = ((FeatureSelection) featureStore.getSelection())
|
504 | .iterator(); |
||
505 | 21668 | vcaballero | |
506 | 23646 | vcaballero | DrawOperationContext doc = new DrawOperationContext();
|
507 | doc.setGraphics(gs); |
||
508 | doc.setViewPort(vp); |
||
509 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
510 | while (iterator.hasNext()) {
|
||
511 | Feature feature = (Feature) iterator.next(); |
||
512 | Handler[] handlers = null; |
||
513 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
514 | .getDefaultGeometry(); |
||
515 | handlers = geom |
||
516 | .getHandlers(org.gvsig.fmap.geom.Geometry.SELECTHANDLER); |
||
517 | 21668 | vcaballero | |
518 | 23646 | vcaballero | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
519 | drawHandlers(geom.cloneGeometry(), gh, vp); |
||
520 | 4366 | caballero | // y miramos los handlers de cada entidad seleccionada
|
521 | 23646 | vcaballero | min = cta.getMapControl().getViewPort().toMapDistance( |
522 | 23657 | vcaballero | MapControl.tolerance); |
523 | 4366 | caballero | for (int j = 0; j < handlers.length; j++) { |
524 | Point2D handlerPoint = handlers[j].getPoint();
|
||
525 | double distance = firstPoint.distance(handlerPoint);
|
||
526 | if (distance <= min) {
|
||
527 | min = distance; |
||
528 | selectedHandler.add(handlers[j]); |
||
529 | } |
||
530 | } |
||
531 | 21668 | vcaballero | |
532 | 23646 | vcaballero | } |
533 | 21668 | vcaballero | |
534 | 23646 | vcaballero | setSelectionImage(selectionImage); |
535 | setHandlersImage(handlersImage); |
||
536 | 21668 | vcaballero | } catch (ReadException e) {
|
537 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
538 | 21668 | vcaballero | } catch (GeometryOperationNotSupportedException e) {
|
539 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
540 | 21668 | vcaballero | } catch (GeometryOperationException e) {
|
541 | 23646 | vcaballero | NotificationManager.addError(e.getMessage(), e); |
542 | 24263 | vcaballero | } catch (DataException e) {
|
543 | NotificationManager.addError(e.getMessage(), e); |
||
544 | 21668 | vcaballero | } |
545 | 4366 | caballero | } |
546 | 4637 | caballero | |
547 | 23646 | vcaballero | public void drawHandlers(org.gvsig.fmap.geom.Geometry geom, Graphics2D gs, |
548 | ViewPort vp) { |
||
549 | // if (!(getLayer() instanceof FLyrAnnotation)){
|
||
550 | Handler[] handlers = geom |
||
551 | .getHandlers(org.gvsig.fmap.geom.Geometry.SELECTHANDLER); |
||
552 | FGraphicUtilities.DrawHandlers(gs, vp.getAffineTransform(), handlers, |
||
553 | DefaultCADTool.handlerSymbol); |
||
554 | // }
|
||
555 | 4637 | caballero | } |
556 | 23646 | vcaballero | |
557 | public Image getSelectionImage() { |
||
558 | 21668 | vcaballero | return imageSelection;
|
559 | 4637 | caballero | } |
560 | 23646 | vcaballero | |
561 | public void setSelectionImage(Image image) { |
||
562 | imageSelection = image; |
||
563 | 21668 | vcaballero | } |
564 | 23646 | vcaballero | |
565 | 4637 | caballero | public Image getHandlersImage() { |
566 | 21668 | vcaballero | return imageHandlers;
|
567 | 4637 | caballero | } |
568 | 23646 | vcaballero | |
569 | public void setHandlersImage(Image image) { |
||
570 | imageHandlers = image; |
||
571 | 4637 | caballero | } |
572 | |||
573 | public void beforeLayerDraw(LayerDrawEvent e) throws CancelationException { |
||
574 | 23646 | vcaballero | FeatureStore featureStore = null;
|
575 | 23086 | vcaballero | try {
|
576 | featureStore = getFeatureStore(); |
||
577 | } catch (ReadException e2) {
|
||
578 | // TODO Auto-generated catch block
|
||
579 | e2.printStackTrace(); |
||
580 | } |
||
581 | 21668 | vcaballero | if (featureStore.isEditing()) {
|
582 | 23646 | vcaballero | // VectorialEditableAdapter vea = (VectorialEditableAdapter)
|
583 | // ((FLyrVect) getLayer())
|
||
584 | // .getSource();
|
||
585 | 6881 | cesar | ViewPort vp = getLayer().getMapContext().getViewPort(); |
586 | 4637 | caballero | BufferedImage selectionImage = new BufferedImage( |
587 | vp.getImageWidth(), vp.getImageHeight(), |
||
588 | BufferedImage.TYPE_INT_ARGB);
|
||
589 | BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
||
590 | vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB);
|
||
591 | Graphics2D gs = selectionImage.createGraphics();
|
||
592 | Graphics2D gh = handlersImage.createGraphics();
|
||
593 | 24263 | vcaballero | Iterator iterator = null; |
594 | try {
|
||
595 | 24429 | vcaballero | iterator = ((FeatureSelection) featureStore.getSelection()) |
596 | .iterator(); |
||
597 | 24263 | vcaballero | } catch (DataException e2) {
|
598 | // TODO Auto-generated catch block
|
||
599 | e2.printStackTrace(); |
||
600 | } |
||
601 | 21668 | vcaballero | while (iterator.hasNext()) {
|
602 | Feature feature = (Feature) iterator.next(); |
||
603 | |||
604 | 23646 | vcaballero | // }
|
605 | // for (int i = 0; i < selectedRow.size(); i++) {
|
||
606 | // IFeature feat = (IFeature) ((IRowEdited) selectedRow.get(i))
|
||
607 | // .getLinkedRow();
|
||
608 | org.gvsig.fmap.geom.Geometry geom = (org.gvsig.fmap.geom.Geometry) feature |
||
609 | .getDefaultGeometry(); |
||
610 | 23086 | vcaballero | |
611 | 23646 | vcaballero | DrawOperationContext doc = new DrawOperationContext();
|
612 | doc.setGraphics(gs); |
||
613 | doc.setViewPort(vp); |
||
614 | doc.setSymbol(DefaultCADTool.selectionSymbol); |
||
615 | try {
|
||
616 | geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
||
617 | 23086 | vcaballero | } catch (GeometryOperationNotSupportedException e1) {
|
618 | e1.printStackTrace(); |
||
619 | } catch (GeometryOperationException e1) {
|
||
620 | e1.printStackTrace(); |
||
621 | } |
||
622 | 4637 | caballero | drawHandlers(geom.cloneGeometry(), gh, vp); |
623 | } |
||
624 | 23535 | vcaballero | setSelectionImage(selectionImage); |
625 | setHandlersImage(handlersImage); |
||
626 | 4637 | caballero | } |
627 | } |
||
628 | |||
629 | public void afterLayerDraw(LayerDrawEvent e) throws CancelationException { |
||
630 | } |
||
631 | |||
632 | 23646 | vcaballero | public void beforeGraphicLayerDraw(LayerDrawEvent e) |
633 | throws CancelationException {
|
||
634 | 4637 | caballero | } |
635 | |||
636 | 23646 | vcaballero | public void afterLayerGraphicDraw(LayerDrawEvent e) |
637 | throws CancelationException {
|
||
638 | 4637 | caballero | } |
639 | 23646 | vcaballero | |
640 | private static boolean contains(org.gvsig.fmap.geom.Geometry g1, |
||
641 | org.gvsig.fmap.geom.Geometry g2) { |
||
642 | try {
|
||
643 | Geometry geometry1 = (Geometry) g1 |
||
644 | .invokeOperation(ToJTS.CODE, null);
|
||
645 | Geometry geometry2 = (Geometry) g2 |
||
646 | .invokeOperation(ToJTS.CODE, null);
|
||
647 | if (geometry1 == null || geometry2 == null) |
||
648 | return false; |
||
649 | 21668 | vcaballero | return geometry1.contains(geometry2);
|
650 | } catch (GeometryOperationNotSupportedException e) {
|
||
651 | e.printStackTrace(); |
||
652 | } catch (GeometryOperationException e) {
|
||
653 | e.printStackTrace(); |
||
654 | } |
||
655 | return false; |
||
656 | 4717 | caballero | } |
657 | 23646 | vcaballero | |
658 | private static boolean intersects(org.gvsig.fmap.geom.Geometry g1, |
||
659 | org.gvsig.fmap.geom.Geometry g2) { |
||
660 | try {
|
||
661 | Geometry geometry1 = (Geometry) g1 |
||
662 | .invokeOperation(ToJTS.CODE, null);
|
||
663 | Geometry geometry2 = (Geometry) g2 |
||
664 | .invokeOperation(ToJTS.CODE, null);
|
||
665 | if (geometry1 == null || geometry2 == null) |
||
666 | return false; |
||
667 | 21668 | vcaballero | return geometry1.intersects(geometry2);
|
668 | } catch (GeometryOperationNotSupportedException e) {
|
||
669 | e.printStackTrace(); |
||
670 | } catch (GeometryOperationException e) {
|
||
671 | e.printStackTrace(); |
||
672 | } |
||
673 | return false; |
||
674 | 4717 | caballero | } |
675 | 5018 | caballero | |
676 | public void activationGained(LayerEvent e) { |
||
677 | 23646 | vcaballero | if (ViewCommandStackExtension.csd != null) { |
678 | 23086 | vcaballero | try {
|
679 | 23646 | vcaballero | ViewCommandStackExtension.csd.setModel(((FLyrVect) getLayer()) |
680 | .getFeatureStore().getCommandsRecord()); |
||
681 | 23086 | vcaballero | } catch (ReadException e1) {
|
682 | // TODO Auto-generated catch block
|
||
683 | e1.printStackTrace(); |
||
684 | 24263 | vcaballero | } catch (DataException e1) {
|
685 | // TODO Auto-generated catch block
|
||
686 | e1.printStackTrace(); |
||
687 | 23086 | vcaballero | } |
688 | 5084 | caballero | } |
689 | 23646 | vcaballero | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
690 | if (window instanceof View) { |
||
691 | View view = (View) window; |
||
692 | if (e.getSource().isEditing()) {
|
||
693 | 10836 | caballero | view.showConsole(); |
694 | } |
||
695 | } |
||
696 | 23646 | vcaballero | if (cadtool != null) { |
697 | 5018 | caballero | CADExtension.getCADToolAdapter().setCadTool(cadtool); |
698 | PluginServices.getMainFrame().setSelectedTool(cadtool.toString()); |
||
699 | 23646 | vcaballero | StartEditing.startCommandsApplicable(null, (FLyrVect) getLayer());
|
700 | 5257 | caballero | CADExtension.initFocus(); |
701 | 5018 | caballero | } |
702 | 5227 | caballero | |
703 | 5018 | caballero | } |
704 | |||
705 | public void activationLost(LayerEvent e) { |
||
706 | 23646 | vcaballero | try {
|
707 | cadtool = CADExtension.getCADTool(); |
||
708 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
709 | if (window instanceof View) { |
||
710 | View view = (View) window; |
||
711 | 10836 | caballero | view.hideConsole(); |
712 | } |
||
713 | 23646 | vcaballero | } catch (EmptyStackException e1) { |
714 | cadtool = new SelectionCADTool();
|
||
715 | 5018 | caballero | cadtool.init(); |
716 | } |
||
717 | |||
718 | } |
||
719 | 5261 | fjp | |
720 | 24429 | vcaballero | // public ArrayList getSnappers() {
|
721 | // return snappers;
|
||
722 | // }
|
||
723 | //
|
||
724 | // public ArrayList getLayersToSnap() {
|
||
725 | // return layersToSnap;
|
||
726 | // }
|
||
727 | //
|
||
728 | // public void setLayersToSnap(ArrayList layersToSnap) {
|
||
729 | // this.layersToSnap = layersToSnap;
|
||
730 | //
|
||
731 | // }
|
||
732 | 5906 | caballero | |
733 | 23646 | vcaballero | // public void setSelectionCache(boolean savePrevious,ArrayList
|
734 | // selectedRowAux) {
|
||
735 | // try {
|
||
736 | // clearSelection(savePrevious);
|
||
737 | // VectorialEditableAdapter vea=getVEA();
|
||
738 | // FBitSet selection=vea.getSelection();
|
||
739 | // selectedRow.addAll(selectedRowAux);
|
||
740 | // for (int i = 0;i < selectedRow.size(); i++) {
|
||
741 | // IRowEdited edRow = (IRowEdited) selectedRow.get(i);
|
||
742 | // selection.set(edRow.getIndex());
|
||
743 | // }
|
||
744 | // FLyrVect active = (FLyrVect)getLayer();
|
||
745 | // active.getRecordset().getSelectionSupport().fireSelectionEvents();
|
||
746 | // } catch (ReadException e) {
|
||
747 | // NotificationManager.addError(e.getMessage(),e);
|
||
748 | // }
|
||
749 | // }
|
||
750 | 5813 | fjp | |
751 | 11558 | jaume | public void setLegend(ILegend legend) { |
752 | 23646 | vcaballero | this.legend = legend;
|
753 | 6312 | caballero | } |
754 | 23646 | vcaballero | |
755 | 11558 | jaume | public ILegend getLegend() {
|
756 | 6312 | caballero | return legend;
|
757 | } |
||
758 | 8940 | caballero | |
759 | 23646 | vcaballero | // public void addSelectionCache(DefaultRowEdited edited) {
|
760 | // selectedRow.add(edited);
|
||
761 | // }
|
||
762 | 8940 | caballero | |
763 | public boolean getPreviousSelection() { |
||
764 | 23086 | vcaballero | try {
|
765 | 24429 | vcaballero | return !((FeatureSelection) ((FLyrVect) getLayer())
|
766 | .getFeatureStore().getSelection()).isEmpty(); |
||
767 | 23086 | vcaballero | } catch (ReadException e) {
|
768 | // TODO Auto-generated catch block
|
||
769 | e.printStackTrace(); |
||
770 | 24263 | vcaballero | } catch (DataException e) {
|
771 | // TODO Auto-generated catch block
|
||
772 | e.printStackTrace(); |
||
773 | 23086 | vcaballero | } |
774 | return false; |
||
775 | 8940 | caballero | } |
776 | 23646 | vcaballero | |
777 | public FeatureStore getFeatureStore() throws ReadException { |
||
778 | return ((FLyrVect) getLayer()).getFeatureStore();
|
||
779 | 22986 | vcaballero | } |
780 | 9814 | caballero | |
781 | 24429 | vcaballero | public void update(WeakReferencingObservable observable, Object notification) { |
782 | 10626 | caballero | try {
|
783 | 24429 | vcaballero | if (((FeatureSelection) getFeatureStore().getSelection()).isEmpty())
|
784 | 10626 | caballero | clearSelection(NOTSAVEPREVIOUS); |
785 | 21668 | vcaballero | } catch (ReadException e1) {
|
786 | 23646 | vcaballero | NotificationManager.addError(e1.getMessage(), e1); |
787 | 24263 | vcaballero | } catch (DataException e1) {
|
788 | NotificationManager.addError(e1.getMessage(), e1); |
||
789 | 10626 | caballero | } |
790 | 21668 | vcaballero | |
791 | 9814 | caballero | } |
792 | 4144 | fjp | } |