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