de.adom.jade.ui
Class MapView

java.lang.Object
  extended by de.adom.jade.ui.MapView
All Implemented Interfaces:
MapListener, java.io.Serializable

public class MapView
extends java.lang.Object
implements MapListener, java.io.Serializable

Memorizes which parts of the map are currently visibly and which are not. It also memorizes all known map parts (visited but not currently visible). Additionally this class memorizes the current on-screen representation for all visited places.

This class is the most direct connector between the rather abstractmap structure and the very real display chosen be the UI to visalize the map.

See Also:
Serialized Form

Constructor Summary
MapView(Map theMap)
          Creates a new map view for a given map.
 
Method Summary
 int getBottomViewBoundary()
          Returns the bottom-most boundary (unwrapped) of the view of the central being.
 int getLeftViewBoundary()
          Returns the left-most boundary (unwrapped) of the view of the central being.
 int getRightViewBoundary()
          Returns the right-most boundary (unwrapped) of the view of the central being.
 TileRepresentation getTileRepresentation(int x, int y)
          Returns the representation for a given position.
 int getTopViewBoundary()
          Returns the top-most boundary (unwrapped) of the view of the central being.
 MapArea getUpdatedViewArea()
          Returns a map area describing those parts of the map that were changed in some visually noticable way since the last call to resetVisibility.
 boolean isVisible(int x, int y)
          Determines whether a given position of the map is visible or not.
 void mapUpdated(int x, int y)
          Notifies the view of an update.
 void resetUpdates()
          Resets the update list.
 void resetVisibility()
          Resets visibility for the complete map.
 void setPointOfView(Being being)
          Sets the point of view of the PC.
 void setTileRepresentation(int x, int y, TileRepresentation representation)
          Sets the current representation for a given position.
 void setVisible(int x, int y, boolean visibility)
          Marks a given position as visible or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapView

public MapView(Map theMap)
Creates a new map view for a given map.

Parameters:
theMap - the map t which this view belongs
Method Detail

isVisible

public boolean isVisible(int x,
                         int y)
Determines whether a given position of the map is visible or not.

Parameters:
x - the x coordinate for the position
y - the y coordinate for the position
Returns:
a boolean value determining whether the given position is currently visible

setVisible

public void setVisible(int x,
                       int y,
                       boolean visibility)
Marks a given position as visible or not. For performance reasons no coordinate wrapping is done in this method.

Parameters:
x - the x coordinate for the position
y - the y coordinate for the position
visibility - a boolean flag determining whether the position is visible or not

resetVisibility

public void resetVisibility()
Resets visibility for the complete map.


setTileRepresentation

public void setTileRepresentation(int x,
                                  int y,
                                  TileRepresentation representation)
Sets the current representation for a given position.

Parameters:
x - the x coordinate for the position
y - the y coordinate for the position
representation - the representation for the given position

getTileRepresentation

public TileRepresentation getTileRepresentation(int x,
                                                int y)
Returns the representation for a given position. For performance reasons no coordinate wrapping is done in this method.

Parameters:
x - the x coordinate for the position
y - the y coordinate for the position
Returns:
the representation for the given position when it was last seen; if the position in question was never before seen, the value null will be returned.

getUpdatedViewArea

public MapArea getUpdatedViewArea()
Returns a map area describing those parts of the map that were changed in some visually noticable way since the last call to resetVisibility.

Returns:
the map area that was recently updated; no copy of the internal object is returned - thus it must not be changed by the calling method

setPointOfView

public void setPointOfView(Being being)
Sets the point of view of the PC.

Parameters:
being - the being to use as the reference being for the next map view

mapUpdated

public void mapUpdated(int x,
                       int y)
Notifies the view of an update.

Specified by:
mapUpdated in interface MapListener
Parameters:
x - the x coordinate of the updated position
y - the y coordinate of the updated position

resetUpdates

public void resetUpdates()
Resets the update list.


getLeftViewBoundary

public int getLeftViewBoundary()
Returns the left-most boundary (unwrapped) of the view of the central being.

Returns:
the left-most boundary

getRightViewBoundary

public int getRightViewBoundary()
Returns the right-most boundary (unwrapped) of the view of the central being.

Returns:
the right-most boundary

getTopViewBoundary

public int getTopViewBoundary()
Returns the top-most boundary (unwrapped) of the view of the central being.

Returns:
the top boundary

getBottomViewBoundary

public int getBottomViewBoundary()
Returns the bottom-most boundary (unwrapped) of the view of the central being.

Returns:
the bottom boundary