uk.ac.starlink.util
Class IconUtils

java.lang.Object
  extended by uk.ac.starlink.util.IconUtils

public class IconUtils
extends Object

Utility functions related to Icons.

Since:
6 Mar 2013

Method Summary
static Icon colorIcon(Icon icon, Color color)
          Modifies an existing icon by changing its colour.
static BufferedImage createImage(Icon icon)
          Returns an image got by drawing an Icon.
static Icon emptyIcon(int width, int height)
          Returns an icon with a given size and no content.
static ImageIcon toImageIcon(Icon icon)
          Returns an ImageIcon based on a given Icon object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

emptyIcon

public static Icon emptyIcon(int width,
                             int height)
Returns an icon with a given size and no content.

Parameters:
width - icon width
height - icon height

colorIcon

public static Icon colorIcon(Icon icon,
                             Color color)
Modifies an existing icon by changing its colour. The colour attribute of the graphics context is changed before the icon is painted.

Parameters:
icon - input icon
color - colour to use as default for painting
Returns:
output icon

toImageIcon

public static ImageIcon toImageIcon(Icon icon)
Returns an ImageIcon based on a given Icon object. If the supplied icon is already an ImageIcon, it is returned. Otherwise, it is painted to an Image and an ImageIcon is constructed from that. The reason this is useful is that some Swing components will only grey out disabled icons if they are ImageIcon subclasses (which is naughty).

Parameters:
icon - input icon
Returns:
image icon

createImage

public static BufferedImage createImage(Icon icon)
Returns an image got by drawing an Icon.

Parameters:
icon -
Returns:
image

Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved.