org.nlogo.agent
Class Observer

java.lang.Object
  extended by java.util.Observable
      extended by org.nlogo.agent.Agent
          extended by org.nlogo.agent.Observer
All Implemented Interfaces:
Comparable<Agent>, Agent, Observer
Direct Known Subclasses:
Observer3D

public class Observer
extends Agent
implements Observer


Field Summary
static int BIT
           
 
Fields inherited from class org.nlogo.agent.Agent
id, variables
 
Constructor Summary
Observer(World world)
           
 
Method Summary
 void assertVariableConstraint(int vn, Object value)
           
 boolean atHome2D()
           
 boolean atHome3D()
           
 String classDisplayName()
          Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer)
 double dist()
           
 double distance(Agent agent)
           
 double distance(Turtle t)
           
 double dx()
           
 double dy()
           
 double dz()
           
 void face(Agent agent)
           
 void face(double x, double y)
           
 int followDistance()
          Returns the current distance behind the followed turtle the 3D view is displaying
 void followDistance(int followDistance)
           
 double followOffsetX()
           
 double followOffsetY()
           
 int getAgentBit()
           
 Class<Observer> getAgentClass()
           
 Object getBreedVariable(String name)
           
 Object getLinkBreedVariable(String name)
           
 Object getLinkVariable(int vn)
           
 Object getObserverVariable(int vn)
           
 Patch getPatchAtOffsets(double dx, double dy)
           
 Object getPatchVariable(int vn)
           
 Object getTurtleOrLinkVariable(String varName)
           
 Object getTurtleVariable(int vn)
           
 Object getVariable(int vn)
          Returns the value of the variable in the given position of the agent variable array
 double heading()
           
 void heading(double heading)
           
 void home()
           
 void moveto(Agent otherAgent)
           
 void orbitRight(double delta)
           
 void orbitUp(double delta)
           
 double oxcor()
           
 void oxcor(double oxcor)
           
 void oxyandzcor(double oxcor, double oycor, double ozcor)
           
 double oycor()
           
 void oycor(double oycor)
           
 double ozcor()
           
 void ozcor(double ozcor)
           
 Perspective perspective()
          Returns the current perspective
 void perspective(Perspective perspective)
           
 double pitch()
           
 void pitch(double pitch)
           
 void resetPerspective()
           
 double roll()
           
 void roll(double roll)
           
 Vect rotationPoint()
           
 void setBreedVariable(String name, Object value)
           
 void setLinkBreedVariable(String name, Object value)
           
 void setLinkVariable(int vn, double value)
           
 void setLinkVariable(int vn, Object value)
           
 void setObserverVariable(int vn, Object value)
           
 void setOrientation(double heading, double pitch, double roll)
           
 void setPatchVariable(int vn, double value)
           
 void setPatchVariable(int vn, Object value)
           
 void setPerspective(Perspective perspective)
           
 void setPerspective(Perspective perspective, Agent agent)
           
 void setRotationPoint(Agent agent)
           
 void setRotationPoint(double x, double y, double z)
           
 void setRotationPoint(Vect v)
           
 void setTurtleOrLinkVariable(String varName, Object value)
           
 void setTurtleVariable(int vn, double value)
           
 void setTurtleVariable(int vn, Object value)
           
 void setVariable(int vn, Object value)
          Sets the variable in the position vn of the agent variable array to value
 String shape()
          Returns the name of the current shape, empty string in the case of patches.
 double size()
          Returns the size of this agent
 Agent targetAgent()
          Returns the currently watched or followed agent (or nobody)
 void targetAgent(Agent agent)
           
 String toString()
           
 void translate(double thetaX, double thetaY)
           
 boolean updatePosition()
           
 
Methods inherited from class org.nlogo.agent.Agent
compareTo, getVariableCount, id, variableConstraint, variableConstraint, world
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nlogo.api.Agent
id, world
 

Field Detail

BIT

public static final int BIT
See Also:
Constant Field Values
Constructor Detail

Observer

public Observer(World world)
Method Detail

getVariable

public Object getVariable(int vn)
Description copied from interface: Agent
Returns the value of the variable in the given position of the agent variable array

Specified by:
getVariable in interface Agent
Specified by:
getVariable in class Agent
Parameters:
vn - the index into the agent variable array

getObserverVariable

public Object getObserverVariable(int vn)
Specified by:
getObserverVariable in class Agent

getTurtleVariable

public Object getTurtleVariable(int vn)
                         throws AgentException
Specified by:
getTurtleVariable in class Agent
Throws:
AgentException

getTurtleOrLinkVariable

public Object getTurtleOrLinkVariable(String varName)
                               throws AgentException
Specified by:
getTurtleOrLinkVariable in class Agent
Throws:
AgentException

getBreedVariable

public Object getBreedVariable(String name)
                        throws AgentException
Specified by:
getBreedVariable in class Agent
Throws:
AgentException

getLinkVariable

public Object getLinkVariable(int vn)
                       throws AgentException
Specified by:
getLinkVariable in class Agent
Throws:
AgentException

getLinkBreedVariable

public Object getLinkBreedVariable(String name)
                            throws AgentException
Specified by:
getLinkBreedVariable in class Agent
Throws:
AgentException

getPatchVariable

public Object getPatchVariable(int vn)
                        throws AgentException
Specified by:
getPatchVariable in class Agent
Throws:
AgentException

setVariable

public void setVariable(int vn,
                        Object value)
                 throws AgentException,
                        LogoException
Description copied from interface: Agent
Sets the variable in the position vn of the agent variable array to value

Specified by:
setVariable in interface Agent
Specified by:
setVariable in class Agent
Parameters:
vn - the index into the agent variable array
value - the new value for the variable
Throws:
AgentException - If value is the wrong type for the given variable or if you try to change variables that cannot be changed
LogoException

assertVariableConstraint

public void assertVariableConstraint(int vn,
                                     Object value)
                              throws AgentException,
                                     LogoException
Throws:
AgentException
LogoException

setObserverVariable

public void setObserverVariable(int vn,
                                Object value)
                         throws AgentException,
                                LogoException
Specified by:
setObserverVariable in class Agent
Throws:
AgentException
LogoException

setTurtleVariable

public void setTurtleVariable(int vn,
                              Object value)
                       throws AgentException
Specified by:
setTurtleVariable in class Agent
Throws:
AgentException

setTurtleVariable

public void setTurtleVariable(int vn,
                              double value)
                       throws AgentException
Specified by:
setTurtleVariable in class Agent
Throws:
AgentException

setBreedVariable

public void setBreedVariable(String name,
                             Object value)
                      throws AgentException
Specified by:
setBreedVariable in class Agent
Throws:
AgentException

setPatchVariable

public void setPatchVariable(int vn,
                             Object value)
                      throws AgentException
Specified by:
setPatchVariable in class Agent
Throws:
AgentException

setPatchVariable

public void setPatchVariable(int vn,
                             double value)
                      throws AgentException
Specified by:
setPatchVariable in class Agent
Throws:
AgentException

setLinkVariable

public void setLinkVariable(int vn,
                            Object value)
                     throws AgentException
Specified by:
setLinkVariable in class Agent
Throws:
AgentException

setLinkVariable

public void setLinkVariable(int vn,
                            double value)
                     throws AgentException
Specified by:
setLinkVariable in class Agent
Throws:
AgentException

setLinkBreedVariable

public void setLinkBreedVariable(String name,
                                 Object value)
                          throws AgentException
Specified by:
setLinkBreedVariable in class Agent
Throws:
AgentException

setTurtleOrLinkVariable

public void setTurtleOrLinkVariable(String varName,
                                    Object value)
                             throws AgentException
Specified by:
setTurtleOrLinkVariable in class Agent
Throws:
AgentException

perspective

public Perspective perspective()
Description copied from interface: Observer
Returns the current perspective

Specified by:
perspective in interface Observer

perspective

public void perspective(Perspective perspective)

targetAgent

public Agent targetAgent()
Description copied from interface: Observer
Returns the currently watched or followed agent (or nobody)

Specified by:
targetAgent in interface Observer

targetAgent

public void targetAgent(Agent agent)

oxcor

public double oxcor()
Specified by:
oxcor in interface Observer

oxcor

public void oxcor(double oxcor)

oycor

public double oycor()
Specified by:
oycor in interface Observer

oycor

public void oycor(double oycor)

ozcor

public double ozcor()
Specified by:
ozcor in interface Observer

ozcor

public void ozcor(double ozcor)

followOffsetX

public double followOffsetX()

followOffsetY

public double followOffsetY()

heading

public double heading()
Specified by:
heading in interface Observer

heading

public void heading(double heading)

pitch

public double pitch()
Specified by:
pitch in interface Observer

pitch

public void pitch(double pitch)

roll

public double roll()
Specified by:
roll in interface Observer

roll

public void roll(double roll)

dist

public double dist()
Specified by:
dist in interface Observer

setRotationPoint

public void setRotationPoint(Vect v)

setRotationPoint

public void setRotationPoint(double x,
                             double y,
                             double z)

setRotationPoint

public void setRotationPoint(Agent agent)

rotationPoint

public Vect rotationPoint()

followDistance

public int followDistance()
Description copied from interface: Observer
Returns the current distance behind the followed turtle the 3D view is displaying

Specified by:
followDistance in interface Observer

followDistance

public void followDistance(int followDistance)

oxyandzcor

public void oxyandzcor(double oxcor,
                       double oycor,
                       double ozcor)

setOrientation

public void setOrientation(double heading,
                           double pitch,
                           double roll)

dx

public double dx()
Specified by:
dx in interface Observer

dy

public double dy()
Specified by:
dy in interface Observer

dz

public double dz()
Specified by:
dz in interface Observer

face

public void face(Agent agent)

face

public void face(double x,
                 double y)

moveto

public void moveto(Agent otherAgent)
            throws AgentException
Throws:
AgentException

setPerspective

public void setPerspective(Perspective perspective,
                           Agent agent)
Specified by:
setPerspective in interface Observer

setPerspective

public void setPerspective(Perspective perspective)

updatePosition

public boolean updatePosition()

distance

public double distance(Agent agent)

distance

public double distance(Turtle t)

resetPerspective

public void resetPerspective()

home

public void home()

atHome2D

public boolean atHome2D()

atHome3D

public boolean atHome3D()

getPatchAtOffsets

public Patch getPatchAtOffsets(double dx,
                               double dy)
                        throws AgentException
Specified by:
getPatchAtOffsets in class Agent
Throws:
AgentException

toString

public String toString()
Overrides:
toString in class Object

classDisplayName

public String classDisplayName()
Description copied from interface: Agent
Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer)

Specified by:
classDisplayName in interface Agent
Specified by:
classDisplayName in class Agent

getAgentClass

public Class<Observer> getAgentClass()
Specified by:
getAgentClass in class Agent

getAgentBit

public int getAgentBit()
Specified by:
getAgentBit in class Agent

shape

public String shape()
Description copied from interface: Agent
Returns the name of the current shape, empty string in the case of patches.

Specified by:
shape in interface Agent

size

public double size()
Description copied from interface: Agent
Returns the size of this agent

Specified by:
size in interface Agent

orbitRight

public void orbitRight(double delta)

orbitUp

public void orbitUp(double delta)

translate

public void translate(double thetaX,
                      double thetaY)