/** * Elements used in the applet AppletPaint * in order to repaint the image. * * @author Ruedi Hofer * @see AppletPaint.java */ import java.awt.*; import java.lang.*; import java.math.*; public class ArrayListElement { private int _x=0; private int _y=0; private Color _color; public void setElement (int x, int y, Color color) { _x=x; _y=y; _color=color; } public int getX () { return _x; } public int getY () { return _y; } public Color getColor () { return _color; } public String toString () { Integer x=new Integer(getX()); Integer y=new Integer(getY()); return ( x.toString() + " " + y.toString() + " " + getColor().toString().substring(getColor().toString().indexOf("["))); } public boolean equals(Object element) { ArrayListElement ale=(ArrayListElement)element; //System.out.println("compare called for "+ale.getX()+" "+ale.getY()+" "+ale.getColor()); return ((Math.abs(ale.getX()-_x)<4) && (Math.abs(ale.getY()-_y)<4) && ale.getColor()==_color); } }