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