org.nlogo.agent
Class Link

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

public class Link
extends Agent
implements Link


Field Summary
static int BIT
           
static Double DEFAULT_COLOR
           
 int LAST_PREDEFINED_VAR
           
static String MODE_FIXED
           
static String MODE_FREE
           
static String MODE_NONE
           
 int NUMBER_PREDEFINED_VARS
           
static int VAR_BREED
           
static int VAR_COLOR
           
static int VAR_END1
           
static int VAR_END2
           
static int VAR_LABEL
           
static int VAR_SHAPE
           
static int VAR_THICKNESS
           
static int VAR_TIEMODE
           
 
Fields inherited from class org.nlogo.agent.Agent
id, variables
 
Constructor Summary
Link(World world, Turtle end1, Turtle end2, int arraySize)
           
 
Method Summary
 Object agentKey()
           
 AgentSet bothEnds()
           
 Shape cachedShape()
           
 void cachedShape(Shape newShape)
           
 String classDisplayName()
          Returns a displayable name of this type of agent (Turtle, Link, Patch, Observer)
 Object color()
          Returns the value of the color variable
 void color(LogoList rgb)
           
 void colorDouble(Double boxedColor)
           
 void colorDoubleUnchecked(Double boxedColor)
           
 int compareTo(Agent a)
           
 void die()
           
 Turtle end1()
          Returns the first end point of this link.
 Turtle end2()
          Returns the second end point of this link.
 int getAgentBit()
           
 Class<Link> getAgentClass()
           
 AgentSet getBreed()
          Returns the breed AgentSet associated with this link, if the link is unbreeded returns the all links AgentSet
 int getBreedIndex()
          Returns the index of the breed of this link
 Object getBreedVariable(String name)
           
 Object getLinkBreedVariable(String name)
           
 Object getLinkVariable(int vn)
           
 double getLinkVariableDouble(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
 boolean hasLabel()
          Returns true if there is a value in the label variable
 double heading()
          Returns the heading towards end2 from end1
 boolean hidden()
          Returns the value of the hidden?
 void hidden(boolean hidden)
           
 boolean isDirectedLink()
          Returns true if this link is directed
 boolean isTied()
           
 Object label()
           
 void label(Object label)
           
 Object labelColor()
          Returns the value of the label-color variable
 void labelColor(double labelColor)
           
 void labelColor(LogoList rgb)
           
 String labelString()
          Returns the value of the label variable
 double lineThickness()
          Returns the value of the thinkness variable
 void lineThickness(Double value)
           
 double linkDestinationSize()
          Returns the size of end2
 double midpointX()
          Returns the x-coordinate of the midpoint of this link taking wrapping in account.
 double midpointY()
          Returns the y-coordinate of the midpoint of this link taking wrapping in account.
 String mode()
           
 void mode(String mode)
           
 void setBreed(AgentSet breed)
           
 void setBreedVariable(int vn, double value)
           
 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.
 void shape(String shape)
           
 double size()
          Returns the size of this agent
 String toString()
           
 void untie()
           
 double x1()
          Returns the x-coordinate of end1
 double x2()
          Returns the x-coordinate of end2 this coordinate is "unwrapped" so it may actually be outside the bounds of the world
 double y1()
          Returns the y-coordinate of end1
 double y2()
          Returns the y-coordinate of end2 this coordinate is "unwrapped" so it may actually be outside the bounds of the world
 
Methods inherited from class org.nlogo.agent.Agent
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_END1

public static final int VAR_END1
See Also:
Constant Field Values

VAR_END2

public static final int VAR_END2
See Also:
Constant Field Values

VAR_COLOR

public static final int VAR_COLOR
See Also:
Constant Field Values

VAR_LABEL

public static final int VAR_LABEL
See Also:
Constant Field Values

VAR_BREED

public static final int VAR_BREED
See Also:
Constant Field Values

VAR_THICKNESS

public static final int VAR_THICKNESS
See Also:
Constant Field Values

VAR_SHAPE

public static final int VAR_SHAPE
See Also:
Constant Field Values

VAR_TIEMODE

public static final int VAR_TIEMODE
See Also:
Constant Field Values

LAST_PREDEFINED_VAR

public int LAST_PREDEFINED_VAR

NUMBER_PREDEFINED_VARS

public int NUMBER_PREDEFINED_VARS

DEFAULT_COLOR

public static final Double DEFAULT_COLOR

MODE_NONE

public static final String MODE_NONE
See Also:
Constant Field Values

MODE_FREE

public static final String MODE_FREE
See Also:
Constant Field Values

MODE_FIXED

public static final String MODE_FIXED
See Also:
Constant Field Values

BIT

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

Link

public Link(World world,
            Turtle end1,
            Turtle end2,
            int arraySize)
Method Detail

end1

public Turtle end1()
Description copied from interface: Link
Returns the first end point of this link. If the link is directed this is the source turtle if the link is undirected it is the turtle with the lower who number.

Specified by:
end1 in interface Link

end2

public Turtle end2()
Description copied from interface: Link
Returns the second end point of this link. If the link is directed this is the destination turtle if the link is undirected it is the turtle with the higher who number.

Specified by:
end2 in interface Link

agentKey

public Object agentKey()

die

public void die()

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

getTurtleOrLinkVariable

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

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

getObserverVariable

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

getLinkVariable

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

getLinkVariableDouble

public double getLinkVariableDouble(int vn)

setObserverVariable

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

setTurtleOrLinkVariable

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

setLinkVariable

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

setLinkVariable

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

getTurtleVariable

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

getBreedVariable

public Object getBreedVariable(String name)
                        throws AgentException
Specified by:
getBreedVariable 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

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

setBreedVariable

public void setBreedVariable(int vn,
                             double value)
                      throws AgentException
Throws:
AgentException

setLinkBreedVariable

public void setLinkBreedVariable(String name,
                                 Object value)
                          throws AgentException
Specified by:
setLinkBreedVariable 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

x1

public double x1()
Description copied from interface: Link
Returns the x-coordinate of end1

Specified by:
x1 in interface Link

y1

public double y1()
Description copied from interface: Link
Returns the y-coordinate of end1

Specified by:
y1 in interface Link

x2

public double x2()
Description copied from interface: Link
Returns the x-coordinate of end2 this coordinate is "unwrapped" so it may actually be outside the bounds of the world

Specified by:
x2 in interface Link

y2

public double y2()
Description copied from interface: Link
Returns the y-coordinate of end2 this coordinate is "unwrapped" so it may actually be outside the bounds of the world

Specified by:
y2 in interface Link

midpointX

public double midpointX()
Description copied from interface: Link
Returns the x-coordinate of the midpoint of this link taking wrapping in account.

Specified by:
midpointX in interface Link

midpointY

public double midpointY()
Description copied from interface: Link
Returns the y-coordinate of the midpoint of this link taking wrapping in account.

Specified by:
midpointY in interface Link

heading

public double heading()
Description copied from interface: Link
Returns the heading towards end2 from end1

Specified by:
heading in interface Link

lineThickness

public double lineThickness()
Description copied from interface: Link
Returns the value of the thinkness variable

Specified by:
lineThickness in interface Link

lineThickness

public void lineThickness(Double value)

isDirectedLink

public boolean isDirectedLink()
Description copied from interface: Link
Returns true if this link is directed

Specified by:
isDirectedLink in interface Link

linkDestinationSize

public double linkDestinationSize()
Description copied from interface: Link
Returns the size of end2

Specified by:
linkDestinationSize in interface Link

size

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

Specified by:
size in interface Agent

cachedShape

public Shape cachedShape()

cachedShape

public void cachedShape(Shape newShape)

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

shape

public void shape(String shape)

mode

public String mode()

mode

public void mode(String mode)

isTied

public boolean isTied()

untie

public void untie()

color

public Object color()
Description copied from interface: Link
Returns the value of the color variable

Specified by:
color in interface Link

colorDouble

public void colorDouble(Double boxedColor)

colorDoubleUnchecked

public void colorDoubleUnchecked(Double boxedColor)

color

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

bothEnds

public AgentSet bothEnds()

getPatchAtOffsets

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

label

public Object label()

hasLabel

public boolean hasLabel()
Description copied from interface: Link
Returns true if there is a value in the label variable

Specified by:
hasLabel in interface Link

labelString

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

Specified by:
labelString in interface Link

label

public void label(Object label)

hidden

public boolean hidden()
Description copied from interface: Link
Returns the value of the hidden? variable

Specified by:
hidden in interface Link

hidden

public void hidden(boolean hidden)

getBreed

public AgentSet getBreed()
Description copied from interface: Link
Returns the breed AgentSet associated with this link, if the link is unbreeded returns the all links AgentSet

Specified by:
getBreed in interface Link

labelColor

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

Specified by:
labelColor in interface Link

labelColor

public void labelColor(double labelColor)

labelColor

public void labelColor(LogoList rgb)
                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<Link> getAgentClass()
Specified by:
getAgentClass in class Agent

getAgentBit

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

setBreed

public void setBreed(AgentSet breed)

getBreedIndex

public int getBreedIndex()
Description copied from interface: Link
Returns the index of the breed of this link

Specified by:
getBreedIndex in interface Link

compareTo

public int compareTo(Agent a)
Specified by:
compareTo in interface Comparable<Agent>
Overrides:
compareTo in class Agent