svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.fmap.control / src / main / java / org / gvsig / fmap / mapcontrol / swing / pickercontroller / impl / EnvelopePickerControllerImpl.java @ 47779
History | View | Annotate | Download (17.3 KB)
1 | 43913 | jjdelcerro | package org.gvsig.fmap.mapcontrol.swing.pickercontroller.impl; |
---|---|---|---|
2 | |||
3 | import org.gvsig.tools.swing.api.documentfilters.DoubleDocumentFilter; |
||
4 | import java.awt.Dimension; |
||
5 | import java.awt.Image; |
||
6 | import java.awt.event.ActionEvent; |
||
7 | import java.net.URL; |
||
8 | 47779 | fdiaz | import java.util.function.Supplier; |
9 | 43913 | jjdelcerro | import javax.swing.ImageIcon; |
10 | import javax.swing.JButton; |
||
11 | import javax.swing.JTextField; |
||
12 | import javax.swing.JToggleButton; |
||
13 | import javax.swing.SwingConstants; |
||
14 | 47260 | jjdelcerro | import javax.swing.text.JTextComponent; |
15 | 46487 | jjdelcerro | import org.apache.commons.lang.StringUtils; |
16 | 43913 | jjdelcerro | import org.gvsig.fmap.dal.DataTypes; |
17 | import org.gvsig.fmap.geom.Geometry; |
||
18 | import org.gvsig.fmap.geom.Geometry.DIMENSIONS; |
||
19 | import org.gvsig.fmap.geom.GeometryLocator; |
||
20 | import org.gvsig.fmap.geom.GeometryManager; |
||
21 | 46487 | jjdelcerro | import org.gvsig.fmap.geom.GeometryUtils; |
22 | 43913 | jjdelcerro | import org.gvsig.fmap.geom.primitive.Envelope; |
23 | import org.gvsig.fmap.geom.primitive.Point; |
||
24 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
25 | import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
||
26 | import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
||
27 | import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent; |
||
28 | import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener; |
||
29 | import org.gvsig.tools.IllegalValueException; |
||
30 | import org.gvsig.tools.ToolsLocator; |
||
31 | import org.gvsig.tools.dataTypes.CoercionException; |
||
32 | import org.gvsig.tools.dataTypes.DataType; |
||
33 | 46489 | jjdelcerro | import org.gvsig.tools.i18n.I18nManager; |
34 | 43953 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
35 | 46487 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingManager; |
36 | 47426 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingUtils; |
37 | 43913 | jjdelcerro | import org.gvsig.tools.swing.api.pickercontroller.AbstractPickerController; |
38 | 43953 | jjdelcerro | import org.gvsig.tools.swing.icontheme.IconTheme; |
39 | import org.gvsig.tools.swing.icontheme.IconThemeManager; |
||
40 | 43913 | jjdelcerro | |
41 | /**
|
||
42 | *
|
||
43 | * @author jjdelcerro
|
||
44 | */
|
||
45 | 46487 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
46 | 43913 | jjdelcerro | public class EnvelopePickerControllerImpl extends AbstractPickerController<Envelope>{ |
47 | |||
48 | 43953 | jjdelcerro | public static void selfRegister() { |
49 | IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
||
50 | 47426 | jjdelcerro | IconTheme theme = iconThemeManager.getActive(); |
51 | 43953 | jjdelcerro | |
52 | 43957 | jjdelcerro | URL url = ScalePickerControllerImpl.class.getClassLoader().getResource("images/picker-envelope-cursor-capture.png"); |
53 | 43953 | jjdelcerro | if( url != null ) { |
54 | ImageIcon icon = new ImageIcon(url); |
||
55 | 47426 | jjdelcerro | theme.registerDefault("mapcontrol", "picker", "picker-envelope", "picker-envelope-cursor-capture", icon, url); |
56 | 43953 | jjdelcerro | } |
57 | 43957 | jjdelcerro | url = ScalePickerControllerImpl.class.getClassLoader().getResource("images/picker-envelope-capture.png");
|
58 | 43953 | jjdelcerro | if( url != null ) { |
59 | ImageIcon icon = new ImageIcon(url); |
||
60 | 47426 | jjdelcerro | theme.registerDefault("mapcontrol", "picker", "picker-envelope", "picker-envelope-capture", icon, url); |
61 | 43953 | jjdelcerro | } |
62 | 43957 | jjdelcerro | url = ScalePickerControllerImpl.class.getClassLoader().getResource("images/picker-envelope-from-mapcontrol.png");
|
63 | 43953 | jjdelcerro | if( url != null ) { |
64 | ImageIcon icon = new ImageIcon(url); |
||
65 | 47426 | jjdelcerro | theme.registerDefault("mapcontrol", "picker", "picker-envelope", "picker-envelope-from-mapcontrol", icon, url); |
66 | 43953 | jjdelcerro | } |
67 | 47426 | jjdelcerro | ToolsSwingUtils.registerSubgroupIconScreenshot( |
68 | EnvelopePickerControllerImpl.class, |
||
69 | "picker",
|
||
70 | "picker-envelope",
|
||
71 | "/images/screenshots/picker-envelope1.png"
|
||
72 | ); |
||
73 | } |
||
74 | 43953 | jjdelcerro | |
75 | |||
76 | 43913 | jjdelcerro | private class CaptureEnvelopeListener implements RectangleListener { |
77 | |||
78 | @Override
|
||
79 | public void rectangle(EnvelopeEvent event) throws BehaviorException { |
||
80 | set(event.getWorldCoordRect()); |
||
81 | } |
||
82 | |||
83 | @Override
|
||
84 | public Image getImageCursor() { |
||
85 | return captureCursor.getImage();
|
||
86 | } |
||
87 | |||
88 | @Override
|
||
89 | public boolean cancelDrawing() { |
||
90 | return false; |
||
91 | } |
||
92 | |||
93 | } |
||
94 | |||
95 | |||
96 | 47779 | fdiaz | private final Supplier<MapControl> mapControl; |
97 | 43913 | jjdelcerro | private final JTextField txtUpperLeftX; |
98 | private final JTextField txtUpperLeftY; |
||
99 | private final JTextField txtLowerRightX; |
||
100 | private final JTextField txtLowerRightY; |
||
101 | 47260 | jjdelcerro | private final JTextComponent txtEnvelope; |
102 | 43913 | jjdelcerro | private final JButton btnMapControlEnvelope; |
103 | private final JToggleButton btnCapture; |
||
104 | |||
105 | private ImageIcon captureCursor; |
||
106 | private RectangleBehavior captureTool;
|
||
107 | private String previosTool; |
||
108 | |||
109 | public EnvelopePickerControllerImpl(
|
||
110 | 47779 | fdiaz | Supplier<MapControl> mapControl, |
111 | 43913 | jjdelcerro | JTextField txtUpperLeftX,
|
112 | JTextField txtUpperLeftY,
|
||
113 | JTextField txtLowerRightX,
|
||
114 | JTextField txtLowerRightY,
|
||
115 | JButton btnMapControlEnvelope,
|
||
116 | final JToggleButton btnCapture |
||
117 | ) { |
||
118 | this.mapControl = mapControl;
|
||
119 | this.txtEnvelope = null; |
||
120 | this.txtUpperLeftX = txtUpperLeftX;
|
||
121 | this.txtUpperLeftY = txtUpperLeftY;
|
||
122 | this.txtLowerRightX = txtLowerRightX;
|
||
123 | this.txtLowerRightY = txtLowerRightY;
|
||
124 | this.btnMapControlEnvelope = btnMapControlEnvelope;
|
||
125 | this.btnCapture = btnCapture;
|
||
126 | |||
127 | this.initComponents();
|
||
128 | } |
||
129 | |||
130 | public EnvelopePickerControllerImpl(
|
||
131 | 47779 | fdiaz | Supplier<MapControl> mapControl, |
132 | 47260 | jjdelcerro | JTextComponent txtEnvelope,
|
133 | 43913 | jjdelcerro | JButton btnMapControlEnvelope,
|
134 | final JToggleButton btnCapture |
||
135 | ) { |
||
136 | this.mapControl = mapControl;
|
||
137 | this.txtEnvelope = txtEnvelope;
|
||
138 | 46487 | jjdelcerro | this.txtUpperLeftX = new JTextField(); |
139 | this.txtUpperLeftY = new JTextField(); |
||
140 | this.txtLowerRightX = new JTextField(); |
||
141 | this.txtLowerRightY = new JTextField(); |
||
142 | 43913 | jjdelcerro | this.btnMapControlEnvelope = btnMapControlEnvelope;
|
143 | this.btnCapture = btnCapture;
|
||
144 | |||
145 | this.initComponents();
|
||
146 | } |
||
147 | |||
148 | private void initComponents() { |
||
149 | 46487 | jjdelcerro | ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
150 | 46489 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
151 | 47779 | fdiaz | MapControl theMapControl = this.getMapControl();
|
152 | 46487 | jjdelcerro | this.captureCursor = new ImageIcon(this.getIcon("picker-envelope-cursor-capture").getImage()); |
153 | 43913 | jjdelcerro | |
154 | 46487 | jjdelcerro | if( this.btnCapture!=null ) { |
155 | this.btnCapture.setIcon(this.getIcon("picker-envelope-capture")); |
||
156 | 46489 | jjdelcerro | this.btnCapture.setToolTipText(i18n.getTranslation("_Capture_an_area_in_the_view")); |
157 | 46487 | jjdelcerro | if( this.btnCapture.getText().equals("...") ) { |
158 | this.btnCapture.setText(""); |
||
159 | } |
||
160 | this.btnCapture.addActionListener((ActionEvent e) -> { |
||
161 | doCaptureEnvelope(btnCapture.isSelected()); |
||
162 | }); |
||
163 | this.btnCapture.setEnabled(this.mapControl!=null); |
||
164 | } |
||
165 | 43913 | jjdelcerro | if( this.btnMapControlEnvelope!=null ) { |
166 | 46487 | jjdelcerro | this.btnMapControlEnvelope.setIcon(this.getIcon("picker-envelope-from-mapcontrol")); |
167 | 46489 | jjdelcerro | this.btnMapControlEnvelope.setToolTipText(i18n.getTranslation("_Capture_the_view_area")); |
168 | 46487 | jjdelcerro | if( this.btnMapControlEnvelope.getText().equals("...") ) { |
169 | this.btnMapControlEnvelope.setText(""); |
||
170 | } |
||
171 | this.btnMapControlEnvelope.addActionListener((ActionEvent e) -> { |
||
172 | 46640 | jjdelcerro | doSetEnvelopeFromMapControlEnvelope(); |
173 | 43913 | jjdelcerro | }); |
174 | 46487 | jjdelcerro | this.btnMapControlEnvelope.setEnabled(this.mapControl!=null); |
175 | 43913 | jjdelcerro | } |
176 | 47779 | fdiaz | if( theMapControl!=null ) { |
177 | 46487 | jjdelcerro | this.captureTool = new RectangleBehavior(new CaptureEnvelopeListener()); |
178 | 47779 | fdiaz | theMapControl.addBehavior("picker-envelope-capture", captureTool);
|
179 | this.previosTool = this.mapControl.get().getCurrentTool(); |
||
180 | 46487 | jjdelcerro | } |
181 | 43913 | jjdelcerro | |
182 | if( this.txtEnvelope==null ) { |
||
183 | 46487 | jjdelcerro | toolsSwingManager.addClearButton(this.txtUpperLeftX);
|
184 | toolsSwingManager.addClearButton(this.txtUpperLeftY);
|
||
185 | toolsSwingManager.addClearButton(this.txtLowerRightX);
|
||
186 | toolsSwingManager.addClearButton(this.txtLowerRightY);
|
||
187 | |||
188 | toolsSwingManager.setDefaultPopupMenu(this.txtUpperLeftX);
|
||
189 | toolsSwingManager.setDefaultPopupMenu(this.txtUpperLeftY);
|
||
190 | toolsSwingManager.setDefaultPopupMenu(this.txtLowerRightX);
|
||
191 | toolsSwingManager.setDefaultPopupMenu(this.txtLowerRightY);
|
||
192 | |||
193 | this.txtUpperLeftX.setHorizontalAlignment(SwingConstants.RIGHT); |
||
194 | this.txtUpperLeftY.setHorizontalAlignment(SwingConstants.RIGHT); |
||
195 | this.txtLowerRightX.setHorizontalAlignment(SwingConstants.RIGHT); |
||
196 | this.txtLowerRightY.setHorizontalAlignment(SwingConstants.RIGHT); |
||
197 | |||
198 | 43913 | jjdelcerro | this.txtUpperLeftX.setText("#########,00000"); |
199 | Dimension dim = this.txtUpperLeftX.getPreferredSize(); |
||
200 | this.txtUpperLeftX.setText(""); |
||
201 | |||
202 | this.txtUpperLeftX.setPreferredSize(dim);
|
||
203 | this.txtUpperLeftY.setPreferredSize(dim);
|
||
204 | this.txtLowerRightX.setPreferredSize(dim);
|
||
205 | this.txtLowerRightY.setPreferredSize(dim);
|
||
206 | |||
207 | DoubleDocumentFilter.install(this.txtUpperLeftX);
|
||
208 | DoubleDocumentFilter.install(this.txtUpperLeftY);
|
||
209 | DoubleDocumentFilter.install(this.txtLowerRightX);
|
||
210 | DoubleDocumentFilter.install(this.txtLowerRightY);
|
||
211 | } else {
|
||
212 | 46487 | jjdelcerro | toolsSwingManager.addClearButton(this.txtEnvelope);
|
213 | toolsSwingManager.setDefaultPopupMenu(this.txtEnvelope);
|
||
214 | // this.txtEnvelope.setEditable(false);
|
||
215 | 43913 | jjdelcerro | } |
216 | } |
||
217 | |||
218 | 46640 | jjdelcerro | protected void doSetEnvelopeFromMapControlEnvelope() { |
219 | 47779 | fdiaz | MapControl theMapControl = this.getMapControl();
|
220 | if( !this.isEditable() || theMapControl==null ) { |
||
221 | 43913 | jjdelcerro | return;
|
222 | } |
||
223 | try {
|
||
224 | 47779 | fdiaz | Envelope env = theMapControl.getViewPort().getEnvelope(); |
225 | 46487 | jjdelcerro | if( env == null ) { |
226 | return;
|
||
227 | } |
||
228 | Envelope theEnvelope = (Envelope) env.clone(); |
||
229 | 43913 | jjdelcerro | this.set(theEnvelope);
|
230 | } catch (Exception ex) { |
||
231 | LOG.warn("Can't get envelope from mapcontrol.", ex);
|
||
232 | } |
||
233 | } |
||
234 | |||
235 | 47779 | fdiaz | |
236 | 43913 | jjdelcerro | protected void doCaptureEnvelope(boolean enabled) { |
237 | 47779 | fdiaz | MapControl theMapControl = this.getMapControl();
|
238 | if( !this.isEditable() || theMapControl==null ) { |
||
239 | 43913 | jjdelcerro | return;
|
240 | } |
||
241 | 47779 | fdiaz | |
242 | Envelope env = theMapControl.getViewPort().getEnvelope(); |
||
243 | 46487 | jjdelcerro | if( env == null ) { |
244 | return;
|
||
245 | } |
||
246 | 43913 | jjdelcerro | if( enabled ) {
|
247 | 47779 | fdiaz | this.previosTool = theMapControl.getCurrentTool();
|
248 | theMapControl.setTool("picker-envelope-capture");
|
||
249 | 43913 | jjdelcerro | } else {
|
250 | 47779 | fdiaz | theMapControl.setTool(this.previosTool);
|
251 | 43913 | jjdelcerro | } |
252 | } |
||
253 | |||
254 | protected String getEnvelopeAsString(Envelope value) { |
||
255 | String s = String.format( |
||
256 | "%+f, %+f, %+f, %+f",
|
||
257 | value.getMinimum(Geometry.DIMENSIONS.X), |
||
258 | value.getMaximum(Geometry.DIMENSIONS.Y), |
||
259 | value.getMaximum(Geometry.DIMENSIONS.X), |
||
260 | value.getMinimum(Geometry.DIMENSIONS.Y) |
||
261 | ); |
||
262 | return s;
|
||
263 | } |
||
264 | |||
265 | @Override
|
||
266 | public boolean isValid() { |
||
267 | if( this.txtEnvelope==null ) { |
||
268 | 46487 | jjdelcerro | if( DoubleDocumentFilter.isEmpty(this.txtUpperLeftX) |
269 | && DoubleDocumentFilter.isEmpty(this.txtUpperLeftY)
|
||
270 | && DoubleDocumentFilter.isEmpty(this.txtLowerRightX)
|
||
271 | && DoubleDocumentFilter.isEmpty(this.txtLowerRightY) ) {
|
||
272 | return true; |
||
273 | } |
||
274 | if( DoubleDocumentFilter.isEmpty(this.txtUpperLeftX) |
||
275 | || DoubleDocumentFilter.isEmpty(this.txtUpperLeftY)
|
||
276 | || DoubleDocumentFilter.isEmpty(this.txtLowerRightX)
|
||
277 | || DoubleDocumentFilter.isEmpty(this.txtLowerRightY) ) {
|
||
278 | return false; |
||
279 | } |
||
280 | 43913 | jjdelcerro | if( !DoubleDocumentFilter.isValid(this.txtUpperLeftX) ) { |
281 | return false; |
||
282 | } |
||
283 | if( !DoubleDocumentFilter.isValid(this.txtUpperLeftY) ) { |
||
284 | return false; |
||
285 | } |
||
286 | if( !DoubleDocumentFilter.isValid(this.txtLowerRightX) ) { |
||
287 | return false; |
||
288 | } |
||
289 | if( !DoubleDocumentFilter.isValid(this.txtLowerRightY) ) { |
||
290 | return false; |
||
291 | } |
||
292 | return true; |
||
293 | } else {
|
||
294 | 46487 | jjdelcerro | if( StringUtils.isBlank(this.txtEnvelope.getText()) ) { |
295 | return true; |
||
296 | } |
||
297 | try {
|
||
298 | GeometryUtils.createFrom(this.txtEnvelope.getText());
|
||
299 | } catch(Exception ex) { |
||
300 | return false; |
||
301 | } |
||
302 | 43913 | jjdelcerro | return true; |
303 | } |
||
304 | } |
||
305 | |||
306 | @Override
|
||
307 | public boolean isEmpty() { |
||
308 | if( this.txtEnvelope==null ) { |
||
309 | 46487 | jjdelcerro | if( DoubleDocumentFilter.isEmpty(this.txtUpperLeftX) |
310 | && DoubleDocumentFilter.isEmpty(this.txtUpperLeftY)
|
||
311 | && DoubleDocumentFilter.isEmpty(this.txtLowerRightX)
|
||
312 | && DoubleDocumentFilter.isEmpty(this.txtLowerRightY) ) {
|
||
313 | 43913 | jjdelcerro | return true; |
314 | } |
||
315 | return false; |
||
316 | } else {
|
||
317 | 46487 | jjdelcerro | return StringUtils.isBlank(this.txtEnvelope.getText()); |
318 | 43913 | jjdelcerro | } |
319 | } |
||
320 | |||
321 | @Override
|
||
322 | public Envelope get() {
|
||
323 | 46487 | jjdelcerro | if( this.isEmpty() ) { |
324 | return null; |
||
325 | } |
||
326 | 43913 | jjdelcerro | if( !this.isValid() ) { |
327 | throw new IllegalValueException(); |
||
328 | } |
||
329 | 46491 | jjdelcerro | Envelope envelope = null;
|
330 | 43913 | jjdelcerro | if( this.txtEnvelope==null ) { |
331 | try {
|
||
332 | double upperLeftX = DoubleDocumentFilter.getValue(this.txtUpperLeftX); |
||
333 | double upperLeftY = DoubleDocumentFilter.getValue(this.txtUpperLeftY); |
||
334 | double lowerRightX = DoubleDocumentFilter.getValue(this.txtLowerRightX); |
||
335 | double lowerRightY = DoubleDocumentFilter.getValue(this.txtLowerRightY); |
||
336 | GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
||
337 | 46491 | jjdelcerro | envelope = geomManager.createEnvelope(Geometry.SUBTYPES.GEOM2D); |
338 | 43913 | jjdelcerro | Point upperLeft = geomManager.createPoint(upperLeftX, upperLeftY, Geometry.SUBTYPES.GEOM2D);
|
339 | Point lowerRight = geomManager.createPoint(lowerRightX, lowerRightY, Geometry.SUBTYPES.GEOM2D);
|
||
340 | 46487 | jjdelcerro | envelope.setUpperCorner(upperLeft); |
341 | envelope.setLowerCorner(lowerRight); |
||
342 | } catch (Exception ex) { |
||
343 | 46491 | jjdelcerro | return null; |
344 | 43913 | jjdelcerro | } |
345 | 46487 | jjdelcerro | } else {
|
346 | try {
|
||
347 | Geometry geom = GeometryUtils.createFrom(this.txtEnvelope.getText());
|
||
348 | 46491 | jjdelcerro | envelope = geom.getEnvelope(); |
349 | 46487 | jjdelcerro | } catch(Exception ex) { |
350 | return null; |
||
351 | } |
||
352 | 43913 | jjdelcerro | } |
353 | 47779 | fdiaz | MapControl theMapControl = this.getMapControl();
|
354 | if( theMapControl!=null ) { |
||
355 | envelope.setProjection(theMapControl.getProjection()); |
||
356 | 46491 | jjdelcerro | } |
357 | return envelope;
|
||
358 | 43913 | jjdelcerro | } |
359 | |||
360 | @Override
|
||
361 | public void set(Envelope envelope) { |
||
362 | 46487 | jjdelcerro | if( envelope == null ) { |
363 | this.clear();
|
||
364 | return;
|
||
365 | 43913 | jjdelcerro | } |
366 | 46491 | jjdelcerro | if( envelope.isCollapsed() ) {
|
367 | this.clear();
|
||
368 | return;
|
||
369 | } |
||
370 | 43913 | jjdelcerro | if( this.txtEnvelope==null ) { |
371 | this.txtUpperLeftX.setText(String.format("%+f", envelope.getMinimum(DIMENSIONS.X))); |
||
372 | this.txtUpperLeftY.setText(String.format("%+f", envelope.getMaximum(DIMENSIONS.Y))); |
||
373 | this.txtLowerRightX.setText(String.format("%+f", envelope.getMaximum(DIMENSIONS.X))); |
||
374 | this.txtLowerRightY.setText(String.format("%+f", envelope.getMinimum(DIMENSIONS.Y))); |
||
375 | } else {
|
||
376 | 46491 | jjdelcerro | this.txtEnvelope.setText(envelope.getBox2D().convertToWKTQuietly());
|
377 | 43913 | jjdelcerro | } |
378 | 46837 | fdiaz | fireChangeEvent(); |
379 | 43913 | jjdelcerro | } |
380 | |||
381 | @Override
|
||
382 | public void coerceAndSet(Object value) { |
||
383 | 46487 | jjdelcerro | if( value == null ) { |
384 | this.clear();
|
||
385 | return;
|
||
386 | } |
||
387 | 43913 | jjdelcerro | DataType dataType = ToolsLocator.getDataTypesManager() |
388 | .get(DataTypes.ENVELOPE); |
||
389 | try {
|
||
390 | this.set((Envelope) dataType.coerce(value));
|
||
391 | } catch (CoercionException ex) {
|
||
392 | LOG.warn("Can't set value.", ex);
|
||
393 | } |
||
394 | } |
||
395 | |||
396 | @Override
|
||
397 | public void setEnabled(boolean enabled) { |
||
398 | if( this.txtEnvelope==null ) { |
||
399 | this.txtUpperLeftX.setEnabled(enabled);
|
||
400 | this.txtUpperLeftY.setEnabled(enabled);
|
||
401 | this.txtLowerRightX.setEnabled(enabled);
|
||
402 | this.txtLowerRightY.setEnabled(enabled);
|
||
403 | } else {
|
||
404 | this.txtEnvelope.setEnabled(enabled);
|
||
405 | } |
||
406 | 46487 | jjdelcerro | if( this.mapControl == null ) { |
407 | this.btnCapture.setEnabled(false); |
||
408 | this.btnMapControlEnvelope.setEnabled(false); |
||
409 | } else {
|
||
410 | this.btnCapture.setEnabled(enabled);
|
||
411 | this.btnMapControlEnvelope.setEnabled(enabled);
|
||
412 | } |
||
413 | 43913 | jjdelcerro | } |
414 | |||
415 | @Override
|
||
416 | public boolean isEnabled() { |
||
417 | if( this.txtEnvelope!=null ) { |
||
418 | return this.txtEnvelope.isEnabled(); |
||
419 | } |
||
420 | return true; |
||
421 | } |
||
422 | |||
423 | @Override
|
||
424 | public void setEditable(boolean editable) { |
||
425 | super.setEditable(editable);
|
||
426 | if( this.txtEnvelope==null ) { |
||
427 | this.txtUpperLeftX.setEditable(editable);
|
||
428 | this.txtUpperLeftY.setEditable(editable);
|
||
429 | this.txtLowerRightX.setEditable(editable);
|
||
430 | this.txtLowerRightY.setEditable(editable);
|
||
431 | } else {
|
||
432 | this.txtEnvelope.setEditable(editable);
|
||
433 | } |
||
434 | } |
||
435 | |||
436 | 46487 | jjdelcerro | public void clear() { |
437 | if( this.txtEnvelope==null ) { |
||
438 | this.txtUpperLeftX.setText(""); |
||
439 | this.txtUpperLeftY.setText(""); |
||
440 | this.txtLowerRightX.setText(""); |
||
441 | this.txtLowerRightY.setText(""); |
||
442 | } else {
|
||
443 | this.txtEnvelope.setText(""); |
||
444 | } |
||
445 | 46837 | fdiaz | fireChangeEvent(); |
446 | 46487 | jjdelcerro | } |
447 | |||
448 | 47779 | fdiaz | |
449 | private MapControl getMapControl() {
|
||
450 | if( this.mapControl == null ) { |
||
451 | return null; |
||
452 | } |
||
453 | return this.mapControl.get(); |
||
454 | } |
||
455 | 43913 | jjdelcerro | } |