/*
* Copyright 2005 MH-Software-Entwicklung. All rights reserved.
* Use is subject to license terms.
*/
package com.jtattoo.plaf.custom.pulsar;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.plaf.*;
import com.jtattoo.plaf.*;
import javax.swing.plaf.basic.BasicGraphicsUtils;
/**
* @author Michael Hagen
*/
public class PulsarButtonUI extends BaseButtonUI {
public static ComponentUI createUI(JComponent c) {
return new PulsarButtonUI();
}
protected void paintBackground(Graphics g, AbstractButton b) {
int w = b.getWidth();
int h = b.getHeight();
Graphics2D g2D = (Graphics2D) g;
Shape savedClip = g.getClip();
if ((b.getBorder() != null) && b.isBorderPainted() && (b.getBorder() instanceof UIResource)) {
Area clipArea = new Area(savedClip);
Area rectArea = new Area(new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 6, 6));
rectArea.intersect(clipArea);
g2D.setClip(rectArea);
}
super.paintBackground(g, b);
g2D.setClip(savedClip);
}
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
g.setColor(AbstractLookAndFeel.getFocusColor());
BasicGraphicsUtils.drawDashedRect(g, 3, 2, b.getWidth() - 6, b.getHeight() - 5);
BasicGraphicsUtils.drawDashedRect(g, 4, 3, b.getWidth() - 8, b.getHeight() - 7);
}
}