e69e1ce6d99d8fd4f0bf88a903234c10d237a483
[jalview.git] / src / MCview / Atom.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package MCview;
20
21 import java.awt.*;
22
23 public class Atom
24 {
25   public float x;
26
27   public float y;
28
29   public float z;
30
31   public int number;
32
33   public String name;
34
35   public String resName;
36
37   public int resNumber;
38
39   public char insCode = ' ';
40
41   public String resNumIns = null;
42
43   public int type;
44
45   Color color = Color.lightGray;
46
47   public String chain;
48
49   public int alignmentMapping = -1;
50
51   public int atomIndex;
52
53   public float occupancy = 0;
54
55   public float tfactor = 0;
56
57   public boolean isSelected = false;
58
59   public Atom(String str)
60   {
61     atomIndex = Integer.parseInt(str.substring(6, 11).trim());
62
63     name = str.substring(12, 15).trim();
64
65     resName = str.substring(17, 20);
66
67     chain = str.substring(21, 22);
68
69     resNumber = Integer.parseInt(str.substring(22, 26).trim());
70     resNumIns = str.substring(22, 27);
71     insCode = str.substring(26, 27).charAt(0);
72     this.x = (float) (new Float(str.substring(30, 38).trim()).floatValue());
73     this.y = (float) (new Float(str.substring(38, 46).trim()).floatValue());
74     this.z = (float) (new Float(str.substring(47, 55).trim()).floatValue());
75     occupancy = (float) (new Float(str.substring(54, 60).trim())
76             .floatValue());
77     tfactor = (float) (new Float(str.substring(60, 66).trim()).floatValue());
78   }
79
80   public Atom(float x, float y, float z)
81   {
82     this.x = x;
83     this.y = y;
84     this.z = z;
85   }
86   // public void setColor(Color col) {
87   // this.color = col;
88   // }
89 }