home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / Coordinate.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  3.4 KB  |  109 lines

  1. /*
  2.  * Copyright (c) 1997 Krumel & Associates, Inc. All Rights Reserved.
  3.  *
  4.  * www.krumel.com - controls@krumel.com
  5.  *
  6.  * Permission is given to the buyer of this package for one software
  7.  * developer to use this software on one CPU (one workstation) and to make
  8.  * one backup copy.  You may uitilize and/or modify this class for use in your
  9.  * projects.  You may distribute or sell any executable which results from
  10.  * using this code in yur application, except a utility or class of similar
  11.  * nature to this product.  You may distribute this product in compiled
  12.  * form only, but soley to be used with your cmpiled executable product
  13.  * for the puposes of dynamic loading. You may NOT redistribute the source
  14.  * code in any form or make it accessible through a network or other
  15.  * distribution media to others. Please refer to the file "copyright.html"
  16.  * for further important copyright and licensing information.
  17.  *
  18.  * The source code is the confidential and proprietary information
  19.  * of Krumel & Associates, Inc. ("Confidential Information").  You shall
  20.  * not disclose such Confidential Information and shall use it only in
  21.  * accordance with the terms of the license agreement you entered into
  22.  * with Krumel & Associates, Inc..
  23.  
  24.  * KRUMEL & ASSOCIATES MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
  25.  * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
  26.  * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  27.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KRUMEL & ASSOCIATES SHALL NOT
  28.  * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
  29.  * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  30.  */
  31.  
  32. package symantec.itools.db.awt;
  33.  
  34.  
  35. /**
  36.  * This class represents a coordinate in a grid system or rows and columns.
  37.  */
  38. public class Coordinate implements java.io.Serializable {
  39.     /**
  40.      * The row of the coordinate.
  41.      */
  42.     public int row;
  43.     /**
  44.      * The column of the coordinate.
  45.      */
  46.     public int col;
  47.  
  48.     /**
  49.      * Default constructor that creates a coordinate at row=0 and column=0.
  50.      */
  51.     public Coordinate() {}
  52.  
  53.     /**
  54.      * Copy constructor.
  55.      */
  56.     public Coordinate(Coordinate c) {
  57.         this(c.row, c.col);
  58.     }
  59.  
  60.     /**
  61.      * Creates a coordinate that is placed at the specified row and column position.
  62.      * @param r The coordinate row.
  63.      * @param c The coordinate column.
  64.      */
  65.     public Coordinate(int r, int c) {
  66.         row = r;
  67.         col = c;
  68.     }
  69.  
  70.     /**
  71.      * Compares this coordinate with another object and returns true if it is a
  72.      * coordinate with the same points.
  73.      */
  74.     public boolean equals(Object o) {
  75.         if (!(o instanceof Coordinate)) {
  76.             return false;
  77.         }
  78.  
  79.         Coordinate c = (Coordinate)o;
  80.         return row == c.row && col == c.col;
  81.     }
  82.  
  83.     /**
  84.      * Changes the row to a new value.
  85.      */
  86.     public void setRow(int r) { row = r; }
  87.  
  88.     /**
  89.      * Changes the column to a new value.
  90.      */
  91.     public void setCol(int c) { col = c; }
  92.  
  93.     /**
  94.      * Get the row of the coordinate.
  95.      */
  96.     public int row() { return row; }
  97.  
  98.     /**
  99.      * Get the column of the coordinate.
  100.      */
  101.     public int col() { return col; }
  102.  
  103.     /**
  104.      * Gets a string representation of the coordinate.
  105.      */
  106.     public String toString() {
  107.         return "Coordinate: row=" + row + " col=" + col;
  108.     }
  109. }