JAL-3853 JAL-1870 toggle to enable/disable posterior probability transparency when...
[jalview.git] / src / jalview / gui / AnnotationRowFilter.java
index a3ce528..50835f2 100644 (file)
@@ -80,7 +80,7 @@ public abstract class AnnotationRowFilter extends JPanel
    */
   protected boolean sliderDragging = false;
 
-  protected JComboBox<String> threshold = new JComboBox<String>();
+  protected JComboBox<String> threshold = new JComboBox<>();
 
   protected JComboBox<String> annotations;
 
@@ -98,7 +98,8 @@ public abstract class AnnotationRowFilter extends JPanel
    * @param viewport
    * @param alignPanel
    */
-  public AnnotationRowFilter(AlignViewport viewport, final AlignmentPanel alignPanel)
+  public AnnotationRowFilter(AlignViewport viewport,
+          final AlignmentPanel alignPanel)
   {
     this.av = viewport;
     this.ap = alignPanel;
@@ -148,6 +149,7 @@ public abstract class AnnotationRowFilter extends JPanel
     }
     adjusting = oldadj;
   }
+
   protected void addSliderMouseListeners()
   {
 
@@ -170,33 +172,30 @@ public abstract class AnnotationRowFilter extends JPanel
       @Override
       public void mouseReleased(MouseEvent evt)
       {
-        if (sliderDragging)
-        {
-          sliderDragging = false;
-          valueChanged(true);
-        }
-        ap.paintAlignment(true);
+        sliderDragReleased();
       }
     });
   }
 
-/**
- * Builds and returns a list of menu items (display text) for choice of
- * annotation. Also builds maps between annotations, their positions in the
- * list, and their display labels in the list.
- * 
- * @param isSeqAssociated
- * @return
- */
+  /**
+   * Builds and returns a list of menu items (display text) for choice of
+   * annotation. Also builds maps between annotations, their positions in the
+   * list, and their display labels in the list.
+   * 
+   * @param isSeqAssociated
+   * @return
+   */
   public Vector<String> getAnnotationItems(boolean isSeqAssociated)
   {
-    annotationLabels = new HashMap<AlignmentAnnotation, String>();
+    annotationLabels = new HashMap<>();
 
-    Vector<String> list = new Vector<String>();
+    Vector<String> list = new Vector<>();
     int index = 1;
-    int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
+    int[] anmap = new int[av.getAlignment()
+            .getAlignmentAnnotation().length];
     seqAssociated.setEnabled(false);
-    for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
+    for (int i = 0; i < av.getAlignment()
+            .getAlignmentAnnotation().length; i++)
     {
       AlignmentAnnotation annotation = av.getAlignment()
               .getAlignmentAnnotation()[i];
@@ -267,7 +266,7 @@ public abstract class AnnotationRowFilter extends JPanel
   public void cancel_actionPerformed()
   {
     reset();
-    ap.paintAlignment(true);
+    ap.paintAlignment(true, true);
     try
     {
       frame.setClosed(true);
@@ -298,9 +297,8 @@ public abstract class AnnotationRowFilter extends JPanel
       float f = Float.parseFloat(thresholdValue.getText());
       if (percentThreshold.isSelected())
       {
-        slider.setValue(slider.getMinimum()
-                + ((int) ((f / 100f) * (slider.getMaximum() - slider
-                        .getMinimum()))));
+        slider.setValue(slider.getMinimum() + ((int) ((f / 100f)
+                * (slider.getMaximum() - slider.getMinimum()))));
       }
       else
       {
@@ -369,6 +367,7 @@ public abstract class AnnotationRowFilter extends JPanel
 
     updateView();
   }
+  
 
   protected void propagateSeqAssociatedThreshold(boolean allAnnotation,
           AlignmentAnnotation annotation)
@@ -379,9 +378,11 @@ public abstract class AnnotationRowFilter extends JPanel
     }
 
     float thr = annotation.threshold.value;
-    for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
+    for (int i = 0; i < av.getAlignment()
+            .getAlignmentAnnotation().length; i++)
     {
-      AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[i];
+      AlignmentAnnotation aa = av.getAlignment()
+              .getAlignmentAnnotation()[i];
       if (aa.label.equals(annotation.label)
               && (annotation.getCalcId() == null ? aa.getCalcId() == null
                       : annotation.getCalcId().equals(aa.getCalcId())))
@@ -408,6 +409,11 @@ public abstract class AnnotationRowFilter extends JPanel
     this.currentAnnotation = annotation;
   }
 
+  /**
+   * update associated view model and trigger any necessary repaints.
+   * 
+   * @param updateAllAnnotation
+   */
   protected abstract void valueChanged(boolean updateAllAnnotation);
 
   protected abstract void updateView();
@@ -451,8 +457,8 @@ public abstract class AnnotationRowFilter extends JPanel
         selectedAnnotationChanged();
       }
     });
-    annotations.setToolTipText(MessageManager
-            .getString("info.select_annotation_row"));
+    annotations.setToolTipText(
+            MessageManager.getString("info.select_annotation_row"));
 
     threshold.addActionListener(new ActionListener()
     {
@@ -474,7 +480,8 @@ public abstract class AnnotationRowFilter extends JPanel
       }
     });
 
-    percentThreshold.setText(MessageManager.getString("label.as_percentage"));
+    percentThreshold
+            .setText(MessageManager.getString("label.as_percentage"));
     percentThreshold.addActionListener(new ActionListener()
     {
       @Override
@@ -513,4 +520,13 @@ public abstract class AnnotationRowFilter extends JPanel
   {
     this.annotations = anns;
   }
+
+  protected void sliderDragReleased()
+  {
+    if (sliderDragging)
+    {
+      sliderDragging = false;
+      valueChanged(true);
+    }
+  }
 }