JAL-3186 ensure transparency slider position is updated on revert
authorJim Procter <jprocter@issues.jalview.org>
Fri, 21 Feb 2020 15:12:18 +0000 (15:12 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 21 Feb 2020 15:12:18 +0000 (15:12 +0000)
src/jalview/gui/FeatureSettings.java

index dc7283b..3efc63e 100644 (file)
@@ -188,12 +188,22 @@ public class FeatureSettings extends JPanel
   {
     // save transparency for restore on Cancel
     originalTransparency = fr.getTransparency();
-    int originalTransparencyAsPercent = (int) (originalTransparency * 100);
-    transparency.setMaximum(100 - originalTransparencyAsPercent);
+
+    updateTransparencySliderFromFR();
 
     originalFilters = new HashMap<>(fr.getFeatureFilters()); // shallow copy
     originalViewStyle = new ViewStyle(af.viewport.getViewStyle());
   }
+
+  private void updateTransparencySliderFromFR()
+  {
+    boolean incon = inConstruction;
+    inConstruction = true;
+
+    int transparencyAsPercent = (int) (fr.getTransparency() * 100);
+    transparency.setValue(100 - transparencyAsPercent);
+    inConstruction = incon;
+  }
   /**
    * Constructor
    * 
@@ -203,7 +213,9 @@ public class FeatureSettings extends JPanel
   {
     this.af = alignFrame;
     fr = af.getFeatureRenderer();
+
     storeOriginalSettings();
+
     try
     {
       jbInit();
@@ -1310,6 +1322,7 @@ public class FeatureSettings extends JPanel
       public void actionPerformed(ActionEvent e)
       {
         revert();
+        refreshDisplay();
         if (!hasComplement)
         {
           close();
@@ -2052,6 +2065,7 @@ public class FeatureSettings extends JPanel
     fr.setFeatureFilters(originalFilters);
     updateFeatureRenderer(originalData);
     af.getViewport().setViewStyle(originalViewStyle);
+    updateTransparencySliderFromFR();
     updateComplementButtons();
     refreshDisplay();
   }