X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationColourChooser.java;h=80d39e80ef783c2fa43dad6952136461b257a184;hb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;hp=ab3b3793d1cb57ff2416194a7f21f42b5c3f0d69;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationColourChooser.java b/src/jalview/appletgui/AnnotationColourChooser.java index ab3b379..80d39e8 100755 --- a/src/jalview/appletgui/AnnotationColourChooser.java +++ b/src/jalview/appletgui/AnnotationColourChooser.java @@ -1,31 +1,33 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.appletgui; -import java.awt.event.*; +import java.util.*; + import java.awt.*; +import java.awt.event.*; +import jalview.datamodel.*; import jalview.schemes.*; -import java.util.*; -import jalview.datamodel.SequenceGroup; -public class AnnotationColourChooser extends Panel implements ActionListener, +public class AnnotationColourChooser + extends Panel implements ActionListener, AdjustmentListener, ItemListener { Frame frame; @@ -63,7 +65,9 @@ public class AnnotationColourChooser extends Panel implements ActionListener, slider.addAdjustmentListener(this); if (av.alignment.getAlignmentAnnotation() == null) + { return; + } if (oldcs instanceof AnnotationColourGradient) { @@ -81,7 +85,9 @@ public class AnnotationColourChooser extends Panel implements ActionListener, for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) { if (av.alignment.getAlignmentAnnotation()[i].graph > 0) + { annotations.addItem(av.alignment.getAlignmentAnnotation()[i].label); + } } threshold.addItem("No Threshold"); @@ -178,10 +184,9 @@ public class AnnotationColourChooser extends Panel implements ActionListener, Checkbox currentColours = new Checkbox(); BorderLayout borderLayout1 = new BorderLayout(); - public void actionPerformed(ActionEvent evt) { - if(evt.getSource() == thresholdValue) + if (evt.getSource() == thresholdValue) { try { @@ -193,9 +198,13 @@ public class AnnotationColourChooser extends Panel implements ActionListener, {} } else if (evt.getSource() == minColour) + { minColour_actionPerformed(null); + } else if (evt.getSource() == maxColour) + { maxColour_actionPerformed(null); + } else if (evt.getSource() == ok) { @@ -210,10 +219,11 @@ public class AnnotationColourChooser extends Panel implements ActionListener, } else + { changeColour(); + } } - public void itemStateChanged(ItemEvent evt) { if (evt.getSource() == currentColours) @@ -256,8 +266,10 @@ public class AnnotationColourChooser extends Panel implements ActionListener, changeColour(); } else + { new UserDefinedColours(this, "Min Colour", - minColour.getBackground()); + minColour.getBackground()); + } } @@ -270,16 +282,19 @@ public class AnnotationColourChooser extends Panel implements ActionListener, changeColour(); } else + { new UserDefinedColours(this, "Max Colour", - maxColour.getBackground()); + maxColour.getBackground()); + } } - void changeColour() { // Check if combobox is still adjusting if (adjusting) + { return; + } // We removed the non-graph annotations when filling the combobox // so allow for them again here @@ -287,21 +302,31 @@ public class AnnotationColourChooser extends Panel implements ActionListener, for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) { if (av.alignment.getAlignmentAnnotation()[i].graph == 0) + { nograph++; + } else + { graph++; + } if (graph == annotations.getSelectedIndex()) + { break; + } } currentAnnotation = av.alignment.getAlignmentAnnotation()[graph + nograph]; int aboveThreshold = -1; if (threshold.getSelectedItem().equals("Above Threshold")) + { aboveThreshold = AnnotationColourGradient.ABOVE_THRESHOLD; + } else if (threshold.getSelectedItem().equals("Below Threshold")) + { aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD; + } slider.setEnabled(true); thresholdValue.setEnabled(true); @@ -322,7 +347,7 @@ public class AnnotationColourChooser extends Panel implements ActionListener, Color.black)); } - if(aboveThreshold != AnnotationColourGradient.NO_THRESHOLD) + if (aboveThreshold != AnnotationColourGradient.NO_THRESHOLD) { adjusting = true; @@ -337,16 +362,20 @@ public class AnnotationColourChooser extends Panel implements ActionListener, AnnotationColourGradient acg = null; if (currentColours.getState()) + { acg = new AnnotationColourGradient( currentAnnotation, av.getGlobalColourScheme(), aboveThreshold); + } else + { acg = new AnnotationColourGradient( currentAnnotation, minColour.getBackground(), maxColour.getBackground(), aboveThreshold); + } av.setGlobalColourScheme(acg); @@ -364,15 +393,19 @@ public class AnnotationColourChooser extends Panel implements ActionListener, } if (currentColours.getState()) + { sg.cs = new AnnotationColourGradient( currentAnnotation, sg.cs, aboveThreshold); + } else + { sg.cs = new AnnotationColourGradient( currentAnnotation, minColour.getBackground(), maxColour.getBackground(), aboveThreshold); + } } } @@ -380,7 +413,6 @@ public class AnnotationColourChooser extends Panel implements ActionListener, ap.repaint(); } - void reset() { av.setGlobalColourScheme(oldcs); @@ -391,13 +423,11 @@ public class AnnotationColourChooser extends Panel implements ActionListener, for (int g = 0; g < allGroups.size(); g++) { sg = (SequenceGroup) allGroups.elementAt(g); - sg.cs = (ColourSchemeI)oldgroupColours.get(sg); + sg.cs = (ColourSchemeI) oldgroupColours.get(sg); } } ap.repaint(); } - - }