X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationColourChooser.java;h=06040a696199444f6135ae262cf244096e7cc0c8;hb=cc6f7ebe59c148e62cd9f1947d9ba30638db2980;hp=71582e593da9e1af0ec440d90fd84dc682faa71d;hpb=452198e86b03d40c83d0492ab04ab2f6d52e8f5e;p=jalview.git diff --git a/src/jalview/gui/AnnotationColourChooser.java b/src/jalview/gui/AnnotationColourChooser.java index 71582e5..06040a6 100755 --- a/src/jalview/gui/AnnotationColourChooser.java +++ b/src/jalview/gui/AnnotationColourChooser.java @@ -42,7 +42,7 @@ public class AnnotationColourChooser frame = new JInternalFrame(); frame.setContentPane(this); frame.setLayer(JLayeredPane.PALETTE_LAYER); - Desktop.addInternalFrame(frame, "Colour by Annotation", 470, 110, false); + Desktop.addInternalFrame(frame, "Colour by Annotation", 480, 110, false); try{ jbInit(); @@ -65,9 +65,14 @@ public class AnnotationColourChooser for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) { - annotations.addItem(av.alignment.getAlignmentAnnotation()[i].label); + if(av.alignment.getAlignmentAnnotation()[i].graph>0) + annotations.addItem(av.alignment.getAlignmentAnnotation()[i].label); } + threshold.addItem("No Threshold"); + threshold.addItem("Above Threshold"); + threshold.addItem("Below Threshold"); + } public AnnotationColourChooser() @@ -106,18 +111,6 @@ public class AnnotationColourChooser maxColour_actionPerformed(e); } }); - thresholdCheck.setOpaque(false); - thresholdCheck.setHorizontalTextPosition(SwingConstants.LEADING); - thresholdCheck.setSelectedIcon(null); - thresholdCheck.setText("Above Threshold"); - thresholdCheck.setBounds(new Rectangle(329, 6, 109, 23)); - thresholdCheck.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - thresholdCheck_actionPerformed(e); - } - }); ok.setOpaque(false); ok.setText("OK"); ok.addActionListener(new ActionListener() @@ -148,12 +141,20 @@ public class AnnotationColourChooser }); jPanel1.setBackground(Color.white); jPanel2.setBackground(Color.white); + threshold.setBounds(new Rectangle(328, 6, 125, 22)); + threshold.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + threshold_actionPerformed(e); + } + }); jPanel1.add(ok); jPanel1.add(cancel); jPanel2.add(annotations); jPanel2.add(minColour); jPanel2.add(maxColour); - jPanel2.add(thresholdCheck); + jPanel2.add(threshold); this.add(jPanel1, java.awt.BorderLayout.SOUTH); this.add(jPanel2, java.awt.BorderLayout.CENTER); } @@ -161,13 +162,12 @@ public class AnnotationColourChooser JComboBox annotations = new JComboBox(); JButton minColour = new JButton(); JButton maxColour = new JButton(); - JCheckBox thresholdCheck = new JCheckBox(); JButton ok = new JButton(); JButton cancel = new JButton(); JPanel jPanel1 = new JPanel(); JPanel jPanel2 = new JPanel(); BorderLayout borderLayout1 = new BorderLayout(); - + JComboBox threshold = new JComboBox(); public void minColour_actionPerformed(ActionEvent e) { @@ -193,18 +193,47 @@ public class AnnotationColourChooser void changeColour() { - jalview.datamodel.AlignmentAnnotation aa = av.alignment.getAlignmentAnnotation()[annotations.getSelectedIndex()]; + // Check if combobox is still adjusting + if(threshold.getSelectedIndex()==-1) + return; - AnnotationColourGradient acg = new AnnotationColourGradient(aa, - minColour.getBackground(), - maxColour.getBackground(), - thresholdCheck.isSelected()); + // 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(thresholdCheck.isSelected() && aa.graphLines==null) + if(graph==annotations.getSelectedIndex()) + break; + } + + jalview.datamodel.AlignmentAnnotation aa + = av.alignment.getAlignmentAnnotation()[graph+nograph]; + + + int aboveThreshold = -1; + if(threshold.getSelectedItem().equals("Above Threshold")) + aboveThreshold = AnnotationColourGradient.ABOVE_THRESHOLD; + else if(threshold.getSelectedItem().equals("Below Threshold")) + aboveThreshold = AnnotationColourGradient.BELOW_THRESHOLD; + + if(aboveThreshold!=AnnotationColourGradient.NO_THRESHOLD && aa.graphLines==null) { aa.addGraphLine(new jalview.datamodel.GraphLine((aa.graphMax-aa.graphMin)/2f, "Threshold", Color.black)); } + AnnotationColourGradient acg = new AnnotationColourGradient(aa, + minColour.getBackground(), + maxColour.getBackground(), + aboveThreshold ); + + + + av.setGlobalColourScheme(acg); ap.repaint(); @@ -236,4 +265,9 @@ public class AnnotationColourChooser changeColour(); } + public void threshold_actionPerformed(ActionEvent e) + { + changeColour(); + } + }