affyfusion-109/src/affymetrix/calvin/utils/GridCoords.java

Code
Comments
Other
Rev Date Author Line
11 13 Sep 07 nicklas 1 /////////////////////////////////////////////////////////////////
11 13 Sep 07 nicklas 2 //
11 13 Sep 07 nicklas 3 // Copyright (C) 2005 Affymetrix, Inc.
11 13 Sep 07 nicklas 4 //
11 13 Sep 07 nicklas 5 // This library is free software; you can redistribute it and/or modify
11 13 Sep 07 nicklas 6 // it under the terms of the GNU Lesser General Public License as published
11 13 Sep 07 nicklas 7 // by the Free Software Foundation; either version 2.1 of the License,
11 13 Sep 07 nicklas 8 // or (at your option) any later version.
11 13 Sep 07 nicklas 9 //
11 13 Sep 07 nicklas 10 // This library is distributed in the hope that it will be useful, but
11 13 Sep 07 nicklas 11 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 13 Sep 07 nicklas 12 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 13 Sep 07 nicklas 13 // for more details.
11 13 Sep 07 nicklas 14 //
11 13 Sep 07 nicklas 15 // You should have received a copy of the GNU Lesser General Public License
11 13 Sep 07 nicklas 16 // along with this library; if not, write to the Free Software Foundation, Inc.,
11 13 Sep 07 nicklas 17 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11 13 Sep 07 nicklas 18 //
11 13 Sep 07 nicklas 19 /////////////////////////////////////////////////////////////////
11 13 Sep 07 nicklas 20
11 13 Sep 07 nicklas 21 package affymetrix.calvin.utils;
11 13 Sep 07 nicklas 22
11 13 Sep 07 nicklas 23 /** Defines an integral rectagle */
11 13 Sep 07 nicklas 24 public class GridCoords {
11 13 Sep 07 nicklas 25         
11 13 Sep 07 nicklas 26     /** Creates a new instance of GridCoords */
11 13 Sep 07 nicklas 27     public GridCoords() {
11 13 Sep 07 nicklas 28         clear();
11 13 Sep 07 nicklas 29     }
11 13 Sep 07 nicklas 30
11 13 Sep 07 nicklas 31     /** Clears the members. */
11 13 Sep 07 nicklas 32     private void clear() {
11 13 Sep 07 nicklas 33         upperleft = new Point();        
11 13 Sep 07 nicklas 34         upperright = new Point();        
11 13 Sep 07 nicklas 35         lowerright = new Point();        
11 13 Sep 07 nicklas 36         lowerleft = new Point();
11 13 Sep 07 nicklas 37     }
11 13 Sep 07 nicklas 38
11 13 Sep 07 nicklas 39     /** Cast constructor from FRegion.
11 13 Sep 07 nicklas 40      * @param r The region of 4 coordinates.
11 13 Sep 07 nicklas 41      */
11 13 Sep 07 nicklas 42     public GridCoords(Region r) {
11 13 Sep 07 nicklas 43         upperleft = new Point(r.elementAt(RectanglePositions.UpperLeft));
11 13 Sep 07 nicklas 44         upperright = new Point(r.elementAt(RectanglePositions.UpperRight));
11 13 Sep 07 nicklas 45         lowerright = new Point(r.elementAt(RectanglePositions.LowerRight));
11 13 Sep 07 nicklas 46         lowerleft = new Point(r.elementAt(RectanglePositions.LowerLeft));
11 13 Sep 07 nicklas 47     }
11 13 Sep 07 nicklas 48
11 13 Sep 07 nicklas 49     /** Return a region
11 13 Sep 07 nicklas 50      * @return A region defined by the grid coordinates.
11 13 Sep 07 nicklas 51      */
11 13 Sep 07 nicklas 52     public Region getRegion() {
11 13 Sep 07 nicklas 53         Region r = new Region();
11 13 Sep 07 nicklas 54         r.setSize(4);
11 13 Sep 07 nicklas 55         r.set(RectanglePositions.UpperLeft, new Point(upperleft));
11 13 Sep 07 nicklas 56         r.set(RectanglePositions.UpperRight, new Point(upperright));
11 13 Sep 07 nicklas 57         r.set(RectanglePositions.LowerRight, new Point(lowerright));
11 13 Sep 07 nicklas 58         r.set(RectanglePositions.LowerLeft, new Point(lowerleft));
11 13 Sep 07 nicklas 59         return r;
11 13 Sep 07 nicklas 60     }
11 13 Sep 07 nicklas 61
11 13 Sep 07 nicklas 62     /** Tests if the rectangle is empty */
11 13 Sep 07 nicklas 63     public boolean isEmpty() {
11 13 Sep 07 nicklas 64         if (upperleft == null || upperright == null || lowerright == null || lowerleft == null)
11 13 Sep 07 nicklas 65             return true;
11 13 Sep 07 nicklas 66         else if (upperleft.equals(upperright) && lowerleft.equals(lowerright) && upperleft.equals(lowerleft))
11 13 Sep 07 nicklas 67             return true;
11 13 Sep 07 nicklas 68         return false;
11 13 Sep 07 nicklas 69     }
11 13 Sep 07 nicklas 70
11 13 Sep 07 nicklas 71     /** The upper left coordinate */
11 13 Sep 07 nicklas 72     private Point upperleft;
11 13 Sep 07 nicklas 73     
11 13 Sep 07 nicklas 74     /** Gets the upper left coordinate */
11 13 Sep 07 nicklas 75     public Point getUpperLeft() { return upperleft; }
11 13 Sep 07 nicklas 76
11 13 Sep 07 nicklas 77     /** Sets the upper left coordinate */
11 13 Sep 07 nicklas 78     public void setUpperLeft(Point pt) { upperleft=pt; }
11 13 Sep 07 nicklas 79
11 13 Sep 07 nicklas 80     /** The upper right coordinate */
11 13 Sep 07 nicklas 81     private Point upperright;
11 13 Sep 07 nicklas 82
11 13 Sep 07 nicklas 83     /** Gets the upper Right coordinate */
11 13 Sep 07 nicklas 84     public Point getUpperRight() { return upperright; }
11 13 Sep 07 nicklas 85
11 13 Sep 07 nicklas 86     /** Sets the upper Right coordinate */
11 13 Sep 07 nicklas 87     public void setUpperRight(Point pt) { upperright=pt; }
11 13 Sep 07 nicklas 88
11 13 Sep 07 nicklas 89     /** The lower right coordinate */
11 13 Sep 07 nicklas 90     private Point lowerright;
11 13 Sep 07 nicklas 91
11 13 Sep 07 nicklas 92     /** Gets the upper left coordinate */
11 13 Sep 07 nicklas 93     public Point getLowerRight() { return lowerright; }
11 13 Sep 07 nicklas 94
11 13 Sep 07 nicklas 95     /** Sets the upper left coordinate */
11 13 Sep 07 nicklas 96     public void setLowerRight(Point pt) { lowerright=pt; }
11 13 Sep 07 nicklas 97
11 13 Sep 07 nicklas 98     /** The lower left coordinate */
11 13 Sep 07 nicklas 99     private Point lowerleft;
11 13 Sep 07 nicklas 100
11 13 Sep 07 nicklas 101     /** Gets the lower left coordinate */
11 13 Sep 07 nicklas 102     public Point getLowerLeft() { return lowerleft; }
11 13 Sep 07 nicklas 103
11 13 Sep 07 nicklas 104     /** Sets the lower left coordinate */
11 13 Sep 07 nicklas 105     public void setLowerLeft(Point pt) { lowerleft=pt; }
11 13 Sep 07 nicklas 106 }