~ubuntu-branches/ubuntu/trusty/libswingx-java/trusty

« back to all changes in this revision

Viewing changes to src/java/org/jdesktop/swingx/plaf/windows/WindowsClassicStatusBarUI.java

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2008-03-08 16:18:24 UTC
  • Revision ID: james.westby@ubuntu.com-20080308161824-wsahvl9pwzjcea3g
Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: WindowsClassicStatusBarUI.java,v 1.6 2007/09/17 16:39:39 rbair Exp $
 
3
 *
 
4
 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
 
5
 * Santa Clara, California 95054, U.S.A. All rights reserved.
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2.1 of the License, or (at your option) any later version.
 
11
 * 
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 * 
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 */
 
21
 
 
22
package org.jdesktop.swingx.plaf.windows;
 
23
 
 
24
import java.awt.Color;
 
25
import java.awt.Component;
 
26
import java.awt.Graphics2D;
 
27
import java.awt.Insets;
 
28
import javax.swing.BorderFactory;
 
29
import javax.swing.JComponent;
 
30
import javax.swing.border.BevelBorder;
 
31
import javax.swing.border.Border;
 
32
import javax.swing.plaf.ComponentUI;
 
33
import javax.swing.plaf.BorderUIResource;
 
34
import org.jdesktop.swingx.JXStatusBar;
 
35
import org.jdesktop.swingx.plaf.basic.BasicStatusBarUI;
 
36
 
 
37
/**
 
38
 *
 
39
 * @author rbair
 
40
 */
 
41
public class WindowsClassicStatusBarUI extends BasicStatusBarUI {
 
42
    /** Creates a new instance of BasicStatusBarUI */
 
43
    public WindowsClassicStatusBarUI() {
 
44
    }
 
45
    
 
46
    /**
 
47
     * Returns an instance of the UI delegate for the specified component.
 
48
     * Each subclass must provide its own static <code>createUI</code>
 
49
     * method that returns an instance of that UI delegate subclass.
 
50
     * If the UI delegate subclass is stateless, it may return an instance
 
51
     * that is shared by multiple components.  If the UI delegate is
 
52
     * stateful, then it should return a new instance per component.
 
53
     * The default implementation of this method throws an error, as it
 
54
     * should never be invoked.
 
55
     */
 
56
    public static ComponentUI createUI(JComponent c) {
 
57
        return new WindowsClassicStatusBarUI();
 
58
    }
 
59
    
 
60
    @Override protected void paintBackground(Graphics2D g, JXStatusBar bar) {        
 
61
        g.setColor(bar.getBackground());
 
62
        g.fillRect(0, 0, bar.getWidth(), bar.getHeight());
 
63
        
 
64
        //paint an inset border around each component. This suggests that
 
65
        //there is an extra border around the status bar...!
 
66
        Border b = BorderFactory.createBevelBorder(BevelBorder.LOWERED, 
 
67
                Color.WHITE, bar.getBackground(), bar.getBackground(), Color.GRAY);
 
68
        Insets insets = new Insets(0, 0, 0, 0);
 
69
        for (Component c : bar.getComponents()) {
 
70
            getSeparatorInsets(insets);
 
71
            int x = c.getX() - insets.right;
 
72
            int y = c.getY() - 2;
 
73
            int w = c.getWidth() + insets.left + insets.right;
 
74
            int h = c.getHeight() + 4;
 
75
            b.paintBorder(c, g, x, y, w, h);
 
76
        }
 
77
    }
 
78
    
 
79
    @Override protected void paintSeparator(Graphics2D g, JXStatusBar bar, int x, int y, int w, int h) {
 
80
        //paint nothing, since paintBackground handles this
 
81
    }
 
82
 
 
83
    @Override protected int getSeparatorWidth() {
 
84
        return 11;
 
85
    }
 
86
 
 
87
    @Override protected BorderUIResource createBorder() {
 
88
        return new BorderUIResource(BorderFactory.createEmptyBorder(4, 5, 3, 22));
 
89
    }
 
90
}