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:     {
 622:       return 16;
 623:     }
 624:     
 625:     /**
 626:      * Returns the height of the icon, in pixels.  The height returned is 
 627:      * <code>16</code> plus the value returned by 
 628:      * {@link #getAdditionalHeight()}.
 629:      * 
 630:      * @return The height of the icon.
 631:      */
 632:     public int getIconHeight() 
 633:     {
 634:       return 16 + getAdditionalHeight();
 635:     }
 636: 
 637:     /**
 638:      * Paints the icon at the location (x, y).
 639:      * 
 640:      * @param c  the component.
 641:      * @param g  the graphics device.
 642:      * @param x  the x coordinate.
 643:      * @param y  the y coordinate.
 644:      */
 645:     public void paintIcon(Component c, Graphics g, int x, int y) 
 646:     {
 647:       // TODO: pick up appropriate UI colors
 648:       g.setColor(Color.black);
 649:       g.drawLine(x, y + 3, x, y + 12);
 650:       g.drawLine(x, y + 12, x + 15, y + 12);
 651:       g.drawLine(x + 15, y + 12, x + 15, y + 2);
 652:       g.drawLine(x + 14, y + 3, x + 9, y + 3);
 653:       g.drawLine(x + 8, y + 2, x + 1, y + 2);
 654:       g.setColor(new Color(204, 204, 255));
 655:       g.fillRect(x + 2, y + 4, 7, 8);
 656:       g.fillRect(x + 9, y + 5, 6, 7);
 657:       g.setColor(new Color(102, 102, 153));
 658:       g.drawLine(x + 9, y + 2, x + 14, y + 2);
 659:       g.setColor(new Color(50, 50, 120));
 660:       g.drawLine(x + 9, y + 1, x + 15, y + 1);
 661:       g.drawLine(x + 10, y, x + 15, y);
 662:     }
 663:     
 664:     /**
 665:      * Returns the additional height for the icon.  The 
 666:      * {@link #getIconHeight()} method adds this value to the icon height it
 667:      * returns.  Subclasses can override this method to adjust the icon height.
 668:      * 
 669:      * @return The additional height (<code>0</code> unless overridden).
 670:      */
 671:     public int getAdditionalHeight() 
 672:     {
 673:       return 0;
 674:     }
 675:     
 676:     /**
 677:      * Returns the shift (???).
 678:      * 
 679:      * @return The shift.
 680:      */
 681:     public int getShift() 
 682:     {
 683:       return 0;
 684:     }
 685:         
 686:   }
 687: 
 688:   /**
 689:    * An icon used by the {@link MetalInternalFrameUI} class when the frame
 690:    * is displayed as a palette.
 691:    * 
 692:    * @since 1.3
 693:    */
 694:   public static class PaletteCloseIcon
 695:     implements Icon, Serializable, UIResource
 696:   {
 697:     /**
 698:      * Returns the width of the icon, in pixels.
 699:      * 
 700:      * @return The width of the icon.
 701:      */
 702:     public int getIconWidth() 
 703:     {
 704:       return 7;
 705:     }
 706:     
 707:     /**
 708:      * Returns the height of the icon, in pixels.
 709:      * 
 710:      * @return The height of the icon.
 711:      */
 712:     public int getIconHeight() 
 713:     {
 714:       return 7;
 715:     }
 716:     
 717:     /**
 718:      * Paints the icon using colors from the {@link MetalLookAndFeel}.
 719:      * 
 720:      * @param c  the component (ignored).
 721:      * @param g  the graphics device.
 722:      * @param x  the x-coordinate for the top-left of the icon.
 723:      * @param y  the y-coordinate for the top-left of the icon.
 724:      */
 725:     public void paintIcon(Component c, Graphics g, int x, int y) 
 726:     {
 727:       Color savedColor = g.getColor();
 728:       AbstractButton button = (AbstractButton) c;
 729:       if (button.getModel().isPressed())
 730:         g.setColor(MetalLookAndFeel.getBlack());
 731:       else
 732:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 733:       g.fillRect(x + 2, y + 2, 3, 3);
 734:       g.drawLine(x + 1, y, x + 1, y + 2);
 735:       g.drawLine(x, y + 1, x + 2, y + 1);
 736:       g.drawLine(x + 5, y, x + 5, y + 2);
 737:       g.drawLine(x + 4, y + 1, x + 6, y + 1);
 738:       g.drawLine(x + 1, y + 4, x + 1, y + 6);
 739:       g.drawLine(x, y + 5, x + 2, y + 5);
 740:       g.drawLine(x + 5, y + 4, x + 5, y + 6);
 741:       g.drawLine(x + 4, y + 5, x + 6, y + 5);
 742:       g.setColor(MetalLookAndFeel.getControlHighlight());
 743:       g.drawLine(x + 2, y + 6, x + 3, y + 5);
 744:       g.drawLine(x + 5, y + 3, x + 6, y + 2);
 745:       g.drawLine(x + 6, y + 6, x + 6, y + 6);
 746:       g.setColor(savedColor);
 747:     }        
 748:   }
 749:   
 750:   /**
 751:    * An {@link Icon} implementation for {@link JCheckBox}es in the
 752:    * Metal Look &amp; Feel.
 753:    *
 754:    * @author Roman Kennke (roman@kennke.org)
 755:    */
 756:   static class RadioButtonIcon implements Icon, UIResource, Serializable
 757:   {
 758: 
 759:     /**
 760:      * This is used as a mask when painting the gradient. See
 761:      * {@link MetalUtils#paintGradient(java.awt.Graphics, int, int, int, int,
 762:      *  float, float, java.awt.Color, java.awt.Color, java.awt.Color, int,
 763:      *  int[][])} for details.
 764:      */
 765:     private static int[][] gradientMask = new int[][] {{3, 7}, {1, 9}, {1, 9},
 766:                                                        {0, 10}, {0, 10}, {0, 10},
 767:                                                        {0, 10}, {1, 9}, {1, 9},
 768:                                                        {3, 7}};
 769: 
 770:     /**
 771:      * Returns the width of the icon in pixels.
 772:      *
 773:      * @return the width of the icon in pixels
 774:      */
 775:     public int getIconWidth()
 776:     {
 777:       return 13;
 778:     }
 779: 
 780:     /**
 781:      * Returns the height of the icon in pixels.
 782:      *
 783:      * @return the height of the icon in pixels
 784:      */
 785:     public int getIconHeight()
 786:     {
 787:       return 13;
 788:     }
 789: 
 790:     /**
 791:      * Paints the icon, taking into account whether or not the component is
 792:      * enabled, selected and/or armed.
 793:      *
 794:      * @param c the Component to draw on (must be an instance of 
 795:      *          {@link JRadioButton})
 796:      * @param g the Graphics context to draw with
 797:      * @param x the X position
 798:      * @param y the Y position
 799:      */
 800:     public void paintIcon(Component c, Graphics g, int x, int y) 
 801:     {
 802:       if (UIManager.get("RadioButton.gradient") != null)
 803:         MetalUtils.paintGradient(g, x + 2, y + 2, 8, 8,
 804:                               SwingConstants.VERTICAL, "RadioButton.gradient",
 805:                               gradientMask);
 806: 
 807:       Color savedColor = g.getColor();
 808:       JRadioButton b = (JRadioButton) c;
 809: 
 810:       // draw outer circle
 811:       if (b.isEnabled())
 812:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 813:       else
 814:         g.setColor(MetalLookAndFeel.getControlDisabled());
 815:       g.drawLine(x + 2, y + 1, x + 3, y + 1);
 816:       g.drawLine(x + 4, y, x + 7, y);
 817:       g.drawLine(x + 8, y + 1, x + 9, y + 1);
 818:       g.drawLine(x + 10, y + 2, x + 10, y + 3);
 819:       g.drawLine(x + 11, y + 4, x + 11, y + 7);
 820:       g.drawLine(x + 10, y + 8, x + 10, y + 9);
 821:       g.drawLine(x + 8, y + 10, x + 9, y + 10);
 822:       g.drawLine(x + 4, y + 11, x + 7, y + 11);
 823:       g.drawLine(x + 2, y + 10, x + 3, y + 10);
 824:       g.drawLine(x + 1, y + 9, x + 1, y + 8);
 825:       g.drawLine(x, y + 7, x, y + 4);
 826:       g.drawLine(x + 1, y + 2, x + 1, y + 3);
 827: 
 828:       if (b.getModel().isArmed())
 829:         {
 830:           g.setColor(MetalLookAndFeel.getControlShadow());
 831:           g.drawLine(x + 4, y + 1, x + 7, y + 1);
 832:           g.drawLine(x + 4, y + 10, x + 7, y + 10);
 833:           g.drawLine(x + 1, y + 4, x + 1, y + 7);
 834:           g.drawLine(x + 10, y + 4, x + 10, y + 7);
 835:           g.fillRect(x + 2, y + 2, 8, 8);
 836:         }
 837:       else 
 838:         {
 839:           // only draw inner highlight if not filled
 840:           if (b.isEnabled())
 841:             {
 842:               g.setColor(MetalLookAndFeel.getWhite());
 843:           
 844:               g.drawLine(x + 2, y + 8, x + 2, y + 9);
 845:               g.drawLine(x + 1, y + 4, x + 1, y + 7);
 846:               g.drawLine(x + 2, y + 2, x + 2, y + 3);
 847:               g.drawLine(x + 3, y + 2, x + 3, y + 2);
 848:               g.drawLine(x + 4, y + 1, x + 7, y + 1);
 849:               g.drawLine(x + 8, y + 2, x + 9, y + 2);
 850:             }
 851:         }
 852: 
 853:       // draw outer highlight
 854:       if (b.isEnabled())
 855:         {
 856:           g.setColor(MetalLookAndFeel.getWhite());
 857:           
 858:           // outer
 859:           g.drawLine(x + 10, y + 1, x + 10, y + 1);
 860:           g.drawLine(x + 11, y + 2, x + 11, y + 3);
 861:           g.drawLine(x + 12, y + 4, x + 12, y + 7);
 862:           g.drawLine(x + 11, y + 8, x + 11, y + 9);
 863:           g.drawLine(x + 10, y + 10, x + 10, y + 10);
 864:           g.drawLine(x + 8, y + 11, x + 9, y + 11);
 865:           g.drawLine(x + 4, y + 12, x + 7, y + 12);
 866:           g.drawLine(x + 2, y + 11, x + 3, y + 11);
 867:         }
 868:       
 869:       if (b.isSelected())
 870:         {
 871:           if (b.isEnabled())
 872:             g.setColor(MetalLookAndFeel.getBlack());
 873:           else
 874:             g.setColor(MetalLookAndFeel.getControlDisabled());
 875:           g.drawLine(x + 4, y + 3, x + 7, y + 3);
 876:           g.fillRect(x + 3, y + 4, 6, 4);
 877:           g.drawLine(x + 4, y + 8, x + 7, y + 8);
 878:         }
 879:       g.setColor(savedColor);
 880:     }        
 881:   }
 882: 
 883:   /**
 884:    * An icon displayed for {@link JRadioButtonMenuItem} components.
 885:    */
 886:   private static class RadioButtonMenuItemIcon implements Icon, Serializable 
 887:   {
 888:     /**
 889:      * Creates a new icon instance.
 890:      */
 891:     public RadioButtonMenuItemIcon() 
 892:     {
 893:       // Nothing to do here.
 894:     }
 895: 
 896:     /**
 897:      * Returns the width of the icon, in pixels.
 898:      * 
 899:      * @return The width of the icon.
 900:      */
 901:     public int getIconWidth() 
 902:     {
 903:       return 10;
 904:     }
 905: 
 906:     /**
 907:      * Returns the height of the icon, in pixels.
 908:      * 
 909:      * @return The height of the icon.
 910:      */
 911:     public int getIconHeight()   
 912:     {
 913:       return 10;
 914:     }
 915: 
 916:     /**
 917:      * Paints the icon.
 918:      * 
 919:      * @param c  the component.
 920:      * @param g  the graphics device.
 921:      * @param x  the x-coordinate.
 922:      * @param y  the y-coordinate.
 923:      */
 924:     public void paintIcon(Component c, Graphics g, int x, int y) 
 925:     {
 926:       Color savedColor = g.getColor();
 927:       JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
 928:       g.setColor(MetalLookAndFeel.getBlack());
 929:       g.drawLine(x + 2, y, x + 6, y);
 930:       g.drawLine(x + 7, y + 1, x + 7, y + 1);
 931:       g.drawLine(x + 8, y + 2, x + 8, y + 6);
 932:       g.drawLine(x + 7, y + 7, x + 7, y + 7);
 933:       g.drawLine(x + 2, y + 8, x + 6, y + 8);
 934:       g.drawLine(x + 1, y + 7, x + 1, y + 7);
 935:       g.drawLine(x, y + 2, x, y + 6);
 936:       g.drawLine(x + 1, y + 1, x + 1, y + 1);
 937:       
 938:       if (item.isSelected())
 939:         {
 940:           g.drawLine(x + 3, y + 2, x + 5, y + 2);
 941:           g.fillRect(x + 2, y + 3, 5, 3);
 942:           g.drawLine(x + 3, y + 6, x + 5, y + 6);
 943:         }
 944: 
 945:       // highlight
 946:       g.setColor(MetalLookAndFeel.getControlHighlight());
 947:       g.drawLine(x + 3, y + 1, x + 6, y + 1);
 948:       g.drawLine(x + 8, y + 1, x + 8, y + 1);
 949:       g.drawLine(x + 9, y + 2, x + 9, y + 7);
 950:       g.drawLine(x + 8, y + 8, x + 8, y + 8);
 951:       g.drawLine(x + 2, y + 9, x + 7, y + 9);
 952:       g.drawLine(x + 1, y + 8, x + 1, y + 8);
 953:       g.drawLine(x + 1, y + 3, x + 1, y + 6);
 954:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
 955:       g.setColor(savedColor);
 956:     }        
 957:   }
 958: 
 959:   /**
 960:    * The icon used to display the thumb control on a horizontally oriented
 961:    * {@link JSlider} component.
 962:    */
 963:   private static class HorizontalSliderThumbIcon  implements Icon, Serializable
 964:   {
 965: 
 966:     /**
 967:      * This mask is used to paint the gradient in the shape of the thumb.
 968:      */
 969:     int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
 970:                                          {0, 12}, {0, 12}, {0, 12}, {1, 11},
 971:                                          {2, 10}, {3, 9}, {4, 8}, {5, 7},
 972:                                          {6, 6}};
 973: 
 974:     /**
 975:      * Creates a new instance.
 976:      */
 977:     public HorizontalSliderThumbIcon() 
 978:     {
 979:       // Nothing to do here.
 980:     }
 981:     
 982:     /**
 983:      * Returns the width of the icon, in pixels.
 984:      * 
 985:      * @return The width of the icon.
 986:      */
 987:     public int getIconWidth() 
 988:     {
 989:       return 15;
 990:     }
 991:     
 992:     /**
 993:      * Returns the height of the icon, in pixels.
 994:      * 
 995:      * @return The height of the icon.
 996:      */
 997:     public int getIconHeight() 
 998:     {
 999:       return 16;
1000:     }
1001:     
1002:     /**
1003:      * Paints the icon, taking into account whether or not the component has 
1004:      * the focus.
1005:      * 
1006:      * @param c  the component.
1007:      * @param g  the graphics device.
1008:      * @param x  the x-coordinate.
1009:      * @param y  the y-coordinate.
1010:      */
1011:     public void paintIcon(Component c, Graphics g, int x, int y) 
1012:     {
1013:       boolean enabled = false;
1014:       boolean focus = false;
1015:       if (c != null)
1016:         {
1017:           enabled = c.isEnabled();
1018:           focus = c.hasFocus();    
1019:         }
1020:       
1021:       // draw the outline
1022:       if (enabled) 
1023:         g.setColor(MetalLookAndFeel.getBlack());
1024:       else
1025:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
1026:       g.drawLine(x + 1, y, x + 13, y);
1027:       g.drawLine(x + 14, y + 1, x + 14, y + 7);
1028:       g.drawLine(x + 14, y + 8, x + 7, y + 15);
1029:       g.drawLine(x + 6, y + 14, x, y + 8);
1030:       g.drawLine(x, y + 7, x, y + 1);
1031:       
1032:       // Fill the icon.
1033:       if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
1034:           && enabled)
1035:         {
1036:           String gradient;
1037:           if (focus)
1038:             gradient = "Slider.focusGradient";
1039:           else
1040:             gradient = "Slider.gradient";
1041:           MetalUtils.paintGradient(g, x + 1, y + 2, 12, 13,
1042:                                    SwingConstants.VERTICAL, gradient,
1043:                                    gradientMask);
1044:         }
1045:       else
1046:         {
1047:           if (focus)
1048:             g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1049:           else
1050:             g.setColor(MetalLookAndFeel.getControl());
1051:           g.fillRect(x + 1, y + 2, 13, 7);
1052:           g.drawLine(x + 2, y + 9, x + 12, y + 9);
1053:           g.drawLine(x + 3, y + 10, x + 11, y + 10);
1054:           g.drawLine(x + 4, y + 11, x + 10, y + 11);
1055:           g.drawLine(x + 5, y + 12, x + 9, y + 12);
1056:           g.drawLine(x + 6, y + 13, x + 8, y + 13);
1057:           g.drawLine(x + 7, y + 14, x + 7, y + 14);
1058:         }
1059: 
1060:       // If the slider is enabled, draw dots and highlights.
1061:       if (c.isEnabled()
1062:           && !(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
1063:         {
1064:           if (focus)
1065:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1066:           else
1067:             g.setColor(MetalLookAndFeel.getBlack());
1068:           g.drawLine(x + 3, y + 3, x + 3, y + 3);
1069:           g.drawLine(x + 7, y + 3, x + 7, y + 3);
1070:           g.drawLine(x + 11, y + 3, x + 11, y + 3);
1071: 
1072:           g.drawLine(x + 5, y + 5, x + 5, y + 5);
1073:           g.drawLine(x + 9, y + 5, x + 9, y + 5);
1074: 
1075:           g.drawLine(x + 3, y + 7, x + 3, y + 7);
1076:           g.drawLine(x + 7, y + 7, x + 7, y + 7);
1077:           g.drawLine(x + 11, y + 7, x + 11, y + 7);
1078: 
1079:           // Draw highlights
1080:           if (focus)
1081:             g.setColor(MetalLookAndFeel.getPrimaryControl());
1082:           else
1083:             g.setColor(MetalLookAndFeel.getWhite());
1084:           g.drawLine(x + 1, y + 1, x + 13, y + 1);
1085:           g.drawLine(x + 1, y + 2, x + 1, y + 8);
1086:           g.drawLine(x + 2, y + 2, x + 2, y + 2);
1087:           g.drawLine(x + 6, y + 2, x + 6, y + 2);
1088:           g.drawLine(x + 10, y + 2, x + 10, y + 2);
1089:           
1090:           g.drawLine(x + 4, y + 4, x + 4, y + 4);
1091:           g.drawLine(x + 8, y + 4, x + 8, y + 4);
1092: 
1093:           g.drawLine(x + 2, y + 6, x + 2, y + 6);
1094:           g.drawLine(x + 6, y + 6, x + 6, y + 6);
1095:           g.drawLine(x + 10, y + 6, x + 10, y + 6);
1096:         }
1097: 
1098:     }        
1099:   }
1100:   
1101:   /**
1102:    * An icon used for the 'close' button in the title frame of a 
1103:    * {@link JInternalFrame}.
1104:    */
1105:   private static class InternalFrameCloseIcon implements Icon, Serializable
1106:   {
1107:     /** The icon size in pixels. */
1108:     private int size;
1109:     
1110:     /**
1111:      * Creates a new icon.
1112:      * 
1113:      * @param size  the icon size (width and height) in pixels.
1114:      */
1115:     public InternalFrameCloseIcon(int size) 
1116:     {
1117:       this.size = size;
1118:     }
1119:     
1120:     /**
1121:      * Returns the width of the icon, in pixels.
1122:      * 
1123:      * @return The width of the icon.
1124:      */
1125:     public int getIconWidth() 
1126:     {
1127:       return size;
1128:     }
1129:     
1130:     /**
1131:      * Returns the height of the icon, in pixels.
1132:      * 
1133:      * @return The height of the icon.
1134:      */
1135:     public int getIconHeight() 
1136:     {
1137:       return size;
1138:     }
1139:     
1140:     /**
1141:      * Paints the icon.
1142:      * 
1143:      * @param c  the component (an {@link JInternalFrame} is expected).
1144:      * @param g  the graphics device.
1145:      * @param x  the x-coordinate.
1146:      * @param y  the y-coordinate.
1147:      */
1148:     public void paintIcon(Component c, Graphics g, int x, int y) 
1149:     {
1150:       Color savedColor = g.getColor();
1151:       AbstractButton b = (AbstractButton) c;
1152:       
1153:       // fill the interior
1154:       if (b.getModel().isPressed())
1155:         // FIXME: also need to take into account whether the internal frame is
1156:         // selected
1157:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1158:       else
1159:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1160:       g.fillRect(x + 2, y + 2, 10, 10);
1161:       
1162:       // draw the outline box and the cross
1163:       if (b.getModel().isPressed())
1164:         g.setColor(MetalLookAndFeel.getBlack());
1165:       else
1166:         {
1167:           // FIXME: also need to take into account whether the internal frame is
1168:           // selected
1169:           boolean selected = true;
1170:           if (selected)
1171:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1172:           else
1173:             g.setColor(MetalLookAndFeel.getControlDarkShadow());
1174:         }
1175:       g.drawLine(x + 1, y + 1, x + 13, y + 1);
1176:       g.drawLine(x + 1, y + 2, x + 1, y + 12);
1177:       g.drawLine(x + 1, y + 13, x + 13, y + 13);
1178:       g.drawLine(x + 13, y + 2, x + 13, y + 12);
1179:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1180:       g.drawLine(x + 12, y + 2, x + 12, y + 2);
1181:       
1182:       g.fillRect(x + 4, y + 4, 2, 2);
1183:       g.fillRect(x + 5, y + 5, 4, 4);
1184:       g.drawLine(x + 9, y + 4, x + 10, y + 4);
1185:       g.drawLine(x + 9, y + 4, x + 9, y + 5);
1186:       g.drawLine(x + 4, y + 9, x + 4, y + 10);
1187:       g.drawLine(x + 4, y + 9, x + 5, y + 9);
1188:       g.drawLine(x + 9, y + 8, x + 9, y + 10);
1189:       g.drawLine(x + 8, y + 9, x + 10, y + 9);
1190:       
1191:       g.setColor(MetalLookAndFeel.getBlack());
1192:       g.drawLine(x, y, x + 13, y);
1193:       g.drawLine(x, y + 1, x, y + 13);
1194:       g.drawLine(x + 3, y + 4, x + 4, y + 3);
1195:       g.drawLine(x + 3, y + 9, x + 5, y + 7);
1196:       g.drawLine(x + 7, y + 5, x + 9, y + 3);
1197:       
1198:       g.drawLine(x + 12, y + 3, x + 12, y + 11);
1199:       g.drawLine(x + 3, y + 12, x + 12, y + 12);
1200:       
1201:       g.setColor(MetalLookAndFeel.getWhite());
1202:       g.drawLine(x + 1, y + 14, x + 14, y + 14);
1203:       g.drawLine(x + 14, y + 1, x + 14, y + 14);
1204:       
1205:       if (!b.getModel().isPressed())
1206:         {
1207:           g.drawLine(x + 5, y + 10, x + 5, y + 10);
1208:           g.drawLine(x + 6, y + 9, x + 7, y + 9);
1209:           g.drawLine(x + 10, y + 5, x + 10, y + 5);
1210:           g.drawLine(x + 9, y + 6, x + 9, y + 7);
1211:           g.drawLine(x + 10, y + 10, x + 11, y + 10);
1212:           g.drawLine(x + 10, y + 11, x + 10, y + 11);
1213:         }
1214:       g.setColor(savedColor);
1215:     }        
1216:   }
1217: 
1218:   /**
1219:    * The icon displayed at the top-left corner of a {@link JInternalFrame}.
1220:    */
1221:   private static class InternalFrameDefaultMenuIcon
1222:     implements Icon, Serializable 
1223:   {
1224:        
1225:     /**
1226:      * Creates a new instance.
1227:      */
1228:     public InternalFrameDefaultMenuIcon() 
1229:     {
1230:       // Nothing to do here.
1231:     }
1232:     
1233:     /**
1234:      * Returns the width of the icon, in pixels.
1235:      * 
1236:      * @return The width of the icon.
1237:      */
1238:     public int getIconWidth() 
1239:     {
1240:       return 16;
1241:     }
1242:     
1243:     /**
1244:      * Returns the height of the icon, in pixels.
1245:      * 
1246:      * @return The height of the icon.
1247:      */
1248:     public int getIconHeight() 
1249:     {
1250:       return 16;
1251:     }
1252:     
1253:     /**
1254:      * Paints the icon at the specified location.
1255:      * 
1256:      * @param c  the component.
1257:      * @param g  the graphics device.
1258:      * @param x  the x coordinate.
1259:      * @param y  the y coordinate.
1260:      */
1261:     public void paintIcon(Component c, Graphics g, int x, int y) 
1262:     {
1263:       g.setColor(new Color(102, 102, 153));
1264:       g.fillRect(x + 1, y, 14, 2);
1265:       g.fillRect(x, y + 1, 2, 14);
1266:       g.fillRect(x + 1, y + 14, 14, 2);
1267:       g.fillRect(x + 14, y + 1, 2, 14);
1268:       g.drawLine(x + 2, y + 5, x + 14, y + 5);
1269:       
1270:       g.setColor(new Color(204, 204, 255));
1271:       g.fillRect(x + 2, y + 2, 12, 3);
1272:       
1273:       g.setColor(new Color(102, 102, 153));
1274:       g.drawLine(x + 3, y + 3, x + 3, y + 3);
1275:       g.drawLine(x + 6, y + 3, x + 6, y + 3);
1276:       g.drawLine(x + 9, y + 3, x + 9, y + 3);
1277:       g.drawLine(x + 12, y + 3, x + 12, y + 3);
1278: 
1279:       g.setColor(Color.white);
1280:       g.fillRect(x + 2, y + 6, 12, 8);
1281:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
1282:       g.drawLine(x + 5, y + 2, x + 5, y + 2);
1283:       g.drawLine(x + 8, y + 2, x + 8, y + 2);
1284:       g.drawLine(x + 11, y + 2, x + 11, y + 2);
1285:     }        
1286:   }
1287: 
1288:   /**
1289:    * An icon used in the title frame of a {@link JInternalFrame}.  When you 
1290:    * maximise an internal frame, this icon will replace the 'maximise' icon to
1291:    * provide a 'restore' option.
1292:    */
1293:   private static class InternalFrameAltMaximizeIcon
1294:     implements Icon, Serializable 
1295:   {
1296:     /** The icon size in pixels. */
1297:     private int size;
1298:     
1299:     /**
1300:      * Creates a new icon.
1301:      * 
1302:      * @param size  the icon size in pixels.
1303:      */
1304:     public InternalFrameAltMaximizeIcon(int size) 
1305:     {
1306:       this.size = size;
1307:     }
1308:     
1309:     /**
1310:      * Returns the width of the icon, in pixels.
1311:      * 
1312:      * @return The width of the icon.
1313:      */
1314:     public int getIconWidth() 
1315:     {
1316:       return size;
1317:     }
1318:     
1319:     /**
1320:      * Returns the height of the icon, in pixels.
1321:      * 
1322:      * @return The height of the icon.
1323:      */
1324:     public int getIconHeight() 
1325:     {
1326:       return size;
1327:     }
1328:     
1329:     /**
1330:      * Paints the icon at the specified location.
1331:      * 
1332:      * @param c  the component.
1333:      * @param g  the graphics device.
1334:      * @param x  the x coordinate.
1335:      * @param y  the y coordinate.
1336:      */
1337:     public void paintIcon(Component c, Graphics g, int x, int y) 
1338:     {
1339:       Color savedColor = g.getColor();
1340: 
1341:       AbstractButton b = (AbstractButton) c;
1342: 
1343:       // fill the small box interior
1344:       if (b.getModel().isPressed())
1345:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1346:       else
1347:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1348:       g.fillRect(x + 2, y + 6, 7, 7);
1349:       
1350:       
1351:       if (b.getModel().isPressed())
1352:         g.setColor(MetalLookAndFeel.getBlack());
1353:       else
1354:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1355:         
1356:       g.drawLine(x + 12, y + 1, x + 13, y + 1);
1357:       g.drawLine(x + 11, y + 2, x + 12, y + 2);
1358:       g.drawLine(x + 10, y + 3, x + 11, y + 3);
1359:       g.drawLine(x + 8, y + 2, x + 8, y + 3);
1360:       g.fillRect(x + 8, y + 4, 3, 3);
1361:       g.drawLine(x + 11, y + 6, x + 12, y + 6);
1362:       
1363:       g.drawLine(x + 1, y + 5, x + 5, y + 5);
1364:       g.drawLine(x + 1, y + 6, x + 1, y + 12);
1365:       g.drawLine(x + 9, y + 9, x + 9, y + 12);
1366:       g.drawLine(x + 1, y + 13, x + 9, y + 13);
1367:       
1368:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1369:       
1370:       g.setColor(MetalLookAndFeel.getBlack());
1371:       g.drawLine(x + 12, y, x + 9, y + 3);
1372:       g.drawLine(x + 7, y + 1, x + 8, y + 1);
1373:       g.drawLine(x + 7, y + 2, x + 7, y + 6);
1374:       g.drawLine(x + 11, y + 5, x + 12, y + 5);
1375:       g.drawLine(x, y + 4, x + 5, y + 4);
1376:       g.drawLine(x, y + 5, x, y + 13);
1377:       g.drawLine(x + 3, y + 12, x + 8, y + 12);
1378:       g.drawLine(x + 8, y + 8, x + 8, y + 11);
1379:       g.drawLine(x + 9, y + 8, x + 9, y + 8);
1380:       
1381:       g.setColor(MetalLookAndFeel.getWhite());
1382:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
1383:       g.drawLine(x + 11, y + 4, x + 13, y + 2);
1384:       g.drawLine(x + 13, y + 6, x + 13, y + 6);
1385:       g.drawLine(x + 8, y + 7, x + 13, y + 7);
1386:       g.drawLine(x + 6, y + 5, x + 6, y + 5);
1387:       g.drawLine(x + 10, y + 8, x + 10, y + 13);
1388:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
1389:       
1390:       if (!b.getModel().isPressed())
1391:         {
1392:           g.drawLine(x + 2, y + 6, x + 6, y + 6);
1393:           g.drawLine(x + 2, y + 6, x + 2, y + 11);
1394:         }
1395:       
1396:       g.setColor(savedColor);
1397:     }        
1398:   }
1399:   
1400:   /**
1401:    * An icon used for the 'maximize' button in the title frame of a 
1402:    * {@link JInternalFrame}.
1403:    */
1404:   private static class InternalFrameMaximizeIcon implements Icon, Serializable
1405:   {
1406:     
1407:     /**
1408:      * Creates a new instance.
1409:      */
1410:     public InternalFrameMaximizeIcon() 
1411:     {
1412:       // Nothing to do here.
1413:     }
1414:     
1415:     /**
1416:      * Returns the width of the icon, in pixels.
1417:      * 
1418:      * @return The width of the icon.
1419:      */
1420:     public int getIconWidth() 
1421:     {
1422:       return 16;
1423:     }
1424:     
1425:     /**
1426:      * Returns the height of the icon, in pixels.
1427:      * 
1428:      * @return The height of the icon.
1429:      */
1430:     public int getIconHeight() 
1431:     {
1432:       return 16;
1433:     }
1434:     
1435:     /**
1436:      * Paints the icon at the specified location.
1437:      * 
1438:      * @param c  the component.
1439:      * @param g  the graphics device.
1440:      * @param x  the x coordinate.
1441:      * @param y  the y coordinate.
1442:      */
1443:     public void paintIcon(Component c, Graphics g, int x, int y) 
1444:     {
1445:       Color savedColor = g.getColor();
1446:       
1447:       AbstractButton b = (AbstractButton) c;
1448:       
1449:       // fill the interior
1450:       if (b.getModel().isPressed())
1451:         g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1452:       else
1453:         g.setColor(MetalLookAndFeel.getPrimaryControl());
1454:       g.fillRect(x + 2, y + 6, 7, 7);
1455: 
1456:       if (b.getModel().isPressed())
1457:         g.setColor(MetalLookAndFeel.getBlack());
1458:       else
1459:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1460:           
1461:       g.drawLine(x + 9, y + 1, x + 10, y + 1);
1462:       g.fillRect(x + 11, y + 1, 3, 3);
1463:       g.fillRect(x + 12, y + 4, 2, 2);
1464:       g.drawLine(x + 10, y + 3, x + 10, y + 3);
1465:       g.drawLine(x + 9, y + 4, x + 10, y + 4);
1466:       g.drawLine(x + 1, y + 5, x + 9, y + 5);
1467:       g.drawLine(x + 1, y + 6, x + 1, y + 12);
1468:       g.drawLine(x + 9, y + 6, x + 9, y + 12);
1469:       g.drawLine(x + 1, y + 13, x + 9, y + 13);
1470:       
1471:       // fill
1472:       g.drawLine(x + 7, y + 6, x + 8, y + 6);
1473:       g.drawLine(x + 6, y + 7, x + 8, y + 7);
1474:       g.drawLine(x + 5, y + 8, x + 6, y + 8);
1475:       g.drawLine(x + 4, y + 9, x + 5, y + 9);
1476:       g.drawLine(x + 3, y + 10, x + 4, y + 10);
1477:       g.drawLine(x + 2, y + 11, x + 3, y + 11);
1478:       g.drawLine(x + 2, y + 12, x + 4, y + 12);
1479:       g.drawLine(x + 8, y + 8, x + 8, y + 8);
1480:       
1481:       // draw black
1482:       g.setColor(MetalLookAndFeel.getBlack());
1483:       g.drawLine(x + 8, y, x + 13, y);
1484:       g.drawLine(x + 8, y + 1, x + 8, y + 1);
1485:       g.drawLine(x + 10, y + 2, x + 9, y + 3);
1486:       g.drawLine(x, y + 4, x + 8, y + 4);
1487:       g.drawLine(x, y + 5, x, y + 13);
1488:       
1489:       g.drawLine(x + 2, y + 10, x + 6, y + 6);
1490:       g.drawLine(x + 8, y + 9, x + 8, y + 11);
1491:       g.drawLine(x + 5, y + 12, x + 8, y + 12);
1492:       
1493:       // draw white
1494:       g.setColor(MetalLookAndFeel.getWhite());
1495:       if (!b.getModel().isPressed())
1496:         {
1497:           g.drawLine(x + 2, y + 6, x + 5, y + 6);
1498:           g.drawLine(x + 2, y + 7, x + 2, y + 9);
1499:           g.drawLine(x + 4, y + 11, x + 7, y + 8);
1500:         }
1501:       
1502:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
1503:       g.drawLine(x + 10, y + 5, x + 10, y + 13);
1504:       
1505:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
1506:       g.drawLine(x + 11, y + 4, x + 11, y + 5);
1507:       g.drawLine(x + 13, y + 6, x + 14, y + 6);
1508:       g.drawLine(x + 14, y + 1, x + 14, y + 5);
1509:       g.setColor(savedColor);
1510:     }        
1511:   }
1512: 
1513:   /**
1514:    * An icon used in the title frame of a {@link JInternalFrame}.
1515:    */
1516:   private static class InternalFrameMinimizeIcon implements Icon, Serializable
1517:   {
1518:   
1519:     /**
1520:      * Creates a new instance.
1521:      */
1522:     public InternalFrameMinimizeIcon() 
1523:     {
1524:       // Nothing to do here.
1525:     }
1526:     
1527:     /**
1528:      * Returns the width of the icon, in pixels.
1529:      * 
1530:      * @return The width of the icon.
1531:      */
1532:     public int getIconWidth() 
1533:     {
1534:       return 16;
1535:     }
1536:     
1537:     /**
1538:      * Returns the height of the icon, in pixels.
1539:      * 
1540:      * @return The height of the icon.
1541:      */
1542:     public int getIconHeight() 
1543:     {
1544:       return 16;
1545:     }
1546:     
1547:     /**
1548:      * Paints the icon at the specified location.
1549:      * 
1550:      * @param c  the component.
1551:      * @param g  the graphics device.
1552:      * @param x  the x coordinate.
1553:      * @param y  the y coordinate.
1554:      */
1555:     public void paintIcon(Component c, Graphics g, int x, int y) 
1556:     {
1557:       Color savedColor = g.getColor();
1558:       
1559:       AbstractButton b = (AbstractButton) c;
1560:       
1561:       if (b.getModel().isPressed())
1562:         g.setColor(MetalLookAndFeel.getBlack());
1563:       else
1564:         // FIXME: here the color depends on whether or not the internal frame 
1565:         // is selected 
1566:         g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1567:       
1568:       g.drawLine(x + 12, y + 1, x + 13, y + 1);
1569:       g.drawLine(x + 11, y + 2, x + 12, y + 2);
1570:       g.drawLine(x + 10, y + 3, x + 11, y + 3);
1571:       g.drawLine(x + 8, y + 2, x + 8, y + 3);
1572:       g.fillRect(x + 8, y + 4, 3, 3);
1573:       g.drawLine(x + 11, y + 6, x + 12, y + 6);
1574:       
1575:       g.drawLine(x + 1, y + 8, x + 6, y + 8);
1576:       g.drawLine(x + 1, y + 9, x + 1, y + 12);
1577:       g.drawLine(x + 6, y + 9, x + 6, y + 12);
1578:       g.drawLine(x + 1, y + 13, x + 6, y + 13);
1579:       
1580:       g.drawLine(x + 5, y + 9, x + 5, y + 9);
1581:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
1582:       
1583:       g.setColor(MetalLookAndFeel.getBlack());
1584:       g.drawLine(x + 12, y, x + 9, y + 3);
1585:       g.drawLine(x + 7, y + 1, x + 8, y + 1);
1586:       g.drawLine(x + 7, y + 2, x + 7, y + 6);
1587:       g.drawLine(x, y + 7, x + 6, y + 7);
1588:       g.drawLine(x, y + 8, x, y + 13);
1589:       g.drawLine(x + 3, y + 12, x + 5, y + 12);
1590:       g.drawLine(x + 5, y + 10, x + 5, y + 11);
1591:       g.drawLine(x + 11, y + 5, x + 12, y + 5);
1592:       
1593:       g.setColor(MetalLookAndFeel.getWhite());
1594:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
1595:       g.drawLine(x + 11, y + 4, x + 13, y + 2);
1596:       g.drawLine(x + 13, y + 6, x + 13, y + 6);
1597:       g.drawLine(x + 8, y + 7, x + 13, y + 7);
1598:       g.drawLine(x + 7, y + 9, x + 7, y + 13);
1599:       g.drawLine(x + 1, y + 14, x + 7, y + 14);
1600: 
1601:       if (b.getModel().isPressed())
1602:         {
1603:           g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1604:           g.fillRect(x + 2, y + 9, 3, 3);
1605:         }
1606:       else
1607:         {
1608:           g.drawLine(x + 2, y + 9, x + 4, y + 9);
1609:           g.drawLine(x + 2, y + 10, x + 2, y + 11);
1610:         }
1611: 
1612:       g.setColor(savedColor);
1613:     }        
1614:   }
1615: 
1616:   /**
1617:    * The icon used to display the thumb control on a horizontally oriented
1618:    * {@link JSlider} component.
1619:    */
1620:   private static class VerticalSliderThumbIcon implements Icon, Serializable
1621:   {
1622:     /**
1623:      * This mask is used to paint the gradient in the shape of the thumb.
1624:      */
1625:     int[][] gradientMask = new int[][] { {0, 12}, {0, 12}, {0, 12}, {0, 12},
1626:                                          {0, 12}, {0, 12}, {0, 12}, {1, 11},
1627:                                          {2, 10}, {3, 9}, {4, 8}, {5, 7},
1628:                                          {6, 6}};
1629: 
1630:     /**
1631:      * Creates a new instance.
1632:      */
1633:     public VerticalSliderThumbIcon() 
1634:     {
1635:       // Nothing to do here.
1636:     }
1637:     
1638:     /**
1639:      * Returns the width of the icon, in pixels.
1640:      * 
1641:      * @return The width of the icon.
1642:      */
1643:     public int getIconWidth() 
1644:     {
1645:       return 16;
1646:     }
1647:     
1648:     /**
1649:      * Returns the height of the icon, in pixels.
1650:      * 
1651:      * @return The height of the icon.
1652:      */
1653:     public int getIconHeight() 
1654:     {
1655:       return 15;
1656:     }
1657:     
1658:     /**
1659:      * Paints the icon taking into account whether the slider control has the
1660:      * focus or not.
1661:      * 
1662:      * @param c  the slider (must be a non-<code>null</code> instance of
1663:      *           {@link JSlider}.
1664:      * @param g  the graphics device.
1665:      * @param x  the x-coordinate.
1666:      * @param y  the y-coordinate.
1667:      */
1668:     public void paintIcon(Component c, Graphics g, int x, int y) 
1669:     {
1670:       boolean enabled = false;
1671:       boolean focus = false;
1672:       if (c != null)
1673:         {
1674:           enabled = c.isEnabled();
1675:           focus = c.hasFocus();    
1676:         }
1677:       
1678:       // draw the outline
1679:       if (enabled) 
1680:         g.setColor(MetalLookAndFeel.getBlack());
1681:       else
1682:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
1683:       g.drawLine(x + 1, y, x + 7, y);
1684:       g.drawLine(x + 8, y, x + 15, y + 7);
1685:       g.drawLine(x + 14, y + 8, x + 8, y + 14);
1686:       g.drawLine(x + 8, y + 14, x + 1, y + 14);
1687:       g.drawLine(x, y + 13, x, y + 1);
1688:       
1689:       // Fill the icon.
1690:       if (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme
1691:           && enabled)
1692:         {
1693:           String gradient;
1694:           if (focus)
1695:             gradient = "Slider.focusGradient";
1696:           else
1697:             gradient = "Slider.gradient";
1698:           MetalUtils.paintGradient(g, x + 2, y + 1, 13, 12,
1699:                                    SwingConstants.HORIZONTAL, gradient,
1700:                                    gradientMask);
1701:         }
1702:       else
1703:         {
1704:           if (focus)
1705:             g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
1706:           else
1707:             g.setColor(MetalLookAndFeel.getControl());
1708:           g.fillRect(x + 2, y + 1, 7, 13);
1709:           g.drawLine(x + 9, y + 2, x + 9, y + 12);
1710:           g.drawLine(x + 10, y + 3, x + 10, y + 11);
1711:           g.drawLine(x + 11, y + 4, x + 11, y + 10);
1712:           g.drawLine(x + 12, y + 5, x + 12, y + 9);
1713:           g.drawLine(x + 13, y + 6, x + 13, y + 8);
1714:           g.drawLine(x + 14, y + 7, x + 14, y + 7);
1715:         }
1716: 
1717:       // if the slider is enabled, draw dots and highlights
1718:       if (enabled
1719:           && ! (MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme))
1720:         {
1721:           if (focus)
1722:             g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
1723:           else
1724:             g.setColor(MetalLookAndFeel.getBlack());
1725:           g.drawLine(x + 3, y + 3, x + 3, y + 3);
1726:           g.drawLine(x + 3, y + 7, x + 3, y + 7);
1727:           g.drawLine(x + 3, y + 11, x + 3, y + 11);
1728: 
1729:           g.drawLine(x + 5, y + 5, x + 5, y + 5);
1730:           g.drawLine(x + 5, y + 9, x + 5, y + 9);
1731: 
1732:           g.drawLine(x + 7, y + 3, x + 7, y + 3);
1733:           g.drawLine(x + 7, y + 7, x + 7, y + 7);
1734:           g.drawLine(x + 7, y + 11, x + 7, y + 11);
1735: 
1736:           // draw highlights
1737:           if (focus)
1738:             g.setColor(MetalLookAndFeel.getPrimaryControl());
1739:           else
1740:             g.setColor(MetalLookAndFeel.getWhite());
1741:           g.drawLine(x + 1, y + 1, x + 8, y + 1);
1742:           g.drawLine(x + 1, y + 2, x + 1, y + 13);
1743:           g.drawLine(x + 2, y + 2, x + 2, y + 2);
1744:           g.drawLine(x + 2, y + 6, x + 2, y + 6);
1745:           g.drawLine(x + 2, y + 10, x + 2, y + 10);
1746: 
1747:           g.drawLine(x + 4, y + 4, x + 4, y + 4);
1748:           g.drawLine(x + 4, y + 8, x + 4, y + 8);
1749: 
1750:           g.drawLine(x + 6, y + 2, x + 6, y + 2);
1751:           g.drawLine(x + 6, y + 6, x + 6, y + 6);
1752:           g.drawLine(x + 6, y + 10, x + 6, y + 10);
1753:         
1754:         }
1755:     }        
1756:   }
1757:     
1758:   /**
1759:    * A tree control icon.  This icon can be in one of two states: expanded and
1760:    * collapsed.
1761:    */
1762:   public static class TreeControlIcon implements Icon, Serializable
1763:   {
1764:     
1765:     /** ???. */
1766:     protected boolean isLight;
1767:     
1768:     /** A flag that controls whether or not the icon is collapsed. */
1769:     private boolean collapsed;
1770:     
1771:     /**
1772:      * Creates a new icon.
1773:      * 
1774:      * @param isCollapsed  a flag that controls whether the icon is in the
1775:      *                     collapsed state or the expanded state.
1776:      */
1777:     public TreeControlIcon(boolean isCollapsed) 
1778:     {
1779:       collapsed = isCollapsed;
1780:     }
1781:     
1782:     /**
1783:      * Returns the width of the icon, in pixels.
1784:      * 
1785:      * @return The width of the icon.
1786:      */
1787:     public int getIconWidth() 
1788:     {
1789:       return 18;
1790:     }
1791:     /**
1792:      * Returns the height of the icon, in pixels.
1793:      * 
1794:      * @return The height of the icon.
1795:      */
1796:     public int getIconHeight() 
1797:     {
1798:       return 18;
1799:     }
1800:     
1801:     /**
1802:      * Paints the icon at the location (x, y).
1803:      * 
1804:      * @param c  the component.
1805:      * @param g  the graphics device.
1806:      * @param x  the x coordinate.
1807:      * @param y  the y coordinate.
1808:      */
1809:     public void paintIcon(Component c, Graphics g, int x, int y) 
1810:     {
1811:       x = x + 5;
1812:       y = y + 5;
1813:       if (collapsed) 
1814:       {
1815:         // TODO: pick up appropriate UI colors
1816:         g.setColor(Color.black);
1817:         g.drawLine(x + 2, y, x + 5, y);
1818:         g.drawLine(x + 6, y + 1, x + 7, y + 2);
1819:         g.fillRect(x + 7, y + 3, 5, 2);
1820:         g.drawLine(x + 7, y + 5, x + 6, y + 6);
1821:         g.drawLine(x + 1, y + 1, x + 1, y + 1);
1822:         g.drawLine(x, y + 2, x, y + 5);
1823:         g.drawLine(x + 1, y + 6, x + 1, y + 6);
1824:         g.drawLine(x + 2, y + 7, x + 5, y + 7);
1825:         g.fillRect(x + 3, y + 3, 2, 2);
1826: 
1827:         g.setColor(new Color(204, 204, 255));
1828:         g.drawLine(x + 3, y + 2, x + 4, y + 2);
1829:         g.drawLine(x + 2, y + 3, x + 2, y + 4);
1830:         g.drawLine(x + 3, y + 5, x + 3, y + 5);
1831:         g.drawLine(x + 5, y + 3, x + 5, y + 3);
1832:         
1833:         g.setColor(new Color(153, 153, 204));
1834:         g.drawLine(x + 2, y + 2, x + 2, y + 2);
1835:         g.drawLine(x + 2, y + 5, x + 2, y + 5);
1836:         g.drawLine(x + 2, y + 6, x + 5, y + 6);
1837:         g.drawLine(x + 5, y + 2, x + 5, y + 2);
1838:         g.drawLine(x + 6, y + 2, x + 6, y + 5);
1839:         
1840:         g.setColor(new Color(102, 102, 153));
1841:         g.drawLine(x + 2, y + 1, x + 5, y + 1);
1842:         g.drawLine(x + 1, y + 2, x + 1, y + 5);
1843:       }
1844:       else
1845:       {
1846:         // TODO: pick up appropriate UI colors
1847:         g.setColor(Color.black);
1848:         g.drawLine(x + 2, y, x + 5, y);
1849:         g.drawLine(x + 6, y + 1, x + 7, y + 2);
1850:         g.drawLine(x + 7, y + 2, x + 7, y + 5);
1851:         g.fillRect(x + 3, y + 7, 2, 5);
1852:         g.drawLine(x + 7, y + 5, x + 6, y + 6);
1853:         g.drawLine(x + 1, y + 1, x + 1, y + 1);
1854:         g.drawLine(x, y + 2, x, y + 5);
1855:         g.drawLine(x + 1, y + 6, x + 1, y + 6);
1856:         g.drawLine(x + 2, y + 7, x + 5, y + 7);
1857:         g.fillRect(x + 3, y + 3, 2, 2);
1858: 
1859:         g.setColor(new Color(204, 204, 255));
1860:         g.drawLine(x + 3, y + 2, x + 4, y + 2);
1861:         g.drawLine(x + 2, y + 3, x + 2, y + 4);
1862:         g.drawLine(x + 3, y + 5, x + 3, y + 5);
1863:         g.drawLine(x + 5, y + 3, x + 5, y + 3);
1864:         
1865:         g.setColor(new Color(153, 153, 204));
1866:         g.drawLine(x + 2, y + 2, x + 2, y + 2);
1867:         g.drawLine(x + 2, y + 5, x + 2, y + 5);
1868:         g.drawLine(x + 2, y + 6, x + 5, y + 6);
1869:         g.drawLine(x + 5, y + 2, x + 5, y + 2);
1870:         g.drawLine(x + 6, y + 2, x + 6, y + 5);
1871:         
1872:         g.setColor(new Color(102, 102, 153));
1873:         g.drawLine(x + 2, y + 1, x + 5, y + 1);
1874:         g.drawLine(x + 1, y + 2, x + 1, y + 5);
1875:       }
1876:     } 
1877:     
1878:     /**
1879:      * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
1880:      * 
1881:      * @param c  the component.
1882:      * @param g  the graphics device.
1883:      * @param x  the x coordinate.
1884:      * @param y  the y coordinate.
1885:      */
1886:     public void paintMe(Component c, Graphics g, int x, int y) 
1887:     {
1888:       paintIcon(c, g, x, y);  
1889:     }
1890:   }
1891:     
1892:   /**
1893:    * A tree folder icon.
1894:    */
1895:   public static class TreeFolderIcon extends FolderIcon16
1896:   {
1897:     /**
1898:      * Creates a new instance.
1899:      */
1900:     public TreeFolderIcon() 
1901:     {
1902:       // Nothing to do here.
1903:     }
1904:     
1905:     /**
1906:      * Returns the additional height for this icon, in this case <code>2</code>
1907:      * pixels.
1908:      * 
1909:      * @return <code>2</code>.
1910:      */
1911:     public int getAdditionalHeight() 
1912:     {
1913:       return 2;
1914:     }
1915:     
1916:     /**
1917:      * Returns the shift (???).
1918:      * 
1919:      * @return The shift.
1920:      */
1921:     public int getShift() 
1922:     {
1923:       return -1;
1924:     }
1925:   }
1926:     
1927:   /**
1928:    * A tree leaf icon.
1929:    */
1930:   public static class TreeLeafIcon extends FileIcon16
1931:   {
1932:     /**
1933:      * Creates a new instance.
1934:      */
1935:     public TreeLeafIcon() 
1936:     {
1937:       // Nothing to do here.
1938:     }
1939:     
1940:     /**
1941:      * Returns the additional height for this icon, in this case <code>4</code>
1942:      * pixels.
1943:      * 
1944:      * @return <code>4</code>.
1945:      */
1946:     public int getAdditionalHeight() 
1947:     {
1948:       return 4;
1949:     }
1950:     
1951:     /**
1952:      * Returns the shift (???).
1953:      * 
1954:      * @return The shift.
1955:      */
1956:     public int getShift() 
1957:     {
1958:       return 2;
1959:     }
1960:   }
1961: 
1962:   /**
1963:    * An icon representing a hard disk.
1964:    * 
1965:    * @see MetalIconFactory#getTreeHardDriveIcon()
1966:    */
1967:   private static class TreeHardDriveIcon implements Icon, Serializable
1968:   {
1969: 
1970:     /**
1971:      * Creates a new icon instance.
1972:      */
1973:     public TreeHardDriveIcon() 
1974:     {
1975:       // Nothing to do here.
1976:     }
1977: 
1978:     /**
1979:      * Returns the width of the icon, in pixels.
1980:      * 
1981:      * @return <code>16</code>.
1982:      */
1983:     public int getIconWidth() 
1984:     { 
1985:       return 16;
1986:     }
1987: 
1988:     /**
1989:      * Returns the height of the icon, in pixels.
1990:      * 
1991:      * @return <code>16</code>.
1992:      */
1993:     public int getIconHeight()   
1994:     {
1995:       return 16;
1996:     }
1997: 
1998:     /**
1999:      * Paints the icon at the specified location, using colors from the 
2000:      * current theme.
2001:      * 
2002:      * @param c  the component (ignored).
2003:      * @param g  the graphics device.
2004:      * @param x  the x-coordinate for the top-left of the icon.
2005:      * @param y  the y-coordinate for the top-left of the icon.
2006:      */
2007:     public void paintIcon(Component c, Graphics g, int x, int y) 
2008:     {
2009:       Color saved = g.getColor();
2010:       g.setColor(MetalLookAndFeel.getBlack());
2011:       g.drawLine(x + 1, y + 4, x + 1, y + 5);
2012:       g.drawLine(x + 14, y + 4, x + 14, y + 5);
2013:       g.drawLine(x + 1, y + 7, x + 1, y + 8);
2014:       g.drawLine(x + 14, y + 7, x + 14, y + 8);
2015:       g.drawLine(x + 1, y + 10, x + 1, y + 11);
2016:       g.drawLine(x + 14, y + 10, x + 14, y + 11);
2017:       
2018:       g.drawLine(x + 2, y + 3, x + 3, y + 3);
2019:       g.drawLine(x + 12, y + 3, x + 13, y + 3);
2020:       g.drawLine(x + 2, y + 6, x + 3, y + 6);
2021:       g.drawLine(x + 12, y + 6, x + 13, y + 6);
2022:       g.drawLine(x + 2, y + 9, x + 3, y + 9);
2023:       g.drawLine(x + 12, y + 9, x + 13, y + 9);
2024:       g.drawLine(x + 2, y + 12, x + 3, y + 12);
2025:       g.drawLine(x + 12, y + 12, x + 13, y + 12);
2026:       
2027:       g.drawLine(x + 4, y + 2, x + 11, y + 2);
2028:       g.drawLine(x + 4, y + 7, x + 11, y + 7);
2029:       g.drawLine(x + 4, y + 10, x + 11, y + 10);
2030:       g.drawLine(x + 4, y + 13, x + 11, y + 13);
2031:       
2032:       g.setColor(MetalLookAndFeel.getWhite());
2033:       g.fillRect(x + 4, y + 3, 2, 2);
2034:       g.drawLine(x + 6, y + 4, x + 6, y + 4);
2035:       g.drawLine(x + 7, y + 3, x + 9, y + 3);
2036:       g.drawLine(x + 8, y + 4, x + 8, y + 4);
2037:       g.drawLine(x + 11, y + 3, x + 11, y + 3);
2038:       g.fillRect(x + 2, y + 4, 2, 2); 
2039:       g.fillRect(x + 2, y + 7, 2, 2); 
2040:       g.fillRect(x + 2, y + 10, 2, 2); 
2041:       g.drawLine(x + 4, y + 6, x + 4, y + 6);
2042:       g.drawLine(x + 4, y + 9, x + 4, y + 9);
2043:       g.drawLine(x + 4, y + 12, x + 4, y + 12);
2044:       
2045:       g.setColor(MetalLookAndFeel.getControlShadow());
2046:       g.drawLine(x + 13, y + 4, x + 13, y + 4);
2047:       g.drawLine(x + 12, y + 5, x + 13, y + 5);
2048:       g.drawLine(x + 13, y + 7, x + 13, y + 7);
2049:       g.drawLine(x + 12, y + 8, x + 13, y + 8);
2050:       g.drawLine(x + 13, y + 10, x + 13, y + 10);
2051:       g.drawLine(x + 12, y + 11, x + 13, y + 11);
2052:       
2053:       g.drawLine(x + 10, y + 5, x + 10, y + 5);
2054:       g.drawLine(x + 7, y + 6, x + 7, y + 6);
2055:       g.drawLine(x + 9, y + 6, x + 9, y + 6);
2056:       g.drawLine(x + 11, y + 6, x + 11, y + 6);
2057: 
2058:       g.drawLine(x + 10, y + 8, x + 10, y + 8);
2059:       g.drawLine(x + 7, y + 9, x + 7, y + 9);
2060:       g.drawLine(x + 9, y + 9, x + 9, y + 9);
2061:       g.drawLine(x + 11, y + 9, x + 11, y + 9);
2062: 
2063:       g.drawLine(x + 10, y + 11, x + 10, y + 11);
2064:       g.drawLine(x + 7, y + 12, x + 7, y + 12);
2065:       g.drawLine(x + 9, y + 12, x + 9, y + 12);
2066:       g.drawLine(x + 11, y + 12, x + 11, y + 12);
2067: 
2068:       g.setColor(saved);
2069:     }        
2070:   }  
2071:   
2072:   /**
2073:    * An icon representing a floppy disk.
2074:    * 
2075:    * @see MetalIconFactory#getTreeFloppyDriveIcon()
2076:    */
2077:   private static class TreeFloppyDriveIcon implements Icon, Serializable
2078:   {
2079: 
2080:     /**
2081:      * Creates a new icon instance.
2082:      */
2083:     public TreeFloppyDriveIcon() 
2084:     {
2085:       // Nothing to do here.
2086:     }
2087: 
2088:     /**
2089:      * Returns the width of the icon, in pixels.
2090:      * 
2091:      * @return <code>16</code>.
2092:      */
2093:     public int getIconWidth() 
2094:     { 
2095:       return 16;
2096:     }
2097: 
2098:     /**
2099:      * Returns the height of the icon, in pixels.
2100:      * 
2101:      * @return <code>16</code>.
2102:      */
2103:     public int getIconHeight()   
2104:     {
2105:       return 16;
2106:     }
2107: 
2108:     /**
2109:      * Paints the icon at the specified location, using colors from the 
2110:      * current theme.
2111:      * 
2112:      * @param c  the component (ignored).
2113:      * @param g  the graphics device.
2114:      * @param x  the x-coordinate for the top-left of the icon.
2115:      * @param y  the y-coordinate for the top-left of the icon.
2116:      */
2117:     public void paintIcon(Component c, Graphics g, int x, int y) 
2118:     {
2119:       Color saved = g.getColor();
2120:       
2121:       g.setColor(MetalLookAndFeel.getBlack());
2122:       g.drawLine(x + 1, y + 1, x + 13, y + 1);
2123:       g.drawLine(x + 1, y + 1, x + 1, y + 14);
2124:       g.drawLine(x + 1, y + 14, x + 14, y + 14);
2125:       g.drawLine(x + 14, y + 2, x + 14, y + 14);
2126:       
2127:       g.setColor(MetalLookAndFeel.getPrimaryControl());
2128:       g.fillRect(x + 2, y + 2, 12, 12);
2129:       
2130:       g.setColor(MetalLookAndFeel.getControlShadow());
2131:       g.fillRect(x + 5, y + 2, 6, 5);
2132:       g.drawLine(x + 4, y + 8, x + 11, y + 8);
2133:       g.drawLine(x + 3, y + 9, x + 3, y + 13);
2134:       g.drawLine(x + 12, y + 9, x + 12, y + 13);
2135:       
2136:       g.setColor(MetalLookAndFeel.getWhite());
2137:       g.fillRect(x + 8, y + 3, 2, 3);
2138:       g.fillRect(x + 4, y + 9, 8, 5);
2139:       
2140:       g.setColor(MetalLookAndFeel.getPrimaryControlShadow());
2141:       g.drawLine(x + 5, y + 10, x + 9, y + 10);
2142:       g.drawLine(x + 5, y + 12, x + 8, y + 12);
2143: 
2144:       g.setColor(saved);
2145:     }        
2146:   }  
2147: 
2148:   /**
2149:    * An icon representing a computer.
2150:    * 
2151:    * @see MetalIconFactory#getTreeComputerIcon()
2152:    */
2153:   private static class TreeComputerIcon implements Icon, Serializable
2154:   {
2155: 
2156:     /**
2157:      * Creates a new icon instance.
2158:      */
2159:     public TreeComputerIcon() 
2160:     {
2161:       // Nothing to do here.
2162:     }
2163: 
2164:     /**
2165:      * Returns the width of the icon, in pixels.
2166:      * 
2167:      * @return <code>16</code>.
2168:      */
2169:     public int getIconWidth() 
2170:     { 
2171:       return 16;
2172:     }
2173: 
2174:     /**
2175:      * Returns the height of the icon, in pixels.
2176:      * 
2177:      * @return <code>16</code>.
2178:      */
2179:     public int getIconHeight()   
2180:     {
2181:       return 16;
2182:     }
2183: 
2184:     /**
2185:      * Paints the icon at the specified location, using colors from the 
2186:      * current theme.
2187:      * 
2188:      * @param c  the component (ignored).
2189:      * @param g  the graphics device.
2190:      * @param x  the x-coordinate for the top-left of the icon.
2191:      * @param y  the y-coordinate for the top-left of the icon.
2192:      */
2193:     public void paintIcon(Component c, Graphics g, int x, int y) 
2194:     {
2195:       Color saved = g.getColor();
2196:       
2197:       g.setColor(MetalLookAndFeel.getBlack());
2198:       g.drawLine(x + 3, y + 1, x + 12, y + 1);
2199:       g.drawLine(x + 2, y + 2, x + 2, y + 8);
2200:       g.drawLine(x + 13, y + 2, x + 13, y + 8);
2201:       g.drawLine(x + 3, y + 9, x + 3, y + 9);
2202:       g.drawLine(x + 12, y + 9, x + 12, y + 9);
2203:       g.drawRect(x + 1, y + 10, 13, 4);
2204:       g.drawLine(x + 5, y + 3, x + 10, y + 3);
2205:       g.drawLine(x + 5, y + 8, x + 10, y + 8);
2206:       g.drawLine(x + 4, y + 4, x + 4, y + 7);
2207:       g.drawLine(x + 11, y + 4, x + 11, y + 7);
2208: 
2209:       g.setColor(MetalLookAndFeel.getPrimaryControl());
2210:       g.fillRect(x + 5, y + 4, 6, 4);
2211:       
2212:       g.setColor(MetalLookAndFeel.getControlShadow());
2213:       g.drawLine(x + 6, y + 12, x + 8, y + 12);
2214:       g.drawLine(x + 10, y + 12, x + 12, y + 12);
2215:       g.setColor(saved);
2216:     }        
2217:   }  
2218:     
2219:   /** The icon returned by {@link #getCheckBoxIcon()}. */
2220:   private static Icon checkBoxIcon;
2221:   
2222:   /** The icon returned by {@link #getCheckBoxMenuItemIcon()}. */
2223:   private static Icon checkBoxMenuItemIcon;
2224:   
2225:   /** The icon returned by {@link #getFileChooserDetailViewIcon()}. */
2226:   private static Icon fileChooserDetailViewIcon;
2227: 
2228:   /** The icon returned by {@link #getFileChooserHomeFolderIcon()}. */
2229:   private static Icon fileChooserHomeFolderIcon;
2230: 
2231:   /** The icon returned by {@link #getFileChooserListViewIcon()}. */
2232:   private static Icon fileChooserListViewIcon;
2233: 
2234:   /** The icon returned by {@link #getFileChooserNewFolderIcon()}. */
2235:   private static Icon fileChooserNewFolderIcon;
2236: 
2237:   /** The icon returned by {@link #getFileChooserUpFolderIcon()}. */
2238:   private static Icon fileChooserUpFolderIcon;
2239: 
2240:   /** The cached RadioButtonIcon instance. */
2241:   private static RadioButtonIcon radioButtonIcon;
2242: 
2243:   /** The icon returned by {@link #getRadioButtonMenuItemIcon()}. */
2244:   private static Icon radioButtonMenuItemIcon;
2245: 
2246:   /** The icon returned by {@link #getInternalFrameDefaultMenuIcon()}. */
2247:   private static Icon internalFrameDefaultMenuIcon;
2248: 
2249:   /** The icon returned by {@link #getTreeComputerIcon()}. */
2250:   private static Icon treeComputerIcon;
2251:   
2252:   /** The icon instance returned by {@link #getTreeFloppyDriveIcon()}. */
2253:   private static Icon treeFloppyDriveIcon;
2254:   
2255:   /** The icon instance returned by {@link #getTreeHardDriveIcon()}. */
2256:   private static Icon treeHardDriveIcon;
2257:   
2258:   /**
2259:    * Creates a new instance.  All the methods are static, so creating an 
2260:    * instance isn't necessary.
2261:    */
2262:   public MetalIconFactory() 
2263:   {
2264:     // Nothing to do here.
2265:   }
2266: 
2267:   /**
2268:    * Returns an icon for use when rendering the {@link JCheckBox} component.
2269:    * 
2270:    * @return A check box icon.
2271:    * 
2272:    * @since 1.3
2273:    */
2274:   public static Icon getCheckBoxIcon() 
2275:   {
2276:     if (checkBoxIcon == null)
2277:       checkBoxIcon = new MetalCheckBoxIcon();
2278:     return checkBoxIcon;
2279:   }
2280:   
2281:   /**
2282:    * Returns an icon for use when rendering the {@link JCheckBoxMenuItem} 
2283:    * component.
2284:    * 
2285:    * @return An icon.
2286:    */
2287:   public static Icon getCheckBoxMenuItemIcon() 
2288:   {
2289:     if (checkBoxMenuItemIcon == null)
2290:       checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
2291:     return checkBoxMenuItemIcon;
2292:   }
2293: 
2294:   /**
2295:    * Returns an icon for use by the {@link JFileChooser} component.
2296:    * 
2297:    * @return An icon.
2298:    */
2299:   public static Icon getFileChooserDetailViewIcon() 
2300:   {
2301:     if (fileChooserDetailViewIcon == null)
2302:       fileChooserDetailViewIcon = new FileChooserDetailViewIcon();
2303:     return fileChooserDetailViewIcon;
2304:   }
2305:     
2306:   /**
2307:    * Returns an icon for use by the {@link JFileChooser} component.
2308:    * 
2309:    * @return An icon.
2310:    */
2311:   public static Icon getFileChooserHomeFolderIcon() 
2312:   {
2313:     if (fileChooserHomeFolderIcon == null)
2314:       fileChooserHomeFolderIcon = new FileChooserHomeFolderIcon();
2315:     return fileChooserHomeFolderIcon;        
2316:   }
2317:     
2318:   /**
2319:    * Returns an icon for use by the {@link JFileChooser} component.
2320:    * 
2321:    * @return An icon.
2322:    */
2323:   public static Icon getFileChooserListViewIcon() 
2324:   {
2325:     if (fileChooserListViewIcon == null)
2326:       fileChooserListViewIcon = new FileChooserListViewIcon();
2327:     return fileChooserListViewIcon;
2328:   }
2329:     
2330:   /**
2331:    * Returns an icon for use by the {@link JFileChooser} component.
2332:    * 
2333:    * @return An icon.
2334:    */
2335:   public static Icon getFileChooserNewFolderIcon() 
2336:   {
2337:     if (fileChooserNewFolderIcon == null)
2338:       fileChooserNewFolderIcon = new FileChooserNewFolderIcon();
2339:     return fileChooserNewFolderIcon;
2340:   }
2341:     
2342:   /**
2343:    * Returns an icon for use by the {@link JFileChooser} component.
2344:    * 
2345:    * @return An icon.
2346:    */
2347:   public static Icon getFileChooserUpFolderIcon() 
2348:   {
2349:     if (fileChooserUpFolderIcon == null)
2350:       fileChooserUpFolderIcon = new FileChooserUpFolderIcon();
2351:     return fileChooserUpFolderIcon;
2352:   }
2353: 
2354:   /**
2355:    * Returns an icon for RadioButtons in the Metal L&amp;F.
2356:    *
2357:    * @return an icon for RadioButtons in the Metal L&amp;F
2358:    */
2359:   public static Icon getRadioButtonIcon()
2360:   {
2361:     if (radioButtonIcon == null)
2362:       radioButtonIcon = new RadioButtonIcon();
2363:     return radioButtonIcon;
2364:   }
2365: 
2366:   /**
2367:    * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
2368:    * 
2369:    * @return A new icon instance.
2370:    */
2371:   public static Icon getRadioButtonMenuItemIcon() 
2372:   {
2373:     if (radioButtonMenuItemIcon == null)
2374:       radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
2375:     return radioButtonMenuItemIcon;
2376:   }
2377: 
2378:   /**
2379:    * Returns the icon used to display the thumb for a horizontally oriented
2380:    * {@link JSlider}.
2381:    * 
2382:    * @return The icon.
2383:    */
2384:   public static Icon getHorizontalSliderThumbIcon() 
2385:   {
2386:     return new HorizontalSliderThumbIcon();
2387:   }
2388:     
2389:   /**
2390:    * Creates a new icon used to represent the 'close' button in the title
2391:    * pane of a {@link JInternalFrame}.
2392:    * 
2393:    * @param size  the icon size.
2394:    * 
2395:    * @return A close icon.
2396:    */
2397:   public static Icon getInternalFrameCloseIcon(int size) 
2398:   {
2399:     return new InternalFrameCloseIcon(size);
2400:   }
2401: 
2402:   /**
2403:    * Creates a new icon for the menu in a {@link JInternalFrame}.  This is the
2404:    * icon displayed at the top left of the frame.
2405:    * 
2406:    * @return A menu icon.
2407:    */
2408:   public static Icon getInternalFrameDefaultMenuIcon() 
2409:   {
2410:     if (internalFrameDefaultMenuIcon == null)
2411:       internalFrameDefaultMenuIcon = new InternalFrameDefaultMenuIcon();
2412:     return internalFrameDefaultMenuIcon;
2413:   }
2414:   
2415:   /**
2416:    * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
2417:    * 
2418:    * @param size  the icon size in pixels.
2419:    * 
2420:    * @return The icon.
2421:    * 
2422:    * @see #getInternalFrameAltMaximizeIcon(int)
2423:    */
2424:   public static Icon getInternalFrameMaximizeIcon(int size) 
2425:   {
2426:     return new InternalFrameMaximizeIcon();
2427:   }
2428:     
2429:   /**
2430:    * Returns the icon used for the minimize button in the frame title for a
2431:    * {@link JInternalFrame}.
2432:    * 
2433:    * @param size  the icon size in pixels (ignored by this implementation).
2434:    * 
2435:    * @return The icon.
2436:    */
2437:   public static Icon getInternalFrameMinimizeIcon(int size) 
2438:   {
2439:     return new InternalFrameMinimizeIcon();
2440:   }
2441: 
2442:   /**
2443:    * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
2444:    * that has been maximised.
2445:    * 
2446:    * @param size  the icon size in pixels.
2447:    * 
2448:    * @return The icon.
2449:    * 
2450:    * @see #getInternalFrameMaximizeIcon(int)
2451:    */
2452:   public static Icon getInternalFrameAltMaximizeIcon(int size) 
2453:   {
2454:     return new InternalFrameAltMaximizeIcon(size);
2455:   }
2456:   
2457:   /**
2458:    * Returns the icon used to display the thumb for a vertically oriented
2459:    * {@link JSlider}.
2460:    * 
2461:    * @return The icon.
2462:    */
2463:   public static Icon getVerticalSliderThumbIcon() 
2464:   {
2465:     return new VerticalSliderThumbIcon();
2466:   }
2467:     
2468:   /**
2469:    * Creates and returns a new tree folder icon.
2470:    * 
2471:    * @return A new tree folder icon.
2472:    */  
2473:   public static Icon getTreeFolderIcon() 
2474:   {
2475:     return new TreeFolderIcon();
2476:   }
2477:     
2478:   /**
2479:    * Creates and returns a new tree leaf icon.
2480:    * 
2481:    * @return A new tree leaf icon.
2482:    */
2483:   public static Icon getTreeLeafIcon() 
2484:   {
2485:     return new TreeLeafIcon();
2486:   }
2487:   
2488:   /**
2489:    * Creates and returns a tree control icon.
2490:    * 
2491:    * @param isCollapsed  a flag that controls whether the icon is in the 
2492:    *                     collapsed or expanded state.
2493:    * 
2494:    * @return A tree control icon.
2495:    */
2496:   public static Icon getTreeControlIcon(boolean isCollapsed) 
2497:   {
2498:     return new TreeControlIcon(isCollapsed);
2499:   }
2500: 
2501:   /**
2502:    * Returns a <code>16x16</code> icon representing a computer.
2503:    * 
2504:    * @return The icon.
2505:    */
2506:   public static Icon getTreeComputerIcon() 
2507:   {
2508:     if (treeComputerIcon == null)
2509:       treeComputerIcon = new TreeComputerIcon();
2510:     return treeComputerIcon;        
2511:   }
2512:     
2513:   /**
2514:    * Returns a <code>16x16</code> icon representing a floppy disk.
2515:    * 
2516:    * @return The icon.
2517:    */
2518:   public static Icon getTreeFloppyDriveIcon() 
2519:   {
2520:     if (treeFloppyDriveIcon == null)
2521:       treeFloppyDriveIcon = new TreeFloppyDriveIcon();
2522:     return treeFloppyDriveIcon;
2523:   }
2524:     
2525:   /**
2526:    * Returns a <code>16x16</code> icon representing a hard disk.
2527:    * 
2528:    * @return The icon.
2529:    */
2530:   public static Icon getTreeHardDriveIcon() 
2531:   {
2532:     if (treeHardDriveIcon == null)
2533:       treeHardDriveIcon = new TreeHardDriveIcon();
2534:     return treeHardDriveIcon;
2535:   }
2536: 
2537:   /**
2538:    * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2539:    * points to the right.  This is displayed in menu items that have a 
2540:    * sub menu.
2541:    * 
2542:    * @return The icon.
2543:    */
2544:   public static Icon getMenuArrowIcon()
2545:   {
2546:     if (menuArrow == null)
2547:       menuArrow = new Icon()
2548:       {
2549:         public int getIconHeight()
2550:         {
2551:           return 8;
2552:         }
2553: 
2554:         public int getIconWidth()
2555:         {
2556:           return 4;
2557:         }
2558: 
2559:         public void paintIcon(Component c, Graphics g, int x, int y)
2560:         {
2561:           Color saved = g.getColor();
2562:           g.setColor(Color.BLACK);
2563:           for (int i = 0; i < 4; i++)
2564:             g.drawLine(x + i, y + i, x + i, y + 7 - i);
2565:           g.setColor(saved);
2566:         }
2567:       };
2568:     return menuArrow;
2569:   }
2570:   
2571:   /**
2572:    * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2573:    * points to the right. This is displayed in menu items that have a sub menu.
2574:    * 
2575:    * @return The icon.
2576:    */
2577:   public static Icon getMenuItemArrowIcon()
2578:   {
2579:     if (menuItemArrow == null)
2580:       menuItemArrow = new Icon()
2581:       {
2582:         public int getIconHeight()
2583:         {
2584:           return 8;
2585:         }
2586: 
2587:         public int getIconWidth()
2588:         {
2589:           return 4;
2590:         }
2591: 
2592:         public void paintIcon(Component c, Graphics g, int x, int y)
2593:         {
2594:           Color saved = g.getColor();
2595:           g.setColor(Color.BLACK);
2596:           for (int i = 0; i < 4; i++)
2597:             g.drawLine(x + i, y + i, x + i, y + 7 - i);
2598:           g.setColor(saved);
2599:         }
2600:       };
2601:     return menuItemArrow;
2602:   }
2603:   
2604:   /**
2605:    * Returns a new instance of a 13 x 13 icon showing a small black check mark.
2606:    * 
2607:    * @return The icon.
2608:    */
2609:   public static Icon getMenuItemCheckIcon()
2610:   {
2611:     return new Icon()
2612:     {
2613:       public int getIconHeight()
2614:       {
2615:         return 13;
2616:       }
2617: 
2618:       public int getIconWidth()
2619:       {
2620:         return 13;
2621:       }
2622: 
2623:       public void paintIcon(Component c, Graphics g, int x, int y)
2624:       {
2625:         Color saved = g.getColor();
2626:         g.setColor(Color.BLACK);
2627:         g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
2628:         g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
2629:         g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
2630:         g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
2631:         g.setColor(saved);
2632:       }
2633:     };
2634:   }
2635: }