com.realtime.crossfire.jxclient.skin.io
Class ImageParser

java.lang.Object
  extended by com.realtime.crossfire.jxclient.skin.io.ImageParser

public class ImageParser
extends java.lang.Object

Creates BufferedImage instances from string representations. Each image is loaded only once.


Field Summary
private  JXCSkinCache<java.awt.image.BufferedImage> definedImages
          All defined images.
private  JXCSkinSource skinSource
          The JXCSkinSource for loading resources.
 
Constructor Summary
ImageParser(JXCSkinSource skinSource)
          Creates a new instance.
 
Method Summary
 void clear()
          Forgets all defined images.
 java.awt.image.BufferedImage getImage(java.awt.Color color, java.lang.String name)
          Optionally loads an image by base file name.
 java.awt.image.BufferedImage getImage(java.lang.String name)
          Loads an image by base file name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

definedImages

@NotNull
private final JXCSkinCache<java.awt.image.BufferedImage> definedImages
All defined images.


skinSource

@NotNull
private final JXCSkinSource skinSource
The JXCSkinSource for loading resources.

Constructor Detail

ImageParser

public ImageParser(@NotNull
                   JXCSkinSource skinSource)
Creates a new instance.

Parameters:
skinSource - the skin source for loading resources
Method Detail

clear

public void clear()
Forgets all defined images.


getImage

@Nullable
public java.awt.image.BufferedImage getImage(@Nullable
                                                      java.awt.Color color,
                                                      @NotNull
                                                      java.lang.String name)
                                      throws java.io.IOException
Optionally loads an image by base file name.

Parameters:
color - if non-null, return null
name - the base file name
Returns:
the image, or null if color!=null
Throws:
java.io.IOException - if the image cannot be loaded

getImage

@NotNull
public java.awt.image.BufferedImage getImage(@NotNull
                                                     java.lang.String name)
                                      throws java.io.IOException
Loads an image by base file name.

Parameters:
name - the base file name
Returns:
the image
Throws:
java.io.IOException - if the image cannot be loaded