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