jurpe.dungeon.rpgmap
Class MapView

java.lang.Object
  extended by jurpe.dungeon.rpgmap.MapView
All Implemented Interfaces:
ILogicalMap

public class MapView
extends java.lang.Object
implements ILogicalMap

Viewport of RpgMap.


Constructor Summary
MapView(RpgMap rpgmap, short viewWidth, short viewHeight)
          Constructor
 
Method Summary
 RpgMapPoint getBottomRight()
          Get bottom right coordinates, relative to RpgMap, of viewport
 Cell getCell(HexPoint p)
          Get RpgMapCell at RpgMapCoordinates XY
 Cell getCell(short x, short y)
          Get RpgMapCell at RpgMapCoordinates XY
 RpgMapPoint getCenter()
          Get current center
 short getCurrentBottom()
           
 short getCurrentLeft()
           
 short getCurrentRight()
           
 short getCurrentTop()
           
 short getHeight()
          Viewport height
 Direction getPerimeterEdge(RpgMapPoint avp)
          This method returns true if the point avp is "next" to a viewport perimeter (up, down, left, right).
 RpgMapPoint getTopLeft()
          Get top left coordinates, relative to RpgMap, of viewport
 ViewMapPoint getViewPosition(RpgMapPoint a)
          Return coordinates in view position, given the RpgMap absolute position
 short getWidth()
          Viewport width
 boolean isInside(RpgMapPoint position)
          Returns true if the position is inside the RpgMapView width and height
 MapIterator iterator()
          Iterator
 void scrollView(RpgMapPoint avatarPoint, Direction dir)
          Scroll this view in the Direction d.
 void setCenter(RpgMapPoint sCenter)
          Set new center
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapView

public MapView(RpgMap rpgmap,
               short viewWidth,
               short viewHeight)
Constructor

Parameters:
rpgmap - Entire map for which this is a view
viewWidth - Width of this viewport
viewHeight - Height of this viewport
Method Detail

getCenter

public RpgMapPoint getCenter()
Get current center

Returns:
RpgMapPoint

getCell

public Cell getCell(HexPoint p)
Get RpgMapCell at RpgMapCoordinates XY

Specified by:
getCell in interface ILogicalMap
Parameters:
p - RpgMapPoint View relative point
Returns:
RpgMapCell Cell in RpgMap

getCell

public Cell getCell(short x,
                    short y)
Get RpgMapCell at RpgMapCoordinates XY

Parameters:
x - x coordinate
y - y coordinate
Returns:
RpgMapCell Cell in RpgMap

isInside

public boolean isInside(RpgMapPoint position)
Returns true if the position is inside the RpgMapView width and height

Specified by:
isInside in interface ILogicalMap
Parameters:
position - Point coordinates of an hexagon
Returns:
True if the position is inside the RpgMapView width and height

getWidth

public short getWidth()
Viewport width

Specified by:
getWidth in interface ILogicalMap
Returns:
Viewport width

getHeight

public short getHeight()
Viewport height

Specified by:
getHeight in interface ILogicalMap
Returns:
Viewport height

getTopLeft

public RpgMapPoint getTopLeft()
Get top left coordinates, relative to RpgMap, of viewport

Specified by:
getTopLeft in interface ILogicalMap
Returns:
top left coordinates, relative to RpgMap, of viewport

getBottomRight

public RpgMapPoint getBottomRight()
Get bottom right coordinates, relative to RpgMap, of viewport

Specified by:
getBottomRight in interface ILogicalMap
Returns:
bottom right coordinates, relative to RpgMap, of viewport

iterator

public MapIterator iterator()
Iterator

Specified by:
iterator in interface ILogicalMap
Returns:
RpgMapIterator

setCenter

public void setCenter(RpgMapPoint sCenter)
Set new center

Parameters:
sCenter - RpgMapPoint

scrollView

public void scrollView(RpgMapPoint avatarPoint,
                       Direction dir)
Scroll this view in the Direction d. The new center will be: - In case of North/South scrolling, the centerX is retained and centerY will be avatarY - In case of East/West scrolling, the centerY is retained and centerX will be avatarX. In this case, for the particular hex geometry, the scroll will take place ONLY if the x coordinate of the avatar is not pair.

Parameters:
avatarPoint - Point in which avatar is
dir - Direction in which avatar is going

getViewPosition

public ViewMapPoint getViewPosition(RpgMapPoint a)
Return coordinates in view position, given the RpgMap absolute position

Parameters:
a - RpgMap point
Returns:
Coordinates as a view map point

getPerimeterEdge

public Direction getPerimeterEdge(RpgMapPoint avp)
This method returns true if the point avp is "next" to a viewport perimeter (up, down, left, right). Uses value=4 to determine by how many cells avp is to be distant from perimeter to be considered 'next'. Use this function to determine if a new center viewport is to be set.

Parameters:
avp - Point in RpgMap
Returns:
True if point is next to the perimeter

getCurrentTop

public short getCurrentTop()

getCurrentBottom

public short getCurrentBottom()

getCurrentLeft

public short getCurrentLeft()

getCurrentRight

public short getCurrentRight()

Jurpe - Java Universal Role Playing Engine - http://jurpe.sourceforge.net