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<ComponentUI> 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 uis.elementAt(0).contains(a,b,c); 234 for (int i = 1; i < uis.size(); i++) { 235 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 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 MultiTextUI mui = new MultiTextUI(); 259 return MultiLookAndFeel.createUIs(mui, mui.uis, a); 260 } 261 262 /** 263 * Invokes the <code>installUI</code> method on each UI handled by this object. 264 */ 265 public void installUI(JComponent a) { 266 for (int i = 0; i < uis.size(); i++) { 267 uis.elementAt(i).installUI(a); 268 } 269 } 270 271 /** 272 * Invokes the <code>uninstallUI</code> method on each UI handled by this object. 273 */ 274 public void uninstallUI(JComponent a) { 275 for (int i = 0; i < uis.size(); i++) { 276 uis.elementAt(i).uninstallUI(a); 277 } 278 } 279 280 /** 281 * Invokes the <code>paint</code> method on each UI handled by this object. 282 */ 283 public void paint(Graphics a, JComponent b) { 284 for (int i = 0; i < uis.size(); i++) { 285 uis.elementAt(i).paint(a,b); 286 } 287 } 288 289 /** 290 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object. 291 * 292 * @return the value obtained from the first UI, which is 293 * the UI obtained from the default <code>LookAndFeel</code> 294 */ 295 public Dimension getPreferredSize(JComponent a) { 296 Dimension returnValue = 297 uis.elementAt(0).getPreferredSize(a); 298 for (int i = 1; i < uis.size(); i++) { 299 uis.elementAt(i).getPreferredSize(a); 300 } 301 return returnValue; 302 } 303 304 /** 305 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object. 306 * 307 * @return the value obtained from the first UI, which is 308 * the UI obtained from the default <code>LookAndFeel</code> 309 */ 310 public Dimension getMinimumSize(JComponent a) { 311 Dimension returnValue = 312 uis.elementAt(0).getMinimumSize(a); 313 for (int i = 1; i < uis.size(); i++) { 314 uis.elementAt(i).getMinimumSize(a); 315 } 316 return returnValue; 317 } 318 319 /** 320 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object. 321 * 322 * @return the value obtained from the first UI, which is 323 * the UI obtained from the default <code>LookAndFeel</code> 324 */ 325 public Dimension getMaximumSize(JComponent a) { 326 Dimension returnValue = 327 uis.elementAt(0).getMaximumSize(a); 328 for (int i = 1; i < uis.size(); i++) { 329 uis.elementAt(i).getMaximumSize(a); 330 } 331 return returnValue; 332 } 333 334 /** 335 * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object. 336 * 337 * @return the value obtained from the first UI, which is 338 * the UI obtained from the default <code>LookAndFeel</code> 339 */ 340 public int getAccessibleChildrenCount(JComponent a) { 341 int returnValue = 342 uis.elementAt(0).getAccessibleChildrenCount(a); 343 for (int i = 1; i < uis.size(); i++) { 344 uis.elementAt(i).getAccessibleChildrenCount(a); 345 } 346 return returnValue; 347 } 348 349 /** 350 * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object. 351 * 352 * @return the value obtained from the first UI, which is 353 * the UI obtained from the default <code>LookAndFeel</code> 354 */ 355 public Accessible getAccessibleChild(JComponent a, int b) { 356 Accessible returnValue = 357 uis.elementAt(0).getAccessibleChild(a,b); 358 for (int i = 1; i < uis.size(); i++) { 359 uis.elementAt(i).getAccessibleChild(a,b); 360 } 361 return returnValue; 362 } 363 }