|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.lib.classes.construct.MagicMapper
Knows how to take a GameMap and turn it into a scaled image. (gif, png, or jpeg format). Don't call it on the Kernel thread - it will just throw an exception, since we don't want the game to lock up while this is processing.
Field Summary | |
static int |
DEFAULT_TYPE
|
static int |
GIF
|
static int |
JPG
|
static int |
PNG
|
Constructor Summary | |
MagicMapper()
Constructs a new MapRenderer |
Method Summary | |
static java.awt.image.BufferedImage |
createBufferedImage(java.awt.Image image)
Creates a buffered image from an image. |
java.awt.Image |
createImage(DenseMap map)
Creates an Image of a dense map (using the entire bounds), at scale factor set by setScale() |
java.awt.Image |
createImage(GameMap map,
Rectangle bounds)
Creates an Image of any map, with the specified bounding rectangle. |
Predicate |
getDrawFilter()
Returns the drawing filter to use, if one has been set. |
boolean |
getDrawInvisible()
Returns true if we draw engine-invis objects. |
boolean |
getLighting()
Returns true if we |
int |
getScale()
Returns the current scale factor. |
boolean |
getTerrainBorders()
Returns true if we draw terrain borders. |
static void |
main(java.lang.String[] args)
Tests the functions by choosing a map and creating an image from it. |
java.awt.Image |
mapToImage(GameMap map,
Rectangle bounds)
Does the work of creating the image. |
void |
setDrawFilter(Predicate p)
Sets a Predicate that tells whether or not to draw each object in the map. |
void |
setDrawInvisible(boolean invis)
Sets whether to draw invisible (-10) objects. |
void |
setImageType(int type)
Sets an image type: MagicMapper.JPG, MagicMapper.PNG, etc. |
void |
setLighting(boolean lighting)
Turns lighting model on and off. |
void |
setScale(int scale)
Sets the scale factor for the map, for shrinking it. |
void |
setTerrainBorders(boolean borders)
Sets whether to draw terrain borders. |
void |
writeGIF(java.awt.Image image,
java.lang.String filename)
Writes the specified image out as a GIF. |
void |
writeImage(java.awt.Image image,
java.lang.String filename)
Writes an image out in the default format. |
void |
writeJPG(java.awt.Image image,
java.lang.String filename)
Writes an Image to a jpeg file. |
void |
writePNG(java.awt.Image image,
java.lang.String filename)
Writes an Image to a PNG file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int JPG
public static final int GIF
public static final int PNG
public static final int DEFAULT_TYPE
Constructor Detail |
public MagicMapper()
Method Detail |
public void setImageType(int type)
public void setScale(int scale)
scale
- the scaling factor: 2 is 1/2 size, 4 is 1/4 size,
and so on. Powers of 2 look the best.public int getScale()
public void setTerrainBorders(boolean borders)
borders
- true to draw terrain borderspublic boolean getTerrainBorders()
public void setDrawInvisible(boolean invis)
invis
- true to draw engine-invis objects.public boolean getDrawInvisible()
public void setLighting(boolean lighting)
lighting
- true to draw in the lighting level in dark mapspublic boolean getLighting()
public void setDrawFilter(Predicate p)
p
- a Predicate object that is passed each object
in the map. The predicate should return true if you want
the MagicMapper to draw the object into the output image.public Predicate getDrawFilter()
public void writeImage(java.awt.Image image, java.lang.String filename) throws java.lang.Exception
image
- the Image to writefilename
- absolute path, without extension (chooses
an extension for you)
java.lang.Exception
public void writeGIF(java.awt.Image image, java.lang.String filename) throws java.lang.Exception
image
- the Image to writefilename
- absolute path, including extension
java.lang.Exception
public void writeJPG(java.awt.Image image, java.lang.String filename) throws java.lang.Exception
image
- the Image to writefilename
- absolute path, including extension
java.lang.Exception
public void writePNG(java.awt.Image image, java.lang.String filename) throws java.lang.Exception
image
- the Image to writefilename
- absolute path, including extension
java.lang.Exception
public java.awt.Image createImage(DenseMap map)
public java.awt.Image createImage(GameMap map, Rectangle bounds)
public java.awt.Image mapToImage(GameMap map, Rectangle bounds)
map
- the mapbounds
- the map boundspublic static java.awt.image.BufferedImage createBufferedImage(java.awt.Image image)
image
- any java.awt.Image or subclass
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |