826220679@qq.com
2025-08-07 4d6cd980c5c69e4d9d150669c89734642297e0cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
package dell_map;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.image.BufferedImage; // ÐÂÔö£ºÓÃÓÚ»ñȡͼƬ³ß´ç
import javax.imageio.ImageIO; // ÐÂÔö£ºÓÃÓÚ¶ÁȡͼƬ
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.regex.Pattern;
import dell_suanfa.Dell_LayerManagement;
import dell_system.Dell_company;
import targets.Mapdata;
 
// Ìí¼Ó/±à¼­µØÍ¼¶Ô»°¿ò
@SuppressWarnings("serial")
public class AddEditMapDialog extends JDialog {
    private boolean saved = false; // ±£´æ×´Ì¬±êÖ¾
    private Mapdata mapData; // µØÍ¼Êý¾Ý¶ÔÏó
    private ResourceBundle messages; // ¹ú¼Ê»¯ÏûÏ¢×ÊÔ´
 
    // ½çÃæ×é¼þ
    private JComboBox<String> companyComboBox; // ËùÊô¹«Ë¾ÏÂÀ­¿ò
    private JTextField mapNameField; // µØÍ¼Ãû³ÆÎı¾¿ò
    private JButton selectMapButton; // Ñ¡ÔñµØÍ¼°´Å¥
    private JComboBox<String> layerComboBox; // ËùÔÚͼ²ãÏÂÀ­¿ò
    private JTextField xRealLengthField; // Xʵ¼Ê³¤¶ÈÎı¾¿ò
    private JTextField yRealLengthField; // Yʵ¼Ê³¤¶ÈÎı¾¿ò
    private JTextField x0CoordinateField; // X0×ø±êÎı¾¿ò
    private JTextField y0CoordinateField; // Y0×ø±êÎı¾¿ò
    private JTextField xPixelsField; // XÏñËØÎı¾¿ò£¨²»¿É±à¼­£©
    private JTextField yPixelsField; // YÏñËØÎı¾¿ò£¨²»¿É±à¼­£©
    private JTextField pointAField; // Aµã×ø±êÎı¾¿ò
    private JTextField pointBField; // Bµã×ø±êÎı¾¿ò
    private JTextField addTimeField; // Ìí¼Óʱ¼äÎı¾¿ò
    private String mapNameDetail; // ´æ´¢µØÍ¼ÏêϸÃû³Æ£¨º¬À©Õ¹Ãû£©
 
    // ¹¹Ô캯Êý
    public AddEditMapDialog(JFrame parent, String title, boolean modal, Mapdata mapData, ResourceBundle messages) {
        super(parent, title, modal);
        this.mapData = mapData; // ÉèÖõØÍ¼Êý¾Ý
        this.messages = messages; // ÉèÖÃÏûÏ¢×ÊÔ´
        initDialog(); // ³õʼ»¯¶Ô»°¿ò½çÃæ
    }
 
    // ³õʼ»¯¶Ô»°¿ò½çÃæ
    private void initDialog() {
        // ÉèÖöԻ°¿ò³ß´ç
        setSize(620, 670);
        setLocationRelativeTo(getOwner()); // ¾ÓÖÐÏÔʾ
 
        // ´´½¨Ö÷Ãæ°å£¨¾ø¶Ô²¼¾Ö£©
        JPanel mainPanel = new JPanel(null);
        mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
 
        int x = 50; // ×é¼þX×ø±ê
        int y = 20; // ÆðʼY×ø±ê
        int w = 150; // ±êÇ©¿í¶È
        int h = 25; // ×é¼þ¸ß¶È
        int j = 20; // Ðмä¾à
        int k = 150; // Îı¾¿ò¿í¶È
 
        // ËùÊô¹«Ë¾±êÇ©
        JLabel companyLabel = new JLabel(getResourceString("map.dialog.company") + ":");
        companyLabel.setBounds(x, y, w, h);
        companyComboBox = new JComboBox<>();
        companyComboBox.setBounds(x + w, y, 300, h); // ÏÂÀ­¿ò¿í¶È300
        // ¼ÓÔØËùÓй«Ë¾Ãû³Æ
        String[] companies = Dell_company.getAllCompanyNames();
        for (String company : companies) {
            companyComboBox.addItem(company); // Ìí¼Ó¹«Ë¾Ñ¡Ïî
        }
        mainPanel.add(companyLabel);
        mainPanel.add(companyComboBox);
 
        // µØÍ¼Ãû³Æ±êÇ©ºÍÑ¡Ôñ°´Å¥
        JLabel mapNameLabel = new JLabel(getResourceString("map.dialog.mapName") + ":");
        mapNameLabel.setBounds(x, y + 1*(h+j), w, h);
        JPanel mapNamePanel = new JPanel(new BorderLayout());
        // Ð޸ģº¿í¶ÈÉèÖÃΪ300£¨Ó빫˾ÏÂÀ­¿òÒ»Ö£©
        mapNamePanel.setBounds(x + w, y + 1*(h+j), 300, h); 
        mapNameField = new JTextField();
        mapNameField.setEditable(false); // µØÍ¼Ãû³Æ²»¿ÉÖ±½Ó±à¼­
        mapNamePanel.add(mapNameField, BorderLayout.CENTER);
        selectMapButton = new JButton(getResourceString("map.dialog.selectMap")); // ¹ú¼Ê»¯Ð޸ģºÑ¡Ôñ°´Å¥Îı¾
        selectMapButton.addActionListener(e -> selectMapImage()); // Ìí¼ÓÑ¡ÔñͼƬ¼àÌý
        mapNamePanel.add(selectMapButton, BorderLayout.EAST);
        mainPanel.add(mapNameLabel);
        mainPanel.add(mapNamePanel);
 
        // ËùÔÚͼ²ã±êÇ©
        JLabel layerLabel = new JLabel(getResourceString("map.dialog.layer") + ":");
        layerLabel.setBounds(x, y + 2*(h+j), w, h);
        layerComboBox = new JComboBox<>();
        layerComboBox.setBounds(x + w, y + 2*(h+j), k, h);
        // ¼ÓÔØËùÓÐͼ²ã±àºÅ
        String[] layers = Dell_LayerManagement.getAllLayerNumbers();
        for (String layer : layers) {
            layerComboBox.addItem(layer); // Ìí¼Óͼ²ãÑ¡Ïî
        }
        mainPanel.add(layerLabel);
        mainPanel.add(layerComboBox);
 
        // Xʵ¼Ê³¤¶È±êÇ©
        JLabel xRealLabel = new JLabel(getResourceString("map.dialog.xRealLength") + ":");
        xRealLabel.setBounds(x, y + 3*(h+j), w, h);
        xRealLengthField = new JTextField();
        xRealLengthField.setBounds(x + w, y + 3*(h+j), k, h);
        mainPanel.add(xRealLabel);
        mainPanel.add(xRealLengthField);
 
        // Yʵ¼Ê³¤¶È±êÇ©
        JLabel yRealLabel = new JLabel(getResourceString("map.dialog.yRealLength") + ":");
        yRealLabel.setBounds(x, y + 4*(h+j), w, h);
        yRealLengthField = new JTextField();
        yRealLengthField.setBounds(x + w, y + 4*(h+j), k, h);
        mainPanel.add(yRealLabel);
        mainPanel.add(yRealLengthField);
 
        // X0×ø±ê±êÇ©
        JLabel x0Label = new JLabel(getResourceString("map.dialog.x0Coordinate") + ":");
        x0Label.setBounds(x, y + 5*(h+j), w, h);
        x0CoordinateField = new JTextField();
        x0CoordinateField.setBounds(x + w, y + 5*(h+j), k, h);
        mainPanel.add(x0Label);
        mainPanel.add(x0CoordinateField);
 
        // Y0×ø±ê±êÇ©
        JLabel y0Label = new JLabel(getResourceString("map.dialog.y0Coordinate") + ":");
        y0Label.setBounds(x, y + 6*(h+j), w, h);
        y0CoordinateField = new JTextField();
        y0CoordinateField.setBounds(x + w, y + 6*(h+j), k, h);
        mainPanel.add(y0Label);
        mainPanel.add(y0CoordinateField);
 
        // XÏñËØ±êÇ©
        JLabel xPixelsLabel = new JLabel(getResourceString("map.dialog.xPixels") + ":");
        xPixelsLabel.setBounds(x, y + 7*(h+j), w, h);
        xPixelsField = new JTextField();
        xPixelsField.setBounds(x + w, y + 7*(h+j), k, h);
        xPixelsField.setEditable(false); // ÉèÖÃΪ²»¿É±à¼­
        mainPanel.add(xPixelsLabel);
        mainPanel.add(xPixelsField);
 
        // YÏñËØ±êÇ©
        JLabel yPixelsLabel = new JLabel(getResourceString("map.dialog.yPixels") + ":");
        yPixelsLabel.setBounds(x, y + 8*(h+j), w, h);
        yPixelsField = new JTextField();
        yPixelsField.setBounds(x + w, y + 8*(h+j), k, h);
        yPixelsField.setEditable(false); // ÉèÖÃΪ²»¿É±à¼­
        mainPanel.add(yPixelsLabel);
        mainPanel.add(yPixelsField);
 
        // Aµã×ø±ê±êÇ©
        JLabel pointALabel = new JLabel(getResourceString("map.dialog.pointA") + ":");
        pointALabel.setBounds(x, y + 9*(h+j), w, h);
        pointAField = new JTextField();
        pointAField.setBounds(x + w, y + 9*(h+j), k + 100, h);
        pointAField.setToolTipText(getResourceString("map.dialog.pointA.tooltip")); // ¹ú¼Ê»¯Ð޸ģºÌáʾÎı¾
        mainPanel.add(pointALabel);
        mainPanel.add(pointAField);
 
        // Bµã×ø±ê±êÇ©
        JLabel pointBLabel = new JLabel(getResourceString("map.dialog.pointB") + ":");
        pointBLabel.setBounds(x, y + 10*(h+j), w, h);
        pointBField = new JTextField();
        pointBField.setBounds(x + w, y + 10*(h+j), k + 100, h);
        pointBField.setToolTipText(getResourceString("map.dialog.pointB.tooltip")); // ¹ú¼Ê»¯Ð޸ģºÌáʾÎı¾
        mainPanel.add(pointBLabel);
        mainPanel.add(pointBField);
 
        // Ìí¼Óʱ¼ä±êÇ©
        JLabel addTimeLabel = new JLabel(getResourceString("map.dialog.addTime") + ":");
        addTimeLabel.setBounds(x, y + 11*(h+j), w, h);
        addTimeField = new JTextField();
        addTimeField.setBounds(x + w, y + 11*(h+j), k, h);
        addTimeField.setEditable(false); // ²»¿É±à¼­
        mainPanel.add(addTimeLabel);
        mainPanel.add(addTimeField);
 
        // ÉèÖóõʼֵ
        if (mapData != null) {
            setFieldValues(); // ÉèÖÃ×Ö¶ÎÖµ£¨±à¼­Ä£Ê½£©
            // ±à¼­Ä£Ê½ÏµØÍ¼Ãû³Æ²»¿ÉÐÞ¸Ä
            mapNameField.setEnabled(false);
            selectMapButton.setEnabled(false); // ½ûÓÃÑ¡Ôñ°´Å¥
        } else {
            // ÉèÖõ±Ç°Ê±¼äΪÌí¼Óʱ¼ä
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            addTimeField.setText(sdf.format(new Date()));
        }
 
        // ´´½¨°´Å¥Ãæ°å
        JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttonPanel.setBounds(0, y + 12*(h+j) + 10, 580, 40);
 
        // ±£´æ°´Å¥
        JButton saveButton = new JButton(getResourceString("common.save"));
        saveButton.addActionListener(e -> saveMapData()); // Ìí¼Ó±£´æ¼àÌý
        buttonPanel.add(saveButton);
 
        // È¡Ïû°´Å¥
        JButton cancelButton = new JButton(getResourceString("common.cancel"));
        cancelButton.addActionListener(e -> dispose()); // ¹Ø±Õ¶Ô»°¿ò
        buttonPanel.add(cancelButton);
 
        // Ìí¼Ó°´Å¥Ãæ°åµ½Ö÷Ãæ°å
        mainPanel.add(buttonPanel);
        add(mainPanel);
    }
 
    // ÉèÖÃ×Ö¶ÎÖµ£¨±à¼­Ä£Ê½£©
    private void setFieldValues() {
        companyComboBox.setSelectedItem(mapData.getCompany());
        mapNameField.setText(mapData.getMapName());
        layerComboBox.setSelectedItem(mapData.getLocatedLayer());
        xRealLengthField.setText(mapData.getActualXLength());
        yRealLengthField.setText(mapData.getActualYLength());
        x0CoordinateField.setText(mapData.getX0Coordinate());
        y0CoordinateField.setText(mapData.getY0Coordinate());
        xPixelsField.setText(mapData.getXPixels());
        yPixelsField.setText(mapData.getYPixels());
        pointAField.setText(mapData.getPointALatlngXyCoordinate());
        pointBField.setText(mapData.getPointBLatlngXyCoordinate());
        addTimeField.setText(mapData.getAddedTime());
    }
 
    // Ñ¡ÔñµØÍ¼Í¼Æ¬
    private void selectMapImage() {
        // ´´½¨ÎļþÑ¡ÔñÆ÷
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle(getResourceString("map.dialog.selectMapImage")); // ¹ú¼Ê»¯Ð޸ģº¶Ô»°¿ò±êÌâ
 
        // ÉèÖÃÎļþ¹ýÂËÆ÷£¨½öͼƬÎļþ£©
        FileNameExtensionFilter filter = new FileNameExtensionFilter(
            getResourceString("map.dialog.imageFiles"), "jpg", "png", "jpeg"); // ¹ú¼Ê»¯Ð޸ģºÎļþÀàÐÍÃèÊö
        fileChooser.setFileFilter(filter);
 
        // ÏÔʾ´ò¿ª¶Ô»°¿ò
        int result = fileChooser.showOpenDialog(this);
 
        if (result == JFileChooser.APPROVE_OPTION) {
            // »ñȡѡÔñµÄÎļþ
            File selectedFile = fileChooser.getSelectedFile();
 
            try {
                // ¶ÁȡͼƬ»ñÈ¡³ß´ç
                BufferedImage image = ImageIO.read(selectedFile);
                if (image != null) {
                    int width = image.getWidth(); // »ñȡͼƬ¿í¶È
                    int height = image.getHeight(); // »ñȡͼƬ¸ß¶È
                    xPixelsField.setText(String.valueOf(width)); // ÉèÖÃXÏñËØÖµ
                    yPixelsField.setText(String.valueOf(height)); // ÉèÖÃYÏñËØÖµ
                }
            } catch (IOException ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(this, 
                    getResourceString("map.dialog.getImageSizeFailed") + ": " + ex.getMessage(), // ¹ú¼Ê»¯Ð޸ģº´íÎóÏûÏ¢
                    getResourceString("common.error"), // ¹ú¼Ê»¯Ð޸ģº´íÎó±êÌâ
                    JOptionPane.ERROR_MESSAGE);
            }
 
            // ÉèÖõØÍ¼Ãû³Æ£¨²»º¬À©Õ¹Ãû£©
            String fileName = selectedFile.getName();
            String mapName = fileName.substring(0, fileName.lastIndexOf('.'));
            mapNameField.setText(mapName);
         // ÐÂÔö£ºÉèÖÃÏêϸÃû³Æ£¨°üº¬À©Õ¹Ãû£©
            this.mapNameDetail = fileName; 
 
            // »ñȡĿ±êĿ¼
            File destDir = new File("systemfile/imagemap");
            if (!destDir.exists()) {
                destDir.mkdirs(); // ´´½¨Ä¿Â¼
            }
 
            // Ä¿±êÎļþ·¾¶
            File destFile = new File(destDir, fileName);
 
            try {
                // ¸´ÖÆÎļþµ½Ä¿±êĿ¼
                Files.copy(selectedFile.toPath(), destFile.toPath(), 
                    StandardCopyOption.REPLACE_EXISTING);
 
                // ÏÔʾ³É¹¦ÏûÏ¢
                JOptionPane.showMessageDialog(this, 
                    getResourceString("map.dialog.uploadSuccess"), // ¹ú¼Ê»¯Ð޸ģºÉÏ´«³É¹¦ÏûÏ¢
                    getResourceString("common.success"), // ¹ú¼Ê»¯Ð޸ģº³É¹¦±êÌâ
                    JOptionPane.INFORMATION_MESSAGE);
            } catch (IOException e) {
                // ´¦ÀíÎļþ¸´ÖÆ´íÎó
                e.printStackTrace();
                JOptionPane.showMessageDialog(this, 
                    getResourceString("map.dialog.uploadFailed") + ": " + e.getMessage(), // ¹ú¼Ê»¯Ð޸ģºÉÏ´«Ê§°ÜÏûÏ¢
                    getResourceString("common.error"), // ¹ú¼Ê»¯Ð޸ģº´íÎó±êÌâ
                    JOptionPane.ERROR_MESSAGE);
            }
        }
    }
 
    private void saveMapData() {
        // ÑéÖ¤×Ö¶Î
        if (!validateFields()) {
            return; // Ñé֤ʧ°ÜÔòÍ˳ö
        }
 
        try {
            // ´´½¨»ò»ñÈ¡µØÍ¼¶ÔÏó
            Mapdata map = (mapData == null) ? new Mapdata() : mapData;
 
            // ÉèÖõØÍ¼ÊôÐÔ - Ö»ÐÞ¸ÄͼƬÖÐÏÔʾµÄ×Ö¶Î
            map.setCompany((String) companyComboBox.getSelectedItem());
            map.setLocatedLayer((String) layerComboBox.getSelectedItem());
            map.setActualXLength(xRealLengthField.getText());
            map.setActualYLength(yRealLengthField.getText());
            map.setX0Coordinate(x0CoordinateField.getText());
            map.setY0Coordinate(y0CoordinateField.getText());
            map.setXPixels(xPixelsField.getText());
            map.setYPixels(yPixelsField.getText());
            map.setPointALatlngXyCoordinate(pointAField.getText());
            map.setPointBLatlngXyCoordinate(pointBField.getText());
            
            // Ìí¼ÓģʽϲÅÉèÖõØÍ¼Ãû³ÆºÍÏêϸÃû³Æ
            if (mapData == null) {
                map.setMapName(mapNameField.getText());
                map.setMapNameDetaile(this.mapNameDetail);
            }
            
            // Ìí¼Óʱ¼ä±£³Ö²»±ä£¨±à¼­Ä£Ê½Ï²»Ð޸ģ©
            if (mapData == null) {
                map.setAddedTime(addTimeField.getText());
            }
 
            // ±£´æµ½Êý¾Ý¿â
            if (mapData == null) {
                // ¼ì²éµØÍ¼Ãû³ÆÊÇ·ñÒÑ´æÔÚ
                if (Dell_Map.isMapNameExist(map.getMapName())) {
                    JOptionPane.showMessageDialog(this, 
                        getResourceString("map.dialog.mapNameExist"), // ¹ú¼Ê»¯Ð޸ģºÃû³Æ´æÔÚÌáʾ
                        getResourceString("common.error"), // ¹ú¼Ê»¯Ð޸ģº´íÎó±êÌâ
                        JOptionPane.ERROR_MESSAGE);
                    return;
                }
                Dell_Map.insertMap(map); // ²åÈëеØÍ¼
            } else {
                Dell_Map.updateMap(map); // ¸üÐÂÏÖÓеØÍ¼
            }
 
            // ÉèÖñ£´æ±êÖ¾
            saved = true;
 
            // ¹Ø±Õ¶Ô»°¿ò
            dispose();
        } catch (SQLException e) {
            // ´¦ÀíÊý¾Ý¿â´íÎó
            e.printStackTrace();
            JOptionPane.showMessageDialog(this, 
                getResourceString("map.dialog.saveMapError") + ": " + e.getMessage(), // ¹ú¼Ê»¯Ð޸ģº±£´æ´íÎóÏûÏ¢
                getResourceString("common.error"), // ¹ú¼Ê»¯Ð޸ģº´íÎó±êÌâ
                JOptionPane.ERROR_MESSAGE);
        }
    }
 
    // ÑéÖ¤×Ö¶Î
    private boolean validateFields() {
        // ÑéÖ¤ËùÊô¹«Ë¾
        if (companyComboBox.getSelectedItem() == null) {
            JOptionPane.showMessageDialog(this, 
                getResourceString("map.dialog.validation.company"), // ¹ú¼Ê»¯Ð޸ģº¹«Ë¾ÑéÖ¤
                getResourceString("common.validationError"), // ¹ú¼Ê»¯Ð޸ģºÑéÖ¤´íÎó±êÌâ
                JOptionPane.ERROR_MESSAGE);
            return false;
        }
 
        // ÑéÖ¤µØÍ¼Ãû³Æ
        String mapName = mapNameField.getText().trim();
        if (mapName.isEmpty()) {
            JOptionPane.showMessageDialog(this, 
                getResourceString("map.dialog.validation.mapName"), // ¹ú¼Ê»¯Ð޸ģºÃû³ÆÑéÖ¤
                getResourceString("common.validationError"), // ¹ú¼Ê»¯Ð޸ģºÑéÖ¤´íÎó±êÌâ
                JOptionPane.ERROR_MESSAGE);
            return false;
        }
 
        // ÑéÖ¤ËùÔÚͼ²ã
        if (layerComboBox.getSelectedItem() == null) {
            JOptionPane.showMessageDialog(this, 
                getResourceString("map.dialog.validation.layer"), // ¹ú¼Ê»¯Ð޸ģºÍ¼²ãÑéÖ¤
                getResourceString("common.validationError"), // ¹ú¼Ê»¯Ð޸ģºÑéÖ¤´íÎó±êÌâ
                JOptionPane.ERROR_MESSAGE);
            return false;
        }
 
        // ÑéÖ¤Êý×Ö×Ö¶Î
        if (!isValidNumber(xRealLengthField.getText()) ||
            !isValidNumber(yRealLengthField.getText()) ||
            !isValidNumber(x0CoordinateField.getText()) ||
            !isValidNumber(y0CoordinateField.getText()) ||
            !isValidNumber(xPixelsField.getText()) || // ×¢Ò⣺ÏñËØÖµÏÖÔÚ×Ô¶¯»ñÈ¡
            !isValidNumber(yPixelsField.getText())) {
            JOptionPane.showMessageDialog(this, 
                getResourceString("map.dialog.validation.numberFields"), // ¹ú¼Ê»¯Ð޸ģºÊý×Ö×Ö¶ÎÑéÖ¤
                getResourceString("common.validationError"), // ¹ú¼Ê»¯Ð޸ģºÑéÖ¤´íÎó±êÌâ
                JOptionPane.ERROR_MESSAGE);
            return false;
        }
 
        return true; // ËùÓÐÑé֤ͨ¹ý
    }
 
    // ÑéÖ¤ÊÇ·ñΪÓÐЧÊý×Ö
    private boolean isValidNumber(String value) {
        return value != null && Pattern.matches("^\\d+(\\.\\d+)?$", value);
    }
 
    // »ñÈ¡¹ú¼Ê»¯×Ö·û´®
    private String getResourceString(String key) {
        return messages.getString(key); // ´Ó×ÊÔ´°ü»ñÈ¡×Ö·û´®
    }
 
    // »ñÈ¡±£´æ×´Ì¬
    public boolean isSaved() {
        return saved;
    }
}