From 59c22b05925dd3b4d148c1ce0e43eea12bc64ba7 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 24 Feb 2006 11:45:36 +0000 Subject: [PATCH] Keeps original threshold value --- src/jalview/gui/AnnotationColourChooser.java | 37 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 49e835d..d49a4b6 100755 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -36,6 +36,7 @@ public class AnnotationColourChooser ColourSchemeI oldcs; Hashtable oldgroupColours; jalview.datamodel.AlignmentAnnotation currentAnnotation; + boolean adjusting = false; public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap) { @@ -56,7 +57,7 @@ public class AnnotationColourChooser frame = new JInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); - Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 145, false); + Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 145); try { @@ -69,8 +70,11 @@ public class AnnotationColourChooser { public void stateChanged(ChangeEvent evt) { - thresholdValue.setText( ( (float) slider.getValue() / 1000f) + ""); - valueChanged(); + if(!adjusting) + { + thresholdValue.setText( ( (float) slider.getValue() / 1000f) + ""); + valueChanged(); + } } }); @@ -89,6 +93,7 @@ public class AnnotationColourChooser maxColour.setBackground(Color.red); } + adjusting = true; for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) { if (av.alignment.getAlignmentAnnotation()[i].graph > 0) @@ -99,6 +104,10 @@ public class AnnotationColourChooser threshold.addItem("Above Threshold"); threshold.addItem("Below Threshold"); + adjusting = false; + + changeColour(); + } public AnnotationColourChooser() @@ -181,10 +190,12 @@ public class AnnotationColourChooser thresholdValue_actionPerformed(e); } }); + slider.setPaintLabels(false); slider.setPaintTicks(true); slider.setBackground(Color.white); slider.setEnabled(false); slider.setOpaque(false); + slider.setPreferredSize(new Dimension(150, 32)); thresholdValue.setEnabled(false); thresholdValue.setColumns(10); jPanel3.setBackground(Color.white); @@ -253,7 +264,7 @@ public class AnnotationColourChooser void changeColour() { // Check if combobox is still adjusting - if (threshold.getSelectedIndex() == -1) + if (adjusting) return; // We removed the non-graph annotations when filling the combobox @@ -278,9 +289,11 @@ public class AnnotationColourChooser else if (threshold.getSelectedItem().equals("Below Threshold")) aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD; + slider.setEnabled(true); + thresholdValue.setEnabled(true); + if (aboveThreshold == AnnotationColourGradient.NO_THRESHOLD) { - currentAnnotation.threshold = null; slider.setEnabled(false); thresholdValue.setEnabled(false); thresholdValue.setText(""); @@ -293,6 +306,11 @@ public class AnnotationColourChooser currentAnnotation.graphMin) / 2f, "Threshold", Color.black)); + } + + if(aboveThreshold != AnnotationColourGradient.NO_THRESHOLD) + { + adjusting = true; float range = currentAnnotation.graphMax * 1000 - currentAnnotation.graphMin * 1000; @@ -304,6 +322,7 @@ public class AnnotationColourChooser slider.setMinorTickSpacing( (int) (range / 100f)); slider.setEnabled(true); thresholdValue.setEnabled(true); + adjusting = false; } AnnotationColourGradient acg = null; @@ -396,8 +415,6 @@ public class AnnotationColourChooser public void annotations_actionPerformed(ActionEvent e) { - if(currentAnnotation!=null) - currentAnnotation.threshold = null; changeColour(); } @@ -419,6 +436,12 @@ public class AnnotationColourChooser public void valueChanged() { + if (currentColours.isSelected() + && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient)) + { + changeColour(); + } + currentAnnotation.threshold.value = (float)slider.getValue()/1000f; ap.repaint(); } -- 1.7.10.2