X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationColourChooser.java;h=0b6f8d8fcc6fc033605ccb70526889940e511958;hb=6fc9aca27f606f6e3a0121597896e1a5dae35c36;hp=49e835de3420d933ef681eb44592c9465041c521;hpb=09003bd97d75ad14cd000fc581d6ec93b7a08bcb;p=jalview.git diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 49e835d..0b6f8d8 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) { @@ -48,7 +49,8 @@ public class AnnotationColourChooser for (int g = 0; g < allGroups.size(); g++) { sg = (SequenceGroup) allGroups.get(g); - oldgroupColours.put(sg, sg.cs); + if(sg.cs!=null) + oldgroupColours.put(sg, sg.cs); } } this.av = av; @@ -56,7 +58,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 +71,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 +94,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 +105,10 @@ public class AnnotationColourChooser threshold.addItem("Above Threshold"); threshold.addItem("Below Threshold"); + adjusting = false; + + changeColour(); + } public AnnotationColourChooser() @@ -181,10 +191,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 +265,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 +290,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 +307,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; @@ -301,9 +320,9 @@ public class AnnotationColourChooser slider.setValue( (int) (currentAnnotation.threshold.value * 1000)); thresholdValue.setText(currentAnnotation.threshold.value + ""); slider.setMajorTickSpacing( (int) (range / 10f)); - 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(); }