//magnets model
MagnetsModel.java
MagnetSpace.java
MagnetAgent.java
Magnet.java
package magnets2;
// RepastJ -> SymphonyRepast modifications are marked with //SR or /*SR ... */
import java.awt.Color;
//SR import uchicago.src.sim.gui.Drawable;
//SR import uchicago.src.sim.gui.SimGraphics;
// Referenced classes of package magnets2:
// MagnetSpace
public class MagnetAgent
//SR implements Drawable
{
public MagnetAgent(int rad)
{
x = -1;
y = -1;
IDNumber++;
ID = IDNumber;
direction = (int)Math.floor(Math.random() * 6D);
}
public String toString()
{
return s;
}
protected boolean tryMove(int newX, int newY, int rad)
{
return sSpace.moveAgentAt(x, y, newX, newY, direction, rad);
}
/*SR
public void draw(SimGraphics G)
{
if(direction == 0)
G.drawString((new StringBuilder()).append(direction).toString(), Color.black);
if(direction == 1)
G.drawString((new StringBuilder()).append(direction).toString(), Color.black);
if(direction == 2)
G.drawString((new StringBuilder()).append(direction).toString(), Color.black);
if(direction == 3)
G.drawString((new StringBuilder()).append(direction).toString(), Color.black);
if(direction == 4)
G.drawString((new StringBuilder()).append(direction).toString(), Color.black);
if(direction == 5)
G.drawString((new StringBuilder()).append(direction).toString(), Color.black);
}
*/
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public void setXY(int newX, int newY)
{
x = newX;
y = newY;
}
public int getDirection()
{
return direction;
}
public String getS()
{
return s;
}
public void setS(String st)
{
s = st;
}
public void step(int rad)
{
//SR uchicago.src.sim.space.Object2DHexagonalGrid grid = getSSpace().getCurrentMagnetAgentSpace();
tryMove(getX(), getY(), rad);
}
public MagnetSpace getSSpace()
{
return sSpace;
}
public void setSSpace(MagnetSpace space)
{
sSpace = space;
}
public void setDirection(int direction)
{
this.direction = direction;
}
private int x;
private int y;
private static int IDNumber = 0;
private int ID;
private MagnetSpace sSpace;
protected int direction;
private String s;
}
//