public class TiledImageRepository
extends java.lang.Object
Constructor and Description |
---|
TiledImageRepository(java.io.File reposDir)
Create a new TiledImageRepository at the specified location.
|
TiledImageRepository(java.lang.String directory)
Create a new TiledImageRepository at the specified location.
|
Modifier and Type | Method and Description |
---|---|
void |
clean()
Clean the repository.
|
java.awt.image.BufferedImage |
composeImage(int level,
int xCoord,
int yCoord,
java.lang.String suffixes)
Compose an image from the base cell and all overlays whose overlay
characters occur in the suffixes argument, in order.
|
void |
extractOverlay(java.io.File imageFile,
int level,
int xCoord,
int yCoord,
char suffix)
Extract an overlay file from the provided image file.
|
java.io.File |
getDirectory()
Get the current repository directory
|
java.awt.image.BufferedImage |
getImage(int level,
int xCoord,
int yCoord,
char suffix)
Get the specified image cell
|
int |
getMaxLevel()
Return the maximum level the repository contains
|
java.util.SortedMap<java.lang.Character,java.lang.String> |
getOverlayList()
Get the set of overlay characters and their names
|
java.awt.image.BufferedImage |
getTmpImage(int level,
int xCoord,
int yCoord,
char suffix)
Get the temporary image for the specified image cell.
|
void |
insetImage(int level,
int xCoord,
int yCoord,
char suffix,
java.awt.image.BufferedImage image,
int xOffset,
int yOffset,
boolean tmp)
Adds an image to the set of tile images.
|
void |
storePaddedImage(java.io.File imageFile,
java.awt.Color margin,
boolean center)
Store an image file into the repository.
|
void |
storePaddedImage(java.awt.Image image,
java.awt.Color margin,
boolean center)
Store an image into the repository.
|
void |
storeScaledImage(java.awt.image.BufferedImage image)
Store an image into the repository.
|
void |
storeScaledImage(java.io.File imageFile)
Store an image file into the repository.
|
java.lang.String |
toImageName(int level,
int xCoord,
int yCoord,
char suffix)
Get the image name based on the level, coordinates and suffix.
|
void |
updateFromChildren(int level,
int xCoord,
int yCoord,
char suffix)
Update an image from its children.
|
boolean |
updateTree(int level,
int xCoord,
int yCoord,
char suffix)
Update the tree by descending and updating each tile whose children are
more current than it is.
|
public TiledImageRepository(java.io.File reposDir)
reposDir
- the directory where the image repository should residepublic TiledImageRepository(java.lang.String directory)
directory
- the directory where the image repository should residepublic void clean()
public java.awt.image.BufferedImage composeImage(int level, int xCoord, int yCoord, java.lang.String suffixes) throws java.io.IOException
level
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffixes
- set of suffixes indicating which overlays to add to the
resulting cell.java.io.IOException
- if there is trouble reading the image filespublic void extractOverlay(java.io.File imageFile, int level, int xCoord, int yCoord, char suffix) throws java.io.IOException
imageFile
- the image cell filelevel
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.java.io.IOException
- if there is trouble reading or writing the image
filespublic java.io.File getDirectory()
public java.awt.image.BufferedImage getImage(int level, int xCoord, int yCoord, char suffix) throws java.io.IOException
level
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.java.io.IOException
- if there is trouble reading the image filespublic int getMaxLevel()
public java.util.SortedMap<java.lang.Character,java.lang.String> getOverlayList()
public java.awt.image.BufferedImage getTmpImage(int level, int xCoord, int yCoord, char suffix) throws java.io.IOException
level
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.java.io.IOException
- if there is trouble reading the image filespublic void insetImage(int level, int xCoord, int yCoord, char suffix, java.awt.image.BufferedImage image, int xOffset, int yOffset, boolean tmp) throws java.io.IOException
level
- level of the tile cellxCoord
- X coordinate of the tile cell. This cell indicates which
cell contains the upper left corner of the inset imageyCoord
- Y coordinate of the tile cell. This cell indicates which
cell contains the upper left corner of the inset imagesuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.image
- the image being overlaidxOffset
- X Offset from the upper left corner of the starting cellyOffset
- Y Offset from the upper left corner of the starting celltmp
- flag indicating whether to use temporary or permanent storage
for the composite imagejava.io.IOException
- if there is a problem reading or writing the image
filespublic void storePaddedImage(java.io.File imageFile, java.awt.Color margin, boolean center) throws java.io.IOException
imageFile
- the original image filemargin
- the color of the margincenter
- whether to center the image or to place it in the upper
left corner of the resulting image tilesjava.io.IOException
- if there is trouble reading or writing the image
filespublic void storePaddedImage(java.awt.Image image, java.awt.Color margin, boolean center) throws java.io.IOException
image
- the original imagemargin
- the color of the margincenter
- whether to center the image or to place it in the upper
left corner of the resulting image tilesjava.io.IOException
- if there is trouble reading or writing the image
filespublic void storeScaledImage(java.awt.image.BufferedImage image) throws java.io.IOException
image
- the original imagejava.io.IOException
- if there is trouble writing the image filespublic void storeScaledImage(java.io.File imageFile) throws java.io.IOException
imageFile
- the original image filejava.io.IOException
- if there is trouble reading or writing the image
filespublic java.lang.String toImageName(int level, int xCoord, int yCoord, char suffix)
level
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.public void updateFromChildren(int level, int xCoord, int yCoord, char suffix) throws java.io.IOException
level
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.java.io.IOException
- if there is trouble reading or writing the image
filespublic boolean updateTree(int level, int xCoord, int yCoord, char suffix) throws java.io.IOException
level
- level of the tile cellxCoord
- X coordinate of the tile cell.yCoord
- Y coordinate of the tile cellsuffix
- suffix character indicating the overlay. A space indicates
the base set of tiles.java.io.IOException
- if there is trouble reading or writing the image
files