1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package javax.swing.plaf.multi;
  26 
  27 import java.util.Vector;
  28 import javax.swing.plaf.ListUI;
  29 import javax.swing.JList;
  30 import java.awt.Point;
  31 import java.awt.Rectangle;
  32 import javax.swing.plaf.ComponentUI;
  33 import javax.swing.JComponent;
  34 import java.awt.Graphics;
  35 import java.awt.Dimension;
  36 import javax.accessibility.Accessible;
  37 
  38 /**
  39  * A multiplexing UI used to combine <code>ListUI</code>s.
  40  *
  41  * <p>This file was automatically generated by AutoMulti.
  42  *
  43  * @author  Otto Multey
  44  */
  45 public class MultiListUI extends ListUI {
  46 
  47     /**
  48      * The vector containing the real UIs.  This is populated
  49      * in the call to <code>createUI</code>, and can be obtained by calling
  50      * the <code>getUIs</code> method.  The first element is guaranteed to be the real UI
  51      * obtained from the default look and feel.
  52      */
  53     protected Vector<ComponentUI> uis = new Vector<>();
  54 
  55 ////////////////////
  56 // Common UI methods
  57 ////////////////////
  58 
  59     /**
  60      * Returns the list of UIs associated with this multiplexing UI.  This
  61      * allows processing of the UIs by an application aware of multiplexing
  62      * UIs on components.
  63      *
  64      * @return an array of the UI delegates
  65      */
  66     public ComponentUI[] getUIs() {
  67         return MultiLookAndFeel.uisToArray(uis);
  68     }
  69 
  70 ////////////////////
  71 // ListUI methods
  72 ////////////////////
  73 
  74     /**
  75      * Invokes the <code>locationToIndex</code> method on each UI handled by this object.
  76      *
  77      * @return the value obtained from the first UI, which is
  78      * the UI obtained from the default <code>LookAndFeel</code>
  79      */
  80     public int locationToIndex(JList<?> a, Point b) {
  81         int returnValue =
  82             ((ListUI) (uis.elementAt(0))).locationToIndex(a,b);
  83         for (int i = 1; i < uis.size(); i++) {
  84             ((ListUI) (uis.elementAt(i))).locationToIndex(a,b);
  85         }
  86         return returnValue;
  87     }
  88 
  89     /**
  90      * Invokes the <code>indexToLocation</code> method on each UI handled by this object.
  91      *
  92      * @return the value obtained from the first UI, which is
  93      * the UI obtained from the default <code>LookAndFeel</code>
  94      */
  95     public Point indexToLocation(JList<?> a, int b) {
  96         Point returnValue =
  97             ((ListUI) (uis.elementAt(0))).indexToLocation(a,b);
  98         for (int i = 1; i < uis.size(); i++) {
  99             ((ListUI) (uis.elementAt(i))).indexToLocation(a,b);
 100         }
 101         return returnValue;
 102     }
 103 
 104     /**
 105      * Invokes the <code>getCellBounds</code> method on each UI handled by this object.
 106      *
 107      * @return the value obtained from the first UI, which is
 108      * the UI obtained from the default <code>LookAndFeel</code>
 109      */
 110     public Rectangle getCellBounds(JList<?> a, int b, int c) {
 111         Rectangle returnValue =
 112             ((ListUI) (uis.elementAt(0))).getCellBounds(a,b,c);
 113         for (int i = 1; i < uis.size(); i++) {
 114             ((ListUI) (uis.elementAt(i))).getCellBounds(a,b,c);
 115         }
 116         return returnValue;
 117     }
 118 
 119 ////////////////////
 120 // ComponentUI methods
 121 ////////////////////
 122 
 123     /**
 124      * Invokes the <code>contains</code> method on each UI handled by this object.
 125      *
 126      * @return the value obtained from the first UI, which is
 127      * the UI obtained from the default <code>LookAndFeel</code>
 128      */
 129     public boolean contains(JComponent a, int b, int c) {
 130         boolean returnValue =
 131             uis.elementAt(0).contains(a,b,c);
 132         for (int i = 1; i < uis.size(); i++) {
 133             uis.elementAt(i).contains(a,b,c);
 134         }
 135         return returnValue;
 136     }
 137 
 138     /**
 139      * Invokes the <code>update</code> method on each UI handled by this object.
 140      */
 141     public void update(Graphics a, JComponent b) {
 142         for (int i = 0; i < uis.size(); i++) {
 143             uis.elementAt(i).update(a,b);
 144         }
 145     }
 146 
 147     /**
 148      * Returns a multiplexing UI instance if any of the auxiliary
 149      * <code>LookAndFeel</code>s supports this UI.  Otherwise, just returns the
 150      * UI object obtained from the default <code>LookAndFeel</code>.
 151      *
 152      * @param  a the component to create the UI for
 153      * @return the UI delegate created
 154      */
 155     public static ComponentUI createUI(JComponent a) {
 156         MultiListUI mui = new MultiListUI();
 157         return MultiLookAndFeel.createUIs(mui, mui.uis, a);
 158     }
 159 
 160     /**
 161      * Invokes the <code>installUI</code> method on each UI handled by this object.
 162      */
 163     public void installUI(JComponent a) {
 164         for (int i = 0; i < uis.size(); i++) {
 165             uis.elementAt(i).installUI(a);
 166         }
 167     }
 168 
 169     /**
 170      * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
 171      */
 172     public void uninstallUI(JComponent a) {
 173         for (int i = 0; i < uis.size(); i++) {
 174             uis.elementAt(i).uninstallUI(a);
 175         }
 176     }
 177 
 178     /**
 179      * Invokes the <code>paint</code> method on each UI handled by this object.
 180      */
 181     public void paint(Graphics a, JComponent b) {
 182         for (int i = 0; i < uis.size(); i++) {
 183             uis.elementAt(i).paint(a,b);
 184         }
 185     }
 186 
 187     /**
 188      * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
 189      *
 190      * @return the value obtained from the first UI, which is
 191      * the UI obtained from the default <code>LookAndFeel</code>
 192      */
 193     public Dimension getPreferredSize(JComponent a) {
 194         Dimension returnValue =
 195             uis.elementAt(0).getPreferredSize(a);
 196         for (int i = 1; i < uis.size(); i++) {
 197             uis.elementAt(i).getPreferredSize(a);
 198         }
 199         return returnValue;
 200     }
 201 
 202     /**
 203      * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 204      *
 205      * @return the value obtained from the first UI, which is
 206      * the UI obtained from the default <code>LookAndFeel</code>
 207      */
 208     public Dimension getMinimumSize(JComponent a) {
 209         Dimension returnValue =
 210             uis.elementAt(0).getMinimumSize(a);
 211         for (int i = 1; i < uis.size(); i++) {
 212             uis.elementAt(i).getMinimumSize(a);
 213         }
 214         return returnValue;
 215     }
 216 
 217     /**
 218      * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 219      *
 220      * @return the value obtained from the first UI, which is
 221      * the UI obtained from the default <code>LookAndFeel</code>
 222      */
 223     public Dimension getMaximumSize(JComponent a) {
 224         Dimension returnValue =
 225             uis.elementAt(0).getMaximumSize(a);
 226         for (int i = 1; i < uis.size(); i++) {
 227             uis.elementAt(i).getMaximumSize(a);
 228         }
 229         return returnValue;
 230     }
 231 
 232     /**
 233      * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object.
 234      *
 235      * @return the value obtained from the first UI, which is
 236      * the UI obtained from the default <code>LookAndFeel</code>
 237      */
 238     public int getAccessibleChildrenCount(JComponent a) {
 239         int returnValue =
 240             uis.elementAt(0).getAccessibleChildrenCount(a);
 241         for (int i = 1; i < uis.size(); i++) {
 242             uis.elementAt(i).getAccessibleChildrenCount(a);
 243         }
 244         return returnValue;
 245     }
 246 
 247     /**
 248      * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
 249      *
 250      * @return the value obtained from the first UI, which is
 251      * the UI obtained from the default <code>LookAndFeel</code>
 252      */
 253     public Accessible getAccessibleChild(JComponent a, int b) {
 254         Accessible returnValue =
 255             uis.elementAt(0).getAccessibleChild(a,b);
 256         for (int i = 1; i < uis.size(); i++) {
 257             uis.elementAt(i).getAccessibleChild(a,b);
 258         }
 259         return returnValue;
 260     }
 261 }