JAL-4152 Remove redundant casts from getInstance usages.
[jalview.git] / src / jalview / structure / StructureImportSettings.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 jalview.structure;
22
23
24 import java.util.Locale;
25
26 import jalview.bin.ApplicationSingletonProvider;
27 import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
28
29
30 import jalview.datamodel.PDBEntry;
31 import jalview.datamodel.PDBEntry.Type;
32
33 /**
34  * bean holding settings for structure IO. TODO: tests for validation of values
35  * TODO: tests for race conditions (all fields are static, is that correct ?)
36  * 
37  * @author tcofoegbu
38  *
39  */
40 public class StructureImportSettings implements ApplicationSingletonI
41 {
42   private StructureImportSettings()
43   {
44     // private singleton
45   }
46
47   private static StructureImportSettings getInstance()
48   {
49     return ApplicationSingletonProvider
50             .getInstance(StructureImportSettings.class);
51   }
52   /**
53    * set to true to add derived sequence annotations (temp factor read from
54    * file, or computed secondary structure) to the alignment
55    */
56   private boolean visibleChainAnnotation = false;
57
58   /**
59    * Set true to predict secondary structure (using JMol for protein, Annotate3D
60    * for RNA)
61    */
62   private static boolean processSecStr = false;
63
64   /**
65    * Set true (with predictSecondaryStructure=true) to predict secondary
66    * structure using an external service (currently Annotate3D for RNA only)
67    */
68   private boolean externalSecondaryStructure = false;
69
70   private static boolean showSeqFeatures = true;
71
72   public enum StructureParser
73   {
74     JMOL_PARSER, JALVIEW_PARSER
75   }
76
77   /**
78    * Determines the default file format for structure files to be downloaded
79    * from the PDB sequence fetcher. Possible options include: PDB|mmCIF
80    */
81   private PDBEntry.Type defaultStructureFileFormat = Type.PDB; // TODO 2.12 should be mmCIF now ?
82
83   /**
84    * Determines the parser used for parsing PDB format file. Possible options
85    * are : JMolParser|JalveiwParser
86    */
87   private StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
88
89   public static void addSettings(boolean addAlignmentAnnotations,
90           boolean processSecStr, boolean externalSecStr)
91   {
92     StructureImportSettings s = getInstance();
93     s.visibleChainAnnotation = addAlignmentAnnotations;
94     s.processSecStr = processSecStr;
95     s.externalSecondaryStructure = externalSecStr;
96     s.showSeqFeatures = true;
97   }
98
99   public static boolean isVisibleChainAnnotation()
100   {
101     return getInstance().visibleChainAnnotation;
102   }
103
104   public static void setVisibleChainAnnotation(
105           boolean visibleChainAnnotation)
106   {
107     getInstance().visibleChainAnnotation = visibleChainAnnotation;
108   }
109
110   public static boolean isProcessSecondaryStructure()
111   {
112     return getInstance().processSecStr;
113   }
114
115   public static void setProcessSecondaryStructure(
116           boolean processSecondaryStructure)
117   {
118     getInstance().processSecStr = processSecondaryStructure;
119   }
120
121   public static boolean isExternalSecondaryStructure()
122   {
123     return getInstance().externalSecondaryStructure;
124   }
125
126   public static void setExternalSecondaryStructure(
127           boolean externalSecondaryStructure)
128   {
129     getInstance().externalSecondaryStructure = externalSecondaryStructure;
130   }
131
132   public static boolean isShowSeqFeatures()
133   {
134     return getInstance().showSeqFeatures;
135   }
136
137   public static void setShowSeqFeatures(boolean showSeqFeatures)
138   {
139     getInstance().showSeqFeatures = showSeqFeatures;
140   }
141
142   public static PDBEntry.Type getDefaultStructureFileFormat()
143   {
144     return getInstance().defaultStructureFileFormat;
145   }
146
147   public static void setDefaultStructureFileFormat(
148           String defaultStructureFileFormat)
149   {
150     getInstance().defaultStructureFileFormat = PDBEntry.Type
151             .valueOf(defaultStructureFileFormat.toUpperCase(Locale.ROOT));
152   }
153
154   public static String getDefaultPDBFileParser()
155   {
156     return getInstance().defaultPDBFileParser.toString();
157   }
158
159   public static void setDefaultPDBFileParser(
160           StructureParser defaultPDBFileParser)
161   {
162     getInstance().defaultPDBFileParser = defaultPDBFileParser;
163   }
164
165   public static void setDefaultPDBFileParser(String defaultPDBFileParser)
166   {
167     getInstance().defaultPDBFileParser = StructureParser
168             .valueOf(defaultPDBFileParser.toUpperCase(Locale.ROOT));
169   }
170
171 }