1. /*
  2. * @(#)MetalIconFactory.java 1.46 00/02/02
  3. *
  4. * Copyright 1998-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.metal;
  11. import javax.swing.*;
  12. import javax.swing.plaf.UIResource;
  13. import java.awt.*;
  14. import java.awt.image.BufferedImage;
  15. import java.io.Serializable;
  16. /**
  17. * Factory object that can vend Icons appropriate for Metal.
  18. * These are used extensively in Metal via the defaults mechanism.
  19. * While other Look and Feels use GIFs for some of these, doing this
  20. * work in code facilitates things when switching to other Themes.
  21. * <p>
  22. * <strong>Warning:</strong>
  23. * Serialized objects of this class will not be compatible with
  24. * future Swing releases. The current serialization support is appropriate
  25. * for short term storage or RMI between applications running the same
  26. * version of Swing. A future release of Swing will provide support for
  27. * long term persistence.
  28. *
  29. * @version 1.46 02/02/00
  30. * @author Michael C. Albers
  31. */
  32. public class MetalIconFactory implements Serializable {
  33. // List of code-drawn Icons
  34. private static Icon fileChooserDetailViewIcon;
  35. private static Icon fileChooserHomeFolderIcon;
  36. private static Icon fileChooserListViewIcon;
  37. private static Icon fileChooserNewFolderIcon;
  38. private static Icon fileChooserUpFolderIcon;
  39. private static Icon internalFrameAltMaximizeIcon;
  40. private static Icon internalFrameCloseIcon;
  41. private static Icon internalFrameDefaultMenuIcon;
  42. private static Icon internalFrameMaximizeIcon;
  43. private static Icon internalFrameMinimizeIcon;
  44. private static Icon radioButtonIcon;
  45. private static Icon treeComputerIcon;
  46. private static Icon treeFloppyDriveIcon;
  47. private static Icon treeHardDriveIcon;
  48. private static Icon menuArrowIcon;
  49. private static Icon menuItemCheckIcon;
  50. private static Icon menuItemArrowIcon;
  51. private static Icon checkBoxMenuItemIcon;
  52. private static Icon radioButtonMenuItemIcon;
  53. private static Icon checkBoxIcon;
  54. // Constants
  55. public static final boolean DARK = false;
  56. public static final boolean LIGHT = true;
  57. // Accessor functions for Icons. Does the caching work.
  58. public static Icon getFileChooserDetailViewIcon() {
  59. if (fileChooserDetailViewIcon == null) {
  60. fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
  61. }
  62. return fileChooserDetailViewIcon;
  63. }
  64. public static Icon getFileChooserHomeFolderIcon() {
  65. if (fileChooserHomeFolderIcon == null) {
  66. fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
  67. }
  68. return fileChooserHomeFolderIcon;
  69. }
  70. public static Icon getFileChooserListViewIcon() {
  71. if (fileChooserListViewIcon == null) {
  72. fileChooserListViewIcon = new FileChooserListViewIcon();
  73. }
  74. return fileChooserListViewIcon;
  75. }
  76. public static Icon getFileChooserNewFolderIcon() {
  77. if (fileChooserNewFolderIcon == null) {
  78. fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
  79. }
  80. return fileChooserNewFolderIcon;
  81. }
  82. public static Icon getFileChooserUpFolderIcon() {
  83. if (fileChooserUpFolderIcon == null) {
  84. fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
  85. }
  86. return fileChooserUpFolderIcon;
  87. }
  88. public static Icon getInternalFrameAltMaximizeIcon(int size) {
  89. return new InternalFrameAltMaximizeIcon(size);
  90. }
  91. public static Icon getInternalFrameCloseIcon(int size) {
  92. return new InternalFrameCloseIcon(size);
  93. }
  94. public static Icon getInternalFrameDefaultMenuIcon() {
  95. if (internalFrameDefaultMenuIcon == null) {
  96. internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
  97. }
  98. return internalFrameDefaultMenuIcon;
  99. }
  100. public static Icon getInternalFrameMaximizeIcon(int size) {
  101. return new InternalFrameMaximizeIcon(size);
  102. }
  103. public static Icon getInternalFrameMinimizeIcon(int size) {
  104. return new InternalFrameMinimizeIcon(size);
  105. }
  106. public static Icon getRadioButtonIcon() {
  107. if (radioButtonIcon == null) {
  108. radioButtonIcon = new RadioButtonIcon();
  109. }
  110. return radioButtonIcon;
  111. }
  112. /**
  113. * Returns a checkbox icon
  114. * @since 1.3
  115. */
  116. public static Icon getCheckBoxIcon() {
  117. if (checkBoxIcon == null) {
  118. checkBoxIcon = new CheckBoxIcon();
  119. }
  120. return checkBoxIcon;
  121. }
  122. public static Icon getTreeComputerIcon() {
  123. if ( treeComputerIcon == null ) {
  124. treeComputerIcon = new TreeComputerIcon();
  125. }
  126. return treeComputerIcon;
  127. }
  128. public static Icon getTreeFloppyDriveIcon() {
  129. if ( treeFloppyDriveIcon == null ) {
  130. treeFloppyDriveIcon = new TreeFloppyDriveIcon();
  131. }
  132. return treeFloppyDriveIcon;
  133. }
  134. public static Icon getTreeFolderIcon() {
  135. return new TreeFolderIcon();
  136. }
  137. public static Icon getTreeHardDriveIcon() {
  138. if ( treeHardDriveIcon == null ) {
  139. treeHardDriveIcon = new TreeHardDriveIcon();
  140. }
  141. return treeHardDriveIcon;
  142. }
  143. public static Icon getTreeLeafIcon() {
  144. return new TreeLeafIcon();
  145. }
  146. public static Icon getTreeControlIcon( boolean isCollapsed ) {
  147. return new TreeControlIcon( isCollapsed );
  148. }
  149. public static Icon getMenuArrowIcon() {
  150. if (menuArrowIcon == null) {
  151. menuArrowIcon = new MenuArrowIcon();
  152. }
  153. return menuArrowIcon;
  154. }
  155. public static Icon getMenuItemCheckIcon() {
  156. if (menuItemCheckIcon == null) {
  157. menuItemCheckIcon = new MenuItemCheckIcon();
  158. }
  159. return menuItemCheckIcon;
  160. }
  161. public static Icon getMenuItemArrowIcon() {
  162. if (menuItemArrowIcon == null) {
  163. menuItemArrowIcon = new MenuItemArrowIcon();
  164. }
  165. return menuItemArrowIcon;
  166. }
  167. public static Icon getCheckBoxMenuItemIcon() {
  168. if (checkBoxMenuItemIcon == null) {
  169. checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
  170. }
  171. return checkBoxMenuItemIcon;
  172. }
  173. public static Icon getRadioButtonMenuItemIcon() {
  174. if (radioButtonMenuItemIcon == null) {
  175. radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
  176. }
  177. return radioButtonMenuItemIcon;
  178. }
  179. public static Icon getHorizontalSliderThumbIcon() {
  180. // don't cache these, bumps don't get updated otherwise
  181. return new HorizontalSliderThumbIcon();
  182. }
  183. public static Icon getVerticalSliderThumbIcon() {
  184. // don't cache these, bumps don't get updated otherwise
  185. return new VerticalSliderThumbIcon();
  186. }
  187. // File Chooser Detail View code
  188. private static class FileChooserDetailViewIcon implements Icon, UIResource, Serializable {
  189. public void paintIcon(Component c, Graphics g, int x, int y) {
  190. g.translate(x, y);
  191. // Draw outside edge of each of the documents
  192. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  193. // top
  194. g.drawLine(2,2, 5,2); // top
  195. g.drawLine(2,3, 2,7); // left
  196. g.drawLine(3,7, 6,7); // bottom
  197. g.drawLine(6,6, 6,3); // right
  198. // bottom
  199. g.drawLine(2,10, 5,10); // top
  200. g.drawLine(2,11, 2,15); // left
  201. g.drawLine(3,15, 6,15); // bottom
  202. g.drawLine(6,14, 6,11); // right
  203. // Draw little dots next to documents
  204. // Same color as outside edge
  205. g.drawLine(8,5, 15,5); // top
  206. g.drawLine(8,13, 15,13); // bottom
  207. // Draw inner highlight on documents
  208. g.setColor(MetalLookAndFeel.getPrimaryControl());
  209. g.drawRect(3,3, 2,3); // top
  210. g.drawRect(3,11, 2,3); // bottom
  211. // Draw inner inner highlight on documents
  212. g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  213. g.drawLine(4,4, 4,5); // top
  214. g.drawLine(4,12, 4,13); // bottom
  215. g.translate(-x, -y);
  216. }
  217. public int getIconWidth() {
  218. return 18;
  219. }
  220. public int getIconHeight() {
  221. return 18;
  222. }
  223. } // End class FileChooserDetailViewIcon
  224. // File Chooser Home Folder code
  225. private static class FileChooserHomeFolderIcon implements Icon, UIResource, Serializable {
  226. public void paintIcon(Component c, Graphics g, int x, int y) {
  227. g.translate(x, y);
  228. // Draw outside edge of house
  229. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  230. g.drawLine(8,1, 1,8); // left edge of roof
  231. g.drawLine(8,1, 15,8); // right edge of roof
  232. g.drawLine(11,2, 11,3); // left edge of chimney
  233. g.drawLine(12,2, 12,4); // right edge of chimney
  234. g.drawLine(3,7, 3,15); // left edge of house
  235. g.drawLine(13,7, 13,15); // right edge of house
  236. g.drawLine(4,15, 12,15); // bottom edge of house
  237. // Draw door frame
  238. // same color as edge of house
  239. g.drawLine( 6,9, 6,14); // left
  240. g.drawLine(10,9, 10,14); // right
  241. g.drawLine( 7,9, 9, 9); // top
  242. // Draw roof body
  243. g.setColor(MetalLookAndFeel.getControlDarkShadow());
  244. g.fillRect(8,2, 1,1); //top toward bottom
  245. g.fillRect(7,3, 3,1);
  246. g.fillRect(6,4, 5,1);
  247. g.fillRect(5,5, 7,1);
  248. g.fillRect(4,6, 9,2);
  249. // Draw doornob
  250. // same color as roof body
  251. g.drawLine(9,12, 9,12);
  252. // Paint the house
  253. g.setColor(MetalLookAndFeel.getPrimaryControl());
  254. g.drawLine(4,8, 12,8); // above door
  255. g.fillRect(4,9, 2,6); // left of door
  256. g.fillRect(11,9, 2,6); // right of door
  257. g.translate(-x, -y);
  258. }
  259. public int getIconWidth() {
  260. return 18;
  261. }
  262. public int getIconHeight() {
  263. return 18;
  264. }
  265. } // End class FileChooserHomeFolderIcon
  266. // File Chooser List View code
  267. private static class FileChooserListViewIcon implements Icon, UIResource, Serializable {
  268. public void paintIcon(Component c, Graphics g, int x, int y) {
  269. g.translate(x, y);
  270. // Draw outside edge of each of the documents
  271. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  272. // top left
  273. g.drawLine(2,2, 5,2); // top
  274. g.drawLine(2,3, 2,7); // left
  275. g.drawLine(3,7, 6,7); // bottom
  276. g.drawLine(6,6, 6,3); // right
  277. // top right
  278. g.drawLine(10,2, 13,2); // top
  279. g.drawLine(10,3, 10,7); // left
  280. g.drawLine(11,7, 14,7); // bottom
  281. g.drawLine(14,6, 14,3); // right
  282. // bottom left
  283. g.drawLine(2,10, 5,10); // top
  284. g.drawLine(2,11, 2,15); // left
  285. g.drawLine(3,15, 6,15); // bottom
  286. g.drawLine(6,14, 6,11); // right
  287. // bottom right
  288. g.drawLine(10,10, 13,10); // top
  289. g.drawLine(10,11, 10,15); // left
  290. g.drawLine(11,15, 14,15); // bottom
  291. g.drawLine(14,14, 14,11); // right
  292. // Draw little dots next to documents
  293. // Same color as outside edge
  294. g.drawLine(8,5, 8,5); // top left
  295. g.drawLine(16,5, 16,5); // top right
  296. g.drawLine(8,13, 8,13); // bottom left
  297. g.drawLine(16,13, 16,13); // bottom right
  298. // Draw inner highlight on documents
  299. g.setColor(MetalLookAndFeel.getPrimaryControl());
  300. g.drawRect(3,3, 2,3); // top left
  301. g.drawRect(11,3, 2,3); // top right
  302. g.drawRect(3,11, 2,3); // bottom left
  303. g.drawRect(11,11, 2,3); // bottom right
  304. // Draw inner inner highlight on documents
  305. g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  306. g.drawLine(4,4, 4,5); // top left
  307. g.drawLine(12,4, 12,5); // top right
  308. g.drawLine(4,12, 4,13); // bottom left
  309. g.drawLine(12,12, 12,13); // bottom right
  310. g.translate(-x, -y);
  311. }
  312. public int getIconWidth() {
  313. return 18;
  314. }
  315. public int getIconHeight() {
  316. return 18;
  317. }
  318. } // End class FileChooserListViewIcon
  319. // File Chooser New Folder code
  320. private static class FileChooserNewFolderIcon implements Icon, UIResource, Serializable {
  321. public void paintIcon(Component c, Graphics g, int x, int y) {
  322. g.translate(x, y);
  323. // Fill background
  324. g.setColor(MetalLookAndFeel.getPrimaryControl());
  325. g.fillRect(3,5, 12,9);
  326. // Draw outside edge of folder
  327. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  328. g.drawLine(1,6, 1,14); // left
  329. g.drawLine(2,14, 15,14); // bottom
  330. g.drawLine(15,13, 15,5); // right
  331. g.drawLine(2,5, 9,5); // top left
  332. g.drawLine(10,6, 14,6); // top right
  333. // Draw inner folder highlight
  334. g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  335. g.drawLine( 2,6, 2,13); // left
  336. g.drawLine( 3,6, 9,6); // top left
  337. g.drawLine(10,7, 14,7); // top right
  338. // Draw tab on folder
  339. g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  340. g.drawLine(11,3, 15,3); // top
  341. g.drawLine(10,4, 15,4); // bottom
  342. g.translate(-x, -y);
  343. }
  344. public int getIconWidth() {
  345. return 18;
  346. }
  347. public int getIconHeight() {
  348. return 18;
  349. }
  350. } // End class FileChooserNewFolderIcon
  351. // File Chooser Up Folder code
  352. private static class FileChooserUpFolderIcon implements Icon, UIResource, Serializable {
  353. public void paintIcon(Component c, Graphics g, int x, int y) {
  354. g.translate(x, y);
  355. // Fill background
  356. g.setColor(MetalLookAndFeel.getPrimaryControl());
  357. g.fillRect(3,5, 12,9);
  358. // Draw outside edge of folder
  359. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  360. g.drawLine(1,6, 1,14); // left
  361. g.drawLine(2,14, 15,14); // bottom
  362. g.drawLine(15,13, 15,5); // right
  363. g.drawLine(2,5, 9,5); // top left
  364. g.drawLine(10,6, 14,6); // top right
  365. // Draw the UP arrow
  366. // same color as edge
  367. g.drawLine(8,13, 8,16); // arrow shaft
  368. g.drawLine(8, 9, 8, 9); // arrowhead top
  369. g.drawLine(7,10, 9,10);
  370. g.drawLine(6,11, 10,11);
  371. g.drawLine(5,12, 11,12);
  372. // Draw inner folder highlight
  373. g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  374. g.drawLine( 2,6, 2,13); // left
  375. g.drawLine( 3,6, 9,6); // top left
  376. g.drawLine(10,7, 14,7); // top right
  377. // Draw tab on folder
  378. g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
  379. g.drawLine(11,3, 15,3); // top
  380. g.drawLine(10,4, 15,4); // bottom
  381. g.translate(-x, -y);
  382. }
  383. public int getIconWidth() {
  384. return 18;
  385. }
  386. public int getIconHeight() {
  387. return 18;
  388. }
  389. } // End class FileChooserUpFolderIcon
  390. /**
  391. * Defines an icon for Palette close
  392. * @since 1.3
  393. */
  394. public static class PaletteCloseIcon implements Icon, UIResource, Serializable{
  395. int iconSize = 7;
  396. public void paintIcon(Component c, Graphics g, int x, int y) {
  397. JButton parentButton = (JButton)c;
  398. ButtonModel buttonModel = parentButton.getModel();
  399. Color back;
  400. Color highlight = MetalLookAndFeel.getPrimaryControlHighlight();
  401. Color shadow = MetalLookAndFeel.getPrimaryControlInfo();
  402. if (buttonModel.isPressed() && buttonModel.isArmed()) {
  403. back = shadow;
  404. } else {
  405. back = MetalLookAndFeel.getPrimaryControlDarkShadow();
  406. }
  407. g.translate(x, y);
  408. g.setColor(back);
  409. g.drawLine( 0, 1, 5, 6);
  410. g.drawLine( 1, 0, 6, 5);
  411. g.drawLine( 1, 1, 6, 6);
  412. g.drawLine( 6, 1, 1, 6);
  413. g.drawLine( 5,0, 0,5);
  414. g.drawLine(5,1, 1,5);
  415. g.setColor(highlight);
  416. g.drawLine(6,2, 5,3);
  417. g.drawLine(2,6, 3, 5);
  418. g.drawLine(6,6,6,6);
  419. g.translate(-x, -y);
  420. }
  421. public int getIconWidth() {
  422. return iconSize;
  423. }
  424. public int getIconHeight() {
  425. return iconSize;
  426. }
  427. }
  428. // Internal Frame Close code
  429. private static class InternalFrameCloseIcon implements Icon, UIResource, Serializable {
  430. int iconSize = 16;
  431. public InternalFrameCloseIcon(int size) {
  432. iconSize = size;
  433. }
  434. public void paintIcon(Component c, Graphics g, int x, int y) {
  435. JButton parentButton = (JButton)c;
  436. ButtonModel buttonModel = parentButton.getModel();
  437. Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
  438. Color internalBackgroundColor =
  439. MetalLookAndFeel.getPrimaryControl();
  440. Color mainItemColor =
  441. MetalLookAndFeel.getPrimaryControlDarkShadow();
  442. Color darkHighlightColor = MetalLookAndFeel.getBlack();
  443. Color xLightHighlightColor = MetalLookAndFeel.getWhite();
  444. Color boxLightHighlightColor = MetalLookAndFeel.getWhite();
  445. // if the inactive window
  446. if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
  447. {
  448. backgroundColor = MetalLookAndFeel.getControl();
  449. internalBackgroundColor = backgroundColor;
  450. mainItemColor = MetalLookAndFeel.getControlDarkShadow();
  451. // if inactive and pressed
  452. if (buttonModel.isPressed() && buttonModel.isArmed()) {
  453. internalBackgroundColor =
  454. MetalLookAndFeel.getControlShadow();
  455. xLightHighlightColor = internalBackgroundColor;
  456. mainItemColor = darkHighlightColor;
  457. }
  458. }
  459. // if pressed
  460. else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  461. internalBackgroundColor =
  462. MetalLookAndFeel.getPrimaryControlShadow();
  463. xLightHighlightColor = internalBackgroundColor;
  464. mainItemColor = darkHighlightColor;
  465. // darkHighlightColor is still "getBlack()"
  466. }
  467. // Some calculations that are needed more than once later on.
  468. int oneHalf = (int)(iconSize / 2); // 16 -> 8
  469. g.translate(x, y);
  470. // fill background
  471. g.setColor(backgroundColor);
  472. g.fillRect(0,0, iconSize,iconSize);
  473. // fill inside of box area
  474. g.setColor(internalBackgroundColor);
  475. g.fillRect(3,3, iconSize-6,iconSize-6);
  476. // THE BOX
  477. // the top/left dark higlight - some of this will get overwritten
  478. g.setColor(darkHighlightColor);
  479. g.drawRect(1,1, iconSize-3,iconSize-3);
  480. // draw the inside bottom/right highlight
  481. g.drawRect(2,2, iconSize-5,iconSize-5);
  482. // draw the light/outside, bottom/right highlight
  483. g.setColor(boxLightHighlightColor);
  484. g.drawRect(2,2, iconSize-3,iconSize-3);
  485. // draw the "normal" box
  486. g.setColor(mainItemColor);
  487. g.drawRect(2,2, iconSize-4,iconSize-4);
  488. g.drawLine(3,iconSize-3, 3,iconSize-3); // lower left
  489. g.drawLine(iconSize-3,3, iconSize-3,3); // up right
  490. // THE "X"
  491. // Dark highlight
  492. g.setColor(darkHighlightColor);
  493. g.drawLine(4,5, 5,4); // far up left
  494. g.drawLine(4,iconSize-6, iconSize-6,4); // against body of "X"
  495. // Light highlight
  496. g.setColor(xLightHighlightColor);
  497. g.drawLine(6,iconSize-5, iconSize-5,6); // against body of "X"
  498. // one pixel over from the body
  499. g.drawLine(oneHalf,oneHalf+2, oneHalf+2,oneHalf);
  500. // bottom right
  501. g.drawLine(iconSize-5,iconSize-5, iconSize-4,iconSize-5);
  502. g.drawLine(iconSize-5,iconSize-4, iconSize-5,iconSize-4);
  503. // Main color
  504. g.setColor(mainItemColor);
  505. // Upper left to lower right
  506. g.drawLine(5,5, iconSize-6,iconSize-6); // g.drawLine(5,5, 10,10);
  507. g.drawLine(6,5, iconSize-5,iconSize-6); // g.drawLine(6,5, 11,10);
  508. g.drawLine(5,6, iconSize-6,iconSize-5); // g.drawLine(5,6, 10,11);
  509. // Lower left to upper right
  510. g.drawLine(5,iconSize-5, iconSize-5,5); // g.drawLine(5,11, 11,5);
  511. g.drawLine(5,iconSize-6, iconSize-6,5); // g.drawLine(5,10, 10,5);
  512. g.translate(-x, -y);
  513. }
  514. public int getIconWidth() {
  515. return iconSize;
  516. }
  517. public int getIconHeight() {
  518. return iconSize;
  519. }
  520. } // End class InternalFrameCloseIcon
  521. // Internal Frame Alternate Maximize code (actually, the un-maximize icon)
  522. private static class InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable {
  523. int iconSize = 16;
  524. public InternalFrameAltMaximizeIcon(int size) {
  525. iconSize = size;
  526. }
  527. public void paintIcon(Component c, Graphics g, int x, int y) {
  528. JButton parentButton = (JButton)c;
  529. ButtonModel buttonModel = parentButton.getModel();
  530. Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
  531. Color internalBackgroundColor =
  532. MetalLookAndFeel.getPrimaryControl();
  533. Color mainItemColor =
  534. MetalLookAndFeel.getPrimaryControlDarkShadow();
  535. Color darkHighlightColor = MetalLookAndFeel.getBlack();
  536. // ul = Upper Left and lr = Lower Right
  537. Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
  538. Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
  539. // if the internal frame is inactive
  540. if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
  541. {
  542. backgroundColor = MetalLookAndFeel.getControl();
  543. internalBackgroundColor = backgroundColor;
  544. mainItemColor = MetalLookAndFeel.getControlDarkShadow();
  545. // if inactive and pressed
  546. if (buttonModel.isPressed() && buttonModel.isArmed()) {
  547. internalBackgroundColor =
  548. MetalLookAndFeel.getControlShadow();
  549. ulLightHighlightColor = internalBackgroundColor;
  550. mainItemColor = darkHighlightColor;
  551. }
  552. }
  553. // if the button is pressed and the mouse is over it
  554. else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  555. internalBackgroundColor =
  556. MetalLookAndFeel.getPrimaryControlShadow();
  557. ulLightHighlightColor = internalBackgroundColor;
  558. mainItemColor = darkHighlightColor;
  559. // darkHighlightColor is still "getBlack()"
  560. }
  561. g.translate(x, y);
  562. // fill background
  563. g.setColor(backgroundColor);
  564. g.fillRect(0,0, iconSize,iconSize);
  565. // BOX
  566. // fill inside the box
  567. g.setColor(internalBackgroundColor);
  568. g.fillRect(3,6, iconSize-9,iconSize-9);
  569. // draw dark highlight color
  570. g.setColor(darkHighlightColor);
  571. g.drawRect(1,5, iconSize-8,iconSize-8);
  572. g.drawLine(1,iconSize-2, 1,iconSize-2); // extra pixel on bottom
  573. // draw lower right light highlight
  574. g.setColor(lrLightHighlightColor);
  575. g.drawRect(2,6, iconSize-7,iconSize-7);
  576. // draw upper left light highlight
  577. g.setColor(ulLightHighlightColor);
  578. g.drawRect(3,7, iconSize-9,iconSize-9);
  579. // draw the main box
  580. g.setColor(mainItemColor);
  581. g.drawRect(2,6, iconSize-8,iconSize-8);
  582. // Six extraneous pixels to deal with
  583. g.setColor(ulLightHighlightColor);
  584. g.drawLine(iconSize-6,8,iconSize-6,8);
  585. g.drawLine(iconSize-9,6, iconSize-7,8);
  586. g.setColor(mainItemColor);
  587. g.drawLine(3,iconSize-3,3,iconSize-3);
  588. g.setColor(darkHighlightColor);
  589. g.drawLine(iconSize-6,9,iconSize-6,9);
  590. g.setColor(backgroundColor);
  591. g.drawLine(iconSize-9,5,iconSize-9,5);
  592. // ARROW
  593. // do the shaft first
  594. g.setColor(mainItemColor);
  595. g.fillRect(iconSize-7,3, 3,5); // do a big block
  596. g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
  597. g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
  598. g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
  599. // draw the dark highlight
  600. g.setColor(darkHighlightColor);
  601. g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
  602. g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
  603. g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
  604. g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
  605. // draw the light highlight
  606. g.setColor(lrLightHighlightColor);
  607. g.drawLine(iconSize-6,3, iconSize-6,3); // top
  608. g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
  609. g.drawLine(iconSize-4,8, iconSize-3,8); // under arrowhead
  610. g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
  611. g.translate(-x, -y);
  612. }
  613. public int getIconWidth() {
  614. return iconSize;
  615. }
  616. public int getIconHeight() {
  617. return iconSize;
  618. }
  619. } // End class InternalFrameAltMaximizeIcon
  620. // Code for the default icons that goes in the upper left corner
  621. private static class InternalFrameDefaultMenuIcon implements Icon, UIResource, Serializable {
  622. public void paintIcon(Component c, Graphics g, int x, int y) {
  623. Color windowBodyColor = MetalLookAndFeel.getWindowBackground();
  624. Color titleColor = MetalLookAndFeel.getPrimaryControl();
  625. Color edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  626. g.translate(x, y);
  627. // draw background color for title area
  628. // catch four corners and title area
  629. g.setColor(titleColor);
  630. g.fillRect(0,0, 16,16);
  631. // fill body of window
  632. g.setColor(windowBodyColor);
  633. g.fillRect(2,6, 13,9);
  634. // draw light parts of two "bumps"
  635. g.drawLine(2,2, 2,2);
  636. g.drawLine(5,2, 5,2);
  637. g.drawLine(8,2, 8,2);
  638. g.drawLine(11,2, 11,2);
  639. // draw line around edge of title and icon
  640. g.setColor(edgeColor);
  641. g.drawRect(1,1, 13,13); // entire inner edge
  642. g.drawLine(1,0, 14,0); // top outter edge
  643. g.drawLine(15,1, 15,14); // right outter edge
  644. g.drawLine(1,15, 14,15); // bottom outter edge
  645. g.drawLine(0,1, 0,14); // left outter edge
  646. g.drawLine(2,5, 13,5); // bottom of title bar area
  647. // draw dark part of four "bumps" (same color)
  648. g.drawLine(3,3, 3,3);
  649. g.drawLine(6,3, 6,3);
  650. g.drawLine(9,3, 9,3);
  651. g.drawLine(12,3, 12,3);
  652. g.translate(-x, -y);
  653. }
  654. public int getIconWidth() {
  655. return 16;
  656. }
  657. public int getIconHeight() {
  658. return 16;
  659. }
  660. } // End class InternalFrameDefaultMenuIcon
  661. // Internal Frame Maximize code
  662. private static class InternalFrameMaximizeIcon implements Icon, UIResource, Serializable {
  663. protected int iconSize = 16;
  664. public InternalFrameMaximizeIcon(int size) {
  665. iconSize = size;
  666. }
  667. public void paintIcon(Component c, Graphics g, int x, int y) {
  668. JButton parentButton = (JButton)c;
  669. ButtonModel buttonModel = parentButton.getModel();
  670. Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
  671. Color internalBackgroundColor =
  672. MetalLookAndFeel.getPrimaryControl();
  673. Color mainItemColor =
  674. MetalLookAndFeel.getPrimaryControlDarkShadow();
  675. Color darkHighlightColor = MetalLookAndFeel.getBlack();
  676. // ul = Upper Left and lr = Lower Right
  677. Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
  678. Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
  679. // if the internal frame is inactive
  680. if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
  681. {
  682. backgroundColor = MetalLookAndFeel.getControl();
  683. internalBackgroundColor = backgroundColor;
  684. mainItemColor = MetalLookAndFeel.getControlDarkShadow();
  685. // if inactive and pressed
  686. if (buttonModel.isPressed() && buttonModel.isArmed()) {
  687. internalBackgroundColor =
  688. MetalLookAndFeel.getControlShadow();
  689. ulLightHighlightColor = internalBackgroundColor;
  690. mainItemColor = darkHighlightColor;
  691. }
  692. }
  693. // if the button is pressed and the mouse is over it
  694. else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  695. internalBackgroundColor =
  696. MetalLookAndFeel.getPrimaryControlShadow();
  697. ulLightHighlightColor = internalBackgroundColor;
  698. mainItemColor = darkHighlightColor;
  699. // darkHighlightColor is still "getBlack()"
  700. }
  701. g.translate(x, y);
  702. // fill background
  703. g.setColor(backgroundColor);
  704. g.fillRect(0,0, iconSize,iconSize);
  705. // BOX drawing
  706. // fill inside the box
  707. g.setColor(internalBackgroundColor);
  708. g.fillRect(3,7, iconSize-10,iconSize-10);
  709. // light highlight
  710. g.setColor(ulLightHighlightColor);
  711. g.drawRect(3,7, iconSize-10,iconSize-10); // up,left
  712. g.setColor(lrLightHighlightColor);
  713. g.drawRect(2,6, iconSize-7,iconSize-7); // low,right
  714. // dark highlight
  715. g.setColor(darkHighlightColor);
  716. g.drawRect(1,5, iconSize-7,iconSize-7); // outer
  717. g.drawRect(2,6, iconSize-9,iconSize-9); // inner
  718. // main box
  719. g.setColor(mainItemColor);
  720. g.drawRect(2,6, iconSize-8,iconSize-8); // g.drawRect(2,6, 8,8);
  721. // ARROW drawing
  722. // dark highlight
  723. g.setColor(darkHighlightColor);
  724. // down,left to up,right - inside box
  725. g.drawLine(3,iconSize-5, iconSize-9,7);
  726. // down,left to up,right - outside box
  727. g.drawLine(iconSize-6,4, iconSize-5,3);
  728. // outside edge of arrow head
  729. g.drawLine(iconSize-7,1, iconSize-7,2);
  730. // outside edge of arrow head
  731. g.drawLine(iconSize-6,1, iconSize-2,1);
  732. // light highlight
  733. g.setColor(ulLightHighlightColor);
  734. // down,left to up,right - inside box
  735. g.drawLine(5,iconSize-4, iconSize-8,9);
  736. g.setColor(lrLightHighlightColor);
  737. g.drawLine(iconSize-6,3, iconSize-4,5); // outside box
  738. g.drawLine(iconSize-4,5, iconSize-4,6); // one down from this
  739. g.drawLine(iconSize-2,7, iconSize-1,7); // outside edge arrow head
  740. g.drawLine(iconSize-1,2, iconSize-1,6); // outside edge arrow head
  741. // main part of arrow
  742. g.setColor(mainItemColor);
  743. g.drawLine(3,iconSize-4, iconSize-3,2); // top edge of staff
  744. g.drawLine(3,iconSize-3, iconSize-2,2); // bottom edge of staff
  745. g.drawLine(4,iconSize-3, 5,iconSize-3); // highlights inside of box
  746. g.drawLine(iconSize-7,8, iconSize-7,9); // highlights inside of box
  747. g.drawLine(iconSize-6,2, iconSize-4,2); // top of arrow head
  748. g.drawRect(iconSize-3,3, 1,3); // right of arrow head
  749. g.translate(-x, -y);
  750. }
  751. public int getIconWidth() {
  752. return iconSize;
  753. }
  754. public int getIconHeight() {
  755. return iconSize;
  756. }
  757. } // End class InternalFrameMaximizeIcon
  758. // Internal Frame Minimize code
  759. private static class InternalFrameMinimizeIcon implements Icon, UIResource, Serializable {
  760. int iconSize = 16;
  761. public InternalFrameMinimizeIcon(int size) {
  762. iconSize = size;
  763. }
  764. public void paintIcon(Component c, Graphics g, int x, int y) {
  765. JButton parentButton = (JButton)c;
  766. ButtonModel buttonModel = parentButton.getModel();
  767. Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
  768. Color internalBackgroundColor =
  769. MetalLookAndFeel.getPrimaryControl();
  770. Color mainItemColor =
  771. MetalLookAndFeel.getPrimaryControlDarkShadow();
  772. Color darkHighlightColor = MetalLookAndFeel.getBlack();
  773. // ul = Upper Left and lr = Lower Right
  774. Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
  775. Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
  776. // if the internal frame is inactive
  777. if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
  778. {
  779. backgroundColor = MetalLookAndFeel.getControl();
  780. internalBackgroundColor = backgroundColor;
  781. mainItemColor = MetalLookAndFeel.getControlDarkShadow();
  782. // if inactive and pressed
  783. if (buttonModel.isPressed() && buttonModel.isArmed()) {
  784. internalBackgroundColor =
  785. MetalLookAndFeel.getControlShadow();
  786. ulLightHighlightColor = internalBackgroundColor;
  787. mainItemColor = darkHighlightColor;
  788. }
  789. }
  790. // if the button is pressed and the mouse is over it
  791. else if (buttonModel.isPressed() && buttonModel.isArmed()) {
  792. internalBackgroundColor =
  793. MetalLookAndFeel.getPrimaryControlShadow();
  794. ulLightHighlightColor = internalBackgroundColor;
  795. mainItemColor = darkHighlightColor;
  796. // darkHighlightColor is still "getBlack()"
  797. }
  798. g.translate(x, y);
  799. // fill background
  800. g.setColor(backgroundColor);
  801. g.fillRect(0,0, iconSize,iconSize);
  802. // BOX drawing
  803. // fill inside the box
  804. g.setColor(internalBackgroundColor);
  805. g.fillRect(4,11, iconSize-13,iconSize-13);
  806. // light highlight
  807. g.setColor(lrLightHighlightColor);
  808. g.drawRect(2,10, iconSize-10,iconSize-11); // low,right
  809. g.setColor(ulLightHighlightColor);
  810. g.drawRect(3,10, iconSize-12,iconSize-12); // up,left
  811. // dark highlight
  812. g.setColor(darkHighlightColor);
  813. g.drawRect(1,8, iconSize-10,iconSize-10); // outer
  814. g.drawRect(2,9, iconSize-12,iconSize-12); // inner
  815. // main box
  816. g.setColor(mainItemColor);
  817. g.drawRect(2,9, iconSize-11,iconSize-11);
  818. g.drawLine(iconSize-10,10, iconSize-10,10); // up right highlight
  819. g.drawLine(3,iconSize-3, 3,iconSize-3); // low left highlight
  820. // ARROW
  821. // do the shaft first
  822. g.setColor(mainItemColor);
  823. g.fillRect(iconSize-7,3, 3,5); // do a big block
  824. g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
  825. g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
  826. g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
  827. // draw the dark highlight
  828. g.setColor(darkHighlightColor);
  829. g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
  830. g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
  831. g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
  832. g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
  833. // draw the light highlight
  834. g.setColor(lrLightHighlightColor);
  835. g.drawLine(iconSize-6,3, iconSize-6,3); // top
  836. g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
  837. g.drawLine(iconSize-7,8, iconSize-3,8); // under arrowhead
  838. g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
  839. g.translate(-x, -y);
  840. }
  841. public int getIconWidth() {
  842. return iconSize;
  843. }
  844. public int getIconHeight() {
  845. return iconSize;
  846. }
  847. } // End class InternalFrameMinimizeIcon
  848. private static class CheckBoxIcon implements Icon, UIResource, Serializable {
  849. protected int getControlSize() { return 13; }
  850. public void paintIcon(Component c, Graphics g, int x, int y) {
  851. JCheckBox cb = (JCheckBox)c;
  852. ButtonModel model = cb.getModel();
  853. int controlSize = getControlSize();
  854. boolean drawCheck = model.isSelected();
  855. if ( model.isEnabled() ) {
  856. if (model.isPressed() && model.isArmed()) {
  857. g.setColor( MetalLookAndFeel.getControlShadow() );
  858. g.fillRect( x, y, controlSize-1, controlSize-1);
  859. MetalUtils.drawPressed3DBorder(g, x, y, controlSize, controlSize);
  860. } else {
  861. MetalUtils.drawFlush3DBorder(g, x, y, controlSize, controlSize);
  862. }
  863. g.setColor( MetalLookAndFeel.getControlInfo() );
  864. } else {
  865. g.setColor( MetalLookAndFeel.getControlShadow() );
  866. g.drawRect( x, y, controlSize-1, controlSize-1);
  867. }
  868. if (model.isSelected()) {
  869. drawCheck(c,g,x,y);
  870. }
  871. }
  872. protected void drawCheck(Component c, Graphics g, int x, int y) {
  873. int controlSize = getControlSize();
  874. g.fillRect( x+3, y+5, 2, controlSize-8 );
  875. g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) );
  876. g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) );
  877. }
  878. public int getIconWidth() {
  879. return getControlSize();
  880. }
  881. public int getIconHeight() {
  882. return getControlSize();
  883. }
  884. } // End class CheckBoxIcon
  885. // Radio button code
  886. private static class RadioButtonIcon implements Icon, UIResource, Serializable {
  887. public void paintIcon(Component c, Graphics g, int x, int y) {
  888. JRadioButton rb = (JRadioButton)c;
  889. ButtonModel model = rb.getModel();
  890. boolean drawDot = model.isSelected();
  891. Color background = c.getBackground();
  892. Color dotColor = c.getForeground();
  893. Color shadow = MetalLookAndFeel.getControlShadow();
  894. Color darkCircle = MetalLookAndFeel.getControlDarkShadow();
  895. Color whiteInnerLeftArc = MetalLookAndFeel.getControlHighlight();
  896. Color whiteOuterRightArc = MetalLookAndFeel.getControlHighlight();
  897. Color interiorColor = background;
  898. // Set up colors per RadioButtonModel condition
  899. if ( !model.isEnabled() ) {
  900. whiteInnerLeftArc = whiteOuterRightArc = background;
  901. darkCircle = dotColor = shadow;
  902. }
  903. else if (model.isPressed() && model.isArmed() ) {
  904. whiteInnerLeftArc = interiorColor = shadow;
  905. }
  906. g.translate(x, y);
  907. // fill interior
  908. g.setColor(interiorColor);
  909. g.fillRect(2,2, 9,9);
  910. // draw Dark Circle (start at top, go clockwise)
  911. g.setColor(darkCircle);
  912. g.drawLine( 4, 0, 7, 0);
  913. g.drawLine( 8, 1, 9, 1);
  914. g.drawLine(10, 2, 10, 3);
  915. g.drawLine(11, 4, 11, 7);
  916. g.drawLine(10, 8, 10, 9);
  917. g.drawLine( 9,10, 8,10);
  918. g.drawLine( 7,11, 4,11);
  919. g.drawLine( 3,10, 2,10);
  920. g.drawLine( 1, 9, 1, 8);
  921. g.drawLine( 0, 7, 0, 4);
  922. g.drawLine( 1, 3, 1, 2);
  923. g.drawLine( 2, 1, 3, 1);
  924. // draw Inner Left (usually) White Arc
  925. // start at lower left corner, go clockwise
  926. g.setColor(whiteInnerLeftArc);
  927. g.drawLine( 2, 9, 2, 8);
  928. g.drawLine( 1, 7, 1, 4);
  929. g.drawLine( 2, 2, 2, 3);
  930. g.drawLine( 2, 2, 3, 2);
  931. g.drawLine( 4, 1, 7, 1);
  932. g.drawLine( 8, 2, 9, 2);
  933. // draw Outer Right White Arc
  934. // start at upper right corner, go clockwise
  935. g.setColor(whiteOuterRightArc);
  936. g.drawLine(10, 1, 10, 1);
  937. g.drawLine(11, 2, 11, 3);
  938. g.drawLine(12, 4, 12, 7);
  939. g.drawLine(11, 8, 11, 9);
  940. g.drawLine(10,10, 10,10);
  941. g.drawLine( 9,11, 8,11);
  942. g.drawLine( 7,12, 4,12);
  943. g.drawLine( 3,11, 2,11);
  944. // selected dot
  945. if ( drawDot ) {
  946. g.setColor(dotColor);
  947. g.fillRect( 4, 4, 4, 4);
  948. g.drawLine( 4, 3, 7, 3);
  949. g.drawLine( 8, 4, 8, 7);
  950. g.drawLine( 7, 8, 4, 8);
  951. g.drawLine( 3, 7, 3, 4);
  952. }
  953. g.translate(-x, -y);
  954. }
  955. public int getIconWidth() {
  956. return 13;
  957. }
  958. public int getIconHeight() {
  959. return 13;
  960. }
  961. } // End class RadioButtonIcon
  962. // Tree Computer Icon code
  963. private static class TreeComputerIcon implements Icon, UIResource, Serializable {
  964. public void paintIcon(Component c, Graphics g, int x, int y) {
  965. g.translate(x, y);
  966. // Fill glass portion of monitor
  967. g.setColor(MetalLookAndFeel.getPrimaryControl());
  968. g.fillRect(5,4, 6,4);
  969. // Draw outside edge of monitor
  970. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  971. g.drawLine( 2,2, 2,8); // left
  972. g.drawLine(13,2, 13,8); // right
  973. g.drawLine( 3,1, 12,1); // top
  974. g.drawLine(12,9, 12,9); // bottom right base
  975. g.drawLine( 3,9, 3,9); // bottom left base
  976. // Draw the edge of the glass
  977. g.drawLine( 4,4, 4,7); // left
  978. g.drawLine( 5,3, 10,3); // top
  979. g.drawLine(11,4, 11,7); // right
  980. g.drawLine( 5,8, 10,8); // bottom
  981. // Draw the edge of the CPU
  982. g.drawLine( 1,10, 14,10); // top
  983. g.drawLine(14,10, 14,14); // right
  984. g.drawLine( 1,14, 14,14); // bottom
  985. g.drawLine( 1,10, 1,14); // left
  986. // Draw the disk drives
  987. g.setColor(MetalLookAndFeel.getControlDarkShadow());
  988. g.drawLine( 6,12, 8,12); // left
  989. g.drawLine(10,12, 12,12); // right
  990. g.translate(-x, -y);
  991. }
  992. public int getIconWidth() {
  993. return 16;
  994. }
  995. public int getIconHeight() {
  996. return 16;
  997. }
  998. } // End class TreeComputerIcon
  999. // Tree HardDrive Icon code
  1000. private static class TreeHardDriveIcon implements Icon, UIResource, Serializable {
  1001. public void paintIcon(Component c, Graphics g, int x, int y) {
  1002. g.translate(x, y);
  1003. // Draw edges of the disks
  1004. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  1005. // top disk
  1006. g.drawLine(1,4, 1,5); // left
  1007. g.drawLine(2,3, 3,3);
  1008. g.drawLine(4,2, 11,2); // top
  1009. g.drawLine(12,3, 13,3);
  1010. g.drawLine(14,4, 14,5); // right
  1011. g.drawLine(12,6, 13,6);
  1012. g.drawLine(4,7, 11,7); // bottom
  1013. g.drawLine(2,6, 3,6);
  1014. // middle disk
  1015. g.drawLine(1,7, 1,8); // left
  1016. g.drawLine(2,9, 3,9);
  1017. g.drawLine(4,10, 11,10); // bottom
  1018. g.drawLine(12,9, 13,9);
  1019. g.drawLine(14,7, 14, 8); // right
  1020. // bottom disk
  1021. g.drawLine(1,10, 1,11); // left
  1022. g.drawLine(2,12, 3,12);
  1023. g.drawLine(4,13, 11,13); // bottom
  1024. g.drawLine(12,12, 13,12);
  1025. g.drawLine(14,10, 14,11); // right
  1026. // Draw the down right shadows
  1027. g.setColor(MetalLookAndFeel.getControlShadow());
  1028. // top disk
  1029. g.drawLine(7,6, 7,6);
  1030. g.drawLine(9,6, 9,6);
  1031. g.drawLine(10,5, 10,5);
  1032. g.drawLine(11,6, 11,6);
  1033. g.drawLine(12,5, 13,5);
  1034. g.drawLine(13,4, 13,4);
  1035. // middle disk
  1036. g.drawLine(7,9, 7,9);
  1037. g.drawLine(9,9, 9,9);
  1038. g.drawLine(10,8, 10,8);
  1039. g.drawLine(11,9, 11,9);
  1040. g.drawLine(12,8, 13,8);
  1041. g.drawLine(13,7, 13,7);
  1042. // bottom disk
  1043. g.drawLine(7,12, 7,12);
  1044. g.drawLine(9,12, 9,12);
  1045. g.drawLine(10,11, 10,11);
  1046. g.drawLine(11,12, 11,12);
  1047. g.drawLine(12,11, 13,11);
  1048. g.drawLine(13,10, 13,10);
  1049. // Draw the up left highlight
  1050. g.setColor(MetalLookAndFeel.getControlHighlight());
  1051. // top disk
  1052. g.drawLine(4,3, 5,3);
  1053. g.drawLine(7,3, 9,3);
  1054. g.drawLine(11,3, 11,3);
  1055. g.drawLine(2,4, 6,4);
  1056. g.drawLine(8,4, 8,4);
  1057. g.drawLine(2,5, 3,5);
  1058. g.drawLine(4,6, 4,6);
  1059. // middle disk
  1060. g.drawLine(2,7, 3,7);
  1061. g.drawLine(2,8, 3,8);
  1062. g.drawLine(4,9, 4,9);
  1063. // bottom disk
  1064. g.drawLine(2,10, 3,10);
  1065. g.drawLine(2,11, 3,11);
  1066. g.drawLine(4,12, 4,12);
  1067. g.translate(-x, -y);
  1068. }
  1069. public int getIconWidth() {
  1070. return 16;
  1071. }
  1072. public int getIconHeight() {
  1073. return 16;
  1074. }
  1075. } // End class TreeHardDriveIcon
  1076. // Tree FloppyDrive Icon code
  1077. private static class TreeFloppyDriveIcon implements Icon, UIResource, Serializable {
  1078. public void paintIcon(Component c, Graphics g, int x, int y) {
  1079. g.translate(x, y);
  1080. // Fill body of floppy
  1081. g.setColor(MetalLookAndFeel.getPrimaryControl());
  1082. g.fillRect(2,2, 12,12);
  1083. // Draw outside edge of floppy
  1084. g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
  1085. g.drawLine( 1, 1, 13, 1); // top
  1086. g.drawLine(14, 2, 14,14); // right
  1087. g.drawLine( 1,14, 14,14); // bottom
  1088. g.drawLine( 1, 1, 1,14); // left
  1089. // Draw grey-ish highlights
  1090. g.setColor(MetalLookAndFeel.getControlDarkShadow());
  1091. g.fillRect(5,2, 6,5); // metal disk protector part
  1092. g.drawLine(4,8, 11,8); // top of label
  1093. g.drawLine(3,9, 3,13); // left of label
  1094. g.drawLine(12,9, 12,13); // right of label
  1095. // Draw label and exposed disk
  1096. g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
  1097. g.fillRect(8,3, 2,3); // exposed disk
  1098. g.fillRect(4,9, 8,5); // label
  1099. // Draw text on label
  1100. g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
  1101. g.drawLine(5,10, 9,10);
  1102. g.drawLine(5,12, 8,12);
  1103. g.translate(-x, -y);
  1104. }
  1105. public int getIconWidth() {
  1106. return 16;
  1107. }
  1108. public int getIconHeight() {
  1109. return 16;
  1110. }
  1111. } // End class TreeFloppyDriveIcon
  1112. static private final Dimension folderIcon16Size = new Dimension( 16, 16 );
  1113. /**
  1114. * <p>
  1115. * <strong>Warning:</strong>
  1116. * Serialized objects of this class will not be compatible with
  1117. * future Swing releases. The current serialization support is appropriate
  1118. * for short term storage or RMI between applications running the same
  1119. * version of Swing. A future release of Swing will provide support for
  1120. * long term persistence.
  1121. */
  1122. public static class FolderIcon16 implements Icon, Serializable {
  1123. transient Image image;
  1124. public void paintIcon(Component c, Graphics g, int x, int y) {
  1125. if (image == null) {
  1126. image = new BufferedImage(getIconWidth(), getIconHeight(),
  1127. BufferedImage.TYPE_INT_ARGB);
  1128. Graphics imageG = image.getGraphics();
  1129. paintMe(c,imageG);
  1130. imageG.dispose();
  1131. }
  1132. g.drawImage(image, x, y+getShift(), null);
  1133. }
  1134. private void paintMe(Component c, Graphics g) {
  1135. int right = folderIcon16Size.width - 1;
  1136. int bottom = folderIcon16Size.height - 1;
  1137. // Draw tab top
  1138. g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
  1139. g.drawLine( right - 5, 3, right, 3 );
  1140. g.drawLine( right - 6, 4, right, 4 );
  1141. // Draw folder front
  1142. g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1143. g.fillRect( 2, 7, 13, 8 );
  1144. // Draw tab bottom
  1145. g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
  1146. g.drawLine( right - 6, 5, right - 1, 5 );
  1147. // Draw outline
  1148. g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1149. g.drawLine( 0, 6, 0, bottom ); // left side
  1150. g.drawLine( 1, 5, right - 7, 5 ); // first part of top
  1151. g.drawLine( right - 6, 6, right - 1, 6 ); // second part of top
  1152. g.drawLine( right, 5, right, bottom ); // right side
  1153. g.drawLine( 0, bottom, right, bottom ); // bottom
  1154. // Draw highlight
  1155. g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
  1156. g.drawLine( 1, 6, 1, bottom - 1 );
  1157. g.drawLine( 1, 6, right - 7, 6 );
  1158. g.drawLine( right - 6, 7, right - 1, 7 );
  1159. }
  1160. public int getShift() { return 0; }
  1161. public int getAdditionalHeight() { return 0; }
  1162. public int getIconWidth() { return folderIcon16Size.width; }
  1163. public int getIconHeight() { return folderIcon16Size.height + getAdditionalHeight(); }
  1164. }
  1165. /**
  1166. * <p>
  1167. * <strong>Warning:</strong>
  1168. * Serialized objects of this class will not be compatible with
  1169. * future Swing releases. The current serialization support is appropriate
  1170. * for short term storage or RMI between applications running the same
  1171. * version of Swing. A future release of Swing will provide support for
  1172. * long term persistence.
  1173. */
  1174. public static class TreeFolderIcon extends FolderIcon16 {
  1175. public int getShift() { return -1; }
  1176. public int getAdditionalHeight() { return 2; }
  1177. }
  1178. static private final Dimension fileIcon16Size = new Dimension( 16, 16 );
  1179. /**
  1180. * <p>
  1181. * <strong>Warning:</strong>
  1182. * Serialized objects of this class will not be compatible with
  1183. * future Swing releases. The current serialization support is appropriate
  1184. * for short term storage or RMI between applications running the same
  1185. * version of Swing. A future release of Swing will provide support for
  1186. * long term persistence.
  1187. */
  1188. public static class FileIcon16 implements Icon, Serializable {
  1189. transient Image image;
  1190. public void paintIcon(Component c, Graphics g, int x, int y) {
  1191. if (image == null) {
  1192. image = new BufferedImage(getIconWidth(), getIconHeight(),
  1193. BufferedImage.TYPE_INT_ARGB);
  1194. Graphics imageG = image.getGraphics();
  1195. paintMe(c,imageG);
  1196. imageG.dispose();
  1197. }
  1198. g.drawImage(image, x, y+getShift(), null);
  1199. }
  1200. private void paintMe(Component c, Graphics g) {
  1201. int right = fileIcon16Size.width - 1;
  1202. int bottom = fileIcon16Size.height - 1;
  1203. // Draw fill
  1204. g.setColor( MetalLookAndFeel.getWindowBackground() );
  1205. g.fillRect( 4, 2, 9, 12 );
  1206. // Draw frame
  1207. g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1208. g.drawLine( 2, 0, 2, bottom ); // left
  1209. g.drawLine( 2, 0, right - 4, 0 ); // top
  1210. g.drawLine( 2, bottom, right - 1, bottom ); // bottom
  1211. g.drawLine( right - 1, 6, right - 1, bottom ); // right
  1212. g.drawLine( right - 6, 2, right - 2, 6 ); // slant 1
  1213. g.drawLine( right - 5, 1, right - 4, 1 ); // part of slant 2
  1214. g.drawLine( right - 3, 2, right - 3, 3 ); // part of slant 2
  1215. g.drawLine( right - 2, 4, right - 2, 5 ); // part of slant 2
  1216. // Draw highlight
  1217. g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1218. g.drawLine( 3, 1, 3, bottom - 1 ); // left
  1219. g.drawLine( 3, 1, right - 6, 1 ); // top
  1220. g.drawLine( right - 2, 7, right - 2, bottom - 1 ); // right
  1221. g.drawLine( right - 5, 2, right - 3, 4 ); // slant
  1222. g.drawLine( 3, bottom - 1, right - 2, bottom - 1 ); // bottom
  1223. }
  1224. public int getShift() { return 0; }
  1225. public int getAdditionalHeight() { return 0; }
  1226. public int getIconWidth() { return fileIcon16Size.width; }
  1227. public int getIconHeight() { return fileIcon16Size.height + getAdditionalHeight(); }
  1228. }
  1229. public static class TreeLeafIcon extends FileIcon16 {
  1230. public int getShift() { return 2; }
  1231. public int getAdditionalHeight() { return 4; }
  1232. }
  1233. static private final Dimension treeControlSize = new Dimension( 18, 18 );
  1234. /**
  1235. * <p>
  1236. * <strong>Warning:</strong>
  1237. * Serialized objects of this class will not be compatible with
  1238. * future Swing releases. The current serialization support is appropriate
  1239. * for short term storage or RMI between applications running the same
  1240. * version of Swing. A future release of Swing will provide support for
  1241. * long term persistence.
  1242. */
  1243. public static class TreeControlIcon implements Icon, Serializable {
  1244. // This data member should not have been exposed. It's called
  1245. // isLight, but now it really means isCollapsed. Since we can't change
  1246. // any APIs... that's life.
  1247. protected boolean isLight;
  1248. public TreeControlIcon( boolean isCollapsed ) {
  1249. isLight = isCollapsed;
  1250. }
  1251. transient Image image;
  1252. transient boolean cachedOrientation = true;
  1253. public void paintIcon(Component c, Graphics g, int x, int y) {
  1254. if (image == null || cachedOrientation != MetalUtils.isLeftToRight(c)) {
  1255. cachedOrientation = MetalUtils.isLeftToRight(c);
  1256. image = new BufferedImage(getIconWidth(), getIconHeight(),
  1257. BufferedImage.TYPE_INT_ARGB);
  1258. Graphics imageG = image.getGraphics();
  1259. paintMe(c,imageG,x,y);
  1260. imageG.dispose();
  1261. }
  1262. if (MetalUtils.isLeftToRight(c)) {
  1263. if (isLight) { // isCollapsed
  1264. g.drawImage(image, x+5, y+3, x+18, y+13,
  1265. 4,3, 17, 13, null);
  1266. }
  1267. else {
  1268. g.drawImage(image, x+5, y+3, x+18, y+17,
  1269. 4,3, 17, 17, null);
  1270. }
  1271. }
  1272. else {
  1273. if (isLight) { // isCollapsed
  1274. g.drawImage(image, x+3, y+3, x+16, y+13,
  1275. 4, 3, 17, 13, null);
  1276. }
  1277. else {
  1278. g.drawImage(image, x+3, y+3, x+16, y+17,
  1279. 4, 3, 17, 17, null);
  1280. }
  1281. }
  1282. }
  1283. public void paintMe(Component c, Graphics g, int x, int y) {
  1284. g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1285. int xoff = (MetalUtils.isLeftToRight(c)) ? 0 : 4;
  1286. // Draw circle
  1287. g.drawLine( xoff + 4, 6, xoff + 4, 9 ); // left
  1288. g.drawLine( xoff + 5, 5, xoff + 5, 5 ); // top left dot
  1289. g.drawLine( xoff + 6, 4, xoff + 9, 4 ); // top
  1290. g.drawLine( xoff + 10, 5, xoff + 10, 5 ); // top right dot
  1291. g.drawLine( xoff + 11, 6, xoff + 11, 9 ); // right
  1292. g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // botom right dot
  1293. g.drawLine( xoff + 6, 11, xoff + 9, 11 ); // bottom
  1294. g.drawLine( xoff + 5, 10, xoff + 5, 10 ); // bottom left dot
  1295. // Draw Center Dot
  1296. g.drawLine( xoff + 7, 7, xoff + 8, 7 );
  1297. g.drawLine( xoff + 7, 8, xoff + 8, 8 );
  1298. // Draw Handle
  1299. if ( isLight ) { // isCollapsed
  1300. if( MetalUtils.isLeftToRight(c) ) {
  1301. g.drawLine( 12, 7, 15, 7 );
  1302. g.drawLine( 12, 8, 15, 8 );
  1303. // g.setColor( c.getBackground() );
  1304. // g.drawLine( 16, 7, 16, 8 );
  1305. }
  1306. else {
  1307. g.drawLine(4, 7, 7, 7);
  1308. g.drawLine(4, 8, 7, 8);
  1309. }
  1310. }
  1311. else {
  1312. g.drawLine( xoff + 7, 12, xoff + 7, 15 );
  1313. g.drawLine( xoff + 8, 12, xoff + 8, 15 );
  1314. // g.setColor( c.getBackground() );
  1315. // g.drawLine( xoff + 7, 16, xoff + 8, 16 );
  1316. }
  1317. // Draw Fill
  1318. g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
  1319. g.drawLine( xoff + 5, 6, xoff + 5, 9 ); // left shadow
  1320. g.drawLine( xoff + 6, 5, xoff + 9, 5 ); // top shadow
  1321. g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
  1322. g.drawLine( xoff + 6, 6, xoff + 6, 6 ); // top left fill
  1323. g.drawLine( xoff + 9, 6, xoff + 9, 6 ); // top right fill
  1324. g.drawLine( xoff + 6, 9, xoff + 6, 9 ); // bottom left fill
  1325. g.drawLine( xoff + 10, 6, xoff + 10, 9 ); // right fill
  1326. g.drawLine( xoff + 6, 10, xoff + 9, 10 ); // bottom fill
  1327. g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1328. g.drawLine( xoff + 6, 7, xoff + 6, 8 ); // left highlight
  1329. g.drawLine( xoff + 7, 6, xoff + 8, 6 ); // top highlight
  1330. g.drawLine( xoff + 9, 7, xoff + 9, 7 ); // right highlight
  1331. g.drawLine( xoff + 7, 9, xoff + 7, 9 ); // bottom highlight
  1332. g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
  1333. g.drawLine( xoff + 8, 9, xoff + 9, 9 );
  1334. g.drawLine( xoff + 9, 8, xoff + 9, 8 );
  1335. }
  1336. public int getIconWidth() { return treeControlSize.width; }
  1337. public int getIconHeight() { return treeControlSize.height; }
  1338. }
  1339. //
  1340. // Menu Icons
  1341. //
  1342. static private final Dimension menuArrowIconSize = new Dimension( 4, 8 );
  1343. static private final Dimension menuCheckIconSize = new Dimension( 10, 10 );
  1344. static private final int xOff = 4;
  1345. private static class MenuArrowIcon implements Icon, UIResource, Serializable
  1346. {
  1347. public void paintIcon( Component c, Graphics g, int x, int y )
  1348. {
  1349. JMenuItem b = (JMenuItem) c;
  1350. ButtonModel model = b.getModel();
  1351. g.translate( x, y );
  1352. if ( !model.isEnabled() )
  1353. {
  1354. g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
  1355. }
  1356. else
  1357. {
  1358. if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
  1359. {
  1360. g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
  1361. }
  1362. else
  1363. {
  1364. g.setColor( b.getForeground() );
  1365. }
  1366. }
  1367. if( MetalUtils.isLeftToRight(b) ) {
  1368. g.drawLine( 0, 0, 0, 7 );
  1369. g.drawLine( 1, 1, 1, 6 );
  1370. g.drawLine( 2, 2, 2, 5 );
  1371. g.drawLine( 3, 3, 3, 4 );
  1372. } else {
  1373. g.drawLine( 4, 0, 4, 7 );
  1374. g.drawLine( 3, 1, 3, 6 );
  1375. g.drawLine( 2, 2, 2, 5 );
  1376. g.drawLine( 1, 3, 1, 4 );
  1377. }
  1378. g.translate( -x, -y );
  1379. }
  1380. public int getIconWidth() { return menuArrowIconSize.width; }
  1381. public int getIconHeight() { return menuArrowIconSize.height; }
  1382. } // End class MenuArrowIcon
  1383. private static class MenuItemCheckIcon implements Icon, UIResource, Serializable
  1384. {
  1385. public void paintIcon( Component c, Graphics g, int x, int y )
  1386. {
  1387. }
  1388. public int getIconWidth() { return menuCheckIconSize.width; }
  1389. public int getIconHeight() { return menuCheckIconSize.height; }
  1390. } // End class MenuItemCheckIcon
  1391. private static class MenuItemArrowIcon implements Icon, UIResource, Serializable
  1392. {
  1393. public void paintIcon( Component c, Graphics g, int x, int y )
  1394. {
  1395. }
  1396. public int getIconWidth() { return menuArrowIconSize.width; }
  1397. public int getIconHeight() { return menuArrowIconSize.height; }
  1398. } // End class MenuItemArrowIcon
  1399. private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
  1400. {
  1401. public void paintIcon( Component c, Graphics g, int x, int y )
  1402. {
  1403. JMenuItem b = (JMenuItem) c;
  1404. ButtonModel model = b.getModel();
  1405. boolean isSelected = model.isSelected();
  1406. boolean isEnabled = model.isEnabled();
  1407. boolean isPressed = model.isPressed();
  1408. boolean isArmed = model.isArmed();
  1409. g.translate( x, y );
  1410. if ( isEnabled )
  1411. {
  1412. if ( isPressed || isArmed )
  1413. {
  1414. g.setColor( MetalLookAndFeel.getControlInfo() );
  1415. g.drawLine( 0, 0, 8, 0 );
  1416. g.drawLine( 0, 0, 0, 8 );
  1417. g.drawLine( 8, 2, 8, 8 );
  1418. g.drawLine( 2, 8, 8, 8 );
  1419. g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1420. g.drawLine( 1, 1, 7, 1 );
  1421. g.drawLine( 1, 1, 1, 7 );
  1422. g.drawLine( 9, 1, 9, 9 );
  1423. g.drawLine( 1, 9, 9, 9 );
  1424. }
  1425. else
  1426. {
  1427. g.setColor( MetalLookAndFeel.getControlDarkShadow() );
  1428. g.drawLine( 0, 0, 8, 0 );
  1429. g.drawLine( 0, 0, 0, 8 );
  1430. g.drawLine( 8, 2, 8, 8 );
  1431. g.drawLine( 2, 8, 8, 8 );
  1432. g.setColor( MetalLookAndFeel.getControlHighlight() );
  1433. g.drawLine( 1, 1, 7, 1 );
  1434. g.drawLine( 1, 1, 1, 7 );
  1435. g.drawLine( 9, 1, 9, 9 );
  1436. g.drawLine( 1, 9, 9, 9 );
  1437. }
  1438. }
  1439. else
  1440. {
  1441. g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
  1442. g.drawRect( 0, 0, 8, 8 );
  1443. }
  1444. if ( isSelected )
  1445. {
  1446. if ( isEnabled )
  1447. {
  1448. if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
  1449. {
  1450. g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
  1451. }
  1452. else
  1453. {
  1454. g.setColor( b.getForeground() );
  1455. }
  1456. }
  1457. else
  1458. {
  1459. g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
  1460. }
  1461. g.drawLine( 2, 2, 2, 6 );
  1462. g.drawLine( 3, 2, 3, 6 );
  1463. g.drawLine( 4, 4, 8, 0 );
  1464. g.drawLine( 4, 5, 9, 0 );
  1465. }
  1466. g.translate( -x, -y );
  1467. }
  1468. public int getIconWidth() { return menuCheckIconSize.width; }
  1469. public int getIconHeight() { return menuCheckIconSize.height; }
  1470. } // End class CheckBoxMenuItemIcon
  1471. private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
  1472. {
  1473. public void paintIcon( Component c, Graphics g, int x, int y )
  1474. {
  1475. JMenuItem b = (JMenuItem) c;
  1476. ButtonModel model = b.getModel();
  1477. boolean isSelected = model.isSelected();
  1478. boolean isEnabled = model.isEnabled();
  1479. boolean isPressed = model.isPressed();
  1480. boolean isArmed = model.isArmed();
  1481. g.translate( x, y );
  1482. if ( isEnabled )
  1483. {
  1484. if ( isPressed || isArmed )
  1485. {
  1486. g.setColor( MetalLookAndFeel.getPrimaryControl() );
  1487. g.drawLine( 3, 1, 8, 1 );
  1488. g.drawLine( 2, 9, 7, 9 );
  1489. g.drawLine( 1, 3, 1, 8 );
  1490. g.drawLine( 9, 2, 9, 7 );
  1491. g.drawLine( 2, 2, 2, 2 );
  1492. g.drawLine( 8, 8, 8, 8 );
  1493. g.setColor( MetalLookAndFeel.getControlInfo() );
  1494. g.drawLine( 2, 0, 6, 0 );
  1495. g.drawLine( 2, 8, 6, 8 );
  1496. g.drawLine( 0, 2, 0, 6 );
  1497. g.drawLine( 8, 2, 8, 6 );
  1498. g.drawLine( 1, 1, 1, 1 );
  1499. g.drawLine( 7, 1, 7, 1 );
  1500. g.drawLine( 1, 7, 1, 7 );
  1501. g.drawLine( 7, 7, 7, 7 );
  1502. }
  1503. else
  1504. {
  1505. g.setColor( MetalLookAndFeel.getControlHighlight() );
  1506. g.drawLine( 3, 1, 8, 1 );
  1507. g.drawLine( 2, 9, 7, 9 );
  1508. g.drawLine( 1, 3, 1, 8 );
  1509. g.drawLine( 9, 2, 9, 7 );
  1510. g.drawLine( 2, 2, 2, 2 );
  1511. g.drawLine( 8, 8, 8, 8 );
  1512. g.setColor( MetalLookAndFeel.getControlDarkShadow() );
  1513. g.drawLine( 2, 0, 6, 0 );
  1514. g.drawLine( 2, 8, 6, 8 );
  1515. g.drawLine( 0, 2, 0, 6 );
  1516. g.drawLine( 8, 2, 8, 6 );
  1517. g.drawLine( 1, 1, 1, 1 );
  1518. g.drawLine( 7, 1, 7, 1 );
  1519. g.drawLine( 1, 7, 1, 7 );
  1520. g.drawLine( 7, 7, 7, 7 );
  1521. }
  1522. }
  1523. else
  1524. {
  1525. g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
  1526. g.drawLine( 2, 0, 6, 0 );
  1527. g.drawLine( 2, 8, 6, 8 );
  1528. g.drawLine( 0, 2, 0, 6 );
  1529. g.drawLine( 8, 2, 8, 6 );
  1530. g.drawLine( 1, 1, 1, 1 );
  1531. g.drawLine( 7, 1, 7, 1 );
  1532. g.drawLine( 1, 7, 1, 7 );
  1533. g.drawLine( 7, 7, 7, 7 );
  1534. }
  1535. if ( isSelected )
  1536. {
  1537. if ( isEnabled )
  1538. {
  1539. if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
  1540. {
  1541. g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
  1542. }
  1543. else
  1544. {
  1545. g.setColor( b.getForeground() );
  1546. }
  1547. }
  1548. else
  1549. {
  1550. g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
  1551. }
  1552. g.drawLine( 3, 2, 5, 2 );
  1553. g.drawLine( 2, 3, 6, 3 );
  1554. g.drawLine( 2, 4, 6, 4 );
  1555. g.drawLine( 2, 5, 6, 5 );
  1556. g.drawLine( 3, 6, 5, 6 );
  1557. }
  1558. g.translate( -x, -y );
  1559. }
  1560. public int getIconWidth() { return menuCheckIconSize.width; }
  1561. public int getIconHeight() { return menuCheckIconSize.height; }
  1562. } // End class RadioButtonMenuItemIcon
  1563. private static class VerticalSliderThumbIcon implements Icon, Serializable, UIResource {
  1564. protected static MetalBumps controlBumps;
  1565. protected static MetalBumps primaryBumps;
  1566. public VerticalSliderThumbIcon() {
  1567. controlBumps = new MetalBumps( 6, 10,
  1568. MetalLookAndFeel.getControlHighlight(),
  1569. MetalLookAndFeel.getControlInfo(),
  1570. MetalLookAndFeel.getControl() );
  1571. primaryBumps = new MetalBumps( 6, 10,
  1572. MetalLookAndFeel.getPrimaryControl(),
  1573. MetalLookAndFeel.getPrimaryControlDarkShadow(),
  1574. MetalLookAndFeel.getPrimaryControlShadow() );
  1575. }
  1576. public void paintIcon( Component c, Graphics g, int x, int y ) {
  1577. JSlider slider = (JSlider)c;
  1578. boolean leftToRight = MetalUtils.isLeftToRight(slider);
  1579. g.translate( x, y );
  1580. // Draw the frame
  1581. if ( slider.hasFocus() ) {
  1582. g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1583. }
  1584. else {
  1585. g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
  1586. MetalLookAndFeel.getControlDarkShadow() );
  1587. }
  1588. if (leftToRight) {
  1589. g.drawLine( 1,0 , 8,0 ); // top
  1590. g.drawLine( 0,1 , 0,13 ); // left
  1591. g.drawLine( 1,14 , 8,14 ); // bottom
  1592. g.drawLine( 9,1 , 15,7 ); // top slant
  1593. g.drawLine( 9,13 , 15,7 ); // bottom slant
  1594. }
  1595. else {
  1596. g.drawLine( 7,0 , 14,0 ); // top
  1597. g.drawLine( 15,1 , 15,13 ); // right
  1598. g.drawLine( 7,14 , 14,14 ); // bottom
  1599. g.drawLine( 0,7 , 6,1 ); // top slant
  1600. g.drawLine( 0,7 , 6,13 ); // bottom slant
  1601. }
  1602. // Fill in the background
  1603. if ( slider.hasFocus() ) {
  1604. g.setColor( c.getForeground() );
  1605. }
  1606. else {
  1607. g.setColor( MetalLookAndFeel.getControl() );
  1608. }
  1609. if (leftToRight) {
  1610. g.fillRect( 1,1 , 8,13 );
  1611. g.drawLine( 9,2 , 9,12 );
  1612. g.drawLine( 10,3 , 10,11 );
  1613. g.drawLine( 11,4 , 11,10 );
  1614. g.drawLine( 12,5 , 12,9 );
  1615. g.drawLine( 13,6 , 13,8 );
  1616. g.drawLine( 14,7 , 14,7 );
  1617. }
  1618. else {
  1619. g.fillRect( 7,1, 8,13 );
  1620. g.drawLine( 6,3 , 6,12 );
  1621. g.drawLine( 5,4 , 5,11 );
  1622. g.drawLine( 4,5 , 4,10 );
  1623. g.drawLine( 3,6 , 3,9 );
  1624. g.drawLine( 2,7 , 2,8 );
  1625. }
  1626. // Draw the bumps
  1627. int offset = (leftToRight) ? 2 : 8;
  1628. if ( slider.isEnabled() ) {
  1629. if ( slider.hasFocus() ) {
  1630. primaryBumps.paintIcon( c, g, offset, 2 );
  1631. }
  1632. else {
  1633. controlBumps.paintIcon( c, g, offset, 2 );
  1634. }
  1635. }
  1636. // Draw the highlight
  1637. if ( slider.isEnabled() ) {
  1638. g.setColor( slider.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
  1639. : MetalLookAndFeel.getControlHighlight() );
  1640. if (leftToRight) {
  1641. g.drawLine( 1, 1, 8, 1 );
  1642. g.drawLine( 1, 1, 1, 13 );
  1643. }
  1644. else {
  1645. g.drawLine( 8,1 , 14,1 ); // top
  1646. g.drawLine( 1,7 , 7,1 ); // top slant
  1647. }
  1648. }
  1649. g.translate( -x, -y );
  1650. }
  1651. public int getIconWidth() {
  1652. return 16;
  1653. }
  1654. public int getIconHeight() {
  1655. return 15;
  1656. }
  1657. }
  1658. private static class HorizontalSliderThumbIcon implements Icon, Serializable, UIResource {
  1659. protected static MetalBumps controlBumps;
  1660. protected static MetalBumps primaryBumps;
  1661. public HorizontalSliderThumbIcon() {
  1662. controlBumps = new MetalBumps( 10, 6,
  1663. MetalLookAndFeel.getControlHighlight(),
  1664. MetalLookAndFeel.getControlInfo(),
  1665. MetalLookAndFeel.getControl() );
  1666. primaryBumps = new MetalBumps( 10, 6,
  1667. MetalLookAndFeel.getPrimaryControl(),
  1668. MetalLookAndFeel.getPrimaryControlDarkShadow(),
  1669. MetalLookAndFeel.getPrimaryControlShadow() );
  1670. }
  1671. public void paintIcon( Component c, Graphics g, int x, int y ) {
  1672. JSlider slider = (JSlider)c;
  1673. g.translate( x, y );
  1674. // Draw the frame
  1675. if ( slider.hasFocus() ) {
  1676. g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
  1677. }
  1678. else {
  1679. g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
  1680. MetalLookAndFeel.getControlDarkShadow() );
  1681. }
  1682. g.drawLine( 1,0 , 13,0 ); // top
  1683. g.drawLine( 0,1 , 0,8 ); // left
  1684. g.drawLine( 14,1 , 14,8 ); // right
  1685. g.drawLine( 1,9 , 7,15 ); // left slant
  1686. g.drawLine( 7,15 , 14,8 ); // right slant
  1687. // Fill in the background
  1688. if ( slider.hasFocus() ) {
  1689. g.setColor( c.getForeground() );
  1690. }
  1691. else {
  1692. g.setColor( MetalLookAndFeel.getControl() );
  1693. }
  1694. g.fillRect( 1,1, 13, 8 );
  1695. g.drawLine( 2,9 , 12,9 );
  1696. g.drawLine( 3,10 , 11,10 );
  1697. g.drawLine( 4,11 , 10,11 );
  1698. g.drawLine( 5,12 , 9,12 );
  1699. g.drawLine( 6,13 , 8,13 );
  1700. g.drawLine( 7,14 , 7,14 );
  1701. // Draw the bumps
  1702. if ( slider.isEnabled() ) {
  1703. if ( slider.hasFocus() ) {
  1704. primaryBumps.paintIcon( c, g, 2, 2 );
  1705. }
  1706. else {
  1707. controlBumps.paintIcon( c, g, 2, 2 );
  1708. }
  1709. }
  1710. // Draw the highlight
  1711. if ( slider.isEnabled() ) {
  1712. g.setColor( slider.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
  1713. : MetalLookAndFeel.getControlHighlight() );
  1714. g.drawLine( 1, 1, 13, 1 );
  1715. g.drawLine( 1, 1, 1, 8 );
  1716. }
  1717. g.translate( -x, -y );
  1718. }
  1719. public int getIconWidth() {
  1720. return 15;
  1721. }
  1722. public int getIconHeight() {
  1723. return 16;
  1724. }
  1725. }
  1726. }