View Javadoc
1 /* 2 * Copyright (C) 2002-2003, Mark Diggory 3 * 4 * This file is part of the CAGN model project. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. License 19 * information is also available at http://www.gnu.org. 20 * 21 */ 22 package org.mrd.repast.landscape; 23 24 import uchicago.src.sim.gui.*; 25 import uchicago.src.sim.engine.Stepable; 26 27 /*** 28 * Used to supply "standard" methods to Agents 29 * that use the Landscape object. 30 * @author Mark Diggory <mdiggory@latte.harvard.edu> 31 */ 32 public abstract class LandscapeAgent implements Stepable, Drawable{ 33 34 /*** Constant representing an alive LandscapeAgent in the model. Is used to identify 35 * live agents on the landscape 36 */ 37 public static final int ALIVE = 0; 38 39 /*** Constant representing a dead LandscapeAgent in the landscape. Is used to reap 40 * dead agents from the landscape 41 */ 42 public static final int DEAD = -1; 43 44 /*** Holds value of property x (the agents location). */ 45 protected int x; 46 47 /*** Holds value of property y (the agents location). */ 48 protected int y; 49 50 /*** Holds value of property stage. */ 51 protected int stage = ALIVE; 52 53 /*** Holds value of property landscape. */ 54 protected Landscape landscape; 55 56 public LandscapeAgent(Landscape landscape){ 57 this.landscape = landscape; 58 } 59 60 /*** Abstract step() method must be overridden in Agents that 61 * extend this class 62 */ 63 public abstract void step(); 64 65 /*** Abstract draw() method must be overridden in Agents that 66 * extend this class 67 * @param g graphics object to draw this in. 68 */ 69 public abstract void draw(SimGraphics g); 70 71 /*** Setter for property stage. 72 * @param stage New value of property stage. 73 */ 74 public void setStage(int stage) { 75 this.stage = stage; 76 } 77 78 /*** Getter for property stage. 79 * @return Value of property stage. 80 */ 81 public int getStage() { 82 return stage; 83 } 84 85 /*** Getter for property x. 86 * @return Value of property x. 87 */ 88 public int getX() { 89 return this.x; 90 } 91 92 /*** Getter for property y. 93 * @return Value of property y. 94 */ 95 public int getY() { 96 return this.y; 97 } 98 99 /*** Setter for property x. 100 * @param x New value of property x. 101 */ 102 public void setX(int x) { 103 this.x = x; 104 } 105 106 /*** Setter for property y. 107 * @param y New value of property y. 108 */ 109 public void setY(int y) { 110 this.y = y; 111 } 112 113 }

This page was automatically generated by Maven