Merge branch 'develop' into features/JAL-2094_colourInterface
[jalview.git] / src / MCview / Bond.java
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 MCview;
22
23 import jalview.api.ColorI;
24 import jalview.schemes.Colour;
25
26 public class Bond
27 {
28   float[] start;
29
30   float[] end;
31
32   ColorI startCol = Colour.lightGray;
33
34   ColorI endCol = Colour.lightGray;
35
36   public Atom at1;
37
38   public Atom at2;
39
40   public Bond(Atom at1, Atom at2)
41   {
42     this.start = new float[] { at1.x, at1.y, at1.z };
43     this.end = new float[] { at2.x, at2.y, at2.z };
44     this.startCol = at1.color;
45     this.endCol = at2.color;
46     this.at1 = at1;
47     this.at2 = at2;
48   }
49
50   /*
51    * public Bond(Bond bond) { this.start = new float[3];
52    * 
53    * this.start[0] = bond.start[0]; this.start[1] = bond.start[1]; this.start[2]
54    * = bond.start[2];
55    * 
56    * this.end = new float[3];
57    * 
58    * this.end[0] = bond.end[0]; this.end[1] = bond.end[1]; this.end[2] =
59    * bond.end[2];
60    * 
61    * this.startCol = bond.startCol; this.endCol = bond.endCol; }
62    * 
63    * public float length() { float len = ((end[0] - start[0]) * (end[0] -
64    * start[0])) + ((end[1] - start[1]) * (end[1] - start[1])) + ((end[2] -
65    * start[2]) * (end[2] - start[2]));
66    * 
67    * len = (float) (Math.sqrt(len));
68    * 
69    * return len; }
70    */
71
72   public void translate(float x, float y, float z)
73   {
74     start[0] = start[0] + x;
75     end[0] = end[0] + x;
76
77     start[1] = start[1] + y;
78     end[1] = end[1] + y;
79
80     start[2] = start[2] + z;
81     end[2] = end[2] + z;
82   }
83 }