|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmhframework.tilemap.MHTileMap
public class MHTileMap
Base class for deriving tile-based map objects. It may be used by itself for creating rectangular tile maps and extended to make isometric and hexagonal maps. This class and its subclasses handle the presentation of and user interaction with the data contained in an MHMap object.
Field Summary | |
---|---|
protected java.awt.geom.Rectangle2D |
anchorSpace
A rectangle defining the difference between the screen space and the world space which is used for clipping and stuff. |
protected MHMapCellAddress |
cursorAddress
|
protected java.awt.Point |
cursorAnchor
|
protected java.awt.Point |
cursorPoint
|
static int |
DIR_EAST
East direction. |
static int |
DIR_NORTH
North direction. |
static int |
DIR_NORTHEAST
Northeast direction. |
static int |
DIR_NORTHWEST
Northwest direction. |
static int |
DIR_SOUTH
South direction. |
static int |
DIR_SOUTHEAST
Southeast direction. |
static int |
DIR_SOUTHWEST
Southwest direction. |
static int |
DIR_WEST
West direction. |
static int |
MAX_DIRECTIONS
Maximum number of directions. |
protected java.awt.Point |
screenAnchor
The upper-left corner of the visible portion of the map. |
protected java.awt.geom.Rectangle2D |
screenSpace
A rectangle containing the screen coordinates. |
protected java.awt.geom.Rectangle2D |
worldSpace
A rectangle containing all of the coordinates of the entire virtual world. |
Constructor Summary | |
---|---|
MHTileMap(java.lang.String filename,
MHObjectFactory vendor)
Constructor. |
Method Summary | |
---|---|
void |
advance()
Tells an object to update its data. |
protected void |
calculateAnchorSpace()
Calculate the anchor space for this tile map. |
protected void |
calculateWorldSpace()
Calculate the world space for this tile map. |
protected void |
clipCursorAddress()
Performs validation on the cursor's map cell address to ensure that it is within the bounds of the map. |
protected void |
clipScreenAnchor()
|
MHMapCellAddress |
getCursorAddress()
|
java.awt.Point |
getCursorPoint()
Returns the cursorPoint. |
MHMap |
getMapData()
Returns a reference to the MHMap object serving as the map's data structure. |
java.awt.Point |
getScreenAnchor()
Returns the screenAnchor. |
java.awt.geom.Rectangle2D |
getScreenSpace()
Returns the screenSpace. |
int |
getTileHeight()
Returns the height of a base tile in this tile map. |
int |
getTileWidth()
Returns the width of a base tile in this tile map. |
boolean |
isAnchorCoordinate(java.awt.Point p)
Determines if the given point is a valid anchor coordinate. |
boolean |
isScreenCoordinate(java.awt.Point p)
Determines if the given point is a valid screen coordinate. |
boolean |
isWorldCoordinate(java.awt.Point p)
Determines if the given point is a valid world coordinate. |
MHMapCellAddress |
mapMouse(java.awt.Point mousePoint)
Converts mouse coordinates into a map cell address. |
void |
mouseMoved(java.awt.event.MouseEvent e)
|
java.awt.Point |
plotTile(int mapRow,
int mapCol)
Tile plotter. |
void |
render(java.awt.Graphics2D g)
Tells an object to draw itself onto the sent Graphics object. |
java.awt.Point |
screenToWorld(java.awt.Point screen)
Convert screen coordinates to world coordinates. |
void |
scrollMap(int scrollX,
int scrollY)
Scrolls the map in the distance specified by the input parameters. |
void |
setCursorPoint(java.awt.Point cursorPoint)
Sets the cursorPoint. |
void |
setScreenAnchor(int x,
int y)
Sets the screen anchor. |
void |
setScreenAnchor(java.awt.Point screenAnchor)
Sets the screenAnchor. |
void |
setScreenSpace(int x,
int y,
int width,
int height)
Defines the bounds of the screen space. |
void |
setTileWidth(int width)
Sets the tile width value . |
java.awt.Point |
worldToScreen(java.awt.Point world)
Convert world coordinates to screen coordinates. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_DIRECTIONS
public static final int DIR_NORTH
public static final int DIR_NORTHEAST
public static final int DIR_EAST
public static final int DIR_SOUTHEAST
public static final int DIR_SOUTH
public static final int DIR_SOUTHWEST
public static final int DIR_WEST
public static final int DIR_NORTHWEST
protected java.awt.geom.Rectangle2D screenSpace
protected java.awt.geom.Rectangle2D worldSpace
protected java.awt.geom.Rectangle2D anchorSpace
protected java.awt.Point screenAnchor
protected MHMapCellAddress cursorAddress
protected java.awt.Point cursorPoint
protected java.awt.Point cursorAnchor
Constructor Detail |
---|
public MHTileMap(java.lang.String filename, MHObjectFactory vendor)
data
- A reference to the application's data model.filename
- The name of the map file to be loaded into
this tile map.vendor
- A reference to an existing MHObjectVendor
for instantiating interactive actor objects.Method Detail |
---|
public java.awt.Point plotTile(int mapRow, int mapCol)
mapRow
- The row of the map whose pixel position is
being calculated.mapCol
- The column of the map whose pixel position is
being calculated.
public void scrollMap(int scrollX, int scrollY)
scrollX
- The horizontal distance in pixels to scroll
the mapscrollY
- The vertical distance in pixels to scroll
the mapprotected void clipScreenAnchor()
public java.awt.Point screenToWorld(java.awt.Point screen)
screen
- A point in screen coordinates.
public java.awt.Point worldToScreen(java.awt.Point world)
world
- A point in world space.
protected void calculateAnchorSpace()
protected void calculateWorldSpace()
public int getTileWidth()
public int getTileHeight()
public boolean isWorldCoordinate(java.awt.Point p)
public boolean isScreenCoordinate(java.awt.Point p)
public boolean isAnchorCoordinate(java.awt.Point p)
public void setScreenSpace(int x, int y, int width, int height)
public MHMapCellAddress mapMouse(java.awt.Point mousePoint)
mousePoint
- A Point indicating the current physical
location of the mouse cursor on screen.
public MHMap getMapData()
public void setTileWidth(int width)
width
- The value to use as the tile width.public void advance()
MHRenderable
advance
in interface MHRenderable
public void render(java.awt.Graphics2D g)
MHRenderable
render
in interface MHRenderable
g
- The Graphics object on which this object is to draw itself.protected void clipCursorAddress()
public void mouseMoved(java.awt.event.MouseEvent e)
public java.awt.geom.Rectangle2D getScreenSpace()
public MHMapCellAddress getCursorAddress()
public java.awt.Point getScreenAnchor()
public void setScreenAnchor(java.awt.Point screenAnchor)
screenAnchor
- The screenAnchor to setpublic void setScreenAnchor(int x, int y)
x
- The x coordinate of the screen anchory
- The y coordinate of the screen anchorpublic java.awt.Point getCursorPoint()
public void setCursorPoint(java.awt.Point cursorPoint)
cursorPoint
- The cursorPoint to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |