001/*
002 * $Id: MetalTaskPaneUI.java 3448 2009-08-19 08:12:23Z kleopatra $
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 */
021package org.jdesktop.swingx.plaf.metal;
022
023import java.awt.Graphics;
024import java.awt.Graphics2D;
025import java.awt.RenderingHints;
026
027import javax.swing.JComponent;
028import javax.swing.LookAndFeel;
029import javax.swing.border.Border;
030import javax.swing.plaf.ComponentUI;
031
032import org.jdesktop.swingx.JXTaskPane;
033import org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI;
034
035/**
036 * Metal implementation of the <code>JXTaskPane</code> UI. <br>
037 * 
038 * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
039 */
040public class MetalTaskPaneUI extends BasicTaskPaneUI {
041
042  public static ComponentUI createUI(JComponent c) {
043    return new MetalTaskPaneUI();
044  }
045
046  @Override
047  protected void installDefaults() {
048    super.installDefaults();
049    
050    LookAndFeel.installProperty(group, "opaque", false);
051  }
052
053  @Override
054  protected Border createPaneBorder() {
055    return new MetalPaneBorder();
056  }
057
058  /**
059   * The border of the task pane group paints the "text", the "icon",
060   * the "expanded" status and the "special" type.
061   *  
062   */
063  class MetalPaneBorder extends PaneBorder {
064
065    @Override
066    protected void paintExpandedControls(JXTaskPane group, Graphics g, int x,
067      int y, int width, int height) {
068      ((Graphics2D)g).setRenderingHint(
069        RenderingHints.KEY_ANTIALIASING,
070        RenderingHints.VALUE_ANTIALIAS_ON);
071      
072      g.setColor(getPaintColor(group));
073      paintRectAroundControls(group, g, x, y, width, height, g.getColor(), g
074        .getColor());
075      paintChevronControls(group, g, x, y, width, height);
076      
077      ((Graphics2D)g).setRenderingHint(
078        RenderingHints.KEY_ANTIALIASING,
079        RenderingHints.VALUE_ANTIALIAS_OFF);      
080    }
081
082    @Override
083    protected boolean isMouseOverBorder() {
084      return true;
085    }    
086  }
087
088}