Back to index

wims  3.65+svn20090927
CellPoint.java
Go to the documentation of this file.
00001 /*
00002  * @(#)CellPoint.java
00003  *
00004  * $Id: CellPoint.java,v 1.13 2000/12/02 21:44:53 rkc10 Exp $  
00005  *
00006  * Created on October 22, 2000, 4:54 PM
00007  */
00008 
00019 package SharpTools; 
00020 
00021 public class CellPoint implements Comparable {
00023     private int row;
00024 
00026     private int col;
00027 
00034     public CellPoint(int aRow, int aCol) {
00035         row = aRow;
00036         col = aCol;
00037     }
00038     
00044     public int getRow() { return row; }
00045     
00049     public int getCol() { return col; }
00050 
00056     public void setRow(int row) { this.row = row; }
00057     
00063     public void setCol(int col) { this.col = col; }
00064     
00068     public void incrRow(int x) { this.row += x; }
00069     
00073     public void incrCol(int x) { this.col += x; }
00074     
00082     public int compareTo(Object x) {
00083         if (x instanceof CellPoint) {
00084             CellPoint y = (CellPoint)x;
00085             
00086             //by row
00087             if (this.row > y.row) {
00088                 return 1;
00089             }else {
00090                 if (this.row == y.row) {
00091                     
00092                     //by column
00093                     if (this.col > y.col) {
00094                         return 1;
00095                     }else {
00096                         
00097                         //equal
00098                         if (this.col == y.col) {
00099                             return 0;
00100                         }else return -1;
00101                     }
00102                 }else {
00103                     return -1;
00104                 }
00105             }
00106         }else return 2;         /* can't compare non-CellPoint objects */
00107     }
00108     
00116     public boolean equals(Object x) {
00117         if (x instanceof CellPoint) {
00118             CellPoint y = (CellPoint)x;
00119             return ((this.row == y.row) && (this.col == y.col));
00120         }else return false;
00121     }
00122 
00128     public String toString() {
00129        return Node.translateColumn(col)+Node.translateRow(row);
00130     }
00131 }
00132