1 /* 2 * Copyright (c) 1997, 2006, 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 public ComponentUI[] getUIs() { 70 return MultiLookAndFeel.uisToArray(uis); 71 } 72 73 //////////////////// 74 // TextUI methods 75 //////////////////// 76 77 /** 78 * Invokes the <code>getToolTipText</code> method on each UI handled by this object. 79 * 80 * @return the value obtained from the first UI, which is 81 * the UI obtained from the default <code>LookAndFeel</code> 82 * @since 1.4 83 */ 84 public String getToolTipText(JTextComponent a, Point b) { 85 String returnValue = 86 ((TextUI) (uis.elementAt(0))).getToolTipText(a,b); 87 for (int i = 1; i < uis.size(); i++) { 88 ((TextUI) (uis.elementAt(i))).getToolTipText(a,b); 89 } 90 return returnValue; 91 } 92 93 /** 94 * Invokes the <code>modelToView</code> method on each UI handled by this object. 95 * 96 * @return the value obtained from the first UI, which is 97 * the UI obtained from the default <code>LookAndFeel</code> 98 */ 99 public Rectangle modelToView(JTextComponent a, int b) 100 throws BadLocationException { 101 Rectangle returnValue = 102 ((TextUI) (uis.elementAt(0))).modelToView(a,b); 103 for (int i = 1; i < uis.size(); i++) { 104 ((TextUI) (uis.elementAt(i))).modelToView(a,b); 105 } 106 return returnValue; 107 } 108 109 /** 110 * Invokes the <code>modelToView</code> method on each UI handled by this object. 111 * 112 * @return the value obtained from the first UI, which is 113 * the UI obtained from the default <code>LookAndFeel</code> 114 */ 115 public Rectangle modelToView(JTextComponent a, int b, Position.Bias c) 116 throws BadLocationException { 117 Rectangle returnValue = 118 ((TextUI) (uis.elementAt(0))).modelToView(a,b,c); 119 for (int i = 1; i < uis.size(); i++) { 120 ((TextUI) (uis.elementAt(i))).modelToView(a,b,c); 121 } 122 return returnValue; 123 } 124 125 /** 126 * Invokes the <code>viewToModel</code> method on each UI handled by this object. 127 * 128 * @return the value obtained from the first UI, which is 129 * the UI obtained from the default <code>LookAndFeel</code> 130 */ 131 public int viewToModel(JTextComponent a, Point b) { 132 int returnValue = 133 ((TextUI) (uis.elementAt(0))).viewToModel(a,b); 134 for (int i = 1; i < uis.size(); i++) { 135 ((TextUI) (uis.elementAt(i))).viewToModel(a,b); 136 } 137 return returnValue; 138 } 139 140 /** 141 * Invokes the <code>viewToModel</code> method on each UI handled by this object. 142 * 143 * @return the value obtained from the first UI, which is 144 * the UI obtained from the default <code>LookAndFeel</code> 145 */ 146 public int viewToModel(JTextComponent a, Point b, Position.Bias[] c) { 147 int returnValue = 148 ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c); 149 for (int i = 1; i < uis.size(); i++) { 150 ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c); 151 } 152 return returnValue; 153 } 154 155 /** 156 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object. 157 * 158 * @return the value obtained from the first UI, which is 159 * the UI obtained from the default <code>LookAndFeel</code> 160 */ 161 public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e) 162 throws BadLocationException { 163 int returnValue = 164 ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e); 165 for (int i = 1; i < uis.size(); i++) { 166 ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e); 167 } 168 return returnValue; 169 } 170 171 /** 172 * Invokes the <code>damageRange</code> method on each UI handled by this object. 173 */ 174 public void damageRange(JTextComponent a, int b, int c) { 175 for (int i = 0; i < uis.size(); i++) { 176 ((TextUI) (uis.elementAt(i))).damageRange(a,b,c); 177 } 178 } 179 180 /** 181 * Invokes the <code>damageRange</code> method on each UI handled by this object. 182 */ 183 public void damageRange(JTextComponent a, int b, int c, Position.Bias d, Position.Bias e) { 184 for (int i = 0; i < uis.size(); i++) { 185 ((TextUI) (uis.elementAt(i))).damageRange(a,b,c,d,e); 186 } 187 } 188 189 /** 190 * Invokes the <code>getEditorKit</code> method on each UI handled by this object. 191 * 192 * @return the value obtained from the first UI, which is 193 * the UI obtained from the default <code>LookAndFeel</code> 194 */ 195 public EditorKit getEditorKit(JTextComponent a) { 196 EditorKit returnValue = 197 ((TextUI) (uis.elementAt(0))).getEditorKit(a); 198 for (int i = 1; i < uis.size(); i++) { 199 ((TextUI) (uis.elementAt(i))).getEditorKit(a); 200 } 201 return returnValue; 202 } 203 204 /** 205 * Invokes the <code>getRootView</code> method on each UI handled by this object. 206 * 207 * @return the value obtained from the first UI, which is 208 * the UI obtained from the default <code>LookAndFeel</code> 209 */ 210 public View getRootView(JTextComponent a) { 211 View returnValue = 212 ((TextUI) (uis.elementAt(0))).getRootView(a); 213 for (int i = 1; i < uis.size(); i++) { 214 ((TextUI) (uis.elementAt(i))).getRootView(a); 215 } 216 return returnValue; 217 } 218 219 //////////////////// 220 // ComponentUI methods 221 //////////////////// 222 223 /** 224 * Invokes the <code>contains</code> method on each UI handled by this object. 225 * 226 * @return the value obtained from the first UI, which is 227 * the UI obtained from the default <code>LookAndFeel</code> 228 */ 229 public boolean contains(JComponent a, int b, int c) { 230 boolean returnValue = 231 uis.elementAt(0).contains(a,b,c); 232 for (int i = 1; i < uis.size(); i++) { 233 uis.elementAt(i).contains(a,b,c); 234 } 235 return returnValue; 236 } 237 238 /** 239 * Invokes the <code>update</code> method on each UI handled by this object. 240 */ 241 public void update(Graphics a, JComponent b) { 242 for (int i = 0; i < uis.size(); i++) { 243 uis.elementAt(i).update(a,b); 244 } 245 } 246 247 /** 248 * Returns a multiplexing UI instance if any of the auxiliary 249 * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the 250 * UI object obtained from the default <code>LookAndFeel</code>. 251 */ 252 public static ComponentUI createUI(JComponent a) { 253 MultiTextUI mui = new MultiTextUI(); 254 return MultiLookAndFeel.createUIs(mui, mui.uis, a); 255 } 256 257 /** 258 * Invokes the <code>installUI</code> method on each UI handled by this object. 259 */ 260 public void installUI(JComponent a) { 261 for (int i = 0; i < uis.size(); i++) { 262 uis.elementAt(i).installUI(a); 263 } 264 } 265 266 /** 267 * Invokes the <code>uninstallUI</code> method on each UI handled by this object. 268 */ 269 public void uninstallUI(JComponent a) { 270 for (int i = 0; i < uis.size(); i++) { 271 uis.elementAt(i).uninstallUI(a); 272 } 273 } 274 275 /** 276 * Invokes the <code>paint</code> method on each UI handled by this object. 277 */ 278 public void paint(Graphics a, JComponent b) { 279 for (int i = 0; i < uis.size(); i++) { 280 uis.elementAt(i).paint(a,b); 281 } 282 } 283 284 /** 285 * Invokes the <code>getPreferredSize</code> method on each UI handled by this object. 286 * 287 * @return the value obtained from the first UI, which is 288 * the UI obtained from the default <code>LookAndFeel</code> 289 */ 290 public Dimension getPreferredSize(JComponent a) { 291 Dimension returnValue = 292 uis.elementAt(0).getPreferredSize(a); 293 for (int i = 1; i < uis.size(); i++) { 294 uis.elementAt(i).getPreferredSize(a); 295 } 296 return returnValue; 297 } 298 299 /** 300 * Invokes the <code>getMinimumSize</code> method on each UI handled by this object. 301 * 302 * @return the value obtained from the first UI, which is 303 * the UI obtained from the default <code>LookAndFeel</code> 304 */ 305 public Dimension getMinimumSize(JComponent a) { 306 Dimension returnValue = 307 uis.elementAt(0).getMinimumSize(a); 308 for (int i = 1; i < uis.size(); i++) { 309 uis.elementAt(i).getMinimumSize(a); 310 } 311 return returnValue; 312 } 313 314 /** 315 * Invokes the <code>getMaximumSize</code> method on each UI handled by this object. 316 * 317 * @return the value obtained from the first UI, which is 318 * the UI obtained from the default <code>LookAndFeel</code> 319 */ 320 public Dimension getMaximumSize(JComponent a) { 321 Dimension returnValue = 322 uis.elementAt(0).getMaximumSize(a); 323 for (int i = 1; i < uis.size(); i++) { 324 uis.elementAt(i).getMaximumSize(a); 325 } 326 return returnValue; 327 } 328 329 /** 330 * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object. 331 * 332 * @return the value obtained from the first UI, which is 333 * the UI obtained from the default <code>LookAndFeel</code> 334 */ 335 public int getAccessibleChildrenCount(JComponent a) { 336 int returnValue = 337 uis.elementAt(0).getAccessibleChildrenCount(a); 338 for (int i = 1; i < uis.size(); i++) { 339 uis.elementAt(i).getAccessibleChildrenCount(a); 340 } 341 return returnValue; 342 } 343 344 /** 345 * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object. 346 * 347 * @return the value obtained from the first UI, which is 348 * the UI obtained from the default <code>LookAndFeel</code> 349 */ 350 public Accessible getAccessibleChild(JComponent a, int b) { 351 Accessible returnValue = 352 uis.elementAt(0).getAccessibleChild(a,b); 353 for (int i = 1; i < uis.size(); i++) { 354 uis.elementAt(i).getAccessibleChild(a,b); 355 } 356 return returnValue; 357 } 358 }