001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package javax.swing.plaf.multi;
019:
020: import java.awt.Dimension;
021: import java.awt.Graphics;
022: import java.awt.Rectangle;
023: import java.util.Vector;
024:
025: import javax.accessibility.Accessible;
026: import javax.swing.JComponent;
027: import javax.swing.JTabbedPane;
028: import javax.swing.plaf.ComponentUI;
029: import javax.swing.plaf.TabbedPaneUI;
030:
031: /**
032: * All the methods described in public api
033: */
034: public class MultiTabbedPaneUI extends TabbedPaneUI {
035:
036: protected Vector uis = new Vector();
037:
038: /**
039: * Used in cycles. numberOfUIs = Correct number of UIs + 1, but the variable
040: * used in that sence
041: */
042: private int numberOfUIs;
043:
044: public static ComponentUI createUI(JComponent a) {
045: MultiTabbedPaneUI mui = new MultiTabbedPaneUI();
046: ComponentUI result = MultiLookAndFeel
047: .createUIs(mui, mui.uis, a);
048: mui.numberOfUIs = mui.uis.size();
049: return result;
050: }
051:
052: @Override
053: public boolean contains(JComponent a, int b, int c) {
054: for (int i = 1; i < numberOfUIs; i++) {
055: ((ComponentUI) uis.get(i)).contains(a, b, c);
056: }
057: return ((ComponentUI) uis.firstElement()).contains(a, b, c);
058: }
059:
060: @Override
061: public Accessible getAccessibleChild(JComponent a, int b) {
062: for (int i = 1; i < numberOfUIs; i++) {
063: ((ComponentUI) uis.get(i)).getAccessibleChild(a, b);
064: }
065: return ((ComponentUI) uis.firstElement()).getAccessibleChild(a,
066: b);
067: }
068:
069: @Override
070: public int getAccessibleChildrenCount(JComponent a) {
071: for (int i = 1; i < numberOfUIs; i++) {
072: ((ComponentUI) uis.get(i)).getAccessibleChildrenCount(a);
073: }
074: return ((ComponentUI) uis.firstElement())
075: .getAccessibleChildrenCount(a);
076: }
077:
078: @Override
079: public Dimension getMaximumSize(JComponent a) {
080: for (int i = 1; i < numberOfUIs; i++) {
081: ((ComponentUI) uis.get(i)).getMaximumSize(a);
082: }
083: return ((ComponentUI) uis.firstElement()).getMaximumSize(a);
084: }
085:
086: @Override
087: public Dimension getMinimumSize(JComponent a) {
088: for (int i = 1; i < numberOfUIs; i++) {
089: ((ComponentUI) uis.get(i)).getMinimumSize(a);
090: }
091: return ((ComponentUI) uis.firstElement()).getMinimumSize(a);
092: }
093:
094: @Override
095: public Dimension getPreferredSize(JComponent a) {
096: for (int i = 1; i < numberOfUIs; i++) {
097: ((ComponentUI) uis.get(i)).getPreferredSize(a);
098: }
099: return ((ComponentUI) uis.firstElement()).getPreferredSize(a);
100: }
101:
102: public ComponentUI[] getUIs() {
103: return MultiLookAndFeel.uisToArray(uis);
104: }
105:
106: @Override
107: public void installUI(JComponent a) {
108: for (Object ui : uis) {
109: ((ComponentUI) ui).installUI(a);
110: }
111: }
112:
113: @Override
114: public void paint(Graphics a, JComponent b) {
115: for (Object ui : uis) {
116: ((ComponentUI) ui).paint(a, b);
117: }
118: }
119:
120: @Override
121: public void uninstallUI(JComponent a) {
122: for (Object ui : uis) {
123: ((ComponentUI) ui).uninstallUI(a);
124: }
125: }
126:
127: @Override
128: public void update(Graphics a, JComponent b) {
129: for (Object ui : uis) {
130: ((ComponentUI) ui).update(a, b);
131: }
132: }
133:
134: @Override
135: public int tabForCoordinate(JTabbedPane pane, int x, int y) {
136: for (int i = 1; i < numberOfUIs; i++) {
137: ((TabbedPaneUI) uis.get(i)).tabForCoordinate(pane, x, y);
138: }
139: return ((TabbedPaneUI) uis.firstElement()).tabForCoordinate(
140: pane, x, y);
141: }
142:
143: @Override
144: public Rectangle getTabBounds(JTabbedPane pane, int index) {
145: for (int i = 1; i < numberOfUIs; i++) {
146: ((TabbedPaneUI) uis.get(i)).getTabBounds(pane, index);
147: }
148: return ((TabbedPaneUI) uis.firstElement()).getTabBounds(pane,
149: index);
150: }
151:
152: @Override
153: public int getTabRunCount(JTabbedPane pane) {
154: for (int i = 1; i < numberOfUIs; i++) {
155: ((TabbedPaneUI) uis.get(i)).getTabRunCount(pane);
156: }
157: return ((TabbedPaneUI) uis.firstElement()).getTabRunCount(pane);
158: }
159: }
|