|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectsimuLCS.Entity
Superclass of all the entities, providing basic functions, but relying a lot on the implementation given by subclasses.
| Field Summary | |
protected java.awt.Color |
color_ext
The color of the border of the entity. |
protected java.awt.Color |
color_int
The color inside the entity. |
protected java.awt.geom.Point2D |
coord
Current position of the entity |
protected java.util.Random |
generator
Pointer to the Random generator |
private int |
id
unique for each entity |
protected java.lang.String |
name
|
private static int |
nbInstances
To obtain the unique id |
protected boolean |
paintName
Boolean which indicates whether or not the name of the Agent should be painted. |
protected int |
size
|
| Constructor Summary | |
Entity()
|
|
| Method Summary | |
void |
clear(java.awt.Graphics2D g,
java.awt.geom.Point2D c)
Clear the drawing of the agent at the indicated coordinates (Basically, a white circle is drawn) |
boolean |
collideWithMe(Agent a)
By default, returns false.
|
double |
distanceTo(java.awt.geom.Point2D p)
Calculates the distance between the CENTER of this entity and another point p. |
java.awt.Color |
getColor_ext()
|
java.awt.Color |
getColor_int()
|
java.awt.geom.Point2D |
getCoord()
|
java.awt.geom.Point2D |
getCoordNearTo(Entity otherEntity)
By default, the closest coordinates of an entity are its normal coordinates. |
int |
getId()
|
java.lang.String |
getName()
|
double |
getRadiusBody()
|
int |
getSize()
|
abstract boolean |
isDangerous()
Should be defined by subclasses |
abstract boolean |
isMoving()
Should be defined by subclasses |
boolean |
isPaintName()
Indicates if the name should be painted |
abstract void |
move(Arena a,
Entity[] others,
int nbEntities,
java.awt.Graphics2D g)
Subclasses must explain how the entity moves. |
void |
paint(java.awt.Graphics2D g)
Paint the entity. |
void |
setColor_ext(java.awt.Color color)
Set the color of the outer circle. |
void |
setColor_int(java.awt.Color color)
Set the color of the inner circle. |
void |
setName(java.lang.String string)
|
void |
setPaintName(boolean b)
Set the parameter paintName to the boolean b. |
void |
setSize(int s)
|
java.lang.String |
toString()
Returns a string describing the Entity. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private static int nbInstances
private int id
protected java.lang.String name
protected java.awt.geom.Point2D coord
protected int size
protected java.util.Random generator
Randomprotected java.awt.Color color_int
protected java.awt.Color color_ext
protected boolean paintName
| Constructor Detail |
public Entity()
| Method Detail |
public void paint(java.awt.Graphics2D g)
public void clear(java.awt.Graphics2D g,
java.awt.geom.Point2D c)
g - Graphicsc - The coordinates where to clear the drawing of the agent.public java.awt.geom.Point2D getCoordNearTo(Entity otherEntity)
public double distanceTo(java.awt.geom.Point2D p)
p - Point2D
public boolean collideWithMe(Agent a)
false.
Should be overriden by subclasses
a -
public abstract boolean isDangerous()
public abstract boolean isMoving()
public abstract void move(Arena a,
Entity[] others,
int nbEntities,
java.awt.Graphics2D g)
a - The Arena inside which to moveg - GraphicsAgentDuck.move(Arena, Entity[], int, Graphics2D),
AgentClassifier.move(Arena, Entity[], int, Graphics2D)public int getId()
public java.lang.String getName()
public void setName(java.lang.String string)
string - public java.awt.geom.Point2D getCoord()
public void setSize(int s)
public int getSize()
public double getRadiusBody()
public java.awt.Color getColor_ext()
public java.awt.Color getColor_int()
public void setColor_ext(java.awt.Color color)
color - public void setColor_int(java.awt.Color color)
color - public boolean isPaintName()
true if it should be painted, false otherwise.paintNamepublic void setPaintName(boolean b)
b - paintNamepublic java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||