From: amwaterhouse Date: Tue, 1 Feb 2005 19:02:28 +0000 (+0000) Subject: Conservation and PID colouring methods updated X-Git-Tag: Release_2_0~709 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f202be793ee0fd5027b8e602761f9860d7eb1ddd;p=jalview.git Conservation and PID colouring methods updated --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 5173fed..9a87b90 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -39,6 +39,9 @@ public class AlignFrame extends GAlignFrame getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER); fontNameMenuItem.setText(viewport.getFont().getName()); fontSizeMenuItem.setText(viewport.getFont().getSize()+""); + + clustalColour.setSelected(true); + clustalColour_actionPerformed(null); } protected void saveAs_actionPerformed(ActionEvent e) @@ -478,8 +481,8 @@ public class AlignFrame extends GAlignFrame public void clustalColour_actionPerformed(ActionEvent e) { - viewport.setGlobalColourScheme(new ClustalxColourScheme( )); - conservationMenuItem.setSelected(false); + viewport.setGlobalColourScheme( + new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth())); abovePIDThreshold.setSelected(false); changeColour(); } @@ -544,119 +547,98 @@ public class AlignFrame extends GAlignFrame else if(conservationMenuItem.isSelected()) conservationMenuItem_actionPerformed(null); - - alignPanel.RefreshPanels(); + alignPanel.RefreshPanels(); } - void addConservationOrPIDColour() + + protected void conservationMenuItem_actionPerformed(ActionEvent e) { - int x=0, y=0, threshold = 70; + if(abovePIDThreshold.isSelected()) + { + abovePIDThreshold.setSelected(false); + Desktop.hidePIDSlider(); + } - 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(); } + viewport.setConservationSelected(conservationMenuItem.isSelected()); - ColourSchemeI oldCs = viewport.getGlobalColourScheme(); + ColourSchemeI oldCs = viewport.getGlobalColourScheme(); - ConservationColourScheme ccs = null; - if (oldCs instanceof ConservationColourScheme) - ccs = (ConservationColourScheme) oldCs; + 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() ); + if (conservationMenuItem.isSelected()) + { + Alignment al = (Alignment) viewport.alignment; + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, + al.getSequences(), 0, + al.getWidth()); - c.calculate(); - c.verdict(false, 100); + c.calculate(); + c.verdict(false, 100); - if(ccs!=null) - ccs = new ConservationColourScheme(c, ccs.cs); - else - ccs = new ConservationColourScheme(c, oldCs); + if (ccs != null) + ccs = new ConservationColourScheme(c, ccs.cs); + else + ccs = new ConservationColourScheme(c, oldCs); - viewport.setGlobalColourScheme( ccs ); - } - else if(oldCs instanceof ConservationColourScheme) - { - oldCs = ccs.cs; - viewport.setGlobalColourScheme( oldCs ); - } + int threshold = Desktop.setConservationSliderSource(alignPanel, ccs, "Background"); + ccs.inc = threshold; + + if (ccs.cs instanceof ResidueColourScheme) + ((ResidueColourScheme) ccs.cs).setThreshold(0); + else if (ccs.cs instanceof ScoreColourScheme) + ((ScoreColourScheme)ccs.cs).setThreshold(0); + + viewport.setGlobalColourScheme(ccs); - 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()) + else if (oldCs instanceof ConservationColourScheme) { - sp = new SliderPanel(alignPanel, threshold, false, oldCs); - sp.cs = oldCs; - Desktop.addInternalFrame(sliderFrame, "Percentage Identity Threshold (Global colour)", 400, 90); + /// ie, if we remove ConservationColourScheme from backgroundColour + oldCs = ccs.cs; + viewport.setGlobalColourScheme(oldCs); + Desktop.hideConservationSlider(); } - sliderFrame.setContentPane(sp); - if(x!=0 && y!=0) - sliderFrame.setLocation(x,y); + if(e!=null) + alignPanel.RefreshPanels(); + } - } - else - threshold = 0; + public void abovePIDThreshold_actionPerformed(ActionEvent e) + { + if(conservationMenuItem.isSelected()) + conservationMenuItem.setSelected(false); - if (oldCs instanceof ResidueColourScheme) + ColourSchemeI oldCs = viewport.getGlobalColourScheme(); + int threshold = 0; + if (oldCs instanceof ConservationColourScheme) { - ResidueColourScheme rcs = (ResidueColourScheme) oldCs; - rcs.setThreshold(threshold); + ConservationColourScheme ccs = (ConservationColourScheme) oldCs; + oldCs = ccs.cs; } - else if (oldCs instanceof ScoreColourScheme) + + if(abovePIDThreshold.isSelected()) { - ScoreColourScheme scs = (ScoreColourScheme) oldCs; - scs.setThreshold(threshold); + threshold = Desktop.setPIDSliderSource(alignPanel, oldCs, "Background"); + Desktop.hideConservationSlider(); } + else + Desktop.hidePIDSlider(); + if (oldCs instanceof ResidueColourScheme) + ((ResidueColourScheme) oldCs).setThreshold(threshold); + else if (oldCs instanceof ScoreColourScheme) + ((ScoreColourScheme)oldCs).setThreshold(threshold); - } - - 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(); + viewport.setGlobalColourScheme(oldCs); + if(e!=null) + alignPanel.RefreshPanels(); } @@ -682,7 +664,7 @@ public class AlignFrame extends GAlignFrame public void BLOSUM62Colour_actionPerformed(ActionEvent e) { viewport.setGlobalColourScheme( new Blosum62ColourScheme(viewport) ); - alignPanel.setColourScheme(); + changeColour(); } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 464ec59..2c475fa 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -12,6 +12,7 @@ package jalview.gui; import jalview.gui.*; import jalview.io.*; import jalview.datamodel.*; +import jalview.schemes.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; @@ -261,4 +262,86 @@ public class Desktop extends jalview.jbgui.GDesktop } } + static JInternalFrame conservationSlider; + static JInternalFrame PIDSlider; + public static int setConservationSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) + { + SliderPanel sp = null; + + if(conservationSlider == null) + { + sp = new SliderPanel(ap, 30, true, cs); + conservationSlider = new JInternalFrame(); + conservationSlider.setContentPane(sp); + conservationSlider.setResizable(false); + addInternalFrame(conservationSlider, "Conservation Colour Increment ("+source+")", 420, 90); + conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed(javax.swing.event.InternalFrameEvent e) + { + conservationSlider = null; + } + }); + } + else + { + conservationSlider.setTitle("Conservation Colour Increment ("+source+")"); + sp = (SliderPanel)conservationSlider.getContentPane(); + sp.cs = cs; + } + + if(ap.av.alignment.getGroups()!=null) + sp.setAllGroupsCheckEnabled( true ); + else + sp.setAllGroupsCheckEnabled( false); + + return sp.getValue(); + + } + + public static void hideConservationSlider() + { + try{ + conservationSlider.setClosed(true); + conservationSlider = null; + }catch(Exception ex){} +} + + + public static void hidePIDSlider() + { + try{ + PIDSlider.setClosed(true); + PIDSlider = null; + }catch(Exception ex){} + } + + public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) + { + SliderPanel pid = null; + if(PIDSlider == null) + { + pid = new SliderPanel(ap, 50, false, cs); + PIDSlider = new JInternalFrame(); + PIDSlider.setContentPane(pid); + PIDSlider.setResizable(false); + addInternalFrame(PIDSlider, "Percentage Identity Threshold ("+source+")", 420, 90); + } + else + { + PIDSlider.setTitle("Percentage Identity Threshold ("+source+")"); + pid = (SliderPanel)PIDSlider.getContentPane(); + pid.cs = cs; + } + + if (ap.av.alignment.getGroups() != null) + pid.setAllGroupsCheckEnabled(true); + else + pid.setAllGroupsCheckEnabled(false); + + + return pid.getValue(); + + } + }