/[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.1 by trebligd, Fri Jul 8 13:53:08 2005 UTC revision 1.2 by trebligd, Mon Jul 11 21:17:39 2005 UTC
# Line 44  import java.awt.Graphics; Line 44  import java.awt.Graphics;
44  import java.io.Serializable;  import java.io.Serializable;
45    
46  import javax.swing.Icon;  import javax.swing.Icon;
47    import javax.swing.JSlider;
48    
49  /**  /**
50   * Creates icons for the {@link MetalLookAndFeel}.   * Creates icons for the {@link MetalLookAndFeel}.
# Line 206  public class MetalIconFactory implements Line 207  public class MetalIconFactory implements
207      }      }
208                    
209    }    }
210      
211        /**
212       * The icon used to display the thumb control on a horizontally oriented
213       * {@link JSlider} component.
214       */
215      private static class HorizontalSliderThumbIcon
216          implements Icon, Serializable
217      {
218    
219        /**
220         * Creates a new instance.
221         */
222        public HorizontalSliderThumbIcon()
223        {
224        }
225        
226        /**
227         * Returns the width of the icon, in pixels.
228         *
229         * @return The width of the icon.
230         */
231        public int getIconWidth()
232        {
233          return 15;
234        }
235        
236        /**
237         * Returns the height of the icon, in pixels.
238         *
239         * @return The height of the icon.
240         */
241        public int getIconHeight()
242        {
243          return 16;
244        }
245        
246        /**
247         * Paints the icon, taking into account whether or not the component has
248         * the focus.
249         *
250         * @param c  the component.
251         * @param g  the graphics device.
252         * @param x  the x-coordinate.
253         * @param y  the y-coordinate.
254         */
255        public void paintIcon(Component c, Graphics g, int x, int y)
256        {
257          boolean focus = false;
258          if (c != null)
259            focus = c.hasFocus();    
260          // TODO: pick up the colors from the look and feel
261          
262          // draw the outline
263          g.setColor(Color.black);
264          g.drawLine(x + 1, y, x + 13, y);
265          g.drawLine(x + 14, y + 1, x + 14, y + 7);
266          g.drawLine(x + 14, y + 8, x + 7, y + 15);
267          g.drawLine(x + 6, y + 14, x, y + 8);
268          g.drawLine(x, y + 7, x, y + 1);
269          
270          // fill the icon
271          g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204));  // medium
272          g.fillRect(x + 2, y + 2, 12, 7);
273          g.drawLine(x + 2, y + 9, x + 12, y + 9);
274          g.drawLine(x + 3, y + 10, x + 11, y + 10);
275          g.drawLine(x + 4, y + 11, x + 10, y + 11);
276          g.drawLine(x + 5, y + 12, x + 9, y + 12);
277          g.drawLine(x + 6, y + 13, x + 8, y + 13);
278          g.drawLine(x + 7, y + 14, x + 7, y + 14);
279          
280          // draw highlights
281          g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));  // light
282          g.drawLine(x + 1, y + 1, x + 13, y + 1);
283          g.drawLine(x + 1, y + 2, x + 1, y + 8);
284          g.drawLine(x + 2, y + 2, x + 2, y + 2);
285          g.drawLine(x + 6, y + 2, x + 6, y + 2);
286          g.drawLine(x + 10, y + 2, x + 10, y + 2);
287    
288          g.drawLine(x + 4, y + 4, x + 4, y + 4);
289          g.drawLine(x + 8, y + 4, x + 8, y + 4);
290    
291          g.drawLine(x + 2, y + 6, x + 2, y + 6);
292          g.drawLine(x + 6, y + 6, x + 6, y + 6);
293          g.drawLine(x + 10, y + 6, x + 10, y + 6);
294    
295          // draw dots
296          g.setColor(focus ? new Color(102, 102, 153) : Color.black);                 // dark
297          g.drawLine(x + 3, y + 3, x + 3, y + 3);
298          g.drawLine(x + 7, y + 3, x + 7, y + 3);
299          g.drawLine(x + 11, y + 3, x + 11, y + 3);
300    
301          g.drawLine(x + 5, y + 5, x + 5, y + 5);
302          g.drawLine(x + 9, y + 5, x + 9, y + 5);
303    
304          g.drawLine(x + 3, y + 7, x + 3, y + 7);
305          g.drawLine(x + 7, y + 7, x + 7, y + 7);
306          g.drawLine(x + 11, y + 7, x + 11, y + 7);
307    
308        }        
309      }
310      
311      /**
312       * The icon used to display the thumb control on a horizontally oriented
313       * {@link JSlider} component.
314       */
315      private static class VerticalSliderThumbIcon implements Icon, Serializable
316      {
317        /**
318         * Creates a new instance.
319         */
320        public VerticalSliderThumbIcon()
321        {
322        }
323            
324        /**
325         * Returns the width of the icon, in pixels.
326         *
327         * @return The width of the icon.
328         */
329        public int getIconWidth()
330        {
331          return 16;
332        }
333        
334        /**
335         * Returns the height of the icon, in pixels.
336         *
337         * @return The height of the icon.
338         */
339        public int getIconHeight()
340        {
341          return 15;
342        }
343        
344        /**
345         * Paints the icon taking into account whether the slider control has the
346         * focus or not.
347         *
348         * @param c  the slider (must be a non-<code>null</code> instance of
349         *           {@link JSlider}.
350         * @param g  the graphics device.
351         * @param x  the x-coordinate.
352         * @param y  the y-coordinate.
353         */
354        public void paintIcon(Component c, Graphics g, int x, int y)
355        {
356          boolean focus = false;
357          if (c != null)
358            focus = c.hasFocus();    
359          // TODO: pick up the colors from the look and feel
360          
361          // draw the outline
362          g.setColor(Color.black);
363          g.drawLine(x + 1, y, x + 7, y);
364          g.drawLine(x + 8, y, x + 15, y + 7);
365          g.drawLine(x + 14, y + 8, x + 8, y + 14);
366          g.drawLine(x + 8, y + 14, x + 1, y + 14);
367          g.drawLine(x, y + 13, x, y + 1);
368          
369          // fill the icon
370          g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204));  // medium
371          g.fillRect(x + 2, y + 2, 7, 12);
372          g.drawLine(x + 9, y + 2, x + 9, y + 12);
373          g.drawLine(x + 10, y + 3, x + 10, y + 11);
374          g.drawLine(x + 11, y + 4, x + 11, y + 10);
375          g.drawLine(x + 12, y + 5, x + 12, y + 9);
376          g.drawLine(x + 13, y + 6, x + 13, y + 8);
377          g.drawLine(x + 14, y + 7, x + 14, y + 7);
378          
379          // draw highlights
380          g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));  // light
381          g.drawLine(x + 1, y + 1, x + 8, y + 1);
382          g.drawLine(x + 1, y + 2, x + 1, y + 13);
383          g.drawLine(x + 2, y + 2, x + 2, y + 2);
384          g.drawLine(x + 2, y + 6, x + 2, y + 6);
385          g.drawLine(x + 2, y + 10, x + 2, y + 10);
386    
387          g.drawLine(x + 4, y + 4, x + 4, y + 4);
388          g.drawLine(x + 4, y + 8, x + 4, y + 8);
389    
390          g.drawLine(x + 6, y + 2, x + 6, y + 2);
391          g.drawLine(x + 6, y + 6, x + 6, y + 6);
392          g.drawLine(x + 6, y + 10, x + 6, y + 10);
393    
394          // draw dots
395          g.setColor(focus ? new Color(102, 102, 153) : Color.black);                 // dark
396          g.drawLine(x + 3, y + 3, x + 3, y + 3);
397          g.drawLine(x + 3, y + 7, x + 3, y + 7);
398          g.drawLine(x + 3, y + 11, x + 3, y + 11);
399    
400          g.drawLine(x + 5, y + 5, x + 5, y + 5);
401          g.drawLine(x + 5, y + 9, x + 5, y + 9);
402    
403          g.drawLine(x + 7, y + 3, x + 7, y + 3);
404          g.drawLine(x + 7, y + 7, x + 7, y + 7);
405          g.drawLine(x + 7, y + 11, x + 7, y + 11);
406        }        
407      }
408      
409    /**    /**
410     * A tree control icon.  This icon can be in one of two states: expanded and     * A tree control icon.  This icon can be in one of two states: expanded and
411     * collapsed.     * collapsed.
# Line 416  public class MetalIconFactory implements Line 615  public class MetalIconFactory implements
615    }    }
616        
617    /**    /**
618       * Returns the icon used to display the thumb for a horizontally oriented
619       * {@link JSlider}.
620       *
621       * @return The icon.
622       */
623      public static Icon getHorizontalSliderThumbIcon()
624      {
625        return new HorizontalSliderThumbIcon();
626      }
627        
628      /**
629       * Returns the icon used to display the thumb for a vertically oriented
630       * {@link JSlider}.
631       *
632       * @return The icon.
633       */
634      public static Icon getVerticalSliderThumbIcon()
635      {
636        return new VerticalSliderThumbIcon();
637      }
638        
639      /**
640     * Creates and returns a new tree folder icon.     * Creates and returns a new tree folder icon.
641     *     *
642     * @return A new tree folder icon.     * @return A new tree folder icon.

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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