public class Map
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private float |
height
The height of the map.
|
private com.google.common.collect.Multimap<java.lang.Class<?>,MapComponent> |
mapComponents
The
MapComponents on the map. |
private float |
minimumHeight
The minimum height of the map.
|
private float |
minimumWidth
The minimum width of the map.
|
private double |
time
The time.
|
private float |
width
The width of the map.
|
| Constructor and Description |
|---|
Map()
Creates a map that automatically scales to the items that are added.
|
Map(float width,
float height)
Creates the map with a minimum width and height.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(MapComponent object)
Adds a map component to the map.
|
private void |
checkForAddIssues(MapComponent mapComponent)
Checks if there is an issue by adding a
MapComponent to the map. |
float |
getHeight()
Gets the height of the map.
|
<T> java.util.Collection<T> |
getMapComponents(java.lang.Class<T> className)
Get all
MapComponents that are an instance of a specific class. |
double |
getTime() |
float |
getWidth()
Gets the width of the map.
|
boolean |
isOutOfBounds(Position position)
Check if a
Position is out of map. |
void |
remove(MapComponent mapComponent)
Remove a
MapComponent from the map. |
private void |
updateDimensions()
Updates the dimensions of the map.
|
void |
updateTime(int timeStep)
Update the time.
|
private com.google.common.collect.Multimap<java.lang.Class<?>,MapComponent> mapComponents
MapComponents on the map. The Multimap is used as an
internal representation to quickly find collections of
MapComponents of a specified type. This results in some extra
memory usage, but enables fast access times.private float height
private float width
private final float minimumHeight
private final float minimumWidth
private double time
public Map()
public Map(float width,
float height)
width - The minimum width of the map.height - The minimum height of the map.public void add(MapComponent object)
object - The map component.private void checkForAddIssues(MapComponent mapComponent)
MapComponent to the map.
Throw an exception if there is.mapComponent - The mapComponent.public float getHeight()
public <T> java.util.Collection<T> getMapComponents(java.lang.Class<T> className)
MapComponents that are an instance of a specific class.T - The class instance.className - The class name.Collection of the map components.public double getTime()
public float getWidth()
public boolean isOutOfBounds(Position position)
Position is out of map.position - The position.public void remove(MapComponent mapComponent)
MapComponent from the map.mapComponent - The map component.private void updateDimensions()
public void updateTime(int timeStep)
timeStep - The time step.