|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsema.Box
Square box. It's the pavement of the Map, used to draw the ground.
But it is also used as a hashtable, to detect the presence of Elements
in a given area of the map, without examining each element of the world. This is very
useful for the computations linked to collisions, or to searche for elements in an area of the world.
Is it typically used by the main application to refresh
the drawing without unuseful computations (ZGCarteSEMA.paintComponent(Graphics)).
| Field Summary | |
protected Drawing |
g
|
protected java.awt.Image |
image
|
protected Map |
map
|
int |
x
the x-coordinate ( in the boxes' matrix 0 is at the left) |
int |
y
the y-coordinate ( in the boxes' matrix 0 is at the top) |
| Constructor Summary | |
Box(Map map,
Drawing drawing,
int x,
int y,
float height,
java.lang.String kind,
java.awt.Image image)
Constructs a Box.
|
|
| Method Summary | |
void |
draw()
Draws the Box.
|
void |
drawBorder(java.awt.Color c)
|
void |
fill(java.awt.Color c)
|
java.util.TreeSet |
getContents()
Returns the registered Elements in the Box.
|
float |
getHeight()
Returns the height. |
javax.swing.Icon |
getIcon()
Returns the associated icon. |
java.awt.Image |
getImage()
Returns the associated image (main image used to create icon and to draw the default) |
java.lang.String |
getKind()
Returns the kind. |
java.lang.String[][] |
getProperties()
Returns the box's properties. |
void |
highlight()
Highlight the Box (used when the box is selected)
With the default blue color for a box. |
void |
highlight(java.awt.Color c)
Highlight the Box. |
boolean |
isFreeFor(Element el)
Determinate whether the Box can host the Element.
|
void |
register(Element element)
Register an Element in the Box.
|
void |
setProperties(java.lang.String property,
java.lang.String value)
Try to sets the value to the property of the box. |
void |
unregister(Element element)
Unregister an element from the Box.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Map map
protected Drawing g
public final int x
public final int y
protected java.awt.Image image
| Constructor Detail |
public Box(Map map,
Drawing drawing,
int x,
int y,
float height,
java.lang.String kind,
java.awt.Image image)
Box.
With his containing Map, his matrix coordinates, his height, his kind, and a main image.
map - the map containing it.drawing - the drawing object of the simulation.x - the x-coordinate ( in the matrix of boxes, 0 is at the left)y - the x-coordinate ( in the matrix of boxes, 0 is at the top)height - the height.kind - the kind.image - The main image, used to draw itself and to create the icon.Map,
Drawing| Method Detail |
public float getHeight()
public java.lang.String getKind()
public java.awt.Image getImage()
public java.util.TreeSet getContents()
Elements in the Box.
It returns a copy of the treeSet so that no external modification could be made.
Elements in the Box.public boolean isFreeFor(Element el)
Box can host the Element.
Very useful to design obstacles or restricted areas.
However, some special agents could ignore the advice of the box.
el - the element to host.
Box can host the Element.public void register(Element element)
Element in the Box.
The call to this method should be made by : Area.getIntersectedBoxes().
element - the element to register.public void unregister(Element element)
Box.
The call to this method should be made by Area.getIntersectedBoxes() or Element.death().
element - the element to unregister.public javax.swing.Icon getIcon()
Iconpublic void draw()
Box.
if the image is set it draw the image.
public void fill(java.awt.Color c)
public void drawBorder(java.awt.Color c)
public void highlight(java.awt.Color c)
Box.
public void highlight()
Box (used when the box is selected)
With the default blue color for a box.
public java.lang.String[][] getProperties()
Engine.getProperties()
public void setProperties(java.lang.String property,
java.lang.String value)
property - the property to change.value - the new value for the property.Engine.setProperties(java.lang.String, java.lang.String)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||