/* * Copyright 2005 MH-Software-Entwicklung. All rights reserved. * Use is subject to license terms. */ package com.jtattoo.plaf.graphite; 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 GraphiteButtonUI extends BaseButtonUI { public static ComponentUI createUI(JComponent c) { return new GraphiteButtonUI(); } 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) { if (!AbstractLookAndFeel.getTheme().doShowFocusFrame()) { 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); } } }