| | |
| | | private JLabel mowerSpeedValueLabel; |
| | | private JLabel mowerSpeedUnitLabel; |
| | | private JLabel mowingProgressLabel; |
| | | private FixQualityIndicator fixQualityIndicator; |
| | | private gpszhuangtai fixQualityIndicator; |
| | | |
| | | // 导航按钮 |
| | | private JButton homeNavBtn; |
| | |
| | | JPanel rightPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0)); |
| | | rightPanel.setOpaque(false); |
| | | |
| | | fixQualityIndicator = new FixQualityIndicator(); |
| | | fixQualityIndicator = new gpszhuangtai(THEME_COLOR); |
| | | fixQualityIndicator.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
| | | fixQualityIndicator.addMouseListener(new MouseAdapter() { |
| | | @Override |
| | |
| | | return !"未选择地块".equals(trimmed); |
| | | } |
| | | |
| | | private final class FixQualityIndicator extends JComponent { |
| | | private static final long serialVersionUID = 1L; |
| | | private static final int DIAMETER = 16; |
| | | private String currentCode; |
| | | private Color currentColor = new Color(160, 160, 160); |
| | | |
| | | private FixQualityIndicator() { |
| | | setPreferredSize(new Dimension(DIAMETER, DIAMETER)); |
| | | setMinimumSize(new Dimension(DIAMETER, DIAMETER)); |
| | | setMaximumSize(new Dimension(DIAMETER, DIAMETER)); |
| | | setToolTipText("未知"); |
| | | } |
| | | |
| | | private void setQuality(String code) { |
| | | if (Objects.equals(currentCode, code)) { |
| | | return; |
| | | } |
| | | currentCode = code; |
| | | currentColor = resolveFixQualityColor(code); |
| | | setToolTipText(resolveFixQualityDescription(code)); |
| | | repaint(); |
| | | } |
| | | |
| | | @Override |
| | | protected void paintComponent(Graphics g) { |
| | | super.paintComponent(g); |
| | | Graphics2D g2 = (Graphics2D) g.create(); |
| | | try { |
| | | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
| | | int diameter = Math.min(getWidth(), getHeight()) - 2; |
| | | int x = (getWidth() - diameter) / 2; |
| | | int y = (getHeight() - diameter) / 2; |
| | | g2.setColor(currentColor); |
| | | g2.fillOval(x, y, diameter, diameter); |
| | | g2.setColor(new Color(255, 255, 255, 128)); |
| | | g2.drawOval(x, y, diameter, diameter); |
| | | } finally { |
| | | g2.dispose(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 测试方法 |
| | | public static void main(String[] args) { |