1. /*
  2. * @(#)MultiTextUI.java 1.34 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.multi;
  8. import java.util.Vector;
  9. import javax.swing.plaf.TextUI;
  10. import java.lang.String;
  11. import javax.swing.text.JTextComponent;
  12. import java.awt.Point;
  13. import java.awt.Rectangle;
  14. import javax.swing.text.BadLocationException;
  15. import javax.swing.text.Position;
  16. import javax.swing.text.EditorKit;
  17. import javax.swing.text.View;
  18. import javax.swing.plaf.ComponentUI;
  19. import javax.swing.JComponent;
  20. import java.awt.Graphics;
  21. import java.awt.Dimension;
  22. import javax.accessibility.Accessible;
  23. /**
  24. * A multiplexing UI used to combine <code>TextUI</code>s.
  25. *
  26. * <p>This file was automatically generated by AutoMulti.
  27. *
  28. * @version 1.34 12/19/03 17:39:44
  29. * @author Otto Multey
  30. */
  31. public class MultiTextUI extends TextUI {
  32. /**
  33. * The vector containing the real UIs. This is populated
  34. * in the call to <code>createUI</code>, and can be obtained by calling
  35. * the <code>getUIs</code> method. The first element is guaranteed to be the real UI
  36. * obtained from the default look and feel.
  37. */
  38. protected Vector uis = new Vector();
  39. ////////////////////
  40. // Common UI methods
  41. ////////////////////
  42. /**
  43. * Returns the list of UIs associated with this multiplexing UI. This
  44. * allows processing of the UIs by an application aware of multiplexing
  45. * UIs on components.
  46. */
  47. public ComponentUI[] getUIs() {
  48. return MultiLookAndFeel.uisToArray(uis);
  49. }
  50. ////////////////////
  51. // TextUI methods
  52. ////////////////////
  53. /**
  54. * Invokes the <code>getToolTipText</code> method on each UI handled by this object.
  55. *
  56. * @return the value obtained from the first UI, which is
  57. * the UI obtained from the default <code>LookAndFeel</code>
  58. */
  59. public String getToolTipText(JTextComponent a, Point b) {
  60. String returnValue =
  61. ((TextUI) (uis.elementAt(0))).getToolTipText(a,b);
  62. for (int i = 1; i < uis.size(); i++) {
  63. ((TextUI) (uis.elementAt(i))).getToolTipText(a,b);
  64. }
  65. return returnValue;
  66. }
  67. /**
  68. * Invokes the <code>modelToView</code> method on each UI handled by this object.
  69. *
  70. * @return the value obtained from the first UI, which is
  71. * the UI obtained from the default <code>LookAndFeel</code>
  72. */
  73. public Rectangle modelToView(JTextComponent a, int b)
  74. throws BadLocationException {
  75. Rectangle returnValue =
  76. ((TextUI) (uis.elementAt(0))).modelToView(a,b);
  77. for (int i = 1; i < uis.size(); i++) {
  78. ((TextUI) (uis.elementAt(i))).modelToView(a,b);
  79. }
  80. return returnValue;
  81. }
  82. /**
  83. * Invokes the <code>modelToView</code> method on each UI handled by this object.
  84. *
  85. * @return the value obtained from the first UI, which is
  86. * the UI obtained from the default <code>LookAndFeel</code>
  87. */
  88. public Rectangle modelToView(JTextComponent a, int b, Position.Bias c)
  89. throws BadLocationException {
  90. Rectangle returnValue =
  91. ((TextUI) (uis.elementAt(0))).modelToView(a,b,c);
  92. for (int i = 1; i < uis.size(); i++) {
  93. ((TextUI) (uis.elementAt(i))).modelToView(a,b,c);
  94. }
  95. return returnValue;
  96. }
  97. /**
  98. * Invokes the <code>viewToModel</code> method on each UI handled by this object.
  99. *
  100. * @return the value obtained from the first UI, which is
  101. * the UI obtained from the default <code>LookAndFeel</code>
  102. */
  103. public int viewToModel(JTextComponent a, Point b) {
  104. int returnValue =
  105. ((TextUI) (uis.elementAt(0))).viewToModel(a,b);
  106. for (int i = 1; i < uis.size(); i++) {
  107. ((TextUI) (uis.elementAt(i))).viewToModel(a,b);
  108. }
  109. return returnValue;
  110. }
  111. /**
  112. * Invokes the <code>viewToModel</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 int viewToModel(JTextComponent a, Point b, Position.Bias[] c) {
  118. int returnValue =
  119. ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c);
  120. for (int i = 1; i < uis.size(); i++) {
  121. ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c);
  122. }
  123. return returnValue;
  124. }
  125. /**
  126. * Invokes the <code>getNextVisualPositionFrom</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 getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
  132. throws BadLocationException {
  133. int returnValue =
  134. ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
  135. for (int i = 1; i < uis.size(); i++) {
  136. ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
  137. }
  138. return returnValue;
  139. }
  140. /**
  141. * Invokes the <code>damageRange</code> method on each UI handled by this object.
  142. */
  143. public void damageRange(JTextComponent a, int b, int c) {
  144. for (int i = 0; i < uis.size(); i++) {
  145. ((TextUI) (uis.elementAt(i))).damageRange(a,b,c);
  146. }
  147. }
  148. /**
  149. * Invokes the <code>damageRange</code> method on each UI handled by this object.
  150. */
  151. public void damageRange(JTextComponent a, int b, int c, Position.Bias d, Position.Bias e) {
  152. for (int i = 0; i < uis.size(); i++) {
  153. ((TextUI) (uis.elementAt(i))).damageRange(a,b,c,d,e);
  154. }
  155. }
  156. /**
  157. * Invokes the <code>getEditorKit</code> method on each UI handled by this object.
  158. *
  159. * @return the value obtained from the first UI, which is
  160. * the UI obtained from the default <code>LookAndFeel</code>
  161. */
  162. public EditorKit getEditorKit(JTextComponent a) {
  163. EditorKit returnValue =
  164. ((TextUI) (uis.elementAt(0))).getEditorKit(a);
  165. for (int i = 1; i < uis.size(); i++) {
  166. ((TextUI) (uis.elementAt(i))).getEditorKit(a);
  167. }
  168. return returnValue;
  169. }
  170. /**
  171. * Invokes the <code>getRootView</code> method on each UI handled by this object.
  172. *
  173. * @return the value obtained from the first UI, which is
  174. * the UI obtained from the default <code>LookAndFeel</code>
  175. */
  176. public View getRootView(JTextComponent a) {
  177. View returnValue =
  178. ((TextUI) (uis.elementAt(0))).getRootView(a);
  179. for (int i = 1; i < uis.size(); i++) {
  180. ((TextUI) (uis.elementAt(i))).getRootView(a);
  181. }
  182. return returnValue;
  183. }
  184. ////////////////////
  185. // ComponentUI methods
  186. ////////////////////
  187. /**
  188. * Invokes the <code>contains</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 boolean contains(JComponent a, int b, int c) {
  194. boolean returnValue =
  195. ((ComponentUI) (uis.elementAt(0))).contains(a,b,c);
  196. for (int i = 1; i < uis.size(); i++) {
  197. ((ComponentUI) (uis.elementAt(i))).contains(a,b,c);
  198. }
  199. return returnValue;
  200. }
  201. /**
  202. * Invokes the <code>update</code> method on each UI handled by this object.
  203. */
  204. public void update(Graphics a, JComponent b) {
  205. for (int i = 0; i < uis.size(); i++) {
  206. ((ComponentUI) (uis.elementAt(i))).update(a,b);
  207. }
  208. }
  209. /**
  210. * Returns a multiplexing UI instance if any of the auxiliary
  211. * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the
  212. * UI object obtained from the default <code>LookAndFeel</code>.
  213. */
  214. public static ComponentUI createUI(JComponent a) {
  215. ComponentUI mui = new MultiTextUI();
  216. return MultiLookAndFeel.createUIs(mui,
  217. ((MultiTextUI) mui).uis,
  218. a);
  219. }
  220. /**
  221. * Invokes the <code>installUI</code> method on each UI handled by this object.
  222. */
  223. public void installUI(JComponent a) {
  224. for (int i = 0; i < uis.size(); i++) {
  225. ((ComponentUI) (uis.elementAt(i))).installUI(a);
  226. }
  227. }
  228. /**
  229. * Invokes the <code>uninstallUI</code> method on each UI handled by this object.
  230. */
  231. public void uninstallUI(JComponent a) {
  232. for (int i = 0; i < uis.size(); i++) {
  233. ((ComponentUI) (uis.elementAt(i))).uninstallUI(a);
  234. }
  235. }
  236. /**
  237. * Invokes the <code>paint</code> method on each UI handled by this object.
  238. */
  239. public void paint(Graphics a, JComponent b) {
  240. for (int i = 0; i < uis.size(); i++) {
  241. ((ComponentUI) (uis.elementAt(i))).paint(a,b);
  242. }
  243. }
  244. /**
  245. * Invokes the <code>getPreferredSize</code> method on each UI handled by this object.
  246. *
  247. * @return the value obtained from the first UI, which is
  248. * the UI obtained from the default <code>LookAndFeel</code>
  249. */
  250. public Dimension getPreferredSize(JComponent a) {
  251. Dimension returnValue =
  252. ((ComponentUI) (uis.elementAt(0))).getPreferredSize(a);
  253. for (int i = 1; i < uis.size(); i++) {
  254. ((ComponentUI) (uis.elementAt(i))).getPreferredSize(a);
  255. }
  256. return returnValue;
  257. }
  258. /**
  259. * Invokes the <code>getMinimumSize</code> method on each UI handled by this object.
  260. *
  261. * @return the value obtained from the first UI, which is
  262. * the UI obtained from the default <code>LookAndFeel</code>
  263. */
  264. public Dimension getMinimumSize(JComponent a) {
  265. Dimension returnValue =
  266. ((ComponentUI) (uis.elementAt(0))).getMinimumSize(a);
  267. for (int i = 1; i < uis.size(); i++) {
  268. ((ComponentUI) (uis.elementAt(i))).getMinimumSize(a);
  269. }
  270. return returnValue;
  271. }
  272. /**
  273. * Invokes the <code>getMaximumSize</code> method on each UI handled by this object.
  274. *
  275. * @return the value obtained from the first UI, which is
  276. * the UI obtained from the default <code>LookAndFeel</code>
  277. */
  278. public Dimension getMaximumSize(JComponent a) {
  279. Dimension returnValue =
  280. ((ComponentUI) (uis.elementAt(0))).getMaximumSize(a);
  281. for (int i = 1; i < uis.size(); i++) {
  282. ((ComponentUI) (uis.elementAt(i))).getMaximumSize(a);
  283. }
  284. return returnValue;
  285. }
  286. /**
  287. * Invokes the <code>getAccessibleChildrenCount</code> method on each UI handled by this object.
  288. *
  289. * @return the value obtained from the first UI, which is
  290. * the UI obtained from the default <code>LookAndFeel</code>
  291. */
  292. public int getAccessibleChildrenCount(JComponent a) {
  293. int returnValue =
  294. ((ComponentUI) (uis.elementAt(0))).getAccessibleChildrenCount(a);
  295. for (int i = 1; i < uis.size(); i++) {
  296. ((ComponentUI) (uis.elementAt(i))).getAccessibleChildrenCount(a);
  297. }
  298. return returnValue;
  299. }
  300. /**
  301. * Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
  302. *
  303. * @return the value obtained from the first UI, which is
  304. * the UI obtained from the default <code>LookAndFeel</code>
  305. */
  306. public Accessible getAccessibleChild(JComponent a, int b) {
  307. Accessible returnValue =
  308. ((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
  309. for (int i = 1; i < uis.size(); i++) {
  310. ((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
  311. }
  312. return returnValue;
  313. }
  314. }