JAL-1620 version bump and release notes
[jalview.git] / src / jalview / gui / AnnotationColourChooser.java
index 39f3a13..1f86d87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  */
 package jalview.gui;
 
-import java.util.*;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.miginfocom.swing.MigLayout;
-
 import jalview.bin.Cache;
-import jalview.datamodel.*;
-import jalview.schemes.*;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.GraphLine;
+import jalview.datamodel.SequenceGroup;
+import jalview.schemes.AnnotationColourGradient;
+import jalview.schemes.ColourSchemeI;
 import jalview.util.MessageManager;
 
+import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JColorChooser;
+import javax.swing.JComboBox;
+import javax.swing.JInternalFrame;
+import javax.swing.JLayeredPane;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+import javax.swing.JTextField;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import net.miginfocom.swing.MigLayout;
 
 public class AnnotationColourChooser extends JPanel
 {
@@ -84,11 +101,12 @@ public class AnnotationColourChooser extends JPanel
 
     slider.addChangeListener(new ChangeListener()
     {
+      @Override
       public void stateChanged(ChangeEvent evt)
       {
         if (!adjusting)
         {
-          thresholdValue.setText(((float) slider.getValue() / 1000f) + "");
+          thresholdValue.setText((slider.getValue() / 1000f) + "");
           valueChanged(!sliderDragging);
         }
       }
@@ -109,6 +127,7 @@ public class AnnotationColourChooser extends JPanel
         super.mouseDragged(e);
       }
 
+      @Override
       public void mouseReleased(MouseEvent evt)
       {
         if (sliderDragging)
@@ -168,8 +187,7 @@ public class AnnotationColourChooser extends JPanel
         threshold.setSelectedIndex(2);
         break;
       default:
-        throw new Error(
-                "Implementation error: don't know about threshold setting for current AnnotationColourGradient.");
+        throw new Error(MessageManager.getString("error.implementation_error_dont_know_about_thereshold_setting"));
       }
       thresholdIsMin.setSelected(acg.thresholdIsMinMax);
       thresholdValue.setText("" + acg.getAnnotationThreshold());
@@ -213,7 +231,7 @@ public class AnnotationColourChooser extends JPanel
       if (!list.contains(label))
       {
         anmap[list.size()] = i;
-        list.addElement(label);
+        list.add(label);
 
       }
       else
@@ -221,13 +239,13 @@ public class AnnotationColourChooser extends JPanel
         if (!isSeqAssociated)
         {
           anmap[list.size()] = i;
-          list.addElement(label + "_" + (index++));
+          list.add(label + "_" + (index++));
         }
       }
     }
     seqAssociated.setEnabled(enableSeqAss);
-    annmap = new int[list.size()];
-    System.arraycopy(anmap, 0, annmap, 0, annmap.length);
+    this.annmap = new int[list.size()];
+    System.arraycopy(anmap, 0, this.annmap, 0, this.annmap.length);
     return list;
   }
 
@@ -258,6 +276,7 @@ public class AnnotationColourChooser extends JPanel
     minColour.setToolTipText(MessageManager.getString("label.min_colour"));
     minColour.addMouseListener(new MouseAdapter()
     {
+      @Override
       public void mousePressed(MouseEvent e)
       {
         if (minColour.isEnabled())
@@ -272,6 +291,7 @@ public class AnnotationColourChooser extends JPanel
     maxColour.setToolTipText(MessageManager.getString("label.max_colour"));
     maxColour.addMouseListener(new MouseAdapter()
     {
+      @Override
       public void mousePressed(MouseEvent e)
       {
         if (maxColour.isEnabled())
@@ -284,6 +304,7 @@ public class AnnotationColourChooser extends JPanel
     ok.setText(MessageManager.getString("action.ok"));
     ok.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         ok_actionPerformed(e);
@@ -293,6 +314,7 @@ public class AnnotationColourChooser extends JPanel
     cancel.setText(MessageManager.getString("action.cancel"));
     cancel.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         cancel_actionPerformed(e);
@@ -314,6 +336,7 @@ public class AnnotationColourChooser extends JPanel
 
     annotations.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         annotations_actionPerformed(e);
@@ -321,6 +344,7 @@ public class AnnotationColourChooser extends JPanel
     });
     threshold.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         threshold_actionPerformed(e);
@@ -328,6 +352,7 @@ public class AnnotationColourChooser extends JPanel
     });
     thresholdValue.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         thresholdValue_actionPerformed(e);
@@ -347,6 +372,7 @@ public class AnnotationColourChooser extends JPanel
             .getString("label.use_original_colours"));
     currentColours.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent e)
       {
         currentColours_actionPerformed(e);
@@ -358,6 +384,7 @@ public class AnnotationColourChooser extends JPanel
             .getString("label.threshold_minmax"));
     thresholdIsMin.addActionListener(new ActionListener()
     {
+      @Override
       public void actionPerformed(ActionEvent actionEvent)
       {
         thresholdIsMin_actionPerformed(actionEvent);
@@ -472,7 +499,7 @@ public class AnnotationColourChooser extends JPanel
   public void minColour_actionPerformed()
   {
     Color col = JColorChooser.showDialog(this,
-            "Select Colour for Minimum Value", minColour.getBackground());
+            MessageManager.getString("label.select_colour_minimum_value"), minColour.getBackground());
     if (col != null)
     {
       minColour.setBackground(col);
@@ -484,7 +511,7 @@ public class AnnotationColourChooser extends JPanel
   public void maxColour_actionPerformed()
   {
     Color col = JColorChooser.showDialog(this,
-            "Select Colour for Maximum Value", maxColour.getBackground());
+            MessageManager.getString("label.select_colour_maximum_value"), maxColour.getBackground());
     if (col != null)
     {
       maxColour.setBackground(col);
@@ -679,7 +706,7 @@ public class AnnotationColourChooser extends JPanel
     {
       changeColour();
     }
-    currentAnnotation.threshold.value = (float) slider.getValue() / 1000f;
+    currentAnnotation.threshold.value = slider.getValue() / 1000f;
     propagateSeqAssociatedThreshold(updateAllAnnotation);
     ap.paintAlignment(false);
   }
@@ -698,9 +725,19 @@ public class AnnotationColourChooser extends JPanel
     for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
     {
       AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[i];
-      if (aa.label.equals(currentAnnotation.label))
+      if (aa.label.equals(currentAnnotation.label)
+              && (currentAnnotation.getCalcId() == null ? aa.getCalcId() == null
+                      : currentAnnotation.getCalcId()
+                              .equals(aa.getCalcId())))
       {
-        aa.threshold.value = thr;
+        if (aa.threshold == null)
+        {
+          aa.threshold = new GraphLine(currentAnnotation.threshold);
+        }
+        else
+        {
+          aa.threshold.value = thr;
+        }
       }
     }
   }