Groovy Documentation

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

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

public class StretchIcon
extends ImageIcon

@(#)StretchIcon.java 1.0 03/27/12


Field Summary
protected boolean proportionate

Determines whether the aspect ratio of the image is maintained.

 
Constructor Summary
StretchIcon(byte[] imageData)

Creates a StretchIcon from an array of bytes.

StretchIcon(byte[] imageData, boolean proportionate)

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

StretchIcon(byte[] imageData, String description)

Creates a StretchIcon from an array of bytes.

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

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

StretchIcon(Image image)

Creates a StretchIcon from the image.

StretchIcon(Image image, boolean proportionate)

Creates a StretchIcon from the image with the specifiec behavior.

StretchIcon(Image image, String description)

Creates a StretchIcon from the image.

StretchIcon(Image image, String description, boolean proportionate)

Creates a StretchIcon from the image with the specified behavior.

StretchIcon(String filename)

Creates a StretchIcon from the specified file.

StretchIcon(String filename, boolean proportionate)

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

StretchIcon(String filename, String description)

Creates a StretchIcon from the specified file.

StretchIcon(String filename, String description, boolean proportionate)

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

StretchIcon(URL location)

Creates a StretchIcon from the specified URL.

StretchIcon(URL location, boolean proportionate)

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

StretchIcon(URL location, String description)

Creates a StretchIcon from the specified URL.

StretchIcon(URL location, String description, boolean proportionate)

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

 
Method Summary
int getIconHeight()

Overridden to return 0.

int getIconWidth()

Overridden to return 0.

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

Paints the icon.

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

Field Detail

proportionate

protected boolean proportionate
Determines whether the aspect ratio of the image is maintained. Set to false to distort the image to fill the component.


 
Constructor Detail

StretchIcon

public StretchIcon(byte[] imageData)
Creates a StretchIcon 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


StretchIcon

public StretchIcon(byte[] imageData, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon.ImageIcon


StretchIcon

public StretchIcon(byte[] imageData, String description)
Creates a StretchIcon 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)


StretchIcon

public StretchIcon(byte[] imageData, String description, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon.ImageIcon
ImageIcon#ImageIcon(byte[], java.lang.String)


StretchIcon

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


StretchIcon

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


StretchIcon

public StretchIcon(Image image, String description)
Creates a StretchIcon 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)


StretchIcon

public StretchIcon(Image image, String description, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon#ImageIcon(java.awt.Image, java.lang.String)


StretchIcon

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


StretchIcon

public StretchIcon(String filename, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon#ImageIcon(java.lang.String)


StretchIcon

public StretchIcon(String filename, String description)
Creates a StretchIcon 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)


StretchIcon

public StretchIcon(String filename, String description, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon#ImageIcon(java.awt.Image, java.lang.String)


StretchIcon

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


StretchIcon

public StretchIcon(URL location, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon#ImageIcon(java.net.URL)


StretchIcon

public StretchIcon(URL location, String description)
Creates a StretchIcon 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)


StretchIcon

public StretchIcon(URL location, String description, boolean proportionate)
Creates a StretchIcon 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 fill the component.
See Also:
ImageIcon#ImageIcon(java.net.URL, java.lang.String)


 
Method Detail

getIconHeight

@Override
public int getIconHeight()
Overridden to return 0. The size of this Icon is determined by the size of the component.
Returns:
0


getIconWidth

@Override
public int getIconWidth()
Overridden to return 0. The size of this Icon is determined by the size of the component.
Returns:
0


paintIcon

@Override
public void paintIcon(Component c, Graphics g, int x, int y)
Paints the icon. The image is reduced or magnified to fit the component to which it is painted.

If the proportion has not been specified, or has been specified as true, the aspect ratio of the image will be preserved by padding and centering the image horizontally or vertically. Otherwise the image may be distorted to fill the component it is painted to.

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:
ImageIcon#paintIcon(java.awt.Component, java.awt.Graphics, int, int)


 

Groovy Documentation