|
MATES 3.0-rc2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mates.sim.Host
Field Summary | |
protected java.awt.Color |
MOUSEOVER_COLOR
The color of a host when the mouse is held over it in the GUI. |
protected java.awt.Color |
RADIO_RANGE_COLOR
The color of a host's radio range when it is drawn in the GUI. |
protected java.awt.Color |
SELECTED_COLOR
The color of a host when it is selected in the GUI. |
Constructor Summary | |
Host(double x,
double y,
MobilityModel mobilityModel,
Simulator simulator)
Constructs a host without a name. |
|
Host(double x,
double y,
Simulator simulator)
Constructs a host. |
|
Host(java.lang.String name,
double x,
double y,
MobilityModel mobilityModel,
Simulator simulator)
Primary constructor. |
|
Host(java.lang.String name,
double x,
double y,
Simulator simulator)
Constructs a host with a StaticMobilityModel and Position2D position. |
|
Host(java.lang.String name,
Position position,
MobilityModel mobilityModel,
Simulator simulator)
Primary constructor. |
Method Summary | |
void |
addAgent(Agent agent)
Adds an agent to this host. |
boolean |
equals(java.lang.Object o)
|
Agent |
getAgent(UniqueID id)
Returns an agent on this host. |
Agent |
getAgentByName(java.lang.String name)
Returns an agent on this host. |
java.util.Enumeration |
getAgents()
Returns an Enumeration of the agents currently on this host. |
java.awt.Color |
getColor()
Returns the color of this host, if it is to be displayed graphically. |
CPUSchedulingModel |
getCPUSchedulingModel()
Returns this host's CPU scheduling model; |
MobilityModel |
getMobilityModel()
Returns this host's mobility model. |
java.lang.String |
getName()
Returns the name of this host. |
java.util.Vector |
getNeighbors()
Conveniance function that calls getSimulator (). |
java.util.Vector |
getNeighborsICanHear()
Conveniance function that calls getSimulator (). |
Position |
getPosition()
Returns the current position of this host. |
double |
getRadioRange()
Returns the radio range of this host. |
Simulator |
getSimulator()
Returns the simulator in which this host was created. |
UniqueID |
getUniqueID()
Returns the unique identifier for this host. |
int |
hashCode()
|
boolean |
isContaining(int pixel_x,
int pixel_y)
Returns true if a the graphical representation of
this host (as defined by paint(java.awt.Graphics) )
contains the pixel at coordinate (x ,
y ). |
void |
iterate()
Called once per simulator iteration, it is this function's responsibility to schedule processing time for each of the agents currently on this host, respecting the agents' priorities. |
void |
paint(java.awt.Graphics graphics)
Paints this host to a graphics object. |
void |
paintRadioRange(java.awt.Graphics graphics,
boolean mouseover,
boolean selected)
Paints the radio range for this host to a graphics object. |
void |
removeAgent(Agent agent)
Removes an agent from this host. |
void |
setColor(java.awt.Color color)
Sets the color that this host should be displayed if a graphical user interface is chosen. |
void |
setCPUSchedulingModel(CPUSchedulingModel model)
Sets the CPU scheduling model of this host. |
void |
setMobilityModel(MobilityModel model)
Sets the mobility model of this host. |
boolean |
setPosition(Position newPosition)
Sets the position of this host. |
void |
setRadioRange(double radio_range)
Sets the radio range for this host. |
void |
setRadioRangeToDefault()
Sets this host's radio range to the default radio range as defined by the simulator. |
java.lang.String |
toString()
Returns the name of the current host and/or its unique ID. |
void |
updateAgentPriority(Agent agent)
An internal function for updating this host to the fact that one of its agents has updated its priority. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.awt.Color SELECTED_COLOR
protected java.awt.Color MOUSEOVER_COLOR
protected java.awt.Color RADIO_RANGE_COLOR
Constructor Detail |
public Host(java.lang.String name, Position position, MobilityModel mobilityModel, Simulator simulator)
DefaultCPUSchedulingModel
.
name
- a not-necessarily-unique name for this host. This is mostly for debugging and conveniance. This may be null
.position
- the initial position of the hostmobilityModel
- the mobility model this host will usesimulator
- the simulator in which this host will live.public Host(java.lang.String name, double x, double y, MobilityModel mobilityModel, Simulator simulator)
DefaultCPUSchedulingModel
and Position2D
position.
name
- a not-necessarily-unique name for this host. This is mostly for debugging and conveniance. This may be null
.x
- the initial x coordinate of the hosty
- the initial y coordinate of the hostmobilityModel
- the mobility model this host will usesimulator
- the simulator in which this host will live.Host(String, Position, MobilityModel, Simulator)
public Host(java.lang.String name, double x, double y, Simulator simulator)
StaticMobilityModel
and Position2D
position.
name
- a not-necessarily-unique name for this host. This is mostly for debugging and conveniance. This may be null
.x
- the initial x coordinate of the hosty
- the initial y coordinate of the hostsimulator
- the simulator in which this host will live.Host(String, double, double, MobilityModel, Simulator)
public Host(double x, double y, MobilityModel mobilityModel, Simulator simulator)
x
- the initial x coordinate of the hosty
- the initial y coordinate of the hostmobilityModel
- the mobility model this host will usesimulator
- the simulator in which this host will live.Host(String, double, double, MobilityModel, Simulator)
public Host(double x, double y, Simulator simulator)
StaticMobilityModel
.
x
- the initial x coordinate of the hosty
- the initial y coordinate of the hostsimulator
- the simulator in which this host will live.Host(String, double, double, Simulator)
,
Host(double, double, MobilityModel, Simulator)
,
Host(String, double, double, MobilityModel, Simulator)
Method Detail |
public boolean setPosition(Position newPosition)
true
if the new position was valid.Simulator.isValidPosition(Position)
public Position getPosition()
public void iterate()
public java.lang.String getName()
public java.util.Enumeration getAgents()
public double getRadioRange()
public void setRadioRange(double radio_range)
radio_range
- the new radio range for this host.public void setRadioRangeToDefault()
setRadioRange
(
getSimulator
().
getDefaultRadioRange
())
.
public MobilityModel getMobilityModel()
public void setMobilityModel(MobilityModel model)
java.lang.NullPointerException
- when model == null
public CPUSchedulingModel getCPUSchedulingModel()
public void setCPUSchedulingModel(CPUSchedulingModel model)
java.lang.NullPointerException
- when model == null
public void addAgent(Agent agent)
Agent.host
member variable. The effect of this function is
that the agent will now be scheduled execution time during each
call to iterate()
. Also, the agent will not be
added if agent.
isAlive
() returns false
.
public void updateAgentPriority(Agent agent)
Agent.setPriority(int)
.
public void setColor(java.awt.Color color)
public java.awt.Color getColor()
Color.black
.
public void removeAgent(Agent agent)
Agent.host
member variable.
public Agent getAgent(UniqueID id)
null
if the
agent is not present.public Agent getAgentByName(java.lang.String name)
null
if the agent is not present.public UniqueID getUniqueID()
public java.util.Vector getNeighborsICanHear()
getSimulator
().
getTopology
().
getNeighborsHostCanHear
(this)
.
public java.util.Vector getNeighbors()
getSimulator
().
getNeighbors
(this)
.
public Simulator getSimulator()
public void paint(java.awt.Graphics graphics)
graphics
is assumed to have the same dimensions as the domain. This
implementation will paint a filled circle of color getColor()
at this host's current coordinates. This
function is used by TopologyVisualizer
as a callback for
whenever a host needs to be painted.
This function will only work if the host's position is an
instance of Position2D
. If this is not the case,
nothing will be painted. If another type of Position
is to be used, one must extend this class and re-implement this
function.
public void paintRadioRange(java.awt.Graphics graphics, boolean mouseover, boolean selected)
graphics
is assumed to have the same
dimensions as the domain. This implementation will draw a
circle according to getRadioRange()
. The color of
the circle will be set according to SELECTED_COLOR
, MOUSEOVER_COLOR
, and RADIO_RANGE_COLOR
. This function is used by TopologyVisualizer
as a callback for
whenever a radio range needs to be painted.
This function will only work if the host's position is an
instance of Position2D
. If this is not the case,
nothing will be painted. If another type of Position
is to be used, one must extend this class and re-implement this
function.
mouseover
- is true
when the mouse is held over this host in the GUI.selected
- is true
when this host is selected in the GUI.public java.lang.String toString()
public boolean isContaining(int pixel_x, int pixel_y)
true
if a the graphical representation of
this host (as defined by paint(java.awt.Graphics)
)
contains the pixel at coordinate (x
,
y
). This function is used as a callback for
determining a mouse-over when the graphical user interface is
used.
This function will only work if the host's position is an
instance of Position2D
. If this is not the case,
false
will always be returned. If another type of
Position
is to be used, one must extend this class and
re-implement this function.
public int hashCode()
public boolean equals(java.lang.Object o)
|
MATES 3.0-rc2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |