package home; import javax.swing.*; import javax.swing.table.DefaultTableModel; import java.awt.*; import java.util.Locale; import java.util.ResourceBundle; public class QuickCalculationPanel extends JPanel { private static final long serialVersionUID = 1L; private ResourceBundle messages; private JTextField pointATextField; private JTextField pointBTextField; private JTextField xyToLonLatTextField; private JTextField lonLatToXYTextField; private JTextField point1RawTextField; private JTextField point2RawTextField; private JTextField distanceResultTextField; private JTable nmeaTable; private DefaultTableModel tableModel; private JTextField result1TextField; private JTextField result2TextField; // ¹¹Ô캯Êý public QuickCalculationPanel(ResourceBundle messages) { this.messages = messages; setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setBackground(Color.WHITE); initUI(); } // ³õʼ»¯Óû§½çÃæ private void initUI() { JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); mainPanel.setBackground(Color.WHITE); // ´´½¨´ø±êÌâ±ß¿òµÄÃæ°å mainPanel.add(createPointInputPanel()); mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(createCoordinateConversionPanel()); mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(createDistanceCalculationPanel()); mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(createNMEATablePanel()); JScrollPane scrollPane = new JScrollPane(mainPanel); scrollPane.setBorder(BorderFactory.createEmptyBorder()); add(scrollPane, BorderLayout.CENTER); } /** * ´´½¨µãÊäÈëÃæ°å */ private JPanel createPointInputPanel() { JPanel panel = createTitledPanel(getMessage("POINT_INPUT_SECTION", "µãÊäÈëÇøÓò")); panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 5, 5, 5); // ÉèÖÃ×é¼þ¼ä¾àΪ5ÏñËØ // µãAÊäÈë gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0; JLabel pointALabel = new JLabel(getMessage("POINT_A", "µãA") + ":"); panel.add(pointALabel, gbc); gbc.gridx = 1; gbc.weightx = 1.0; pointATextField = new JTextField(); pointATextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ pointATextField.setToolTipText(getMessage("POINT_A1", "¸ñʽ: ¾­¶È,γ¶È,±¾µØX,±¾µØY")); panel.add(pointATextField, gbc); // µãBÊäÈë gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; JLabel pointBLabel = new JLabel(getMessage("POINT_B", "µãB") + ":"); panel.add(pointBLabel, gbc); gbc.gridx = 1; gbc.weightx = 1.0; pointBTextField = new JTextField(); pointBTextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ pointBTextField.setToolTipText(getMessage("POINT_B1", "¸ñʽ: ¾­¶È,γ¶È,±¾µØX,±¾µØY")); panel.add(pointBTextField, gbc); return panel; } /** * ´´½¨×ø±êת»»Ãæ°å */ private JPanel createCoordinateConversionPanel() { JPanel panel = createTitledPanel(getMessage("COORDINATE_CONVERSION", "×ø±êת»»")); panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 5, 5, 5); // ÉèÖÃ×é¼þ¼ä¾àΪ5ÏñËØ // XYת¾­Î³¶È gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0; JLabel xyToLonLatLabel = new JLabel(getMessage("XY_TO_LONLAT", "XYת¾­Î³¶È") + ":"); panel.add(xyToLonLatLabel, gbc); gbc.gridx = 1; gbc.weightx = 1.0; xyToLonLatTextField = new JTextField(); xyToLonLatTextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ xyToLonLatTextField.setToolTipText(getMessage("XY_TO_LONLAT1", "ÊäÈëX,Y×ø±ê")); panel.add(xyToLonLatTextField, gbc); gbc.gridx = 2; gbc.weightx = 0; JButton convertXYButton = createStyledButton(getMessage("CONVERT", "ת»»")); convertXYButton.addActionListener(e -> convertXYToLonLat()); panel.add(convertXYButton, gbc); // ת»»½á¹û1 gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; JLabel result1Label = new JLabel(getMessage("RESULT", "½á¹û") + ":"); panel.add(result1Label, gbc); gbc.gridx = 1; gbc.weightx = 1.0; result1TextField = new JTextField(); result1TextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ result1TextField.setEditable(false); panel.add(result1TextField, gbc); // ¾­Î³¶ÈתXY gbc.gridx = 0; gbc.gridy = 2; gbc.weightx = 0; JLabel lonLatToXYLabel = new JLabel(getMessage("LONLAT_TO_XY", "¾­Î³¶ÈתXY") + ":"); panel.add(lonLatToXYLabel, gbc); gbc.gridx = 1; gbc.weightx = 1.0; lonLatToXYTextField = new JTextField(); lonLatToXYTextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ lonLatToXYTextField.setToolTipText(getMessage("LONLAT_TO_XY1", "ÊäÈë¾­¶È,γ¶È")); panel.add(lonLatToXYTextField, gbc); gbc.gridx = 2; gbc.weightx = 0; JButton convertLonLatButton = createStyledButton(getMessage("CONVERT", "ת»»")); convertLonLatButton.addActionListener(e -> convertLonLatToXY()); panel.add(convertLonLatButton, gbc); // ת»»½á¹û2 gbc.gridx = 0; gbc.gridy = 3; gbc.weightx = 0; JLabel result2Label = new JLabel(getMessage("RESULT", "½á¹û") + ":"); panel.add(result2Label, gbc); gbc.gridx = 1; gbc.weightx = 1.0; result2TextField = new JTextField(); result2TextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ result2TextField.setEditable(false); panel.add(result2TextField, gbc); return panel; } /** * ´´½¨¾àÀë¼ÆËãÃæ°å */ private JPanel createDistanceCalculationPanel() { JPanel panel = createTitledPanel(getMessage("DISTANCE_CALCULATION", "¾àÀë¼ÆËã")); panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 5, 5, 5); // ÉèÖÃ×é¼þ¼ä¾àΪ5ÏñËØ // ԭʼµã1ÊäÈë gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0; JLabel point1Label = new JLabel(getMessage("POINT1_RAW", "ԭʼµã1") + ":"); panel.add(point1Label, gbc); gbc.gridx = 1; gbc.weightx = 1.0; point1RawTextField = new JTextField(); point1RawTextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ panel.add(point1RawTextField, gbc); // ԭʼµã2ÊäÈë gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; JLabel point2Label = new JLabel(getMessage("POINT2_RAW", "ԭʼµã2") + ":"); panel.add(point2Label, gbc); gbc.gridx = 1; gbc.weightx = 1.0; point2RawTextField = new JTextField(); point2RawTextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ panel.add(point2RawTextField, gbc); // ¼ÆËã°´Å¥ºÍ½á¹û gbc.gridx = 0; gbc.gridy = 2; gbc.weightx = 0; JButton calculateButton = createStyledButton(getMessage("CALCULATE_DISTANCE", "¼ÆËã¾àÀë")); calculateButton.addActionListener(e -> calculateDistance()); panel.add(calculateButton, gbc); gbc.gridx = 1; gbc.weightx = 1.0; distanceResultTextField = new JTextField(); distanceResultTextField.setPreferredSize(new Dimension(200, 25)); // ÉèÖÃÎı¾¿ò³¤¶ÈΪ300ÏñËØ distanceResultTextField.setEditable(false); panel.add(distanceResultTextField, gbc); return panel; } /** * ´´½¨NMEA±í¸ñÃæ°å */ private JPanel createNMEATablePanel() { JPanel panel = createTitledPanel(getMessage("NMEA_DATA_TABLE", "NMEAÊý¾Ý±í")); panel.setLayout(new BorderLayout()); // ´´½¨±í¸ñÁбêÌâ String[] columns = { getMessage("FIELD_NAME", "×Ö¶ÎÃû"), getMessage("POINT1", "µã1"), getMessage("POINT2", "µã2") }; // ¶¨Òå±í¸ñÐÐÃû³Æ String[] rowNames = { getMessage("MSG_ID", "ÏûÏ¢ID"), getMessage("UTC_TIME", "UTCʱ¼ä"), getMessage("LATITUDE", "γ¶È"), getMessage("LAT_HEMISPHERE", "γ¶È°ëÇò"), getMessage("LONGITUDE", "¾­¶È"), getMessage("LON_HEMISPHERE", "¾­¶È°ëÇò"), getMessage("QUALITY", "ÖÊÁ¿"), getMessage("NUM_SATELLITES", "ÎÀÐÇÊýÁ¿"), getMessage("HDOP", "HDOP"), getMessage("ALTITUDE", "º£°Î"), getMessage("ALTITUDE_UNIT", "º£°Îµ¥Î»"), getMessage("GEOID_HEIGHT", "´óµØË®×¼Ãæ¸ß¶È"), getMessage("GEOID_HEIGHT_UNIT", "´óµØË®×¼Ãæ¸ß¶Èµ¥Î»"), getMessage("DIFF_TIME", "²î·Öʱ¼ä"), getMessage("CHECKSUM", "УÑéºÍ"), getMessage("DEVICE_ID", "É豸ID"), getMessage("DEVICE_POWER", "É豸¹¦ÂÊ"), getMessage("SIGNAL_STRENGTH", "ÐźÅÇ¿¶È"), getMessage("RESERVED1", "±£Áô1"), getMessage("RESERVED2", "±£Áô2"), getMessage("RESERVED3", "±£Áô3") }; // ³õʼ»¯±í¸ñÄ£ÐÍ tableModel = new DefaultTableModel(columns, 0); // Ìí¼ÓÐÐÊý¾Ý for (String rowName : rowNames) { tableModel.addRow(new Object[]{rowName, "", ""}); } // ´´½¨±í¸ñ²¢½ûÓñ༭ nmeaTable = new JTable(tableModel); nmeaTable.setEnabled(false); nmeaTable.setRowHeight(25); nmeaTable.getTableHeader().setReorderingAllowed(false); JScrollPane scrollPane = new JScrollPane(nmeaTable); scrollPane.setPreferredSize(new Dimension(600, 300)); panel.add(scrollPane, BorderLayout.CENTER); return panel; } /** * ´´½¨´ø±êÌâ±ß¿òµÄÃæ°å */ private JPanel createTitledPanel(String title) { JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.GRAY), title)); panel.setBackground(Color.WHITE); return panel; } /** * ´´½¨Ñùʽ°´Å¥£¨²Î¿¼ExtensionPanelµÄ°´Å¥Ñùʽ£© */ private JButton createStyledButton(String text) { JButton button = new JButton(text); // ÉèÖð´Å¥´óСΪ80¡Á25£¨¿í¡Á¸ß£© button.setPreferredSize(new Dimension(80, 25)); button.setMinimumSize(new Dimension(80, 25)); button.setMaximumSize(new Dimension(100, 25)); // ÉèÖð´Å¥Ñùʽ£¨²Î¿¼ExtensionPanel£© button.setBackground(new Color(0, 120, 215)); button.setForeground(Color.WHITE); button.setFocusPainted(false); button.setBorderPainted(false); button.setFont(button.getFont().deriveFont(Font.BOLD, 12f)); // Ìí¼ÓÊó±ê½»»¥Ð§¹û£¨²Î¿¼ExtensionPanel£© button.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { button.setBackground(new Color(0, 150, 255)); // Ðüͣʱ±äÁÁ button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } public void mouseExited(java.awt.event.MouseEvent evt) { button.setBackground(new Color(0, 120, 215)); // »Ö¸´Õý³£ÑÕÉ« button.setCursor(Cursor.getDefaultCursor()); } public void mousePressed(java.awt.event.MouseEvent evt) { // µã»÷Ч¹û - ÑÕÉ«±äÉî²¢ÓÐÇá΢ËõСЧ¹û button.setBackground(new Color(0, 80, 160)); button.setBounds(button.getX() + 1, button.getY() + 1, 78, 23); } public void mouseReleased(java.awt.event.MouseEvent evt) { // »Ö¸´Ô­×´ button.setBackground(new Color(0, 150, 255)); button.setBounds(button.getX() - 1, button.getY() - 1, 80, 25); } }); return button; } /** * »ñÈ¡ÏûÏ¢Îı¾£¬Èç¹û×ÊÔ´ÊøÖÐûÓÐÔòʹÓÃĬÈÏÖµ */ private String getMessage(String key, String defaultValue) { try { return messages.getString(key); } catch (Exception e) { return defaultValue; } } // XY×ø±êת¾­Î³¶È private void convertXYToLonLat() { String xy = xyToLonLatTextField.getText().trim(); if (xy.isEmpty()) { JOptionPane.showMessageDialog(this, getMessage("FIELD_REQUIRED", "´Ë×Ö¶ÎΪ±ØÌîÏî"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } // »ñÈ¡AµãÊý¾Ý String[] pointA = pointATextField.getText().split(",|£¬"); if (pointA.length < 4) { JOptionPane.showMessageDialog(this, String.format(getMessage("INVALID_POINT_FORMAT2", "µãA¸ñʽÎÞЧ"), getMessage("POINT_A", "µãA")), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } // »ñÈ¡BµãÊý¾Ý String[] pointB = pointBTextField.getText().split(",|£¬"); if (pointB.length < 4) { JOptionPane.showMessageDialog(this, String.format(getMessage("INVALID_POINT_FORMAT3", "µãB¸ñʽÎÞЧ"), getMessage("POINT_B", "µãB")), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } try { // ½âÎöÊäÈëÊý¾Ý double latA = Double.parseDouble(pointA[1]); double lonA = Double.parseDouble(pointA[0]); double localXA = Double.parseDouble(pointA[2]); double localYA = Double.parseDouble(pointA[3]); double latB = Double.parseDouble(pointB[1]); double lonB = Double.parseDouble(pointB[0]); double localXB = Double.parseDouble(pointB[2]); double localYB = Double.parseDouble(pointB[3]); // ¼ì²é¾­Î³¶ÈÊÇ·ñΪÁã if (latA == 0 || lonA == 0 || latB == 0 || lonB == 0) { JOptionPane.showMessageDialog(this, String.format(getMessage("ZERO_LATLON", "¾­Î³¶È²»ÄÜΪÁã"), getMessage("POINT_A", "µãA") + "/" + getMessage("POINT_B", "µãB")), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } String[] xyParts = xy.split(",|£¬"); if (xyParts.length < 2) { JOptionPane.showMessageDialog(this, getMessage("XY_TO_LONLAT12", "ÇëÊäÈëX,Y×ø±ê"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } String localX = xyParts[0]; String localY = xyParts[1]; // µ÷ÓÃת»»·½·¨ String[] result = XyToLatLngConverter.convertLocalToGlobalCoordinates( localX, localY, latA, lonA, latB, lonB, localXA, localYA, localXB, localYB ); // ÏÔʾת»»½á¹û£¨Ê®½øÖƾ­Î³¶È£© result1TextField.setText(result[3] + "," + result[2]); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, getMessage("INVALID_NUMBER", "ÎÞЧÊý×Ö¸ñʽ"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); } catch (Exception e) { JOptionPane.showMessageDialog(this, String.format(getMessage("SAVE_FENCE_ERROR", "±£´æÎ§À¸´íÎó: %s"), e.getMessage()), getMessage("ERROR", "´íÎó"), JOptionPane.ERROR_MESSAGE); } } // ¾­Î³¶ÈתXY×ø±ê private void convertLonLatToXY() { String lonlat = lonLatToXYTextField.getText().trim(); if (lonlat.isEmpty()) { JOptionPane.showMessageDialog(this, getMessage("FIELD_REQUIRED", "´Ë×Ö¶ÎΪ±ØÌîÏî"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } try { // ½âÎöµ±Ç°µãµÄ¾­Î³¶È String[] lonLatParts = lonlat.split("[,£¬]"); if (lonLatParts.length < 2) { JOptionPane.showMessageDialog(this, getMessage("INVALID_LONLAT_FORMAT", "¾­Î³¶È¸ñʽÎÞЧ"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } String jd1 = lonLatParts[0].trim(); String wd1 = lonLatParts[1].trim(); // ½âÎöAµãÊý¾Ý String[] pointA = pointATextField.getText().split("[,£¬]"); if (pointA.length < 4) { JOptionPane.showMessageDialog(this, String.format(getMessage("INVALID_POINT_FORMAT", "µã¸ñʽÎÞЧ"), getMessage("POINT_A", "µãA")), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } double latA = Double.parseDouble(pointA[1].trim()); double lonA = Double.parseDouble(pointA[0].trim()); double localXA = Double.parseDouble(pointA[2].trim()); double localYA = Double.parseDouble(pointA[3].trim()); // ½âÎöBµãÊý¾Ý String[] pointB = pointBTextField.getText().split("[,£¬]"); if (pointB.length < 4) { JOptionPane.showMessageDialog(this, String.format(getMessage("INVALID_POINT_FORMAT", "µã¸ñʽÎÞЧ"), getMessage("POINT_B", "µãB")), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } double latB = Double.parseDouble(pointB[1].trim()); double lonB = Double.parseDouble(pointB[0].trim()); double localXB = Double.parseDouble(pointB[2].trim()); double localYB = Double.parseDouble(pointB[3].trim()); // ¼ì²é¾­Î³¶ÈÊÇ·ñΪÁã if (latA == 0 || lonA == 0 || latB == 0 || lonB == 0) { JOptionPane.showMessageDialog(this, String.format(getMessage("ZERO_LATLON", "¾­Î³¶È²»ÄÜΪÁã"), getMessage("POINT_A", "µãA") + "/" + getMessage("POINT_B", "µãB")), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } // µ÷ÓÃת»»·½·¨ int[] xyResult = CoordinateTranslator.gps_xy( new String[]{String.valueOf(lonA), String.valueOf(latA), String.valueOf(localXA), String.valueOf(localYA)}, new String[]{String.valueOf(lonB), String.valueOf(latB), String.valueOf(localXB), String.valueOf(localYB)}, jd1, wd1 ); // ÏÔʾת»»½á¹û (X, Y) result2TextField.setText(xyResult[1] + ", " + xyResult[0]); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, getMessage("INVALID_NUMBER", "ÎÞЧÊý×Ö¸ñʽ"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); } catch (Exception e) { JOptionPane.showMessageDialog(this, String.format(getMessage("CONVERSION_ERROR", "ת»»´íÎó: %s"), e.getMessage()), getMessage("ERROR", "´íÎó"), JOptionPane.ERROR_MESSAGE); } } /** * ¼ÆËãÁ½µã¼ä¾àÀë */ private void calculateDistance() { String point1 = point1RawTextField.getText().trim(); String point2 = point2RawTextField.getText().trim(); if (point1.isEmpty() || point2.isEmpty()) { JOptionPane.showMessageDialog(this, getMessage("FIELD_REQUIRED", "´Ë×Ö¶ÎΪ±ØÌîÏî"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } parseNMEAData(point1, 1); parseNMEAData(point2, 2); try { // ½âÎöNMEAÊý¾Ý»ñÈ¡¾­Î³¶È String[] fields1 = point1.split(","); String[] fields2 = point2.split(","); // È·±£ÓÐ×ã¹»×Ö¶Î (γ¶ÈÔÚË÷Òý2£¬¾­¶ÈÔÚË÷Òý4) if (fields1.length < 6 || fields2.length < 6) { JOptionPane.showMessageDialog(this, getMessage("INVALID_NMEA_FORMAT", "NMEAÊý¾Ý¸ñʽÎÞЧ"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); return; } // ÌáÈ¡µã1µÄ¾­Î³¶È double lat1 = Double.parseDouble(fields1[2]); double lon1 = Double.parseDouble(fields1[4]); // ÌáÈ¡µã2µÄ¾­Î³¶È double lat2 = Double.parseDouble(fields2[2]); double lon2 = Double.parseDouble(fields2[4]); // ʹÓÃCoordinateTranslator¼ÆËã¾àÀë (ÀåÃ×) int distanceCm = CoordinateTranslator.distance2(lon1, lat1, lon2, lat2); // ת»»ÎªÃײ¢±£ÁôÁ½Î»Ð¡Êý double distanceMeters = distanceCm / 100.0; String formattedDistance = String.format(Locale.US, "%.2f %s", distanceMeters, getMessage("METERS", "Ã×")); // ÏÔʾ¼ÆËã½á¹û distanceResultTextField.setText(formattedDistance); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(this, getMessage("INVALID_NUMBER", "ÎÞЧÊý×Ö¸ñʽ"), getMessage("VALIDATION_ERROR", "ÑéÖ¤´íÎó"), JOptionPane.ERROR_MESSAGE); } catch (Exception e) { JOptionPane.showMessageDialog(this, String.format(getMessage("CALCULATION_ERROR", "¼ÆËã´íÎó: %s"), e.getMessage()), getMessage("ERROR", "´íÎó"), JOptionPane.ERROR_MESSAGE); } } /** * ½âÎöNMEAÊý¾Ýµ½±í¸ñ */ private void parseNMEAData(String nmea, int pointIndex) { String[] fields = nmea.split(","); int column = pointIndex; // Ìî³ä±í¸ñÊý¾Ý for (int i = 0; i < Math.min(fields.length, tableModel.getRowCount()); i++) { tableModel.setValueAt(fields[i], i, column); } } }