formatting
[jalview.git] / src / MCview / Bond.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  *\r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  *\r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  *\r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package MCview;\r
20 \r
21 import java.awt.*;\r
22 \r
23 public class Bond\r
24 {\r
25   float[] start;\r
26   float[] end;\r
27   Color startCol = Color.lightGray;\r
28   Color endCol = Color.lightGray;\r
29   public Atom at1;\r
30   public Atom at2;\r
31 \r
32   public Bond(float[] start, float[] end, Atom at1, Atom at2)\r
33   {\r
34     this.start = start;\r
35     this.end = end;\r
36     this.startCol = at1.color;\r
37     this.endCol = at2.color;\r
38     this.at1 = at1;\r
39     this.at2 = at2;\r
40   }\r
41 \r
42   /*  public Bond(Bond bond) {\r
43         this.start = new float[3];\r
44 \r
45         this.start[0] = bond.start[0];\r
46         this.start[1] = bond.start[1];\r
47         this.start[2] = bond.start[2];\r
48 \r
49         this.end = new float[3];\r
50 \r
51         this.end[0] = bond.end[0];\r
52         this.end[1] = bond.end[1];\r
53         this.end[2] = bond.end[2];\r
54 \r
55         this.startCol = bond.startCol;\r
56         this.endCol = bond.endCol;\r
57     }\r
58 \r
59     public float length() {\r
60         float len = ((end[0] - start[0]) * (end[0] - start[0])) +\r
61             ((end[1] - start[1]) * (end[1] - start[1])) +\r
62             ((end[2] - start[2]) * (end[2] - start[2]));\r
63 \r
64         len = (float) (Math.sqrt(len));\r
65 \r
66         return len;\r
67     }*/\r
68 \r
69   public void translate(float x, float y, float z)\r
70   {\r
71     start[0] = (start[0] + x);\r
72     end[0] = (end[0] + x);\r
73 \r
74     start[1] = (start[1] + y);\r
75     end[1] = (end[1] + y);\r
76 \r
77     start[2] = (start[2] + z);\r
78     end[2] = (end[2] + z);\r
79   }\r
80 }\r