Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import javax.swing.ImageIcon;
- import java.awt.image.*;
- import java.awt.*;
- import java.io.*;
- import java.util.List;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import javax.swing.GrayFilter;
- /**
- * GridImages represents the images to be used for pieces and backgrounds in
- * a grid game. GridImages acts like a map between piece names and their
- * corresponding images. The key values do NOT contain actual filenames.
- * In most cases the plugin author will want to use an enum name as the key.
- *
- * GridImages is a Singleton.
- */
- public final class GridImages
- {
- /** The name of the directory containing the images */
- public final static String kImageDir = "Images";
- /** The prefix for background images */
- public final static String kBackgroundPrefix = "background";
- /** The prefix for piece images */
- public final static String kPiecePrefix = "piece";
- /** The prefixes for all desired files to be loaded. */
- public final static String[] kImagePrefixes =
- {
- kBackgroundPrefix, kPiecePrefix
- };
- private final String imagePath = kImageDir + System.getProperty(
- "file.separator");
- /** Initialize and return the one allowed instance of this class.
- * The instance contains images loaded from <code>kImageDir</code>,
- * whose names begin with the <code>kImagePrefixes</code>. For example,
- * if <code>kPiecePrefix</code> contains "piece" then all images whose filenames
- * begin with "piece" will be loaded from <code>kImageDir</code>:
- * piecehidden.jpg, pieceflagged.png, pieceflower.jpg and so on.
- *
- * @param gamePrefix is the folder in which to find <code>kImageDir</code>
- * @return an instance of this class.
- * @post An error message will be displayed if there are no files with
- * the given prefix in the specified directory. Hint: use FilenameFilter.
- */
- public static GridImages createInstance(String gamePrefix)
- /** Retrieve an image.
- * @param name the name of the desired image (usually the <code>name()</code>
- * of a piece enum)
- * @return ImageIcon the image associated with the specified name
- */
- public ImageIcon getImage(String name)
- /** Constructor is private to defeat instantiation */
- private GridImages(String prefix)
- }
Advertisement
Add Comment
Please, Sign In to add comment