23 |
23 |
*/
|
24 |
24 |
package org.gvsig.app.project.documents.view.toolListeners;
|
25 |
25 |
|
26 |
|
|
|
26 |
import java.text.NumberFormat;
|
27 |
27 |
import org.gvsig.andami.PluginServices;
|
|
28 |
import org.gvsig.andami.ui.mdiFrame.MainFrame;
|
|
29 |
import org.gvsig.andami.ui.mdiFrame.NewStatusBar;
|
|
30 |
import org.gvsig.app.ApplicationLocator;
|
|
31 |
import org.gvsig.fmap.geom.Geometry;
|
|
32 |
import org.gvsig.fmap.geom.GeometryUtils;
|
|
33 |
import org.gvsig.fmap.geom.primitive.Surface;
|
|
34 |
import org.gvsig.fmap.mapcontext.MapContext;
|
28 |
35 |
import org.gvsig.fmap.mapcontrol.MapControl;
|
29 |
36 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
|
30 |
37 |
import org.gvsig.fmap.mapcontrol.tools.PointSelectionListener;
|
31 |
38 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent;
|
32 |
39 |
|
33 |
|
|
34 |
|
|
35 |
40 |
/**
|
36 |
|
* <p>Inherits {@link PointSelectListener PointSelectListener} enabling/disabling special
|
37 |
|
* controls for managing the data selected.</p>
|
|
41 |
* <p>
|
|
42 |
* Inherits {@link PointSelectListener PointSelectListener} enabling/disabling
|
|
43 |
* special controls for managing the data selected.</p>
|
38 |
44 |
*
|
39 |
45 |
* @see PointSelectionListener
|
40 |
46 |
*
|
41 |
47 |
* @author Vicente Caballero Navarro
|
42 |
48 |
*/
|
43 |
49 |
public class PointSelectListener extends PointSelectionListener {
|
44 |
|
/**
|
45 |
|
* <p>Creates a new <code>PointSelectListener</code> object.</p>
|
46 |
|
*
|
47 |
|
* @param mapCtrl the <code>MapControl</code> where will be applied the changes
|
48 |
|
*/
|
49 |
|
public PointSelectListener(MapControl mapCtrl) {
|
50 |
|
super(mapCtrl);
|
51 |
|
}
|
52 |
50 |
|
53 |
|
/*
|
|
51 |
/**
|
|
52 |
* <p>
|
|
53 |
* Creates a new <code>PointSelectListener</code> object.</p>
|
|
54 |
*
|
|
55 |
* @param mapCtrl the <code>MapControl</code> where will be applied the
|
|
56 |
* changes
|
|
57 |
*/
|
|
58 |
public PointSelectListener(MapControl mapCtrl) {
|
|
59 |
super(mapCtrl);
|
|
60 |
}
|
|
61 |
|
|
62 |
/*
|
54 |
63 |
* (non-Javadoc)
|
55 |
64 |
* @see com.iver.cit.gvsig.fmap.tools.PointSelectionListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
56 |
|
*/
|
57 |
|
public void point(PointEvent event) throws BehaviorException {
|
58 |
|
super.point(event);
|
59 |
|
PluginServices.getMainFrame().enableControls();
|
60 |
|
}
|
|
65 |
*/
|
|
66 |
public void point(PointEvent event) throws BehaviorException {
|
|
67 |
super.point(event);
|
|
68 |
MainFrame mainFrame = ApplicationLocator.getApplicationManager().getMainFrame();
|
|
69 |
if (mainFrame != null) {
|
|
70 |
NewStatusBar statusbar = mainFrame.getStatusBar();
|
|
71 |
Geometry geom = this.getSelectedGeometry();
|
|
72 |
if (geom != null) {
|
|
73 |
double len = -1;
|
|
74 |
double area = -1;
|
|
75 |
try {
|
|
76 |
if (GeometryUtils.isSubtype(Geometry.TYPES.SURFACE, geom.getType())
|
|
77 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTISURFACE, geom.getType())) {
|
|
78 |
len = geom.perimeter();
|
|
79 |
area = geom.area();
|
|
80 |
} else if (GeometryUtils.isSubtype(Geometry.TYPES.CURVE, geom.getType())
|
|
81 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, geom.getType())) {
|
|
82 |
len = geom.perimeter();
|
|
83 |
}
|
|
84 |
} catch (Exception e) {
|
61 |
85 |
|
62 |
|
/*
|
|
86 |
}
|
|
87 |
|
|
88 |
NumberFormat nf = NumberFormat.getInstance();
|
|
89 |
nf.setMaximumFractionDigits(2);
|
|
90 |
|
|
91 |
|
|
92 |
int distanceUnits = mapCtrl.getViewPort().getDistanceUnits();
|
|
93 |
double trans2Meter = MapContext.getDistanceTrans2Meter()[distanceUnits];
|
|
94 |
String distanceAbbr = MapContext.getDistanceAbbr()[distanceUnits];
|
|
95 |
|
|
96 |
if (len > 0) {
|
|
97 |
statusbar.setMessage("4", "L=" + nf.format(len / trans2Meter) + " " + distanceAbbr);
|
|
98 |
} else {
|
|
99 |
statusbar.setMessage("4", "");
|
|
100 |
}
|
|
101 |
if (area > 0) {
|
|
102 |
statusbar.setMessage("5", "A=" + nf.format(area / trans2Meter) + " " + distanceAbbr);
|
|
103 |
} else {
|
|
104 |
statusbar.setMessage("5", "");
|
|
105 |
}
|
|
106 |
} else {
|
|
107 |
statusbar.setMessage("4", "");
|
|
108 |
statusbar.setMessage("5", "");
|
|
109 |
}
|
|
110 |
mainFrame.enableControls();
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
/*
|
63 |
115 |
* (non-Javadoc)
|
64 |
116 |
* @see com.iver.cit.gvsig.fmap.tools.PointSelectionListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
65 |
|
*/
|
66 |
|
public void pointDoubleClick(PointEvent event) throws BehaviorException {
|
67 |
|
/* try {
|
|
117 |
*/
|
|
118 |
public void pointDoubleClick(PointEvent event) throws BehaviorException {
|
|
119 |
/* try {
|
68 |
120 |
FLayer[] actives = mapCtrl.getMapContext()
|
69 |
121 |
.getLayers().getActives();
|
70 |
122 |
for (int i=0; i < actives.length; i++){
|
... | ... | |
93 |
145 |
e.printStackTrace();
|
94 |
146 |
throw new BehaviorException("Fallo con el recordset");
|
95 |
147 |
}
|
96 |
|
*/
|
97 |
|
}
|
|
148 |
*/
|
|
149 |
}
|
98 |
150 |
}
|