|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.croftsoft.core.animation.icon.ResourceImageIcon
public final class ResourceImageIcon
When contents lost, reloads the VolatileImage from the ClassLoader.
This class only works with opaque (non-transparent) images.
Example code:
Icon heroIcon = new ResourceImageIcon ( HERO_IMAGE_FILENAME, getClass ( ).getClassLoader ( ), new Dimension ( ( int ) scalingRatio * HERO_IMAGE_WIDTH, ( int ) scalingRatio * HERO_IMAGE_HEIGHT ), animatedComponent );
VolatileImage
Constructor Summary | |
---|---|
ResourceImageIcon(String imageFilename)
|
|
ResourceImageIcon(String imageFilename,
ClassLoader classLoader,
Dimension scaleDimension,
Component component)
Main constructor. |
Method Summary | |
---|---|
int |
getIconHeight()
|
int |
getIconWidth()
|
void |
paintIcon(Component component,
Graphics graphics,
int x,
int y)
If VolatileImage contents are lost, calls prepareVolatileImage(). |
void |
prepareVolatileImage(Component component)
Loads the VolatileImage. |
void |
setHeight(int height)
|
void |
setSize(Dimension size)
|
void |
setWidth(int width)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResourceImageIcon(String imageFilename, ClassLoader classLoader, Dimension scaleDimension, Component component)
imageFilename
- The image path and filename, usually pulled from a JAR.classLoader
- The ClassLoader to use to load the image as a resource file.scaleDimension
- If not null, used to pre-scale the VolatileImage.component
- If not null, prepareVolatileImage() is called during construction.public ResourceImageIcon(String imageFilename)
Method Detail |
---|
public int getIconWidth()
getIconWidth
in interface Icon
public int getIconHeight()
getIconHeight
in interface Icon
public void paintIcon(Component component, Graphics graphics, int x, int y)
paintIcon
in interface Icon
public void prepareVolatileImage(Component component)
Call this method to load the image after construction but before the first call to paint(). This is useful if you cannot perform this operation when the main constructor is called because the Component is not ready at the time and you do not want to wait until the first paint() because the load may stall animation.
Example code:
ResourceImageIcon heroIcon = new ResourceImageIcon ( HERO_IMAGE_FILENAME, getClass ( ).getClassLoader ( ), ( Dimension ) null, // no scaling ( Component ) null ); [...wait until Component is ready...] heroIcon.prepareVolatileImage ( animatedComponent );
public void setWidth(int width)
public void setHeight(int height)
public void setSize(Dimension size)
|
CroftSoft Javadoc | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |