001/*
002 * $Id: BasicBusyLabelUI.java 3927 2011-02-22 16:34:11Z 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.basic;
022import java.awt.Color;
023import java.awt.Dimension;
024import java.awt.Shape;
025
026import javax.swing.JComponent;
027import javax.swing.UIManager;
028import javax.swing.plaf.ComponentUI;
029import javax.swing.plaf.basic.BasicLabelUI;
030
031import org.jdesktop.swingx.JXBusyLabel;
032import org.jdesktop.swingx.painter.BusyPainter;
033import org.jdesktop.swingx.plaf.BusyLabelUI;
034import org.jdesktop.swingx.plaf.UIManagerExt;
035
036/**
037 * Base implementation of the <code>JXBusyLabel</code> UI.
038 *
039 * @author rah003
040 */
041public class BasicBusyLabelUI extends BasicLabelUI implements BusyLabelUI {
042    
043    /** Creates a new instance of BasicBusyLabelUI */
044    public BasicBusyLabelUI(JXBusyLabel lbl) {
045    }
046    
047  public static ComponentUI createUI(JComponent c) {
048    return new BasicBusyLabelUI((JXBusyLabel)c);
049  }
050
051    @Override
052    public BusyPainter getBusyPainter(final Dimension dim) {
053        BusyPainter p = new BusyPainter() {
054            @Override
055            protected void init(Shape point, Shape trajectory, Color b, Color h) {
056                super.init(dim == null ? UIManagerExt.getShape("JXBusyLabel.pointShape") : getScaledDefaultPoint(dim.height), 
057                        dim == null ? UIManagerExt.getShape("JXBusyLabel.trajectoryShape") : getScaledDefaultTrajectory(dim.height),
058                        UIManagerExt.getSafeColor("JXBusyLabel.baseColor", Color.LIGHT_GRAY),
059                        UIManagerExt.getSafeColor("JXBusyLabel.highlightColor", Color.BLACK));
060            }
061        };
062        return p;
063    }
064
065    @Override
066    public int getDelay() {
067        return UIManager.getInt("JXBusyLabel.delay");
068    }
069
070
071}