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