jdk/src/share/classes/javax/swing/plaf/metal/MetalIconFactory.java
changeset 1299 027d966d5658
parent 715 f16baef3a20e
parent 1290 da8902cd496c
child 5506 202f599c92aa
equal deleted inserted replaced
915:e1e2fc296618 1299:027d966d5658
   596                 mainItemColor = darkHighlightColor;
   596                 mainItemColor = darkHighlightColor;
   597                 // darkHighlightColor is still "getBlack()"
   597                 // darkHighlightColor is still "getBlack()"
   598             }
   598             }
   599 
   599 
   600             // Some calculations that are needed more than once later on.
   600             // Some calculations that are needed more than once later on.
   601             int oneHalf = (int)(iconSize / 2); // 16 -> 8
   601             int oneHalf = iconSize / 2; // 16 -> 8
   602 
   602 
   603             g.translate(x, y);
   603             g.translate(x, y);
   604 
   604 
   605             // fill background
   605             // fill background
   606             g.setColor(backgroundColor);
   606             g.setColor(backgroundColor);
  1500      */
  1500      */
  1501     static class ImageCacher {
  1501     static class ImageCacher {
  1502 
  1502 
  1503         // PENDING: Replace this class with CachedPainter.
  1503         // PENDING: Replace this class with CachedPainter.
  1504 
  1504 
  1505         Vector images = new Vector(1, 1);
  1505         Vector<ImageGcPair> images = new Vector<ImageGcPair>(1, 1);
  1506         ImageGcPair currentImageGcPair;
  1506         ImageGcPair currentImageGcPair;
  1507 
  1507 
  1508         class ImageGcPair {
  1508         class ImageGcPair {
  1509             Image image;
  1509             Image image;
  1510             GraphicsConfiguration gc;
  1510             GraphicsConfiguration gc;
  1512                 this.image = image;
  1512                 this.image = image;
  1513                 this.gc = gc;
  1513                 this.gc = gc;
  1514             }
  1514             }
  1515 
  1515 
  1516             boolean hasSameConfiguration(GraphicsConfiguration newGC) {
  1516             boolean hasSameConfiguration(GraphicsConfiguration newGC) {
  1517                 if (((newGC != null) && (newGC.equals(gc))) ||
  1517                 return ((newGC != null) && (newGC.equals(gc))) ||
  1518                     ((newGC == null) && (gc == null)))
  1518                         ((newGC == null) && (gc == null));
  1519                 {
       
  1520                     return true;
       
  1521                 }
       
  1522                 return false;
       
  1523             }
  1519             }
  1524 
  1520 
  1525         }
  1521         }
  1526 
  1522 
  1527         Image getImage(GraphicsConfiguration newGC) {
  1523         Image getImage(GraphicsConfiguration newGC) {
  1528             if ((currentImageGcPair == null) ||
  1524             if ((currentImageGcPair == null) ||
  1529                 !(currentImageGcPair.hasSameConfiguration(newGC)))
  1525                 !(currentImageGcPair.hasSameConfiguration(newGC)))
  1530             {
  1526             {
  1531                 Enumeration elements = images.elements();
  1527                 for (ImageGcPair imgGcPair : images) {
  1532                 while (elements.hasMoreElements()) {
       
  1533                     ImageGcPair imgGcPair = (ImageGcPair)elements.nextElement();
       
  1534                     if (imgGcPair.hasSameConfiguration(newGC)) {
  1528                     if (imgGcPair.hasSameConfiguration(newGC)) {
  1535                         currentImageGcPair = imgGcPair;
  1529                         currentImageGcPair = imgGcPair;
  1536                         return imgGcPair.image;
  1530                         return imgGcPair.image;
  1537                     }
  1531                     }
  1538                 }
  1532                 }