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.TextUI;
  29 import java.lang.String;
  30 import javax.swing.text.JTextComponent;
  31 import java.awt.Point;
  32 import java.awt.Rectangle;
  33 import javax.swing.text.BadLocationException;
  34 import javax.swing.text.Position;
  35 import javax.swing.text.EditorKit;
  36 import javax.swing.text.View;
  37 import javax.swing.plaf.ComponentUI;
  38 import javax.swing.JComponent;
  39 import java.awt.Graphics;
  40 import java.awt.Dimension;
  41 import javax.accessibility.Accessible;
  42 
  43 /**
  44  * A multiplexing UI used to combine <code>TextUI</code>s.
  45  *
  46  * <p>This file was automatically generated by AutoMulti.
  47  *
  48  * @author  Otto Multey
  49  */
  50 public class MultiTextUI extends TextUI {
  51 
  52     /**
  53      * The vector containing the real UIs.  This is populated
  54      * in the call to <code>createUI</code>, and can be obtained by calling
  55      * the <code>getUIs</code> method.  The first element is guaranteed to be the real UI
  56      * obtained from the default look and feel.
  57      */
  58     protected Vector uis = new Vector();
  59 
  60 ////////////////////
  61 // Common UI methods
  62 ////////////////////
  63 
  64     /**
  65      * Returns the list of UIs associated with this multiplexing UI.  This
  66      * allows processing of the UIs by an application aware of multiplexing
  67      * UIs on components.
  68      *
  69      * @return an array of the UI delegates
  70      */
  71     public ComponentUI[] getUIs() {
  72         return MultiLookAndFeel.uisToArray(uis);
  73     }
  74 
  75 ////////////////////
  76 // TextUI methods
  77 ////////////////////
  78 
  79     /**
  80      * Invokes the <code>getToolTipText</code> method on each UI handled by this object.
  81      *
  82      * @return the value obtained from the first UI, which is
  83      * the UI obtained from the default <code>LookAndFeel</code>
  84      * @since 1.4
  85      */
  86     public String getToolTipText(JTextComponent a, Point b) {
  87         String returnValue =
  88             ((TextUI) (uis.elementAt(0))).getToolTipText(a,b);
  89         for (int i = 1; i < uis.size(); i++) {
  90             ((TextUI) (uis.elementAt(i))).getToolTipText(a,b);
  91         }
  92         return returnValue;
  93     }
  94 
  95     /**
  96      * Invokes the <code>modelToView</code> method on each UI handled by this object.
  97      *
  98      * @return the value obtained from the first UI, which is
  99      * the UI obtained from the default <code>LookAndFeel</code>
 100      */
 101     public Rectangle modelToView(JTextComponent a, int b)
 102             throws BadLocationException {
 103         Rectangle returnValue =
 104             ((TextUI) (uis.elementAt(0))).modelToView(a,b);
 105         for (int i = 1; i < uis.size(); i++) {
 106             ((TextUI) (uis.elementAt(i))).modelToView(a,b);
 107         }
 108         return returnValue;
 109     }
 110 
 111     /**
 112      * Invokes the <code>modelToView</code> method on each UI handled by this object.
 113      *
 114      * @return the value obtained from the first UI, which is
 115      * the UI obtained from the default <code>LookAndFeel</code>
 116      */
 117     public Rectangle modelToView(JTextComponent a, int b, Position.Bias c)
 118             throws BadLocationException {
 119         Rectangle returnValue =
 120             ((TextUI) (uis.elementAt(0))).modelToView(a,b,c);
 121         for (int i = 1; i < uis.size(); i++) {
 122             ((TextUI) (uis.elementAt(i))).modelToView(a,b,c);
 123         }
 124         return returnValue;
 125     }
 126 
 127     /**
 128      * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 129      *
 130      * @return the value obtained from the first UI, which is
 131      * the UI obtained from the default <code>LookAndFeel</code>
 132      */
 133     public int viewToModel(JTextComponent a, Point b) {
 134         int returnValue =
 135             ((TextUI) (uis.elementAt(0))).viewToModel(a,b);
 136         for (int i = 1; i < uis.size(); i++) {
 137             ((TextUI) (uis.elementAt(i))).viewToModel(a,b);
 138         }
 139         return returnValue;
 140     }
 141 
 142     /**
 143      * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 144      *
 145      * @return the value obtained from the first UI, which is
 146      * the UI obtained from the default <code>LookAndFeel</code>
 147      */
 148     public int viewToModel(JTextComponent a, Point b, Position.Bias[] c) {
 149         int returnValue =
 150             ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c);
 151         for (int i = 1; i < uis.size(); i++) {
 152             ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c);
 153         }
 154         return returnValue;
 155     }
 156 
 157     /**
 158      * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 159      *
 160      * @return the value obtained from the first UI, which is
 161      * the UI obtained from the default <code>LookAndFeel</code>
 162      */
 163     public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
 164             throws BadLocationException {
 165         int returnValue =
 166             ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
 167         for (int i = 1; i < uis.size(); i++) {
 168             ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
 169         }
 170         return returnValue;
 171     }
 172 
 173     /**
 174      * Invokes the <code>damageRange</code> method on each UI handled by this object.
 175      */
 176     public void damageRange(JTextComponent a, int b, int c) {
 177         for (int i = 0; i < uis.size(); i++) {
 178             ((TextUI) (uis.elementAt(i))).damageRange(a,b,c);
 179         }
 180     }
 181 
 182     /**
 183      * Invokes the <code>damageRange</code> method on each UI handled by this object.
 184      */
 185     public void damageRange(JTextComponent a, int b, int c, Position.Bias d, Position.Bias e) {
 186         for (int i = 0; i < uis.size(); i++) {
 187             ((TextUI) (uis.elementAt(i))).damageRange(a,b,c,d,e);
 188         }
 189     }
 190 
 191     /**
 192      * Invokes the <code>getEditorKit</code> method on each UI handled by this object.
 193      *
 194      * @return the value obtained from the first UI, which is
 195      * the UI obtained from the default <code>LookAndFeel</code>
 196      */
 197     public EditorKit getEditorKit(JTextComponent a) {
 198         EditorKit returnValue =
 199             ((TextUI) (uis.elementAt(0))).getEditorKit(a);
 200         for (int i = 1; i < uis.size(); i++) {
 201             ((TextUI) (uis.elementAt(i))).getEditorKit(a);
 202         }
 203         return returnValue;
 204     }
 205 
 206     /**
 207      * Invokes the <code>getRootView</code> method on each UI handled by this object.
 208      *
 209      * @return the value obtained from the first UI, which is
 210      * the UI obtained from the default <code>LookAndFeel</code>
 211      */
 212     public View getRootView(JTextComponent a) {
 213         View returnValue =
 214             ((TextUI) (uis.elementAt(0))).getRootView(a);
 215         for (int i = 1; i < uis.size(); i++) {
 216             ((TextUI) (uis.elementAt(i))).getRootView(a);
 217         }
 218         return returnValue;
 219     }
 220 
 221 ////////////////////
 222 // ComponentUI methods
 223 ////////////////////
 224 
 225     /**
 226      * Invokes the <code>contains</code> method on each UI handled by this object.
 227      *
 228      * @return the value obtained from the first UI, which is
 229      * the UI obtained from the default <code>LookAndFeel</code>
 230      */
 231     public boolean contains(JComponent a, int b, int c) {
 232         boolean returnValue =
 233             ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
 234         for (int i = 1; i < uis.size(); i++) {
 235             ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
 236         }
 237         return returnValue;
 238     }
 239 
 240     /**
 241      * Invokes the <code>update</code> method on each UI handled by this object.
 242      */
 243     public void update(Graphics a, JComponent b) {
 244         for (int i = 0; i < uis.size(); i++) {
 245             ((ComponentUI) (uis.elementAt(i))).update(a,b);
 246         }
 247     }
 248 
 249     /**
 250      * Returns a multiplexing UI instance if any of the auxiliary
 251      * <code>LookAndFeel</code>s supports this UI.  Otherwise, just returns the
 252      * UI object obtained from the default <code>LookAndFeel</code>.
 253      *
 254      * @param  a the component to create the UI for
 255      * @return the UI delegate created
 256      */
 257     public static ComponentUI createUI(JComponent a) {
 258         ComponentUI mui = new MultiTextUI();
 259         return MultiLookAndFeel.createUIs(mui,
 260                                           ((MultiTextUI) mui).uis,
 261                                           a);
 262     }
 263 
 264     /**
 265      * Invokes the <code>installUI</code> method on each UI handled by this object.
 266      */
 267     public void installUI(JComponent a) {
 268         for (int i = 0; i < uis.size(); i++) {
 269             ((ComponentUI) (uis.elementAt(i))).installUI(a);
 270         }
 271     }
 272 
 273     /**
 274      * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
 275      */
 276     public void uninstallUI(JComponent a) {
 277         for (int i = 0; i < uis.size(); i++) {
 278             ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
 279         }
 280     }
 281 
 282     /**
 283      * Invokes the <code>paint</code> method on each UI handled by this object.
 284      */
 285     public void paint(Graphics a, JComponent b) {
 286         for (int i = 0; i < uis.size(); i++) {
 287             ((ComponentUI) (uis.elementAt(i))).paint(a,b);
 288         }
 289     }
 290 
 291     /**
 292      * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
 293      *
 294      * @return the value obtained from the first UI, which is
 295      * the UI obtained from the default <code>LookAndFeel</code>
 296      */
 297     public Dimension getPreferredSize(JComponent a) {
 298         Dimension returnValue =
 299             ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
 300         for (int i = 1; i < uis.size(); i++) {
 301             ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
 302         }
 303         return returnValue;
 304     }
 305 
 306     /**
 307      * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
 308      *
 309      * @return the value obtained from the first UI, which is
 310      * the UI obtained from the default <code>LookAndFeel</code>
 311      */
 312     public Dimension getMinimumSize(JComponent a) {
 313         Dimension returnValue =
 314             ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
 315         for (int i = 1; i < uis.size(); i++) {
 316             ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
 317         }
 318         return returnValue;
 319     }
 320 
 321     /**
 322      * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
 323      *
 324      * @return the value obtained from the first UI, which is
 325      * the UI obtained from the default <code>LookAndFeel</code>
 326      */
 327     public Dimension getMaximumSize(JComponent a) {
 328         Dimension returnValue =
 329             ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
 330         for (int i = 1; i < uis.size(); i++) {
 331             ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
 332         }
 333         return returnValue;
 334     }
 335 
 336     /**
 337      * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object.
 338      *
 339      * @return the value obtained from the first UI, which is
 340      * the UI obtained from the default <code>LookAndFeel</code>
 341      */
 342     public int getAccessibleChildrenCount(JComponent a) {
 343         int returnValue =
 344             ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
 345         for (int i = 1; i < uis.size(); i++) {
 346             ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
 347         }
 348         return returnValue;
 349     }
 350 
 351     /**
 352      * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
 353      *
 354      * @return the value obtained from the first UI, which is
 355      * the UI obtained from the default <code>LookAndFeel</code>
 356      */
 357     public Accessible getAccessibleChild(JComponent a, int b) {
 358         Accessible returnValue =
 359             ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
 360         for (int i = 1; i < uis.size(); i++) {
 361             ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
 362         }
 363         return returnValue;
 364     }
 365 }