KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > plaf > metal > MetalIconFactory


1 /*
2  * @(#)MetalIconFactory.java 1.60 04/02/15
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.plaf.metal;
9
10 import javax.swing.*;
11 import javax.swing.plaf.UIResource JavaDoc;
12 import java.awt.*;
13 import java.awt.image.BufferedImage JavaDoc;
14 import java.io.Serializable JavaDoc;
15 import java.util.Enumeration JavaDoc;
16 import java.util.Vector JavaDoc;
17
18 /**
19  * Factory object that vends <code>Icon</code>s for
20  * the Java<sup><font size="-2">TM</font></sup> look and feel (Metal).
21  * These icons are used extensively in Metal via the defaults mechanism.
22  * While other look and feels often use GIFs for icons, creating icons
23  * in code facilitates switching to other themes.
24  *
25  * <p>
26  * Each method in this class returns
27  * either an <code>Icon</code> or <code>null</code>,
28  * where <code>null</code> implies that there is no default icon.
29  *
30  * <p>
31  * <strong>Warning:</strong>
32  * Serialized objects of this class will not be compatible with
33  * future Swing releases. The current serialization support is
34  * appropriate for short term storage or RMI between applications running
35  * the same version of Swing. As of 1.4, support for long term storage
36  * of all JavaBeans<sup><font size="-2">TM</font></sup>
37  * has been added to the <code>java.beans</code> package.
38  * Please see {@link java.beans.XMLEncoder}.
39  *
40  * @version 1.60 02/15/04
41  * @author Michael C. Albers
42  */

43 public class MetalIconFactory implements Serializable JavaDoc {
44
45     // List of code-drawn Icons
46
private static Icon fileChooserDetailViewIcon;
47     private static Icon fileChooserHomeFolderIcon;
48     private static Icon fileChooserListViewIcon;
49     private static Icon fileChooserNewFolderIcon;
50     private static Icon fileChooserUpFolderIcon;
51     private static Icon internalFrameAltMaximizeIcon;
52     private static Icon internalFrameCloseIcon;
53     private static Icon internalFrameDefaultMenuIcon;
54     private static Icon internalFrameMaximizeIcon;
55     private static Icon internalFrameMinimizeIcon;
56     private static Icon radioButtonIcon;
57     private static Icon treeComputerIcon;
58     private static Icon treeFloppyDriveIcon;
59     private static Icon treeHardDriveIcon;
60
61
62     private static Icon menuArrowIcon;
63     private static Icon menuItemArrowIcon;
64     private static Icon checkBoxMenuItemIcon;
65     private static Icon radioButtonMenuItemIcon;
66     private static Icon checkBoxIcon;
67
68
69     // Ocean icons
70
private static Icon oceanHorizontalSliderThumb;
71     private static Icon oceanVerticalSliderThumb;
72
73     // Constants
74
public static final boolean DARK = false;
75     public static final boolean LIGHT = true;
76
77     // Accessor functions for Icons. Does the caching work.
78
public static Icon getFileChooserDetailViewIcon() {
79     if (fileChooserDetailViewIcon == null) {
80         fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
81     }
82     return fileChooserDetailViewIcon;
83     }
84
85     public static Icon getFileChooserHomeFolderIcon() {
86     if (fileChooserHomeFolderIcon == null) {
87         fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
88     }
89     return fileChooserHomeFolderIcon;
90     }
91
92     public static Icon getFileChooserListViewIcon() {
93     if (fileChooserListViewIcon == null) {
94         fileChooserListViewIcon = new FileChooserListViewIcon();
95     }
96     return fileChooserListViewIcon;
97     }
98
99     public static Icon getFileChooserNewFolderIcon() {
100     if (fileChooserNewFolderIcon == null) {
101         fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
102     }
103     return fileChooserNewFolderIcon;
104     }
105
106     public static Icon getFileChooserUpFolderIcon() {
107     if (fileChooserUpFolderIcon == null) {
108         fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
109     }
110     return fileChooserUpFolderIcon;
111     }
112
113     public static Icon getInternalFrameAltMaximizeIcon(int size) {
114     return new InternalFrameAltMaximizeIcon(size);
115     }
116
117     public static Icon getInternalFrameCloseIcon(int size) {
118     return new InternalFrameCloseIcon(size);
119     }
120
121     public static Icon getInternalFrameDefaultMenuIcon() {
122     if (internalFrameDefaultMenuIcon == null) {
123         internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
124     }
125     return internalFrameDefaultMenuIcon;
126     }
127
128     public static Icon getInternalFrameMaximizeIcon(int size) {
129     return new InternalFrameMaximizeIcon(size);
130     }
131
132     public static Icon getInternalFrameMinimizeIcon(int size) {
133     return new InternalFrameMinimizeIcon(size);
134     }
135
136     public static Icon getRadioButtonIcon() {
137     if (radioButtonIcon == null) {
138         radioButtonIcon = new RadioButtonIcon();
139     }
140     return radioButtonIcon;
141     }
142
143     /**
144      * Returns a checkbox icon.
145      * @since 1.3
146      */

147     public static Icon getCheckBoxIcon() {
148     if (checkBoxIcon == null) {
149         checkBoxIcon = new CheckBoxIcon();
150     }
151     return checkBoxIcon;
152     }
153
154     public static Icon getTreeComputerIcon() {
155         if ( treeComputerIcon == null ) {
156         treeComputerIcon = new TreeComputerIcon();
157     }
158     return treeComputerIcon;
159     }
160
161     public static Icon getTreeFloppyDriveIcon() {
162         if ( treeFloppyDriveIcon == null ) {
163         treeFloppyDriveIcon = new TreeFloppyDriveIcon();
164     }
165     return treeFloppyDriveIcon;
166     }
167
168     public static Icon getTreeFolderIcon() {
169     return new TreeFolderIcon();
170     }
171
172     public static Icon getTreeHardDriveIcon() {
173         if ( treeHardDriveIcon == null ) {
174         treeHardDriveIcon = new TreeHardDriveIcon();
175     }
176     return treeHardDriveIcon;
177     }
178
179     public static Icon getTreeLeafIcon() {
180     return new TreeLeafIcon();
181     }
182
183     public static Icon getTreeControlIcon( boolean isCollapsed ) {
184         return new TreeControlIcon( isCollapsed );
185     }
186
187     public static Icon getMenuArrowIcon() {
188     if (menuArrowIcon == null) {
189         menuArrowIcon = new MenuArrowIcon();
190     }
191     return menuArrowIcon;
192     }
193
194     /**
195      * Returns an icon to be used by <code>JCheckBoxMenuItem</code>.
196      *
197      * @return the default icon for check box menu items,
198      * or <code>null</code> if no default exists
199      */

200     public static Icon getMenuItemCheckIcon() {
201         return null;
202     }
203
204     public static Icon getMenuItemArrowIcon() {
205     if (menuItemArrowIcon == null) {
206         menuItemArrowIcon = new MenuItemArrowIcon();
207     }
208     return menuItemArrowIcon;
209     }
210
211     public static Icon getCheckBoxMenuItemIcon() {
212     if (checkBoxMenuItemIcon == null) {
213         checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
214     }
215     return checkBoxMenuItemIcon;
216     }
217
218     public static Icon getRadioButtonMenuItemIcon() {
219     if (radioButtonMenuItemIcon == null) {
220         radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
221     }
222     return radioButtonMenuItemIcon;
223     }
224
225     public static Icon getHorizontalSliderThumbIcon() {
226         if (MetalLookAndFeel.usingOcean()) {
227             if (oceanHorizontalSliderThumb == null) {
228                 oceanHorizontalSliderThumb =
229                                new OceanHorizontalSliderThumbIcon();
230             }
231             return oceanHorizontalSliderThumb;
232         }
233       // don't cache these, bumps don't get updated otherwise
234
return new HorizontalSliderThumbIcon();
235     }
236
237     public static Icon getVerticalSliderThumbIcon() {
238         if (MetalLookAndFeel.usingOcean()) {
239             if (oceanVerticalSliderThumb == null) {
240                 oceanVerticalSliderThumb = new OceanVerticalSliderThumbIcon();
241             }
242             return oceanVerticalSliderThumb;
243         }
244         // don't cache these, bumps don't get updated otherwise
245
return new VerticalSliderThumbIcon();
246     }
247
248     // File Chooser Detail View code
249
private static class FileChooserDetailViewIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
250         public void paintIcon(Component c, Graphics g, int x, int y) {
251         g.translate(x, y);
252
253         // Draw outside edge of each of the documents
254
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
255         // top
256
g.drawLine(2,2, 5,2); // top
257
g.drawLine(2,3, 2,7); // left
258
g.drawLine(3,7, 6,7); // bottom
259
g.drawLine(6,6, 6,3); // right
260
// bottom
261
g.drawLine(2,10, 5,10); // top
262
g.drawLine(2,11, 2,15); // left
263
g.drawLine(3,15, 6,15); // bottom
264
g.drawLine(6,14, 6,11); // right
265

266         // Draw little dots next to documents
267
// Same color as outside edge
268
g.drawLine(8,5, 15,5); // top
269
g.drawLine(8,13, 15,13); // bottom
270

271         // Draw inner highlight on documents
272
g.setColor(MetalLookAndFeel.getPrimaryControl());
273         g.drawRect(3,3, 2,3); // top
274
g.drawRect(3,11, 2,3); // bottom
275

276         // Draw inner inner highlight on documents
277
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
278         g.drawLine(4,4, 4,5); // top
279
g.drawLine(4,12, 4,13); // bottom
280

281         g.translate(-x, -y);
282     }
283     
284     public int getIconWidth() {
285         return 18;
286     }
287     
288     public int getIconHeight() {
289         return 18;
290     }
291     } // End class FileChooserDetailViewIcon
292

293     // File Chooser Home Folder code
294
private static class FileChooserHomeFolderIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
295         public void paintIcon(Component c, Graphics g, int x, int y) {
296         g.translate(x, y);
297
298         // Draw outside edge of house
299
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
300         g.drawLine(8,1, 1,8); // left edge of roof
301
g.drawLine(8,1, 15,8); // right edge of roof
302
g.drawLine(11,2, 11,3); // left edge of chimney
303
g.drawLine(12,2, 12,4); // right edge of chimney
304
g.drawLine(3,7, 3,15); // left edge of house
305
g.drawLine(13,7, 13,15); // right edge of house
306
g.drawLine(4,15, 12,15); // bottom edge of house
307
// Draw door frame
308
// same color as edge of house
309
g.drawLine( 6,9, 6,14); // left
310
g.drawLine(10,9, 10,14); // right
311
g.drawLine( 7,9, 9, 9); // top
312

313         // Draw roof body
314
g.setColor(MetalLookAndFeel.getControlDarkShadow());
315         g.fillRect(8,2, 1,1); //top toward bottom
316
g.fillRect(7,3, 3,1);
317         g.fillRect(6,4, 5,1);
318         g.fillRect(5,5, 7,1);
319         g.fillRect(4,6, 9,2);
320         // Draw doornob
321
// same color as roof body
322
g.drawLine(9,12, 9,12);
323
324         // Paint the house
325
g.setColor(MetalLookAndFeel.getPrimaryControl());
326         g.drawLine(4,8, 12,8); // above door
327
g.fillRect(4,9, 2,6); // left of door
328
g.fillRect(11,9, 2,6); // right of door
329

330         g.translate(-x, -y);
331     }
332     
333     public int getIconWidth() {
334         return 18;
335     }
336     
337     public int getIconHeight() {
338         return 18;
339     }
340     } // End class FileChooserHomeFolderIcon
341

342     // File Chooser List View code
343
private static class FileChooserListViewIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
344         public void paintIcon(Component c, Graphics g, int x, int y) {
345         g.translate(x, y);
346
347         // Draw outside edge of each of the documents
348
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
349         // top left
350
g.drawLine(2,2, 5,2); // top
351
g.drawLine(2,3, 2,7); // left
352
g.drawLine(3,7, 6,7); // bottom
353
g.drawLine(6,6, 6,3); // right
354
// top right
355
g.drawLine(10,2, 13,2); // top
356
g.drawLine(10,3, 10,7); // left
357
g.drawLine(11,7, 14,7); // bottom
358
g.drawLine(14,6, 14,3); // right
359
// bottom left
360
g.drawLine(2,10, 5,10); // top
361
g.drawLine(2,11, 2,15); // left
362
g.drawLine(3,15, 6,15); // bottom
363
g.drawLine(6,14, 6,11); // right
364
// bottom right
365
g.drawLine(10,10, 13,10); // top
366
g.drawLine(10,11, 10,15); // left
367
g.drawLine(11,15, 14,15); // bottom
368
g.drawLine(14,14, 14,11); // right
369

370         // Draw little dots next to documents
371
// Same color as outside edge
372
g.drawLine(8,5, 8,5); // top left
373
g.drawLine(16,5, 16,5); // top right
374
g.drawLine(8,13, 8,13); // bottom left
375
g.drawLine(16,13, 16,13); // bottom right
376

377         // Draw inner highlight on documents
378
g.setColor(MetalLookAndFeel.getPrimaryControl());
379         g.drawRect(3,3, 2,3); // top left
380
g.drawRect(11,3, 2,3); // top right
381
g.drawRect(3,11, 2,3); // bottom left
382
g.drawRect(11,11, 2,3); // bottom right
383

384         // Draw inner inner highlight on documents
385
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
386         g.drawLine(4,4, 4,5); // top left
387
g.drawLine(12,4, 12,5); // top right
388
g.drawLine(4,12, 4,13); // bottom left
389
g.drawLine(12,12, 12,13); // bottom right
390

391         g.translate(-x, -y);
392     }
393     
394     public int getIconWidth() {
395         return 18;
396     }
397     
398     public int getIconHeight() {
399         return 18;
400     }
401     } // End class FileChooserListViewIcon
402

403     // File Chooser New Folder code
404
private static class FileChooserNewFolderIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
405         public void paintIcon(Component c, Graphics g, int x, int y) {
406         g.translate(x, y);
407
408         // Fill background
409
g.setColor(MetalLookAndFeel.getPrimaryControl());
410         g.fillRect(3,5, 12,9);
411
412         // Draw outside edge of folder
413
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
414         g.drawLine(1,6, 1,14); // left
415
g.drawLine(2,14, 15,14); // bottom
416
g.drawLine(15,13, 15,5); // right
417
g.drawLine(2,5, 9,5); // top left
418
g.drawLine(10,6, 14,6); // top right
419

420         // Draw inner folder highlight
421
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
422         g.drawLine( 2,6, 2,13); // left
423
g.drawLine( 3,6, 9,6); // top left
424
g.drawLine(10,7, 14,7); // top right
425

426         // Draw tab on folder
427
g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
428         g.drawLine(11,3, 15,3); // top
429
g.drawLine(10,4, 15,4); // bottom
430

431         g.translate(-x, -y);
432     }
433     
434     public int getIconWidth() {
435         return 18;
436     }
437     
438     public int getIconHeight() {
439         return 18;
440     }
441     } // End class FileChooserNewFolderIcon
442

443     // File Chooser Up Folder code
444
private static class FileChooserUpFolderIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
445         public void paintIcon(Component c, Graphics g, int x, int y) {
446         g.translate(x, y);
447
448         // Fill background
449
g.setColor(MetalLookAndFeel.getPrimaryControl());
450         g.fillRect(3,5, 12,9);
451
452         // Draw outside edge of folder
453
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
454         g.drawLine(1,6, 1,14); // left
455
g.drawLine(2,14, 15,14); // bottom
456
g.drawLine(15,13, 15,5); // right
457
g.drawLine(2,5, 9,5); // top left
458
g.drawLine(10,6, 14,6); // top right
459
// Draw the UP arrow
460
// same color as edge
461
g.drawLine(8,13, 8,16); // arrow shaft
462
g.drawLine(8, 9, 8, 9); // arrowhead top
463
g.drawLine(7,10, 9,10);
464         g.drawLine(6,11, 10,11);
465         g.drawLine(5,12, 11,12);
466
467         // Draw inner folder highlight
468
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
469         g.drawLine( 2,6, 2,13); // left
470
g.drawLine( 3,6, 9,6); // top left
471
g.drawLine(10,7, 14,7); // top right
472

473         // Draw tab on folder
474
g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
475         g.drawLine(11,3, 15,3); // top
476
g.drawLine(10,4, 15,4); // bottom
477

478         g.translate(-x, -y);
479     }
480     
481     public int getIconWidth() {
482         return 18;
483     }
484     
485     public int getIconHeight() {
486         return 18;
487     }
488     } // End class FileChooserUpFolderIcon
489

490
491     /**
492      * Defines an icon for Palette close
493      * @since 1.3
494      */

495     public static class PaletteCloseIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc{
496         int iconSize = 7;
497
498         public void paintIcon(Component c, Graphics g, int x, int y) {
499         JButton parentButton = (JButton)c;
500         ButtonModel buttonModel = parentButton.getModel();
501
502         Color back;
503         Color highlight = MetalLookAndFeel.getPrimaryControlHighlight();
504         Color shadow = MetalLookAndFeel.getPrimaryControlInfo();
505         if (buttonModel.isPressed() && buttonModel.isArmed()) {
506             back = shadow;
507         } else {
508             back = MetalLookAndFeel.getPrimaryControlDarkShadow();
509         }
510
511         g.translate(x, y);
512         g.setColor(back);
513         g.drawLine( 0, 1, 5, 6);
514         g.drawLine( 1, 0, 6, 5);
515         g.drawLine( 1, 1, 6, 6);
516         g.drawLine( 6, 1, 1, 6);
517         g.drawLine( 5,0, 0,5);
518         g.drawLine(5,1, 1,5);
519        
520         g.setColor(highlight);
521         g.drawLine(6,2, 5,3);
522         g.drawLine(2,6, 3, 5);
523         g.drawLine(6,6,6,6);
524
525
526         g.translate(-x, -y);
527     }
528
529     public int getIconWidth() {
530         return iconSize;
531     }
532     
533     public int getIconHeight() {
534         return iconSize;
535     }
536     }
537
538     // Internal Frame Close code
539
private static class InternalFrameCloseIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
540     int iconSize = 16;
541     
542         public InternalFrameCloseIcon(int size) {
543         iconSize = size;
544     }
545     
546         public void paintIcon(Component c, Graphics g, int x, int y) {
547         JButton parentButton = (JButton)c;
548         ButtonModel buttonModel = parentButton.getModel();
549
550         Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
551         Color internalBackgroundColor =
552         MetalLookAndFeel.getPrimaryControl();
553         Color mainItemColor =
554         MetalLookAndFeel.getPrimaryControlDarkShadow();
555         Color darkHighlightColor = MetalLookAndFeel.getBlack();
556         Color xLightHighlightColor = MetalLookAndFeel.getWhite();
557         Color boxLightHighlightColor = MetalLookAndFeel.getWhite();
558         
559         // if the inactive window
560
if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
561         {
562         backgroundColor = MetalLookAndFeel.getControl();
563         internalBackgroundColor = backgroundColor;
564         mainItemColor = MetalLookAndFeel.getControlDarkShadow();
565         // if inactive and pressed
566
if (buttonModel.isPressed() && buttonModel.isArmed()) {
567             internalBackgroundColor =
568             MetalLookAndFeel.getControlShadow();
569             xLightHighlightColor = internalBackgroundColor;
570             mainItemColor = darkHighlightColor;
571         }
572         }
573         // if pressed
574
else if (buttonModel.isPressed() && buttonModel.isArmed()) {
575         internalBackgroundColor =
576             MetalLookAndFeel.getPrimaryControlShadow();
577         xLightHighlightColor = internalBackgroundColor;
578         mainItemColor = darkHighlightColor;
579         // darkHighlightColor is still "getBlack()"
580
}
581
582         // Some calculations that are needed more than once later on.
583
int oneHalf = (int)(iconSize / 2); // 16 -> 8
584

585         g.translate(x, y);
586
587         // fill background
588
g.setColor(backgroundColor);
589         g.fillRect(0,0, iconSize,iconSize);
590         
591         // fill inside of box area
592
g.setColor(internalBackgroundColor);
593         g.fillRect(3,3, iconSize-6,iconSize-6);
594
595         // THE BOX
596
// the top/left dark higlight - some of this will get overwritten
597
g.setColor(darkHighlightColor);
598         g.drawRect(1,1, iconSize-3,iconSize-3);
599         // draw the inside bottom/right highlight
600
g.drawRect(2,2, iconSize-5,iconSize-5);
601         // draw the light/outside, bottom/right highlight
602
g.setColor(boxLightHighlightColor);
603         g.drawRect(2,2, iconSize-3,iconSize-3);
604         // draw the "normal" box
605
g.setColor(mainItemColor);
606         g.drawRect(2,2, iconSize-4,iconSize-4);
607         g.drawLine(3,iconSize-3, 3,iconSize-3); // lower left
608
g.drawLine(iconSize-3,3, iconSize-3,3); // up right
609

610         // THE "X"
611
// Dark highlight
612
g.setColor(darkHighlightColor);
613         g.drawLine(4,5, 5,4); // far up left
614
g.drawLine(4,iconSize-6, iconSize-6,4); // against body of "X"
615
// Light highlight
616
g.setColor(xLightHighlightColor);
617         g.drawLine(6,iconSize-5, iconSize-5,6); // against body of "X"
618
// one pixel over from the body
619
g.drawLine(oneHalf,oneHalf+2, oneHalf+2,oneHalf);
620           // bottom right
621
g.drawLine(iconSize-5,iconSize-5, iconSize-4,iconSize-5);
622         g.drawLine(iconSize-5,iconSize-4, iconSize-5,iconSize-4);
623         // Main color
624
g.setColor(mainItemColor);
625           // Upper left to lower right
626
g.drawLine(5,5, iconSize-6,iconSize-6); // g.drawLine(5,5, 10,10);
627
g.drawLine(6,5, iconSize-5,iconSize-6); // g.drawLine(6,5, 11,10);
628
g.drawLine(5,6, iconSize-6,iconSize-5); // g.drawLine(5,6, 10,11);
629
// Lower left to upper right
630
g.drawLine(5,iconSize-5, iconSize-5,5); // g.drawLine(5,11, 11,5);
631
g.drawLine(5,iconSize-6, iconSize-6,5); // g.drawLine(5,10, 10,5);
632

633         g.translate(-x, -y);
634     }
635     
636     public int getIconWidth() {
637         return iconSize;
638     }
639
640     public int getIconHeight() {
641         return iconSize;
642     }
643     } // End class InternalFrameCloseIcon
644

645     // Internal Frame Alternate Maximize code (actually, the un-maximize icon)
646
private static class InternalFrameAltMaximizeIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
647     int iconSize = 16;
648
649         public InternalFrameAltMaximizeIcon(int size) {
650         iconSize = size;
651     }
652
653         public void paintIcon(Component c, Graphics g, int x, int y) {
654         JButton parentButton = (JButton)c;
655         ButtonModel buttonModel = parentButton.getModel();
656
657         Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
658         Color internalBackgroundColor =
659         MetalLookAndFeel.getPrimaryControl();
660         Color mainItemColor =
661         MetalLookAndFeel.getPrimaryControlDarkShadow();
662         Color darkHighlightColor = MetalLookAndFeel.getBlack();
663         // ul = Upper Left and lr = Lower Right
664
Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
665         Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
666         
667         // if the internal frame is inactive
668
if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
669         {
670         backgroundColor = MetalLookAndFeel.getControl();
671         internalBackgroundColor = backgroundColor;
672         mainItemColor = MetalLookAndFeel.getControlDarkShadow();
673         // if inactive and pressed
674
if (buttonModel.isPressed() && buttonModel.isArmed()) {
675             internalBackgroundColor =
676             MetalLookAndFeel.getControlShadow();
677             ulLightHighlightColor = internalBackgroundColor;
678             mainItemColor = darkHighlightColor;
679         }
680         }
681         // if the button is pressed and the mouse is over it
682
else if (buttonModel.isPressed() && buttonModel.isArmed()) {
683         internalBackgroundColor =
684             MetalLookAndFeel.getPrimaryControlShadow();
685         ulLightHighlightColor = internalBackgroundColor;
686         mainItemColor = darkHighlightColor;
687         // darkHighlightColor is still "getBlack()"
688
}
689
690         g.translate(x, y);
691
692         // fill background
693
g.setColor(backgroundColor);
694         g.fillRect(0,0, iconSize,iconSize);
695
696         // BOX
697
// fill inside the box
698
g.setColor(internalBackgroundColor);
699         g.fillRect(3,6, iconSize-9,iconSize-9);
700
701         // draw dark highlight color
702
g.setColor(darkHighlightColor);
703         g.drawRect(1,5, iconSize-8,iconSize-8);
704         g.drawLine(1,iconSize-2, 1,iconSize-2); // extra pixel on bottom
705

706         // draw lower right light highlight
707
g.setColor(lrLightHighlightColor);
708         g.drawRect(2,6, iconSize-7,iconSize-7);
709         // draw upper left light highlight
710
g.setColor(ulLightHighlightColor);
711         g.drawRect(3,7, iconSize-9,iconSize-9);
712
713         // draw the main box
714
g.setColor(mainItemColor);
715         g.drawRect(2,6, iconSize-8,iconSize-8);
716
717         // Six extraneous pixels to deal with
718
g.setColor(ulLightHighlightColor);
719         g.drawLine(iconSize-6,8,iconSize-6,8);
720         g.drawLine(iconSize-9,6, iconSize-7,8);
721         g.setColor(mainItemColor);
722         g.drawLine(3,iconSize-3,3,iconSize-3);
723         g.setColor(darkHighlightColor);
724         g.drawLine(iconSize-6,9,iconSize-6,9);
725         g.setColor(backgroundColor);
726         g.drawLine(iconSize-9,5,iconSize-9,5);
727
728         // ARROW
729
// do the shaft first
730
g.setColor(mainItemColor);
731         g.fillRect(iconSize-7,3, 3,5); // do a big block
732
g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
733
g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
734
g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
735

736         // draw the dark highlight
737
g.setColor(darkHighlightColor);
738         g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
739
g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
740
g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
741
g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
742

743         // draw the light highlight
744
g.setColor(lrLightHighlightColor);
745         g.drawLine(iconSize-6,3, iconSize-6,3); // top
746
g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
747
g.drawLine(iconSize-4,8, iconSize-3,8); // under arrowhead
748
g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
749

750         g.translate(-x, -y);
751     }
752     
753     public int getIconWidth() {
754         return iconSize;
755     }
756     
757     public int getIconHeight() {
758         return iconSize;
759     }
760     } // End class InternalFrameAltMaximizeIcon
761

762     // Code for the default icons that goes in the upper left corner
763
private static class InternalFrameDefaultMenuIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
764         public void paintIcon(Component c, Graphics g, int x, int y) {
765
766         Color windowBodyColor = MetalLookAndFeel.getWindowBackground();
767         Color titleColor = MetalLookAndFeel.getPrimaryControl();
768         Color edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
769
770         g.translate(x, y);
771
772         // draw background color for title area
773
// catch four corners and title area
774
g.setColor(titleColor);
775         g.fillRect(0,0, 16,16);
776
777         // fill body of window
778
g.setColor(windowBodyColor);
779         g.fillRect(2,6, 13,9);
780         // draw light parts of two "bumps"
781
g.drawLine(2,2, 2,2);
782         g.drawLine(5,2, 5,2);
783         g.drawLine(8,2, 8,2);
784         g.drawLine(11,2, 11,2);
785         
786         // draw line around edge of title and icon
787
g.setColor(edgeColor);
788         g.drawRect(1,1, 13,13); // entire inner edge
789
g.drawLine(1,0, 14,0); // top outter edge
790
g.drawLine(15,1, 15,14); // right outter edge
791
g.drawLine(1,15, 14,15); // bottom outter edge
792
g.drawLine(0,1, 0,14); // left outter edge
793
g.drawLine(2,5, 13,5); // bottom of title bar area
794
// draw dark part of four "bumps" (same color)
795
g.drawLine(3,3, 3,3);
796         g.drawLine(6,3, 6,3);
797         g.drawLine(9,3, 9,3);
798         g.drawLine(12,3, 12,3);
799
800         g.translate(-x, -y);
801     }
802     
803     public int getIconWidth() {
804         return 16;
805     }
806     
807     public int getIconHeight() {
808         return 16;
809     }
810     } // End class InternalFrameDefaultMenuIcon
811

812     // Internal Frame Maximize code
813
private static class InternalFrameMaximizeIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
814     protected int iconSize = 16;
815
816         public InternalFrameMaximizeIcon(int size) {
817         iconSize = size;
818     }
819
820         public void paintIcon(Component c, Graphics g, int x, int y) {
821         JButton parentButton = (JButton)c;
822         ButtonModel buttonModel = parentButton.getModel();
823
824         Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
825         Color internalBackgroundColor =
826         MetalLookAndFeel.getPrimaryControl();
827         Color mainItemColor =
828         MetalLookAndFeel.getPrimaryControlDarkShadow();
829         Color darkHighlightColor = MetalLookAndFeel.getBlack();
830         // ul = Upper Left and lr = Lower Right
831
Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
832         Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
833         
834         // if the internal frame is inactive
835
if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
836         {
837         backgroundColor = MetalLookAndFeel.getControl();
838         internalBackgroundColor = backgroundColor;
839         mainItemColor = MetalLookAndFeel.getControlDarkShadow();
840         // if inactive and pressed
841
if (buttonModel.isPressed() && buttonModel.isArmed()) {
842             internalBackgroundColor =
843             MetalLookAndFeel.getControlShadow();
844             ulLightHighlightColor = internalBackgroundColor;
845             mainItemColor = darkHighlightColor;
846         }
847         }
848         // if the button is pressed and the mouse is over it
849
else if (buttonModel.isPressed() && buttonModel.isArmed()) {
850         internalBackgroundColor =
851             MetalLookAndFeel.getPrimaryControlShadow();
852         ulLightHighlightColor = internalBackgroundColor;
853         mainItemColor = darkHighlightColor;
854         // darkHighlightColor is still "getBlack()"
855
}
856
857         g.translate(x, y);
858
859         // fill background
860
g.setColor(backgroundColor);
861         g.fillRect(0,0, iconSize,iconSize);
862
863         // BOX drawing
864
// fill inside the box
865
g.setColor(internalBackgroundColor);
866         g.fillRect(3,7, iconSize-10,iconSize-10);
867
868         // light highlight
869
g.setColor(ulLightHighlightColor);
870         g.drawRect(3,7, iconSize-10,iconSize-10); // up,left
871
g.setColor(lrLightHighlightColor);
872         g.drawRect(2,6, iconSize-7,iconSize-7); // low,right
873
// dark highlight
874
g.setColor(darkHighlightColor);
875         g.drawRect(1,5, iconSize-7,iconSize-7); // outer
876
g.drawRect(2,6, iconSize-9,iconSize-9); // inner
877
// main box
878
g.setColor(mainItemColor);
879         g.drawRect(2,6, iconSize-8,iconSize-8); // g.drawRect(2,6, 8,8);
880

881         // ARROW drawing
882
// dark highlight
883
g.setColor(darkHighlightColor);
884           // down,left to up,right - inside box
885
g.drawLine(3,iconSize-5, iconSize-9,7);
886           // down,left to up,right - outside box
887
g.drawLine(iconSize-6,4, iconSize-5,3);
888           // outside edge of arrow head
889
g.drawLine(iconSize-7,1, iconSize-7,2);
890           // outside edge of arrow head
891
g.drawLine(iconSize-6,1, iconSize-2,1);
892         // light highlight
893
g.setColor(ulLightHighlightColor);
894           // down,left to up,right - inside box
895
g.drawLine(5,iconSize-4, iconSize-8,9);
896         g.setColor(lrLightHighlightColor);
897         g.drawLine(iconSize-6,3, iconSize-4,5); // outside box
898
g.drawLine(iconSize-4,5, iconSize-4,6); // one down from this
899
g.drawLine(iconSize-2,7, iconSize-1,7); // outside edge arrow head
900
g.drawLine(iconSize-1,2, iconSize-1,6); // outside edge arrow head
901
// main part of arrow
902
g.setColor(mainItemColor);
903         g.drawLine(3,iconSize-4, iconSize-3,2); // top edge of staff
904
g.drawLine(3,iconSize-3, iconSize-2,2); // bottom edge of staff
905
g.drawLine(4,iconSize-3, 5,iconSize-3); // highlights inside of box
906
g.drawLine(iconSize-7,8, iconSize-7,9); // highlights inside of box
907
g.drawLine(iconSize-6,2, iconSize-4,2); // top of arrow head
908
g.drawRect(iconSize-3,3, 1,3); // right of arrow head
909

910         g.translate(-x, -y);
911     }
912     
913     public int getIconWidth() {
914         return iconSize;
915     }
916     
917     public int getIconHeight() {
918         return iconSize;
919     }
920     } // End class InternalFrameMaximizeIcon
921

922     // Internal Frame Minimize code
923
private static class InternalFrameMinimizeIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
924     int iconSize = 16;
925
926         public InternalFrameMinimizeIcon(int size) {
927         iconSize = size;
928     }
929
930         public void paintIcon(Component c, Graphics g, int x, int y) {
931         JButton parentButton = (JButton)c;
932         ButtonModel buttonModel = parentButton.getModel();
933
934
935         Color backgroundColor = MetalLookAndFeel.getPrimaryControl();
936         Color internalBackgroundColor =
937         MetalLookAndFeel.getPrimaryControl();
938         Color mainItemColor =
939         MetalLookAndFeel.getPrimaryControlDarkShadow();
940         Color darkHighlightColor = MetalLookAndFeel.getBlack();
941         // ul = Upper Left and lr = Lower Right
942
Color ulLightHighlightColor = MetalLookAndFeel.getWhite();
943         Color lrLightHighlightColor = MetalLookAndFeel.getWhite();
944         
945         // if the internal frame is inactive
946
if (parentButton.getClientProperty("paintActive") != Boolean.TRUE)
947         {
948         backgroundColor = MetalLookAndFeel.getControl();
949         internalBackgroundColor = backgroundColor;
950         mainItemColor = MetalLookAndFeel.getControlDarkShadow();
951         // if inactive and pressed
952
if (buttonModel.isPressed() && buttonModel.isArmed()) {
953             internalBackgroundColor =
954             MetalLookAndFeel.getControlShadow();
955             ulLightHighlightColor = internalBackgroundColor;
956             mainItemColor = darkHighlightColor;
957         }
958         }
959         // if the button is pressed and the mouse is over it
960
else if (buttonModel.isPressed() && buttonModel.isArmed()) {
961         internalBackgroundColor =
962             MetalLookAndFeel.getPrimaryControlShadow();
963         ulLightHighlightColor = internalBackgroundColor;
964         mainItemColor = darkHighlightColor;
965         // darkHighlightColor is still "getBlack()"
966
}
967
968         g.translate(x, y);
969
970         // fill background
971
g.setColor(backgroundColor);
972         g.fillRect(0,0, iconSize,iconSize);
973
974         // BOX drawing
975
// fill inside the box
976
g.setColor(internalBackgroundColor);
977         g.fillRect(4,11, iconSize-13,iconSize-13);
978         // light highlight
979
g.setColor(lrLightHighlightColor);
980         g.drawRect(2,10, iconSize-10,iconSize-11); // low,right
981
g.setColor(ulLightHighlightColor);
982         g.drawRect(3,10, iconSize-12,iconSize-12); // up,left
983
// dark highlight
984
g.setColor(darkHighlightColor);
985         g.drawRect(1,8, iconSize-10,iconSize-10); // outer
986
g.drawRect(2,9, iconSize-12,iconSize-12); // inner
987
// main box
988
g.setColor(mainItemColor);
989         g.drawRect(2,9, iconSize-11,iconSize-11);
990         g.drawLine(iconSize-10,10, iconSize-10,10); // up right highlight
991
g.drawLine(3,iconSize-3, 3,iconSize-3); // low left highlight
992

993         // ARROW
994
// do the shaft first
995
g.setColor(mainItemColor);
996         g.fillRect(iconSize-7,3, 3,5); // do a big block
997
g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft
998
g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft
999
g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head
1000

1001        // draw the dark highlight
1002
g.setColor(darkHighlightColor);
1003        g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead
1004
g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead
1005
g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft
1006
g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead
1007

1008        // draw the light highlight
1009
g.setColor(lrLightHighlightColor);
1010        g.drawLine(iconSize-6,3, iconSize-6,3); // top
1011
g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft
1012
g.drawLine(iconSize-7,8, iconSize-3,8); // under arrowhead
1013
g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead
1014

1015        g.translate(-x, -y);
1016    }
1017    
1018    public int getIconWidth() {
1019        return iconSize;
1020    }
1021    
1022    public int getIconHeight() {
1023        return iconSize;
1024    }
1025    } // End class InternalFrameMinimizeIcon
1026

1027    private static class CheckBoxIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
1028    
1029    protected int getControlSize() { return 13; }
1030    
1031    private void paintOceanIcon(Component c, Graphics g, int x, int y) {
1032        ButtonModel model = ((JCheckBox)c).getModel();
1033
1034            g.translate(x, y);
1035            int w = getIconWidth();
1036            int h = getIconHeight();
1037        if ( model.isEnabled() ) {
1038        if (model.isPressed() && model.isArmed()) {
1039                    g.setColor(MetalLookAndFeel.getControlShadow());
1040                    g.fillRect(0, 0, w, h);
1041                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
1042                    g.fillRect(0, 0, w, 2);
1043                    g.fillRect(0, 2, 2, h - 2);
1044                    g.fillRect(w - 1, 1, 1, h - 1);
1045                    g.fillRect(1, h - 1, w - 2, 1);
1046        } else if (model.isRollover()) {
1047                    MetalUtils.drawGradient(c, g, "CheckBox.gradient", 0, 0,
1048                                            w, h, true);
1049                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
1050                    g.drawRect(0, 0, w - 1, h - 1);
1051                    g.setColor(MetalLookAndFeel.getPrimaryControl());
1052                    g.drawRect(1, 1, w - 3, h - 3);
1053                    g.drawRect(2, 2, w - 5, h - 5);
1054                }
1055                else {
1056                    MetalUtils.drawGradient(c, g, "CheckBox.gradient", 0, 0,
1057                                            w, h, true);
1058                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
1059                    g.drawRect(0, 0, w - 1, h - 1);
1060        }
1061        g.setColor( MetalLookAndFeel.getControlInfo() );
1062        } else {
1063                g.setColor(MetalLookAndFeel.getControlDarkShadow());
1064                g.drawRect(0, 0, w - 1, h - 1);
1065        }
1066            g.translate(-x, -y);
1067        if (model.isSelected()) {
1068        drawCheck(c,g,x,y);
1069        }
1070    }
1071
1072    public void paintIcon(Component c, Graphics g, int x, int y) {
1073        if (MetalLookAndFeel.usingOcean()) {
1074                paintOceanIcon(c, g, x, y);
1075                return;
1076            }
1077        ButtonModel model = ((JCheckBox)c).getModel();
1078        int controlSize = getControlSize();
1079        
1080        if ( model.isEnabled() ) {
1081        if (model.isPressed() && model.isArmed()) {
1082            g.setColor( MetalLookAndFeel.getControlShadow() );
1083            g.fillRect( x, y, controlSize-1, controlSize-1);
1084            MetalUtils.drawPressed3DBorder(g, x, y, controlSize, controlSize);
1085        } else {
1086            MetalUtils.drawFlush3DBorder(g, x, y, controlSize, controlSize);
1087        }
1088        g.setColor( MetalLookAndFeel.getControlInfo() );
1089        } else {
1090            g.setColor( MetalLookAndFeel.getControlShadow() );
1091            g.drawRect( x, y, controlSize-2, controlSize-2);
1092        }
1093        
1094        if (model.isSelected()) {
1095        drawCheck(c,g,x,y);
1096        }
1097        
1098    }
1099    
1100    protected void drawCheck(Component c, Graphics g, int x, int y) {
1101        int controlSize = getControlSize();
1102        g.fillRect( x+3, y+5, 2, controlSize-8 );
1103        g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) );
1104        g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) );
1105    }
1106    
1107    public int getIconWidth() {
1108        return getControlSize();
1109    }
1110    
1111    public int getIconHeight() {
1112        return getControlSize();
1113    }
1114    } // End class CheckBoxIcon
1115

1116    // Radio button code
1117
private static class RadioButtonIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
1118        public void paintOceanIcon(Component c, Graphics g, int x, int y) {
1119        ButtonModel model = ((JRadioButton)c).getModel();
1120            boolean enabled = model.isEnabled();
1121            boolean pressed = (enabled && model.isPressed() &&
1122                               model.isArmed());
1123            boolean rollover = (enabled && model.isRollover());
1124
1125        g.translate(x, y);
1126            if (enabled && !pressed) {
1127                // PENDING: this isn't quite right, when we're sure it won't
1128
// change it needs to be cleaned.
1129
MetalUtils.drawGradient(c, g, "RadioButton.gradient",
1130                                        1, 1, 10, 10, true);
1131                g.setColor(c.getBackground());
1132                g.fillRect(1, 1, 1, 1);
1133                g.fillRect(10, 1, 1, 1);
1134                g.fillRect(1, 10, 1, 1);
1135                g.fillRect(10, 10, 1, 1);
1136            }
1137            else if (pressed || !enabled) {
1138                if (pressed) {
1139                    g.setColor(MetalLookAndFeel.getPrimaryControl());
1140                }
1141                else {
1142                    g.setColor(MetalLookAndFeel.getControl());
1143                }
1144                g.fillRect(2, 2, 8, 8);
1145                g.fillRect(4, 1, 4, 1);
1146                g.fillRect(4, 10, 4, 1);
1147                g.fillRect(1, 4, 1, 4);
1148                g.fillRect(10, 4, 1, 4);
1149            }
1150
1151        // draw Dark Circle (start at top, go clockwise)
1152
if (!enabled) {
1153                g.setColor(MetalLookAndFeel.getInactiveControlTextColor());
1154        }
1155        else {
1156                g.setColor(MetalLookAndFeel.getControlDarkShadow());
1157        }
1158        g.drawLine( 4, 0, 7, 0);
1159        g.drawLine( 8, 1, 9, 1);
1160        g.drawLine(10, 2, 10, 3);
1161        g.drawLine(11, 4, 11, 7);
1162        g.drawLine(10, 8, 10, 9);
1163        g.drawLine( 9,10, 8,10);
1164        g.drawLine( 7,11, 4,11);
1165        g.drawLine( 3,10, 2,10);
1166        g.drawLine( 1, 9, 1, 8);
1167        g.drawLine( 0, 7, 0, 4);
1168        g.drawLine( 1, 3, 1, 2);
1169        g.drawLine( 2, 1, 3, 1);
1170
1171            if (pressed) {
1172                g.fillRect(1, 4, 1, 4);
1173                g.fillRect(2, 2, 1, 2);
1174                g.fillRect(3, 2, 1, 1);
1175                g.fillRect(4, 1, 4, 1);
1176            }
1177            else if (rollover) {
1178                g.setColor(MetalLookAndFeel.getPrimaryControl());
1179                g.fillRect(4, 1, 4, 2);
1180                g.fillRect(8, 2, 2, 2);
1181                g.fillRect(9, 4, 2, 4);
1182                g.fillRect(8, 8, 2, 2);
1183                g.fillRect(4, 9, 4, 2);
1184                g.fillRect(2, 8, 2, 2);
1185                g.fillRect(1, 4, 2, 4);
1186                g.fillRect(2, 2, 2, 2);
1187            }
1188
1189            // selected dot
1190
if (model.isSelected()) {
1191                if (enabled) {
1192                    g.setColor(c.getForeground());
1193                } else {
1194                    g.setColor(MetalLookAndFeel.getControlDarkShadow());
1195                }
1196                g.fillRect(4, 4, 4, 4);
1197                g.drawLine(4, 3, 7, 3);
1198                g.drawLine(8, 4, 8, 7);
1199                g.drawLine(7, 8, 4, 8);
1200                g.drawLine(3, 7, 3, 4);
1201            }
1202
1203        g.translate(-x, -y);
1204    }
1205
1206        public void paintIcon(Component c, Graphics g, int x, int y) {
1207            if (MetalLookAndFeel.usingOcean()) {
1208                paintOceanIcon(c, g, x, y);
1209                return;
1210            }
1211        JRadioButton rb = (JRadioButton)c;
1212        ButtonModel model = rb.getModel();
1213        boolean drawDot = model.isSelected();
1214
1215        Color background = c.getBackground();
1216        Color dotColor = c.getForeground();
1217        Color shadow = MetalLookAndFeel.getControlShadow();
1218        Color darkCircle = MetalLookAndFeel.getControlDarkShadow();
1219        Color whiteInnerLeftArc = MetalLookAndFeel.getControlHighlight();
1220        Color whiteOuterRightArc = MetalLookAndFeel.getControlHighlight();
1221        Color interiorColor = background;
1222
1223        // Set up colors per RadioButtonModel condition
1224
if ( !model.isEnabled() ) {
1225        whiteInnerLeftArc = whiteOuterRightArc = background;
1226        darkCircle = dotColor = shadow;
1227        }
1228        else if (model.isPressed() && model.isArmed() ) {
1229        whiteInnerLeftArc = interiorColor = shadow;
1230        }
1231        
1232        g.translate(x, y);
1233
1234        // fill interior
1235
g.setColor(interiorColor);
1236        g.fillRect(2,2, 9,9);
1237       
1238        // draw Dark Circle (start at top, go clockwise)
1239
g.setColor(darkCircle);
1240        g.drawLine( 4, 0, 7, 0);
1241        g.drawLine( 8, 1, 9, 1);
1242        g.drawLine(10, 2, 10, 3);
1243        g.drawLine(11, 4, 11, 7);
1244        g.drawLine(10, 8, 10, 9);
1245        g.drawLine( 9,10, 8,10);
1246        g.drawLine( 7,11, 4,11);
1247        g.drawLine( 3,10, 2,10);
1248        g.drawLine( 1, 9, 1, 8);
1249        g.drawLine( 0, 7, 0, 4);
1250        g.drawLine( 1, 3, 1, 2);
1251        g.drawLine( 2, 1, 3, 1);
1252
1253        // draw Inner Left (usually) White Arc
1254
// start at lower left corner, go clockwise
1255
g.setColor(whiteInnerLeftArc);
1256        g.drawLine( 2, 9, 2, 8);
1257        g.drawLine( 1, 7, 1, 4);
1258        g.drawLine( 2, 2, 2, 3);
1259        g.drawLine( 2, 2, 3, 2);
1260        g.drawLine( 4, 1, 7, 1);
1261        g.drawLine( 8, 2, 9, 2);
1262        // draw Outer Right White Arc
1263
// start at upper right corner, go clockwise
1264
g.setColor(whiteOuterRightArc);
1265        g.drawLine(10, 1, 10, 1);
1266        g.drawLine(11, 2, 11, 3);
1267        g.drawLine(12, 4, 12, 7);
1268        g.drawLine(11, 8, 11, 9);
1269        g.drawLine(10,10, 10,10);
1270        g.drawLine( 9,11, 8,11);
1271        g.drawLine( 7,12, 4,12);
1272        g.drawLine( 3,11, 2,11);
1273
1274        // selected dot
1275
if ( drawDot ) {
1276        g.setColor(dotColor);
1277        g.fillRect( 4, 4, 4, 4);
1278        g.drawLine( 4, 3, 7, 3);
1279        g.drawLine( 8, 4, 8, 7);
1280        g.drawLine( 7, 8, 4, 8);
1281        g.drawLine( 3, 7, 3, 4);
1282        }
1283
1284        g.translate(-x, -y);
1285    }
1286    
1287    public int getIconWidth() {
1288        return 13;
1289    }
1290    
1291    public int getIconHeight() {
1292        return 13;
1293    }
1294    } // End class RadioButtonIcon
1295

1296    // Tree Computer Icon code
1297
private static class TreeComputerIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
1298        public void paintIcon(Component c, Graphics g, int x, int y) {
1299        g.translate(x, y);
1300
1301        // Fill glass portion of monitor
1302
g.setColor(MetalLookAndFeel.getPrimaryControl());
1303        g.fillRect(5,4, 6,4);
1304
1305        // Draw outside edge of monitor
1306
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
1307        g.drawLine( 2,2, 2,8); // left
1308
g.drawLine(13,2, 13,8); // right
1309
g.drawLine( 3,1, 12,1); // top
1310
g.drawLine(12,9, 12,9); // bottom right base
1311
g.drawLine( 3,9, 3,9); // bottom left base
1312
// Draw the edge of the glass
1313
g.drawLine( 4,4, 4,7); // left
1314
g.drawLine( 5,3, 10,3); // top
1315
g.drawLine(11,4, 11,7); // right
1316
g.drawLine( 5,8, 10,8); // bottom
1317
// Draw the edge of the CPU
1318
g.drawLine( 1,10, 14,10); // top
1319
g.drawLine(14,10, 14,14); // right
1320
g.drawLine( 1,14, 14,14); // bottom
1321
g.drawLine( 1,10, 1,14); // left
1322

1323        // Draw the disk drives
1324
g.setColor(MetalLookAndFeel.getControlDarkShadow());
1325        g.drawLine( 6,12, 8,12); // left
1326
g.drawLine(10,12, 12,12); // right
1327

1328        g.translate(-x, -y);
1329    }
1330    
1331    public int getIconWidth() {
1332        return 16;
1333    }
1334    
1335    public int getIconHeight() {
1336        return 16;
1337    }
1338    } // End class TreeComputerIcon
1339

1340    // Tree HardDrive Icon code
1341
private static class TreeHardDriveIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
1342        public void paintIcon(Component c, Graphics g, int x, int y) {
1343        g.translate(x, y);
1344
1345        // Draw edges of the disks
1346
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
1347        // top disk
1348
g.drawLine(1,4, 1,5); // left
1349
g.drawLine(2,3, 3,3);
1350        g.drawLine(4,2, 11,2); // top
1351
g.drawLine(12,3, 13,3);
1352        g.drawLine(14,4, 14,5); // right
1353
g.drawLine(12,6, 13,6);
1354        g.drawLine(4,7, 11,7); // bottom
1355
g.drawLine(2,6, 3,6);
1356        // middle disk
1357
g.drawLine(1,7, 1,8); // left
1358
g.drawLine(2,9, 3,9);
1359        g.drawLine(4,10, 11,10); // bottom
1360
g.drawLine(12,9, 13,9);
1361        g.drawLine(14,7, 14, 8); // right
1362
// bottom disk
1363
g.drawLine(1,10, 1,11); // left
1364
g.drawLine(2,12, 3,12);
1365        g.drawLine(4,13, 11,13); // bottom
1366
g.drawLine(12,12, 13,12);
1367        g.drawLine(14,10, 14,11); // right
1368

1369        // Draw the down right shadows
1370
g.setColor(MetalLookAndFeel.getControlShadow());
1371        // top disk
1372
g.drawLine(7,6, 7,6);
1373        g.drawLine(9,6, 9,6);
1374        g.drawLine(10,5, 10,5);
1375        g.drawLine(11,6, 11,6);
1376        g.drawLine(12,5, 13,5);
1377        g.drawLine(13,4, 13,4);
1378        // middle disk
1379
g.drawLine(7,9, 7,9);
1380        g.drawLine(9,9, 9,9);
1381        g.drawLine(10,8, 10,8);
1382        g.drawLine(11,9, 11,9);
1383        g.drawLine(12,8, 13,8);
1384        g.drawLine(13,7, 13,7);
1385        // bottom disk
1386
g.drawLine(7,12, 7,12);
1387        g.drawLine(9,12, 9,12);
1388        g.drawLine(10,11, 10,11);
1389        g.drawLine(11,12, 11,12);
1390        g.drawLine(12,11, 13,11);
1391        g.drawLine(13,10, 13,10);
1392
1393        // Draw the up left highlight
1394
g.setColor(MetalLookAndFeel.getControlHighlight());
1395        // top disk
1396
g.drawLine(4,3, 5,3);
1397        g.drawLine(7,3, 9,3);
1398        g.drawLine(11,3, 11,3);
1399        g.drawLine(2,4, 6,4);
1400        g.drawLine(8,4, 8,4);
1401        g.drawLine(2,5, 3,5);
1402        g.drawLine(4,6, 4,6);
1403        // middle disk
1404
g.drawLine(2,7, 3,7);
1405        g.drawLine(2,8, 3,8);
1406        g.drawLine(4,9, 4,9);
1407        // bottom disk
1408
g.drawLine(2,10, 3,10);
1409        g.drawLine(2,11, 3,11);
1410        g.drawLine(4,12, 4,12);
1411
1412        g.translate(-x, -y);
1413    }
1414    
1415    public int getIconWidth() {
1416        return 16;
1417    }
1418    
1419    public int getIconHeight() {
1420        return 16;
1421    }
1422    } // End class TreeHardDriveIcon
1423

1424    // Tree FloppyDrive Icon code
1425
private static class TreeFloppyDriveIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc {
1426        public void paintIcon(Component c, Graphics g, int x, int y) {
1427        g.translate(x, y);
1428
1429        // Fill body of floppy
1430
g.setColor(MetalLookAndFeel.getPrimaryControl());
1431        g.fillRect(2,2, 12,12);
1432
1433        // Draw outside edge of floppy
1434
g.setColor(MetalLookAndFeel.getPrimaryControlInfo());
1435        g.drawLine( 1, 1, 13, 1); // top
1436
g.drawLine(14, 2, 14,14); // right
1437
g.drawLine( 1,14, 14,14); // bottom
1438
g.drawLine( 1, 1, 1,14); // left
1439

1440        // Draw grey-ish highlights
1441
g.setColor(MetalLookAndFeel.getControlDarkShadow());
1442        g.fillRect(5,2, 6,5); // metal disk protector part
1443
g.drawLine(4,8, 11,8); // top of label
1444
g.drawLine(3,9, 3,13); // left of label
1445
g.drawLine(12,9, 12,13); // right of label
1446

1447        // Draw label and exposed disk
1448
g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
1449        g.fillRect(8,3, 2,3); // exposed disk
1450
g.fillRect(4,9, 8,5); // label
1451

1452        // Draw text on label
1453
g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1454        g.drawLine(5,10, 9,10);
1455        g.drawLine(5,12, 8,12);
1456
1457        g.translate(-x, -y);
1458    }
1459    
1460    public int getIconWidth() {
1461        return 16;
1462    }
1463    
1464    public int getIconHeight() {
1465        return 16;
1466    }
1467    } // End class TreeFloppyDriveIcon
1468

1469
1470    static private final Dimension folderIcon16Size = new Dimension( 16, 16 );
1471
1472    /**
1473     * Utility class for caching icon images. This is necessary because
1474     * we need a new image whenever we are rendering into a new
1475     * GraphicsConfiguration, but we do not want to keep recreating icon
1476     * images for GC's that we have already seen (for example,
1477     * dragging a window back and forth between monitors on a multimon
1478     * system, or drawing an icon to different Components that have different
1479     * GC's).
1480     * So now whenever we create a new icon image for a given GC, we
1481     * cache that image with the GC for later retrieval.
1482     */

1483    static class ImageCacher {
1484
1485        // PENDING: Replace this class with CachedPainter.
1486

1487    Vector JavaDoc images = new Vector JavaDoc(1, 1);
1488    ImageGcPair currentImageGcPair;
1489
1490    class ImageGcPair {
1491        Image JavaDoc image;
1492        GraphicsConfiguration gc;
1493        ImageGcPair(Image JavaDoc image, GraphicsConfiguration gc) {
1494        this.image = image;
1495        this.gc = gc;
1496        }
1497
1498        boolean hasSameConfiguration(GraphicsConfiguration newGC) {
1499        if (((newGC != null) && (newGC.equals(gc))) ||
1500            ((newGC == null) && (gc == null)))
1501        {
1502            return true;
1503        }
1504        return false;
1505        }
1506
1507    }
1508
1509    Image JavaDoc getImage(GraphicsConfiguration newGC) {
1510        if ((currentImageGcPair == null) ||
1511        !(currentImageGcPair.hasSameConfiguration(newGC)))
1512        {
1513        Enumeration JavaDoc elements = images.elements();
1514        while (elements.hasMoreElements()) {
1515            ImageGcPair imgGcPair = (ImageGcPair)elements.nextElement();
1516            if (imgGcPair.hasSameConfiguration(newGC)) {
1517            currentImageGcPair = imgGcPair;
1518            return imgGcPair.image;
1519            }
1520        }
1521        return null;
1522        }
1523        return currentImageGcPair.image;
1524    }
1525
1526    void cacheImage(Image JavaDoc image, GraphicsConfiguration gc) {
1527        ImageGcPair imgGcPair = new ImageGcPair(image, gc);
1528        images.addElement(imgGcPair);
1529        currentImageGcPair = imgGcPair;
1530    }
1531
1532    }
1533
1534    /**
1535     * <p>
1536     * <strong>Warning:</strong>
1537     * Serialized objects of this class will not be compatible with
1538     * future Swing releases. The current serialization support is
1539     * appropriate for short term storage or RMI between applications running
1540     * the same version of Swing. As of 1.4, support for long term storage
1541     * of all JavaBeans<sup><font size="-2">TM</font></sup>
1542     * has been added to the <code>java.beans</code> package.
1543     * Please see {@link java.beans.XMLEncoder}.
1544     */

1545    public static class FolderIcon16 implements Icon, Serializable JavaDoc {
1546
1547    ImageCacher imageCacher;
1548
1549    public void paintIcon(Component c, Graphics g, int x, int y) {
1550        GraphicsConfiguration gc = c.getGraphicsConfiguration();
1551        if (imageCacher == null) {
1552        imageCacher = new ImageCacher();
1553        }
1554        Image JavaDoc image = imageCacher.getImage(gc);
1555        if (image == null) {
1556        if (gc != null) {
1557            image = gc.createCompatibleImage(getIconWidth(),
1558                             getIconHeight(),
1559                             Transparency.BITMASK);
1560        } else {
1561            image = new BufferedImage JavaDoc(getIconWidth(),
1562                          getIconHeight(),
1563                          BufferedImage.TYPE_INT_ARGB);
1564        }
1565                Graphics imageG = image.getGraphics();
1566        paintMe(c,imageG);
1567        imageG.dispose();
1568        imageCacher.cacheImage(image, gc);
1569        }
1570            g.drawImage(image, x, y+getShift(), null);
1571    }
1572
1573
1574    private void paintMe(Component c, Graphics g) {
1575
1576        int right = folderIcon16Size.width - 1;
1577        int bottom = folderIcon16Size.height - 1;
1578
1579        // Draw tab top
1580
g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
1581        g.drawLine( right - 5, 3, right, 3 );
1582        g.drawLine( right - 6, 4, right, 4 );
1583
1584        // Draw folder front
1585
g.setColor( MetalLookAndFeel.getPrimaryControl() );
1586        g.fillRect( 2, 7, 13, 8 );
1587
1588        // Draw tab bottom
1589
g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
1590        g.drawLine( right - 6, 5, right - 1, 5 );
1591
1592        // Draw outline
1593
g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
1594        g.drawLine( 0, 6, 0, bottom ); // left side
1595
g.drawLine( 1, 5, right - 7, 5 ); // first part of top
1596
g.drawLine( right - 6, 6, right - 1, 6 ); // second part of top
1597
g.drawLine( right, 5, right, bottom ); // right side
1598
g.drawLine( 0, bottom, right, bottom ); // bottom
1599

1600        // Draw highlight
1601
g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
1602        g.drawLine( 1, 6, 1, bottom - 1 );
1603        g.drawLine( 1, 6, right - 7, 6 );
1604        g.drawLine( right - 6, 7, right - 1, 7 );
1605
1606    }
1607
1608        public int getShift() { return 0; }
1609        public int getAdditionalHeight() { return 0; }
1610
1611    public int getIconWidth() { return folderIcon16Size.width; }
1612    public int getIconHeight() { return folderIcon16Size.height + getAdditionalHeight(); }
1613    }
1614
1615  
1616    /**
1617     * <p>
1618     * <strong>Warning:</strong>
1619     * Serialized objects of this class will not be compatible with
1620     * future Swing releases. The current serialization support is
1621     * appropriate for short term storage or RMI between applications running
1622     * the same version of Swing. As of 1.4, support for long term storage
1623     * of all JavaBeans<sup><font size="-2">TM</font></sup>
1624     * has been added to the <code>java.beans</code> package.
1625     * Please see {@link java.beans.XMLEncoder}.
1626     */

1627    public static class TreeFolderIcon extends FolderIcon16 {
1628        public int getShift() { return -1; }
1629        public int getAdditionalHeight() { return 2; }
1630    }
1631
1632
1633    static private final Dimension fileIcon16Size = new Dimension( 16, 16 );
1634
1635    /**
1636     * <p>
1637     * <strong>Warning:</strong>
1638     * Serialized objects of this class will not be compatible with
1639     * future Swing releases. The current serialization support is
1640     * appropriate for short term storage or RMI between applications running
1641     * the same version of Swing. As of 1.4, support for long term storage
1642     * of all JavaBeans<sup><font size="-2">TM</font></sup>
1643     * has been added to the <code>java.beans</code> package.
1644     * Please see {@link java.beans.XMLEncoder}.
1645     */

1646    public static class FileIcon16 implements Icon, Serializable JavaDoc {
1647
1648    ImageCacher imageCacher;
1649
1650    public void paintIcon(Component c, Graphics g, int x, int y) {
1651        GraphicsConfiguration gc = c.getGraphicsConfiguration();
1652        if (imageCacher == null) {
1653        imageCacher = new ImageCacher();
1654        }
1655        Image JavaDoc image = imageCacher.getImage(gc);
1656        if (image == null) {
1657        if (gc != null) {
1658            image = gc.createCompatibleImage(getIconWidth(),
1659                             getIconHeight(),
1660                             Transparency.BITMASK);
1661        } else {
1662            image = new BufferedImage JavaDoc(getIconWidth(),
1663                          getIconHeight(),
1664                          BufferedImage.TYPE_INT_ARGB);
1665        }
1666                Graphics imageG = image.getGraphics();
1667        paintMe(c,imageG);
1668        imageG.dispose();
1669        imageCacher.cacheImage(image, gc);
1670        }
1671            g.drawImage(image, x, y+getShift(), null);
1672    }
1673
1674        private void paintMe(Component c, Graphics g) {
1675
1676        int right = fileIcon16Size.width - 1;
1677        int bottom = fileIcon16Size.height - 1;
1678
1679        // Draw fill
1680
g.setColor( MetalLookAndFeel.getWindowBackground() );
1681        g.fillRect( 4, 2, 9, 12 );
1682
1683        // Draw frame
1684
g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
1685        g.drawLine( 2, 0, 2, bottom ); // left
1686
g.drawLine( 2, 0, right - 4, 0 ); // top
1687
g.drawLine( 2, bottom, right - 1, bottom ); // bottom
1688
g.drawLine( right - 1, 6, right - 1, bottom ); // right
1689
g.drawLine( right - 6, 2, right - 2, 6 ); // slant 1
1690
g.drawLine( right - 5, 1, right - 4, 1 ); // part of slant 2
1691
g.drawLine( right - 3, 2, right - 3, 3 ); // part of slant 2
1692
g.drawLine( right - 2, 4, right - 2, 5 ); // part of slant 2
1693

1694        // Draw highlight
1695
g.setColor( MetalLookAndFeel.getPrimaryControl() );
1696        g.drawLine( 3, 1, 3, bottom - 1 ); // left
1697
g.drawLine( 3, 1, right - 6, 1 ); // top
1698
g.drawLine( right - 2, 7, right - 2, bottom - 1 ); // right
1699
g.drawLine( right - 5, 2, right - 3, 4 ); // slant
1700
g.drawLine( 3, bottom - 1, right - 2, bottom - 1 ); // bottom
1701

1702    }
1703
1704        public int getShift() { return 0; }
1705        public int getAdditionalHeight() { return 0; }
1706
1707    public int getIconWidth() { return fileIcon16Size.width; }
1708    public int getIconHeight() { return fileIcon16Size.height + getAdditionalHeight(); }
1709    }
1710
1711
1712    public static class TreeLeafIcon extends FileIcon16 {
1713        public int getShift() { return 2; }
1714        public int getAdditionalHeight() { return 4; }
1715    }
1716
1717
1718    static private final Dimension treeControlSize = new Dimension( 18, 18 );
1719
1720    /**
1721     * <p>
1722     * <strong>Warning:</strong>
1723     * Serialized objects of this class will not be compatible with
1724     * future Swing releases. The current serialization support is
1725     * appropriate for short term storage or RMI between applications running
1726     * the same version of Swing. As of 1.4, support for long term storage
1727     * of all JavaBeans<sup><font size="-2">TM</font></sup>
1728     * has been added to the <code>java.beans</code> package.
1729     * Please see {@link java.beans.XMLEncoder}.
1730     */

1731    public static class TreeControlIcon implements Icon, Serializable JavaDoc {
1732        // This data member should not have been exposed. It's called
1733
// isLight, but now it really means isCollapsed. Since we can't change
1734
// any APIs... that's life.
1735
protected boolean isLight;
1736
1737
1738        public TreeControlIcon( boolean isCollapsed ) {
1739        isLight = isCollapsed;
1740    }
1741
1742    ImageCacher imageCacher;
1743
1744        transient boolean cachedOrientation = true;
1745
1746    public void paintIcon(Component c, Graphics g, int x, int y) {
1747
1748        GraphicsConfiguration gc = c.getGraphicsConfiguration();
1749
1750        if (imageCacher == null) {
1751        imageCacher = new ImageCacher();
1752        }
1753        Image JavaDoc image = imageCacher.getImage(gc);
1754
1755        if (image == null || cachedOrientation != MetalUtils.isLeftToRight(c)) {
1756        cachedOrientation = MetalUtils.isLeftToRight(c);
1757        if (gc != null) {
1758            image = gc.createCompatibleImage(getIconWidth(),
1759                             getIconHeight(),
1760                             Transparency.BITMASK);
1761        } else {
1762            image = new BufferedImage JavaDoc(getIconWidth(),
1763                          getIconHeight(),
1764                          BufferedImage.TYPE_INT_ARGB);
1765        }
1766                Graphics imageG = image.getGraphics();
1767        paintMe(c,imageG,x,y);
1768        imageG.dispose();
1769        imageCacher.cacheImage(image, gc);
1770        
1771        }
1772
1773        if (MetalUtils.isLeftToRight(c)) {
1774            if (isLight) { // isCollapsed
1775
g.drawImage(image, x+5, y+3, x+18, y+13,
1776                       4,3, 17, 13, null);
1777        }
1778            else {
1779            g.drawImage(image, x+5, y+3, x+18, y+17,
1780                       4,3, 17, 17, null);
1781        }
1782        }
1783        else {
1784            if (isLight) { // isCollapsed
1785
g.drawImage(image, x+3, y+3, x+16, y+13,
1786                       4, 3, 17, 13, null);
1787        }
1788        else {
1789            g.drawImage(image, x+3, y+3, x+16, y+17,
1790                       4, 3, 17, 17, null);
1791        }
1792        }
1793    }
1794
1795    public void paintMe(Component c, Graphics g, int x, int y) {
1796
1797        g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
1798
1799        int xoff = (MetalUtils.isLeftToRight(c)) ? 0 : 4;
1800
1801        // Draw circle
1802
g.drawLine( xoff + 4, 6, xoff + 4, 9 ); // left
1803
g.drawLine( xoff + 5, 5, xoff + 5, 5 ); // top left dot
1804
g.drawLine( xoff + 6, 4, xoff + 9, 4 ); // top
1805
g.drawLine( xoff + 10, 5, xoff + 10, 5 ); // top right dot
1806
g.drawLine( xoff + 11, 6, xoff + 11, 9 ); // right
1807
g.drawLine( xoff + 10, 10, xoff + 10, 10 ); // botom right dot
1808
g.drawLine( xoff + 6, 11, xoff + 9, 11 ); // bottom
1809
g.drawLine( xoff + 5, 10, xoff + 5, 10 ); // bottom left dot
1810

1811        // Draw Center Dot
1812
g.drawLine( xoff + 7, 7, xoff + 8, 7 );
1813        g.drawLine( xoff + 7, 8, xoff + 8, 8 );
1814
1815        // Draw Handle
1816
if ( isLight ) { // isCollapsed
1817
if( MetalUtils.isLeftToRight(c) ) {
1818                g.drawLine( 12, 7, 15, 7 );
1819            g.drawLine( 12, 8, 15, 8 );
1820            // g.setColor( c.getBackground() );
1821
// g.drawLine( 16, 7, 16, 8 );
1822
}
1823        else {
1824            g.drawLine(4, 7, 7, 7);
1825            g.drawLine(4, 8, 7, 8);
1826        }
1827        }
1828        else {
1829            g.drawLine( xoff + 7, 12, xoff + 7, 15 );
1830        g.drawLine( xoff + 8, 12, xoff + 8, 15 );
1831        // g.setColor( c.getBackground() );
1832
// g.drawLine( xoff + 7, 16, xoff + 8, 16 );
1833
}
1834
1835        // Draw Fill
1836
g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );
1837        g.drawLine( xoff + 5, 6, xoff + 5, 9 ); // left shadow
1838
g.drawLine( xoff + 6, 5, xoff + 9, 5 ); // top shadow
1839

1840        g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );
1841        g.drawLine( xoff + 6, 6, xoff + 6, 6 ); // top left fill
1842
g.drawLine( xoff + 9, 6, xoff + 9, 6 ); // top right fill
1843
g.drawLine( xoff + 6, 9, xoff + 6, 9 ); // bottom left fill
1844
g.drawLine( xoff + 10, 6, xoff + 10, 9 ); // right fill
1845
g.drawLine( xoff + 6, 10, xoff + 9, 10 ); // bottom fill
1846

1847        g.setColor( MetalLookAndFeel.getPrimaryControl() );
1848        g.drawLine( xoff + 6, 7, xoff + 6, 8 ); // left highlight
1849
g.drawLine( xoff + 7, 6, xoff + 8, 6 ); // top highlight
1850
g.drawLine( xoff + 9, 7, xoff + 9, 7 ); // right highlight
1851
g.drawLine( xoff + 7, 9, xoff + 7, 9 ); // bottom highlight
1852

1853        g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );
1854        g.drawLine( xoff + 8, 9, xoff + 9, 9 );
1855        g.drawLine( xoff + 9, 8, xoff + 9, 8 );
1856    }
1857
1858    public int getIconWidth() { return treeControlSize.width; }
1859    public int getIconHeight() { return treeControlSize.height; }
1860    }
1861
1862  //
1863
// Menu Icons
1864
//
1865

1866    static private final Dimension menuArrowIconSize = new Dimension( 4, 8 );
1867    static private final Dimension menuCheckIconSize = new Dimension( 10, 10 );
1868    static private final int xOff = 4;
1869
1870    private static class MenuArrowIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc
1871    {
1872    public void paintIcon( Component c, Graphics g, int x, int y )
1873    {
1874        JMenuItem b = (JMenuItem) c;
1875        ButtonModel model = b.getModel();
1876
1877        g.translate( x, y );
1878
1879        if ( !model.isEnabled() )
1880        {
1881            g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
1882        }
1883        else
1884        {
1885            if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
1886        {
1887            g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
1888        }
1889        else
1890        {
1891            g.setColor( b.getForeground() );
1892        }
1893        }
1894            if( MetalUtils.isLeftToRight(b) ) {
1895                g.drawLine( 0, 0, 0, 7 );
1896                g.drawLine( 1, 1, 1, 6 );
1897                g.drawLine( 2, 2, 2, 5 );
1898                g.drawLine( 3, 3, 3, 4 );
1899            } else {
1900                g.drawLine( 4, 0, 4, 7 );
1901                g.drawLine( 3, 1, 3, 6 );
1902                g.drawLine( 2, 2, 2, 5 );
1903                g.drawLine( 1, 3, 1, 4 );
1904            }
1905
1906        g.translate( -x, -y );
1907    }
1908
1909    public int getIconWidth() { return menuArrowIconSize.width; }
1910
1911    public int getIconHeight() { return menuArrowIconSize.height; }
1912
1913    } // End class MenuArrowIcon
1914

1915    private static class MenuItemArrowIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc
1916    {
1917    public void paintIcon( Component c, Graphics g, int x, int y )
1918    {
1919    }
1920
1921    public int getIconWidth() { return menuArrowIconSize.width; }
1922
1923    public int getIconHeight() { return menuArrowIconSize.height; }
1924
1925    } // End class MenuItemArrowIcon
1926

1927    private static class CheckBoxMenuItemIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc
1928    {
1929    public void paintOceanIcon(Component c, Graphics g, int x, int y) {
1930        ButtonModel model = ((JMenuItem)c).getModel();
1931        boolean isSelected = model.isSelected();
1932        boolean isEnabled = model.isEnabled();
1933        boolean isPressed = model.isPressed();
1934        boolean isArmed = model.isArmed();
1935        
1936        g.translate(x, y);
1937            if (isEnabled) {
1938                MetalUtils.drawGradient(c, g, "CheckBoxMenuItem.gradient",
1939                                        1, 1, 7, 7, true);
1940            if (isPressed || isArmed) {
1941            g.setColor(MetalLookAndFeel.getControlInfo());
1942            g.drawLine( 0, 0, 8, 0 );
1943            g.drawLine( 0, 0, 0, 8 );
1944            g.drawLine( 8, 2, 8, 8 );
1945            g.drawLine( 2, 8, 8, 8 );
1946
1947            g.setColor(MetalLookAndFeel.getPrimaryControl());
1948            g.drawLine( 9, 1, 9, 9 );
1949            g.drawLine( 1, 9, 9, 9 );
1950        }
1951        else {
1952            g.setColor(MetalLookAndFeel.getControlDarkShadow());
1953            g.drawLine( 0, 0, 8, 0 );
1954            g.drawLine( 0, 0, 0, 8 );
1955            g.drawLine( 8, 2, 8, 8 );
1956            g.drawLine( 2, 8, 8, 8 );
1957
1958            g.setColor(MetalLookAndFeel.getControlHighlight());
1959            g.drawLine( 9, 1, 9, 9 );
1960            g.drawLine( 1, 9, 9, 9 );
1961        }
1962        }
1963        else {
1964            g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
1965        g.drawRect( 0, 0, 8, 8 );
1966        }
1967        if (isSelected) {
1968            if (isEnabled) {
1969            if (isArmed || ( c instanceof JMenu && isSelected)) {
1970                g.setColor(
1971                            MetalLookAndFeel.getMenuSelectedForeground() );
1972            }
1973            else {
1974                g.setColor(c.getForeground());
1975            }
1976        }
1977        else {
1978            g.setColor( MetalLookAndFeel.getMenuDisabledForeground());
1979        }
1980
1981        g.drawLine( 2, 2, 2, 6 );
1982        g.drawLine( 3, 2, 3, 6 );
1983        g.drawLine( 4, 4, 8, 0 );
1984        g.drawLine( 4, 5, 9, 0 );
1985        }
1986        g.translate( -x, -y );
1987    }
1988
1989    public void paintIcon( Component c, Graphics g, int x, int y )
1990    {
1991            if (MetalLookAndFeel.usingOcean()) {
1992                paintOceanIcon(c, g, x, y);
1993                return;
1994            }
1995        JMenuItem b = (JMenuItem) c;
1996        ButtonModel model = b.getModel();
1997
1998        boolean isSelected = model.isSelected();
1999        boolean isEnabled = model.isEnabled();
2000        boolean isPressed = model.isPressed();
2001        boolean isArmed = model.isArmed();
2002        
2003        g.translate( x, y );
2004
2005        if ( isEnabled )
2006        {
2007            if ( isPressed || isArmed )
2008        {
2009            g.setColor( MetalLookAndFeel.getControlInfo() );
2010            g.drawLine( 0, 0, 8, 0 );
2011            g.drawLine( 0, 0, 0, 8 );
2012            g.drawLine( 8, 2, 8, 8 );
2013            g.drawLine( 2, 8, 8, 8 );
2014
2015            g.setColor( MetalLookAndFeel.getPrimaryControl() );
2016            g.drawLine( 1, 1, 7, 1 );
2017            g.drawLine( 1, 1, 1, 7 );
2018            g.drawLine( 9, 1, 9, 9 );
2019            g.drawLine( 1, 9, 9, 9 );
2020        }
2021        else
2022        {
2023            g.setColor( MetalLookAndFeel.getControlDarkShadow() );
2024            g.drawLine( 0, 0, 8, 0 );
2025            g.drawLine( 0, 0, 0, 8 );
2026            g.drawLine( 8, 2, 8, 8 );
2027            g.drawLine( 2, 8, 8, 8 );
2028
2029            g.setColor( MetalLookAndFeel.getControlHighlight() );
2030            g.drawLine( 1, 1, 7, 1 );
2031            g.drawLine( 1, 1, 1, 7 );
2032            g.drawLine( 9, 1, 9, 9 );
2033            g.drawLine( 1, 9, 9, 9 );
2034        }
2035        }
2036        else
2037        {
2038            g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
2039        g.drawRect( 0, 0, 8, 8 );
2040        }
2041
2042        if ( isSelected )
2043        {
2044            if ( isEnabled )
2045        {
2046            if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
2047            {
2048                g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
2049            }
2050            else
2051            {
2052                g.setColor( b.getForeground() );
2053            }
2054        }
2055        else
2056        {
2057            g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
2058        }
2059
2060        g.drawLine( 2, 2, 2, 6 );
2061        g.drawLine( 3, 2, 3, 6 );
2062        g.drawLine( 4, 4, 8, 0 );
2063        g.drawLine( 4, 5, 9, 0 );
2064        }
2065
2066        g.translate( -x, -y );
2067    }
2068
2069    public int getIconWidth() { return menuCheckIconSize.width; }
2070
2071    public int getIconHeight() { return menuCheckIconSize.height; }
2072
2073    } // End class CheckBoxMenuItemIcon
2074

2075    private static class RadioButtonMenuItemIcon implements Icon, UIResource JavaDoc, Serializable JavaDoc
2076    {
2077    public void paintOceanIcon(Component c, Graphics g, int x, int y) {
2078        ButtonModel model = ((JMenuItem)c).getModel();
2079        boolean isSelected = model.isSelected();
2080        boolean isEnabled = model.isEnabled();
2081        boolean isPressed = model.isPressed();
2082        boolean isArmed = model.isArmed();
2083        
2084        g.translate( x, y );
2085
2086            if (isEnabled) {
2087                MetalUtils.drawGradient(c, g, "RadioButtonMenuItem.gradient",
2088                                        1, 1, 7, 7, true);
2089            if (isPressed || isArmed) {
2090            g.setColor(MetalLookAndFeel.getPrimaryControl());
2091                }
2092                else {
2093            g.setColor(MetalLookAndFeel.getControlHighlight());
2094                }
2095                g.drawLine( 2, 9, 7, 9 );
2096                g.drawLine( 9, 2, 9, 7 );
2097                g.drawLine( 8, 8, 8, 8 );
2098
2099                if (isPressed || isArmed) {
2100            g.setColor(MetalLookAndFeel.getControlInfo());
2101                }
2102                else {
2103            g.setColor(MetalLookAndFeel.getControlDarkShadow());
2104                }
2105            }
2106            else {
2107            g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
2108            }
2109            g.drawLine( 2, 0, 6, 0 );
2110            g.drawLine( 2, 8, 6, 8 );
2111            g.drawLine( 0, 2, 0, 6 );
2112            g.drawLine( 8, 2, 8, 6 );
2113            g.drawLine( 1, 1, 1, 1 );
2114            g.drawLine( 7, 1, 7, 1 );
2115            g.drawLine( 1, 7, 1, 7 );
2116            g.drawLine( 7, 7, 7, 7 );
2117
2118        if (isSelected) {
2119            if (isEnabled) {
2120            if (isArmed || (c instanceof JMenu && model.isSelected())){
2121                g.setColor(MetalLookAndFeel.
2122                                   getMenuSelectedForeground() );
2123            }
2124            else {
2125                g.setColor(c.getForeground());
2126            }
2127        }
2128        else {
2129            g.setColor(MetalLookAndFeel.getMenuDisabledForeground());
2130        }
2131        g.drawLine( 3, 2, 5, 2 );
2132        g.drawLine( 2, 3, 6, 3 );
2133        g.drawLine( 2, 4, 6, 4 );
2134        g.drawLine( 2, 5, 6, 5 );
2135        g.drawLine( 3, 6, 5, 6 );
2136        }
2137
2138        g.translate( -x, -y );
2139    }
2140
2141    public void paintIcon( Component c, Graphics g, int x, int y )
2142    {
2143            if (MetalLookAndFeel.usingOcean()) {
2144                paintOceanIcon(c, g, x, y);
2145                return;
2146            }
2147        JMenuItem b = (JMenuItem) c;
2148        ButtonModel model = b.getModel();
2149
2150        boolean isSelected = model.isSelected();
2151        boolean isEnabled = model.isEnabled();
2152        boolean isPressed = model.isPressed();
2153        boolean isArmed = model.isArmed();
2154        
2155        g.translate( x, y );
2156
2157        if ( isEnabled )
2158        {
2159            if ( isPressed || isArmed )
2160        {
2161            g.setColor( MetalLookAndFeel.getPrimaryControl() );
2162            g.drawLine( 3, 1, 8, 1 );
2163            g.drawLine( 2, 9, 7, 9 );
2164            g.drawLine( 1, 3, 1, 8 );
2165            g.drawLine( 9, 2, 9, 7 );
2166            g.drawLine( 2, 2, 2, 2 );
2167            g.drawLine( 8, 8, 8, 8 );
2168
2169            g.setColor( MetalLookAndFeel.getControlInfo() );
2170            g.drawLine( 2, 0, 6, 0 );
2171            g.drawLine( 2, 8, 6, 8 );
2172            g.drawLine( 0, 2, 0, 6 );
2173            g.drawLine( 8, 2, 8, 6 );
2174            g.drawLine( 1, 1, 1, 1 );
2175            g.drawLine( 7, 1, 7, 1 );
2176            g.drawLine( 1, 7, 1, 7 );
2177            g.drawLine( 7, 7, 7, 7 );
2178        }
2179        else
2180        {
2181            g.setColor( MetalLookAndFeel.getControlHighlight() );
2182            g.drawLine( 3, 1, 8, 1 );
2183            g.drawLine( 2, 9, 7, 9 );
2184            g.drawLine( 1, 3, 1, 8 );
2185            g.drawLine( 9, 2, 9, 7 );
2186            g.drawLine( 2, 2, 2, 2 );
2187            g.drawLine( 8, 8, 8, 8 );
2188
2189            g.setColor( MetalLookAndFeel.getControlDarkShadow() );
2190            g.drawLine( 2, 0, 6, 0 );
2191            g.drawLine( 2, 8, 6, 8 );
2192            g.drawLine( 0, 2, 0, 6 );
2193            g.drawLine( 8, 2, 8, 6 );
2194            g.drawLine( 1, 1, 1, 1 );
2195            g.drawLine( 7, 1, 7, 1 );
2196            g.drawLine( 1, 7, 1, 7 );
2197            g.drawLine( 7, 7, 7, 7 );
2198        }
2199        }
2200        else
2201        {
2202            g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
2203        g.drawLine( 2, 0, 6, 0 );
2204        g.drawLine( 2, 8, 6, 8 );
2205        g.drawLine( 0, 2, 0, 6 );
2206        g.drawLine( 8, 2, 8, 6 );
2207        g.drawLine( 1, 1, 1, 1 );
2208        g.drawLine( 7, 1, 7, 1 );
2209        g.drawLine( 1, 7, 1, 7 );
2210        g.drawLine( 7, 7, 7, 7 );
2211        }
2212
2213        if ( isSelected )
2214        {
2215            if ( isEnabled )
2216        {
2217            if ( model.isArmed() || ( c instanceof JMenu && model.isSelected() ) )
2218            {
2219                g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
2220            }
2221            else
2222            {
2223                g.setColor( b.getForeground() );
2224            }
2225        }
2226        else
2227        {
2228            g.setColor( MetalLookAndFeel.getMenuDisabledForeground() );
2229        }
2230
2231        g.drawLine( 3, 2, 5, 2 );
2232        g.drawLine( 2, 3, 6, 3 );
2233        g.drawLine( 2, 4, 6, 4 );
2234        g.drawLine( 2, 5, 6, 5 );
2235        g.drawLine( 3, 6, 5, 6 );
2236        }
2237
2238        g.translate( -x, -y );
2239    }
2240
2241    public int getIconWidth() { return menuCheckIconSize.width; }
2242
2243    public int getIconHeight() { return menuCheckIconSize.height; }
2244
2245    } // End class RadioButtonMenuItemIcon
2246

2247private static class VerticalSliderThumbIcon implements Icon, Serializable JavaDoc, UIResource JavaDoc {
2248    protected static MetalBumps JavaDoc controlBumps;
2249    protected static MetalBumps JavaDoc primaryBumps;
2250
2251    public VerticalSliderThumbIcon() {
2252        controlBumps = new MetalBumps JavaDoc( 6, 10,
2253                MetalLookAndFeel.getControlHighlight(),
2254                MetalLookAndFeel.getControlInfo(),
2255                MetalLookAndFeel.getControl() );
2256        primaryBumps = new MetalBumps JavaDoc( 6, 10,
2257                MetalLookAndFeel.getPrimaryControl(),
2258                MetalLookAndFeel.getPrimaryControlDarkShadow(),
2259                MetalLookAndFeel.getPrimaryControlShadow() );
2260    }
2261
2262    public void paintIcon( Component c, Graphics g, int x, int y ) {
2263        JSlider slider = (JSlider)c;
2264
2265    boolean leftToRight = MetalUtils.isLeftToRight(slider);
2266
2267        g.translate( x, y );
2268
2269    // Draw the frame
2270
if ( slider.hasFocus() ) {
2271        g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
2272    }
2273    else {
2274        g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
2275                                 MetalLookAndFeel.getControlDarkShadow() );
2276    }
2277
2278    if (leftToRight) {
2279        g.drawLine( 1,0 , 8,0 ); // top
2280
g.drawLine( 0,1 , 0,13 ); // left
2281
g.drawLine( 1,14 , 8,14 ); // bottom
2282
g.drawLine( 9,1 , 15,7 ); // top slant
2283
g.drawLine( 9,13 , 15,7 ); // bottom slant
2284
}
2285    else {
2286        g.drawLine( 7,0 , 14,0 ); // top
2287
g.drawLine( 15,1 , 15,13 ); // right
2288
g.drawLine( 7,14 , 14,14 ); // bottom
2289
g.drawLine( 0,7 , 6,1 ); // top slant
2290
g.drawLine( 0,7 , 6,13 ); // bottom slant
2291
}
2292
2293    // Fill in the background
2294
if ( slider.hasFocus() ) {
2295        g.setColor( c.getForeground() );
2296    }
2297    else {
2298        g.setColor( MetalLookAndFeel.getControl() );
2299    }
2300
2301    if (leftToRight) {
2302        g.fillRect( 1,1 , 8,13 );
2303
2304        g.drawLine( 9,2 , 9,12 );
2305        g.drawLine( 10,3 , 10,11 );
2306        g.drawLine( 11,4 , 11,10 );
2307        g.drawLine( 12,5 , 12,9 );
2308        g.drawLine( 13,6 , 13,8 );
2309        g.drawLine( 14,7 , 14,7 );
2310    }
2311    else {
2312        g.fillRect( 7,1, 8,13 );
2313
2314        g.drawLine( 6,3 , 6,12 );
2315        g.drawLine( 5,4 , 5,11 );
2316        g.drawLine( 4,5 , 4,10 );
2317        g.drawLine( 3,6 , 3,9 );
2318        g.drawLine( 2,7 , 2,8 );
2319    }
2320
2321    // Draw the bumps
2322
int offset = (leftToRight) ? 2 : 8;
2323    if ( slider.isEnabled() ) {
2324        if ( slider.hasFocus() ) {
2325            primaryBumps.paintIcon( c, g, offset, 2 );
2326        }
2327        else {
2328            controlBumps.paintIcon( c, g, offset, 2 );
2329        }
2330    }
2331
2332    // Draw the highlight
2333
if ( slider.isEnabled() ) {
2334        g.setColor( slider.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
2335            : MetalLookAndFeel.getControlHighlight() );
2336        if (leftToRight) {
2337            g.drawLine( 1, 1, 8, 1 );
2338        g.drawLine( 1, 1, 1, 13 );
2339        }
2340        else {
2341            g.drawLine( 8,1 , 14,1 ); // top
2342
g.drawLine( 1,7 , 7,1 ); // top slant
2343
}
2344    }
2345
2346        g.translate( -x, -y );
2347    }
2348
2349    public int getIconWidth() {
2350        return 16;
2351    }
2352
2353    public int getIconHeight() {
2354        return 15;
2355    }
2356}
2357
2358private static class HorizontalSliderThumbIcon implements Icon, Serializable JavaDoc, UIResource JavaDoc {
2359    protected static MetalBumps JavaDoc controlBumps;
2360    protected static MetalBumps JavaDoc primaryBumps;
2361
2362    public HorizontalSliderThumbIcon() {
2363        controlBumps = new MetalBumps JavaDoc( 10, 6,
2364                MetalLookAndFeel.getControlHighlight(),
2365                MetalLookAndFeel.getControlInfo(),
2366                MetalLookAndFeel.getControl() );
2367        primaryBumps = new MetalBumps JavaDoc( 10, 6,
2368                MetalLookAndFeel.getPrimaryControl(),
2369                MetalLookAndFeel.getPrimaryControlDarkShadow(),
2370                MetalLookAndFeel.getPrimaryControlShadow() );
2371    }
2372
2373    public void paintIcon( Component c, Graphics g, int x, int y ) {
2374        JSlider slider = (JSlider)c;
2375
2376        g.translate( x, y );
2377    
2378    // Draw the frame
2379
if ( slider.hasFocus() ) {
2380        g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );
2381    }
2382    else {
2383        g.setColor( slider.isEnabled() ? MetalLookAndFeel.getPrimaryControlInfo() :
2384                                 MetalLookAndFeel.getControlDarkShadow() );
2385    }
2386
2387    g.drawLine( 1,0 , 13,0 ); // top
2388
g.drawLine( 0,1 , 0,8 ); // left
2389
g.drawLine( 14,1 , 14,8 ); // right
2390
g.drawLine( 1,9 , 7,15 ); // left slant
2391
g.drawLine( 7,15 , 14,8 ); // right slant
2392

2393    // Fill in the background
2394
if ( slider.hasFocus() ) {
2395        g.setColor( c.getForeground() );
2396    }
2397    else {
2398        g.setColor( MetalLookAndFeel.getControl() );
2399    }
2400    g.fillRect( 1,1, 13, 8 );
2401    
2402    g.drawLine( 2,9 , 12,9 );
2403    g.drawLine( 3,10 , 11,10 );
2404    g.drawLine( 4,11 , 10,11 );
2405    g.drawLine( 5,12 , 9,12 );
2406    g.drawLine( 6,13 , 8,13 );
2407    g.drawLine( 7,14 , 7,14 );
2408    
2409    // Draw the bumps
2410
if ( slider.isEnabled() ) {
2411        if ( slider.hasFocus() ) {
2412            primaryBumps.paintIcon( c, g, 2, 2 );
2413        }
2414        else {
2415            controlBumps.paintIcon( c, g, 2, 2 );
2416        }
2417    }
2418
2419    // Draw the highlight
2420
if ( slider.isEnabled() ) {
2421        g.setColor( slider.hasFocus() ? MetalLookAndFeel.getPrimaryControl()
2422            : MetalLookAndFeel.getControlHighlight() );
2423        g.drawLine( 1, 1, 13, 1 );
2424        g.drawLine( 1, 1, 1, 8 );
2425    }
2426        
2427        g.translate( -x, -y );
2428    }
2429
2430    public int getIconWidth() {
2431        return 15;
2432    }
2433
2434    public int getIconHeight() {
2435        return 16;
2436    }
2437}
2438
2439    private static class OceanVerticalSliderThumbIcon extends CachedPainter JavaDoc
2440                              implements Icon, Serializable JavaDoc, UIResource JavaDoc {
2441        // Used for clipping when the orientation is left to right
2442
private static Polygon LTR_THUMB_SHAPE;
2443        // Used for clipping when the orientation is right to left
2444
private static Polygon RTL_THUMB_SHAPE;
2445
2446        static {
2447            LTR_THUMB_SHAPE = new Polygon(new int[] { 0, 8, 15, 8, 0},
2448                                          new int[] { 0, 0, 7, 14, 14 }, 5);
2449            RTL_THUMB_SHAPE = new Polygon(new int[] { 15, 15, 7, 0, 7},
2450                                          new int[] { 0, 14, 14, 7, 0}, 5);
2451        }
2452
2453        OceanVerticalSliderThumbIcon() {
2454            super(3);
2455        }
2456
2457        public void paintIcon(Component c, Graphics g, int x, int y) {
2458            if (!(g instanceof Graphics2D)) {
2459                return;
2460            }
2461            paint(c, g, x, y, getIconWidth(), getIconHeight(),
2462                  MetalUtils.isLeftToRight(c), c.hasFocus(), c.isEnabled(),
2463                  MetalLookAndFeel.getCurrentTheme());
2464        }
2465
2466        protected void paintToImage(Component c, Graphics g2,
2467                                    int w, int h, Object JavaDoc[] args) {
2468            Graphics2D g = (Graphics2D)g2;
2469            boolean leftToRight = ((Boolean JavaDoc)args[0]).booleanValue();
2470            boolean hasFocus = ((Boolean JavaDoc)args[1]).booleanValue();
2471            boolean enabled = ((Boolean JavaDoc)args[2]).booleanValue();
2472
2473            Rectangle clip = g.getClipBounds();
2474            if (leftToRight) {
2475                g.clip(LTR_THUMB_SHAPE);
2476            }
2477            else {
2478                g.clip(RTL_THUMB_SHAPE);
2479            }
2480            if (!enabled) {
2481                g.setColor(MetalLookAndFeel.getControl());
2482                g.fillRect(1, 1, 14, 14);
2483            }
2484            else if (hasFocus) {
2485                MetalUtils.drawGradient(c, g, "Slider.focusGradient",
2486                                        1, 1, 14, 14, false);
2487            }
2488            else {
2489                MetalUtils.drawGradient(c, g, "Slider.gradient",
2490                                        1, 1, 14, 14, false);
2491            }
2492            g.setClip(clip);
2493
2494            // Draw the frame
2495
if (hasFocus) {
2496                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
2497            }
2498            else {
2499                g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
2500                           MetalLookAndFeel.getControlDarkShadow());
2501            }
2502
2503            if (leftToRight) {
2504                g.drawLine( 1,0 , 8,0 ); // top
2505
g.drawLine( 0,1 , 0,13 ); // left
2506
g.drawLine( 1,14 , 8,14 ); // bottom
2507
g.drawLine( 9,1 , 15,7 ); // top slant
2508
g.drawLine( 9,13 , 15,7 ); // bottom slant
2509
}
2510            else {
2511                g.drawLine( 7,0 , 14,0 ); // top
2512
g.drawLine( 15,1 , 15,13 ); // right
2513
g.drawLine( 7,14 , 14,14 ); // bottom
2514
g.drawLine( 0,7 , 6,1 ); // top slant
2515
g.drawLine( 0,7 , 6,13 ); // bottom slant
2516
}
2517
2518            if (hasFocus && enabled) {
2519                // Inner line.
2520
g.setColor(MetalLookAndFeel.getPrimaryControl());
2521                if (leftToRight) {
2522                    g.drawLine( 1,1 , 8,1 ); // top
2523
g.drawLine( 1,1 , 1,13 ); // left
2524
g.drawLine( 1,13 , 8,13 ); // bottom
2525
g.drawLine( 9,2 , 14,7 ); // top slant
2526
g.drawLine( 9,12 , 14,7 ); // bottom slant
2527
}
2528                else {
2529                    g.drawLine( 7,1 , 14,1 ); // top
2530
g.drawLine( 14,1 , 14,13 ); // right
2531
g.drawLine( 7,13 , 14,13 ); // bottom
2532
g.drawLine( 1,7 , 7,1 ); // top slant
2533
g.drawLine( 1,7 , 7,13 ); // bottom slant
2534
}
2535            }
2536        }
2537
2538        public int getIconWidth() {
2539            return 16;
2540        }
2541
2542        public int getIconHeight() {
2543            return 15;
2544        }
2545
2546        protected Image JavaDoc createImage(Component c, int w, int h,
2547                                    GraphicsConfiguration config) {
2548            return config.createCompatibleImage(
2549                                w, h, Transparency.BITMASK);
2550        }
2551    }
2552
2553
2554    private static class OceanHorizontalSliderThumbIcon extends CachedPainter JavaDoc
2555                              implements Icon, Serializable JavaDoc, UIResource JavaDoc {
2556        // Used for clipping
2557
private static Polygon THUMB_SHAPE;
2558
2559        static {
2560            THUMB_SHAPE = new Polygon(new int[] { 0, 14, 14, 7, 0 },
2561                                      new int[] { 0, 0, 8, 15, 8 }, 5);
2562        }
2563
2564        OceanHorizontalSliderThumbIcon() {
2565            super(3);
2566        }
2567
2568        public void paintIcon(Component c, Graphics g, int x, int y) {
2569            if (!(g instanceof Graphics2D)) {
2570                return;
2571            }
2572            paint(c, g, x, y, getIconWidth(), getIconHeight(),
2573                  c.hasFocus(), c.isEnabled(),
2574                  MetalLookAndFeel.getCurrentTheme());
2575        }
2576
2577
2578        protected Image JavaDoc createImage(Component c, int w, int h,
2579                                    GraphicsConfiguration config) {
2580            return config.createCompatibleImage(
2581                                w, h, Transparency.BITMASK);
2582        }
2583
2584        protected void paintToImage(Component c, Graphics g2,
2585                                    int w, int h, Object JavaDoc[] args) {
2586            Graphics2D g = (Graphics2D)g2;
2587            boolean hasFocus = ((Boolean JavaDoc)args[0]).booleanValue();
2588            boolean enabled = ((Boolean JavaDoc)args[1]).booleanValue();
2589
2590            // Fill in the background
2591
Rectangle clip = g.getClipBounds();
2592            g.clip(THUMB_SHAPE);
2593            if (!enabled) {
2594                g.setColor(MetalLookAndFeel.getControl());
2595                g.fillRect(1, 1, 13, 14);
2596            }
2597            else if (hasFocus) {
2598                MetalUtils.drawGradient(c, g, "Slider.focusGradient",
2599                                        1, 1, 13, 14, true);
2600            }
2601            else {
2602                MetalUtils.drawGradient(c, g, "Slider.gradient",
2603                                        1, 1, 13, 14, true);
2604            }
2605            g.setClip(clip);
2606
2607            // Draw the frame
2608
if (hasFocus) {
2609                g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
2610            }
2611            else {
2612                g.setColor(enabled ? MetalLookAndFeel.getPrimaryControlInfo() :
2613                           MetalLookAndFeel.getControlDarkShadow());
2614            }
2615
2616            g.drawLine( 1,0 , 13,0 ); // top
2617
g.drawLine( 0,1 , 0,8 ); // left
2618
g.drawLine( 14,1 , 14,8 ); // right
2619
g.drawLine( 1,9 , 7,15 ); // left slant
2620
g.drawLine( 7,15 , 14,8 ); // right slant
2621

2622            if (hasFocus && enabled) {
2623                // Inner line.
2624
g.setColor(MetalLookAndFeel.getPrimaryControl());
2625                g.fillRect(1, 1, 13, 1);
2626                g.fillRect(1, 2, 1, 7);
2627                g.fillRect(13, 2, 1, 7);
2628                g.drawLine(2, 9, 7, 14);
2629                g.drawLine(8, 13, 12, 9);
2630            }
2631        }
2632
2633        public int getIconWidth() {
2634            return 15;
2635        }
2636
2637        public int getIconHeight() {
2638            return 16;
2639        }
2640    }
2641}
2642
Popular Tags