affyfusion-109/src/affymetrix/calvin/utils/FGridCoords.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
11 13 Sep 07 nicklas 22 package affymetrix.calvin.utils;
11 13 Sep 07 nicklas 23
11 13 Sep 07 nicklas 24 /** Defines a floating point grid coords */
11 13 Sep 07 nicklas 25 public class FGridCoords {
11 13 Sep 07 nicklas 26     
11 13 Sep 07 nicklas 27     /** Creates a new instance of FGridCoords */
11 13 Sep 07 nicklas 28     public FGridCoords() {
11 13 Sep 07 nicklas 29         clear();
11 13 Sep 07 nicklas 30     }
11 13 Sep 07 nicklas 31     
11 13 Sep 07 nicklas 32     /** Clears the members. */
11 13 Sep 07 nicklas 33     private void clear() {
11 13 Sep 07 nicklas 34         upperleft = new FPoint();        
11 13 Sep 07 nicklas 35         upperright = new FPoint();        
11 13 Sep 07 nicklas 36         lowerright = new FPoint();        
11 13 Sep 07 nicklas 37         lowerleft = new FPoint();
11 13 Sep 07 nicklas 38     }
11 13 Sep 07 nicklas 39
11 13 Sep 07 nicklas 40     /** Cast constructor from FRegion.
11 13 Sep 07 nicklas 41      * @param r The region of 4 coordinates.
11 13 Sep 07 nicklas 42      */
11 13 Sep 07 nicklas 43     public FGridCoords(FRegion r) {
11 13 Sep 07 nicklas 44         upperleft = new FPoint(r.elementAt(RectanglePositions.UpperLeft));
11 13 Sep 07 nicklas 45         upperright = new FPoint(r.elementAt(RectanglePositions.UpperRight));
11 13 Sep 07 nicklas 46         lowerright = new FPoint(r.elementAt(RectanglePositions.LowerRight));
11 13 Sep 07 nicklas 47         lowerleft = new FPoint(r.elementAt(RectanglePositions.LowerLeft));
11 13 Sep 07 nicklas 48     }
11 13 Sep 07 nicklas 49
11 13 Sep 07 nicklas 50     /** Return a region
11 13 Sep 07 nicklas 51      * @return A region defined by the grid coordinates.
11 13 Sep 07 nicklas 52      */
11 13 Sep 07 nicklas 53     public FRegion getRegion() {
11 13 Sep 07 nicklas 54         FRegion r = new FRegion();
11 13 Sep 07 nicklas 55         r.setSize(4);
11 13 Sep 07 nicklas 56         r.set(RectanglePositions.UpperLeft, new FPoint(upperleft));
11 13 Sep 07 nicklas 57         r.set(RectanglePositions.UpperRight, new FPoint(upperright));
11 13 Sep 07 nicklas 58         r.set(RectanglePositions.LowerRight, new FPoint(lowerright));
11 13 Sep 07 nicklas 59         r.set(RectanglePositions.LowerLeft, new FPoint(lowerleft));
11 13 Sep 07 nicklas 60         return r;
11 13 Sep 07 nicklas 61     }
11 13 Sep 07 nicklas 62
11 13 Sep 07 nicklas 63     /** Tests if the rectangle is empty */
11 13 Sep 07 nicklas 64     public boolean isEmpty() {
11 13 Sep 07 nicklas 65         if (upperleft == null || upperright == null || lowerright == null || lowerleft == null)
11 13 Sep 07 nicklas 66             return true;
11 13 Sep 07 nicklas 67         else if (upperleft.equals(upperright) && lowerleft.equals(lowerright) && upperleft.equals(lowerleft))
11 13 Sep 07 nicklas 68             return true;
11 13 Sep 07 nicklas 69         return false;
11 13 Sep 07 nicklas 70     }
11 13 Sep 07 nicklas 71
11 13 Sep 07 nicklas 72     /** The upper left coordinate */
11 13 Sep 07 nicklas 73     private FPoint upperleft;
11 13 Sep 07 nicklas 74     
11 13 Sep 07 nicklas 75     /** Gets the upper left coordinate */
11 13 Sep 07 nicklas 76     public FPoint getUpperLeft() { return upperleft; }
11 13 Sep 07 nicklas 77
11 13 Sep 07 nicklas 78     /** Sets the upper left coordinate */
11 13 Sep 07 nicklas 79     public void setUpperLeft(FPoint pt) { upperleft=pt; }
11 13 Sep 07 nicklas 80
11 13 Sep 07 nicklas 81     /** The upper right coordinate */
11 13 Sep 07 nicklas 82     private FPoint upperright;
11 13 Sep 07 nicklas 83
11 13 Sep 07 nicklas 84     /** Gets the upper Right coordinate */
11 13 Sep 07 nicklas 85     public FPoint getUpperRight() { return upperright; }
11 13 Sep 07 nicklas 86
11 13 Sep 07 nicklas 87     /** Sets the upper Right coordinate */
11 13 Sep 07 nicklas 88     public void setUpperRight(FPoint pt) { upperright=pt; }
11 13 Sep 07 nicklas 89
11 13 Sep 07 nicklas 90     /** The lower right coordinate */
11 13 Sep 07 nicklas 91     private FPoint lowerright;
11 13 Sep 07 nicklas 92
11 13 Sep 07 nicklas 93     /** Gets the upper left coordinate */
11 13 Sep 07 nicklas 94     public FPoint getLowerRight() { return lowerright; }
11 13 Sep 07 nicklas 95
11 13 Sep 07 nicklas 96     /** Sets the upper left coordinate */
11 13 Sep 07 nicklas 97     public void setLowerRight(FPoint pt) { lowerright=pt; }
11 13 Sep 07 nicklas 98
11 13 Sep 07 nicklas 99     /** The lower left coordinate */
11 13 Sep 07 nicklas 100     private FPoint lowerleft;
11 13 Sep 07 nicklas 101
11 13 Sep 07 nicklas 102     /** Gets the lower left coordinate */
11 13 Sep 07 nicklas 103     public FPoint getLowerLeft() { return lowerleft; }
11 13 Sep 07 nicklas 104
11 13 Sep 07 nicklas 105     /** Sets the lower left coordinate */
11 13 Sep 07 nicklas 106     public void setLowerLeft(FPoint pt) { lowerleft=pt; }
11 13 Sep 07 nicklas 107     
11 13 Sep 07 nicklas 108 }