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