1060 |
05 Aug 05 |
enell |
1 |
/* |
1060 |
05 Aug 05 |
enell |
$Id$ |
1060 |
05 Aug 05 |
enell |
3 |
|
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Johan Enell, Nicklas Nordborg |
4889 |
06 Apr 09 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
1060 |
05 Aug 05 |
enell |
6 |
|
2304 |
22 May 06 |
jari |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
Available at http://base.thep.lu.se/ |
1060 |
05 Aug 05 |
enell |
9 |
|
1060 |
05 Aug 05 |
enell |
BASE is free software; you can redistribute it and/or |
1060 |
05 Aug 05 |
enell |
modify it under the terms of the GNU General Public License |
4479 |
05 Sep 08 |
jari |
as published by the Free Software Foundation; either version 3 |
1060 |
05 Aug 05 |
enell |
of the License, or (at your option) any later version. |
1060 |
05 Aug 05 |
enell |
14 |
|
1060 |
05 Aug 05 |
enell |
BASE is distributed in the hope that it will be useful, |
1060 |
05 Aug 05 |
enell |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1060 |
05 Aug 05 |
enell |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1060 |
05 Aug 05 |
enell |
GNU General Public License for more details. |
1060 |
05 Aug 05 |
enell |
19 |
|
1060 |
05 Aug 05 |
enell |
You should have received a copy of the GNU General Public License |
4517 |
11 Sep 08 |
jari |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
1060 |
05 Aug 05 |
enell |
22 |
*/ |
1060 |
05 Aug 05 |
enell |
23 |
package net.sf.basedb.core; |
1060 |
05 Aug 05 |
enell |
24 |
|
1060 |
05 Aug 05 |
enell |
25 |
/** |
2459 |
30 Jun 06 |
nicklas |
Represents the coordinate of a feature on an array design. One coordinate |
2459 |
30 Jun 06 |
nicklas |
is equal to another if the row and column match and if either the block number |
2459 |
30 Jun 06 |
nicklas |
(if it is non-zero) or the meta row and meta column (if the block is zero) match. |
2459 |
30 Jun 06 |
nicklas |
29 |
|
1060 |
05 Aug 05 |
enell |
@base.modified $Date$ |
1143 |
29 Aug 05 |
nicklas |
@author Enell, Nicklas |
1060 |
05 Aug 05 |
enell |
@version 2.0 |
1060 |
05 Aug 05 |
enell |
33 |
*/ |
1060 |
05 Aug 05 |
enell |
34 |
public class FeatureCoordinate |
1060 |
05 Aug 05 |
enell |
35 |
{ |
2459 |
30 Jun 06 |
nicklas |
36 |
|
2459 |
30 Jun 06 |
nicklas |
37 |
private final int block; |
2459 |
30 Jun 06 |
nicklas |
38 |
|
2459 |
30 Jun 06 |
nicklas |
39 |
private final int metaRow; |
2459 |
30 Jun 06 |
nicklas |
40 |
|
2459 |
30 Jun 06 |
nicklas |
41 |
private final int metaColumn; |
2459 |
30 Jun 06 |
nicklas |
42 |
|
1060 |
05 Aug 05 |
enell |
43 |
/** |
1060 |
05 Aug 05 |
enell |
The row of this feature. |
1060 |
05 Aug 05 |
enell |
45 |
*/ |
2459 |
30 Jun 06 |
nicklas |
46 |
private final int row; |
1060 |
05 Aug 05 |
enell |
47 |
/** |
1060 |
05 Aug 05 |
enell |
The column of this feature. |
1060 |
05 Aug 05 |
enell |
49 |
*/ |
2459 |
30 Jun 06 |
nicklas |
50 |
private final int column; |
1060 |
05 Aug 05 |
enell |
51 |
|
1060 |
05 Aug 05 |
enell |
52 |
/** |
1143 |
29 Aug 05 |
nicklas |
Create new object with the specified row and column. |
4034 |
05 Dec 07 |
martin |
@param block Block number the feature belongs to. |
4034 |
05 Dec 07 |
martin |
@param metaRow Meta row number |
4034 |
05 Dec 07 |
martin |
@param metaColumn Meta column number |
4034 |
05 Dec 07 |
martin |
@param row Row number of the feature |
4034 |
05 Dec 07 |
martin |
@param column Column number of the feature. |
1060 |
05 Aug 05 |
enell |
59 |
*/ |
2751 |
20 Oct 06 |
nicklas |
60 |
public FeatureCoordinate(Integer block, Integer metaRow, Integer metaColumn, Integer row, Integer column) |
1060 |
05 Aug 05 |
enell |
61 |
{ |
2751 |
20 Oct 06 |
nicklas |
62 |
this.block = block == null ? 0 : block.intValue(); |
2751 |
20 Oct 06 |
nicklas |
63 |
this.metaRow = metaRow == null ? 0 : metaRow.intValue(); |
2751 |
20 Oct 06 |
nicklas |
64 |
this.metaColumn = metaColumn == null ? 0 : metaColumn.intValue(); |
2751 |
20 Oct 06 |
nicklas |
65 |
this.row = row == null ? 0 : row.intValue(); |
2751 |
20 Oct 06 |
nicklas |
66 |
this.column = column == null ? 0 : column.intValue(); |
1060 |
05 Aug 05 |
enell |
67 |
} |
1060 |
05 Aug 05 |
enell |
68 |
|
1060 |
05 Aug 05 |
enell |
69 |
/* |
1060 |
05 Aug 05 |
enell |
From the Object class |
1060 |
05 Aug 05 |
enell |
71 |
------------------------------------------- |
1060 |
05 Aug 05 |
enell |
72 |
*/ |
1060 |
05 Aug 05 |
enell |
73 |
/** |
1060 |
05 Aug 05 |
enell |
Check if this object is equal to another <code>FeatureCoordinate</code> |
2542 |
17 Aug 06 |
nicklas |
object. For non-zero block number they are equal if the block, row and column |
2542 |
17 Aug 06 |
nicklas |
match, otherwise they are equal if the metarow, metacolumn, row and column |
2542 |
17 Aug 06 |
nicklas |
match. |
1060 |
05 Aug 05 |
enell |
78 |
*/ |
6127 |
14 Sep 12 |
nicklas |
79 |
@Override |
1060 |
05 Aug 05 |
enell |
80 |
public boolean equals(Object o) |
1060 |
05 Aug 05 |
enell |
81 |
{ |
1060 |
05 Aug 05 |
enell |
82 |
if ((o == null) || (getClass() != o.getClass())) return false; |
1060 |
05 Aug 05 |
enell |
83 |
FeatureCoordinate fc = (FeatureCoordinate)o; |
2542 |
17 Aug 06 |
nicklas |
84 |
return (this.row == fc.row) && (this.column == fc.column) && this.block == fc.block && |
2542 |
17 Aug 06 |
nicklas |
85 |
(this.block != 0 || (this.metaRow == fc.metaRow && this.metaColumn == fc.metaColumn)); |
1060 |
05 Aug 05 |
enell |
86 |
} |
1060 |
05 Aug 05 |
enell |
87 |
|
1060 |
05 Aug 05 |
enell |
88 |
/** |
1060 |
05 Aug 05 |
enell |
Calculate the hash code for the object. |
1060 |
05 Aug 05 |
enell |
90 |
*/ |
6127 |
14 Sep 12 |
nicklas |
91 |
@Override |
1060 |
05 Aug 05 |
enell |
92 |
public int hashCode() |
1060 |
05 Aug 05 |
enell |
93 |
{ |
2542 |
17 Aug 06 |
nicklas |
94 |
return 89 * row + 53 * column + (block != 0 ? 37 * block : 17 * metaRow + 7 * metaColumn); |
1060 |
05 Aug 05 |
enell |
95 |
} |
1060 |
05 Aug 05 |
enell |
96 |
|
1060 |
05 Aug 05 |
enell |
97 |
/** |
2459 |
30 Jun 06 |
nicklas |
Get the coordinate as [block, row, column] or |
2459 |
30 Jun 06 |
nicklas |
[metarow, metacolumn, row, column] |
1060 |
05 Aug 05 |
enell |
100 |
*/ |
6127 |
14 Sep 12 |
nicklas |
101 |
@Override |
1060 |
05 Aug 05 |
enell |
102 |
public String toString() |
1060 |
05 Aug 05 |
enell |
103 |
{ |
2459 |
30 Jun 06 |
nicklas |
104 |
if (block == 0) |
2459 |
30 Jun 06 |
nicklas |
105 |
{ |
2459 |
30 Jun 06 |
nicklas |
106 |
return "[" + metaRow + ", " + metaColumn + ", " + row + ", " + column + "]"; |
2459 |
30 Jun 06 |
nicklas |
107 |
} |
2459 |
30 Jun 06 |
nicklas |
108 |
else |
2459 |
30 Jun 06 |
nicklas |
109 |
{ |
2459 |
30 Jun 06 |
nicklas |
110 |
return "[" + block + ", " + row + ", " + column + "]"; |
2459 |
30 Jun 06 |
nicklas |
111 |
} |
1060 |
05 Aug 05 |
enell |
112 |
} |
1060 |
05 Aug 05 |
enell |
113 |
// ------------------------------------------- |
1060 |
05 Aug 05 |
enell |
114 |
|
2459 |
30 Jun 06 |
nicklas |
115 |
public int getBlock() |
2459 |
30 Jun 06 |
nicklas |
116 |
{ |
2459 |
30 Jun 06 |
nicklas |
117 |
return block; |
2459 |
30 Jun 06 |
nicklas |
118 |
} |
2459 |
30 Jun 06 |
nicklas |
119 |
|
2459 |
30 Jun 06 |
nicklas |
120 |
public int getMetaRow() |
2459 |
30 Jun 06 |
nicklas |
121 |
{ |
2459 |
30 Jun 06 |
nicklas |
122 |
return metaRow; |
2459 |
30 Jun 06 |
nicklas |
123 |
} |
2459 |
30 Jun 06 |
nicklas |
124 |
|
2459 |
30 Jun 06 |
nicklas |
125 |
public int getMetaColumn() |
2459 |
30 Jun 06 |
nicklas |
126 |
{ |
2459 |
30 Jun 06 |
nicklas |
127 |
return metaColumn; |
2459 |
30 Jun 06 |
nicklas |
128 |
} |
2459 |
30 Jun 06 |
nicklas |
129 |
|
1060 |
05 Aug 05 |
enell |
130 |
public int getColumn() |
1060 |
05 Aug 05 |
enell |
131 |
{ |
1060 |
05 Aug 05 |
enell |
132 |
return column; |
1060 |
05 Aug 05 |
enell |
133 |
} |
1060 |
05 Aug 05 |
enell |
134 |
|
1060 |
05 Aug 05 |
enell |
135 |
public int getRow() |
1060 |
05 Aug 05 |
enell |
136 |
{ |
1060 |
05 Aug 05 |
enell |
137 |
return row; |
1060 |
05 Aug 05 |
enell |
138 |
} |
1060 |
05 Aug 05 |
enell |
139 |
|
3675 |
16 Aug 07 |
jari |
140 |
} |