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.Icon;
  47: import javax.swing.JCheckBox;
  48: import javax.swing.JCheckBoxMenuItem;
  49: import javax.swing.JInternalFrame;
  50: import javax.swing.JRadioButton;
  51: import javax.swing.JRadioButtonMenuItem;
  52: import javax.swing.JSlider;
  53: import javax.swing.plaf.UIResource;
  54: 
  55: 
  56: /**
  57:  * Creates icons for the {@link MetalLookAndFeel}.
  58:  */
  59: public class MetalIconFactory implements Serializable 
  60: {
  61: 
  62:   /** A constant representing "dark". */
  63:   public static final boolean DARK = false;
  64:     
  65:   /** A constant representing "light". */
  66:   public static final boolean LIGHT = true;
  67:     
  68:   /**
  69:    * An icon displayed for {@link JCheckBoxMenuItem} components.
  70:    */
  71:   private static class CheckBoxMenuItemIcon implements Icon, Serializable 
  72:   {
  73:     /**
  74:      * Creates a new icon instance.
  75:      */
  76:     public CheckBoxMenuItemIcon() 
  77:     {
  78:     }
  79:       
  80:     /**
  81:      * Returns the width of the icon, in pixels.
  82:      * 
  83:      * @return The width of the icon (10 pixels).
  84:      */
  85:     public int getIconWidth() 
  86:     {
  87:       return 10;
  88:     }
  89:     
  90:     /**
  91:      * Returns the height of the icon, in pixels.
  92:      * 
  93:      * @return The height of the icon (10 pixels).
  94:      */
  95:     public int getIconHeight() 
  96:     {
  97:       return 10;
  98:     }
  99:     
 100:     /**
 101:      * Paints the icon.
 102:      * 
 103:      * @param c  the component.
 104:      * @param g  the graphics device.
 105:      * @param x  the x-coordinate.
 106:      * @param y  the y-coordinate.
 107:      */
 108:     public void paintIcon(Component c, Graphics g, int x, int y) 
 109:     {
 110:       JCheckBoxMenuItem item = (JCheckBoxMenuItem) c;
 111:         
 112:       if (item.isArmed())
 113:         g.setColor(MetalLookAndFeel.getBlack());
 114:       else
 115:         g.setColor(MetalLookAndFeel.getControlDarkShadow());
 116:       g.drawLine(x, y, x + 8, y);
 117:       g.drawLine(x, y + 1, x, y + 8);
 118:       g.drawLine(x + 2, y + 8, x + 8, y + 8);
 119:       g.drawLine(x + 8, y + 2, x + 8, y + 7);
 120:       
 121:       g.setColor(MetalLookAndFeel.getWhite());
 122:       g.drawLine(x + 1, y + 1, x + 7, y + 1);
 123:       g.drawLine(x + 1, y + 2, x + 1, y + 7);
 124:       g.drawLine(x + 1, y + 9, x + 9, y + 9);
 125:       g.drawLine(x + 9, y + 1, x + 9, y + 8);
 126: 
 127:       // if the item is selected, we should draw a tick
 128:       if (item.isSelected())
 129:       {
 130:         g.setColor(MetalLookAndFeel.getBlack());
 131:         g.fillRect(x + 2, y + 2, 2, 5);
 132:         for (int i = 0; i < 6; i++)
 133:           g.drawLine(x + 8 - i, y + i, x + 9 - i, y + i);
 134:       }
 135: 
 136:     }        
 137:   }
 138: 
 139:   /**
 140:    * An icon representing a file (drawn as a piece of paper with the top-right
 141:    * corner turned down).
 142:    */
 143:   public static class FileIcon16 implements Icon, Serializable 
 144:   {
 145:     /**
 146:      * Returns the width of the icon, in pixels.
 147:      * 
 148:      * @return The width of the icon.
 149:      */
 150:     public int getIconWidth() 
 151:     {
 152:       return 16;
 153:     }
 154: 
 155:     /**
 156:      * Returns the height of the icon, in pixels.
 157:      * 
 158:      * @return The height of the icon.
 159:      */
 160:     public int getIconHeight() 
 161:     {
 162:       return 16;
 163:     }
 164:     
 165:     /**
 166:      * Paints the icon at the location (x, y).
 167:      * 
 168:      * @param c  the component.
 169:      * @param g  the graphics context.
 170:      * @param x  the x coordinate.
 171:      * @param y  the y coordinate.
 172:      */
 173:     public void paintIcon(Component c, Graphics g, int x, int y) 
 174:     {
 175:       // TODO: pick up appropriate UI colors
 176:       g.setColor(Color.black);
 177:       g.drawLine(x, y, x + 9, y);            
 178:       g.drawLine(x, y + 1, x, y + 15);            
 179:       g.drawLine(x, y + 15, x + 12, y + 15);            
 180:       g.drawLine(x + 12, y + 15, x + 12, y + 6);            
 181:       g.drawLine(x + 12, y + 6, x + 9, y);           
 182: 
 183:       g.drawLine(x + 7, y + 2, x + 11, y + 6);
 184:       g.drawLine(x + 8, y + 1, x + 9, y + 1);
 185: 
 186:       g.setColor(new Color(204, 204, 255));
 187:       g.drawLine(x + 1, y + 1, x + 7, y + 1);            
 188:       g.drawLine(x + 1, y + 1, x + 1, y + 14);            
 189:       g.drawLine(x + 1, y + 14, x + 11, y + 14);            
 190:       g.drawLine(x + 11, y + 14, x + 11, y + 7);            
 191:       g.drawLine(x + 8, y + 2, x + 10, y + 4);
 192:     }
 193:     
 194:     /**
 195:      * Returns the additional height (???).
 196:      * 
 197:      * @return The additional height.
 198:      */
 199:     public int getAdditionalHeight() 
 200:     {
 201:       return 0;
 202:     }
 203:         
 204:     /**
 205:      * Returns the shift (???).
 206:      * 
 207:      * @return The shift.
 208:      */
 209:     public int getShift() 
 210:     {
 211:       return 0;
 212:     }
 213:         
 214:   }
 215:     
 216:   /**
 217:    * An icon representing a folder.
 218:    */
 219:   public static class FolderIcon16 implements Icon, Serializable 
 220:   {
 221:     /**
 222:      * Returns the width of the icon, in pixels.
 223:      * 
 224:      * @return The width of the icon.
 225:      */
 226:     public int getIconWidth() {
 227:       return 16;
 228:     }
 229:     
 230:     /**
 231:      * Returns the height of the icon, in pixels.
 232:      * 
 233:      * @return The height of the icon.
 234:      */
 235:     public int getIconHeight() 
 236:     {
 237:       return 16;
 238:     }
 239: 
 240:     /**
 241:      * Paints the icon at the location (x, y).
 242:      * 
 243:      * @param c  the component.
 244:      * @param g  the graphics device.
 245:      * @param x  the x coordinate.
 246:      * @param y  the y coordinate.
 247:      */
 248:     public void paintIcon(Component c, Graphics g, int x, int y) 
 249:     {
 250:       // TODO: pick up appropriate UI colors
 251:       g.setColor(Color.black);
 252:       g.drawLine(x, y + 3, x, y + 12);
 253:       g.drawLine(x, y + 12, x + 15, y + 12);
 254:       g.drawLine(x + 15, y + 12, x + 15, y + 2);
 255:       g.drawLine(x + 14, y + 3, x + 9, y + 3);
 256:       g.drawLine(x + 8, y + 2, x + 1, y + 2);
 257:       g.setColor(new Color(204, 204, 255));
 258:       g.fillRect(x + 2, y + 4, 7, 8);
 259:       g.fillRect(x + 9, y + 5, 6, 7);
 260:       g.setColor(new Color(102, 102, 153));
 261:       g.drawLine(x + 9, y + 2, x + 14, y + 2);
 262:       g.setColor(new Color(50, 50, 120));
 263:       g.drawLine(x + 9, y + 1, x + 15, y + 1);
 264:       g.drawLine(x + 10, y, x + 15, y);
 265:     }
 266:     
 267:     /**
 268:      * Returns the additional height (???).
 269:      * 
 270:      * @return The additional height.
 271:      */
 272:     public int getAdditionalHeight() 
 273:     {
 274:       return 0;
 275:     }
 276:     
 277:     /**
 278:      * Returns the shift (???).
 279:      * 
 280:      * @return The shift.
 281:      */
 282:     public int getShift() 
 283:     {
 284:       return 0;
 285:     }
 286:         
 287:   }
 288:    
 289:   /**
 290:    * An {@link Icon} implementation for {@link JCheckBox}es in the
 291:    * Metal Look &amp; Feel.
 292:    *
 293:    * @author Roman Kennke (roman@kennke.org)
 294:    */
 295:   static class RadioButtonIcon
 296:     implements Icon, UIResource, Serializable
 297:   {
 298:     /**
 299:      * Draws the check in the RadioButton.
 300:      *
 301:      * @param c the component to draw on
 302:      * @param g the Graphics context to draw with
 303:      */
 304:     protected void drawCheck(Component c, Graphics g)
 305:     {
 306:       g.setColor(MetalLookAndFeel.getBlack());
 307:       g.fillRect(4, 3, 4, 6);
 308:       g.drawLine(3, 4, 3, 7);
 309:       g.drawLine(8, 4, 8, 7);
 310:     }
 311: 
 312:     /**
 313:      * Returns the width of the icon in pixels.
 314:      *
 315:      * @return the width of the icon in pixels
 316:      */
 317:     public int getIconWidth()
 318:     {
 319:       return 13;
 320:     }
 321: 
 322:     /**
 323:      * Returns the height of the icon in pixels.
 324:      *
 325:      * @return the height of the icon in pixels
 326:      */
 327:     public int getIconHeight()
 328:     {
 329:       return 13;
 330:     }
 331: 
 332:     /**
 333:      * Paints the icon. This first paints the border of the RadioButton and
 334:      * if the CheckBox is selected it calls {@link #drawCheck} to draw
 335:      * the check.
 336:      *
 337:      * @param c the Component to draw on (gets casted to JCheckBox)
 338:      * @param g the Graphics context to draw with
 339:      * @param x the X position
 340:      * @param y the Y position
 341:      */
 342:     public void paintIcon(Component c, Graphics g, int x, int y)
 343:     {
 344:       Color dark = MetalLookAndFeel.getControlDarkShadow();
 345:       Color light = MetalLookAndFeel.getWhite();
 346:       g.translate(x, y);
 347: 
 348:       // The light 'circle'
 349:       g.setColor(light);
 350:       g.drawLine(4, 1, 10, 1);
 351:       g.drawLine(2, 2, 3, 2);
 352:       g.drawLine(8, 2, 11, 2);
 353:       g.drawLine(2, 3, 2, 3);
 354:       g.drawLine(11, 2, 11, 9);
 355:       g.drawLine(1, 4, 1, 7);
 356:       g.drawLine(12, 4, 12, 7);
 357:       g.drawLine(2, 8, 2, 11);
 358:       g.drawLine(11, 8, 11, 9);
 359:       g.drawLine(10, 10, 10, 10);
 360:       g.drawLine(2, 11, 9, 11);
 361:       g.drawLine(4, 12, 7, 12);
 362: 
 363:       // The dark 'circle'
 364:       g.setColor(dark);
 365:       g.drawLine(4, 0, 7, 0);
 366:       g.drawLine(2, 1, 3, 1);
 367:       g.drawLine(8, 1, 9, 1);
 368:       g.drawLine(1, 2, 1, 3);
 369:       g.drawLine(10, 2, 10, 3);
 370:       g.drawLine(0, 4, 0, 7);
 371:       g.drawLine(11, 4, 11, 7);
 372:       g.drawLine(1, 8, 1, 9);
 373:       g.drawLine(10, 8, 10, 9);
 374:       g.drawLine(2, 10, 3, 10);
 375:       g.drawLine(8, 10, 9, 10);
 376:       g.drawLine(4, 11, 7, 11);
 377: 
 378:       JRadioButton rb = (JRadioButton) c;
 379:       if (rb.isSelected())
 380:         drawCheck(c, g);
 381: 
 382:       g.translate(-x, -y);
 383:     }
 384:   }
 385: 
 386:   /**
 387:    * An icon displayed for {@link JRadioButtonMenuItem} components.
 388:    */
 389:   private static class RadioButtonMenuItemIcon 
 390:       implements Icon, Serializable 
 391:   {
 392:     /**
 393:      * Creates a new icon instance.
 394:      */
 395:     public RadioButtonMenuItemIcon() 
 396:     {  
 397:     }
 398: 
 399:     /**
 400:      * Returns the width of the icon, in pixels.
 401:      * 
 402:      * @return The width of the icon.
 403:      */
 404:     public int getIconWidth() 
 405:     {
 406:       return 10;
 407:     }
 408: 
 409:     /**
 410:      * Returns the height of the icon, in pixels.
 411:      * 
 412:      * @return The height of the icon.
 413:      */
 414:     public int getIconHeight()   
 415:     {
 416:       return 10;
 417:     }
 418: 
 419:     /**
 420:      * Paints the icon.
 421:      * 
 422:      * @param c  the component.
 423:      * @param g  the graphics device.
 424:      * @param x  the x-coordinate.
 425:      * @param y  the y-coordinate.
 426:      */
 427:     public void paintIcon(Component c, Graphics g, int x, int y) 
 428:     {
 429:       Color savedColor = g.getColor();
 430:       JRadioButtonMenuItem item = (JRadioButtonMenuItem) c;
 431:       g.setColor(MetalLookAndFeel.getBlack());
 432:       g.drawLine(x + 2, y, x + 6, y);
 433:       g.drawLine(x + 7, y + 1, x + 7, y + 1);
 434:       g.drawLine(x + 8, y + 2, x + 8, y + 6);
 435:       g.drawLine(x + 7, y + 7, x + 7, y + 7);
 436:       g.drawLine(x + 2, y + 8, x + 6, y + 8);
 437:       g.drawLine(x + 1, y + 7, x + 1, y + 7);
 438:       g.drawLine(x, y + 2, x, y + 6);
 439:       g.drawLine(x + 1, y + 1, x + 1, y + 1);
 440:       
 441:       if (item.isSelected())
 442:         {
 443:           g.drawLine(x + 3, y + 2, x + 5, y + 2);
 444:           g.fillRect(x + 2, y + 3, 5, 3);
 445:           g.drawLine(x + 3, y + 6, x + 5, y + 6);
 446:         }
 447: 
 448:       // highlight
 449:       g.setColor(MetalLookAndFeel.getControlHighlight());
 450:       g.drawLine(x + 3, y + 1, x + 6, y + 1);
 451:       g.drawLine(x + 8, y + 1, x + 8, y + 1);
 452:       g.drawLine(x + 9, y + 2, x + 9, y + 7);
 453:       g.drawLine(x + 8, y + 8, x + 8, y + 8);
 454:       g.drawLine(x + 2, y + 9, x + 7, y + 9);
 455:       g.drawLine(x + 1, y + 8, x + 1, y + 8);
 456:       g.drawLine(x + 1, y + 3, x + 1, y + 6);
 457:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
 458:       g.setColor(savedColor);
 459:     }        
 460:   }
 461: 
 462:   /**
 463:    * The icon used to display the thumb control on a horizontally oriented
 464:    * {@link JSlider} component.
 465:    */
 466:   private static class HorizontalSliderThumbIcon 
 467:       implements Icon, Serializable 
 468:   {
 469: 
 470:     /**
 471:      * Creates a new instance.
 472:      */
 473:     public HorizontalSliderThumbIcon() 
 474:     {
 475:     }
 476:     
 477:     /**
 478:      * Returns the width of the icon, in pixels.
 479:      * 
 480:      * @return The width of the icon.
 481:      */
 482:     public int getIconWidth() 
 483:     {
 484:       return 15;
 485:     }
 486:     
 487:     /**
 488:      * Returns the height of the icon, in pixels.
 489:      * 
 490:      * @return The height of the icon.
 491:      */
 492:     public int getIconHeight() 
 493:     {
 494:       return 16;
 495:     }
 496:     
 497:     /**
 498:      * Paints the icon, taking into account whether or not the component has 
 499:      * the focus.
 500:      * 
 501:      * @param c  the component.
 502:      * @param g  the graphics device.
 503:      * @param x  the x-coordinate.
 504:      * @param y  the y-coordinate.
 505:      */
 506:     public void paintIcon(Component c, Graphics g, int x, int y) 
 507:     {
 508:       boolean focus = false;
 509:       if (c != null) 
 510:         focus = c.hasFocus();    
 511:       // TODO: pick up the colors from the look and feel
 512:       
 513:       // draw the outline
 514:       g.setColor(Color.black);
 515:       g.drawLine(x + 1, y, x + 13, y);
 516:       g.drawLine(x + 14, y + 1, x + 14, y + 7);
 517:       g.drawLine(x + 14, y + 8, x + 7, y + 15);
 518:       g.drawLine(x + 6, y + 14, x, y + 8);
 519:       g.drawLine(x, y + 7, x, y + 1);
 520:       
 521:       // fill the icon
 522:       g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204));  // medium
 523:       g.fillRect(x + 2, y + 2, 12, 7);
 524:       g.drawLine(x + 2, y + 9, x + 12, y + 9);
 525:       g.drawLine(x + 3, y + 10, x + 11, y + 10);
 526:       g.drawLine(x + 4, y + 11, x + 10, y + 11);
 527:       g.drawLine(x + 5, y + 12, x + 9, y + 12);
 528:       g.drawLine(x + 6, y + 13, x + 8, y + 13);
 529:       g.drawLine(x + 7, y + 14, x + 7, y + 14);
 530:       
 531:       // draw highlights
 532:       g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));  // light
 533:       g.drawLine(x + 1, y + 1, x + 13, y + 1);
 534:       g.drawLine(x + 1, y + 2, x + 1, y + 8);
 535:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
 536:       g.drawLine(x + 6, y + 2, x + 6, y + 2);
 537:       g.drawLine(x + 10, y + 2, x + 10, y + 2);
 538: 
 539:       g.drawLine(x + 4, y + 4, x + 4, y + 4);
 540:       g.drawLine(x + 8, y + 4, x + 8, y + 4);
 541: 
 542:       g.drawLine(x + 2, y + 6, x + 2, y + 6);
 543:       g.drawLine(x + 6, y + 6, x + 6, y + 6);
 544:       g.drawLine(x + 10, y + 6, x + 10, y + 6);
 545: 
 546:       // draw dots
 547:       g.setColor(focus ? new Color(102, 102, 153) : Color.black);                 // dark
 548:       g.drawLine(x + 3, y + 3, x + 3, y + 3);
 549:       g.drawLine(x + 7, y + 3, x + 7, y + 3);
 550:       g.drawLine(x + 11, y + 3, x + 11, y + 3);
 551: 
 552:       g.drawLine(x + 5, y + 5, x + 5, y + 5);
 553:       g.drawLine(x + 9, y + 5, x + 9, y + 5);
 554: 
 555:       g.drawLine(x + 3, y + 7, x + 3, y + 7);
 556:       g.drawLine(x + 7, y + 7, x + 7, y + 7);
 557:       g.drawLine(x + 11, y + 7, x + 11, y + 7);
 558: 
 559:     }        
 560:   }
 561:   
 562:   /**
 563:    * An icon used for the 'close' button in the title frame of a 
 564:    * {@link JInternalFrame}.
 565:    */
 566:   private static class InternalFrameCloseIcon implements Icon, Serializable 
 567:   {
 568:     /** The icon size in pixels. */
 569:     private int size;
 570:     
 571:     /**
 572:      * Creates a new icon.
 573:      * 
 574:      * @param size  the icon size (width and height) in pixels.
 575:      */
 576:     public InternalFrameCloseIcon(int size) 
 577:     {
 578:       this.size = size;
 579:     }
 580:     
 581:     /**
 582:      * Returns the width of the icon, in pixels.
 583:      * 
 584:      * @return The width of the icon.
 585:      */
 586:     public int getIconWidth() 
 587:     {
 588:       return size;
 589:     }
 590:     
 591:     /**
 592:      * Returns the height of the icon, in pixels.
 593:      * 
 594:      * @return The height of the icon.
 595:      */
 596:     public int getIconHeight() 
 597:     {
 598:       return size;
 599:     }
 600:     
 601:     /**
 602:      * Paints the icon.
 603:      * 
 604:      * @param c  the component.
 605:      * @param g  the graphics device.
 606:      * @param x  the x-coordinate.
 607:      * @param y  the y-coordinate.
 608:      */
 609:     public void paintIcon(Component c, Graphics g, int x, int y) 
 610:     {
 611:       // draw the gray areas first
 612:       g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
 613:       g.drawLine(x + 1, y + 1, x + 13, y + 1);
 614:       g.drawLine(x + 1, y + 2, x + 1, y + 12);
 615:       g.drawLine(x + 1, y + 13, x + 13, y + 13);
 616:       g.drawLine(x + 13, y + 2, x + 13, y + 12);
 617:       
 618:       g.fillRect(x + 4, y + 4, 2, 2);
 619:       g.fillRect(x + 4, y + 9, 2, 2);
 620:       g.fillRect(x + 9, y + 4, 2, 2);
 621:       g.fillRect(x + 9, y + 9, 2, 2);
 622:       g.fillRect(x + 5, y + 5, 5, 5);
 623:       
 624:       g.setColor(MetalLookAndFeel.getBlack());
 625:       g.drawLine(x, y, x + 13, y);
 626:       g.drawLine(x, y + 1, x, y + 13);
 627:       g.drawLine(x + 3, y + 4, x + 4, y + 3);
 628:       g.drawLine(x + 3, y + 9, x + 5, y + 7);
 629:       g.drawLine(x + 7, y + 5, x + 9, y + 3);
 630:       
 631:       g.drawLine(x + 12, y + 3, x + 12, y + 11);
 632:       g.drawLine(x + 3, y + 12, x + 12, y + 12);
 633:       
 634:       g.setColor(MetalLookAndFeel.getWhite());
 635:       g.drawLine(x + 1, y + 14, x + 14, y + 14);
 636:       g.drawLine(x + 14, y + 1, x + 14, y + 14);
 637:       
 638:       g.drawLine(x + 5, y + 10, x + 5, y + 10);
 639:       g.drawLine(x + 6, y + 9, x + 7, y + 9);
 640:       g.drawLine(x + 10, y + 5, x + 10, y + 5);
 641:       g.drawLine(x + 9, y + 6, x + 9, y + 7);
 642:       g.drawLine(x + 10, y + 10, x + 11, y + 10);
 643:       g.drawLine(x + 10, y + 11, x + 10, y + 11);
 644:     }        
 645:   }
 646: 
 647:   /**
 648:    * The icon displayed at the top-left corner of a {@link JInternalFrame}.
 649:    */
 650:   private static class InternalFrameDefaultMenuIcon 
 651:       implements Icon, Serializable 
 652:   {
 653:        
 654:     /**
 655:      * Creates a new instance.
 656:      */
 657:     public InternalFrameDefaultMenuIcon() 
 658:     {
 659:     }
 660:     
 661:     /**
 662:      * Returns the width of the icon, in pixels.
 663:      * 
 664:      * @return The width of the icon.
 665:      */
 666:     public int getIconWidth() 
 667:     {
 668:       return 16;
 669:     }
 670:     
 671:     /**
 672:      * Returns the height of the icon, in pixels.
 673:      * 
 674:      * @return The height of the icon.
 675:      */
 676:     public int getIconHeight() 
 677:     {
 678:       return 16;
 679:     }
 680:     
 681:     /**
 682:      * Paints the icon at the specified location.
 683:      * 
 684:      * @param c  the component.
 685:      * @param g  the graphics device.
 686:      * @param x  the x coordinate.
 687:      * @param y  the y coordinate.
 688:      */
 689:     public void paintIcon(Component c, Graphics g, int x, int y) 
 690:     {
 691:       g.setColor(new Color(102, 102, 153));
 692:       g.fillRect(x + 1, y, 14, 2);
 693:       g.fillRect(x, y + 1, 2, 14);
 694:       g.fillRect(x + 1, y + 14, 14, 2);
 695:       g.fillRect(x + 14, y + 1, 2, 14);
 696:       g.drawLine(x + 2, y + 5, x + 14, y + 5);
 697:       
 698:       g.setColor(new Color(204, 204, 255));
 699:       g.fillRect(x + 2, y + 2, 12, 3);
 700:       
 701:       g.setColor(new Color(102, 102, 153));
 702:       g.drawLine(x + 3, y + 3, x + 3, y + 3);
 703:       g.drawLine(x + 6, y + 3, x + 6, y + 3);
 704:       g.drawLine(x + 9, y + 3, x + 9, y + 3);
 705:       g.drawLine(x + 12, y + 3, x + 12, y + 3);
 706: 
 707:       g.setColor(Color.white);
 708:       g.fillRect(x + 2, y + 6, 12, 8);
 709:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
 710:       g.drawLine(x + 5, y + 2, x + 5, y + 2);
 711:       g.drawLine(x + 8, y + 2, x + 8, y + 2);
 712:       g.drawLine(x + 11, y + 2, x + 11, y + 2);
 713:     }        
 714:   }
 715: 
 716:   /**
 717:    * An icon used in the title frame of a {@link JInternalFrame}.  When you 
 718:    * maximise an internal frame, this icon will replace the 'maximise' icon to
 719:    * provide a 'restore' option.
 720:    */
 721:   private static class InternalFrameAltMaximizeIcon 
 722:       implements Icon, Serializable 
 723:   {
 724:     /** The icon size in pixels. */
 725:     private int size;
 726:     
 727:     /**
 728:      * Creates a new icon.
 729:      * 
 730:      * @param size  the icon size in pixels.
 731:      */
 732:     public InternalFrameAltMaximizeIcon(int size) 
 733:     {
 734:       this.size = size;
 735:     }
 736:     
 737:     /**
 738:      * Returns the width of the icon, in pixels.
 739:      * 
 740:      * @return The width of the icon.
 741:      */
 742:     public int getIconWidth() 
 743:     {
 744:       return size;
 745:     }
 746:     
 747:     /**
 748:      * Returns the height of the icon, in pixels.
 749:      * 
 750:      * @return The height of the icon.
 751:      */
 752:     public int getIconHeight() 
 753:     {
 754:       return size;
 755:     }
 756:     
 757:     /**
 758:      * Paints the icon at the specified location.
 759:      * 
 760:      * @param c  the component.
 761:      * @param g  the graphics device.
 762:      * @param x  the x coordinate.
 763:      * @param y  the y coordinate.
 764:      */
 765:     public void paintIcon(Component c, Graphics g, int x, int y) 
 766:     {
 767:       Color color = MetalLookAndFeel.getControlDarkShadow();
 768:       if (c instanceof JInternalFrame)
 769:         {
 770:           JInternalFrame f = (JInternalFrame) c;
 771:           if (f.isSelected())
 772:             color = MetalLookAndFeel.getPrimaryControlShadow();
 773:         }
 774:       g.setColor(color);
 775:       g.drawLine(x + 12, y + 1, x + 13, y + 1);
 776:       g.drawLine(x + 11, y + 2, x + 12, y + 2);
 777:       g.drawLine(x + 10, y + 3, x + 11, y + 3);
 778:       g.drawLine(x + 8, y + 2, x + 8, y + 3);
 779:       g.fillRect(x + 8, y + 4, 3, 3);
 780:       g.drawLine(x + 11, y + 6, x + 12, y + 6);
 781:       
 782:       g.drawLine(x + 1, y + 5, x + 5, y + 5);
 783:       g.drawLine(x + 1, y + 6, x + 1, y + 12);
 784:       g.drawLine(x + 9, y + 9, x + 9, y + 12);
 785:       g.drawLine(x + 1, y + 13, x + 9, y + 13);
 786:       
 787:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
 788:       
 789:       g.setColor(MetalLookAndFeel.getBlack());
 790:       g.drawLine(x + 12, y, x + 9, y + 3);
 791:       g.drawLine(x + 7, y + 1, x + 8, y + 1);
 792:       g.drawLine(x + 7, y + 2, x + 7, y + 6);
 793:       g.drawLine(x + 11, y + 5, x + 12, y + 5);
 794:       g.drawLine(x, y + 4, x + 5, y + 4);
 795:       g.drawLine(x, y + 5, x, y + 13);
 796:       g.drawLine(x + 3, y + 12, x + 8, y + 12);
 797:       g.drawLine(x + 8, y + 8, x + 8, y + 11);
 798:       g.drawLine(x + 9, y + 8, x + 9, y + 8);
 799:       
 800:       g.setColor(MetalLookAndFeel.getWhite());
 801:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
 802:       g.drawLine(x + 11, y + 4, x + 13, y + 2);
 803:       g.drawLine(x + 13, y + 6, x + 13, y + 6);
 804:       g.drawLine(x + 8, y + 7, x + 13, y + 7);
 805:       g.drawLine(x + 6, y + 5, x + 6, y + 5);
 806:       g.drawLine(x + 2, y + 6, x + 6, y + 6);
 807:       g.drawLine(x + 2, y + 6, x + 2, y + 11);
 808:       g.drawLine(x + 10, y + 8, x + 10, y + 13);
 809:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
 810:     }        
 811:   }
 812:   
 813:   /**
 814:    * An icon used for the 'maximize' button in the title frame of a 
 815:    * {@link JInternalFrame}.
 816:    */
 817:   private static class InternalFrameMaximizeIcon 
 818:       implements Icon, Serializable 
 819:   {
 820:     
 821:     /**
 822:      * Creates a new instance.
 823:      */
 824:     public InternalFrameMaximizeIcon() 
 825:     {
 826:     }
 827:     
 828:     /**
 829:      * Returns the width of the icon, in pixels.
 830:      * 
 831:      * @return The width of the icon.
 832:      */
 833:     public int getIconWidth() 
 834:     {
 835:       return 16;
 836:     }
 837:     
 838:     /**
 839:      * Returns the height of the icon, in pixels.
 840:      * 
 841:      * @return The height of the icon.
 842:      */
 843:     public int getIconHeight() 
 844:     {
 845:       return 16;
 846:     }
 847:     
 848:     /**
 849:      * Paints the icon at the specified location.
 850:      * 
 851:      * @param c  the component.
 852:      * @param g  the graphics device.
 853:      * @param x  the x coordinate.
 854:      * @param y  the y coordinate.
 855:      */
 856:     public void paintIcon(Component c, Graphics g, int x, int y) 
 857:     {
 858:       Color color = MetalLookAndFeel.getControlDarkShadow();
 859:       if (c instanceof JInternalFrame)
 860:         {
 861:           JInternalFrame f = (JInternalFrame) c;
 862:           if (f.isSelected())
 863:             color = MetalLookAndFeel.getPrimaryControlShadow();
 864:         }
 865:       g.setColor(color);
 866:       g.drawLine(x + 9, y + 1, x + 10, y + 1);
 867:       g.fillRect(x + 11, y + 1, 3, 3);
 868:       g.fillRect(x + 12, y + 4, 2, 2);
 869:       g.drawLine(x + 10, y + 3, x + 10, y + 3);
 870:       g.drawLine(x + 9, y + 4, x + 10, y + 4);
 871:       g.drawLine(x + 1, y + 5, x + 9, y + 5);
 872:       g.drawLine(x + 1, y + 6, x + 1, y + 12);
 873:       g.drawLine(x + 9, y + 6, x + 9, y + 12);
 874:       g.drawLine(x + 1, y + 13, x + 9, y + 13);
 875:       
 876:       // fill
 877:       g.drawLine(x + 7, y + 6, x + 8, y + 6);
 878:       g.drawLine(x + 6, y + 7, x + 8, y + 7);
 879:       g.drawLine(x + 5, y + 8, x + 6, y + 8);
 880:       g.drawLine(x + 4, y + 9, x + 5, y + 9);
 881:       g.drawLine(x + 3, y + 10, x + 4, y + 10);
 882:       g.drawLine(x + 2, y + 11, x + 3, y + 11);
 883:       g.drawLine(x + 2, y + 12, x + 4, y + 12);
 884:       g.drawLine(x + 8, y + 8, x + 8, y + 8);
 885:       
 886:       // draw black
 887:       g.setColor(MetalLookAndFeel.getBlack());
 888:       g.drawLine(x + 8, y, x + 13, y);
 889:       g.drawLine(x + 8, y + 1, x + 8, y + 1);
 890:       g.drawLine(x + 10, y + 2, x + 9, y + 3);
 891:       g.drawLine(x, y + 4, x + 8, y + 4);
 892:       g.drawLine(x, y + 5, x, y + 13);
 893:       
 894:       g.drawLine(x + 2, y + 10, x + 6, y + 6);
 895:       g.drawLine(x + 8, y + 9, x + 8, y + 11);
 896:       g.drawLine(x + 5, y + 12, x + 8, y + 12);
 897:       
 898:       // draw white
 899:       g.setColor(MetalLookAndFeel.getWhite());
 900:       g.drawLine(x + 2, y + 6, x + 5, y + 6);
 901:       g.drawLine(x + 2, y + 7, x + 2, y + 9);
 902:       g.drawLine(x + 4, y + 11, x + 7, y + 8);
 903:       
 904:       g.drawLine(x + 1, y + 14, x + 10, y + 14);
 905:       g.drawLine(x + 10, y + 5, x + 10, y + 13);
 906:       
 907:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
 908:       g.drawLine(x + 11, y + 4, x + 11, y + 5);
 909:       g.drawLine(x + 13, y + 6, x + 14, y + 6);
 910:       g.drawLine(x + 14, y + 1, x + 14, y + 5);
 911:     }        
 912:   }
 913: 
 914:   /**
 915:    * An icon used in the title frame of a {@link JInternalFrame}.
 916:    */
 917:   private static class InternalFrameMinimizeIcon 
 918:       implements Icon, Serializable 
 919:   {
 920:   
 921:     /**
 922:      * Creates a new instance.
 923:      */
 924:     public InternalFrameMinimizeIcon() 
 925:     {
 926:     }
 927:     
 928:     /**
 929:      * Returns the width of the icon, in pixels.
 930:      * 
 931:      * @return The width of the icon.
 932:      */
 933:     public int getIconWidth() 
 934:     {
 935:       return 16;
 936:     }
 937:     
 938:     /**
 939:      * Returns the height of the icon, in pixels.
 940:      * 
 941:      * @return The height of the icon.
 942:      */
 943:     public int getIconHeight() 
 944:     {
 945:       return 16;
 946:     }
 947:     
 948:     /**
 949:      * Paints the icon at the specified location.
 950:      * 
 951:      * @param c  the component.
 952:      * @param g  the graphics device.
 953:      * @param x  the x coordinate.
 954:      * @param y  the y coordinate.
 955:      */
 956:     public void paintIcon(Component c, Graphics g, int x, int y) 
 957:     {
 958:       Color color = MetalLookAndFeel.getControlDarkShadow();
 959:       if (c instanceof JInternalFrame)
 960:         {
 961:           JInternalFrame f = (JInternalFrame) c;
 962:           if (f.isSelected())
 963:             color = MetalLookAndFeel.getPrimaryControlShadow();
 964:         }
 965:       g.setColor(color);
 966:       g.drawLine(x + 12, y + 1, x + 13, y + 1);
 967:       g.drawLine(x + 11, y + 2, x + 12, y + 2);
 968:       g.drawLine(x + 10, y + 3, x + 11, y + 3);
 969:       g.drawLine(x + 8, y + 2, x + 8, y + 3);
 970:       g.fillRect(x + 8, y + 4, 3, 3);
 971:       g.drawLine(x + 11, y + 6, x + 12, y + 6);
 972:       
 973:       g.drawLine(x + 1, y + 8, x + 6, y + 8);
 974:       g.drawLine(x + 1, y + 9, x + 1, y + 12);
 975:       g.drawLine(x + 6, y + 9, x + 6, y + 12);
 976:       g.drawLine(x + 1, y + 13, x + 6, y + 13);
 977:       
 978:       g.drawLine(x + 5, y + 9, x + 5, y + 9);
 979:       g.drawLine(x + 2, y + 12, x + 2, y + 12);
 980:       
 981:       g.setColor(MetalLookAndFeel.getBlack());
 982:       g.drawLine(x + 12, y, x + 9, y + 3);
 983:       g.drawLine(x + 7, y + 1, x + 8, y + 1);
 984:       g.drawLine(x + 7, y + 2, x + 7, y + 6);
 985:       g.drawLine(x, y + 7, x + 6, y + 7);
 986:       g.drawLine(x, y + 8, x, y + 13);
 987:       g.drawLine(x + 3, y + 12, x + 5, y + 12);
 988:       g.drawLine(x + 5, y + 10, x + 5, y + 11);
 989:       g.drawLine(x + 11, y + 5, x + 12, y + 5);
 990:       
 991:       g.setColor(MetalLookAndFeel.getWhite());
 992:       g.drawLine(x + 9, y + 2, x + 9, y + 2);
 993:       g.drawLine(x + 11, y + 4, x + 13, y + 2);
 994:       g.drawLine(x + 13, y + 6, x + 13, y + 6);
 995:       g.drawLine(x + 8, y + 7, x + 13, y + 7);
 996:       g.drawLine(x + 2, y + 9, x + 4, y + 9);
 997:       g.drawLine(x + 2, y + 10, x + 2, y + 11);
 998:       g.drawLine(x + 7, y + 9, x + 7, y + 13);
 999:       g.drawLine(x + 1, y + 14, x + 7, y + 14);
1000:     }        
1001:   }
1002: 
1003:   /**
1004:    * The icon used to display the thumb control on a horizontally oriented
1005:    * {@link JSlider} component.
1006:    */
1007:   private static class VerticalSliderThumbIcon implements Icon, Serializable 
1008:   {
1009:     /**
1010:      * Creates a new instance.
1011:      */
1012:     public VerticalSliderThumbIcon() 
1013:     {
1014:     }
1015:     
1016:     /**
1017:      * Returns the width of the icon, in pixels.
1018:      * 
1019:      * @return The width of the icon.
1020:      */
1021:     public int getIconWidth() 
1022:     {
1023:       return 16;
1024:     }
1025:     
1026:     /**
1027:      * Returns the height of the icon, in pixels.
1028:      * 
1029:      * @return The height of the icon.
1030:      */
1031:     public int getIconHeight() 
1032:     {
1033:       return 15;
1034:     }
1035:     
1036:     /**
1037:      * Paints the icon taking into account whether the slider control has the
1038:      * focus or not.
1039:      * 
1040:      * @param c  the slider (must be a non-<code>null</code> instance of
1041:      *           {@link JSlider}.
1042:      * @param g  the graphics device.
1043:      * @param x  the x-coordinate.
1044:      * @param y  the y-coordinate.
1045:      */
1046:     public void paintIcon(Component c, Graphics g, int x, int y) 
1047:     {
1048:       boolean focus = false;
1049:       if (c != null) 
1050:         focus = c.hasFocus();    
1051:       // TODO: pick up the colors from the look and feel
1052:       
1053:       // draw the outline
1054:       g.setColor(Color.black);
1055:       g.drawLine(x + 1, y, x + 7, y);
1056:       g.drawLine(x + 8, y, x + 15, y + 7);
1057:       g.drawLine(x + 14, y + 8, x + 8, y + 14);
1058:       g.drawLine(x + 8, y + 14, x + 1, y + 14);
1059:       g.drawLine(x, y + 13, x, y + 1);
1060:       
1061:       // fill the icon
1062:       g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204));  // medium
1063:       g.fillRect(x + 2, y + 2, 7, 12);
1064:       g.drawLine(x + 9, y + 2, x + 9, y + 12);
1065:       g.drawLine(x + 10, y + 3, x + 10, y + 11);
1066:       g.drawLine(x + 11, y + 4, x + 11, y + 10);
1067:       g.drawLine(x + 12, y + 5, x + 12, y + 9);
1068:       g.drawLine(x + 13, y + 6, x + 13, y + 8);
1069:       g.drawLine(x + 14, y + 7, x + 14, y + 7);
1070:       
1071:       // draw highlights
1072:       g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));  // light
1073:       g.drawLine(x + 1, y + 1, x + 8, y + 1);
1074:       g.drawLine(x + 1, y + 2, x + 1, y + 13);
1075:       g.drawLine(x + 2, y + 2, x + 2, y + 2);
1076:       g.drawLine(x + 2, y + 6, x + 2, y + 6);
1077:       g.drawLine(x + 2, y + 10, x + 2, y + 10);
1078: 
1079:       g.drawLine(x + 4, y + 4, x + 4, y + 4);
1080:       g.drawLine(x + 4, y + 8, x + 4, y + 8);
1081: 
1082:       g.drawLine(x + 6, y + 2, x + 6, y + 2);
1083:       g.drawLine(x + 6, y + 6, x + 6, y + 6);
1084:       g.drawLine(x + 6, y + 10, x + 6, y + 10);
1085: 
1086:       // draw dots
1087:       g.setColor(focus ? new Color(102, 102, 153) : Color.black);                 // dark
1088:       g.drawLine(x + 3, y + 3, x + 3, y + 3);
1089:       g.drawLine(x + 3, y + 7, x + 3, y + 7);
1090:       g.drawLine(x + 3, y + 11, x + 3, y + 11);
1091: 
1092:       g.drawLine(x + 5, y + 5, x + 5, y + 5);
1093:       g.drawLine(x + 5, y + 9, x + 5, y + 9);
1094: 
1095:       g.drawLine(x + 7, y + 3, x + 7, y + 3);
1096:       g.drawLine(x + 7, y + 7, x + 7, y + 7);
1097:       g.drawLine(x + 7, y + 11, x + 7, y + 11);
1098:     }        
1099:   }
1100:   
1101:   /**
1102:    * A tree control icon.  This icon can be in one of two states: expanded and
1103:    * collapsed.
1104:    */
1105:   public static class TreeControlIcon implements Icon, Serializable 
1106:   {
1107:     
1108:     /** ???. */
1109:     protected boolean isLight;
1110:     
1111:     /** A flag that controls whether or not the icon is collapsed. */
1112:     private boolean collapsed;
1113:     
1114:     /**
1115:      * Creates a new icon.
1116:      * 
1117:      * @param isCollapsed  a flag that controls whether the icon is in the
1118:      *                     collapsed state or the expanded state.
1119:      */
1120:     public TreeControlIcon(boolean isCollapsed) 
1121:     {
1122:       collapsed = isCollapsed;
1123:     }
1124:     
1125:     /**
1126:      * Returns the width of the icon, in pixels.
1127:      * 
1128:      * @return The width of the icon.
1129:      */
1130:     public int getIconWidth() 
1131:     {
1132:       return 18;
1133:     }
1134:     /**
1135:      * Returns the height of the icon, in pixels.
1136:      * 
1137:      * @return The height of the icon.
1138:      */
1139:     public int getIconHeight() 
1140:     {
1141:       return 18;
1142:     }
1143:     
1144:     /**
1145:      * Paints the icon at the location (x, y).
1146:      * 
1147:      * @param c  the component.
1148:      * @param g  the graphics device.
1149:      * @param x  the x coordinate.
1150:      * @param y  the y coordinate.
1151:      */
1152:     public void paintIcon(Component c, Graphics g, int x, int y) 
1153:     {
1154:       x = x + 5;
1155:       y = y + 5;
1156:       if (collapsed) 
1157:       {
1158:         // TODO: pick up appropriate UI colors
1159:         g.setColor(Color.black);
1160:         g.drawLine(x + 2, y, x + 5, y);
1161:         g.drawLine(x + 6, y + 1, x + 7, y + 2);
1162:         g.fillRect(x + 7, y + 3, 5, 2);
1163:         g.drawLine(x + 7, y + 5, x + 6, y + 6);
1164:         g.drawLine(x + 1, y + 1, x + 1, y + 1);
1165:         g.drawLine(x, y + 2, x, y + 5);
1166:         g.drawLine(x + 1, y + 6, x + 1, y + 6);
1167:         g.drawLine(x + 2, y + 7, x + 5, y + 7);
1168:         g.fillRect(x + 3, y + 3, 2, 2);
1169: 
1170:         g.setColor(new Color(204, 204, 255));
1171:         g.drawLine(x + 3, y + 2, x + 4, y + 2);
1172:         g.drawLine(x + 2, y + 3, x + 2, y + 4);
1173:         g.drawLine(x + 3, y + 5, x + 3, y + 5);
1174:         g.drawLine(x + 5, y + 3, x + 5, y + 3);
1175:         
1176:         g.setColor(new Color(153, 153, 204));
1177:         g.drawLine(x + 2, y + 2, x + 2, y + 2);
1178:         g.drawLine(x + 2, y + 5, x + 2, y + 5);
1179:         g.drawLine(x + 2, y + 6, x + 5, y + 6);
1180:         g.drawLine(x + 5, y + 2, x + 5, y + 2);
1181:         g.drawLine(x + 6, y + 2, x + 6, y + 5);
1182:         
1183:         g.setColor(new Color(102, 102, 153));
1184:         g.drawLine(x + 2, y + 1, x + 5, y + 1);
1185:         g.drawLine(x + 1, y + 2, x + 1, y + 5);
1186:       }
1187:       else
1188:       {
1189:         // TODO: pick up appropriate UI colors
1190:         g.setColor(Color.black);
1191:         g.drawLine(x + 2, y, x + 5, y);
1192:         g.drawLine(x + 6, y + 1, x + 7, y + 2);
1193:         g.drawLine(x + 7, y + 2, x + 7, y + 5);
1194:         g.fillRect(x + 3, y + 7, 2, 5);
1195:         g.drawLine(x + 7, y + 5, x + 6, y + 6);
1196:         g.drawLine(x + 1, y + 1, x + 1, y + 1);
1197:         g.drawLine(x, y + 2, x, y + 5);
1198:         g.drawLine(x + 1, y + 6, x + 1, y + 6);
1199:         g.drawLine(x + 2, y + 7, x + 5, y + 7);
1200:         g.fillRect(x + 3, y + 3, 2, 2);
1201: 
1202:         g.setColor(new Color(204, 204, 255));
1203:         g.drawLine(x + 3, y + 2, x + 4, y + 2);
1204:         g.drawLine(x + 2, y + 3, x + 2, y + 4);
1205:         g.drawLine(x + 3, y + 5, x + 3, y + 5);
1206:         g.drawLine(x + 5, y + 3, x + 5, y + 3);
1207:         
1208:         g.setColor(new Color(153, 153, 204));
1209:         g.drawLine(x + 2, y + 2, x + 2, y + 2);
1210:         g.drawLine(x + 2, y + 5, x + 2, y + 5);
1211:         g.drawLine(x + 2, y + 6, x + 5, y + 6);
1212:         g.drawLine(x + 5, y + 2, x + 5, y + 2);
1213:         g.drawLine(x + 6, y + 2, x + 6, y + 5);
1214:         
1215:         g.setColor(new Color(102, 102, 153));
1216:         g.drawLine(x + 2, y + 1, x + 5, y + 1);
1217:         g.drawLine(x + 1, y + 2, x + 1, y + 5);
1218:       }
1219:     } 
1220:     
1221:     /**
1222:      * Simply calls {@link #paintIcon(Component, Graphics, int, int)}.
1223:      * 
1224:      * @param c  the component.
1225:      * @param g  the graphics device.
1226:      * @param x  the x coordinate.
1227:      * @param y  the y coordinate.
1228:      */
1229:     public void paintMe(Component c, Graphics g, int x, int y) 
1230:     {
1231:       paintIcon(c, g, x, y);  
1232:     }
1233:   }
1234:     
1235:   /**
1236:    * A tree folder icon.
1237:    */
1238:   public static class TreeFolderIcon extends FolderIcon16 
1239:   {
1240:     /**
1241:      * Creates a new instance.
1242:      */
1243:     public TreeFolderIcon() 
1244:     {     
1245:     }
1246:     
1247:     /**
1248:      * Returns the additional height (???).
1249:      * 
1250:      * @return The additional height.
1251:      */
1252:     public int getAdditionalHeight() 
1253:     {
1254:       return 2;
1255:     }
1256:     
1257:     /**
1258:      * Returns the shift (???).
1259:      * 
1260:      * @return The shift.
1261:      */
1262:     public int getShift() 
1263:     {
1264:       return -1;
1265:     }
1266:   }
1267:     
1268:   /**
1269:    * A tree leaf icon.
1270:    */
1271:   public static class TreeLeafIcon extends FileIcon16 
1272:   {
1273:     /**
1274:      * Creates a new instance.
1275:      */
1276:     public TreeLeafIcon() 
1277:     {
1278:     }
1279:     
1280:     /**
1281:      * Returns the additional height (???).
1282:      * 
1283:      * @return The additional height.
1284:      */
1285:     public int getAdditionalHeight() 
1286:     {
1287:       return 4;
1288:     }
1289:     
1290:     /**
1291:      * Returns the shift (???).
1292:      * 
1293:      * @return The shift.
1294:      */
1295:     public int getShift() 
1296:     {
1297:       return 2;
1298:     }
1299:   }
1300:     
1301:   /** The cached RadioButtonIcon instance. */
1302:   private static RadioButtonIcon radioButtonIcon;
1303: 
1304:   /**
1305:    * Creates a new instance.  All the methods are static, so creating an 
1306:    * instance isn't necessary.
1307:    */
1308:   public MetalIconFactory() 
1309:   {   
1310:   }
1311: 
1312:   /**
1313:    * Returns an icon for use when rendering the {@link JCheckBox} component.
1314:    * 
1315:    * @return A check box icon.
1316:    * 
1317:    * @since 1.3
1318:    */
1319:   public static Icon getCheckBoxIcon() 
1320:   {
1321:     return new MetalCheckBoxIcon();
1322:   }
1323:   
1324:   /**
1325:    * Returns an icon for use when rendering the {@link JCheckBoxMenuItem} 
1326:    * component.
1327:    * 
1328:    * @return An icon.
1329:    */
1330:   public static Icon getCheckBoxMenuItemIcon() 
1331:   {
1332:     return new CheckBoxMenuItemIcon();
1333:   }
1334: 
1335:   /**
1336:    * Returns an icon for RadioButtons in the Metal L&amp;F.
1337:    *
1338:    * @return an icon for RadioButtons in the Metal L&amp;F
1339:    */
1340:   public static Icon getRadioButtonIcon()
1341:   {
1342:     if (radioButtonIcon == null)
1343:       radioButtonIcon = new RadioButtonIcon();
1344:     return radioButtonIcon;
1345:   }
1346: 
1347:   /**
1348:    * Creates a new instance of the icon used in a {@link JRadioButtonMenuItem}.
1349:    * 
1350:    * @return A new icon instance.
1351:    */
1352:   public static Icon getRadioButtonMenuItemIcon() 
1353:   {
1354:     return new RadioButtonMenuItemIcon();
1355:   }
1356: 
1357:   /**
1358:    * Returns the icon used to display the thumb for a horizontally oriented
1359:    * {@link JSlider}.
1360:    * 
1361:    * @return The icon.
1362:    */
1363:   public static Icon getHorizontalSliderThumbIcon() 
1364:   {
1365:     return new HorizontalSliderThumbIcon();
1366:   }
1367:     
1368:   /**
1369:    * Creates a new icon used to represent the 'close' button in the title
1370:    * pane of a {@link JInternalFrame}.
1371:    * 
1372:    * @param size  the icon size.
1373:    * 
1374:    * @return A close icon.
1375:    */
1376:   public static Icon getInternalFrameCloseIcon(int size) 
1377:   {
1378:     return new InternalFrameCloseIcon(size);
1379:   }
1380: 
1381:   /**
1382:    * Creates a new icon for the menu in a {@link JInternalFrame}.  This is the
1383:    * icon displayed at the top left of the frame.
1384:    * 
1385:    * @return A menu icon.
1386:    */
1387:   public static Icon getInternalFrameDefaultMenuIcon() 
1388:   {
1389:     return new InternalFrameDefaultMenuIcon();
1390:   }
1391:   
1392:   /**
1393:    * Creates a new icon for the 'maximize' button in a {@link JInternalFrame}.
1394:    * 
1395:    * @param size  the icon size in pixels.
1396:    * 
1397:    * @return The icon.
1398:    * 
1399:    * @see #getInternalFrameAltMaximizeIcon(int)
1400:    */
1401:   public static Icon getInternalFrameMaximizeIcon(int size) 
1402:   {
1403:     return new InternalFrameMaximizeIcon();
1404:   }
1405:     
1406:   /**
1407:    * Returns the icon used for the minimize button in the frame title for a
1408:    * {@link JInternalFrame}.
1409:    * 
1410:    * @param size  the icon size in pixels (ignored by this implementation).
1411:    * 
1412:    * @return The icon.
1413:    */
1414:   public static Icon getInternalFrameMinimizeIcon(int size) 
1415:   {
1416:     return new InternalFrameMinimizeIcon();
1417:   }
1418: 
1419:   /**
1420:    * Creates a new icon for the 'restore' button in a {@link JInternalFrame}
1421:    * that has been maximised.
1422:    * 
1423:    * @param size  the icon size in pixels.
1424:    * 
1425:    * @return The icon.
1426:    * 
1427:    * @see #getInternalFrameMaximizeIcon(int)
1428:    */
1429:   public static Icon getInternalFrameAltMaximizeIcon(int size) 
1430:   {
1431:     return new InternalFrameAltMaximizeIcon(size);
1432:   }
1433:   
1434:   /**
1435:    * Returns the icon used to display the thumb for a vertically oriented
1436:    * {@link JSlider}.
1437:    * 
1438:    * @return The icon.
1439:    */
1440:   public static Icon getVerticalSliderThumbIcon() 
1441:   {
1442:     return new VerticalSliderThumbIcon();
1443:   }
1444:     
1445:   /**
1446:    * Creates and returns a new tree folder icon.
1447:    * 
1448:    * @return A new tree folder icon.
1449:    */  
1450:   public static Icon getTreeFolderIcon() 
1451:   {
1452:     return new TreeFolderIcon();
1453:   }
1454:     
1455:   /**
1456:    * Creates and returns a new tree leaf icon.
1457:    * 
1458:    * @return A new tree leaf icon.
1459:    */
1460:   public static Icon getTreeLeafIcon() 
1461:   {
1462:     return new TreeLeafIcon();
1463:   }
1464:   
1465:   /**
1466:    * Creates and returns a tree control icon.
1467:    * 
1468:    * @param isCollapsed  a flag that controls whether the icon is in the 
1469:    *                     collapsed or expanded state.
1470:    * 
1471:    * @return A tree control icon.
1472:    */
1473:   public static Icon getTreeControlIcon(boolean isCollapsed) 
1474:   {
1475:     return new TreeControlIcon(isCollapsed);
1476:   }
1477: 
1478: }