org.nlogo.agent
Class Patch

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

public class Patch
extends Agent
implements Patch


Field Summary
static int BIT
           
static int LAST_PREDEFINED_VAR
           
 int NUMBER_PREDEFINED_VARS
           
 AgentSet patchNeighbors
           
 AgentSet patchNeighbors4
           
 int pxcor
           
 int pycor
           
 List<Turtle> turtlesHere
           
static int VAR_PCOLOR
           
static int VAR_PLABEL
           
static int VAR_PLABELCOLOR
           
static int VAR_PXCOR
           
static int VAR_PYCOR
           
 
Fields inherited from class org.nlogo.agent.Agent
id, variables
 
Method Summary
 String classDisplayName()
          Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer)
 Patch fastGetPatchAt(int x, int y)
           
 int getAgentBit()
           
 Class<Patch> getAgentClass()
           
 Object getBreedVariable(String name)
           
 Object getLinkBreedVariable(String name)
           
 Object getLinkVariable(int vn)
           
 AgentSet getNeighbors()
           
 AgentSet getNeighbors4()
           
 Object getObserverVariable(int vn)
           
 Patch getPatchAtOffsets(double dx, double dy)
          Returns the patch at dx and dy from this patch
 Patch getPatchEast()
           
 Patch getPatchNorth()
           
 Patch getPatchNorthEast()
           
 Patch getPatchNorthWest()
           
 Patch getPatchSouth()
           
 Patch getPatchSouthEast()
           
 Patch getPatchSouthWest()
           
 Object getPatchVariable(int vn)
           
 double getPatchVariableDouble(int vn)
           
 Patch getPatchWest()
           
 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
 boolean hasLabel()
          Returns true if the label variable contains something other than an empty string
 Object label()
           
 void label(Object label)
           
 Object labelColor()
          Returns the value of the label-color variable
 void labelColor(double labelColor)
           
 void labelColor(Double labelColor)
           
 void labelColor(LogoList rgb, int varIndex)
           
 String labelString()
          Returns the value of the label variable
 Object pcolor()
          Returns the value of the pcolor variable
 void pcolor(double pcolor)
           
 void pcolor(Double boxedColor)
           
 void pcolor(LogoList rgb)
           
 void pcolor(LogoList rgb, int varIndex, boolean allowAlpha)
           
 double pcolorDouble()
           
 void pcolorDoubleUnchecked(Double boxedColor)
           
 int pxcor()
          Returns the value of the pxcor variable
 int pycor()
          Returns the value of the pycor variable
 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 setPatchVariable(int vn, double value)
           
 void setPatchVariable(int vn, Object value)
           
 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
 Turtle sprout(int c, int heading, AgentSet breed)
           
 String toString()
           
 
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

VAR_PXCOR

public static final int VAR_PXCOR
See Also:
Constant Field Values

VAR_PYCOR

public static final int VAR_PYCOR
See Also:
Constant Field Values

VAR_PCOLOR

public static final int VAR_PCOLOR
See Also:
Constant Field Values

VAR_PLABEL

public static final int VAR_PLABEL
See Also:
Constant Field Values

VAR_PLABELCOLOR

public static final int VAR_PLABELCOLOR
See Also:
Constant Field Values

LAST_PREDEFINED_VAR

public static final int LAST_PREDEFINED_VAR
See Also:
Constant Field Values

NUMBER_PREDEFINED_VARS

public int NUMBER_PREDEFINED_VARS

turtlesHere

public final List<Turtle> turtlesHere

patchNeighbors

public AgentSet patchNeighbors

patchNeighbors4

public AgentSet patchNeighbors4

pxcor

public final int pxcor

pycor

public final int pycor

BIT

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

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

getLinkVariable

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

getTurtleOrLinkVariable

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

getLinkBreedVariable

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

getBreedVariable

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

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

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

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

setTurtleOrLinkVariable

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

setLinkBreedVariable

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

setVariable

public void setVariable(int vn,
                        Object value)
                 throws AgentException
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

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

getPatchVariable

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

getPatchVariableDouble

public double getPatchVariableDouble(int vn)

getPatchAtOffsets

public Patch getPatchAtOffsets(double dx,
                               double dy)
                        throws AgentException
Description copied from interface: Patch
Returns the patch at dx and dy from this patch

Specified by:
getPatchAtOffsets in interface Patch
Specified by:
getPatchAtOffsets in class Agent
Parameters:
dx - the x offset from this patch
dy - the y offset from this patch
Throws:
AgentException

fastGetPatchAt

public Patch fastGetPatchAt(int x,
                            int y)

getNeighbors

public AgentSet getNeighbors()

getNeighbors4

public AgentSet getNeighbors4()

sprout

public Turtle sprout(int c,
                     int heading,
                     AgentSet breed)

pcolorDouble

public double pcolorDouble()

pcolor

public Object pcolor()
Description copied from interface: Patch
Returns the value of the pcolor variable

Specified by:
pcolor in interface Patch

pcolor

public void pcolor(double pcolor)

pcolor

public void pcolor(Double boxedColor)

pcolorDoubleUnchecked

public void pcolorDoubleUnchecked(Double boxedColor)

pcolor

public void pcolor(LogoList rgb)
            throws AgentException
Throws:
AgentException

pcolor

public void pcolor(LogoList rgb,
                   int varIndex,
                   boolean allowAlpha)
            throws AgentException
Throws:
AgentException

pxcor

public int pxcor()
Description copied from interface: Patch
Returns the value of the pxcor variable

Specified by:
pxcor in interface Patch

pycor

public int pycor()
Description copied from interface: Patch
Returns the value of the pycor variable

Specified by:
pycor in interface Patch

label

public Object label()

hasLabel

public boolean hasLabel()
Description copied from interface: Patch
Returns true if the label variable contains something other than an empty string

Specified by:
hasLabel in interface Patch

labelString

public String labelString()
Description copied from interface: Patch
Returns the value of the label variable

Specified by:
labelString in interface Patch

label

public void label(Object label)

labelColor

public Object labelColor()
Description copied from interface: Patch
Returns the value of the label-color variable

Specified by:
labelColor in interface Patch

labelColor

public void labelColor(double labelColor)

labelColor

public void labelColor(Double labelColor)

labelColor

public void labelColor(LogoList rgb,
                       int varIndex)
                throws AgentException
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<Patch> 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

getPatchNorth

public Patch getPatchNorth()

getPatchSouth

public Patch getPatchSouth()

getPatchEast

public Patch getPatchEast()

getPatchWest

public Patch getPatchWest()

getPatchNorthWest

public Patch getPatchNorthWest()

getPatchSouthWest

public Patch getPatchSouthWest()

getPatchSouthEast

public Patch getPatchSouthEast()

getPatchNorthEast

public Patch getPatchNorthEast()