From 5504aa5ac8a832f1c437b38ada4681545ed639f3 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 14 Jan 2005 15:46:53 +0000 Subject: [PATCH] Various color bugs sorted out --- src/jalview/gui/AlignFrame.java | 187 +++++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 85 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index ede7eac..f7b4ac5 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -459,6 +459,8 @@ public class AlignFrame extends GAlignFrame public void clustalColour_actionPerformed(ActionEvent e) { viewport.setGlobalColourScheme(new ClustalxColourScheme( )); + conservationMenuItem.setSelected(false); + abovePIDThreshold.setSelected(false); changeColour(); } @@ -511,110 +513,125 @@ public class AlignFrame extends GAlignFrame void changeColour() { if(abovePIDThreshold.isSelected()) - { abovePIDThreshold_actionPerformed(null); - alignPanel.setColourScheme( ); - } else if(conservationMenuItem.isSelected()) conservationMenuItem_actionPerformed(null); - else - alignPanel.setColourScheme( ); + alignPanel.seqPanel.seqCanvas.paintFlag = true; + alignPanel.repaint(); } - protected void conservationMenuItem_actionPerformed(ActionEvent e) + void addConservationOrPIDColour() { - viewport.setConservationSelected(conservationMenuItem.isSelected()); + int x=0, y=0, threshold = 70; - alignPanel.setColourScheme(); - ColourSchemeI oldCs = viewport.getGlobalColourScheme(); + if(sliderFrame!=null) + try + { + x = sliderFrame.getX(); + y = sliderFrame.getY(); + SliderPanel sp = (SliderPanel) sliderFrame.getContentPane(); + threshold = sp.getValue(); + sliderFrame.setClosed(true); + } + catch (Exception ex) + { ex.printStackTrace(); } - if(conservationMenuItem.isSelected()) - { - if(sliderPanel!=null) - { - sliderPanel.cs = oldCs; - } + ColourSchemeI oldCs = viewport.getGlobalColourScheme(); - else - { - sliderPanel = new SliderPanel(alignPanel, 30, true, - viewport.getGlobalColourScheme()); - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(sliderPanel); - Desktop.addInternalFrame(frame, "Conservation Colour Increment", 400, - 90); - frame.setMaximizable(false); - frame.setResizable(false); - frame.addInternalFrameListener(new javax.swing.event. - InternalFrameAdapter() - { - public void internalFrameClosed(javax.swing.event.InternalFrameEvent - evt) - { - sliderPanel = null; - }; - }); - } - } - else - { - if(oldCs instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme)oldCs; - viewport.setGlobalColourScheme( ccs.cs ); - } - alignPanel.setColourScheme(); - } + ConservationColourScheme ccs = null; + if (oldCs instanceof ConservationColourScheme) + ccs = (ConservationColourScheme) oldCs; - } + if(conservationMenuItem.isSelected()) + { + Alignment al = (Alignment)viewport.alignment; + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, al.getSequences(), 0, + al.getWidth() ); - SliderPanel sliderPanel; - public void abovePIDThreshold_actionPerformed(ActionEvent e) - { - ColourSchemeI oldCs = viewport.getGlobalColourScheme(); - int threshold = 0; + c.calculate(); + c.verdict(false, 100); - if(abovePIDThreshold.isSelected()) - { - if(sliderPanel!=null) - sliderPanel.cs = oldCs; + if(ccs!=null) + ccs = new ConservationColourScheme(c, ccs.cs); + else + ccs = new ConservationColourScheme(c, oldCs); - else - { - sliderPanel = new SliderPanel(alignPanel, 70, false, oldCs); - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(sliderPanel); - Desktop.addInternalFrame(frame, "Percentage Identity Threshold", 400, - 90); - frame.setMaximizable(false); - frame.setResizable(false); - frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { - public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) - { - sliderPanel = null; - }; - }); + viewport.setGlobalColourScheme( ccs ); - } + } + else if(oldCs instanceof ConservationColourScheme) + { + oldCs = ccs.cs; + viewport.setGlobalColourScheme( oldCs ); + } - threshold = sliderPanel.getValue(); - } - if (oldCs instanceof ResidueColourScheme) - { - ResidueColourScheme rcs = (ResidueColourScheme) oldCs; - rcs.setThreshold(threshold); - } - else if (oldCs instanceof ScoreColourScheme) - { - ScoreColourScheme scs = (ScoreColourScheme) oldCs; - scs.setThreshold(threshold); - } + if( conservationMenuItem.isSelected() || abovePIDThreshold.isSelected() ) + { + sliderFrame = new JInternalFrame(); + sliderFrame.setMaximizable(false); + sliderFrame.setResizable(false); + + SliderPanel sp = null; + if (conservationMenuItem.isSelected()) + { + if(threshold > 50) + threshold = 30; + sp = new SliderPanel(alignPanel, threshold, true,ccs); + Desktop.addInternalFrame(sliderFrame, "Conservation Colour Increment (Global colour)", 400, 90); + threshold = 0; + } + else if (abovePIDThreshold.isSelected()) + { + sp = new SliderPanel(alignPanel, threshold, false, oldCs); + sp.cs = oldCs; + Desktop.addInternalFrame(sliderFrame, "Percentage Identity Threshold (Global colour)", 400, 90); + } + + sliderFrame.setContentPane(sp); + if(x!=0 && y!=0) + sliderFrame.setLocation(x,y); - alignPanel.setColourScheme(); + } + else + threshold = 0; + + + if (oldCs instanceof ResidueColourScheme) + { + ResidueColourScheme rcs = (ResidueColourScheme) oldCs; + rcs.setThreshold(threshold); + } + else if (oldCs instanceof ScoreColourScheme) + { + ScoreColourScheme scs = (ScoreColourScheme) oldCs; + scs.setThreshold(threshold); + } + + alignPanel.seqPanel.seqCanvas.paintFlag = true; + alignPanel.repaint(); + + } + + protected void conservationMenuItem_actionPerformed(ActionEvent e) + { + if(abovePIDThreshold.isSelected()) + abovePIDThreshold.setSelected(false); + + viewport.setConservationSelected(conservationMenuItem.isSelected()); + + addConservationOrPIDColour(); + } + + JInternalFrame sliderFrame; + public void abovePIDThreshold_actionPerformed(ActionEvent e) + { + if(conservationMenuItem.isSelected()) + conservationMenuItem.setSelected(false); + addConservationOrPIDColour(); } -- 1.7.10.2