~nvervelle/jmol/trunk

« back to all changes in this revision

Viewing changes to srcjsv/jspecview/source/JDXHeader.java

  • Committer: hansonr
  • Date: 2017-07-20 11:42:01 UTC
  • Revision ID: svn-v4:62be27d7-c70d-0410-b753-bb59b6ba1b27:trunk/Jmol:21665
Jmol.___JmolVersion="14.20.3" // 2017.07.20

bug fix: CIPChirality tests for CIP1966#31,#32 douple spirans and C3 compounds
bug fix: CIPChirality for Rule 2 using atomic masses and not for duplicate atoms
bug fix: MOL file reading where isotope is indicated in atom line and V item
bug fix: MOL reader fails for H1, D, T isotopes indicated as symbols along with isotope difference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package jspecview.source;
2
 
 
3
 
import javajs.util.Lst;
4
 
 
5
 
/**
6
 
 * could be a spectrum or a source
7
 
 * 
8
 
 * @author Bob Hanson
9
 
 * 
10
 
 */
11
 
public class JDXHeader {
12
 
 
13
 
  public String title = "";
14
 
  public String jcampdx = "5.01";
15
 
  public String dataType = "";
16
 
  public String dataClass = "";
17
 
  public String origin = "";
18
 
  public String owner = "PUBLIC DOMAIN";
19
 
  public String longDate = "";
20
 
  public String date = "";
21
 
  public String time = "";
22
 
 
23
 
 
24
 
  /**
25
 
   * Sets the title of the spectrum
26
 
   * 
27
 
   * @param title
28
 
   *        the spectrum title
29
 
   */
30
 
  public void setTitle(String title) {
31
 
    this.title = title;
32
 
  }
33
 
 
34
 
  /**
35
 
   * Sets the JCAMP-DX version number
36
 
   * 
37
 
   * @param versionNum
38
 
   *        the JCAMP-DX version number
39
 
   */
40
 
  public void setJcampdx(String versionNum) {
41
 
    this.jcampdx = versionNum;
42
 
  }
43
 
 
44
 
  /**
45
 
   * Sets the data type
46
 
   * 
47
 
   * @param dataType
48
 
   *        the data type
49
 
   */
50
 
  public void setDataType(String dataType) {
51
 
    this.dataType = dataType;
52
 
  }
53
 
 
54
 
  /**
55
 
   * Sets the data class
56
 
   * 
57
 
   * @param dataClass
58
 
   *        the data class
59
 
   */
60
 
  public void setDataClass(String dataClass) {
61
 
    this.dataClass = dataClass;
62
 
  }
63
 
 
64
 
  /**
65
 
   * Sets the origin of the JCAMP-DX spectrum
66
 
   * 
67
 
   * @param origin
68
 
   *        the origin
69
 
   */
70
 
  public void setOrigin(String origin) {
71
 
    this.origin = origin;
72
 
  }
73
 
 
74
 
  /**
75
 
   * Sets the owner
76
 
   * 
77
 
   * @param owner
78
 
   *        the owner
79
 
   */
80
 
  public void setOwner(String owner) {
81
 
    this.owner = owner;
82
 
  }
83
 
 
84
 
  /**
85
 
   * Sets the long date of when the file was created
86
 
   * 
87
 
   * @param longDate
88
 
   *        String
89
 
   */
90
 
  public void setLongDate(String longDate) {
91
 
    this.longDate = longDate;
92
 
  }
93
 
 
94
 
  /**
95
 
   * Sets the date the file was created
96
 
   * 
97
 
   * @param date
98
 
   *        String
99
 
   */
100
 
  public void setDate(String date) {
101
 
    this.date = date;
102
 
  }
103
 
 
104
 
  /**
105
 
   * Sets the time the file was created
106
 
   * 
107
 
   * @param time
108
 
   *        String
109
 
   */
110
 
  public void setTime(String time) {
111
 
    this.time = time;
112
 
  }
113
 
 
114
 
 
115
 
  /**
116
 
   * Getter for property title.
117
 
   * 
118
 
   * @return Value of property title.
119
 
   */
120
 
  public String getTitle() {
121
 
    return title;
122
 
  }
123
 
 
124
 
  final static String[] typeNames = {
125
 
        "ND NMR SPECTRUM   NMR",
126
 
        "NMR SPECTRUM      NMR",
127
 
        "INFRARED SPECTRUM IR",
128
 
        "MASS SPECTRUM     MS",
129
 
        "RAMAN SPECTRUM    RAMAN",
130
 
        "GAS CHROMATOGRAM  GC",
131
 
        "UV/VIS SPECTRUM   UV/VIS"
132
 
  };
133
 
  
134
 
  private String qualifiedType;
135
 
  
136
 
  static String getTypeName(String type) {
137
 
        type = type.toUpperCase();
138
 
        for (int i = 0; i < typeNames.length; i++)
139
 
                if (typeNames[i].startsWith(type)) {
140
 
                        return typeNames[i].substring(18);
141
 
                }
142
 
        return type;
143
 
  }
144
 
 
145
 
  public String getQualifiedDataType() {
146
 
        return (qualifiedType == null ? (qualifiedType = getTypeName(dataType)) : qualifiedType);
147
 
  }
148
 
  /**
149
 
   * Getter for property jcampdx.
150
 
   * 
151
 
   * @return Value of property jcampdx.
152
 
   */
153
 
  public String getJcampdx() {
154
 
    return jcampdx;
155
 
  }
156
 
 
157
 
  /**
158
 
   * Getter for property dataType.
159
 
   * 
160
 
   * @return Value of property dataType.
161
 
   */
162
 
  public String getDataType() {
163
 
    return dataType;
164
 
  }
165
 
 
166
 
  /**
167
 
   * Getter for property origin.
168
 
   * 
169
 
   * @return Value of property origin.
170
 
   */
171
 
  public String getOrigin() {
172
 
    return origin;
173
 
  }
174
 
 
175
 
  /**
176
 
   * Getter for property owner.
177
 
   * 
178
 
   * @return Value of property owner.
179
 
   */
180
 
  public String getOwner() {
181
 
    return owner;
182
 
  }
183
 
 
184
 
  /**
185
 
   * Getter for property longDate.
186
 
   * 
187
 
   * @return Value of property longDate.
188
 
   */
189
 
  public String getLongDate() {
190
 
    return longDate;
191
 
  }
192
 
 
193
 
  /**
194
 
   * Getter for property date.
195
 
   * 
196
 
   * @return Value of property date.
197
 
   */
198
 
  public String getDate() {
199
 
    return date;
200
 
  }
201
 
 
202
 
  /**
203
 
   * Getter for property time.
204
 
   * 
205
 
   * @return Value of property time.
206
 
   */
207
 
  public String getTime() {
208
 
    return time;
209
 
  }
210
 
 
211
 
  /**
212
 
   * Returns the data class
213
 
   * spectrum only
214
 
   * @return the data class
215
 
   */
216
 
  public String getDataClass() {
217
 
    return dataClass;
218
 
  }
219
 
 
220
 
  // Table of header variables specific to the jdx source or spectrum
221
 
  protected Lst<String[]> headerTable = new Lst<String[]>();
222
 
  
223
 
  /**
224
 
   * Sets the headerTable for this Source or spectrum
225
 
   * 
226
 
   * @param table
227
 
   *        the header table
228
 
   */
229
 
  public void setHeaderTable(Lst<String[]> table) {
230
 
    headerTable = table;
231
 
  }
232
 
 
233
 
  /**
234
 
   * Returns the table of headers
235
 
   * 
236
 
   * @return the table of headers
237
 
   */
238
 
  public Lst<String[]> getHeaderTable() {
239
 
    return headerTable;
240
 
  }
241
 
 
242
 
  public String[][] getHeaderRowDataAsArray(boolean addDataClass, int nMore) {
243
 
    
244
 
    String[][] rowData = new String[(addDataClass ? 6 : 5) + headerTable.size() + nMore][];
245
 
 
246
 
    int i = 0;
247
 
    rowData[i++] = new String[] { "##TITLE", title };
248
 
    rowData[i++] = new String[] { "##JCAMP-DX", jcampdx };
249
 
    rowData[i++] = new String[] { "##DATA TYPE", dataType };
250
 
    if (addDataClass)
251
 
      rowData[i++] = new String[] { "##DATA CLASS", dataClass };      
252
 
    rowData[i++] = new String[] { "##ORIGIN", origin };
253
 
    rowData[i++] = new String[] { "##OWNER", owner };
254
 
    
255
 
    for(int j = 0; j < headerTable.size(); j++)
256
 
      rowData[i++] = getRow(j);
257
 
    
258
 
    return rowData;
259
 
  }
260
 
 
261
 
        private String[] getRow(int j) {
262
 
                String[] s = headerTable.get(j);
263
 
                /**
264
 
                 * @j2sNative
265
 
                 * 
266
 
                 * return [s[0], javajs.util.PT.rep(s[1], "<", "&lt;")];
267
 
                 * 
268
 
                 */
269
 
                {
270
 
                        return s;
271
 
                }
272
 
        }
273
 
 
274
 
  
275
 
  
276
 
}