From: Jim Procter Date: Fri, 21 Jun 2013 14:08:37 +0000 (+0100) Subject: JAL-1326 JAL-1327 update all graphline thresholds with flag for interactive or final... X-Git-Tag: Jalview_2_9~232^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5aae79c31ad27e418e887151f27819516b725ace;p=jalview.git JAL-1326 JAL-1327 update all graphline thresholds with flag for interactive or final adjustment event --- diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 599cf0b..96bf602 100755 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -47,6 +47,10 @@ public class AnnotationColourChooser extends JPanel jalview.datamodel.AlignmentAnnotation currentAnnotation; boolean adjusting = false; + /** + * enabled if the user is dragging the slider - try to keep updates to a minimun + */ + boolean sliderDragging = false; public AnnotationColourChooser(AlignViewport av, final AlignmentPanel ap) { @@ -76,14 +80,32 @@ public class AnnotationColourChooser extends JPanel if (!adjusting) { thresholdValue.setText(((float) slider.getValue() / 1000f) + ""); - valueChanged(); + valueChanged(!sliderDragging); } } }); slider.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) + { + sliderDragging=true; + super.mousePressed(e); + } + + @Override + public void mouseDragged(MouseEvent e) + { + sliderDragging=true; + super.mouseDragged(e); + } public void mouseReleased(MouseEvent evt) { + if (sliderDragging) + { + sliderDragging=false; + valueChanged(true); + } ap.paintAlignment(true); } }); @@ -193,7 +215,6 @@ public class AnnotationColourChooser extends JPanel System.arraycopy(anmap, 0, annmap, 0, annmap.length); return list; } - private void setDefaultMinMax() { minColour.setBackground(Cache.getDefaultColour("ANNOTATIONCOLOUR_MIN", @@ -632,18 +653,38 @@ public class AnnotationColourChooser extends JPanel } } - public void valueChanged() + public void valueChanged(boolean updateAllAnnotation) { if (currentColours.isSelected() && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient)) { changeColour(); } - currentAnnotation.threshold.value = (float) slider.getValue() / 1000f; + propagateSeqAssociatedThreshold(updateAllAnnotation); ap.paintAlignment(false); } + private void propagateSeqAssociatedThreshold(boolean allAnnotation) + { + if (currentAnnotation.sequenceRef == null + || currentAnnotation.threshold == null) + { + return; + } + // TODO: only update visible annotation thresholds if allAnnotation is false, since we only need to provide a quick visual indicator + + float thr = currentAnnotation.threshold.value; + for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++) + { + AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[i]; + if (aa.label.equals(currentAnnotation.label)) + { + aa.threshold.value = thr; + } + } + } + public void currentColours_actionPerformed(ActionEvent e) { if (currentColours.isSelected())