|
|
@@ -16,15 +16,17 @@ import java.io.File;
|
|
|
public class CoordinateAdjustTool extends JFrame {
|
|
|
|
|
|
// 当前坐标(初始值从 FlowCardRenderer 获取)
|
|
|
- private float qrX = 194.5f;
|
|
|
- private float qrY = 65.4f - 4.0f; // 当前已上移4pt
|
|
|
+ private float qrX = 194.1f;
|
|
|
+ private float qrY = 63.3f;
|
|
|
private float qrW = 35.7f;
|
|
|
private float qrH = 34.6f;
|
|
|
|
|
|
+ private float prodTextX = 291.5f;
|
|
|
+ private float prodTextY = 66.0f;
|
|
|
private float steelTextX = 291.5f;
|
|
|
- private float steelTextY = 85.5f - 4.0f; // 当前已上移4pt
|
|
|
- private float snTextX = 291.5f;
|
|
|
- private float snTextY = 96.4f - 4.0f; // 当前已上移4pt
|
|
|
+ private float steelTextY = 77.5f;
|
|
|
+ private float snTextX = 286.7f;
|
|
|
+ private float snTextY = 89.4f;
|
|
|
|
|
|
private JLabel previewLabel;
|
|
|
private FlowCardData testData;
|
|
|
@@ -138,6 +140,48 @@ public class CoordinateAdjustTool extends JFrame {
|
|
|
}));
|
|
|
controlPanel.add(Box.createVerticalStrut(20));
|
|
|
|
|
|
+ // 项目号坐标控制
|
|
|
+ controlPanel.add(createLabel("=== 项目号位置 ==="));
|
|
|
+ JTextField prodXField = new JTextField(String.format("%.1f", prodTextX), 8);
|
|
|
+ JTextField prodYField = new JTextField(String.format("%.1f", prodTextY), 8);
|
|
|
+
|
|
|
+ JPanel prodXPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
+ prodXPanel.add(new JLabel("X:"));
|
|
|
+ prodXPanel.add(prodXField);
|
|
|
+ prodXField.addActionListener(e -> {
|
|
|
+ try {
|
|
|
+ prodTextX = Float.parseFloat(prodXField.getText());
|
|
|
+ updatePreview();
|
|
|
+ } catch (NumberFormatException ex) {
|
|
|
+ prodXField.setText(String.format("%.1f", prodTextX));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ controlPanel.add(prodXPanel);
|
|
|
+ controlPanel.add(createSlider("X坐标", prodTextX, 200f, 400f, v -> {
|
|
|
+ prodTextX = v;
|
|
|
+ prodXField.setText(String.format("%.1f", v));
|
|
|
+ updatePreview();
|
|
|
+ }));
|
|
|
+
|
|
|
+ JPanel prodYPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
|
+ prodYPanel.add(new JLabel("Y:"));
|
|
|
+ prodYPanel.add(prodYField);
|
|
|
+ prodYField.addActionListener(e -> {
|
|
|
+ try {
|
|
|
+ prodTextY = Float.parseFloat(prodYField.getText());
|
|
|
+ updatePreview();
|
|
|
+ } catch (NumberFormatException ex) {
|
|
|
+ prodYField.setText(String.format("%.1f", prodTextY));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ controlPanel.add(prodYPanel);
|
|
|
+ controlPanel.add(createSlider("Y坐标", prodTextY, 50f, 150f, v -> {
|
|
|
+ prodTextY = v;
|
|
|
+ prodYField.setText(String.format("%.1f", v));
|
|
|
+ updatePreview();
|
|
|
+ }));
|
|
|
+ controlPanel.add(Box.createVerticalStrut(20));
|
|
|
+
|
|
|
// 钢印码坐标控制 - 改为输入框+滑动条
|
|
|
controlPanel.add(createLabel("=== 钢印码位置 ==="));
|
|
|
JTextField steelXField = new JTextField(String.format("%.1f", steelTextX), 8);
|
|
|
@@ -393,6 +437,14 @@ public class CoordinateAdjustTool extends JFrame {
|
|
|
g2.setColor(Color.BLACK);
|
|
|
g2.setFont(new Font("SimSun", Font.BOLD, (int)(8 * scale)));
|
|
|
|
|
|
+ // 绘制项目号文字
|
|
|
+ int imgProdX = (int)(prodTextX * scale);
|
|
|
+ int imgProdY = (int)(prodTextY * scale);
|
|
|
+ String prodCode = testData.getProdCode();
|
|
|
+ if (prodCode != null && !prodCode.isEmpty()) {
|
|
|
+ g2.drawString(prodCode, imgProdX, imgProdY);
|
|
|
+ }
|
|
|
+
|
|
|
// 绘制钢印码文字
|
|
|
int imgSteelX = (int)(steelTextX * scale);
|
|
|
int imgSteelY = (int)(steelTextY * scale);
|
|
|
@@ -407,6 +459,12 @@ public class CoordinateAdjustTool extends JFrame {
|
|
|
g2.drawString(testData.getSn(), imgSnX, imgSnY);
|
|
|
}
|
|
|
|
|
|
+ // 绘制辅助标记(蓝色十字标记项目号位置)
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
+ g2.setStroke(new BasicStroke(2));
|
|
|
+ g2.drawLine(imgProdX - 20, imgProdY, imgProdX + 20, imgProdY);
|
|
|
+ g2.drawLine(imgProdX, imgProdY - 20, imgProdX, imgProdY + 20);
|
|
|
+
|
|
|
// 绘制辅助标记(红色十字标记钢印码位置)
|
|
|
g2.setColor(Color.RED);
|
|
|
g2.setStroke(new BasicStroke(2));
|
|
|
@@ -423,8 +481,9 @@ public class CoordinateAdjustTool extends JFrame {
|
|
|
g2.setColor(Color.BLACK);
|
|
|
g2.setFont(new Font("Consolas", Font.BOLD, 24));
|
|
|
g2.drawString(String.format("QR: (%.1f, %.1f)", qrX, qrY), 20, 50);
|
|
|
- g2.drawString(String.format("钢印: (%.1f, %.1f)", steelTextX, steelTextY), 20, 90);
|
|
|
- g2.drawString(String.format("客户: (%.1f, %.1f)", snTextX, snTextY), 20, 130);
|
|
|
+ g2.drawString(String.format("项目号: (%.1f, %.1f) = %s", prodTextX, prodTextY, prodCode != null ? prodCode : ""), 20, 90);
|
|
|
+ g2.drawString(String.format("钢印: (%.1f, %.1f)", steelTextX, steelTextY), 20, 130);
|
|
|
+ g2.drawString(String.format("客户: (%.1f, %.1f)", snTextX, snTextY), 20, 170);
|
|
|
|
|
|
g2.dispose();
|
|
|
return img;
|
|
|
@@ -437,12 +496,14 @@ public class CoordinateAdjustTool extends JFrame {
|
|
|
"private static final float QR_Y = %.1ff;\n" +
|
|
|
"private static final float QR_W = %.1ff;\n" +
|
|
|
"private static final float QR_H = %.1ff;\n\n" +
|
|
|
+ "private static final float PROD_TEXT_X = %.1ff;\n" +
|
|
|
+ "private static final float PROD_TEXT_Y = %.1ff;\n" +
|
|
|
"private static final float STEEL_TEXT_X = %.1ff;\n" +
|
|
|
"private static final float STEEL_TEXT_Y = %.1ff;\n" +
|
|
|
"private static final float SN_TEXT_X = %.1ff;\n" +
|
|
|
"private static final float SN_TEXT_Y = %.1ff;\n",
|
|
|
qrX, qrY, qrW, qrH,
|
|
|
- steelTextX, steelTextY, snTextX, snTextY
|
|
|
+ prodTextX, prodTextY, steelTextX, steelTextY, snTextX, snTextY
|
|
|
);
|
|
|
|
|
|
JTextArea textArea = new JTextArea(code, 12, 50);
|