JAL-1432 updated copyright notices
[jalview.git] / src / MCview / Atom.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 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 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  * The Jalview Authors are detailed in the 'AUTHORS' file.
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   /**
50    * this is a temporary value - designed to store the position in sequence that
51    * this atom corresponds to after aligning the chain to a SequenceI object. Do
52    * not rely on its value being correct when visualizing sequence colourings on
53    * the structure - use the StructureSelectionManager's mapping instead.
54    */
55   public int alignmentMapping = -1;
56
57   public int atomIndex;
58
59   public float occupancy = 0;
60
61   public float tfactor = 0;
62
63   // need these if we ever want to export Atom data
64   // public boolean tfacset=true,occset=true;
65   public boolean isSelected = false;
66
67   public Atom(String str)
68   {
69     atomIndex = Integer.parseInt(str.substring(6, 11).trim());
70
71     name = str.substring(12, 15).trim();
72
73     resName = str.substring(17, 20);
74
75     chain = str.substring(21, 22);
76
77     resNumber = Integer.parseInt(str.substring(22, 26).trim());
78     resNumIns = str.substring(22, 27);
79     insCode = str.substring(26, 27).charAt(0);
80     this.x = (float) (new Float(str.substring(30, 38).trim()).floatValue());
81     this.y = (float) (new Float(str.substring(38, 46).trim()).floatValue());
82     this.z = (float) (new Float(str.substring(47, 55).trim()).floatValue());
83     // optional entries - see JAL-730
84     String tm = str.substring(54, 60).trim();
85     if (tm.length() > 0)
86     {
87       occupancy = (float) (new Float(tm)).floatValue();
88     }
89     else
90     {
91       occupancy = 1f; // default occupancy
92       // see note above: occset=false;
93     }
94     tm = str.substring(60, 66).trim();
95     if (tm.length() > 0)
96     {
97       tfactor = (float) (new Float(tm).floatValue());
98     }
99     else
100     {
101       tfactor = 1f;
102       // see note above: tfacset=false;
103     }
104   }
105
106   public Atom(float x, float y, float z)
107   {
108     this.x = x;
109     this.y = y;
110     this.z = z;
111   }
112   // public void setColor(Color col) {
113   // this.color = col;
114   // }
115 }