Class | Line # | Actions | |||
---|---|---|---|---|---|
SequencePoint | 29 | 6 | 5 |
1 | /* | |
2 | * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) | |
3 | * Copyright (C) $$Year-Rel$$ The Jalview Authors | |
4 | * | |
5 | * This file is part of Jalview. | |
6 | * | |
7 | * Jalview is free software: you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License | |
9 | * as published by the Free Software Foundation, either version 3 | |
10 | * of the License, or (at your option) any later version. | |
11 | * | |
12 | * Jalview is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty | |
14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
15 | * PURPOSE. See the GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Jalview. If not, see <http://www.gnu.org/licenses/>. | |
19 | * The Jalview Authors are detailed in the 'AUTHORS' file. | |
20 | */ | |
21 | package jalview.datamodel; | |
22 | ||
23 | /** | |
24 | * A bean that models a set of (x, y, z) values and a reference to a sequence. | |
25 | * As used in Principal Component Analysis, the (x, y, z) values are the | |
26 | * sequence's score for the currently selected first, second and third | |
27 | * dimensions of the PCA. | |
28 | */ | |
29 | public class SequencePoint | |
30 | { | |
31 | /* | |
32 | * Associated alignment sequence, or dummy sequence object | |
33 | */ | |
34 | private final SequenceI sequence; | |
35 | ||
36 | /* | |
37 | * x, y, z values | |
38 | */ | |
39 | public Point coord; | |
40 | ||
41 | /** | |
42 | * Constructor | |
43 | * | |
44 | * @param sequence | |
45 | * @param coord | |
46 | */ | |
47 | 0 | public SequencePoint(SequenceI sequence, Point pt) |
48 | { | |
49 | 0 | this.sequence = sequence; |
50 | 0 | this.coord = pt; |
51 | } | |
52 | ||
53 | /** | |
54 | * Constructor given a sequence and an array of x, y, z coordinate positions | |
55 | * | |
56 | * @param sequence | |
57 | * @param coords | |
58 | * @throws ArrayIndexOutOfBoundsException | |
59 | * if array length is less than 3 | |
60 | */ | |
61 | 0 | public SequencePoint(SequenceI sequence, float[] coords) |
62 | { | |
63 | 0 | this(sequence, new Point(coords[0], coords[1], coords[2])); |
64 | } | |
65 | ||
66 | 0 | public SequenceI getSequence() |
67 | { | |
68 | 0 | return sequence; |
69 | } | |
70 | ||
71 | /** | |
72 | * Applies a translation to the (x, y, z) coordinates | |
73 | * | |
74 | * @param centre | |
75 | */ | |
76 | 0 | public void translate(float x, float y, float z) |
77 | { | |
78 | 0 | coord = new Point(coord.x + x, coord.y + y, coord.z + z); |
79 | } | |
80 | ||
81 | /** | |
82 | * string representation for ease of inspection in debugging or logging only | |
83 | */ | |
84 | 0 | @Override |
85 | public String toString() | |
86 | { | |
87 | 0 | return sequence.getName() + " " + coord.toString(); |
88 | } | |
89 | } |