Package com.kheops.ui.component
Class StretchIcon
java.lang.Object
javax.swing.ImageIcon
com.kheops.ui.component.StretchIcon
- All Implemented Interfaces:
- Serializable,- Accessible,- Icon
An 
Icon that scales its image to fill the component area,
 excluding any border or insets, optionally maintaining the image's aspect
 ratio by padding and centering the scaled image horizontally or vertically.
 
 The class is a drop-in replacement for ImageIcon, except that
 the no-argument constructor is not supported.
 
 As the size of the Icon is determined by the size of the component in which
 it is displayed, StretchIcon must only be used in conjunction
 with a component and layout that does not depend on the size of the
 component's Icon.
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class javax.swing.ImageIconImageIcon.AccessibleImageIcon
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanDetermines whether the aspect ratio of the image is maintained.
- 
Constructor SummaryConstructorsConstructorDescriptionStretchIcon(byte[] imageData) Creates aStretchIconfrom an array of bytes.StretchIcon(byte[] imageData, boolean proportionate) Creates aStretchIconfrom an array of bytes with the specified behavior.StretchIcon(byte[] imageData, String description) Creates aStretchIconfrom an array of bytes.StretchIcon(byte[] imageData, String description, boolean proportionate) Creates aStretchIconfrom an array of bytes with the specified behavior.StretchIcon(Image image) Creates aStretchIconfrom the image.StretchIcon(Image image, boolean proportionate) Creates aStretchIconfrom the image with the specified behavior.StretchIcon(Image image, String description) Creates aStretchIconfrom the image.StretchIcon(Image image, String description, boolean proportionate) Creates aStretchIconfrom the image with the specified behavior.StretchIcon(String filename) Creates aStretchIconfrom the specified file.StretchIcon(String filename, boolean proportionate) Creates aStretchIconfrom the specified file with the specified behavior.StretchIcon(String filename, String description) Creates aStretchIconfrom the specified file.StretchIcon(String filename, String description, boolean proportionate) Creates aStretchIconfrom the specified file with the specified behavior.StretchIcon(URL location) Creates aStretchIconfrom the specified URL.StretchIcon(URL location, boolean proportionate) Creates aStretchIconfrom the specified URL with the specified behavior.StretchIcon(URL location, String description) Creates aStretchIconfrom the specified URL.StretchIcon(URL location, String description, boolean proportionate) Creates aStretchIconfrom the specified URL with the specified behavior.
- 
Method SummaryModifier and TypeMethodDescriptionintOverridden to return 0.intOverridden to return 0.voidPaints the icon.Methods inherited from class javax.swing.ImageIcongetAccessibleContext, getDescription, getImage, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImage, setImageObserver, toString
- 
Field Details- 
proportionateprotected boolean proportionateDetermines whether the aspect ratio of the image is maintained. Set tofalseto allow th image to distort to fill the component.
 
- 
- 
Constructor Details- 
StretchIconpublic StretchIcon(byte[] imageData) Creates aStretchIconfrom 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:
 
- 
StretchIconpublic StretchIcon(byte[] imageData, boolean proportionate) Creates aStretchIconfrom 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-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom 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:
 
- 
StretchIconCreates aStretchIconfrom 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-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the image.- Parameters:
- image- the image
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the image with the specified behavior.- Parameters:
- image- the image
- proportionate-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the image.- Parameters:
- image- the image
- description- a brief textual description of the image
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the image with the specified behavior.- Parameters:
- image- the image
- description- a brief textual description of the image
- proportionate-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified file.- Parameters:
- filename- a String specifying a filename or path
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified file with the specified behavior.- Parameters:
- filename- a String specifying a filename or path
- proportionate-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified file.- Parameters:
- filename- a String specifying a filename or path
- description- a brief textual description of the image
- See Also:
 
- 
StretchIconCreates aStretchIconfrom 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-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified URL.- Parameters:
- location- the URL for the image
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified URL with the specified behavior.- Parameters:
- location- the URL for the image
- proportionate-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified URL.- Parameters:
- location- the URL for the image
- description- a brief textual description of the image
- See Also:
 
- 
StretchIconCreates aStretchIconfrom the specified URL with the specified behavior.- Parameters:
- location- the URL for the image
- description- a brief textual description of the image
- proportionate-- trueto retain the image's aspect ratio,- falseto allow distortion of the image to fill the component.
- See Also:
 
 
- 
- 
Method Details- 
paintIconPaints 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 ccomponent as the observer.
- 
getIconWidthpublic int getIconWidth()Overridden to return 0. The size of this Icon is determined by the size of the component.- Specified by:
- getIconWidthin interface- Icon
- Overrides:
- getIconWidthin class- ImageIcon
- Returns:
- 0
 
- 
getIconHeightpublic int getIconHeight()Overridden to return 0. The size of this Icon is determined by the size of the component.- Specified by:
- getIconHeightin interface- Icon
- Overrides:
- getIconHeightin class- ImageIcon
- Returns:
- 0
 
 
-