/[classpath]/classpath/javax/swing/plaf/metal/MetalIconFactory.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/metal/MetalIconFactory.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4.2.4 by gnu_andrew, Wed Nov 2 00:44:00 2005 UTC revision 1.4.2.5 by gnu_andrew, Sun Nov 27 21:00:41 2005 UTC
# Line 52  import javax.swing.JInternalFrame; Line 52  import javax.swing.JInternalFrame;
52  import javax.swing.JRadioButton;  import javax.swing.JRadioButton;
53  import javax.swing.JRadioButtonMenuItem;  import javax.swing.JRadioButtonMenuItem;
54  import javax.swing.JSlider;  import javax.swing.JSlider;
55    import javax.swing.SwingConstants;
56    import javax.swing.UIManager;
57  import javax.swing.plaf.UIResource;  import javax.swing.plaf.UIResource;
58    
59    
# Line 66  public class MetalIconFactory implements Line 68  public class MetalIconFactory implements
68            
69    /** A constant representing "light". */    /** A constant representing "light". */
70    public static final boolean LIGHT = true;    public static final boolean LIGHT = true;
71      
72      /** A shared instance of the MenuArrowIcon. */
73      private static Icon menuArrow;
74      
75      /** A shared instance of the MenuItemArrowIcon. */
76      private static Icon menuItemArrow;
77            
78    /**    /**
79     * An icon displayed for {@link JCheckBoxMenuItem} components.     * An icon displayed for {@link JCheckBoxMenuItem} components.
# Line 779  public class MetalIconFactory implements Line 787  public class MetalIconFactory implements
787       */       */
788      public void paintIcon(Component c, Graphics g, int x, int y)      public void paintIcon(Component c, Graphics g, int x, int y)
789      {      {
790          if (UIManager.get("RadioButton.gradient") != null)
791            MetalUtils.paintGradient(g, x, y, getIconWidth(), getIconHeight(),
792                                  SwingConstants.VERTICAL, "RadioButton.gradient");
793    
794        Color savedColor = g.getColor();        Color savedColor = g.getColor();
795        JRadioButton b = (JRadioButton) c;        JRadioButton b = (JRadioButton) c;
796                
# Line 2461  public class MetalIconFactory implements Line 2473  public class MetalIconFactory implements
2473      return treeHardDriveIcon;      return treeHardDriveIcon;
2474    }    }
2475    
2476      /**
2477       * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2478       * points to the right.  This is displayed in menu items that have a
2479       * sub menu.
2480       *
2481       * @return The icon.
2482       */
2483      public static Icon getMenuArrowIcon()
2484      {
2485        if (menuArrow == null)
2486          menuArrow = new Icon()
2487          {
2488            public int getIconHeight()
2489            {
2490              return 8;
2491            }
2492    
2493            public int getIconWidth()
2494            {
2495              return 4;
2496            }
2497    
2498            public void paintIcon(Component c, Graphics g, int x, int y)
2499            {
2500              Color saved = g.getColor();
2501              g.setColor(Color.BLACK);
2502              for (int i = 0; i < 4; i++)
2503                g.drawLine(x + i, y + i, x + i, y + 7 - i);
2504              g.setColor(saved);
2505            }
2506          };
2507        return menuArrow;
2508      }
2509      
2510      /**
2511       * Returns a new instance of a 4 x 8 icon showing a small black triangle that
2512       * points to the right. This is displayed in menu items that have a sub menu.
2513       *
2514       * @return The icon.
2515       */
2516      public static Icon getMenuItemArrowIcon()
2517      {
2518        if (menuItemArrow == null)
2519          menuItemArrow = new Icon()
2520          {
2521            public int getIconHeight()
2522            {
2523              return 8;
2524            }
2525    
2526            public int getIconWidth()
2527            {
2528              return 4;
2529            }
2530    
2531            public void paintIcon(Component c, Graphics g, int x, int y)
2532            {
2533              Color saved = g.getColor();
2534              g.setColor(Color.BLACK);
2535              for (int i = 0; i < 4; i++)
2536                g.drawLine(x + i, y + i, x + i, y + 7 - i);
2537              g.setColor(saved);
2538            }
2539          };
2540        return menuItemArrow;
2541      }
2542      
2543      /**
2544       * Returns a new instance of a 13 x 13 icon showing a small black check mark.
2545       *
2546       * @return The icon.
2547       */
2548      public static Icon getMenuItemCheckIcon()
2549      {
2550        return new Icon()
2551        {
2552          public int getIconHeight()
2553          {
2554            return 13;
2555          }
2556    
2557          public int getIconWidth()
2558          {
2559            return 13;
2560          }
2561    
2562          public void paintIcon(Component c, Graphics g, int x, int y)
2563          {
2564            Color saved = g.getColor();
2565            g.setColor(Color.BLACK);
2566            g.drawLine(3 + x, 5 + y, 3 + x, 9 + y);
2567            g.drawLine(4 + x, 5 + y, 4 + x, 9 + y);
2568            g.drawLine(5 + x, 7 + y, 9 + x, 3 + y);
2569            g.drawLine(5 + x, 8 + y, 9 + x, 4 + y);
2570            g.setColor(saved);
2571          }
2572        };
2573      }
2574  }  }

Legend:
Removed from v.1.4.2.4  
changed lines
  Added in v.1.4.2.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26