Source for javax.swing.plaf.metal.MetalIconFactory

   1: /* MetalIconFactory.java --
   2:    Copyright (C) 2005 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package javax.swing.plaf.metal;
  40: 
  41: import java.awt.Color;
  42: import java.awt.Component;
  43: import java.awt.Graphics;
  44: import java.io.Serializable;
  45: 
  46: import javax.swing.AbstractButton;
  47: import javax.swing.Icon;
  48: import javax.swing.JCheckBox;
  49: import javax.swing.JCheckBoxMenuItem;
  50: import javax.swing.JFileChooser;
  51: import javax.swing.JInternalFrame;
  52: import javax.swing.JRadioButton;
  53: import javax.swing.JRadioButtonMenuItem;
  54: import javax.swing.JSlider;
  55: import javax.swing.SwingConstants;
  56: import javax.swing.UIManager;
  57: import javax.swing.plaf.UIResource;
  58: 
  59: 
  60: /**
  61:  * Creates icons for the {@link MetalLookAndFeel}.
  62:  */
  63: public class MetalIconFactory implements Serializable 
  64: {
  65: 
  66:   /** A constant representing "dark". */
  67:   public static final boolean DARK = false;
  68:     
  69:   /** A constant representing "light". */
  70:   public static final boolean LIGHT = true;
  71:   
  72:   /** A shared instance of the MenuArrowIcon. */
  73:   private static Icon menuArrow;
  74:   
  75:   /** A shared instance of the MenuItemArrowIcon. */
  76:   private static Icon menuItemArrow;
  77:     
  78:   /**
  79:    * An icon displayed for {@link JCheckBoxMenuItem} components.
  80:    */
  81:   private static class CheckBoxMenuItemIcon implements Icon, Serializable 
  82:   {
  83:     /**
  84:      * Creates a new icon instance.
  85:      */
  86:     public CheckBoxMenuItemIcon() 
  87:     {
  88:       // Nothing to do here.
  89:     }
  90:       
  91:     /**
  92:      * Returns the width of the icon, in pixels.
  93:      * 
  94:      * @return The width of the icon (10 pixels).
  95:      */
  96:     public int getIconWidth() 
  97:     {
  98:       return 10;
  99:     }
 100:     
 101:     /**
 102:      * Returns the height of the icon, in pixels.
 103:      * 
 104:      * @return The height of the icon (10 pixels).
 105:      */
 106:     public int getIconHeight() 
 107:     {
 108:       return 10;
 109:     }
 110:     
 111:     /**
 112:      * Paints the icon.
 113:      * 
 114:      * @param c  the component.
 115:      * @param g  the graphics device.
 116:      * @param x  the x-coordinate.
 117:      * @param y  the y-coordinate.
 118:      */
 119:     public void paintIcon(Component c, Graphics g, int x, int y) 
 120:     {
 121:       JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
 122:         
 123:       if (item.isArmed())
 124:         g.setColor(MetalLookAndFeel.getBlack());
 125:       else
 126:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 127:       g.drawLine(x, y, x + 8, y);
 128:       g.drawLine(x, y + 1, x, y + 8);
 129:       g.drawLine(x + 2, y + 8, x + 8, y + 8);
 130:       g.drawLine(x + 8, y + 2, x + 8, y + 7);
 131:       
 132:       g.setColor(MetalLookAndFeel.getWhite());
 133:       g.drawLine(x + 1, y + 1, x + 7, y + 1);
 134:       g.drawLine(x + 1, y + 2, x + 1, y + 7);
 135:       g.drawLine(x + 1, y + 9, x + 9, y + 9);
 136:       g.drawLine(x + 9, y + 1, x + 9, y + 8);
 137: 
 138:       // if the item is selected, we should draw a tick
 139:       if (item.isSelected())
 140:       {
 141:         g.setColor(MetalLookAndFeel.getBlack());
 142:         g.fillRect(x + 2, y + 2, 2, 5);
 143:         for (int i = 0; i < 6; i++)
 144:           g.drawLine(x + 8 - i, y + i, x + 9 - i, y + i);
 145:       }
 146: 
 147:     }        
 148:   }
 149: 
 150:   /**
 151:    * An icon used for the "detail view" button on a {@link JFileChooser} under
 152:    * the {@link MetalLookAndFeel}.
 153:    * 
 154:    * @see MetalIconFactory#getFileChooserDetailViewIcon()
 155:    */
 156:   private static class FileChooserDetailViewIcon implements Icon, Serializable
 157:   {
 158: 
 159:     /**
 160:      * Creates a new icon.
 161:      */
 162:     public FileChooserDetailViewIcon() 
 163:     {
 164:       // Nothing to do here.
 165:     }
 166:       
 167:     /**
 168:      * Returns the width of the icon, in pixels.
 169:      * 
 170:      * @return The width of the icon.
 171:      */
 172:     public int getIconWidth() 
 173:     {
 174:       return 18;
 175:     }
 176:     
 177:     /**
 178:      * Returns the height of the icon, in pixels.
 179:      * 
 180:      * @return The height of the icon.
 181:      */
 182:     public int getIconHeight() 
 183:     {
 184:       return 18;
 185:     }
 186:     
 187:     /**
 188:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 189:      * 
 190:      * @param c  the component (ignored).
 191:      * @param g  the graphics device.
 192:      * @param x  the x-coordinate for the top-left of the icon.
 193:      * @param y  the y-coordinate for the top-left of the icon.
 194:      */
 195:     public void paintIcon(Component c, Graphics g, int x, int y) 
 196:     {
 197:       Color savedColor = g.getColor();
 198:       g.setColor(MetalLookAndFeel.getBlack());
 199: 
 200:       // file 1 outline
 201:       g.drawLine(x + 2, y + 2, x + 5, y + 2);
 202:       g.drawLine(x + 6, y + 3, x + 6, y + 7);
 203:       g.drawLine(x + 2, y + 7, x + 6, y + 7);
 204:       g.drawLine(x + 2, y + 2, x + 2, y + 7);
 205:       
 206:       // file 2 outline
 207:       g.drawLine(x + 2, y + 10, x + 5, y + 10);
 208:       g.drawLine(x + 6, y + 11, x + 6, y + 15);
 209:       g.drawLine(x + 2, y + 15, x + 6, y + 15);
 210:       g.drawLine(x + 2, y + 10, x + 2, y + 15);
 211: 
 212:       // detail lines
 213:       g.drawLine(x + 8, y + 5, x + 15, y + 5);
 214:       g.drawLine(x + 8, y + 13, x + 15, y + 13);
 215:       
 216:       // fill files
 217:       g.setColor(MetalLookAndFeel.getPrimaryControl());
 218:       g.fillRect(x + 3, y + 3, 3, 4);
 219:       g.fillRect(x + 3, y + 11, 3, 4);
 220:       
 221:       // highlight files
 222:       g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
 223:       g.drawLine(x + 4, y + 4, x + 4, y + 5);
 224:       g.drawLine(x + 4, y + 12, x + 4, y + 13);
 225:       
 226:       g.setColor(savedColor);
 227:     }        
 228:   }
 229: 
 230:   /**
 231:    * An icon used for the "home folder" button on a {@link JFileChooser} under
 232:    * the {@link MetalLookAndFeel}.
 233:    * 
 234:    * @see MetalIconFactory#getFileChooserHomeFolderIcon()
 235:    */
 236:   private static class FileChooserHomeFolderIcon implements Icon, Serializable
 237:   {
 238: 
 239:     /**
 240:      * Creates a new icon.
 241:      */
 242:     public FileChooserHomeFolderIcon() 
 243:     {
 244:       // Nothing to do here.
 245:     }
 246: 
 247:     /**
 248:      * Returns the width of the icon, in pixels.
 249:      * 
 250:      * @return The width of the icon.
 251:      */
 252:     public int getIconWidth() 
 253:     {
 254:       return 18;
 255:     }
 256:     
 257:     /**
 258:      * Returns the height of the icon, in pixels.
 259:      * 
 260:      * @return The height of the icon.
 261:      */
 262:     public int getIconHeight() 
 263:     {
 264:       return 18;
 265:     }
 266:     
 267:     /**
 268:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 269:      * 
 270:      * @param c  the component (ignored).
 271:      * @param g  the graphics device.
 272:      * @param x  the x-coordinate for the top-left of the icon.
 273:      * @param y  the y-coordinate for the top-left of the icon.
 274:      */
 275:     public void paintIcon(Component c, Graphics g, int x, int y) 
 276:     {   
 277:       Color savedColor = g.getColor();
 278:       g.setColor(MetalLookAndFeel.getBlack());
 279:       
 280:       // roof
 281:       g.drawLine(x + 1, y + 8, x + 8, y + 1);
 282:       g.drawLine(x + 8, y + 1, x + 15, y + 8);
 283:       
 284:       // base of house
 285:       g.drawLine(x + 3, y + 6, x + 3, y + 15);
 286:       g.drawLine(x + 3, y + 15, x + 13, y + 15);
 287:       g.drawLine(x + 13, y + 6, x + 13, y + 15);
 288:       
 289:       // door frame
 290:       g.drawLine(x + 6, y + 9, x + 6, y + 15);
 291:       g.drawLine(x + 6, y + 9, x + 10, y + 9);
 292:       g.drawLine(x + 10, y + 9, x + 10, y + 15);
 293:       
 294:       // chimney
 295:       g.drawLine(x + 11, y + 2, x + 11, y + 4);
 296:       g.drawLine(x + 12, y + 2, x + 12, y + 5);
 297:       
 298:       g.setColor(MetalLookAndFeel.getControlDarkShadow());
 299:       
 300:       // roof paint
 301:       int xx = x + 8;
 302:       for (int i = 0; i < 4; i++)
 303:         g.drawLine(xx - i, y + 2 + i, xx + i, y + 2 + i);
 304:       g.fillRect(x + 4, y + 6, 9, 2);
 305:       
 306:       // door knob
 307:       g.drawLine(x + 9, y + 12, x + 9, y + 12);
 308:       
 309:       // house paint
 310:       g.setColor(MetalLookAndFeel.getPrimaryControl());
 311:       g.drawLine(x + 4, y + 8, x + 12, y + 8);
 312:       g.fillRect(x + 4, y + 9, 2, 6);
 313:       g.fillRect(x + 11, y + 9, 2, 6);
 314:       
 315:       g.setColor(savedColor);
 316:     }        
 317:   }
 318:     
 319:   /**
 320:    * An icon used for the "list view" button on a {@link JFileChooser} under
 321:    * the {@link MetalLookAndFeel}.
 322:    * 
 323:    * @see MetalIconFactory#getFileChooserListViewIcon()
 324:    */
 325:   private static class FileChooserListViewIcon implements Icon, Serializable 
 326:   {
 327:     /**
 328:      * Creates a new icon.
 329:      */
 330:     public FileChooserListViewIcon() 
 331:     {
 332:       // Nothing to do here.
 333:     }
 334:     
 335:     /**
 336:      * Returns the width of the icon, in pixels.
 337:      * 
 338:      * @return The width of the icon.
 339:      */
 340:     public int getIconWidth() 
 341:     {
 342:       return 18;
 343:     }
 344:     
 345:     /**
 346:      * Returns the height of the icon, in pixels.
 347:      * 
 348:      * @return The height of the icon.
 349:      */
 350:     public int getIconHeight() 
 351:     {
 352:       return 18;
 353:     }
 354:     
 355:     /**
 356:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 357:      * 
 358:      * @param c  the component (ignored).
 359:      * @param g  the graphics device.
 360:      * @param x  the x-coordinate for the top-left of the icon.
 361:      * @param y  the y-coordinate for the top-left of the icon.
 362:      */
 363:     public void paintIcon(Component c, Graphics g, int x, int y) 
 364:     {
 365:       Color savedColor = g.getColor();
 366:       g.setColor(MetalLookAndFeel.getBlack());
 367: 
 368:       // file 1 outline
 369:       g.drawLine(x + 2, y + 2, x + 5, y + 2);
 370:       g.drawLine(x + 6, y + 3, x + 6, y + 7);
 371:       g.drawLine(x + 2, y + 7, x + 6, y + 7);
 372:       g.drawLine(x + 2, y + 2, x + 2, y + 7);
 373:       
 374:       // file 2 outline
 375:       g.drawLine(x + 2, y + 10, x + 5, y + 10);
 376:       g.drawLine(x + 6, y + 11, x + 6, y + 15);
 377:       g.drawLine(x + 2, y + 15, x + 6, y + 15);
 378:       g.drawLine(x + 2, y + 10, x + 2, y + 15);
 379:       
 380:       // file 3 outline
 381:       g.drawLine(x + 10, y + 2, x + 13, y + 2);
 382:       g.drawLine(x + 14, y + 3, x + 14, y + 7);
 383:       g.drawLine(x + 10, y + 7, x + 14, y + 7);
 384:       g.drawLine(x + 10, y + 2, x + 10, y + 7);
 385:       
 386:       // file 4 outline
 387:       g.drawLine(x + 10, y + 10, x + 13, y + 10);
 388:       g.drawLine(x + 14, y + 11, x + 14, y + 15);
 389:       g.drawLine(x + 10, y + 15, x + 14, y + 15);
 390:       g.drawLine(x + 10, y + 10, x + 10, y + 15);
 391:       
 392:       g.drawLine(x + 8, y + 5, x + 8, y + 5);
 393:       g.drawLine(x + 8, y + 13, x + 8, y + 13);
 394:       g.drawLine(x + 16, y + 5, x + 16, y + 5);
 395:       g.drawLine(x + 16, y + 13, x + 16, y + 13);
 396:       
 397:       // fill files
 398:       g.setColor(MetalLookAndFeel.getPrimaryControl());
 399:       g.fillRect(x + 3, y + 3, 3, 4);
 400:       g.fillRect(x + 3, y + 11, 3, 4);
 401:       g.fillRect(x + 11, y + 3, 3, 4);
 402:       g.fillRect(x + 11, y + 11, 3, 4);
 403:       
 404:       // highlight files
 405:       g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
 406:       g.drawLine(x + 4, y + 4, x + 4, y + 5);
 407:       g.drawLine(x + 4, y + 12, x + 4, y + 13);
 408:       g.drawLine(x + 12, y + 4, x + 12, y + 5);
 409:       g.drawLine(x + 12, y + 12, x + 12, y + 13);
 410: 
 411:       g.setColor(savedColor);
 412:     }        
 413:   }
 414:     
 415:   /**
 416:    * An icon used for the "new folder" button on a {@link JFileChooser} under
 417:    * the {@link MetalLookAndFeel}.
 418:    * 
 419:    * @see MetalIconFactory#getFileChooserNewFolderIcon()
 420:    */
 421:   private static class FileChooserNewFolderIcon  implements Icon, Serializable
 422:   {
 423:     /** 
 424:      * Creates a new icon.
 425:      */
 426:     public FileChooserNewFolderIcon() 
 427:     {
 428:       // Nothing to do here.
 429:     }
 430:     
 431:     /**
 432:      * Returns the width of the icon, in pixels.
 433:      * 
 434:      * @return The width of the icon.
 435:      */
 436:     public int getIconWidth() 
 437:     {
 438:       return 18;
 439:     }
 440:     
 441:     /**
 442:      * Returns the height of the icon, in pixels.
 443:      * 
 444:      * @return The height of the icon.
 445:      */
 446:     public int getIconHeight() 
 447:     {
 448:       return 18;
 449:     }
 450:     
 451:     /**
 452:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 453:      * 
 454:      * @param c  the component (ignored).
 455:      * @param g  the graphics device.
 456:      * @param x  the x-coordinate for the top-left of the icon.
 457:      * @param y  the y-coordinate for the top-left of the icon.
 458:      */
 459:     public void paintIcon(Component c, Graphics g, int x, int y) 
 460:     {      
 461:       Color savedColor = g.getColor();
 462:       g.setColor(MetalLookAndFeel.getBlack());
 463:       
 464:       g.drawLine(x + 2, y + 5, x + 9, y + 5);
 465:       g.drawLine(x + 10, y + 6, x + 15, y + 6);
 466:       g.drawLine(x + 15, y + 5, x + 15, y + 14);
 467:       g.drawLine(x + 2, y + 14, x + 15, y + 14);
 468:       g.drawLine(x + 1, y + 6, x + 1, y + 14);
 469:       
 470:       g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
 471:       g.drawLine(x + 11, y + 3, x + 15, y + 3);
 472:       g.drawLine(x + 10, y + 4, x + 15, y + 4);
 473:       
 474:       g.setColor(MetalLookAndFeel.getPrimaryControl());
 475:       g.fillRect(x + 3, y + 7, 7, 7);
 476:       g.fillRect(x + 10, y + 8, 5, 6);
 477:       g.drawLine(x + 10, y + 5, x + 14, y + 5);
 478:       
 479:       g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());
 480:       g.drawLine(x + 10, y + 7, x + 14, y + 7);
 481:       g.drawLine(x + 2, y + 6, x + 9, y + 6);
 482:       g.drawLine(x + 2, y + 6, x + 2, y + 13);
 483:       g.setColor(savedColor);
 484:     }        
 485:   }
 486: 
 487:   /**
 488:    * An icon used for the "up folder" button on a {@link JFileChooser} under
 489:    * the {@link MetalLookAndFeel}.
 490:    * 
 491:    * @see MetalIconFactory#getFileChooserNewFolderIcon()
 492:    */
 493:   private static class FileChooserUpFolderIcon extends FileChooserNewFolderIcon
 494:     implements Icon, Serializable 
 495:   {
 496:     /**
 497:      * Creates a new icon.
 498:      */
 499:     public FileChooserUpFolderIcon() 
 500:     {
 501:       // Nothing to do here.
 502:     }
 503:     
 504:     /**
 505:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 506:      * 
 507:      * @param c  the component (ignored).
 508:      * @param g  the graphics device.
 509:      * @param x  the x-coordinate for the top-left of the icon.
 510:      * @param y  the y-coordinate for the top-left of the icon.
 511:      */
 512:     public void paintIcon(Component c, Graphics g, int x, int y) 
 513:     {
 514:       Color savedColor = g.getColor();
 515: 
 516:       // draw the folder
 517:       super.paintIcon(c, g, x, y);
 518:       
 519:       // now draw the up arrow
 520:       g.setColor(MetalLookAndFeel.getBlack());
 521:       g.drawLine(x + 8, y + 9, x + 8, y + 16);
 522:       int xx = x + 8;
 523:       for (int i = 0; i < 4; i++)
 524:         g.drawLine(xx - i, y + 9 + i, xx + i, y + 9 + i);
 525:       g.setColor(savedColor);
 526:     }        
 527:   }
 528: 
 529:   /**
 530:    * An icon representing a file (drawn as a piece of paper with the top-right
 531:    * corner turned down).
 532:    */
 533:   public static class FileIcon16 implements Icon, Serializable 
 534:   {
 535:     /**
 536:      * Returns the width of the icon, in pixels.
 537:      * 
 538:      * @return The width of the icon.
 539:      */
 540:     public int getIconWidth() 
 541:     {
 542:       return 16;
 543:     }
 544: 
 545:     /**
 546:      * Returns the height of the icon, in pixels.  The height returned is 
 547:      * <code>16</code> plus the value returned by 
 548:      * {@link #getAdditionalHeight()}.
 549:      * 
 550:      * @return The height of the icon.
 551:      */
 552:     public int getIconHeight() 
 553:     {
 554:       return 16 + getAdditionalHeight();
 555:     }
 556:     
 557:     /**
 558:      * Paints the icon at the location (x, y).
 559:      * 
 560:      * @param c  the component.
 561:      * @param g  the graphics context.
 562:      * @param x  the x coordinate.
 563:      * @param y  the y coordinate.
 564:      */
 565:     public void paintIcon(Component c, Graphics g, int x, int y) 
 566:     {
 567:       // TODO: pick up appropriate UI colors
 568:       g.setColor(Color.black);
 569:       g.drawLine(x, y, x + 9, y);            
 570:       g.drawLine(x, y + 1, x, y + 15);            
 571:       g.drawLine(x, y + 15, x + 12, y + 15);            
 572:       g.drawLine(x + 12, y + 15, x + 12, y + 6);            
 573:       g.drawLine(x + 12, y + 6, x + 9, y);           
 574: 
 575:       g.drawLine(x + 7, y + 2, x + 11, y + 6);
 576:       g.drawLine(x + 8, y + 1, x + 9, y + 1);
 577: 
 578:       g.setColor(new Color(204, 204, 255));
 579:       g.drawLine(x + 1, y + 1, x + 7, y + 1);            
 580:       g.drawLine(x + 1, y + 1, x + 1, y + 14);            
 581:       g.drawLine(x + 1, y + 14, x + 11, y + 14);            
 582:       g.drawLine(x + 11, y + 14, x + 11, y + 7);            
 583:       g.drawLine(x + 8, y + 2, x + 10, y + 4);
 584:     }
 585:     
 586:     /**
 587:      * Returns the additional height for the icon.  The 
 588:      * {@link #getIconHeight()} method adds this value to the icon height it
 589:      * returns.  Subclasses can override this method to adjust the icon height.
 590:      * 
 591:      * @return The additional height (<code>0</code> unless overridden).
 592:      */
 593:     public int getAdditionalHeight() 
 594:     {
 595:       return 0;
 596:     }
 597:         
 598:     /**
 599:      * Returns the shift (???).
 600:      * 
 601:      * @return The shift.
 602:      */
 603:     public int getShift() 
 604:     {
 605:       return 0;
 606:     }
 607:         
 608:   }
 609:     
 610:   /**
 611:    * An icon representing a folder.
 612:    */
 613:   public static class FolderIcon16 implements Icon, Serializable 
 614:   {
 615:     /**
 616:      * Returns the width of the icon, in pixels.
 617:      * 
 618:      * @return The width of the icon.
 619:      */
 620:     public int getIconWidth() {
 621:       return 16;
 622:     }
 623:     
 624:     /**
 625:      * Returns the height of the icon, in pixels.  The height returned is 
 626:      * <code>16</code> plus the value returned by 
 627:      * {@link #getAdditionalHeight()}.
 628:      * 
 629:      * @return The height of the icon.
 630:      */
 631:     public int getIconHeight() 
 632:     {
 633:       return 16 + getAdditionalHeight();
 634:     }
 635: 
 636:     /**
 637:      * Paints the icon at the location (x, y).
 638:      * 
 639:      * @param c  the component.
 640:      * @param g  the graphics device.
 641:      * @param x  the x coordinate.
 642:      * @param y  the y coordinate.
 643:      */
 644:     public void paintIcon(Component c, Graphics g, int x, int y) 
 645:     {
 646:       // TODO: pick up appropriate UI colors
 647:       g.setColor(Color.black);
 648:       g.drawLine(x, y + 3, x, y + 12);
 649:       g.drawLine(x, y + 12, x + 15, y + 12);
 650:       g.drawLine(x + 15, y + 12, x + 15, y + 2);
 651:       g.drawLine(x + 14, y + 3, x + 9, y + 3);
 652:       g.drawLine(x + 8, y + 2, x + 1, y + 2);
 653:       g.setColor(new Color(204, 204, 255));
 654:       g.fillRect(x + 2, y + 4, 7, 8);
 655:       g.fillRect(x + 9, y + 5, 6, 7);
 656:       g.setColor(new Color(102, 102, 153));
 657:       g.drawLine(x + 9, y + 2, x + 14, y + 2);
 658:       g.setColor(new Color(50, 50, 120));
 659:       g.drawLine(x + 9, y + 1, x + 15, y + 1);
 660:       g.drawLine(x + 10, y, x + 15, y);
 661:     }
 662:     
 663:     /**
 664:      * Returns the additional height for the icon.  The 
 665:      * {@link #getIconHeight()} method adds this value to the icon height it
 666:      * returns.  Subclasses can override this method to adjust the icon height.
 667:      * 
 668:      * @return The additional height (<code>0</code> unless overridden).
 669:      */
 670:     public int getAdditionalHeight() 
 671:     {
 672:       return 0;
 673:     }
 674:     
 675:     /**
 676:      * Returns the shift (???).
 677:      * 
 678:      * @return The shift.
 679:      */
 680:     public int getShift() 
 681:     {
 682:       return 0;
 683:     }
 684:         
 685:   }
 686: 
 687:   /**
 688:    * An icon used by the {@link MetalInternalFrameUI} class when the frame
 689:    * is displayed as a palette.
 690:    * 
 691:    * @since 1.3
 692:    */
 693:   public static class PaletteCloseIcon
 694:     implements Icon, Serializable, UIResource
 695:   {
 696:     /**
 697:      * Returns the width of the icon, in pixels.
 698:      * 
 699:      * @return The width of the icon.
 700:      */
 701:     public int getIconWidth() 
 702:     {
 703:       return 7;
 704:     }
 705:     
 706:     /**
 707:      * Returns the height of the icon, in pixels.
 708:      * 
 709:      * @return The height of the icon.
 710:      */
 711:     public int getIconHeight() 
 712:     {
 713:       return 7;
 714:     }
 715:     
 716:     /**
 717:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 718:      * 
 719:      * @param c  the component (ignored).
 720:      * @param g  the graphics device.
 721:      * @param x  the x-coordinate for the top-left of the icon.
 722:      * @param y  the y-coordinate for the top-left of the icon.
 723:      */
 724:     public void paintIcon(Component c, Graphics g, int x, int y) 
 725:     {
 726:       Color savedColor = g.getColor();
 727:       AbstractButton button = (AbstractButton) c;
 728:       if (button.getModel().isPressed())
 729:         g.setColor(MetalLookAndFeel.getBlack());
 730:       else
 731:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 732:       g.fillRect(x + 2, y + 2, 3, 3);
 733:       g.drawLine(x + 1, y, x + 1, y + 2);
 734:       g.drawLine(x, y + 1, x + 2, y + 1);
 735:       g.drawLine(x + 5, y, x + 5, y + 2);
 736:       g.drawLine(x + 4, y + 1, x + 6, y + 1);
 737:       g.drawLine(x + 1, y + 4, x + 1, y + 6);
 738:       g.drawLine(x, y + 5, x + 2, y + 5);
 739:       g.drawLine(x + 5, y + 4, x + 5, y + 6);
 740:       g.drawLine(x + 4, y + 5, x + 6, y + 5);
 741:       g.setColor(MetalLookAndFeel.getControlHighlight());
 742:       g.drawLine(x + 2, y + 6, x + 3, y + 5);
 743:       g.drawLine(x + 5, y + 3, x + 6, y + 2);
 744:       g.drawLine(x + 6, y + 6, x + 6, y + 6);
 745:       g.setColor(savedColor);
 746:     }        
 747:   }
 748:   
 749:   /**
 750:    * An {@link Icon} implementation for {@link JCheckBox}es in the
 751:    * Metal Look &amp; Feel.
 752:    *
 753:    * @author Roman Kennke (roman@kennke.org)
 754:    */
 755:   static class RadioButtonIcon implements Icon, UIResource, Serializable
 756:   {
 757: 
 758:     /**
 759:      * This is used as a mask when painting the gradient. See
 760:      * {@link MetalUtils#paintGradient(java.awt.Graphics, int, int, int, int,
 761:      *  float, float, java.awt.Color, java.awt.Color, java.awt.Color, int,
 762:      *  int[][])} for details.
 763:      */
 764:     private static int[][] gradientMask = new int[][] {{3, 7}, {1, 9}, {1, 9},
 765:                                                        {0, 10}, {0, 10}, {0, 10},
 766:                                                        {0, 10}, {1, 9}, {1, 9},
 767:                                                        {3, 7}};
 768: 
 769:     /**
 770:      * Returns the width of the icon in pixels.
 771:      *
 772:      * @return the width of the icon in pixels
 773:      */
 774:     public int getIconWidth()
 775:     {
 776:       return 13;
 777:     }
 778: 
 779:     /**
 780:      * Returns the height of the icon in pixels.
 781:      *
 782:      * @return the height of the icon in pixels
 783:      */
 784:     public int getIconHeight()
 785:     {
 786:       return 13;
 787:     }
 788: 
 789:     /**
 790:      * Paints the icon, taking into account whether or not the component is
 791:      * enabled, selected and/or armed.
 792:      *
 793:      * @param c the Component to draw on (must be an instance of 
 794:      *          {@link JRadioButton})
 795:      * @param g the Graphics context to draw with
 796:      * @param x the X position
 797:      * @param y the Y position
 798:      */
 799:     public void paintIcon(Component c, Graphics g, int x, int y) 
 800:     {
 801:       if (UIManager.get("RadioButton.gradient") != null)
 802:         MetalUtils.paintGradient(g, x + 2, y + 2, 8, 8,
 803:                               SwingConstants.VERTICAL, "RadioButton.gradient",
 804:                               gradientMask);
 805: 
 806:       Color savedColor = g.getColor();
 807:       JRadioButton b = (JRadioButton) c;
 808: 
 809:       // draw outer circle
 810:       if (b.isEnabled())
 811:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 812:       else
 813:         g.setColor(MetalLookAndFeel.getControlDisabled());
 814:       g.drawLine(x + 2, y + 1, x + 3, y + 1);
 815:       g.drawLine(x + 4, y, x + 7, y);
 816:       g.drawLine(x + 8, y + 1, x + 9, y + 1);
 817:       g.drawLine(x + 10, y + 2, x + 10, y + 3);
 818:       g.drawLine(x + 11, y + 4, x + 11, y + 7);
 819:       g.drawLine(x + 10, y + 8, x + 10, y + 9);
 820:       g.drawLine(x + 8, y + 10, x + 9, y + 10);
 821:       g.drawLine(x + 4, y + 11, x + 7, y + 11);
 822:       g.drawLine(x + 2, y + 10, x + 3, y + 10);
 823:       g.drawLine(x + 1, y + 9, x + 1, y + 8);
 824:       g.drawLine(x, y + 7, x, y + 4);
 825:       g.drawLine(x + 1, y + 2, x + 1, y + 3);
 826: 
 827:       if (b.getModel().isArmed())
 828:         {
 829:           g.setColor(MetalLookAndFeel.getControlShadow());
 830:           g.drawLine(x + 4, y + 1, x + 7, y + 1);
 831:           g.drawLine(x + 4, y + 10, x + 7, y + 10);
 832:           g.drawLine(x + 1, y + 4, x + 1, y + 7);
 833:           g.drawLine(x + 10, y + 4, x + 10, y + 7);
 834:           g.fillRect(x + 2, y + 2, 8, 8);
 835:         }
 836:       else 
 837:         {
 838:           // only draw inner highlight if not filled
 839:           if (b.isEnabled())
 840:             {
 841:               g.setColor(MetalLookAndFeel.getWhite());
 842:           
 843:               g.drawLine(x + 2, y + 8, x + 2, y + 9);
 844:               g.drawLine(x + 1, y + 4, x + 1, y + 7);
 845:               g.drawLine(x + 2, y + 2, x + 2, y + 3);
 846:               g.drawLine(x + 3, y + 2, x + 3, y + 2);
 847:               g.drawLine(x + 4, y + 1, x + 7, y + 1);
 848:               g.drawLine(x + 8, y + 2, x + 9, y + 2);
 849:             }
 850:         }
 851: 
 852:       // draw outer highlight
 853:       if (b.isEnabled())
 854:         {
 855:           g.setColor(MetalLookAndFeel.getWhite());
 856:           
 857:           // outer
 858:           g.drawLine(x + 10, y + 1, x + 10, y + 1);
 859:           g.drawLine(x + 11, y + 2, x + 11, y + 3);
 860:           g.drawLine(x + 12, y + 4, x + 12, y + 7);
 861:           g.drawLine(x + 11, y + 8, x + 11, y + 9);
 862:           g.drawLine(x + 10, y + 10, x + 10, y + 10);
 863:           g.drawLine(x + 8, y + 11, x + 9, y + 11);
 864:           g.drawLine(x + 4, y + 12, x + 7, y + 12);
 865:           g.drawLine(x + 2, y + 11, x + 3, y + 11);
 866:         }
 867:       
 868:       if (b.isSelected())
 869:         {
 870:           if (b.isEnabled())
 871:             g.setColor(MetalLookAndFeel.getBlack());
 872:           else
 873:             g.setColor(MetalLookAndFeel.getControlDisabled());
 874:           g.drawLine(x + 4, y + 3, x + 7, y + 3);
 875:           g.fillRect(x + 3, y + 4, 6, 4);
 876:           g.drawLine(x + 4, y + 8, x + 7, y + 8);
 877:         }
 878:       g.setColor(savedColor);
 879:     }        
 880:   }
 881: 
 882:   /**
 883:    * An icon displayed for {@link JRadioButtonMenuItem} components.
 884:    */
 885:   private static class RadioButtonMenuItemIcon implements Icon, Serializable 
 886:   {
 887:     /**
 888:      * Creates a new icon instance.
 889:      */
 890:     public RadioButtonMenuItemIcon() 
 891:     {
 892:       // Nothing to do here.
 893:     }
 894: 
 895:     /**
 896:      * Returns the width of the icon, in pixels.
 897:      * 
 898:      * @return The width of the icon.
 899:      */
 900:     public int getIconWidth() 
 901:     {
 902:       return 10;
 903:     }
 904: 
 905:     /**
 906:      * Returns the height of the icon, in pixels.
 907:      * 
 908:      * @return The height of the icon.
 909:      */
 910:     public int getIconHeight()   
 911:     {
 912:       return 10;
 913:     }
 914: 
 915:     /**
 916:      * Paints the icon.
 917:      * 
 918:      * @param c  the component.
 919:      * @param g  the graphics device.
 920:      * @param x  the x-coordinate.
 921:      * @param y  the y-coordinate.
 922:      */
 923:     public void paintIcon(Component c, Graphics g, int x, int y) 
 924:     {
 925:       Color savedColor = g.getColor();
 926:       JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
 927:       g.setColor(MetalLookAndFeel.getBlack());
 928:       g.drawLine(x + 2, y, x + 6, y);
 929:       g.drawLine(x + 7, y + 1, x + 7, y + 1);
 930:       g.drawLine(x + 8, y + 2, x + 8, y + 6);
 931:       g.drawLine(x + 7, y + 7, x + 7, y + 7);
 932:       g.drawLine(x + 2, y + 8, x + 6, y + 8);
 933:       g.drawLine(x + 1, y + 7, x + 1, y + 7);
 934:       g.drawLine(x, y + 2, x, y + 6);
 935:       g.drawLine(x + 1, y + 1, x + 1, y + 1);
 936:       
 937:       if (item.isSelected())
 938:         {
 939:           g.drawLine(x + 3, y + 2, x + 5, y + 2);
 940:           g.fillRect(x + 2, y + 3, 5, 3);
 941:           g.drawLine(x + 3, y + 6, x + 5, y + 6);
 942:         }
 943: 
 944:       // highlight
 945:       g.setColor(MetalLookAndFeel.getControlHighlight());
 946:       g.drawLine(x + 3, y + 1, x + 6, y + 1);
 947:       g.drawLine(x + 8, y + 1, x + 8, y + 1);
 948:       g.drawLine(x + 9, y + 2, x + 9, y + 7);
 949:       g.drawLine(x + 8, y + 8, x + 8, y + 8);
 950:       g.drawLine(x + 2, y + 9, x + 7, y + 9);
 951:       g.drawLine(x + 1, y + 8, x + 1, y + 8);
 952:       g.drawLine(x + 1, y + 3, x + 1, y + 6);
 953:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
 954:       g.setColor(savedColor);
 955:     }        
 956:   }
 957: 
 958:   /**
 959:    * The icon used to display the thumb control on a horizontally oriented
 960:    * {@link JSlider} component.
 961:    */
 962:   private static class HorizontalSliderThumbIcon  implements Icon, Serializable
 963:   {
 964: 
 965:     /**
 966:      * This mask is used to paint the gradient in the shape of the thumb.
 967:      */
 968:     int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
 969:                                          {0, 12}, {0, 12}, {0, 12}, {1, 12},
 970:                                          {2, 10}, {3, 9}, {4, 8}, {5, 7},
 971:                                          {6, 6}};
 972: 
 973:     /**
 974:      * Creates a new instance.
 975:      */
 976:     public HorizontalSliderThumbIcon() 
 977:     {
 978:       // Nothing to do here.
 979:     }
 980:     
 981:     /**
 982:      * Returns the width of the icon, in pixels.
 983:      * 
 984:      * @return The width of the icon.
 985:      */
 986:     public int getIconWidth() 
 987:     {
 988:       return 15;
 989:     }
 990:     
 991:     /**
 992:      * Returns the height of the icon, in pixels.
 993:      * 
 994:      * @return The height of the icon.
 995:      */
 996:     public int getIconHeight() 
 997:     {
 998:       return 16;
 999:     }
1000:     
1001:     /**
1002:      * Paints the icon, taking into account whether or not the component has 
1003:      * the focus.
1004:      * 
1005:      * @param c  the component.
1006:      * @param g  the graphics device.
1007:      * @param x  the x-coordinate.
1008:      * @param y  the y-coordinate.
1009:      */
1010:     public void paintIcon(Component c, Graphics g, int x, int y) 
1011:     {
1012:       boolean enabled = false;
1013:       boolean focus = false;
1014:       if (c != null)
1015:         {
1016:           enabled = c.isEnabled();
1017:           focus = c.hasFocus();    
1018:         }
1019:       
1020:       // draw the outline
1021:       if (enabled) 
1022:         g.setColor(MetalLookAndFeel.getBlack());
1023:       else
1024:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
1025:       g.drawLine(x + 1, y, x + 13, y);
1026:       g.drawLine(x + 14, y + 1, x + 14, y + 7);
1027:       g.drawLine(x + 14, y + 8, x + 7, y + 15);
1028:       g.drawLine(x + 6, y + 14, x, y + 8);
1029:       g.drawLine(x, y + 7, x, y + 1);
1030:       
1031:       // Fill the icon.
1032:       if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
1033:           && enabled)
1034:         {
1035:           String gradient;
1036:           if (focus)
1037:             gradient = "Slider.focusGradient";
1038:           else
1039:             gradient = "Slider.gradient";
1040:           MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13,
1041:                                    SwingConstants.VERTICAL, gradient,
1042:                                    gradientMask);
1043:         }
1044:       else
1045:         {
1046:           if (focus)
1047:             g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1048:           else
1049:             g.setColor(MetalLookAndFeel.getControl());
1050:           g.fillRect(x + 1, y + 2, 13, 7);
1051:           g.drawLine(x + 2, y + 9, x + 12, y + 9);
1052:           g.drawLine(x + 3, y + 10, x + 11, y + 10);
1053:           g.drawLine(x + 4, y + 11, x + 10, y + 11);
1054:           g.drawLine(x + 5, y + 12, x + 9, y + 12);
1055:           g.drawLine(x + 6, y + 13, x + 8, y + 13);
1056:           g.drawLine(x + 7, y + 14, x + 7, y + 14);
1057:         }
1058: 
1059:       // If the slider is enabled, draw dots and highlights.
1060:       if (c.isEnabled()
1061:           && !(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
1062:         {
1063:           if (focus)
1064:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1065:           else
1066:             g.setColor(MetalLookAndFeel.getBlack());
1067:           g.drawLine(x + 3, y + 3, x + 3, y + 3);
1068:           g.drawLine(x + 7, y + 3, x + 7, y + 3);
1069:           g.drawLine(x + 11, y + 3, x + 11, y + 3);
1070: 
1071:           g.drawLine(x + 5, y + 5, x + 5, y + 5);
1072:           g.drawLine(x + 9, y + 5, x + 9, y + 5);
1073: 
1074:           g.drawLine(x + 3, y + 7, x + 3, y + 7);
1075:           g.drawLine(x + 7, y + 7, x + 7, y + 7);
1076:           g.drawLine(x + 11, y + 7, x + 11, y + 7);
1077: 
1078:           // Draw highlights
1079:           if (focus)
1080:             g.setColor(MetalLookAndFeel.getPrimaryControl());
1081:           else
1082:             g.setColor(MetalLookAndFeel.getWhite());
1083:           g.drawLine(x + 1, y + 1, x + 13, y + 1);
1084:           g.drawLine(x + 1, y + 2, x + 1, y + 8);
1085:           g.drawLine(x + 2, y + 2, x + 2, y + 2);
1086:           g.drawLine(x + 6, y + 2, x + 6, y + 2);
1087:           g.drawLine(x + 10, y + 2, x + 10, y + 2);
1088:           
1089:           g.drawLine(x + 4, y + 4, x + 4, y + 4);
1090:           g.drawLine(x + 8, y + 4, x + 8, y + 4);
1091: 
1092:           g.drawLine(x + 2, y + 6, x + 2, y + 6);
1093:           g.drawLine(x + 6, y + 6, x + 6, y + 6);
1094:           g.drawLine(x + 10, y + 6, x + 10, y + 6);
1095:         }
1096: 
1097:     }        
1098:   }
1099:   
1100:   /**
1101:    * An icon used for the 'close' button in the title frame of a 
1102:    * {@link JInternalFrame}.
1103:    */
1104:   private static class InternalFrameCloseIcon implements Icon, Serializable
1105:   {
1106:     /** The icon size in pixels. */
1107:     private int size;
1108:     
1109:     /**
1110:      * Creates a new icon.
1111:      * 
1112:      * @param size  the icon size (width and height) in pixels.
1113:      */
1114:     public InternalFrameCloseIcon(int size) 
1115:     {
1116:       this.size = size;
1117:     }
1118:     
1119:     /**
1120:      * Returns the width of the icon, in pixels.
1121:      * 
1122:      * @return The width of the icon.
1123:      */
1124:     public int getIconWidth() 
1125:     {
1126:       return size;
1127:     }
1128:     
1129:     /**
1130:      * Returns the height of the icon, in pixels.
1131:      * 
1132:      * @return The height of the icon.
1133:      */
1134:     public int getIconHeight() 
1135:     {
1136:       return size;
1137:     }
1138:     
1139:     /**
1140:      * Paints the icon.
1141:      * 
1142:      * @param c  the component (an {@link JInternalFrame} is expected).
1143:      * @param g  the graphics device.
1144:      * @param x  the x-coordinate.
1145:      * @param y  the y-coordinate.
1146:      */
1147:     public void paintIcon(Component c, Graphics g, int x, int y) 
1148:     {
1149:       Color savedColor = g.getColor();
1150:       AbstractButton b = (AbstractButton) c;
1151:       
1152:       // fill the interior
1153:       if (b.getModel().isPressed())
1154:         // FIXME: also need to take into account whether the internal frame is
1155:         // selected
1156:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1157:       else
1158:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1159:       g.fillRect(x + 2, y + 2, 10, 10);
1160:       
1161:       // draw the outline box and the cross
1162:       if (b.getModel().isPressed())
1163:         g.setColor(MetalLookAndFeel.getBlack());
1164:       else
1165:         {
1166:           // FIXME: also need to take into account whether the internal frame is
1167:           // selected
1168:           boolean selected = true;
1169:           if (selected)
1170:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1171:           else
1172:             g.setColor(MetalLookAndFeel.getControlDarkShadow());
1173:         }
1174:       g.drawLine(x + 1, y + 1, x + 13, y + 1);
1175:       g.drawLine(x + 1, y + 2, x + 1, y + 12);
1176:       g.drawLine(x + 1, y + 13, x + 13, y + 13);
1177:       g.drawLine(x + 13, y + 2, x + 13, y + 12);
1178:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1179:       g.drawLine(x + 12, y + 2, x + 12, y + 2);
1180:       
1181:       g.fillRect(x + 4, y + 4, 2, 2);
1182:       g.fillRect(x + 5, y + 5, 4, 4);
1183:       g.drawLine(x + 9, y + 4, x + 10, y + 4);
1184:       g.drawLine(x + 9, y + 4, x + 9, y + 5);
1185:       g.drawLine(x + 4, y + 9, x + 4, y + 10);
1186:       g.drawLine(x + 4, y + 9, x + 5, y + 9);
1187:       g.drawLine(x + 9, y + 8, x + 9, y + 10);
1188:       g.drawLine(x + 8, y + 9, x + 10, y + 9);
1189:       
1190:       g.setColor(MetalLookAndFeel.getBlack());
1191:       g.drawLine(x, y, x + 13, y);
1192:       g.drawLine(x, y + 1, x, y + 13);
1193:       g.drawLine(x + 3, y + 4, x + 4, y + 3);
1194:       g.drawLine(x + 3, y + 9, x + 5, y + 7);
1195:       g.drawLine(x + 7, y + 5, x + 9, y + 3);
1196:       
1197:       g.drawLine(x + 12, y + 3, x + 12, y + 11);
1198:       g.drawLine(x + 3, y + 12, x + 12, y + 12);
1199:       
1200:       g.setColor(MetalLookAndFeel.getWhite());
1201:       g.drawLine(x + 1, y + 14, x + 14, y + 14);
1202:       g.drawLine(x + 14, y + 1, x + 14, y + 14);
1203:       
1204:       if (!b.getModel().isPressed())
1205:         {
1206:           g.drawLine(x + 5, y + 10, x + 5, y + 10);
1207:           g.drawLine(x + 6, y + 9, x + 7, y + 9);
1208:           g.drawLine(x + 10, y + 5, x + 10, y + 5);
1209:           g.drawLine(x + 9, y + 6, x + 9, y + 7);
1210:           g.drawLine(x + 10, y + 10, x + 11, y + 10);
1211:           g.drawLine(x + 10, y + 11, x + 10, y + 11);
1212:         }
1213:       g.setColor(savedColor);
1214:     }        
1215:   }
1216: 
1217:   /**
1218:    * The icon displayed at the top-left corner of a {@link JInternalFrame}.
1219:    */
1220:   private static class InternalFrameDefaultMenuIcon
1221:     implements Icon, Serializable 
1222:   {
1223:        
1224:     /**
1225:      * Creates a new instance.
1226:      */
1227:     public InternalFrameDefaultMenuIcon() 
1228:     {
1229:       // Nothing to do here.
1230:     }
1231:     
1232:     /**
1233:      * Returns the width of the icon, in pixels.
1234:      * 
1235:      * @return The width of the icon.
1236:      */
1237:     public int getIconWidth() 
1238:     {
1239:       return 16;
1240:     }
1241:     
1242:     /**
1243:      * Returns the height of the icon, in pixels.
1244:      * 
1245:      * @return The height of the icon.
1246:      */
1247:     public int getIconHeight() 
1248:     {
1249:       return 16;
1250:     }
1251:     
1252:     /**
1253:      * Paints the icon at the specified location.
1254:      * 
1255:      * @param c  the component.
1256:      * @param g  the graphics device.
1257:      * @param x  the x coordinate.
1258:      * @param y  the y coordinate.
1259:      */
1260:     public void paintIcon(Component c, Graphics g, int x, int y) 
1261:     {
1262:       g.setColor(new Color(102, 102, 153));
1263:       g.fillRect(x + 1, y, 14, 2);
1264:       g.fillRect(x, y + 1, 2, 14);
1265:       g.fillRect(x + 1, y + 14, 14, 2);
1266:       g.fillRect(x + 14, y + 1, 2, 14);
1267:       g.drawLine(x + 2, y + 5, x + 14, y + 5);
1268:       
1269:       g.setColor(new Color(204, 204, 255));
1270:       g.fillRect(x + 2, y + 2, 12, 3);
1271:       
1272:       g.setColor(new Color(102, 102, 153));
1273:       g.drawLine(x + 3, y + 3, x + 3, y + 3);
1274:       g.drawLine(x + 6, y + 3, x + 6, y + 3);
1275:       g.drawLine(x + 9, y + 3, x + 9, y + 3);
1276:       g.drawLine(x + 12, y + 3, x + 12, y + 3);
1277: 
1278:       g.setColor(Color.white);
1279:       g.fillRect(x + 2, y + 6, 12, 8);
1280:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
1281:       g.drawLine(x + 5, y + 2, x + 5, y + 2);
1282:       g.drawLine(x + 8, y + 2, x + 8, y + 2);
1283:       g.drawLine(x + 11, y + 2, x + 11, y + 2);
1284:     }        
1285:   }
1286: 
1287:   /**
1288:    * An icon used in the title frame of a {@link JInternalFrame}.  When you 
1289:    * maximise an internal frame, this icon will replace the 'maximise' icon to
1290:    * provide a 'restore' option.
1291:    */
1292:   private static class InternalFrameAltMaximizeIcon
1293:     implements Icon, Serializable 
1294:   {
1295:     /** The icon size in pixels. */
1296:     private int size;
1297:     
1298:     /**
1299:      * Creates a new icon.
1300:      * 
1301:      * @param size  the icon size in pixels.
1302:      */
1303:     public InternalFrameAltMaximizeIcon(int size) 
1304:     {
1305:       this.size = size;
1306:     }
1307:     
1308:     /**
1309:      * Returns the width of the icon, in pixels.
1310:      * 
1311:      * @return The width of the icon.
1312:      */
1313:     public int getIconWidth() 
1314:     {
1315:       return size;
1316:     }
1317:     
1318:     /**
1319:      * Returns the height of the icon, in pixels.
1320:      * 
1321:      * @return The height of the icon.
1322:      */
1323:     public int getIconHeight() 
1324:     {
1325:       return size;
1326:     }
1327:     
1328:     /**
1329:      * Paints the icon at the specified location.
1330:      * 
1331:      * @param c  the component.
1332:      * @param g  the graphics device.
1333:      * @param x  the x coordinate.
1334:      * @param y  the y coordinate.
1335:      */
1336:     public void paintIcon(Component c, Graphics g, int x, int y) 
1337:     {
1338:       Color savedColor = g.getColor();
1339: 
1340:       AbstractButton b = (AbstractButton) c;
1341: 
1342:       // fill the small box interior
1343:       if (b.getModel().isPressed())
1344:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1345:       else
1346:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1347:       g.fillRect(x + 2, y + 6, 7, 7);
1348:       
1349:       
1350:       if (b.getModel().isPressed())
1351:         g.setColor(MetalLookAndFeel.getBlack());
1352:       else
1353:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1354:         
1355:       g.drawLine(x + 12, y + 1, x + 13, y + 1);
1356:       g.drawLine(x + 11, y + 2, x + 12, y + 2);
1357:       g.drawLine(x + 10, y + 3, x + 11, y + 3);
1358:       g.drawLine(x + 8, y + 2, x + 8, y + 3);
1359:       g.fillRect(x + 8, y + 4, 3, 3);
1360:       g.drawLine(x + 11, y + 6, x + 12, y + 6);
1361:       
1362:       g.drawLine(x + 1, y + 5, x + 5, y + 5);
1363:       g.drawLine(x + 1, y + 6, x + 1, y + 12);
1364:       g.drawLine(x + 9, y + 9, x + 9, y + 12);
1365:       g.drawLine(x + 1, y + 13, x + 9, y + 13);
1366:       
1367:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1368:       
1369:       g.setColor(MetalLookAndFeel.getBlack());
1370:       g.drawLine(x + 12, y, x + 9, y + 3);
1371:       g.drawLine(x + 7, y + 1, x + 8, y + 1);
1372:       g.drawLine(x + 7, y + 2, x + 7, y + 6);
1373:       g.drawLine(x + 11, y + 5, x + 12, y + 5);
1374:       g.drawLine(x, y + 4, x + 5, y + 4);
1375:       g.drawLine(x, y + 5, x, y + 13);
1376:       g.drawLine(x + 3, y + 12, x + 8, y + 12);
1377:       g.drawLine(x + 8, y + 8, x + 8, y + 11);
1378:       g.drawLine(x + 9, y + 8, x + 9, y + 8);
1379:       
1380:       g.setColor(MetalLookAndFeel.getWhite());
1381:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
1382:       g.drawLine(x + 11, y + 4, x + 13, y + 2);
1383:       g.drawLine(x + 13, y + 6, x + 13, y + 6);
1384:       g.drawLine(x + 8, y + 7, x + 13, y + 7);
1385:       g.drawLine(x + 6, y + 5, x + 6, y + 5);
1386:       g.drawLine(x + 10, y + 8, x + 10, y + 13);
1387:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
1388:       
1389:       if (!b.getModel().isPressed())
1390:         {
1391:           g.drawLine(x + 2, y + 6, x + 6, y + 6);
1392:           g.drawLine(x + 2, y + 6, x + 2, y + 11);
1393:         }
1394:       
1395:       g.setColor(savedColor);
1396:     }        
1397:   }
1398:   
1399:   /**
1400:    * An icon used for the 'maximize' button in the title frame of a 
1401:    * {@link JInternalFrame}.
1402:    */
1403:   private static class InternalFrameMaximizeIcon implements Icon, Serializable
1404:   {
1405:     
1406:     /**
1407:      * Creates a new instance.
1408:      */
1409:     public InternalFrameMaximizeIcon() 
1410:     {
1411:       // Nothing to do here.
1412:     }
1413:     
1414:     /**
1415:      * Returns the width of the icon, in pixels.
1416:      * 
1417:      * @return The width of the icon.
1418:      */
1419:     public int getIconWidth() 
1420:     {
1421:       return 16;
1422:     }
1423:     
1424:     /**
1425:      * Returns the height of the icon, in pixels.
1426:      * 
1427:      * @return The height of the icon.
1428:      */
1429:     public int getIconHeight() 
1430:     {
1431:       return 16;
1432:     }
1433:     
1434:     /**
1435:      * Paints the icon at the specified location.
1436:      * 
1437:      * @param c  the component.
1438:      * @param g  the graphics device.
1439:      * @param x  the x coordinate.
1440:      * @param y  the y coordinate.
1441:      */
1442:     public void paintIcon(Component c, Graphics g, int x, int y) 
1443:     {
1444:       Color savedColor = g.getColor();
1445:       
1446:       AbstractButton b = (AbstractButton) c;
1447:       
1448:       // fill the interior
1449:       if (b.getModel().isPressed())
1450:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1451:       else
1452:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1453:       g.fillRect(x + 2, y + 6, 7, 7);
1454: 
1455:       if (b.getModel().isPressed())
1456:         g.setColor(MetalLookAndFeel.getBlack());
1457:       else
1458:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1459:           
1460:       g.drawLine(x + 9, y + 1, x + 10, y + 1);
1461:       g.fillRect(x + 11, y + 1, 3, 3);
1462:       g.fillRect(x + 12, y + 4, 2, 2);
1463:       g.drawLine(x + 10, y + 3, x + 10, y + 3);
1464:       g.drawLine(x + 9, y + 4, x + 10, y + 4);
1465:       g.drawLine(x + 1, y + 5, x + 9, y + 5);
1466:       g.drawLine(x + 1, y + 6, x + 1, y + 12);
1467:       g.drawLine(x + 9, y + 6, x + 9, y + 12);
1468:       g.drawLine(x + 1, y + 13, x + 9, y + 13);
1469:       
1470:       // fill
1471:       g.drawLine(x + 7, y + 6, x + 8, y + 6);
1472:       g.drawLine(x + 6, y + 7, x + 8, y + 7);
1473:       g.drawLine(x + 5, y + 8, x + 6, y + 8);
1474:       g.drawLine(x + 4, y + 9, x + 5, y + 9);
1475:       g.drawLine(x + 3, y + 10, x + 4, y + 10);
1476:       g.drawLine(x + 2, y + 11, x + 3, y + 11);
1477:       g.drawLine(x + 2, y + 12, x + 4, y + 12);
1478:       g.drawLine(x + 8, y + 8, x + 8, y + 8);
1479:       
1480:       // draw black
1481:       g.setColor(MetalLookAndFeel.getBlack());
1482:       g.drawLine(x + 8, y, x + 13, y);
1483:       g.drawLine(x + 8, y + 1, x + 8, y + 1);
1484:       g.drawLine(x + 10, y + 2, x + 9, y + 3);
1485:       g.drawLine(x, y + 4, x + 8, y + 4);
1486:       g.drawLine(x, y + 5, x, y + 13);
1487:       
1488:       g.drawLine(x + 2, y + 10, x + 6, y + 6);
1489:       g.drawLine(x + 8, y + 9, x + 8, y + 11);
1490:       g.drawLine(x + 5, y + 12, x + 8, y + 12);
1491:       
1492:       // draw white
1493:       g.setColor(MetalLookAndFeel.getWhite());
1494:       if (!b.getModel().isPressed())
1495:         {
1496:           g.drawLine(x + 2, y + 6, x + 5, y + 6);
1497:           g.drawLine(x + 2, y + 7, x + 2, y + 9);
1498:           g.drawLine(x + 4, y + 11, x + 7, y + 8);
1499:         }
1500:       
1501:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
1502:       g.drawLine(x + 10, y + 5, x + 10, y + 13);
1503:       
1504:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
1505:       g.drawLine(x + 11, y + 4, x + 11, y + 5);
1506:       g.drawLine(x + 13, y + 6, x + 14, y + 6);
1507:       g.drawLine(x + 14, y + 1, x + 14, y + 5);
1508:       g.setColor(savedColor);
1509:     }        
1510:   }
1511: 
1512:   /**
1513:    * An icon used in the title frame of a {@link JInternalFrame}.
1514:    */
1515:   private static class InternalFrameMinimizeIcon implements Icon, Serializable
1516:   {
1517:   
1518:     /**
1519:      * Creates a new instance.
1520:      */
1521:     public InternalFrameMinimizeIcon() 
1522:     {
1523:       // Nothing to do here.
1524:     }
1525:     
1526:     /**
1527:      * Returns the width of the icon, in pixels.
1528:      * 
1529:      * @return The width of the icon.
1530:      */
1531:     public int getIconWidth() 
1532:     {
1533:       return 16;
1534:     }
1535:     
1536:     /**
1537:      * Returns the height of the icon, in pixels.
1538:      * 
1539:      * @return The height of the icon.
1540:      */
1541:     public int getIconHeight() 
1542:     {
1543:       return 16;
1544:     }
1545:     
1546:     /**
1547:      * Paints the icon at the specified location.
1548:      * 
1549:      * @param c  the component.
1550:      * @param g  the graphics device.
1551:      * @param x  the x coordinate.
1552:      * @param y  the y coordinate.
1553:      */
1554:     public void paintIcon(Component c, Graphics g, int x, int y) 
1555:     {
1556:       Color savedColor = g.getColor();
1557:       
1558:       AbstractButton b = (AbstractButton) c;
1559:       
1560:       if (b.getModel().isPressed())
1561:         g.setColor(MetalLookAndFeel.getBlack());
1562:       else
1563:         // FIXME: here the color depends on whether or not the internal frame 
1564:         // is selected 
1565:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1566:       
1567:       g.drawLine(x + 12, y + 1, x + 13, y + 1);
1568:       g.drawLine(x + 11, y + 2, x + 12, y + 2);
1569:       g.drawLine(x + 10, y + 3, x + 11, y + 3);
1570:       g.drawLine(x + 8, y + 2, x + 8, y + 3);
1571:       g.fillRect(x + 8, y + 4, 3, 3);
1572:       g.drawLine(x + 11, y + 6, x + 12, y + 6);
1573:       
1574:       g.drawLine(x + 1, y + 8, x + 6, y + 8);
1575:       g.drawLine(x + 1, y + 9, x + 1, y + 12);
1576:       g.drawLine(x + 6, y + 9, x + 6, y + 12);
1577:       g.drawLine(x + 1, y + 13, x + 6, y + 13);
1578:       
1579:       g.drawLine(x + 5, y + 9, x + 5, y + 9);
1580:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1581:       
1582:       g.setColor(MetalLookAndFeel.getBlack());
1583:       g.drawLine(x + 12, y, x + 9, y + 3);
1584:       g.drawLine(x + 7, y + 1, x + 8, y + 1);
1585:       g.drawLine(x + 7, y + 2, x + 7, y + 6);
1586:       g.drawLine(x, y + 7, x + 6, y + 7);
1587:       g.drawLine(x, y + 8, x, y + 13);
1588:       g.drawLine(x + 3, y + 12, x + 5, y + 12);
1589:       g.drawLine(x + 5, y + 10, x + 5, y + 11);
1590:       g.drawLine(x + 11, y + 5, x + 12, y + 5);
1591:       
1592:       g.setColor(MetalLookAndFeel.getWhite());
1593:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
1594:       g.drawLine(x + 11, y + 4, x + 13, y + 2);
1595:       g.drawLine(x + 13, y + 6, x + 13, y + 6);
1596:       g.drawLine(x + 8, y + 7, x + 13, y + 7);
1597:       g.drawLine(x + 7, y + 9, x + 7, y + 13);
1598:       g.drawLine(x + 1, y + 14, x + 7, y + 14);
1599: 
1600:       if (b.getModel().isPressed())
1601:         {
1602:           g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1603:           g.fillRect(x + 2, y + 9, 3, 3);
1604:         }
1605:       else
1606:         {
1607:           g.drawLine(x + 2, y + 9, x + 4, y + 9);
1608:           g.drawLine(x + 2, y + 10, x + 2, y + 11);
1609:         }
1610: 
1611:       g.setColor(savedColor);
1612:     }        
1613:   }
1614: 
1615:   /**
1616:    * The icon used to display the thumb control on a horizontally oriented
1617:    * {@link JSlider} component.
1618:    */
1619:   private static class VerticalSliderThumbIcon implements Icon, Serializable
1620:   {
1621:     /**
1622:      * This mask is used to paint the gradient in the shape of the thumb.
1623:      */
1624:     int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
1625:                                          {0, 12}, {0, 12}, {0, 12}, {1, 12},
1626:                                          {2, 10}, {3, 9}, {4, 8}, {5, 7},
1627:                                          {6, 6}};
1628: 
1629:     /**
1630:      * Creates a new instance.
1631:      */
1632:     public VerticalSliderThumbIcon() 
1633:     {
1634:       // Nothing to do here.
1635:     }
1636:     
1637:     /**
1638:      * Returns the width of the icon, in pixels.
1639:      * 
1640:      * @return The width of the icon.
1641:      */
1642:     public int getIconWidth() 
1643:     {
1644:       return 16;
1645:     }
1646:     
1647:     /**
1648:      * Returns the height of the icon, in pixels.
1649:      * 
1650:      * @return The height of the icon.
1651:      */
1652:     public int getIconHeight() 
1653:     {
1654:       return 15;
1655:     }
1656:     
1657:     /**
1658:      * Paints the icon taking into account whether the slider control has the
1659:      * focus or not.
1660:      * 
1661:      * @param c  the slider (must be a non-<code>null</code> instance of
1662:      *           {@link JSlider}.
1663:      * @param g  the graphics device.
1664:      * @param x  the x-coordinate.
1665:      * @param y  the y-coordinate.
1666:      */
1667:     public void paintIcon(Component c, Graphics g, int x, int y) 
1668:     {
1669:       boolean enabled = false;
1670:       boolean focus = false;
1671:       if (c != null)
1672:         {
1673:           enabled = c.isEnabled();
1674:           focus = c.hasFocus();    
1675:         }
1676:       
1677:       // draw the outline
1678:       if (enabled) 
1679:         g.setColor(MetalLookAndFeel.getBlack());
1680:       else
1681:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
1682:       g.drawLine(x + 1, y, x + 7, y);
1683:       g.drawLine(x + 8, y, x + 15, y + 7);
1684:       g.drawLine(x + 14, y + 8, x + 8, y + 14);
1685:       g.drawLine(x + 8, y + 14, x + 1, y + 14);
1686:       g.drawLine(x, y + 13, x, y + 1);
1687:       
1688:       // Fill the icon.
1689:       if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
1690:           && enabled)
1691:         {
1692:           String gradient;
1693:           if (focus)
1694:             gradient = "Slider.focusGradient";
1695:           else
1696:             gradient = "Slider.gradient";
1697:           MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12,
1698:                                    SwingConstants.HORIZONTAL, gradient,
1699:                                    gradientMask);
1700:         }
1701:       else
1702:         {
1703:           if (focus)
1704:             g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1705:           else
1706:             g.setColor(MetalLookAndFeel.getControl());
1707:           g.fillRect(x + 2, y + 1, 7, 13);
1708:           g.drawLine(x + 9, y + 2, x + 9, y + 12);
1709:           g.drawLine(x + 10, y + 3, x + 10, y + 11);
1710:           g.drawLine(x + 11, y + 4, x + 11, y + 10);
1711:           g.drawLine(x + 12, y + 5, x + 12, y + 9);
1712:           g.drawLine(x + 13, y + 6, x + 13, y + 8);
1713:           g.drawLine(x + 14, y + 7, x + 14, y + 7);
1714:         }
1715: 
1716:       // if the slider is enabled, draw dots and highlights
1717:       if (enabled
1718:           && ! (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
1719:         {
1720:           if (focus)
1721:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1722:           else
1723:             g.setColor(MetalLookAndFeel.getBlack());
1724:           g.drawLine(x + 3, y + 3, x + 3, y + 3);
1725:           g.drawLine(x + 3, y + 7, x + 3, y + 7);
1726:           g.drawLine(x + 3, y + 11, x + 3, y + 11);
1727: 
1728:           g.drawLine(x + 5, y + 5, x + 5, y + 5);
1729:           g.drawLine(x + 5, y + 9, x + 5, y + 9);
1730: 
1731:           g.drawLine(x + 7, y + 3, x + 7, y + 3);
1732:           g.drawLine(x + 7, y + 7, x + 7, y + 7);
1733:           g.drawLine(x + 7, y + 11, x + 7, y + 11);
1734: 
1735:           // draw highlights
1736:           if (focus)
1737:             g.setColor(MetalLookAndFeel.getPrimaryControl());
1738:           else
1739:             g.setColor(MetalLookAndFeel.getWhite());
1740:           g.drawLine(x + 1, y + 1, x + 8, y + 1);
1741:           g.drawLine(x + 1, y + 2, x + 1, y + 13);
1742:           g.drawLine(x + 2, y + 2, x + 2, y + 2);
1743:           g.drawLine(x + 2, y + 6, x + 2, y + 6);
1744:           g.drawLine(x + 2, y + 10, x + 2, y + 10);
1745: 
1746:           g.drawLine(x + 4, y + 4, x + 4, y + 4);
1747:           g.drawLine(x + 4, y + 8, x + 4, y + 8);
1748: 
1749:           g.drawLine(x + 6, y + 2, x + 6, y + 2);
1750:           g.drawLine(x + 6, y + 6, x + 6, y + 6);
1751:           g.drawLine(x + 6, y + 10, x + 6, y + 10);
1752:         
1753:         }
1754:     }        
1755:   }
1756:     
1757:   /**
1758:    * A tree control icon.  This icon can be in one of two states: expanded and
1759:    * collapsed.
1760:    */
1761:   public static class TreeControlIcon implements Icon, Serializable
1762:   {
1763:     
1764:     /** ???. */
1765:     protected boolean isLight;
1766:     
1767:     /** A flag that controls whether or not the icon is collapsed. */
1768:     private boolean collapsed;
1769:     
1770:     /**
1771:      * Creates a new icon.
1772:      * 
1773:      * @param isCollapsed  a flag that controls whether the icon is in the
1774:      *                     collapsed state or the expanded state.
1775:      */
1776:     public TreeControlIcon(boolean isCollapsed) 
1777:     {
1778:       collapsed = isCollapsed;
1779:     }
1780:     
1781:     /**
1782:      * Returns the width of the icon, in pixels.
1783:      * 
1784:      * @return The width of the icon.
1785:      */
1786:     public int getIconWidth() 
1787:     {
1788:       return 18;
1789:     }
1790:     /**
1791:      * Returns the height of the icon, in pixels.
1792:      * 
1793:      * @return The height of the icon.
1794:      */
1795:     public int getIconHeight() 
1796:     {
1797:       return 18;
1798:     }
1799:     
1800:     /**
1801:      * Paints the icon at the location (x, y).
1802:      * 
1803:      * @param c  the component.
1804:      * @param g  the graphics device.
1805:      * @param x  the x coordinate.
1806:      * @param y  the y coordinate.
1807:      */
1808:     public void paintIcon(Component c, Graphics g, int x, int y) 
1809:     {
1810:       x = x + 5;
1811:       y = y + 5;
1812:       if (collapsed) 
1813:       {
1814:         // TODO: pick up appropriate UI colors
1815:         g.setColor(Color.black);
1816:         g.drawLine(x + 2, y, x + 5, y);
1817:         g.drawLine(x + 6, y + 1, x + 7, y + 2);
1818:         g.fillRect(x + 7, y + 3, 5, 2);
1819:         g.drawLine(x + 7, y + 5, x + 6, y + 6);
1820:         g.drawLine(x + 1, y + 1, x + 1, y + 1);
1821:         g.drawLine(x, y + 2, x, y + 5);
1822:         g.drawLine(x + 1, y + 6, x + 1, y + 6);
1823:         g.drawLine(x + 2, y + 7, x + 5, y + 7);
1824:         g.fillRect(x + 3, y + 3, 2, 2);
1825: 
1826:         g.setColor(new Color(204, 204, 255));
1827:         g.drawLine(x + 3, y + 2, x + 4, y + 2);
1828:         g.drawLine(x + 2, y + 3, x + 2, y + 4);
1829:         g.drawLine(x + 3, y + 5, x + 3, y + 5);
1830:         g.drawLine(x + 5, y + 3, x + 5, y + 3);
1831:         
1832:         g.setColor(new Color(153, 153, 204));
1833:         g.drawLine(x + 2, y + 2, x + 2, y + 2);
1834:         g.drawLine(x + 2, y + 5, x + 2, y + 5);
1835:         g.drawLine(x + 2, y + 6, x + 5, y + 6);
1836:         g.drawLine(x + 5, y + 2, x + 5, y + 2);
1837:         g.drawLine(x + 6, y + 2, x + 6, y + 5);
1838:         
1839:         g.setColor(new Color(102, 102, 153));
1840:         g.drawLine(x + 2, y + 1, x + 5, y + 1);
1841:         g.drawLine(x + 1, y + 2, x + 1, y + 5);
1842:       }
1843:       else
1844:       {
1845:         // TODO: pick up appropriate UI colors
1846:         g.setColor(Color.black);
1847:         g.drawLine(x + 2, y, x + 5, y);
1848:         g.drawLine(x + 6, y + 1, x + 7, y + 2);
1849:         g.drawLine(x + 7, y + 2, x + 7, y + 5);
1850:         g.fillRect(x + 3, y + 7, 2, 5);
1851:         g.drawLine(x + 7, y + 5, x + 6, y + 6);
1852:         g.drawLine(x + 1, y + 1, x + 1, y + 1);
1853:         g.drawLine(x, y + 2, x, y + 5);
1854:         g.drawLine(x + 1, y + 6, x + 1, y + 6);
1855:         g.drawLine(x + 2, y + 7, x + 5, y + 7);
1856:         g.fillRect(x + 3, y + 3, 2, 2);
1857: 
1858:         g.setColor(new Color(204, 204, 255));
1859:         g.drawLine(x + 3, y + 2, x + 4, y + 2);
1860:         g.drawLine(x + 2, y + 3, x + 2, y + 4);
1861:         g.drawLine(x + 3, y + 5, x + 3, y + 5);
1862:         g.drawLine(x + 5, y + 3, x + 5, y + 3);
1863:         
1864:         g.setColor(new Color(153, 153, 204));
1865:         g.drawLine(x + 2, y + 2, x + 2, y + 2);
1866:         g.drawLine(x + 2, y + 5, x + 2, y + 5);
1867:         g.drawLine(x + 2, y + 6, x + 5, y + 6);
1868:         g.drawLine(x + 5, y + 2, x + 5, y + 2);
1869:         g.drawLine(x + 6, y + 2, x + 6, y + 5);
1870:         
1871:         g.setColor(new Color(102, 102, 153));
1872:         g.drawLine(x + 2, y + 1, x + 5, y + 1);
1873:         g.drawLine(x + 1, y + 2, x + 1, y + 5);
1874:       }
1875:     } 
1876:     
1877:     /**
1878:      * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
1879:      * 
1880:      * @param c  the component.
1881:      * @param g  the graphics device.
1882:      * @param x  the x coordinate.
1883:      * @param y  the y coordinate.
1884:      */
1885:     public void paintMe(Component c, Graphics g, int x, int y) 
1886:     {
1887:       paintIcon(c, g, x, y);  
1888:     }
1889:   }
1890:     
1891:   /**
1892:    * A tree folder icon.
1893:    */
1894:   public static class TreeFolderIcon extends FolderIcon16
1895:   {
1896:     /**
1897:      * Creates a new instance.
1898:      */
1899:     public TreeFolderIcon() 
1900:     {
1901:       // Nothing to do here.
1902:     }
1903:     
1904:     /**
1905:      * Returns the additional height for this icon, in this case <code>2</code>
1906:      * pixels.
1907:      * 
1908:      * @return <code>2</code>.
1909:      */
1910:     public int getAdditionalHeight() 
1911:     {
1912:       return 2;
1913:     }
1914:     
1915:     /**
1916:      * Returns the shift (???).
1917:      * 
1918:      * @return The shift.
1919:      */
1920:     public int getShift() 
1921:     {
1922:       return -1;
1923:     }
1924:   }
1925:     
1926:   /**
1927:    * A tree leaf icon.
1928:    */
1929:   public static class TreeLeafIcon extends FileIcon16
1930:   {
1931:     /**
1932:      * Creates a new instance.
1933:      */
1934:     public TreeLeafIcon() 
1935:     {
1936:       // Nothing to do here.
1937:     }
1938:     
1939:     /**
1940:      * Returns the additional height for this icon, in this case <code>4</code>
1941:      * pixels.
1942:      * 
1943:      * @return <code>4</code>.
1944:      */
1945:     public int getAdditionalHeight() 
1946:     {
1947:       return 4;
1948:     }
1949:     
1950:     /**
1951:      * Returns the shift (???).
1952:      * 
1953:      * @return The shift.
1954:      */
1955:     public int getShift() 
1956:     {
1957:       return 2;
1958:     }
1959:   }
1960: 
1961:   /**
1962:    * An icon representing a hard disk.
1963:    * 
1964:    * @see MetalIconFactory#getTreeHardDriveIcon()
1965:    */
1966:   private static class TreeHardDriveIcon implements Icon, Serializable
1967:   {
1968: 
1969:     /**
1970:      * Creates a new icon instance.
1971:      */
1972:     public TreeHardDriveIcon() 
1973:     {
1974:       // Nothing to do here.
1975:     }
1976: 
1977:     /**
1978:      * Returns the width of the icon, in pixels.
1979:      * 
1980:      * @return <code>16</code>.
1981:      */
1982:     public int getIconWidth() 
1983:     { 
1984:       return 16;
1985:     }
1986: 
1987:     /**
1988:      * Returns the height of the icon, in pixels.
1989:      * 
1990:      * @return <code>16</code>.
1991:      */
1992:     public int getIconHeight()   
1993:     {
1994:       return 16;
1995:     }
1996: 
1997:     /**
1998:      * Paints the icon at the specified location, using colors from the 
1999:      * current theme.
2000:      * 
2001:      * @param c  the component (ignored).
2002:      * @param g  the graphics device.
2003:      * @param x  the x-coordinate for the top-left of the icon.
2004:      * @param y  the y-coordinate for the top-left of the icon.
2005:      */
2006:     public void paintIcon(Component c, Graphics g, int x, int y) 
2007:     {
2008:       Color saved = g.getColor();
2009:       g.setColor(MetalLookAndFeel.getBlack());
2010:       g.drawLine(x + 1, y + 4, x + 1, y + 5);
2011:       g.drawLine(x + 14, y + 4, x + 14, y + 5);
2012:       g.drawLine(x + 1, y + 7, x + 1, y + 8);
2013:       g.drawLine(x + 14, y + 7, x + 14, y + 8);
2014:       g.drawLine(x + 1, y + 10, x + 1, y + 11);
2015:       g.drawLine(x + 14, y + 10, x + 14, y + 11);
2016:       
2017:       g.drawLine(x + 2, y + 3, x + 3, y + 3);
2018:       g.drawLine(x + 12, y + 3, x + 13, y + 3);
2019:       g.drawLine(x + 2, y + 6, x + 3, y + 6);
2020:       g.drawLine(x + 12, y + 6, x + 13, y + 6);
2021:       g.drawLine(x + 2, y + 9, x + 3, y + 9);
2022:       g.drawLine(x + 12, y + 9, x + 13, y + 9);
2023:       g.drawLine(x + 2, y + 12, x + 3, y + 12);
2024:       g.drawLine(x + 12, y + 12, x + 13, y + 12);
2025:       
2026:       g.drawLine(x + 4, y + 2, x + 11, y + 2);
2027:       g.drawLine(x + 4, y + 7, x + 11, y + 7);
2028:       g.drawLine(x + 4, y + 10, x + 11, y + 10);
2029:       g.drawLine(x + 4, y + 13, x + 11, y + 13);
2030:       
2031:       g.setColor(MetalLookAndFeel.getWhite());
2032:       g.fillRect(x + 4, y + 3, 2, 2);
2033:       g.drawLine(x + 6, y + 4, x + 6, y + 4);
2034:       g.drawLine(x + 7, y + 3, x + 9, y + 3);
2035:       g.drawLine(x + 8, y + 4, x + 8, y + 4);
2036:       g.drawLine(x + 11, y + 3, x + 11, y + 3);
2037:       g.fillRect(x + 2, y + 4, 2, 2); 
2038:       g.fillRect(x + 2, y + 7, 2, 2); 
2039:       g.fillRect(x + 2, y + 10, 2, 2); 
2040:       g.drawLine(x + 4, y + 6, x + 4, y + 6);
2041:       g.drawLine(x + 4, y + 9, x + 4, y + 9);
2042:       g.drawLine(x + 4, y + 12, x + 4, y + 12);
2043:       
2044:       g.setColor(MetalLookAndFeel.getControlShadow());
2045:       g.drawLine(x + 13, y + 4, x + 13, y + 4);
2046:       g.drawLine(x + 12, y + 5, x + 13, y + 5);
2047:       g.drawLine(x + 13, y + 7, x + 13, y + 7);
2048:       g.drawLine(x + 12, y + 8, x + 13, y + 8);
2049:       g.drawLine(x + 13, y + 10, x + 13, y + 10);
2050:       g.drawLine(x + 12, y + 11, x + 13, y + 11);
2051:       
2052:       g.drawLine(x + 10, y + 5, x + 10, y + 5);
2053:       g.drawLine(x + 7, y + 6, x + 7, y + 6);
2054:       g.drawLine(x + 9, y + 6, x + 9, y + 6);
2055:       g.drawLine(x + 11, y + 6, x + 11, y + 6);
2056: 
2057:       g.drawLine(x + 10, y + 8, x + 10, y + 8);
2058:       g.drawLine(x + 7, y + 9, x + 7, y + 9);
2059:       g.drawLine(x + 9, y + 9, x + 9, y + 9);
2060:       g.drawLine(x + 11, y + 9, x + 11, y + 9);
2061: 
2062:       g.drawLine(x + 10, y + 11, x + 10, y + 11);
2063:       g.drawLine(x + 7, y + 12, x + 7, y + 12);
2064:       g.drawLine(x + 9, y + 12, x + 9, y + 12);
2065:       g.drawLine(x + 11, y + 12, x + 11, y + 12);
2066: 
2067:       g.setColor(saved);
2068:     }        
2069:   }  
2070:   
2071:   /**
2072:    * An icon representing a floppy disk.
2073:    * 
2074:    * @see MetalIconFactory#getTreeFloppyDriveIcon()
2075:    */
2076:   private static class TreeFloppyDriveIcon implements Icon, Serializable
2077:   {
2078: 
2079:     /**
2080:      * Creates a new icon instance.
2081:      */
2082:     public TreeFloppyDriveIcon() 
2083:     {
2084:       // Nothing to do here.
2085:     }
2086: 
2087:     /**
2088:      * Returns the width of the icon, in pixels.
2089:      * 
2090:      * @return <code>16</code>.
2091:      */
2092:     public int getIconWidth() 
2093:     { 
2094:       return 16;
2095:     }
2096: 
2097:     /**
2098:      * Returns the height of the icon, in pixels.
2099:      * 
2100:      * @return <code>16</code>.
2101:      */
2102:     public int getIconHeight()   
2103:     {
2104:       return 16;
2105:     }
2106: 
2107:     /**
2108:      * Paints the icon at the specified location, using colors from the 
2109:      * current theme.
2110:      * 
2111:      * @param c  the component (ignored).
2112:      * @param g  the graphics device.
2113:      * @param x  the x-coordinate for the top-left of the icon.
2114:      * @param y  the y-coordinate for the top-left of the icon.
2115:      */
2116:     public void paintIcon(Component c, Graphics g, int x, int y) 
2117:     {
2118:       Color saved = g.getColor();
2119:       
2120:       g.setColor(MetalLookAndFeel.getBlack());
2121:       g.drawLine(x + 1, y + 1, x + 13, y + 1);
2122:       g.drawLine(x + 1, y + 1, x + 1, y + 14);
2123:       g.drawLine(x + 1, y + 14, x + 14, y + 14);
2124:       g.drawLine(x + 14, y + 2, x + 14, y + 14);
2125:       
2126:       g.setColor(MetalLookAndFeel.getPrimaryControl());
2127:       g.fillRect(x + 2, y + 2, 12, 12);
2128:       
2129:       g.setColor(MetalLookAndFeel.getControlShadow());
2130:       g.fillRect(x + 5, y + 2, 6, 5);
2131:       g.drawLine(x + 4, y + 8, x + 11, y + 8);
2132:       g.drawLine(x + 3, y + 9, x + 3, y + 13);
2133:       g.drawLine(x + 12, y + 9, x + 12, y + 13);
2134:       
2135:       g.setColor(MetalLookAndFeel.getWhite());
2136:       g.fillRect(x + 8, y + 3, 2, 3);
2137:       g.fillRect(x + 4, y + 9, 8, 5);
2138:       
2139:       g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
2140:       g.drawLine(x + 5, y + 10, x + 9, y + 10);
2141:       g.drawLine(x + 5, y + 12, x + 8, y + 12);
2142: 
2143:       g.setColor(saved);
2144:     }        
2145:   }  
2146: 
2147:   /**
2148:    * An icon representing a computer.
2149:    * 
2150:    * @see MetalIconFactory#getTreeComputerIcon()
2151:    */
2152:   private static class TreeComputerIcon implements Icon, Serializable
2153:   {
2154: 
2155:     /**
2156:      * Creates a new icon instance.
2157:      */
2158:     public TreeComputerIcon() 
2159:     {
2160:       // Nothing to do here.
2161:     }
2162: 
2163:     /**
2164:      * Returns the width of the icon, in pixels.
2165:      * 
2166:      * @return <code>16</code>.
2167:      */
2168:     public int getIconWidth() 
2169:     { 
2170:       return 16;
2171:     }
2172: 
2173:     /**
2174:      * Returns the height of the icon, in pixels.
2175:      * 
2176:      * @return <code>16</code>.
2177:      */
2178:     public int getIconHeight()   
2179:     {
2180:       return 16;
2181:     }
2182: 
2183:     /**
2184:      * Paints the icon at the specified location, using colors from the 
2185:      * current theme.
2186:      * 
2187:      * @param c  the component (ignored).
2188:      * @param g  the graphics device.
2189:      * @param x  the x-coordinate for the top-left of the icon.
2190:      * @param y  the y-coordinate for the top-left of the icon.
2191:      */
2192:     public void paintIcon(Component c, Graphics g, int x, int y) 
2193:     {
2194:       Color saved = g.getColor();
2195:       
2196:       g.setColor(MetalLookAndFeel.getBlack());
2197:       g.drawLine(x + 3, y + 1, x + 12, y + 1);
2198:       g.drawLine(x + 2, y + 2, x + 2, y + 8);
2199:       g.drawLine(x + 13, y + 2, x + 13, y + 8);
2200:       g.drawLine(x + 3, y + 9, x + 3, y + 9);
2201:       g.drawLine(x + 12, y + 9, x + 12, y + 9);
2202:       g.drawRect(x + 1, y + 10, 13, 4);
2203:       g.drawLine(x + 5, y + 3, x + 10, y + 3);
2204:       g.drawLine(x + 5, y + 8, x + 10, y + 8);
2205:       g.drawLine(x + 4, y + 4, x + 4, y + 7);
2206:       g.drawLine(x + 11, y + 4, x + 11, y + 7);
2207: 
2208:       g.setColor(MetalLookAndFeel.getPrimaryControl());
2209:       g.fillRect(x + 5, y + 4, 6, 4);
2210:       
2211:       g.setColor(MetalLookAndFeel.getControlShadow());
2212:       g.drawLine(x + 6, y + 12, x + 8, y + 12);
2213:       g.drawLine(x + 10, y + 12, x + 12, y + 12);
2214:       g.setColor(saved);
2215:     }        
2216:   }  
2217:     
2218:   /** The icon returned by {@link #getCheckBoxIcon()}. */
2219:   private static Icon checkBoxIcon;
2220:   
2221:   /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
2222:   private static Icon checkBoxMenuItemIcon;
2223:   
2224:   /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
2225:   private static Icon fileChooserDetailViewIcon;
2226: 
2227:   /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
2228:   private static Icon fileChooserHomeFolderIcon;
2229: 
2230:   /** The icon returned by {@link #getFileChooserListViewIcon()}. */
2231:   private static Icon fileChooserListViewIcon;
2232: 
2233:   /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
2234:   private static Icon fileChooserNewFolderIcon;
2235: 
2236:   /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
2237:   private static Icon fileChooserUpFolderIcon;
2238: 
2239:   /** The cached RadioButtonIcon instance. */
2240:   private static RadioButtonIcon radioButtonIcon;
2241: 
2242:   /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
2243:   private static Icon radioButtonMenuItemIcon;
2244: 
2245:   /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
2246:   private static Icon internalFrameDefaultMenuIcon;
2247: 
2248:   /** The icon returned by {@link #getTreeComputerIcon()}. */
2249:   private static Icon treeComputerIcon;
2250:   
2251:   /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
2252:   private static Icon treeFloppyDriveIcon;
2253:   
2254:   /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
2255:   private static Icon treeHardDriveIcon;
2256:   
2257:   /**
2258:    * Creates a new instance.  All the methods are static, so creating an 
2259:    * instance isn't necessary.
2260:    */
2261:   public MetalIconFactory() 
2262:   {
2263:     // Nothing to do here.
2264:   }
2265: 
2266:   /**
2267:    * Returns an icon for use when rendering the {@link JCheckBox} component.
2268:    * 
2269:    * @return A check box icon.
2270:    * 
2271:    * @since 1.3
2272:    */
2273:   public static Icon getCheckBoxIcon() 
2274:   {
2275:     if (checkBoxIcon == null)
2276:       checkBoxIcon = new MetalCheckBoxIcon();
2277:     return checkBoxIcon;
2278:   }
2279:   
2280:   /**
2281:    * Returns an icon for use when rendering the {@link JCheckBoxMenuItem} 
2282:    * component.
2283:    * 
2284:    * @return An icon.
2285:    */
2286:   public static Icon getCheckBoxMenuItemIcon() 
2287:   {
2288:     if (checkBoxMenuItemIcon == null)
2289:       checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
2290:     return checkBoxMenuItemIcon;
2291:   }
2292: 
2293:   /**
2294:    * Returns an icon for use by the {@link JFileChooser} component.
2295:    * 
2296:    * @return An icon.
2297:    */
2298:   public static Icon getFileChooserDetailViewIcon() 
2299:   {
2300:     if (fileChooserDetailViewIcon == null)
2301:       fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
2302:     return fileChooserDetailViewIcon;
2303:   }
2304:     
2305:   /**
2306:    * Returns an icon for use by the {@link JFileChooser} component.
2307:    * 
2308:    * @return An icon.
2309:    */
2310:   public static Icon getFileChooserHomeFolderIcon() 
2311:   {
2312:     if (fileChooserHomeFolderIcon == null)
2313:       fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
2314:     return fileChooserHomeFolderIcon;        
2315:   }
2316:     
2317:   /**
2318:    * Returns an icon for use by the {@link JFileChooser} component.
2319:    * 
2320:    * @return An icon.
2321:    */
2322:   public static Icon getFileChooserListViewIcon() 
2323:   {
2324:     if (fileChooserListViewIcon == null)
2325:       fileChooserListViewIcon = new FileChooserListViewIcon();
2326:     return fileChooserListViewIcon;
2327:   }
2328:     
2329:   /**
2330:    * Returns an icon for use by the {@link JFileChooser} component.
2331:    * 
2332:    * @return An icon.
2333:    */
2334:   public static Icon getFileChooserNewFolderIcon() 
2335:   {
2336:     if (fileChooserNewFolderIcon == null)
2337:       fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
2338:     return fileChooserNewFolderIcon;
2339:   }
2340:     
2341:   /**
2342:    * Returns an icon for use by the {@link JFileChooser} component.
2343:    * 
2344:    * @return An icon.
2345:    */
2346:   public static Icon getFileChooserUpFolderIcon() 
2347:   {
2348:     if (fileChooserUpFolderIcon == null)
2349:       fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
2350:     return fileChooserUpFolderIcon;
2351:   }
2352: 
2353:   /**
2354:    * Returns an icon for RadioButtons in the Metal L&amp;F.
2355:    *
2356:    * @return an icon for RadioButtons in the Metal L&amp;F
2357:    */
2358:   public static Icon getRadioButtonIcon()
2359:   {
2360:     if (radioButtonIcon == null)
2361:       radioButtonIcon = new RadioButtonIcon();
2362:     return radioButtonIcon;
2363:   }
2364: 
2365:   /**
2366:    * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
2367:    * 
2368:    * @return A new icon instance.
2369:    */
2370:   public static Icon getRadioButtonMenuItemIcon() 
2371:   {
2372:     if (radioButtonMenuItemIcon == null)
2373:       radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
2374:     return radioButtonMenuItemIcon;
2375:   }
2376: 
2377:   /**
2378:    * Returns the icon used to display the thumb for a horizontally oriented
2379:    * {@link JSlider}.
2380:    * 
2381:    * @return The icon.
2382:    */
2383:   public static Icon getHorizontalSliderThumbIcon() 
2384:   {
2385:     return new HorizontalSliderThumbIcon();
2386:   }
2387:     
2388:   /**
2389:    * Creates a new icon used to represent the 'close' button in the title
2390:    * pane of a {@link JInternalFrame}.
2391:    * 
2392:    * @param size  the icon size.
2393:    * 
2394:    * @return A close icon.
2395:    */
2396:   public static Icon getInternalFrameCloseIcon(int size) 
2397:   {
2398:     return new InternalFrameCloseIcon(size);
2399:   }
2400: 
2401:   /**
2402:    * Creates a new icon for the menu in a {@link JInternalFrame}.  This is the
2403:    * icon displayed at the top left of the frame.
2404:    * 
2405:    * @return A menu icon.
2406:    */
2407:   public static Icon getInternalFrameDefaultMenuIcon() 
2408:   {
2409:     if (internalFrameDefaultMenuIcon == null)
2410:       internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
2411:     return internalFrameDefaultMenuIcon;
2412:   }
2413:   
2414:   /**
2415:    * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
2416:    * 
2417:    * @param size  the icon size in pixels.
2418:    * 
2419:    * @return The icon.
2420:    * 
2421:    * @see #getInternalFrameAltMaximizeIcon(int)
2422:    */
2423:   public static Icon getInternalFrameMaximizeIcon(int size) 
2424:   {
2425:     return new InternalFrameMaximizeIcon();
2426:   }
2427:     
2428:   /**
2429:    * Returns the icon used for the minimize button in the frame title for a
2430:    * {@link JInternalFrame}.
2431:    * 
2432:    * @param size  the icon size in pixels (ignored by this implementation).
2433:    * 
2434:    * @return The icon.
2435:    */
2436:   public static Icon getInternalFrameMinimizeIcon(int size) 
2437:   {
2438:     return new InternalFrameMinimizeIcon();
2439:   }
2440: 
2441:   /**
2442:    * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
2443:    * that has been maximised.
2444:    * 
2445:    * @param size  the icon size in pixels.
2446:    * 
2447:    * @return The icon.
2448:    * 
2449:    * @see #getInternalFrameMaximizeIcon(int)
2450:    */
2451:   public static Icon getInternalFrameAltMaximizeIcon(int size) 
2452:   {
2453:     return new InternalFrameAltMaximizeIcon(size);
2454:   }
2455:   
2456:   /**
2457:    * Returns the icon used to display the thumb for a vertically oriented
2458:    * {@link JSlider}.
2459:    * 
2460:    * @return The icon.
2461:    */
2462:   public static Icon getVerticalSliderThumbIcon() 
2463:   {
2464:     return new VerticalSliderThumbIcon();
2465:   }
2466:     
2467:   /**
2468:    * Creates and returns a new tree folder icon.
2469:    * 
2470:    * @return A new tree folder icon.
2471:    */  
2472:   public static Icon getTreeFolderIcon() 
2473:   {
2474:     return new TreeFolderIcon();
2475:   }
2476:     
2477:   /**
2478:    * Creates and returns a new tree leaf icon.
2479:    * 
2480:    * @return A new tree leaf icon.
2481:    */
2482:   public static Icon getTreeLeafIcon() 
2483:   {
2484:     return new TreeLeafIcon();
2485:   }
2486:   
2487:   /**
2488:    * Creates and returns a tree control icon.
2489:    * 
2490:    * @param isCollapsed  a flag that controls whether the icon is in the 
2491:    *                     collapsed or expanded state.
2492:    * 
2493:    * @return A tree control icon.
2494:    */
2495:   public static Icon getTreeControlIcon(boolean isCollapsed) 
2496:   {
2497:     return new TreeControlIcon(isCollapsed);
2498:   }
2499: 
2500:   /**
2501:    * Returns a <code>16x16</code> icon representing a computer.
2502:    * 
2503:    * @return The icon.
2504:    */
2505:   public static Icon getTreeComputerIcon() 
2506:   {
2507:     if (treeComputerIcon == null)
2508:       treeComputerIcon = new TreeComputerIcon();
2509:     return treeComputerIcon;        
2510:   }
2511:     
2512:   /**
2513:    * Returns a <code>16x16</code> icon representing a floppy disk.
2514:    * 
2515:    * @return The icon.
2516:    */
2517:   public static Icon getTreeFloppyDriveIcon() 
2518:   {
2519:     if (treeFloppyDriveIcon == null)
2520:       treeFloppyDriveIcon = new TreeFloppyDriveIcon();
2521:     return treeFloppyDriveIcon;
2522:   }
2523:     
2524:   /**
2525:    * Returns a <code>16x16</code> icon representing a hard disk.
2526:    * 
2527:    * @return The icon.
2528:    */
2529:   public static Icon getTreeHardDriveIcon() 
2530:   {
2531:     if (treeHardDriveIcon == null)
2532:       treeHardDriveIcon = new TreeHardDriveIcon();
2533:     return treeHardDriveIcon;
2534:   }
2535: 
2536:   /**
2537:    * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2538:    * points to the right.  This is displayed in menu items that have a 
2539:    * sub menu.
2540:    * 
2541:    * @return The icon.
2542:    */
2543:   public static Icon getMenuArrowIcon()
2544:   {
2545:     if (menuArrow == null)
2546:       menuArrow = new Icon()
2547:       {
2548:         public int getIconHeight()
2549:         {
2550:           return 8;
2551:         }
2552: 
2553:         public int getIconWidth()
2554:         {
2555:           return 4;
2556:         }
2557: 
2558:         public void paintIcon(Component c, Graphics g, int x, int y)
2559:         {
2560:           Color saved = g.getColor();
2561:           g.setColor(Color.BLACK);
2562:           for (int i = 0; i < 4; i++)
2563:             g.drawLine(x + i, y + i, x + i, y + 7 - i);
2564:           g.setColor(saved);
2565:         }
2566:       };
2567:     return menuArrow;
2568:   }
2569:   
2570:   /**
2571:    * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2572:    * points to the right. This is displayed in menu items that have a sub menu.
2573:    * 
2574:    * @return The icon.
2575:    */
2576:   public static Icon getMenuItemArrowIcon()
2577:   {
2578:     if (menuItemArrow == null)
2579:       menuItemArrow = new Icon()
2580:       {
2581:         public int getIconHeight()
2582:         {
2583:           return 8;
2584:         }
2585: 
2586:         public int getIconWidth()
2587:         {
2588:           return 4;
2589:         }
2590: 
2591:         public void paintIcon(Component c, Graphics g, int x, int y)
2592:         {
2593:           Color saved = g.getColor();
2594:           g.setColor(Color.BLACK);
2595:           for (int i = 0; i < 4; i++)
2596:             g.drawLine(x + i, y + i, x + i, y + 7 - i);
2597:           g.setColor(saved);
2598:         }
2599:       };
2600:     return menuItemArrow;
2601:   }
2602:   
2603:   /**
2604:    * Returns a new instance of a 13 x 13 icon showing a small black check mark.
2605:    * 
2606:    * @return The icon.
2607:    */
2608:   public static Icon getMenuItemCheckIcon()
2609:   {
2610:     return new Icon()
2611:     {
2612:       public int getIconHeight()
2613:       {
2614:         return 13;
2615:       }
2616: 
2617:       public int getIconWidth()
2618:       {
2619:         return 13;
2620:       }
2621: 
2622:       public void paintIcon(Component c, Graphics g, int x, int y)
2623:       {
2624:         Color saved = g.getColor();
2625:         g.setColor(Color.BLACK);
2626:         g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
2627:         g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
2628:         g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
2629:         g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
2630:         g.setColor(saved);
2631:       }
2632:     };
2633:   }
2634: }