01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Alexander T. Simbirtsev
19: * @version $Revision$
20: */package javax.swing.border;
21:
22: import java.awt.Component;
23: import java.awt.Graphics;
24: import java.awt.Insets;
25: import java.awt.Rectangle;
26: import java.io.Serializable;
27:
28: public abstract class AbstractBorder implements Border, Serializable {
29:
30: public Insets getBorderInsets(final Component component,
31: final Insets insets) {
32: if (insets != null) {
33: insets.top = 0;
34: insets.left = 0;
35: insets.right = 0;
36: insets.bottom = 0;
37:
38: return insets;
39: } else {
40: return new Insets(0, 0, 0, 0);
41: }
42: }
43:
44: public Rectangle getInteriorRectangle(final Component c,
45: final int x, final int y, final int width, final int height) {
46: return AbstractBorder.getInteriorRectangle(c, this , x, y,
47: width, height);
48: }
49:
50: public Insets getBorderInsets(final Component component) {
51: return new Insets(0, 0, 0, 0);
52: }
53:
54: public void paintBorder(final Component c, final Graphics g,
55: final int x, final int y, final int width, final int height) {
56: }
57:
58: public boolean isBorderOpaque() {
59: return false;
60: }
61:
62: public static Rectangle getInteriorRectangle(
63: final Component component, final Border border,
64: final int x, final int y, final int width, final int height) {
65: Rectangle result = new Rectangle(x, y, width, height);
66: if (border != null) {
67: Insets insets = border.getBorderInsets(component);
68: result.x += insets.left;
69: result.y += insets.top;
70: result.width -= insets.left + insets.right;
71: result.height -= insets.top + insets.bottom;
72: }
73: return result;
74: }
75: }
|