JAL-1066 basic gui and functionality for per-sequence colour by annotation
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 28 Aug 2012 13:47:30 +0000 (14:47 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 28 Aug 2012 13:47:30 +0000 (14:47 +0100)
src/jalview/gui/AnnotationColourChooser.java

index 64b1d19..5b69534 100755 (executable)
@@ -105,8 +105,8 @@ public class AnnotationColourChooser extends JPanel
        minColour.setBackground(acg.getMinColour());
         maxColour.setBackground(acg.getMaxColour());
       }
+      seqAssociated.setSelected(acg.isSeqAssociated());
     }
-
     adjusting = true;
     Vector list = new Vector();
     int index = 1;
@@ -156,7 +156,8 @@ public class AnnotationColourChooser extends JPanel
     adjusting = false;
 
     changeColour();
-    validate();
+    frame.invalidate();
+    frame.pack();
 
   }
 
@@ -287,6 +288,19 @@ public class AnnotationColourChooser extends JPanel
         thresholdIsMin_actionPerformed(actionEvent);
       }
     });
+    seqAssociated.setBackground(Color.white);
+    seqAssociated.setFont(JvSwingUtils.getLabelFont());
+    seqAssociated.setText("Per-sequence only");
+    seqAssociated.addActionListener(new ActionListener()
+    {
+      
+      @Override
+      public void actionPerformed(ActionEvent arg0)
+      {
+        seqAssociated_actionPerformed(arg0);
+      }
+    });
+    
     this.setLayout(borderLayout1);
     jPanel2.setLayout(new MigLayout("","[left][center][right]","[][][]"));
     jPanel1.setBackground(Color.white);
@@ -301,7 +315,7 @@ public class AnnotationColourChooser extends JPanel
     colpanel.add(minColour);
     colpanel.add(maxColour);
     jPanel2.add(colpanel, "wrap");
-    
+    jPanel2.add(seqAssociated, "wrap");
     jPanel2.add(threshold);
     jPanel2.add(defColours,"skip 1, wrap");
     jPanel2.add(thresholdIsMin);
@@ -309,6 +323,12 @@ public class AnnotationColourChooser extends JPanel
     jPanel2.add(thresholdValue, "grow");
     this.add(jPanel1, java.awt.BorderLayout.SOUTH);
     this.add(jPanel2, java.awt.BorderLayout.CENTER);
+    this.validate();
+  }
+
+  protected void seqAssociated_actionPerformed(ActionEvent arg0)
+  {
+    changeColour();
   }
 
   protected void resetColours_actionPerformed(ActionEvent arg0)
@@ -342,6 +362,8 @@ public class AnnotationColourChooser extends JPanel
   JCheckBox currentColours = new JCheckBox();
 
   JCheckBox thresholdIsMin = new JCheckBox();
+  
+  JCheckBox seqAssociated = new JCheckBox();
 
   public void minColour_actionPerformed()
   {
@@ -436,6 +458,7 @@ public class AnnotationColourChooser extends JPanel
               minColour.getBackground(), maxColour.getBackground(),
               aboveThreshold);
     }
+    acg.setSeqAssociated(seqAssociated.isSelected());
 
     if (currentAnnotation.graphMin == 0f
             && currentAnnotation.graphMax == 0f)
@@ -461,16 +484,20 @@ public class AnnotationColourChooser extends JPanel
         {
           sg.cs = new AnnotationColourGradient(currentAnnotation, sg.cs,
                   aboveThreshold);
+          ((AnnotationColourGradient)sg.cs).setSeqAssociated(seqAssociated.isSelected());
+
         }
         else
         {
           sg.cs = new AnnotationColourGradient(currentAnnotation,
                   minColour.getBackground(), maxColour.getBackground(),
                   aboveThreshold);
+          ((AnnotationColourGradient)sg.cs).setSeqAssociated(seqAssociated.isSelected());
         }
 
       }
     }
+    ap.alignmentChanged();
     // ensure all associated views (overviews, structures, etc) are notified of updated colours.
     ap.paintAlignment(true);
   }