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.plaf;
21:
22: import java.awt.Dimension;
23: import java.awt.Graphics;
24:
25: import javax.accessibility.Accessible;
26: import javax.accessibility.AccessibleContext;
27: import javax.swing.JComponent;
28:
29: import org.apache.harmony.x.swing.internal.nls.Messages;
30:
31: public abstract class ComponentUI {
32: public void update(final Graphics graphics,
33: final JComponent component) {
34: if (component.isOpaque()) {
35: graphics.setColor(component.getBackground());
36: graphics.fillRect(0, 0, component.getWidth(), component
37: .getHeight());
38: }
39: paint(graphics, component);
40: }
41:
42: public void paint(final Graphics graphics,
43: final JComponent component) {
44: }
45:
46: public Accessible getAccessibleChild(final JComponent component,
47: final int childIndex) {
48: AccessibleContext context = component.getAccessibleContext();
49: return (context != null) ? context
50: .getAccessibleChild(childIndex) : null;
51: }
52:
53: public Dimension getPreferredSize(final JComponent component) {
54: return null;
55: }
56:
57: public Dimension getMinimumSize(final JComponent component) {
58: return getPreferredSize(component);
59: }
60:
61: public Dimension getMaximumSize(final JComponent component) {
62: return getPreferredSize(component);
63: }
64:
65: public boolean contains(final JComponent component, final int x,
66: final int y) {
67: return ((0 <= x && x < component.getWidth()) && (0 <= y && y < component
68: .getHeight()));
69: }
70:
71: public void uninstallUI(final JComponent component) {
72: }
73:
74: public void installUI(final JComponent component) {
75: }
76:
77: public int getAccessibleChildrenCount(final JComponent component) {
78: AccessibleContext accessibleContext = component
79: .getAccessibleContext();
80: return (accessibleContext != null) ? accessibleContext
81: .getAccessibleChildrenCount() : 0;
82: }
83:
84: public static ComponentUI createUI(final JComponent component) {
85: throw new Error(Messages.getString(
86: "swing.err.0C", "ComponentUI.createUI")); //$NON-NLS-1$ //$NON-NLS-2$
87: }
88: }
|