From ff6238a50f9d5717b2c789126a71232bcdb93b91 Mon Sep 17 00:00:00 2001 From: author Date: Thu, 22 Aug 2019 18:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8Csonar?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/icheckbox/UICheckBox.java | 100 +++++++++--------- .../fr/design/gui/icheckbox/UICheckBoxUI.java | 2 +- .../fr/design/gui/icombobox/LazyComboBox.java | 1 + .../gui/icombobox/LazyComboBoxTest.java | 1 + 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index 7489b4f59..10ea06a8c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -125,60 +125,58 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser private class UICheckBoxUI extends MetalCheckBoxUI { @Override - public void paint(Graphics g, JComponent c) { - synchronized (this) { - AbstractButton b = (AbstractButton) c; - ButtonModel model = b.getModel(); - Dimension size = c.getSize(); - Font f = c.getFont(); - g.setFont(f); - FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); - - Rectangle viewRect = new Rectangle(size); - Rectangle iconRect = new Rectangle(); - Rectangle textRect = new Rectangle(); - - Insets i = c.getInsets(); - viewRect.x += i.left; - viewRect.y += i.top; - viewRect.width -= (i.right + viewRect.x); - viewRect.height -= (i.bottom + viewRect.y); - - Icon altIcon = b.getIcon(); - - String text = SwingUtilities.layoutCompoundLabel( - c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), - b.getVerticalAlignment(), b.getHorizontalAlignment(), - b.getVerticalTextPosition(), b.getHorizontalTextPosition(), - viewRect, iconRect, textRect, b.getIconTextGap()); - - // fill background - if (c.isOpaque()) { - g.setColor(b.getBackground()); - g.fillRect(0, 0, size.width, size.height); - } - - Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - if (model.isSelected()) { - GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height, false, Constants.NULL, - model.isEnabled() ? UIConstants.CHECKBOX_HOVER_SELECTED : UIConstants.DISABLED_ICON_COLOR, 0); - } else if (model.isRollover() && !model.isSelected()) { - g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED); - g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); - } else { - g.setColor(UIConstants.LINE_COLOR); - g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); - } + public synchronized void paint(Graphics g, JComponent c) { + AbstractButton b = (AbstractButton) c; + ButtonModel model = b.getModel(); + Dimension size = c.getSize(); + Font f = c.getFont(); + g.setFont(f); + FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); + + Rectangle viewRect = new Rectangle(size); + Rectangle iconRect = new Rectangle(); + Rectangle textRect = new Rectangle(); + + Insets i = c.getInsets(); + viewRect.x += i.left; + viewRect.y += i.top; + viewRect.width -= (i.right + viewRect.x); + viewRect.height -= (i.bottom + viewRect.y); + + Icon altIcon = b.getIcon(); + + String text = SwingUtilities.layoutCompoundLabel( + c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), + b.getVerticalAlignment(), b.getHorizontalAlignment(), + b.getVerticalTextPosition(), b.getHorizontalTextPosition(), + viewRect, iconRect, textRect, b.getIconTextGap()); + + // fill background + if (c.isOpaque()) { + g.setColor(b.getBackground()); + g.fillRect(0, 0, size.width, size.height); + } - if (model.isSelected()) { - UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); - } - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + if (model.isSelected()) { + GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height, false, Constants.NULL, + model.isEnabled() ? UIConstants.CHECKBOX_HOVER_SELECTED : UIConstants.DISABLED_ICON_COLOR, 0); + } else if (model.isRollover() && !model.isSelected()) { + g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED); + g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); + } else { + g.setColor(UIConstants.LINE_COLOR); + g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); + } - // Draw the Text - drawLine(text, g, b, c, textRect, fm); + if (model.isSelected()) { + UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); } + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + + // Draw the Text + drawLine(text, g, b, c, textRect, fm); } private void drawLine(String text, Graphics g, AbstractButton b, JComponent c, Rectangle textRect, FontMetrics fm) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java index 1a7bbb661..9076d355d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java @@ -64,7 +64,7 @@ public class UICheckBoxUI extends MetalCheckBoxUI { } } - static BasicStroke focusStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[]{1.0f / 1.0f}, 1.0f); + static BasicStroke focusStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[]{1.0f}, 1.0f); protected void paintFocus(Graphics g, Rectangle t, Dimension arg2) { if (!ThemeUtils.BUTTON_FOCUS) { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java index be83cf5b1..300790457 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java @@ -84,6 +84,7 @@ public abstract class LazyComboBox extends UIComboBox implements PopupMenuListen LazyComboBox.this.loadList(get()); } catch (InterruptedException | ExecutionException exception) { FineLoggerFactory.getLogger().debug(exception.getMessage()); + Thread.currentThread().interrupt(); } LazyComboBox.this.showPopup(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java index 4016a263c..37e9db154 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java @@ -40,6 +40,7 @@ public class LazyComboBoxTest { Thread.sleep(3000); } catch (InterruptedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + Thread.currentThread().interrupt(); } return m; }