/*\r
* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
*\r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
import javax.swing.event.*;\r
import java.util.*;\r
import jalview.datamodel.SequenceGroup;\r
+import java.awt.Dimension;\r
+import javax.swing.BorderFactory;\r
\r
public class AnnotationColourChooser\r
extends JPanel\r
ColourSchemeI oldcs;\r
Hashtable oldgroupColours;\r
jalview.datamodel.AlignmentAnnotation currentAnnotation;\r
+ boolean adjusting = false;\r
\r
public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap)\r
{\r
for (int g = 0; g < allGroups.size(); g++)\r
{\r
sg = (SequenceGroup) allGroups.get(g);\r
- oldgroupColours.put(sg, sg.cs);\r
+ if(sg.cs!=null)\r
+ oldgroupColours.put(sg, sg.cs);\r
}\r
}\r
this.av = av;\r
frame = new JInternalFrame();\r
frame.setContentPane(this);\r
frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
- Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 145, false);\r
+ Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 145);\r
\r
try\r
{\r
{\r
public void stateChanged(ChangeEvent evt)\r
{\r
- thresholdValue.setText( ( (float) slider.getValue() / 1000f) + "");\r
- valueChanged();\r
+ if(!adjusting)\r
+ {\r
+ thresholdValue.setText( ( (float) slider.getValue() / 1000f) + "");\r
+ valueChanged();\r
+ }\r
}\r
});\r
\r
maxColour.setBackground(Color.red);\r
}\r
\r
+ adjusting = true;\r
for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++)\r
{\r
if (av.alignment.getAlignmentAnnotation()[i].graph > 0)\r
threshold.addItem("Above Threshold");\r
threshold.addItem("Below Threshold");\r
\r
+ adjusting = false;\r
+\r
+ changeColour();\r
+\r
}\r
\r
public AnnotationColourChooser()\r
throws Exception\r
{\r
minColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
- minColour.setToolTipText("");\r
- minColour.setMargin(new Insets(2, 2, 2, 2));\r
- minColour.setText("Min Colour");\r
- minColour.addActionListener(new ActionListener()\r
+ minColour.setBorder(BorderFactory.createEtchedBorder());\r
+ minColour.setPreferredSize(new Dimension(40, 20));\r
+ minColour.setToolTipText("Minimum Colour");\r
+ minColour.addMouseListener(new MouseAdapter()\r
{\r
- public void actionPerformed(ActionEvent e)\r
+ public void mousePressed(MouseEvent e)\r
{\r
- minColour_actionPerformed(e);\r
+ if (minColour.isEnabled())\r
+ minColour_actionPerformed();\r
}\r
});\r
maxColour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
- maxColour.setMargin(new Insets(2, 2, 2, 2));\r
- maxColour.setText("Max Colour");\r
- maxColour.addActionListener(new ActionListener()\r
+ maxColour.setBorder(BorderFactory.createEtchedBorder());\r
+ maxColour.setPreferredSize(new Dimension(40, 20));\r
+ maxColour.setToolTipText("Maximum Colour");\r
+ maxColour.addMouseListener(new MouseAdapter()\r
{\r
- public void actionPerformed(ActionEvent e)\r
+ public void mousePressed(MouseEvent e)\r
{\r
- maxColour_actionPerformed(e);\r
+ if (maxColour.isEnabled())\r
+ maxColour_actionPerformed();\r
}\r
});\r
ok.setOpaque(false);\r
thresholdValue_actionPerformed(e);\r
}\r
});\r
+ slider.setPaintLabels(false);\r
slider.setPaintTicks(true);\r
slider.setBackground(Color.white);\r
slider.setEnabled(false);\r
slider.setOpaque(false);\r
+ slider.setPreferredSize(new Dimension(150, 32));\r
thresholdValue.setEnabled(false);\r
thresholdValue.setColumns(10);\r
jPanel3.setBackground(Color.white);\r
}\r
\r
JComboBox annotations = new JComboBox();\r
- JButton minColour = new JButton();\r
- JButton maxColour = new JButton();\r
+ JPanel minColour = new JPanel();\r
+ JPanel maxColour = new JPanel();\r
JButton ok = new JButton();\r
JButton cancel = new JButton();\r
JPanel jPanel1 = new JPanel();\r
JTextField thresholdValue = new JTextField(20);\r
JCheckBox currentColours = new JCheckBox();\r
\r
- public void minColour_actionPerformed(ActionEvent e)\r
+ public void minColour_actionPerformed()\r
{\r
Color col = JColorChooser.showDialog(this,\r
"Select Colour for Minimum Value",\r
changeColour();\r
}\r
\r
- public void maxColour_actionPerformed(ActionEvent e)\r
+ public void maxColour_actionPerformed()\r
{\r
Color col = JColorChooser.showDialog(this,\r
"Select Colour for Maximum Value",\r
void changeColour()\r
{\r
// Check if combobox is still adjusting\r
- if (threshold.getSelectedIndex() == -1)\r
+ if (adjusting)\r
return;\r
\r
// We removed the non-graph annotations when filling the combobox\r
else if (threshold.getSelectedItem().equals("Below Threshold"))\r
aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD;\r
\r
+ slider.setEnabled(true);\r
+ thresholdValue.setEnabled(true);\r
+\r
if (aboveThreshold == AnnotationColourGradient.NO_THRESHOLD)\r
{\r
- currentAnnotation.threshold = null;\r
slider.setEnabled(false);\r
thresholdValue.setEnabled(false);\r
thresholdValue.setText("");\r
currentAnnotation.graphMin) / 2f,\r
"Threshold",\r
Color.black));\r
+ }\r
+\r
+ if(aboveThreshold != AnnotationColourGradient.NO_THRESHOLD)\r
+ {\r
+ adjusting = true;\r
float range = currentAnnotation.graphMax * 1000 -\r
currentAnnotation.graphMin * 1000;\r
\r
slider.setValue( (int) (currentAnnotation.threshold.value * 1000));\r
thresholdValue.setText(currentAnnotation.threshold.value + "");\r
slider.setMajorTickSpacing( (int) (range / 10f));\r
- slider.setMinorTickSpacing( (int) (range / 100f));\r
slider.setEnabled(true);\r
thresholdValue.setEnabled(true);\r
+ adjusting = false;\r
}\r
\r
AnnotationColourGradient acg = null;\r
\r
public void annotations_actionPerformed(ActionEvent e)\r
{\r
- if(currentAnnotation!=null)\r
- currentAnnotation.threshold = null;\r
changeColour();\r
}\r
\r
\r
public void valueChanged()\r
{\r
+ if (currentColours.isSelected()\r
+ && !(av.getGlobalColourScheme() instanceof AnnotationColourGradient))\r
+ {\r
+ changeColour();\r
+ }\r
+\r
currentAnnotation.threshold.value = (float)slider.getValue()/1000f;\r
ap.repaint();\r
}\r