org.openbp.common.icon
Class MultiImageIcon

java.lang.Object
  extended by javax.swing.ImageIcon
      extended by org.openbp.common.icon.MultiImageIcon
All Implemented Interfaces:
java.io.Serializable, javax.accessibility.Accessible, javax.swing.Icon, FlexibleSize, MultiIcon
Direct Known Subclasses:
OverlayIcon

public class MultiImageIcon
extends javax.swing.ImageIcon
implements MultiIcon

IconImage that supports multiple sizes at once.

Author:
Stephan Moritz
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.ImageIcon
javax.swing.ImageIcon.AccessibleImageIcon
 
Field Summary
 
Fields inherited from class javax.swing.ImageIcon
component, tracker
 
Fields inherited from interface org.openbp.common.icon.FlexibleSize
HUGE, LARGE, MEDIUM, SMALL, STANDARD, UNDETERMINED
 
Constructor Summary
MultiImageIcon(javax.swing.ImageIcon source)
          Creates a new multi image icon that is built around a single ImageIcon.
MultiImageIcon(MultiImageIcon src)
          Copy constructor.
MultiImageIcon(java.lang.String resourceName, ResourceMgr resMgr)
          Creates a new multi image icon from a given filename.
 
Method Summary
 javax.swing.Icon getIcon(int size)
          Returns an icon with the given size.
 int getIconHeight()
           
 int getIconSize()
          Gets the current icon size.
 int getIconWidth()
           
 java.awt.Image getImage()
          Returns an image representation of this icon in the currently active size.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
           
 void setIconSize(int size)
          Sets the current icon size.
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImage, setImageObserver, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiImageIcon

public MultiImageIcon(MultiImageIcon src)
Copy constructor.

Parameters:
src - The source icon

MultiImageIcon

public MultiImageIcon(javax.swing.ImageIcon source)
Creates a new multi image icon that is built around a single ImageIcon.

Parameters:
source - The icon

MultiImageIcon

public MultiImageIcon(java.lang.String resourceName,
                      ResourceMgr resMgr)
Creates a new multi image icon from a given filename.

Parameters:
resourceName - Name of the icon resource (without the size suffix, but including the icon file type)
resMgr - Resource manager to use for resource access or null for the default resource manager
Method Detail

getIconSize

public int getIconSize()
Description copied from interface: FlexibleSize
Gets the current icon size.

Specified by:
getIconSize in interface FlexibleSize
Returns:
The icon size descriptor (FlexibleSize.STANDARD/FlexibleSize.SMALL/ FlexibleSize.MEDIUM/FlexibleSize.LARGE/FlexibleSize.HUGE)

setIconSize

public void setIconSize(int size)
Description copied from interface: FlexibleSize
Sets the current icon size.

Specified by:
setIconSize in interface FlexibleSize
Parameters:
size - The icon size descriptor (FlexibleSize.STANDARD/FlexibleSize.SMALL/ FlexibleSize.MEDIUM/FlexibleSize.LARGE/FlexibleSize.HUGE)

getIcon

public javax.swing.Icon getIcon(int size)
Returns an icon with the given size.

Specified by:
getIcon in interface MultiIcon
Parameters:
size - Size of the desired icon or null for default
Returns:
The icon

getImage

public java.awt.Image getImage()
Description copied from interface: MultiIcon
Returns an image representation of this icon in the currently active size.

Specified by:
getImage in interface MultiIcon
Overrides:
getImage in class javax.swing.ImageIcon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon
Overrides:
getIconHeight in class javax.swing.ImageIcon
See Also:
Icon.getIconHeight()

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon
Overrides:
getIconWidth in class javax.swing.ImageIcon
See Also:
Icon.getIconWidth()

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface javax.swing.Icon
Overrides:
paintIcon in class javax.swing.ImageIcon
See Also:
Icon.paintIcon(Component, Graphics, int, int)


Copyright © 2011. All Rights Reserved.