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.util.Vector;
023:
024: import javax.accessibility.Accessible;
025: import javax.swing.JComponent;
026: import javax.swing.plaf.ColorChooserUI;
027: import javax.swing.plaf.ComponentUI;
028:
029: /**
030: * All the methods described in public api
031: */
032: public class MultiColorChooserUI extends ColorChooserUI {
033:
034: protected Vector uis = new Vector();
035:
036: /**
037: * Used in cycles. numberOfUIs = Correct number of UIs + 1, but the variable
038: * used in that sence
039: */
040: private int numberOfUIs;
041:
042: public static ComponentUI createUI(JComponent a) {
043: MultiColorChooserUI mui = new MultiColorChooserUI();
044: ComponentUI result = MultiLookAndFeel
045: .createUIs(mui, mui.uis, a);
046: mui.numberOfUIs = mui.uis.size();
047: return result;
048: }
049:
050: @Override
051: public boolean contains(JComponent a, int b, int c) {
052: for (int i = 1; i < numberOfUIs; i++) {
053: ((ComponentUI) uis.get(i)).contains(a, b, c);
054: }
055: return ((ComponentUI) uis.firstElement()).contains(a, b, c);
056: }
057:
058: @Override
059: public Accessible getAccessibleChild(JComponent a, int b) {
060: for (int i = 1; i < numberOfUIs; i++) {
061: ((ComponentUI) uis.get(i)).getAccessibleChild(a, b);
062: }
063: return ((ComponentUI) uis.firstElement()).getAccessibleChild(a,
064: b);
065: }
066:
067: @Override
068: public int getAccessibleChildrenCount(JComponent a) {
069: for (int i = 1; i < numberOfUIs; i++) {
070: ((ComponentUI) uis.get(i)).getAccessibleChildrenCount(a);
071: }
072: return ((ComponentUI) uis.firstElement())
073: .getAccessibleChildrenCount(a);
074: }
075:
076: @Override
077: public Dimension getMaximumSize(JComponent a) {
078: for (int i = 1; i < numberOfUIs; i++) {
079: ((ComponentUI) uis.get(i)).getMaximumSize(a);
080: }
081: return ((ComponentUI) uis.firstElement()).getMaximumSize(a);
082: }
083:
084: @Override
085: public Dimension getMinimumSize(JComponent a) {
086: for (int i = 1; i < numberOfUIs; i++) {
087: ((ComponentUI) uis.get(i)).getMinimumSize(a);
088: }
089: return ((ComponentUI) uis.firstElement()).getMinimumSize(a);
090: }
091:
092: @Override
093: public Dimension getPreferredSize(JComponent a) {
094: for (int i = 1; i < numberOfUIs; i++) {
095: ((ComponentUI) uis.get(i)).getPreferredSize(a);
096: }
097: return ((ComponentUI) uis.firstElement()).getPreferredSize(a);
098: }
099:
100: public ComponentUI[] getUIs() {
101: return MultiLookAndFeel.uisToArray(uis);
102: }
103:
104: @Override
105: public void installUI(JComponent a) {
106: for (Object ui : uis) {
107: ((ComponentUI) ui).installUI(a);
108: }
109: }
110:
111: @Override
112: public void paint(Graphics a, JComponent b) {
113: for (Object ui : uis) {
114: ((ComponentUI) ui).paint(a, b);
115: }
116: }
117:
118: @Override
119: public void uninstallUI(JComponent a) {
120: for (Object ui : uis) {
121: ((ComponentUI) ui).uninstallUI(a);
122: }
123: }
124:
125: @Override
126: public void update(Graphics a, JComponent b) {
127: for (Object ui : uis) {
128: ((ComponentUI) ui).update(a, b);
129: }
130: }
131:
132: }
|