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