X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationColourChooser.java;h=b748c85c01c57390eb0631a225890b0227aaaef8;hb=3e6b14950a06bb87c147493e4dfff0c4491ea25b;hp=49e835de3420d933ef681eb44592c9465041c521;hpb=09003bd97d75ad14cd000fc581d6ec93b7a08bcb;p=jalview.git diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 49e835d..b748c85 100755 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* 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 @@ -26,6 +26,8 @@ import jalview.schemes.*; import javax.swing.event.*; import java.util.*; import jalview.datamodel.SequenceGroup; +import java.awt.Dimension; +import javax.swing.BorderFactory; public class AnnotationColourChooser extends JPanel @@ -36,6 +38,7 @@ public class AnnotationColourChooser ColourSchemeI oldcs; Hashtable oldgroupColours; jalview.datamodel.AlignmentAnnotation currentAnnotation; + boolean adjusting = false; public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap) { @@ -48,7 +51,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 +60,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 +73,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 +96,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 +107,10 @@ public class AnnotationColourChooser threshold.addItem("Above Threshold"); threshold.addItem("Below Threshold"); + adjusting = false; + + changeColour(); + } public AnnotationColourChooser() @@ -117,24 +129,27 @@ public class AnnotationColourChooser throws Exception { minColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - minColour.setToolTipText(""); - minColour.setMargin(new Insets(2, 2, 2, 2)); - minColour.setText("Min Colour"); - minColour.addActionListener(new ActionListener() + minColour.setBorder(BorderFactory.createEtchedBorder()); + minColour.setPreferredSize(new Dimension(40, 20)); + minColour.setToolTipText("Minimum Colour"); + minColour.addMouseListener(new MouseAdapter() { - public void actionPerformed(ActionEvent e) + public void mousePressed(MouseEvent e) { - minColour_actionPerformed(e); + if (minColour.isEnabled()) + minColour_actionPerformed(); } }); maxColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - maxColour.setMargin(new Insets(2, 2, 2, 2)); - maxColour.setText("Max Colour"); - maxColour.addActionListener(new ActionListener() + maxColour.setBorder(BorderFactory.createEtchedBorder()); + maxColour.setPreferredSize(new Dimension(40, 20)); + maxColour.setToolTipText("Maximum Colour"); + maxColour.addMouseListener(new MouseAdapter() { - public void actionPerformed(ActionEvent e) + public void mousePressed(MouseEvent e) { - maxColour_actionPerformed(e); + if (maxColour.isEnabled()) + maxColour_actionPerformed(); } }); ok.setOpaque(false); @@ -181,10 +196,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); @@ -213,8 +230,8 @@ public class AnnotationColourChooser } JComboBox annotations = new JComboBox(); - JButton minColour = new JButton(); - JButton maxColour = new JButton(); + JPanel minColour = new JPanel(); + JPanel maxColour = new JPanel(); JButton ok = new JButton(); JButton cancel = new JButton(); JPanel jPanel1 = new JPanel(); @@ -228,7 +245,7 @@ public class AnnotationColourChooser JTextField thresholdValue = new JTextField(20); JCheckBox currentColours = new JCheckBox(); - public void minColour_actionPerformed(ActionEvent e) + public void minColour_actionPerformed() { Color col = JColorChooser.showDialog(this, "Select Colour for Minimum Value", @@ -239,7 +256,7 @@ public class AnnotationColourChooser changeColour(); } - public void maxColour_actionPerformed(ActionEvent e) + public void maxColour_actionPerformed() { Color col = JColorChooser.showDialog(this, "Select Colour for Maximum Value", @@ -253,7 +270,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 +295,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 +312,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 +325,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 +420,6 @@ public class AnnotationColourChooser public void annotations_actionPerformed(ActionEvent e) { - if(currentAnnotation!=null) - currentAnnotation.threshold = null; changeColour(); } @@ -419,6 +441,12 @@ public class AnnotationColourChooser public void valueChanged() { + if (currentColours.isSelected() + && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient)) + { + changeColour(); + } + currentAnnotation.threshold.value = (float)slider.getValue()/1000f; ap.repaint(); }