4
* Copyright 2009 Sun Microsystems, Inc., 4150 Network Circle,
5
* Santa Clara, California 95054, U.S.A. All rights reserved.
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.
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.
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
22
package org.jdesktop.swingx.plaf.synth;
25
* @(#)SynthBorder.java 1.15 06/11/30
27
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
28
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
31
import java.awt.Component;
32
import java.awt.Graphics;
33
import java.awt.Insets;
35
import javax.swing.JComponent;
36
import javax.swing.border.AbstractBorder;
37
import javax.swing.plaf.UIResource;
38
import javax.swing.plaf.synth.SynthContext;
39
import javax.swing.plaf.synth.SynthStyle;
42
* SynthBorder is a border that delegates to a Painter. The Insets
43
* are determined at construction time.<p>
47
* @version 1.15, 11/30/06
48
* @author Scott Violet
50
class SynthBorder extends AbstractBorder implements UIResource {
52
private Insets insets;
54
SynthBorder(SynthUI ui, Insets insets) {
59
SynthBorder(SynthUI ui) {
64
public void paintBorder(Component c, Graphics g, int x, int y,
65
int width, int height) {
66
JComponent jc = (JComponent)c;
67
SynthContext context = ui.getContext(jc);
68
SynthStyle style = context.getStyle();
70
assert false: "SynthBorder is being used outside after the UI " +
71
"has been uninstalled";
74
ui.paintBorder(context, g, x, y, width, height);
78
* This default implementation returns a new <code>Insets</code>
79
* instance where the <code>top</code>, <code>left</code>,
80
* <code>bottom</code>, and
81
* <code>right</code> fields are set to <code>0</code>.
82
* @param c the component for which this border insets value applies
83
* @return the new <code>Insets</code> object initialized to 0
86
public Insets getBorderInsets(Component c) {
87
return getBorderInsets(c, null);
91
* Reinitializes the insets parameter with this Border's current Insets.
92
* @param c the component for which this border insets value applies
93
* @param insets the object to be reinitialized
94
* @return the <code>insets</code> object
97
public Insets getBorderInsets(Component c, Insets insets) {
98
if (this.insets != null) {
100
insets = new Insets(this.insets.top, this.insets.left,
101
this.insets.bottom, this.insets.right);
104
insets.top = this.insets.top;
105
insets.bottom = this.insets.bottom;
106
insets.left = this.insets.left;
107
insets.right = this.insets.right;
110
else if (insets == null) {
111
insets = new Insets(0, 0, 0, 0);
114
insets.top = insets.bottom = insets.left = insets.right = 0;
120
* This default implementation returns false.
124
public boolean isBorderOpaque() {