From 2ea1fb1e8751ac7272c421820000449525664f02 Mon Sep 17 00:00:00 2001 From: hansonr Date: Fri, 17 May 2019 08:26:33 -0500 Subject: [PATCH] Jalview-JS/JAL-3253-applet additional static final preferences --- src/jalview/bin/Cache.java | 4 +- src/jalview/bin/Jalview.java | 2 +- src/jalview/fts/core/FTSRestRequest.java | 2 +- .../fts/service/uniprot/UniProtFTSRestClient.java | 2 +- src/jalview/gui/AlignFrame.java | 6 +- src/jalview/gui/AlignViewport.java | 78 +++--- src/jalview/gui/AlignmentPanel.java | 4 +- src/jalview/gui/CalculationChooser.java | 3 +- src/jalview/gui/CrossRefAction.java | 2 +- src/jalview/gui/CutAndPasteTransfer.java | 3 +- src/jalview/gui/FontChooser.java | 8 +- src/jalview/gui/Preferences.java | 259 ++++++++++++++------ src/jalview/gui/SequenceFetcher.java | 5 +- src/jalview/io/FormatAdapter.java | 12 +- src/jalview/jbgui/GAlignFrame.java | 11 +- src/jalview/ws/DBRefFetcher.java | 3 +- src/jalview/ws/dbsources/Uniprot.java | 2 +- 17 files changed, 268 insertions(+), 138 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 2d33478..4dac4df 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -510,7 +510,7 @@ public class Cache implements ApplicationSingletonI getDefault("sifts_cache_threshold_in_days", DEFAULT_CACHE_THRESHOLD_IN_DAYS)); - IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL", + IdOrgSettings.setUrl(getDefault(Preferences.ID_ORG_HOSTURL, "http://www.jalview.org/services/identifiers")); IdOrgSettings.setDownloadLocation(ID_ORG_FILE); @@ -518,7 +518,7 @@ public class Cache implements ApplicationSingletonI .println("Jalview Version: " + codeVersion + codeInstallation); StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache - .getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT)); + .getDefault(Preferences.PDB_DOWNLOAD_FORMAT, PDB_DOWNLOAD_FORMAT)); StructureImportSettings .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER); // StructureImportSettings diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 07fd4d6..b39f0e2 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -439,7 +439,7 @@ public class Jalview implements ApplicationSingletonI * configure 'full' SO model if preferences say to, * else use the default (SO Lite) */ - if (Cache.getDefault("USE_FULL_SO", false)) + if (Cache.getDefault(Preferences.USE_FULL_SO, false)) { SequenceOntologyFactory.setSequenceOntology(new SequenceOntology()); } diff --git a/src/jalview/fts/core/FTSRestRequest.java b/src/jalview/fts/core/FTSRestRequest.java index 2d9eeb6..b09fcc0 100644 --- a/src/jalview/fts/core/FTSRestRequest.java +++ b/src/jalview/fts/core/FTSRestRequest.java @@ -46,7 +46,7 @@ public class FTSRestRequest private boolean allowEmptySequence; private boolean allowUnpublishedEntries = Cache - .getDefault("ALLOW_UNPUBLISHED_PDB_QUERYING", false); + .getDefault(Preferences.ALLOW_UNPUBLISHED_PDB_QUERYING, false); private boolean facet; diff --git a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java index 9570dd3..d56bcbf 100644 --- a/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java +++ b/src/jalview/fts/service/uniprot/UniProtFTSRestClient.java @@ -59,7 +59,7 @@ public class UniProtFTSRestClient extends FTSRestClient { // singleton -- use getInstance() - uniprotSearchEndpoint = Cache.getDefault("UNIPROT_DOMAIN", + uniprotSearchEndpoint = Cache.getDefault(Preferences.UNIPROT_DOMAIN, DEFAULT_UNIPROT_DOMAIN) + "/uniprot/"; } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index bc08c4f..b56f269 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -407,7 +407,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, wrapMenuItem_actionPerformed(null); } - if (jalview.bin.Cache.getDefault("SHOW_OVERVIEW", false)) + if (jalview.bin.Cache.getDefault(Preferences.SHOW_OVERVIEW, false)) { this.overviewMenuItem_actionPerformed(null); } @@ -4461,7 +4461,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { // BH 2018 return avc.parseFeaturesFile(file, sourceType, - Cache.getDefault("RELAXEDSEQIDMATCHING", false)); + Cache.getDefault(Preferences.RELAXEDSEQIDMATCHING, false)); } @@ -4604,7 +4604,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (filesmatched.size() > 0) { boolean autoAssociate = Cache - .getDefault("AUTOASSOCIATE_PDBANDSEQS", false); + .getDefault(Preferences.AUTOASSOCIATE_PDBANDSEQS, false); if (!autoAssociate) { String msg = MessageManager.formatMessage( diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 4edb580..7c3dca0 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -206,25 +206,26 @@ public class AlignViewport extends AlignmentViewport */ private void applyViewProperties() { - antiAlias = Cache.getDefault("ANTI_ALIAS", false); + antiAlias = Cache.getDefault(Preferences.ANTI_ALIAS, false); - viewStyle.setShowJVSuffix(Cache.getDefault("SHOW_JVSUFFIX", true)); + viewStyle.setShowJVSuffix( + Cache.getDefault(Preferences.SHOW_JVSUFFIX, true)); setShowAnnotation(Cache.getDefault(Preferences.SHOW_ANNOTATIONS, true)); - setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false)); - setCentreColumnLabels(Cache.getDefault("CENTRE_COLUMN_LABELS", false)); - autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true); + setRightAlignIds(Cache.getDefault(Preferences.RIGHT_ALIGN_IDS, false)); + setCentreColumnLabels(Cache.getDefault(Preferences.CENTRE_COLUMN_LABELS, false)); + autoCalculateConsensus = Cache.getDefault(Preferences.AUTO_CALC_CONSENSUS, true); - setPadGaps(Cache.getDefault("PAD_GAPS", true)); - setShowNPFeats(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true)); - setShowDBRefs(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true)); - viewStyle.setSeqNameItalics(Cache.getDefault("ID_ITALICS", true)); + setPadGaps(Cache.getDefault(Preferences.PAD_GAPS, true)); + setShowNPFeats(Cache.getDefault(Preferences.SHOW_NPFEATS_TOOLTIP, true)); + setShowDBRefs(Cache.getDefault(Preferences.SHOW_DBREFS_TOOLTIP, true)); + viewStyle.setSeqNameItalics(Cache.getDefault(Preferences.ID_ITALICS, true)); viewStyle.setWrapAlignment( Cache.getDefault(Preferences.WRAP_ALIGNMENT, false)); viewStyle.setShowUnconserved( Cache.getDefault(Preferences.SHOW_UNCONSERVED, false)); sortByTree = Cache.getDefault(Preferences.SORT_BY_TREE, false); - followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true); + followSelection = Cache.getDefault(Preferences.FOLLOW_SELECTIONS, true); sortAnnotationsBy = SequenceAnnotationOrder .valueOf(Cache.getDefault(Preferences.SORT_ANNOTATIONS, SequenceAnnotationOrder.NONE.name())); @@ -238,9 +239,10 @@ public class AlignViewport extends AlignmentViewport { applyViewProperties(); - String fontName = Cache.getDefault("FONT_NAME", "SansSerif"); - String fontStyle = Cache.getDefault("FONT_STYLE", Font.PLAIN + ""); - String fontSize = Cache.getDefault("FONT_SIZE", "10"); + String fontName = Cache.getDefault(Preferences.FONT_NAME, "SansSerif"); + String fontStyle = Cache.getDefault(Preferences.FONT_STYLE, + Font.PLAIN + ""); + String fontSize = Cache.getDefault(Preferences.FONT_SIZE, "10"); int style = 0; @@ -256,7 +258,8 @@ public class AlignViewport extends AlignmentViewport setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true); alignment - .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0)); + .setGapCharacter(Cache.getDefault(Preferences.GAP_SYMBOL, "-") + .charAt(0)); // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done @@ -264,21 +267,22 @@ public class AlignViewport extends AlignmentViewport { if (!alignment.isNucleotide()) { - showConservation = Cache.getDefault(Preferences.SHOW_CONSERVATION, true); + showConservation = Cache.getDefault(Preferences.SHOW_CONSERVATION, + true); showQuality = Cache.getDefault(Preferences.SHOW_QUALITY, true); - showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION", - false); + showGroupConservation = Cache + .getDefault(Preferences.SHOW_GROUP_CONSERVATION, false); } - showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM", - true); - showSequenceLogo = Cache.getDefault(Preferences.SHOW_CONSENSUS_LOGO, false); - - normaliseSequenceLogo = Cache.getDefault( - Preferences.NORMALISE_CONSENSUS_LOGO, + showConsensusHistogram = Cache + .getDefault(Preferences.SHOW_CONSENSUS_HISTOGRAM, true); + showSequenceLogo = Cache.getDefault(Preferences.SHOW_CONSENSUS_LOGO, false); + + normaliseSequenceLogo = Cache + .getDefault(Preferences.NORMALISE_CONSENSUS_LOGO, false); showGroupConsensus = Cache .getDefault(Preferences.SHOW_GROUP_CONSENSUS, false); - showConsensus = Cache.getDefault("SHOW_IDENTITY", true); + showConsensus = Cache.getDefault(Preferences.SHOW_IDENTITY, true); showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true); } @@ -293,8 +297,8 @@ public class AlignViewport extends AlignmentViewport schemeName = Cache.getDefault(Preferences.DEFAULT_COLOUR, ResidueColourScheme.NONE); } - ColourSchemeI colourScheme = ColourSchemeProperty - .getColourScheme(this, alignment, schemeName); + ColourSchemeI colourScheme = ColourSchemeProperty.getColourScheme(this, + alignment, schemeName); residueShading = new ResidueShader(colourScheme); if (colourScheme instanceof UserColourScheme) @@ -769,20 +773,20 @@ public class AlignViewport extends AlignmentViewport MessageManager.getString("label.new_window"), }; final String question = JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.open_split_window?")); - /* * options No, Split Window, New Window correspond to * dialog responses 0, 1, 2 (even though JOptionPane shows them * in reverse order) */ - JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.getDesktopPane()) + JvOptionPane dialog = JvOptionPane + .newOptionDialog(Desktop.getDesktopPane()) .setResponseHandler(NO_SPLIT, new Runnable() { @Override public void run() { - addDataToAlignment(al); + addDataToAlignment(al); } }).setResponseHandler(SPLIT_FRAME, new Runnable() { @@ -790,8 +794,8 @@ public class AlignViewport extends AlignmentViewport public void run() { openLinkedAlignmentAs(getAlignPanel().alignFrame, - new Alignment(getAlignment()), al, - title, SPLIT_FRAME); + new Alignment(getAlignment()), al, title, + SPLIT_FRAME); } }).setResponseHandler(NEW_WINDOW, new Runnable() { @@ -816,9 +820,8 @@ public class AlignViewport extends AlignmentViewport * @param mode * SPLIT_FRAME or NEW_WINDOW */ - public static void openLinkedAlignmentAs(AlignFrame thisFrame, AlignmentI thisAlignment, - AlignmentI al, String title, - int mode) + public static void openLinkedAlignmentAs(AlignFrame thisFrame, + AlignmentI thisAlignment, AlignmentI al, String title, int mode) { /* * Identify protein and dna alignments. Make a copy of this one if opening @@ -862,8 +865,8 @@ public class AlignViewport extends AlignmentViewport try { - newAlignFrame.setMaximum( - jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false)); + newAlignFrame.setMaximum(jalview.bin.Cache + .getDefault(Preferences.SHOW_FULLSCREEN, false)); } catch (java.beans.PropertyVetoException ex) { } @@ -886,8 +889,7 @@ public class AlignViewport extends AlignmentViewport * @return the protein alignment in the split frame */ static protected AlignmentI openSplitFrame(AlignFrame thisFrame, - AlignFrame newAlignFrame, - AlignmentI complement) + AlignFrame newAlignFrame, AlignmentI complement) { /* * Make a new frame with a copy of the alignment we are adding to. If this diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 20d06e9..0040dd7 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1148,13 +1148,13 @@ public class AlignmentPanel extends GAlignmentPanel implements public int getVisibleIdWidth(boolean onscreen) { // see if rendering offscreen - check preferences and calc width accordingly - if (!onscreen && Cache.getDefault("FIGURE_AUTOIDWIDTH", false)) + if (!onscreen && Cache.getDefault(Preferences.FIGURE_AUTOIDWIDTH, false)) { return calculateIdWidth(-1).width + 4; } Integer idwidth = null; if (onscreen || (idwidth = Cache - .getIntegerProperty("FIGURE_FIXEDIDWIDTH")) == null) + .getIntegerProperty(Preferences.FIGURE_FIXEDIDWIDTH)) == null) { int w = getIdPanel().getWidth(); return (w > 0 ? w : calculateIdWidth().width + 4); diff --git a/src/jalview/gui/CalculationChooser.java b/src/jalview/gui/CalculationChooser.java index 093eb48..45bf2d7 100644 --- a/src/jalview/gui/CalculationChooser.java +++ b/src/jalview/gui/CalculationChooser.java @@ -500,7 +500,8 @@ public class CalculationChooser extends JPanel * for backwards compatibility with Jalview < 2.8 (JAL-2962) */ if (nucleotide && forPca - && Cache.getDefault("BLOSUM62_PCA_FOR_NUCLEOTIDE", false)) + && Cache.getDefault(Preferences.BLOSUM62_PCA_FOR_NUCLEOTIDE, + false)) { filtered.add(scoreModels.getBlosum62()); } diff --git a/src/jalview/gui/CrossRefAction.java b/src/jalview/gui/CrossRefAction.java index 2d20ad9..2ee741b 100644 --- a/src/jalview/gui/CrossRefAction.java +++ b/src/jalview/gui/CrossRefAction.java @@ -141,7 +141,7 @@ public class CrossRefAction implements Runnable */ AlignFrame newFrame = new AlignFrame(xrefsAlignment, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - if (Cache.getDefault("HIDE_INTRONS", true)) + if (Cache.getDefault(Preferences.HIDE_INTRONS, true)) { newFrame.hideFeatureColumns(SequenceOntologyI.EXON, false); } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 4badcba..3514b75 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -330,7 +330,8 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer try { af.setMaximum( - jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false)); + jalview.bin.Cache.getDefault(Preferences.SHOW_FULLSCREEN, + false)); } catch (Exception ex) { } diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 92cc4c6..ad41293 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -408,10 +408,10 @@ public class FontChooser extends GFontChooser @Override public void defaultButton_actionPerformed() { - Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString()); - Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + ""); - Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString()); - Cache.setProperty("ANTI_ALIAS", + Cache.setProperty(Preferences.FONT_NAME, fontName.getSelectedItem().toString()); + Cache.setProperty(Preferences.FONT_STYLE, fontStyle.getSelectedIndex() + ""); + Cache.setProperty(Preferences.FONT_SIZE, fontSize.getSelectedItem().toString()); + Cache.setProperty(Preferences.ANTI_ALIAS, Boolean.toString(smoothFont.isSelected())); Cache.setProperty(Preferences.SCALE_PROTEIN_TO_CDNA, Boolean.toString(scaleAsCdna.isSelected())); diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index e80b28b..dbb5aec 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -85,81 +85,194 @@ import ext.edu.ucsf.rbvi.strucviz2.StructureManager; public class Preferences extends GPreferences { - public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES"; - public static final String QUESTIONNAIRE = "QUESTIONNAIRE"; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public static final String ADD_SS_ANN = "ADD_SS_ANN"; + + public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN"; + + public static final String ALLOW_UNPUBLISHED_PDB_QUERYING = "ALLOW_UNPUBLISHED_PDB_QUERYING"; public static final String ANNOTATIONCOLOUR_MAX = "ANNOTATIONCOLOUR_MAX"; public static final String ANNOTATIONCOLOUR_MIN = "ANNOTATIONCOLOUR_MIN"; - public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME"; + public static final String ANTI_ALIAS = "ANTI_ALIAS"; - public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA"; + public static final String AUTO_CALC_CONSENSUS = "AUTO_CALC_CONSENSUS"; + + public static final String AUTOASSOCIATE_PDBANDSEQS = "AUTOASSOCIATE_PDBANDSEQS"; + + public static final String CENTRE_COLUMN_LABELS = "CENTRE_COLUMN_LABELS"; + + public static final String CHIMERA_PATH = "CHIMERA_PATH"; + + public static final String DBREFFETCH_USEPICR = "DBREFFETCH_USEPICR"; public static final String DEFAULT_COLOUR = "DEFAULT_COLOUR"; + public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC"; + public static final String DEFAULT_COLOUR_PROT = "DEFAULT_COLOUR_PROT"; - public static final String DEFAULT_COLOUR_NUC = "DEFAULT_COLOUR_NUC"; + public static final String ENABLE_SPLIT_FRAME = "ENABLE_SPLIT_FRAME"; - public static final String ADD_TEMPFACT_ANN = "ADD_TEMPFACT_ANN"; + public static final String FIGURE_AUTOIDWIDTH = "FIGURE_AUTOIDWIDTH"; - public static final String ADD_SS_ANN = "ADD_SS_ANN"; + public static final String FIGURE_FIXEDIDWIDTH = "FIGURE_FIXEDIDWIDTH"; - public static final String USE_RNAVIEW = "USE_RNAVIEW"; + public static final String FOLLOW_SELECTIONS = "FOLLOW_SELECTIONS"; - public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB"; + public static final String FONT_NAME = "FONT_NAME"; - public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY"; + public static final String FONT_SIZE = "FONT_SIZE"; - public static final String CHIMERA_PATH = "CHIMERA_PATH"; + public static final String FONT_STYLE = "FONT_STYLE"; - public static final String SORT_ALIGNMENT = "SORT_ALIGNMENT"; + public static final String GAP_COLOUR = "GAP_COLOUR"; - public static final String WRAP_ALIGNMENT = "WRAP_ALIGNMENT"; + public static final String GAP_SYMBOL = "GAP_SYMBOL"; - public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS"; + public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR"; - public static final String SORT_BY_TREE = "SORT_BY_TREE"; + public static final String HIDE_INTRONS = "HIDE_INTRONS"; - public static final String SHOW_ANNOTATIONS = "SHOW_ANNOTATIONS"; + public static final String ID_ITALICS = "ID_ITALICS"; - public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE"; + public static final String ID_ORG_HOSTURL = "ID_ORG_HOSTURL"; - public static final String SHOW_CONSERVATION = "SHOW_CONSERVATION"; + public static final String MAP_WITH_SIFTS = "MAP_WITH_SIFTS"; - public static final String SHOW_QUALITY = "SHOW_QUALITY"; + public static final String NOQUESTIONNAIRES = "NOQUESTIONNAIRES"; - public static final String SHOW_CONSENSUS_HISTOGRAM = "SHOW_CONSENSUS_HISTOGRAM"; + public static final String NORMALISE_CONSENSUS_LOGO = "NORMALISE_CONSENSUS_LOGO"; + + public static final String NORMALISE_LOGO = "NORMALISE_LOGO"; + + public static final String PAD_GAPS = "PAD_GAPS"; + + public static final String PDB_DOWNLOAD_FORMAT = "PDB_DOWNLOAD_FORMAT"; + + public static final String QUESTIONNAIRE = "QUESTIONNAIRE"; + + public static final String RELAXEDSEQIDMATCHING = "RELAXEDSEQIDMATCHING"; + + public static final String RIGHT_ALIGN_IDS = "RIGHT_ALIGN_IDS"; + + public static final String SCALE_PROTEIN_TO_CDNA = "SCALE_PROTEIN_TO_CDNA"; + + public static final String SHOW_ANNOTATIONS = "SHOW_ANNOTATIONS"; + + public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE"; public static final String SHOW_CONSENSUS = "SHOW_CONSENSUS"; + public static final String SHOW_CONSENSUS_HISTOGRAM = "SHOW_CONSENSUS_HISTOGRAM"; + public static final String SHOW_CONSENSUS_LOGO = "SHOW_CONSENSUS_LOGO"; + public static final String SHOW_CONSERVATION = "SHOW_CONSERVATION"; + + public static final String SHOW_DBREFS_TOOLTIP = "SHOW_DBREFS_TOOLTIP"; + public static final String SHOW_GROUP_CONSENSUS = "SHOW_GROUP_CONSENSUS"; public static final String SHOW_GROUP_CONSERVATION = "SHOW_GROUP_CONSERVATION"; - public static final String NORMALISE_CONSENSUS_LOGO = "NORMALISE_CONSENSUS_LOGO"; + public static final String SHOW_JVSUFFIX = "SHOW_JVSUFFIX"; - public static final String NORMALISE_LOGO = "NORMALISE_LOGO"; + public static final String SHOW_NPFEATS_TOOLTIP = "SHOW_NPFEATS_TOOLTIP"; public static final String SHOW_OCCUPANCY = "SHOW_OCCUPANCY"; + public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START"; + public static final String SHOW_OVERVIEW = "SHOW_OVERVIEW"; + public static final String SHOW_QUALITY = "SHOW_QUALITY"; + public static final String SHOW_UNCONSERVED = "SHOW_UNCONSERVED"; - public static final String SHOW_OV_HIDDEN_AT_START = "SHOW_OV_HIDDEN_AT_START"; + public static final String SORT_ALIGNMENT = "SORT_ALIGNMENT"; - public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS"; + public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS"; + + public static final String SORT_BY_TREE = "SORT_BY_TREE"; + + public static final String STRUCT_FROM_PDB = "STRUCT_FROM_PDB"; + + public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY"; + + public static final String UNIPROT_DOMAIN = "UNIPROT_DOMAIN"; + + public static final String USE_FULL_SO = "USE_FULL_SO"; public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP"; - public static final String GAP_COLOUR = "GAP_COLOUR"; + public static final String USE_RNAVIEW = "USE_RNAVIEW"; + + public static final String USER_DEFINED_COLOURS = "USER_DEFINED_COLOURS"; + + public static final String WRAP_ALIGNMENT = "WRAP_ALIGNMENT"; - public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR"; private static final int MIN_FONT_SIZE = 1; @@ -183,6 +296,12 @@ public class Preferences extends GPreferences public static final List groupURLLinks; // not implemented + public static final String BLOSUM62_PCA_FOR_NUCLEOTIDE = "BLOSUM62_PCA_FOR_NUCLEOTIDE"; + + public static final String SHOW_IDENTITY = "SHOW_IDENTITY"; + + public static final String SHOW_FULLSCREEN = "SHOW_FULLSCREEN"; + static { @@ -258,14 +377,14 @@ public class Preferences extends GPreferences /* * Set Visual tab defaults */ - seqLimit.setSelected(Cache.getDefault("SHOW_JVSUFFIX", true)); - rightAlign.setSelected(Cache.getDefault("RIGHT_ALIGN_IDS", false)); - fullScreen.setSelected(Cache.getDefault("SHOW_FULLSCREEN", false)); - annotations.setSelected(Cache.getDefault("SHOW_ANNOTATIONS", true)); + seqLimit.setSelected(Cache.getDefault(SHOW_JVSUFFIX, true)); + rightAlign.setSelected(Cache.getDefault(RIGHT_ALIGN_IDS, false)); + fullScreen.setSelected(Cache.getDefault(SHOW_FULLSCREEN, false)); + annotations.setSelected(Cache.getDefault(SHOW_ANNOTATIONS, true)); conservation.setSelected(Cache.getDefault(SHOW_CONSERVATION, true)); quality.setSelected(Cache.getDefault(SHOW_QUALITY, true)); - identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true)); + identity.setSelected(Cache.getDefault(SHOW_IDENTITY, true)); openoverv.setSelected(Cache.getDefault(SHOW_OVERVIEW, false)); showUnconserved .setSelected(Cache.getDefault(SHOW_UNCONSERVED, false)); @@ -279,9 +398,9 @@ public class Preferences extends GPreferences showConsensLogo .setSelected(Cache.getDefault(SHOW_CONSENSUS_LOGO, false)); showNpTooltip - .setSelected(Cache.getDefault("SHOW_NPFEATS_TOOLTIP", true)); + .setSelected(Cache.getDefault(SHOW_NPFEATS_TOOLTIP, true)); showDbRefTooltip - .setSelected(Cache.getDefault("SHOW_DBREFS_TOOLTIP", true)); + .setSelected(Cache.getDefault(SHOW_DBREFS_TOOLTIP, true)); String[] fonts = java.awt.GraphicsEnvironment .getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); @@ -299,23 +418,23 @@ public class Preferences extends GPreferences fontStyleCB.addItem("bold"); fontStyleCB.addItem("italic"); - fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif")); - fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10")); + fontNameCB.setSelectedItem(Cache.getDefault(FONT_NAME, "SansSerif")); + fontSizeCB.setSelectedItem(Cache.getDefault(FONT_SIZE, "10")); fontStyleCB.setSelectedItem( - Cache.getDefault("FONT_STYLE", Font.PLAIN + "")); + Cache.getDefault(FONT_STYLE, Font.PLAIN + "")); - smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false)); + smoothFont.setSelected(Cache.getDefault(ANTI_ALIAS, false)); scaleProteinToCdna .setSelected(Cache.getDefault(SCALE_PROTEIN_TO_CDNA, false)); - idItalics.setSelected(Cache.getDefault("ID_ITALICS", true)); + idItalics.setSelected(Cache.getDefault(ID_ITALICS, true)); - wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false)); + wrap.setSelected(Cache.getDefault(WRAP_ALIGNMENT, false)); gapSymbolCB.addItem("-"); gapSymbolCB.addItem("."); - gapSymbolCB.setSelectedItem(Cache.getDefault("GAP_SYMBOL", "-")); + gapSymbolCB.setSelectedItem(Cache.getDefault(GAP_SYMBOL, "-")); sortby.addItem("No sort"); sortby.addItem("Id"); @@ -403,7 +522,7 @@ public class Preferences extends GPreferences } }); - if (Cache.getDefault("MAP_WITH_SIFTS", false)) + if (Cache.getDefault(MAP_WITH_SIFTS, false)) { siftsMapping.setSelected(true); } @@ -413,7 +532,7 @@ public class Preferences extends GPreferences } SiftsSettings - .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false)); + .setMapWithSifts(Cache.getDefault(MAP_WITH_SIFTS, false)); /* * Set Connections tab defaults @@ -558,10 +677,10 @@ public class Preferences extends GPreferences setupOutputCombo(epsRendering, "EPS_RENDERING"); setupOutputCombo(htmlRendering, "HTML_RENDERING"); setupOutputCombo(svgRendering, "SVG_RENDERING"); - autoIdWidth.setSelected(Cache.getDefault("FIGURE_AUTOIDWIDTH", false)); + autoIdWidth.setSelected(Cache.getDefault(FIGURE_AUTOIDWIDTH, false)); userIdWidth.setEnabled(!autoIdWidth.isSelected()); userIdWidthlabel.setEnabled(!autoIdWidth.isSelected()); - Integer wi = Cache.getIntegerProperty("FIGURE_FIXEDIDWIDTH"); + Integer wi = Cache.getIntegerProperty(FIGURE_FIXEDIDWIDTH); userIdWidth.setText(wi == null ? "" : wi.toString()); // TODO: refactor to use common enum via FormatAdapter and allow extension // for new flat file formats @@ -580,8 +699,8 @@ public class Preferences extends GPreferences * Set Editing tab defaults */ autoCalculateConsCheck - .setSelected(Cache.getDefault("AUTO_CALC_CONSENSUS", true)); - padGaps.setSelected(Cache.getDefault("PAD_GAPS", false)); + .setSelected(Cache.getDefault(AUTO_CALC_CONSENSUS, true)); + padGaps.setSelected(Cache.getDefault(PAD_GAPS, false)); sortByTree.setSelected(Cache.getDefault(SORT_BY_TREE, false)); annotations_actionPerformed(null); // update the display of the annotation @@ -644,36 +763,36 @@ public class Preferences extends GPreferences /* * Save Visual settings */ - Cache.setPropertyNoSave("SHOW_JVSUFFIX", + Cache.setPropertyNoSave(SHOW_JVSUFFIX, Boolean.toString(seqLimit.isSelected())); - Cache.setPropertyNoSave("RIGHT_ALIGN_IDS", + Cache.setPropertyNoSave(RIGHT_ALIGN_IDS, Boolean.toString(rightAlign.isSelected())); - Cache.setPropertyNoSave("SHOW_FULLSCREEN", + Cache.setPropertyNoSave(SHOW_FULLSCREEN, Boolean.toString(fullScreen.isSelected())); - Cache.setPropertyNoSave("SHOW_OVERVIEW", + Cache.setPropertyNoSave(SHOW_OVERVIEW, Boolean.toString(openoverv.isSelected())); - Cache.setPropertyNoSave("SHOW_ANNOTATIONS", + Cache.setPropertyNoSave(SHOW_ANNOTATIONS, Boolean.toString(annotations.isSelected())); Cache.setPropertyNoSave(SHOW_CONSERVATION, Boolean.toString(conservation.isSelected())); Cache.setPropertyNoSave(SHOW_QUALITY, Boolean.toString(quality.isSelected())); - Cache.setPropertyNoSave("SHOW_IDENTITY", + Cache.setPropertyNoSave(SHOW_IDENTITY, Boolean.toString(identity.isSelected())); - Cache.setPropertyNoSave("GAP_SYMBOL", + Cache.setPropertyNoSave(GAP_SYMBOL, gapSymbolCB.getSelectedItem().toString()); - Cache.setPropertyNoSave("FONT_NAME", + Cache.setPropertyNoSave(FONT_NAME, fontNameCB.getSelectedItem().toString()); - Cache.setPropertyNoSave("FONT_STYLE", + Cache.setPropertyNoSave(FONT_STYLE, fontStyleCB.getSelectedItem().toString()); - Cache.setPropertyNoSave("FONT_SIZE", + Cache.setPropertyNoSave(FONT_SIZE, fontSizeCB.getSelectedItem().toString()); - Cache.setPropertyNoSave("ID_ITALICS", + Cache.setPropertyNoSave(ID_ITALICS, Boolean.toString(idItalics.isSelected())); - Cache.setPropertyNoSave("SHOW_UNCONSERVED", + Cache.setPropertyNoSave(SHOW_UNCONSERVED, Boolean.toString(showUnconserved.isSelected())); Cache.setPropertyNoSave(SHOW_OCCUPANCY, Boolean.toString(showOccupancy.isSelected())); @@ -685,16 +804,16 @@ public class Preferences extends GPreferences Boolean.toString(showConsensHistogram.isSelected())); Cache.setPropertyNoSave(SHOW_CONSENSUS_LOGO, Boolean.toString(showConsensLogo.isSelected())); - Cache.setPropertyNoSave("ANTI_ALIAS", + Cache.setPropertyNoSave(ANTI_ALIAS, Boolean.toString(smoothFont.isSelected())); Cache.setPropertyNoSave(SCALE_PROTEIN_TO_CDNA, Boolean.toString(scaleProteinToCdna.isSelected())); - Cache.setPropertyNoSave("SHOW_NPFEATS_TOOLTIP", + Cache.setPropertyNoSave(SHOW_NPFEATS_TOOLTIP, Boolean.toString(showNpTooltip.isSelected())); - Cache.setPropertyNoSave("SHOW_DBREFS_TOOLTIP", + Cache.setPropertyNoSave(SHOW_DBREFS_TOOLTIP, Boolean.toString(showDbRefTooltip.isSelected())); - Cache.setPropertyNoSave("WRAP_ALIGNMENT", + Cache.setPropertyNoSave(WRAP_ALIGNMENT, Boolean.toString(wrap.isSelected())); Cache.setPropertyNoSave("STARTUP_FILE", @@ -754,7 +873,7 @@ public class Preferences extends GPreferences Cache.setPropertyNoSave(STRUCTURE_DISPLAY, structViewer.getSelectedItem().toString()); Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText()); - Cache.setPropertyNoSave("MAP_WITH_SIFTS", + Cache.setPropertyNoSave(MAP_WITH_SIFTS, Boolean.toString(siftsMapping.isSelected())); SiftsSettings.setMapWithSifts(siftsMapping.isSelected()); @@ -862,7 +981,7 @@ public class Preferences extends GPreferences Boolean.toString(modellerOutput.isSelected())); Cache.setPropertyNoSave("EXPORT_EMBBED_BIOJSON", Boolean.toString(embbedBioJSON.isSelected())); - Cache.setPropertyNoSave("FIGURE_AUTOIDWIDTH", + Cache.setPropertyNoSave(FIGURE_AUTOIDWIDTH, Boolean.toString(autoIdWidth.isSelected())); userIdWidth_actionPerformed(); Cache.setPropertyNoSave("FIGURE_FIXEDIDWIDTH", @@ -871,11 +990,11 @@ public class Preferences extends GPreferences /* * Save Editing settings */ - Cache.setPropertyNoSave("AUTO_CALC_CONSENSUS", + Cache.setPropertyNoSave(AUTO_CALC_CONSENSUS, Boolean.toString(autoCalculateConsCheck.isSelected())); - Cache.setPropertyNoSave("SORT_BY_TREE", + Cache.setPropertyNoSave(SORT_BY_TREE, Boolean.toString(sortByTree.isSelected())); - Cache.setPropertyNoSave("PAD_GAPS", + Cache.setPropertyNoSave(PAD_GAPS, Boolean.toString(padGaps.isSelected())); if (!Platform.isJS()) @@ -943,9 +1062,9 @@ public class Preferences extends GPreferences Cache.setPropertyNoSave(SHOW_CONSERVATION, "true"); Cache.setPropertyNoSave(SHOW_QUALITY, "false"); Cache.setPropertyNoSave(SHOW_CONSENSUS, "true"); - Cache.setPropertyNoSave("SHOW_UNCONSERVED", "false"); - Cache.setPropertyNoSave("SHOW_GROUP_CONSERVATION", "false"); - Cache.setPropertyNoSave("SHOW_GROUP_CONCENSUS", "false"); + Cache.setPropertyNoSave(SHOW_UNCONSERVED, "false"); + Cache.setPropertyNoSave(SHOW_GROUP_CONSERVATION, "false"); + Cache.setPropertyNoSave(SHOW_GROUP_CONSENSUS, "false"); // TODO -- just a start here } diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index 518654e..b8e3b33 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -815,7 +815,7 @@ public class SequenceFetcher extends JPanel implements Runnable { af.getViewport().applyFeaturesStyle(preferredFeatureColours); } - if (Cache.getDefault("HIDE_INTRONS", true)) + if (Cache.getDefault(Preferences.HIDE_INTRONS, true)) { af.hideFeatureColumns(SequenceOntologyI.EXON, false); } @@ -827,7 +827,8 @@ public class SequenceFetcher extends JPanel implements Runnable try { - af.setMaximum(Cache.getDefault("SHOW_FULLSCREEN", false)); + af.setMaximum( + Cache.getDefault(Preferences.SHOW_FULLSCREEN, false)); } catch (Exception ex) { } diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 85cf48a..b0414af 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -30,6 +30,7 @@ import jalview.datamodel.HiddenColumns; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.Preferences; import jalview.util.Comparison; import java.io.File; @@ -63,13 +64,16 @@ public class FormatAdapter extends AppletFormatAdapter private void init() { - if (jalview.bin.Cache.getDefault("STRUCT_FROM_PDB", true)) + if (jalview.bin.Cache.getDefault(Preferences.STRUCT_FROM_PDB, true)) { - annotFromStructure = jalview.bin.Cache.getDefault("ADD_TEMPFACT_ANN", + annotFromStructure = jalview.bin.Cache.getDefault( + Preferences.ADD_TEMPFACT_ANN, true); - localSecondaryStruct = jalview.bin.Cache.getDefault("ADD_SS_ANN", + localSecondaryStruct = jalview.bin.Cache.getDefault( + Preferences.ADD_SS_ANN, true); - serviceSecondaryStruct = jalview.bin.Cache.getDefault("USE_RNAVIEW", + serviceSecondaryStruct = jalview.bin.Cache + .getDefault(Preferences.USE_RNAVIEW, true); } else diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index dbe46f6..1263adb 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -556,7 +556,7 @@ public class GAlignFrame extends JInternalFrame annotationPanelMenuItem .setText(MessageManager.getString("label.show_annotations")); annotationPanelMenuItem - .setState(Cache.getDefault("SHOW_ANNOTATIONS", true)); + .setState(Cache.getDefault(Preferences.SHOW_ANNOTATIONS, true)); annotationPanelMenuItem.addActionListener(new ActionListener() { @Override @@ -1065,7 +1065,7 @@ public class GAlignFrame extends JInternalFrame }); seqLimits.setText( MessageManager.getString("label.show_sequence_limits")); - seqLimits.setState(jalview.bin.Cache.getDefault("SHOW_JVSUFFIX", true)); + seqLimits.setState(jalview.bin.Cache.getDefault(Preferences.SHOW_JVSUFFIX, true)); seqLimits.addActionListener(new ActionListener() { @Override @@ -1216,7 +1216,7 @@ public class GAlignFrame extends JInternalFrame padGapsMenuitem.setText(MessageManager.getString("label.pad_gaps")); padGapsMenuitem - .setState(jalview.bin.Cache.getDefault("PAD_GAPS", false)); + .setState(jalview.bin.Cache.getDefault(Preferences.PAD_GAPS, false)); padGapsMenuitem.addActionListener(new ActionListener() { @Override @@ -1359,7 +1359,7 @@ public class GAlignFrame extends JInternalFrame autoCalculate.setText( MessageManager.getString("label.autocalculate_consensus")); autoCalculate.setState( - jalview.bin.Cache.getDefault("AUTO_CALC_CONSENSUS", true)); + jalview.bin.Cache.getDefault(Preferences.AUTO_CALC_CONSENSUS, true)); autoCalculate.addActionListener(new ActionListener() { @Override @@ -1373,7 +1373,8 @@ public class GAlignFrame extends JInternalFrame sortByTree.setToolTipText("" + MessageManager.getString( "label.enable_automatically_sort_alignment_when_open_new_tree")); sortByTree - .setState(jalview.bin.Cache.getDefault("SORT_BY_TREE", false)); + .setState(jalview.bin.Cache.getDefault(Preferences.SORT_BY_TREE, + false)); sortByTree.addActionListener(new ActionListener() { @Override diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 6c21941..7745b74 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -32,6 +32,7 @@ import jalview.gui.Desktop; import jalview.gui.FeatureSettings; import jalview.gui.IProgressIndicator; import jalview.gui.OOMWarning; +import jalview.gui.Preferences; import jalview.util.DBRefUtils; import jalview.util.MessageManager; import jalview.ws.seqfetcher.DbSourceProxy; @@ -302,7 +303,7 @@ public class DBRefFetcher implements Runnable } try { - if (Cache.getDefault("DBREFFETCH_USEPICR", false)) + if (Cache.getDefault(Preferences.DBREFFETCH_USEPICR, false)) { picrClient = new AccessionMapperServiceLocator() .getAccessionMapperPort(); diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 6f5f033..a3d6dbf 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -81,7 +81,7 @@ public class Uniprot extends DbSourceProxyImpl private String getDomain() { - return Cache.getDefault("UNIPROT_DOMAIN", DEFAULT_UNIPROT_DOMAIN); + return Cache.getDefault(Preferences.UNIPROT_DOMAIN, DEFAULT_UNIPROT_DOMAIN); } /* -- 1.7.10.2