001    /*
002     * $Id: MetalTaskPaneUI.java,v 1.5 2005/10/10 18:03:11 rbair Exp $
003     *
004     * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005     * Santa Clara, California 95054, U.S.A. All rights reserved.
006     *
007     * This library is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU Lesser General Public
009     * License as published by the Free Software Foundation; either
010     * version 2.1 of the License, or (at your option) any later version.
011     * 
012     * This library is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015     * Lesser General Public License for more details.
016     * 
017     * You should have received a copy of the GNU Lesser General Public
018     * License along with this library; if not, write to the Free Software
019     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020     */
021    package org.jdesktop.swingx.plaf.metal;
022    
023    import java.awt.Graphics;
024    import java.awt.Graphics2D;
025    import java.awt.RenderingHints;
026    
027    import javax.swing.JComponent;
028    import javax.swing.border.Border;
029    import javax.swing.plaf.ComponentUI;
030    
031    import org.jdesktop.swingx.JXTaskPane;
032    import org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI;
033    
034    /**
035     * Metal implementation of the <code>JXTaskPane</code> UI. <br>
036     * 
037     * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
038     */
039    public class MetalTaskPaneUI extends BasicTaskPaneUI {
040    
041      public static ComponentUI createUI(JComponent c) {
042        return new MetalTaskPaneUI();
043      }
044    
045      protected void installDefaults() {
046        super.installDefaults();
047        group.setOpaque(false);
048      }
049    
050      protected Border createPaneBorder() {
051        return new MetalPaneBorder();
052      }
053    
054      /**
055       * The border of the taskpane group paints the "text", the "icon",
056       * the "expanded" status and the "special" type.
057       *  
058       */
059      class MetalPaneBorder extends PaneBorder {
060    
061        protected void paintExpandedControls(JXTaskPane group, Graphics g, int x,
062          int y, int width, int height) {
063          ((Graphics2D)g).setRenderingHint(
064            RenderingHints.KEY_ANTIALIASING,
065            RenderingHints.VALUE_ANTIALIAS_ON);
066          
067          g.setColor(getPaintColor(group));
068          paintRectAroundControls(group, g, x, y, width, height, g.getColor(), g
069            .getColor());
070          paintChevronControls(group, g, x, y, width, height);
071          
072          ((Graphics2D)g).setRenderingHint(
073            RenderingHints.KEY_ANTIALIASING,
074            RenderingHints.VALUE_ANTIALIAS_OFF);      
075        }
076    
077        @Override
078        protected boolean isMouseOverBorder() {
079          return true;
080        }    
081      }
082    
083    }