2137 |
31 Mar 06 |
nicklas |
1 |
/* |
2137 |
31 Mar 06 |
nicklas |
$Id$ |
2137 |
31 Mar 06 |
nicklas |
3 |
|
4889 |
06 Apr 09 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
2137 |
31 Mar 06 |
nicklas |
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/ |
2137 |
31 Mar 06 |
nicklas |
9 |
|
2137 |
31 Mar 06 |
nicklas |
BASE is free software; you can redistribute it and/or |
2137 |
31 Mar 06 |
nicklas |
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 |
2137 |
31 Mar 06 |
nicklas |
of the License, or (at your option) any later version. |
2137 |
31 Mar 06 |
nicklas |
14 |
|
2137 |
31 Mar 06 |
nicklas |
BASE is distributed in the hope that it will be useful, |
2137 |
31 Mar 06 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2137 |
31 Mar 06 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2137 |
31 Mar 06 |
nicklas |
GNU General Public License for more details. |
2137 |
31 Mar 06 |
nicklas |
19 |
|
2137 |
31 Mar 06 |
nicklas |
You should have received a copy of the GNU General Public License |
4515 |
11 Sep 08 |
jari |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2137 |
31 Mar 06 |
nicklas |
22 |
*/ |
2137 |
31 Mar 06 |
nicklas |
23 |
package net.sf.basedb.util.plot; |
2137 |
31 Mar 06 |
nicklas |
24 |
|
3015 |
11 Dec 06 |
nicklas |
25 |
import java.util.Arrays; |
2137 |
31 Mar 06 |
nicklas |
26 |
import java.util.Collection; |
2137 |
31 Mar 06 |
nicklas |
27 |
|
2601 |
29 Aug 06 |
martin |
28 |
import net.sf.basedb.core.query.SqlResultIterator; |
2601 |
29 Aug 06 |
martin |
29 |
|
2137 |
31 Mar 06 |
nicklas |
30 |
/** |
2327 |
24 May 06 |
nicklas |
Used to map spot data into different annotations. The mapping is done by checking |
2327 |
24 May 06 |
nicklas |
which {@link #getValues()} collection a value falls in. |
2137 |
31 Mar 06 |
nicklas |
33 |
|
2137 |
31 Mar 06 |
nicklas |
@author Nicklas |
2137 |
31 Mar 06 |
nicklas |
@version 2.0 |
2137 |
31 Mar 06 |
nicklas |
@base.modified $Date$ |
2327 |
24 May 06 |
nicklas |
@see ScatterPlot#addData(SqlResultIterator, Collection) |
2137 |
31 Mar 06 |
nicklas |
38 |
*/ |
2137 |
31 Mar 06 |
nicklas |
39 |
public class PlotAnnotation |
5384 |
13 Aug 10 |
nicklas |
40 |
implements Comparable<PlotAnnotation> |
2137 |
31 Mar 06 |
nicklas |
41 |
{ |
2137 |
31 Mar 06 |
nicklas |
42 |
|
2137 |
31 Mar 06 |
nicklas |
43 |
private final String name; |
2327 |
24 May 06 |
nicklas |
44 |
private final Collection<Integer> values; |
2137 |
31 Mar 06 |
nicklas |
45 |
|
2327 |
24 May 06 |
nicklas |
46 |
/** |
2327 |
24 May 06 |
nicklas |
Create a new PlotAnnotation. |
2327 |
24 May 06 |
nicklas |
@param name The name of the annotation, which will be used as a label in the image |
3616 |
01 Aug 07 |
nicklas |
@param value The value that belongs to this annotation |
3015 |
11 Dec 06 |
nicklas |
@since 2.2 |
3015 |
11 Dec 06 |
nicklas |
51 |
*/ |
3015 |
11 Dec 06 |
nicklas |
52 |
public PlotAnnotation(String name, int value) |
3015 |
11 Dec 06 |
nicklas |
53 |
{ |
3015 |
11 Dec 06 |
nicklas |
54 |
this(name, Arrays.asList(value)); |
3015 |
11 Dec 06 |
nicklas |
55 |
} |
3015 |
11 Dec 06 |
nicklas |
56 |
|
3015 |
11 Dec 06 |
nicklas |
57 |
/** |
3015 |
11 Dec 06 |
nicklas |
Create a new PlotAnnotation. |
3015 |
11 Dec 06 |
nicklas |
@param name The name of the annotation, which will be used as a label in the image |
2327 |
24 May 06 |
nicklas |
@param values The values that belongs to this annotation |
2327 |
24 May 06 |
nicklas |
61 |
*/ |
2327 |
24 May 06 |
nicklas |
62 |
public PlotAnnotation(String name, Collection<Integer> values) |
2137 |
31 Mar 06 |
nicklas |
63 |
{ |
2137 |
31 Mar 06 |
nicklas |
64 |
this.name = name; |
2327 |
24 May 06 |
nicklas |
65 |
this.values = values; |
2137 |
31 Mar 06 |
nicklas |
66 |
} |
2137 |
31 Mar 06 |
nicklas |
67 |
|
2327 |
24 May 06 |
nicklas |
68 |
/** |
2327 |
24 May 06 |
nicklas |
The name of the annotation, which will be used as a label in the image. |
2327 |
24 May 06 |
nicklas |
70 |
*/ |
2137 |
31 Mar 06 |
nicklas |
71 |
public String getName() |
2137 |
31 Mar 06 |
nicklas |
72 |
{ |
2137 |
31 Mar 06 |
nicklas |
73 |
return name; |
2137 |
31 Mar 06 |
nicklas |
74 |
} |
2327 |
24 May 06 |
nicklas |
75 |
|
2327 |
24 May 06 |
nicklas |
76 |
/** |
2327 |
24 May 06 |
nicklas |
The values that falls into this annotation. This collection shouldn't contain |
2327 |
24 May 06 |
nicklas |
a value that is also found in another <code>PlotAnnotation</code>. |
2327 |
24 May 06 |
nicklas |
79 |
*/ |
2327 |
24 May 06 |
nicklas |
80 |
public Collection<Integer> getValues() |
2137 |
31 Mar 06 |
nicklas |
81 |
{ |
2327 |
24 May 06 |
nicklas |
82 |
return values; |
2137 |
31 Mar 06 |
nicklas |
83 |
} |
2704 |
04 Oct 06 |
nicklas |
84 |
|
5384 |
13 Aug 10 |
nicklas |
85 |
@Override |
5384 |
13 Aug 10 |
nicklas |
86 |
public int compareTo(PlotAnnotation o) |
2704 |
04 Oct 06 |
nicklas |
87 |
{ |
5384 |
13 Aug 10 |
nicklas |
88 |
int tmp = this.name.compareTo(o.name); |
5384 |
13 Aug 10 |
nicklas |
89 |
return tmp != 0 ? tmp : hashCode() - o.hashCode(); |
2704 |
04 Oct 06 |
nicklas |
90 |
} |
2137 |
31 Mar 06 |
nicklas |
91 |
|
2137 |
31 Mar 06 |
nicklas |
92 |
} |