JAL-3083 another try: restore original GraphLines with original values bug/JAL-3083cancelAnnotationColour
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 4 Mar 2019 15:17:17 +0000 (15:17 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 4 Mar 2019 15:17:17 +0000 (15:17 +0000)
src/jalview/gui/AnnotationColourChooser.java

index b29a1dd..2b7d678 100644 (file)
@@ -63,7 +63,9 @@ public class AnnotationColourChooser extends AnnotationRowFilter
 
   private Map<SequenceGroup, ColourSchemeI> oldgroupColours;
 
-  private Map<AlignmentAnnotation, GraphLine> oldThresholds;
+  private Map<AlignmentAnnotation, GraphLine> oldGraphLines;
+
+  private Map<GraphLine, Float> oldThresholds;
 
   private JCheckBox useOriginalColours = new JCheckBox();
 
@@ -183,6 +185,7 @@ public class AnnotationColourChooser extends AnnotationRowFilter
      * save any existing annotation threshold settings; note we make a copy
      * of each in case the current threshold value gets amended
      */
+    oldGraphLines = new HashMap<>();
     oldThresholds = new HashMap<>();
     AlignmentAnnotation[] anns = av.getAlignment().getAlignmentAnnotation();
     if (anns != null)
@@ -190,8 +193,11 @@ public class AnnotationColourChooser extends AnnotationRowFilter
       for (AlignmentAnnotation ann : anns)
       {
         GraphLine thresh = ann.getThreshold();
-        oldThresholds.put(ann,
-                thresh == null ? null : new GraphLine(thresh));
+        oldGraphLines.put(ann, thresh);
+        if (thresh != null)
+        {
+          oldThresholds.put(thresh, thresh.value);
+        }
       }
     }
   }
@@ -364,10 +370,15 @@ public class AnnotationColourChooser extends AnnotationRowFilter
         sg.setColourScheme(oldgroupColours.get(sg));
       }
     }
-    for (Entry<AlignmentAnnotation, GraphLine> entry : oldThresholds
+    for (Entry<AlignmentAnnotation, GraphLine> entry : oldGraphLines
             .entrySet())
     {
-      entry.getKey().setThreshold(entry.getValue());
+      GraphLine graphLine = entry.getValue();
+      entry.getKey().setThreshold(graphLine);
+      if (graphLine != null)
+      {
+        graphLine.value = oldThresholds.get(graphLine).floatValue();
+      }
     }
   }