/[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.8 by trebligd, Tue Aug 30 20:46:31 2005 UTC revision 1.9 by trebligd, Tue Sep 6 19:57:34 2005 UTC
# Line 295  public class MetalIconFactory implements Line 295  public class MetalIconFactory implements
295    static class RadioButtonIcon    static class RadioButtonIcon
296      implements Icon, UIResource, Serializable      implements Icon, UIResource, Serializable
297    {    {
     /**  
      * Draws the check in the RadioButton.  
      *  
      * @param c the component to draw on  
      * @param g the Graphics context to draw with  
      */  
     protected void drawCheck(Component c, Graphics g)  
     {  
       g.setColor(MetalLookAndFeel.getBlack());  
       g.fillRect(4, 3, 4, 6);  
       g.drawLine(3, 4, 3, 7);  
       g.drawLine(8, 4, 8, 7);  
     }  
298    
299      /**      /**
300       * Returns the width of the icon in pixels.       * Returns the width of the icon in pixels.
# Line 330  public class MetalIconFactory implements Line 317  public class MetalIconFactory implements
317      }      }
318    
319      /**      /**
320       * Paints the icon. This first paints the border of the RadioButton and       * Paints the icon, taking into account whether or not the component is
321       * if the CheckBox is selected it calls {@link #drawCheck} to draw       * enabled, selected and/or armed.
      * the check.  
322       *       *
323       * @param c the Component to draw on (gets casted to JCheckBox)       * @param c the Component to draw on (must be an instance of
324         *          {@link JRadioButton})
325       * @param g the Graphics context to draw with       * @param g the Graphics context to draw with
326       * @param x the X position       * @param x the X position
327       * @param y the Y position       * @param y the Y position
328       */       */
329      public void paintIcon(Component c, Graphics g, int x, int y)      public void paintIcon(Component c, Graphics g, int x, int y)
330      {      {
331        Color dark = MetalLookAndFeel.getControlDarkShadow();        Color savedColor = g.getColor();
332        Color light = MetalLookAndFeel.getWhite();        JRadioButton b = (JRadioButton) c;
333        g.translate(x, y);        
334          // draw outer circle
335        // The light 'circle'        if (b.isEnabled())
336        g.setColor(light);          g.setColor(MetalLookAndFeel.getControlDarkShadow());
337        g.drawLine(4, 1, 10, 1);        else
338        g.drawLine(2, 2, 3, 2);          g.setColor(MetalLookAndFeel.getControlDisabled());
339        g.drawLine(8, 2, 11, 2);        g.drawLine(x + 2, y + 1, x + 3, y + 1);
340        g.drawLine(2, 3, 2, 3);        g.drawLine(x + 4, y, x + 7, y);
341        g.drawLine(11, 2, 11, 9);        g.drawLine(x + 8, y + 1, x + 9, y + 1);
342        g.drawLine(1, 4, 1, 7);        g.drawLine(x + 10, y + 2, x + 10, y + 3);
343        g.drawLine(12, 4, 12, 7);        g.drawLine(x + 11, y + 4, x + 11, y + 7);
344        g.drawLine(2, 8, 2, 11);        g.drawLine(x + 10, y + 8, x + 10, y + 9);
345        g.drawLine(11, 8, 11, 9);        g.drawLine(x + 8, y + 10, x + 9, y + 10);
346        g.drawLine(10, 10, 10, 10);        g.drawLine(x + 4, y + 11, x + 7, y + 11);
347        g.drawLine(2, 11, 9, 11);        g.drawLine(x + 2, y + 10, x + 3, y + 10);
348        g.drawLine(4, 12, 7, 12);        g.drawLine(x + 1, y + 9, x + 1, y + 8);
349          g.drawLine(x, y + 7, x, y + 4);
350        // The dark 'circle'        g.drawLine(x + 1, y + 2, x + 1, y + 3);
351        g.setColor(dark);  
352        g.drawLine(4, 0, 7, 0);        if (b.getModel().isArmed())
353        g.drawLine(2, 1, 3, 1);          {
354        g.drawLine(8, 1, 9, 1);            g.setColor(MetalLookAndFeel.getControlShadow());
355        g.drawLine(1, 2, 1, 3);            g.drawLine(x + 4, y + 1, x + 7, y + 1);
356        g.drawLine(10, 2, 10, 3);            g.drawLine(x + 4, y + 10, x + 7, y + 10);
357        g.drawLine(0, 4, 0, 7);            g.drawLine(x + 1, y + 4, x + 1, y + 7);
358        g.drawLine(11, 4, 11, 7);            g.drawLine(x + 10, y + 4, x + 10, y + 7);
359        g.drawLine(1, 8, 1, 9);            g.fillRect(x + 2, y + 2, 8, 8);
360        g.drawLine(10, 8, 10, 9);          }
361        g.drawLine(2, 10, 3, 10);        else
362        g.drawLine(8, 10, 9, 10);          {
363        g.drawLine(4, 11, 7, 11);            // only draw inner highlight if not filled
364              if (b.isEnabled())
365        JRadioButton rb = (JRadioButton) c;              {
366        if (rb.isSelected())                g.setColor(MetalLookAndFeel.getWhite());
367          drawCheck(c, g);            
368                  g.drawLine(x + 2, y + 8, x + 2, y + 9);
369        g.translate(-x, -y);                g.drawLine(x + 1, y + 4, x + 1, y + 7);
370      }                g.drawLine(x + 2, y + 2, x + 2, y + 3);
371                  g.drawLine(x + 3, y + 2, x + 3, y + 2);
372                  g.drawLine(x + 4, y + 1, x + 7, y + 1);
373                  g.drawLine(x + 8, y + 2, x + 9, y + 2);
374                }
375            }
376    
377          // draw outer highlight
378          if (b.isEnabled())
379            {
380              g.setColor(MetalLookAndFeel.getWhite());
381              
382              // outer
383              g.drawLine(x + 10, y + 1, x + 10, y + 1);
384              g.drawLine(x + 11, y + 2, x + 11, y + 3);
385              g.drawLine(x + 12, y + 4, x + 12, y + 7);
386              g.drawLine(x + 11, y + 8, x + 11, y + 9);
387              g.drawLine(x + 10, y + 10, x + 10, y + 10);
388              g.drawLine(x + 8, y + 11, x + 9, y + 11);
389              g.drawLine(x + 4, y + 12, x + 7, y + 12);
390              g.drawLine(x + 2, y + 11, x + 3, y + 11);
391            }
392          
393          if (b.isSelected())
394            {
395              g.setColor(MetalLookAndFeel.getBlack());
396              g.drawLine(x + 4, y + 3, x + 7, y + 3);
397              g.fillRect(x + 3, y + 4, 6, 4);
398              g.drawLine(x + 4, y + 8, x + 7, y + 8);
399            }
400          g.setColor(savedColor);
401        }        
402    }    }
403    
404    /**    /**

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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