To load this file without formatting, visit http://whoyouknow.co.uk/ants/java/17.1/src/ants/MyObject.java. This is a spam-protection measure; sorry for the inconvenience.
· MyObject.java ·
1/* 2 * MyObject.java 3 * 4 * Created on 12 October 2006, 22:50 5 * 6 * To change this template, choose Tools | Template Manager 7 * and open the template in the editor. 8 */ 9 10package ants; 11 12import java.awt.Graphics; 13import java.awt.Graphics2D; 14import java.awt.Rectangle; 15import java.awt.event.MouseListener; 16 17/** 18 * 19 * @author James Hamilton 20 */ 21public abstract class MyObject extends Rectangle implements MyObjectInterface { 22 23 private GridSquare gridSquare; 24 25 /** Creates a new instance of MyObject */ 26 public MyObject() { 27 setSize(GridSquare.SIZE, GridSquare.SIZE); 28 } 29 30 public MyObject(GridSquare s) { 31 setGridSquare(s); 32 setSize(s.getSize()); 33 setLocation(s.getLocation()); 34 } 35 36 public void draw(Graphics g) { 37 38 Graphics2D g2d = (Graphics2D)g; 39 40 g2d.setColor( getColor()); 41 42 g2d.fill(this); 43 44 g2d.draw(this); 45 } 46 47 public GridSquare getGridSquare() { 48 return gridSquare; 49 } 50 51 public void setGridSquare(GridSquare gridSquare) { 52 if(this.gridSquare != null) this.gridSquare.setObject(null); 53 this.gridSquare = gridSquare; 54 55 if(gridSquare == null) { 56 setLocation(-99, -99); 57 58 }else{ 59 setLocation(gridSquare.getLocation()); 60// if(this instanceof Ant) 61// gridSquare.setAnt((Ant)this); 62// else 63 gridSquare.setObject(this); 64 } 65 } 66} 67
· MyObject.java ends ·
To load this file without formatting, visit http://whoyouknow.co.uk/ants/java/17.1/src/ants/MyObject.java. This is a spam-protection measure; sorry for the inconvenience.