X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationColourChooser.java;h=83a8a12b0cb1733abe1abc44c00fe9b14d483ccc;hb=60f2d6c034560415fd0139c8bc7df0c19cae1186;hp=ba76858d39d049f526df041f1b5393585365fa8b;hpb=7bc226b58110fa26d9dbd3f0c78095d06909ffc3;p=jalview.git diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index ba76858..83a8a12 100755 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -27,6 +27,7 @@ import javax.swing.event.*; import jalview.datamodel.*; import jalview.schemes.*; +import java.awt.Dimension; public class AnnotationColourChooser extends JPanel @@ -39,7 +40,7 @@ public class AnnotationColourChooser jalview.datamodel.AlignmentAnnotation currentAnnotation; boolean adjusting = false; - public AnnotationColourChooser(AlignViewport av, AlignmentPanel ap) + public AnnotationColourChooser(AlignViewport av, final AlignmentPanel ap) { oldcs = av.getGlobalColourScheme(); if (av.alignment.getGroups() != null) @@ -63,12 +64,6 @@ public class AnnotationColourChooser frame.setLayer(JLayeredPane.PALETTE_LAYER); Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 145); - try - { - jbInit(); - } - catch (Exception ex) - {} slider.addChangeListener(new ChangeListener() { @@ -81,6 +76,13 @@ public class AnnotationColourChooser } } }); + slider.addMouseListener(new MouseAdapter() + { + public void mouseReleased(MouseEvent evt) + { + ap.paintAlignment(true); + } + }); if (av.alignment.getAlignmentAnnotation() == null) { @@ -100,18 +102,30 @@ public class AnnotationColourChooser } adjusting = true; + Vector list = new Vector(); + int index = 1; for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) { - if (av.alignment.getAlignmentAnnotation()[i].graph > 0) - { - annotations.addItem(av.alignment.getAlignmentAnnotation()[i].label); - } + String label = av.alignment.getAlignmentAnnotation()[i].label; + if (!list.contains(label)) + list.addElement(label); + else + list.addElement(label+"_"+(index++)); } + annotations = new JComboBox(list); + threshold.addItem("No Threshold"); threshold.addItem("Above Threshold"); threshold.addItem("Below Threshold"); + try + { + jbInit(); + } + catch (Exception ex) + {} + adjusting = false; changeColour(); @@ -210,9 +224,9 @@ public class AnnotationColourChooser slider.setBackground(Color.white); slider.setEnabled(false); slider.setOpaque(false); - slider.setPreferredSize(new Dimension(150, 32)); + slider.setPreferredSize(new Dimension(100, 32)); thresholdValue.setEnabled(false); - thresholdValue.setColumns(10); + thresholdValue.setColumns(7); jPanel3.setBackground(Color.white); currentColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); currentColours.setOpaque(false); @@ -224,6 +238,15 @@ public class AnnotationColourChooser currentColours_actionPerformed(e); } }); + thresholdIsMin.setBackground(Color.white); + thresholdIsMin.setText("Threshold is Min/Max"); + thresholdIsMin.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + thresholdIsMin_actionPerformed(actionEvent); + } + }); jPanel1.add(ok); jPanel1.add(cancel); jPanel2.add(annotations); @@ -234,11 +257,12 @@ public class AnnotationColourChooser jPanel3.add(threshold); jPanel3.add(slider); jPanel3.add(thresholdValue); + jPanel3.add(thresholdIsMin); this.add(jPanel1, java.awt.BorderLayout.SOUTH); this.add(jPanel2, java.awt.BorderLayout.NORTH); } - JComboBox annotations = new JComboBox(); + JComboBox annotations; JPanel minColour = new JPanel(); JPanel maxColour = new JPanel(); JButton ok = new JButton(); @@ -253,6 +277,7 @@ public class AnnotationColourChooser JSlider slider = new JSlider(); JTextField thresholdValue = new JTextField(20); JCheckBox currentColours = new JCheckBox(); + JCheckBox thresholdIsMin = new JCheckBox(); public void minColour_actionPerformed() { @@ -288,27 +313,8 @@ public class AnnotationColourChooser return; } - // We removed the non-graph annotations when filling the combobox - // so allow for them again here - int nograph = 0, graph = -1; - for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) - { - if (av.alignment.getAlignmentAnnotation()[i].graph == 0) - { - nograph++; - } - else - { - graph++; - } - - if (graph == annotations.getSelectedIndex()) - { - break; - } - } - currentAnnotation = av.alignment.getAlignmentAnnotation()[graph + nograph]; + currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations.getSelectedIndex()]; int aboveThreshold = -1; if (threshold.getSelectedItem().equals("Above Threshold")) @@ -372,6 +378,13 @@ public class AnnotationColourChooser aboveThreshold); } + if(currentAnnotation.graphMin==0f&& currentAnnotation.graphMax==0f) + { + acg.predefinedColours = true; + } + + acg.thresholdIsMinMax = thresholdIsMin.isSelected(); + av.setGlobalColourScheme(acg); if (av.alignment.getGroups() != null) @@ -405,7 +418,7 @@ public class AnnotationColourChooser } } - ap.repaint(); + ap.paintAlignment(false); } public void ok_actionPerformed(ActionEvent e) @@ -480,7 +493,7 @@ public class AnnotationColourChooser } currentAnnotation.threshold.value = (float) slider.getValue() / 1000f; - ap.repaint(); + ap.paintAlignment(false); } public void currentColours_actionPerformed(ActionEvent e) @@ -496,4 +509,9 @@ public class AnnotationColourChooser changeColour(); } + public void thresholdIsMin_actionPerformed(ActionEvent actionEvent) + { + changeColour(); + } + }