Revision 37 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingBehavior.java
DefaultEditingBehavior.java | ||
---|---|---|
9 | 9 |
import java.awt.Color; |
10 | 10 |
import java.awt.Graphics; |
11 | 11 |
import java.awt.Image; |
12 |
import java.awt.Point; |
|
13 | 12 |
import java.awt.event.MouseEvent; |
14 | 13 |
import java.awt.geom.Point2D; |
15 | 14 |
import java.awt.image.BufferedImage; |
... | ... | |
19 | 18 |
import org.cresques.cts.IProjection; |
20 | 19 |
import org.gvsig.andami.PluginServices; |
21 | 20 |
import org.gvsig.andami.ui.mdiFrame.MainFrame; |
22 |
import org.gvsig.app.ApplicationLocator; |
|
23 | 21 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
24 | 22 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
25 | 23 |
import org.gvsig.fmap.geom.Geometry; |
24 |
import org.gvsig.fmap.geom.primitive.Point; |
|
26 | 25 |
import org.gvsig.fmap.mapcontext.MapContext; |
27 | 26 |
import org.gvsig.fmap.mapcontext.ViewPort; |
28 | 27 |
import org.gvsig.fmap.mapcontext.layers.CancelationException; |
... | ... | |
282 | 281 |
switch (currentParam.getType()) { |
283 | 282 |
case EditingServiceParameter.TYPE_POINT: |
284 | 283 |
ViewPort vp = mapControl.getViewPort(); |
285 |
Point2D point;
|
|
286 |
point = vp.toMapPoint(e.getX(), e.getY());
|
|
284 |
Point point; |
|
285 |
point = vp.convertToMapPoint(e.getX(), e.getY());
|
|
287 | 286 |
this.activeService.setValueParameter(currentParam, point); |
288 | 287 |
|
289 | 288 |
case EditingServiceParameter.TYPE_LIST_POINTS: |
... | ... | |
303 | 302 |
} |
304 | 303 |
|
305 | 304 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
306 |
adjustedPoint = e.getPoint(); |
|
305 |
ViewPort vp = mapControl.getViewPort(); |
|
306 |
adjustedPoint = vp.convertToMapPoint(e.getX(),e.getY()); |
|
307 |
showCoords(e.getPoint()); |
|
307 | 308 |
|
308 |
showCoords(adjustedPoint); |
|
309 |
|
|
310 | 309 |
getMapControl().repaint(); |
311 | 310 |
} |
312 | 311 |
|
... | ... | |
318 | 317 |
// TODO Auto-generated method stub |
319 | 318 |
} |
320 | 319 |
|
321 |
@SuppressWarnings("deprecation") |
|
322 | 320 |
public void paintComponent(MapControlDrawer mapControlDrawer) { |
323 | 321 |
super.paintComponent(mapControlDrawer); |
324 | 322 |
if (activeService == null || adjustedPoint == null) { |
325 | 323 |
return; |
326 | 324 |
} |
327 |
Point2D p = null; |
|
328 | 325 |
|
329 |
p = getMapControl().getViewPort().toMapPoint(adjustedPoint); |
|
330 |
Geometry helperGeo = activeService.drawOperation(p); |
|
326 |
Geometry helperGeo = activeService.drawOperation(adjustedPoint); |
|
331 | 327 |
if (helperGeo != null) { |
332 | 328 |
mapControl.getMapControlDrawer().draw(helperGeo, |
333 | 329 |
MapControlLocator.getMapControlManager().getAxisReferenceSymbol()); |
... | ... | |
352 | 348 |
} |
353 | 349 |
} |
354 | 350 |
|
355 |
private void showCoords(Point point) { |
|
351 |
private void showCoords(Point2D point) {
|
|
356 | 352 |
String[] axisText = new String[2]; |
357 | 353 |
axisText[0] = "X = "; |
358 | 354 |
axisText[1] = "Y = "; |
359 | 355 |
|
360 | 356 |
ViewPort vp = mapControl.getMapContext().getViewPort(); |
361 | 357 |
IProjection iProj = vp.getProjection(); |
362 |
Point2D p = vp.toMapPoint((int) point.getX(), (int) point.getY()); |
|
363 |
; |
|
364 |
// if (mapAdjustedPoint == null) { |
|
365 |
// p = vp.toMapPoint(point); |
|
366 |
// } else { |
|
367 |
// p = mapAdjustedPoint; |
|
368 |
// } |
|
369 |
sbl.setFractionDigits(p); |
|
358 |
Point p = vp.convertToMapPoint(point); |
|
359 |
Point2D p2D = new Point2D.Double(p.getX(), p.getY()); |
|
360 |
|
|
361 |
sbl.setFractionDigits(p2D); |
|
370 | 362 |
axisText = sbl.setCoorDisplayText(axisText); |
371 | 363 |
MainFrame mF = PluginServices.getMainFrame(); |
372 | 364 |
|
... | ... | |
379 | 371 |
String.valueOf(mapControl.getMapContext().getScaleView())); |
380 | 372 |
mF.getStatusBar().setMessage("projection", iProj.getAbrev()); |
381 | 373 |
|
382 |
String[] coords = sbl.getCoords(p); |
|
374 |
String[] coords = sbl.getCoords(p2D);
|
|
383 | 375 |
mF.getStatusBar().setMessage("x", axisText[0] + coords[0]); |
384 | 376 |
mF.getStatusBar().setMessage("y", axisText[1] + coords[1]); |
385 | 377 |
} |
Also available in: Unified diff