From ff3c6d412fe13784cde1e15a12567d6537f4151c Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Mon, 17 Jan 2005 14:16:19 +0000 Subject: [PATCH] Works out exisiting colur of a group --- src/jalview/gui/PopupMenu.java | 253 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 247 insertions(+), 6 deletions(-) diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 62d69d0..19698b7 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -25,7 +25,7 @@ public class PopupMenu extends JPopupMenu protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem abovePIDColour = new JRadioButtonMenuItem(); + protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); @@ -75,7 +75,37 @@ public class PopupMenu extends JPopupMenu SequenceGroup sg = ap.av.getRubberbandGroup(); if(sg!=null) - groupName.setText( sg.getName() ); + { + groupName.setText(sg.getName()); + if(sg.cs instanceof ZappoColourScheme) + zappoColour.setSelected(true); + else if(sg.cs instanceof TaylorColourScheme) + taylorColour.setSelected(true); + else if (sg.cs instanceof PIDColourScheme) + PIDColour.setSelected(true); + else if (sg.cs instanceof Blosum62ColourScheme) + BLOSUM62Colour.setSelected(true); + else if (sg.cs instanceof UserColourScheme) + userDefinedColour.setSelected(true); + else if (sg.cs instanceof HydrophobicColourScheme) + hydrophobicityColour.setSelected(true); + else if (sg.cs instanceof HelixColourScheme) + helixColour.setSelected(true); + else if (sg.cs instanceof StrandColourScheme) + strandColour.setSelected(true); + else if (sg.cs instanceof TurnColourScheme) + turnColour.setSelected(true); + else if (sg.cs instanceof BuriedColourScheme) + buriedColour.setSelected(true); + else if (sg.cs instanceof ClustalxColourScheme) + clustalColour.setSelected(true); + else + noColourmenuItem.setSelected(true); + + if (sg.cs instanceof ConservationColourScheme) + conservationMenuItem.setSelected(true); + + } if(seq!=null) { @@ -183,7 +213,6 @@ public class PopupMenu extends JPopupMenu residueMenu.add(annotateResidue); noColourmenuItem.setText("None"); - noColourmenuItem.setSelected(true); noColourmenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) @@ -192,7 +221,6 @@ public class PopupMenu extends JPopupMenu } }); - clustalColour.setSelected(false); clustalColour.setText("Clustalx colours"); clustalColour.addActionListener(new java.awt.event.ActionListener() { @@ -375,7 +403,7 @@ frame.setMaximizable(false); SliderPanel sp = new SliderPanel(ap, 70, false, getGroup().cs ); JInternalFrame frame = new JInternalFrame(); frame.setContentPane(sp); - Desktop.addInternalFrame(frame, "Percentage Identity Threshold", 400,90); + Desktop.addInternalFrame(frame, "Percentage Identity Threshold ("+getGroup().getName()+")" , 400,90); frame.setMaximizable(false); } @@ -386,7 +414,7 @@ frame.setMaximizable(false); JInternalFrame frame = new JInternalFrame(); UserDefinedColours chooser = new UserDefinedColours( frame, ap, getGroup()); frame.setContentPane(chooser); - Desktop.addInternalFrame(frame,"User defined colours", 450,540 ); + Desktop.addInternalFrame(frame,"User defined colours ("+getGroup().getName()+")", 450,540 ); frame.setResizable(false); frame.setIconifiable(false); frame.setMaximizable(false); @@ -428,6 +456,219 @@ frame.setMaximizable(false); refresh(); } +/* + protected void noColourmenuItem_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme( null ); + changeColour(); + } + + + public void clustalColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme(new ClustalxColourScheme( )); + conservationMenuItem.setSelected(false); + abovePIDThreshold.setSelected(false); + changeColour(); + } + + public void zappoColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme(new ZappoColourScheme() ); + changeColour(); + } + + public void taylorColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme(new TaylorColourScheme() ); + changeColour(); + } + + + public void hydrophobicityColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme( new HydrophobicColourScheme() ); + changeColour(); + } + + public void helixColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme( new HelixColourScheme() ); + changeColour(); + } + + + public void strandColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme(new StrandColourScheme() ); + changeColour(); + } + + + public void turnColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme(new TurnColourScheme() ); + changeColour(); + } + + + public void buriedColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme( new BuriedColourScheme() ); + changeColour(); + } + + void changeColour() + { + if(abovePIDThreshold.isSelected()) + abovePIDThreshold_actionPerformed(null); + else if(conservationMenuItem.isSelected()) + conservationMenuItem_actionPerformed(null); + + alignPanel.seqPanel.seqCanvas.paintFlag = true; + alignPanel.repaint(); + } + + void addConservationOrPIDColour() + { + int x=0, y=0, threshold = 70; + + 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(); } + + ColourSchemeI oldCs = viewport.getGlobalColourScheme(); + + 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() ); + + c.calculate(); + c.verdict(false, 100); + + 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 ); + } + + + 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); + + } + 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(); + } + + + + public void userDefinedColour_actionPerformed(ActionEvent e) + { + JInternalFrame frame = new JInternalFrame(); + UserDefinedColours chooser = new UserDefinedColours( frame, alignPanel, null); + frame.setContentPane(chooser); + Desktop.addInternalFrame(frame,"User defined colours", 450,540 ); + frame.setResizable(false); + frame.setIconifiable(false); + frame.setMaximizable(false); + } + + public void PIDColour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme( new PIDColourScheme() ); + alignPanel.setColourScheme( ); + } + + + public void BLOSUM62Colour_actionPerformed(ActionEvent e) + { + viewport.setGlobalColourScheme( new Blosum62ColourScheme(viewport) ); + alignPanel.setColourScheme(); + } +*/ +////////////////////////////////////// protected void groupAnnotation_actionPerformed(ActionEvent e) { -- 1.7.10.2