|
|
@ -125,60 +125,58 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser |
|
|
|
|
|
|
|
|
|
|
|
private class UICheckBoxUI extends MetalCheckBoxUI { |
|
|
|
private class UICheckBoxUI extends MetalCheckBoxUI { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
public synchronized void paint(Graphics g, JComponent c) { |
|
|
|
synchronized (this) { |
|
|
|
AbstractButton b = (AbstractButton) c; |
|
|
|
AbstractButton b = (AbstractButton) c; |
|
|
|
ButtonModel model = b.getModel(); |
|
|
|
ButtonModel model = b.getModel(); |
|
|
|
Dimension size = c.getSize(); |
|
|
|
Dimension size = c.getSize(); |
|
|
|
Font f = c.getFont(); |
|
|
|
Font f = c.getFont(); |
|
|
|
g.setFont(f); |
|
|
|
g.setFont(f); |
|
|
|
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); |
|
|
|
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); |
|
|
|
|
|
|
|
|
|
|
|
Rectangle viewRect = new Rectangle(size); |
|
|
|
Rectangle viewRect = new Rectangle(size); |
|
|
|
Rectangle iconRect = new Rectangle(); |
|
|
|
Rectangle iconRect = new Rectangle(); |
|
|
|
Rectangle textRect = new Rectangle(); |
|
|
|
Rectangle textRect = new Rectangle(); |
|
|
|
|
|
|
|
|
|
|
|
Insets i = c.getInsets(); |
|
|
|
Insets i = c.getInsets(); |
|
|
|
viewRect.x += i.left; |
|
|
|
viewRect.x += i.left; |
|
|
|
viewRect.y += i.top; |
|
|
|
viewRect.y += i.top; |
|
|
|
viewRect.width -= (i.right + viewRect.x); |
|
|
|
viewRect.width -= (i.right + viewRect.x); |
|
|
|
viewRect.height -= (i.bottom + viewRect.y); |
|
|
|
viewRect.height -= (i.bottom + viewRect.y); |
|
|
|
|
|
|
|
|
|
|
|
Icon altIcon = b.getIcon(); |
|
|
|
Icon altIcon = b.getIcon(); |
|
|
|
|
|
|
|
|
|
|
|
String text = SwingUtilities.layoutCompoundLabel( |
|
|
|
String text = SwingUtilities.layoutCompoundLabel( |
|
|
|
c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), |
|
|
|
c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), |
|
|
|
b.getVerticalAlignment(), b.getHorizontalAlignment(), |
|
|
|
b.getVerticalAlignment(), b.getHorizontalAlignment(), |
|
|
|
b.getVerticalTextPosition(), b.getHorizontalTextPosition(), |
|
|
|
b.getVerticalTextPosition(), b.getHorizontalTextPosition(), |
|
|
|
viewRect, iconRect, textRect, b.getIconTextGap()); |
|
|
|
viewRect, iconRect, textRect, b.getIconTextGap()); |
|
|
|
|
|
|
|
|
|
|
|
// fill background
|
|
|
|
// fill background
|
|
|
|
if (c.isOpaque()) { |
|
|
|
if (c.isOpaque()) { |
|
|
|
g.setColor(b.getBackground()); |
|
|
|
g.setColor(b.getBackground()); |
|
|
|
g.fillRect(0, 0, size.width, size.height); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.isSelected()) { |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); |
|
|
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
|
|
|
} |
|
|
|
if (model.isSelected()) { |
|
|
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); |
|
|
|
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
|
|
|
|
if (model.isSelected()) { |
|
|
|
drawLine(text, g, b, c, textRect, fm); |
|
|
|
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) { |
|
|
|
private void drawLine(String text, Graphics g, AbstractButton b, JComponent c, Rectangle textRect, FontMetrics fm) { |
|
|
|