2 Copyright (C) 2003 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.swing
.border
;
41 import java
.awt
.Component
;
42 import java
.awt
.Graphics
;
43 import java
.awt
.Insets
;
47 * A border for leaving a specifiable number of pixels empty around
48 * the enclosed component. An EmptyBorder requires some space on each
49 * edge, but does not perform any drawing.
51 * <p><img src="EmptyBorder-1.png" width="290" height="200"
52 * alt="[An illustration of EmptyBorder]" />
54 * @author Sascha Brawer (brawer@dandelis.ch)
56 public class EmptyBorder
extends AbstractBorder
59 * Determined using the <code>serialver</code> tool
60 * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
62 static final long serialVersionUID
= -8116076291731988694L;
66 * The number of pixels required at the left edge.
72 * The number of pixels required at the right edge.
78 * The number of pixels required at the top edge.
84 * The number of pixels required at the bottom edge.
90 * Constructs an empty border given the number of pixels required
93 * @param top the number of pixels that the border will need
96 * @param left the number of pixels that the border will need
99 * @param bottom the number of pixels that the border will need
100 * for its bottom edge.
102 * @param right the number of pixels that the border will need
103 * for its right edge.
105 public EmptyBorder(int top
, int left
, int bottom
, int right
)
109 this.bottom
= bottom
;
115 * Constructs an empty border given the number of pixels required
116 * on each side, passed in an Insets object.
118 * @param borderInsets the Insets for the new border.
120 public EmptyBorder(Insets borderInsets
)
122 this(borderInsets
.top
, borderInsets
.left
,
123 borderInsets
.bottom
, borderInsets
.right
);
128 * Performs nothing because an EmptyBorder does not paint any
129 * pixels. While the inherited implementation provided by
130 * {@link AbstractBorder#paintBorder} is a no-op as well,
131 * it is overwritten in order to match the API of the Sun
132 * reference implementation.
134 * @param c the component whose border is to be painted.
135 * @param g the graphics for painting.
136 * @param x the horizontal position for painting the border.
137 * @param y the vertical position for painting the border.
138 * @param width the width of the available area for painting the border.
139 * @param height the height of the available area for painting the border.
141 public void paintBorder(Component c
, Graphics g
,
142 int x
, int y
, int width
, int height
)
144 // Nothing to do here.
149 * Measures the width of this border.
151 * @param c the component whose border is to be measured.
153 * @return an Insets object whose <code>left</code>, <code>right</code>,
154 * <code>top</code> and <code>bottom</code> fields indicate the
155 * width of the border at the respective edge.
157 * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
159 public Insets
getBorderInsets(Component c
)
161 return getBorderInsets(c
, null);
166 * Measures the width of this border, storing the results into a
167 * pre-existing Insets object.
169 * @param insets an Insets object for holding the result values.
170 * After invoking this method, the <code>left</code>,
171 * <code>right</code>, <code>top</code> and
172 * <code>bottom</code> fields indicate the width of the
173 * border at the respective edge.
175 * @return the same object that was passed for <code>insets</code>.
177 * @see #getBorderInsets()
179 public Insets
getBorderInsets(Component c
, Insets insets
)
182 insets
= new Insets(0, 0, 0, 0);
185 insets
.right
= right
;
187 insets
.bottom
= bottom
;
193 * Measures the width of this border.
195 * @return an Insets object whose <code>left</code>, <code>right</code>,
196 * <code>top</code> and <code>bottom</code> fields indicate the
197 * width of the border at the respective edge.
199 * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
201 public Insets
getBorderInsets()
203 return getBorderInsets(null, null);
208 * Determines whether this border fills every pixel in its area
209 * when painting. Since an empty border does not paint any pixels
210 * whatsoever, the result is <code>false</code>.
212 * @return <code>false</code>.
214 public boolean isBorderOpaque()
216 /* The inherited implementation of AbstractBorder.isBorderOpaque()
217 * would also return false. It is not clear why this is overriden
218 * in the Sun implementation, at least not from just reading the