From 478d5e13ea50c83e373ae46668422888974c0e79 Mon Sep 17 00:00:00 2001 From: kiramt Date: Thu, 31 Aug 2017 11:46:14 +0100 Subject: [PATCH] JAL-2527 Updates following code review --- src/jalview/gui/OverviewCanvas.java | 9 +++++---- src/jalview/gui/OverviewPanel.java | 3 ++- src/jalview/gui/Preferences.java | 22 ++++++++++++--------- src/jalview/jbgui/GPreferences.java | 6 +----- src/jalview/renderer/OverviewResColourFinder.java | 10 +++++----- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java index 5f6a1f6..ed1497a 100644 --- a/src/jalview/gui/OverviewCanvas.java +++ b/src/jalview/gui/OverviewCanvas.java @@ -71,10 +71,11 @@ public class OverviewCanvas extends JComponent sr.renderGaps = false; fr = new jalview.renderer.seqfeatures.FeatureRenderer(av); - boolean useLegacy = Cache.getDefault("USE_LEGACY_GAP", false); - Color gapCol = Cache.getDefaultColour("GAP_COLOUR", Color.lightGray); - Color hiddenCol = Cache.getDefaultColour("HIDDEN_COLOUR", - Color.DARK_GRAY.darker()); + boolean useLegacy = Cache.getDefault(Preferences.USE_LEGACY_GAP, false); + Color gapCol = Cache.getDefaultColour(Preferences.GAP_COLOUR, + Preferences.OVERVIEW_DEFAULT_GAP); + Color hiddenCol = Cache.getDefaultColour(Preferences.HIDDEN_COLOUR, + Preferences.OVERVIEW_DEFAULT_HIDDEN); cf = new OverviewResColourFinder(useLegacy, gapCol, hiddenCol); } diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index d66bbf0..3c94f26 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -80,7 +80,8 @@ public class OverviewPanel extends JPanel this.av = alPanel.av; this.ap = alPanel; - showHidden = Cache.getDefault("SHOW_OV_HIDDEN_AT_START", true); + showHidden = Cache.getDefault(Preferences.SHOW_OV_HIDDEN_AT_START, + true); if (showHidden) { od = new OverviewDimensionsShowHidden(av.getRanges(), diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 3c0faab..7ceb04e 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -113,15 +113,19 @@ public class Preferences extends GPreferences public static final String USE_LEGACY_GAP = "USE_LEGACY_GAP"; + public static final String GAP_COLOUR = "GAP_COLOUR"; + + public static final String HIDDEN_COLOUR = "HIDDEN_COLOUR"; + private static final int MIN_FONT_SIZE = 1; private static final int MAX_FONT_SIZE = 30; - private static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray; + public static final Color OVERVIEW_DEFAULT_GAP = Color.lightGray; - private static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white; + public static final Color OVERVIEW_DEFAULT_LEGACY_GAP = Color.white; - private static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray + public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray .darker(); /** @@ -323,15 +327,15 @@ public class Preferences extends GPreferences * Set overview panel defaults */ gapColour.setBackground( - Cache.getDefaultColour("GAP_COLOUR", OVERVIEW_DEFAULT_GAP)); + Cache.getDefaultColour(GAP_COLOUR, OVERVIEW_DEFAULT_GAP)); hiddenColour.setBackground( - Cache.getDefaultColour("HIDDEN_COLOUR", + Cache.getDefaultColour(HIDDEN_COLOUR, OVERVIEW_DEFAULT_HIDDEN)); - useLegacyGap.setSelected(Cache.getDefault("USE_LEGACY_GAP", false)); + useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false)); gapLabel.setEnabled(!useLegacyGap.isSelected()); gapColour.setEnabled(!useLegacyGap.isSelected()); showHiddenAtStart - .setSelected(Cache.getDefault("SHOW_OV_HIDDEN_AT_START", true)); + .setSelected(Cache.getDefault(SHOW_OV_HIDDEN_AT_START, true)); /* * Set Structure tab defaults. @@ -658,8 +662,8 @@ public class Preferences extends GPreferences /* * Save Overview settings */ - Cache.setColourProperty("GAP_COLOUR", gapColour.getBackground()); - Cache.setColourProperty("HIDDEN_COLOUR", hiddenColour.getBackground()); + Cache.setColourProperty(GAP_COLOUR, gapColour.getBackground()); + Cache.setColourProperty(HIDDEN_COLOUR, hiddenColour.getBackground()); Cache.applicationProperties.setProperty(USE_LEGACY_GAP, Boolean.toString(useLegacyGap.isSelected())); Cache.applicationProperties.setProperty(SHOW_OV_HIDDEN_AT_START, diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index fa45769..dfd2c2d 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -183,8 +183,6 @@ public class GPreferences extends JPanel /* * Overview tab components */ - protected JPanel overviewTab; - protected JPanel gapColour = new JPanel(); protected JPanel hiddenColour = new JPanel(); @@ -195,8 +193,6 @@ public class GPreferences extends JPanel protected JLabel gapLabel; - protected JButton resetButton; - /* * Connections tab components */ @@ -1093,7 +1089,7 @@ public class GPreferences extends JPanel c6.insets = new Insets(0, 0, 0, 15); overviewPanel.add(hiddenColour, c6); - resetButton = new JButton( + JButton resetButton = new JButton( MessageManager.getString("label.reset_to_defaults")); resetButton.addActionListener(new ActionListener() diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index 07fc6e3..b606ba3 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -22,6 +22,7 @@ package jalview.renderer; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.Preferences; import jalview.util.Comparison; import java.awt.Color; @@ -41,9 +42,8 @@ public class OverviewResColourFinder extends ResidueColourFinder */ public OverviewResColourFinder() { - GAP_COLOUR = Color.lightGray; - RESIDUE_COLOUR = Color.white; - HIDDEN_COLOUR = Color.DARK_GRAY.darker(); + this(false, Preferences.OVERVIEW_DEFAULT_GAP, + Preferences.OVERVIEW_DEFAULT_HIDDEN); } /** @@ -84,8 +84,8 @@ public class OverviewResColourFinder extends ResidueColourFinder // settings if (shader.getColourScheme() != null) { - if (!shader.getColourScheme().hasGapColour() - && Comparison.isGap(currentChar)) + if (Comparison.isGap(currentChar) + && (!shader.getColourScheme().hasGapColour())) { resBoxColour = GAP_COLOUR; } -- 1.7.10.2