Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class ShrinkIcon

java.lang.Object
  javax.swing.ImageIcon
      com.wordpress.tipsforjava.swing.StretchIcon
          com.wordpress.tipsforjava.swing.ShrinkIcon

public class ShrinkIcon
extends StretchIcon

@(#)ShrinkIcon.java 1.0 04/05/12


Field Summary
 
Fields inherited from class StretchIcon
proportionate
 
Constructor Summary
ShrinkIcon(byte[] imageData)

Creates a ShrinkIcon from an array of bytes.

ShrinkIcon(byte[] imageData, boolean proportionate)

Creates a ShrinkIcon from an array of bytes with the specified behavior.

ShrinkIcon(byte[] imageData, String description)

Creates a ShrinkIcon from an array of bytes.

ShrinkIcon(byte[] imageData, String description, boolean proportionate)

Creates a ShrinkIcon from an array of bytes with the specified behavior.

ShrinkIcon(Image image)

Creates a ShrinkIcon from the image.

ShrinkIcon(Image image, boolean proportionate)

Creates a ShrinkIcon from the image with the specified behavior.

ShrinkIcon(Image image, String description)

Creates a ShrinkIcon from the image.

ShrinkIcon(Image image, String description, boolean proportionate)

Creates a ShrinkIcon from the image with the specified behavior.

ShrinkIcon(String filename)

Creates a ShrinkIcon from the specified file.

ShrinkIcon(String filename, boolean proportionate)

Creates a ShrinkIcon from the specified file with the specified behavior.

ShrinkIcon(String filename, String description)

Creates a ShrinkIcon from the specified file.

ShrinkIcon(String filename, String description, boolean proportionate)

Creates a ShrinkIcon from the specified file with the specified behavior.

ShrinkIcon(URL location)

Creates a ShrinkIcon from the specified URL.

ShrinkIcon(URL location, boolean proportionate)

Creates a ShrinkIcon from the specified URL with the specified behavior.

ShrinkIcon(URL location, String description)

Creates a ShrinkIcon from the specified URL.

ShrinkIcon(URL location, String description, boolean proportionate)

Creates a ShrinkIcon from the specified URL with the specified behavior.

 
Method Summary
void paintIcon(Component c, Graphics g, int x, int y)

Paints the icon.

 
Methods inherited from class StretchIcon
getIconHeight, getIconWidth, paintIcon
 
Methods inherited from class ImageIcon
toString, getDescription, getAccessibleContext, getIconWidth, getIconHeight, setDescription, getImage, paintIcon, getImageLoadStatus, setImage, setImageObserver, getImageObserver, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll
 

Constructor Detail

ShrinkIcon

public ShrinkIcon(byte[] imageData)
Creates a ShrinkIcon from an array of bytes.
Parameters:
imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
See Also:
ImageIcon.ImageIcon


ShrinkIcon

public ShrinkIcon(byte[] imageData, boolean proportionate)
Creates a ShrinkIcon from an array of bytes with the specified behavior.
Parameters:
imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon.ImageIcon


ShrinkIcon

public ShrinkIcon(byte[] imageData, String description)
Creates a ShrinkIcon from an array of bytes.
Parameters:
imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
description - a brief textual description of the image
See Also:
ImageIcon#ImageIcon(byte[], java.lang.String)


ShrinkIcon

public ShrinkIcon(byte[] imageData, String description, boolean proportionate)
Creates a ShrinkIcon from an array of bytes with the specified behavior.
Parameters:
imageData - an array of pixels in an image format supported by the AWT Toolkit, such as GIF, JPEG, or (as of 1.3) PNG
description - a brief textual description of the image
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon.ImageIcon
ImageIcon#ImageIcon(byte[], java.lang.String)


ShrinkIcon

public ShrinkIcon(Image image)
Creates a ShrinkIcon from the image.
Parameters:
image - the image
See Also:
ImageIcon#ImageIcon(java.awt.Image)


ShrinkIcon

public ShrinkIcon(Image image, boolean proportionate)
Creates a ShrinkIcon from the image with the specified behavior.
Parameters:
image - the image
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon#ImageIcon(java.awt.Image)


ShrinkIcon

public ShrinkIcon(Image image, String description)
Creates a ShrinkIcon from the image.
Parameters:
image - the image
description - a brief textual description of the image
See Also:
ImageIcon#ImageIcon(java.awt.Image, java.lang.String)


ShrinkIcon

public ShrinkIcon(Image image, String description, boolean proportionate)
Creates a ShrinkIcon from the image with the specified behavior.
Parameters:
image - the image
description - a brief textual description of the image
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon#ImageIcon(java.awt.Image, java.lang.String)


ShrinkIcon

public ShrinkIcon(String filename)
Creates a ShrinkIcon from the specified file.
Parameters:
filename - a String specifying a filename or path
See Also:
ImageIcon#ImageIcon(java.lang.String)


ShrinkIcon

public ShrinkIcon(String filename, boolean proportionate)
Creates a ShrinkIcon from the specified file with the specified behavior.
Parameters:
filename - a String specifying a filename or path
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon#ImageIcon(java.lang.String)


ShrinkIcon

public ShrinkIcon(String filename, String description)
Creates a ShrinkIcon from the specified file.
Parameters:
filename - a String specifying a filename or path
description - a brief textual description of the image
See Also:
ImageIcon#ImageIcon(java.lang.String, java.lang.String)


ShrinkIcon

public ShrinkIcon(String filename, String description, boolean proportionate)
Creates a ShrinkIcon from the specified file with the specified behavior.
Parameters:
filename - a String specifying a filename or path
description - a brief textual description of the image
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon#ImageIcon(java.awt.Image, java.lang.String)


ShrinkIcon

public ShrinkIcon(URL location)
Creates a ShrinkIcon from the specified URL.
Parameters:
location - the URL for the image
See Also:
ImageIcon#ImageIcon(java.net.URL)


ShrinkIcon

public ShrinkIcon(URL location, boolean proportionate)
Creates a ShrinkIcon from the specified URL with the specified behavior.
Parameters:
location - the URL for the image
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon#ImageIcon(java.net.URL)


ShrinkIcon

public ShrinkIcon(URL location, String description)
Creates a ShrinkIcon from the specified URL.
Parameters:
location - the URL for the image
description - a brief textual description of the image
See Also:
ImageIcon#ImageIcon(java.net.URL, java.lang.String)


ShrinkIcon

public ShrinkIcon(URL location, String description, boolean proportionate)
Creates a ShrinkIcon from the specified URL with the specified behavior.
Parameters:
location - the URL for the image
description - a brief textual description of the image
proportionate - true to retain the image's aspect ratio, false to allow distortion of the image to fit the component.
See Also:
ImageIcon#ImageIcon(java.net.URL, java.lang.String)


 
Method Detail

paintIcon

@Override
public void paintIcon(Component c, Graphics g, int x, int y)
Paints the icon. If necessary, the image is reduced to fit the component to which it is painted, otherwise the image is centered horizontally and/or vertically and painted with a width and height not exceeding its natural size.

If the proportion has not been specified, or has been specified as true, the aspect ratio of the image will be preserved when reducing the size, by padding and centering the image horizontally or vertically.

If the proportion has been specified as false the image may be reduced on one or both axes, each independent of the other, to fit the component.

If this icon has no image observer,this method uses the c component as the observer.

Parameters:
c - the component to which the Icon is painted. This is used as the observer if this icon has no image observer
g - the graphics context
x - not used
y - not used
See Also:
StretchIcon.paintIcon


 

Groovy Documentation