From: amwaterhouse Date: Fri, 9 Dec 2005 14:10:59 +0000 (+0000) Subject: Applet Structure viewer has all colours available X-Git-Tag: Release_2_07~17 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dfb45c8f874124d3ff3caac2902ed0c4a0e87cf5;p=jalview.git Applet Structure viewer has all colours available --- diff --git a/src/MCview/AppletPDBCanvas.java b/src/MCview/AppletPDBCanvas.java index f39a3fa..d91d43e 100755 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@ -418,7 +418,13 @@ public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotion drawLabels(ig); } - + void setColours(jalview.schemes.ColourSchemeI cs) + { + bysequence = false; + pdb.setColours(cs); + redrawneeded = true; + repaint(); + } public void updateSeqColours() { if (pdbAction) diff --git a/src/MCview/AppletPDBViewer.java b/src/MCview/AppletPDBViewer.java index 901297b..2c0080e 100755 --- a/src/MCview/AppletPDBViewer.java +++ b/src/MCview/AppletPDBViewer.java @@ -23,6 +23,7 @@ import java.awt.*; import java.awt.event.*; import jalview.datamodel.*; import jalview.appletgui.*; +import jalview.schemes.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; @@ -121,7 +122,7 @@ public class AppletPDBViewer extends Frame { public void actionPerformed(ActionEvent e) { - hydro_actionPerformed(); + pdbcanvas.setColours(new HydrophobicColourScheme()); } }); chain.setLabel("By Chain"); @@ -147,19 +148,84 @@ public class AppletPDBViewer extends Frame allchains_itemStateChanged(itemEvent); } }); + viewMenu.setLabel("View"); + zappo.setLabel("Zappo"); + zappo.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.setColours(new ZappoColourScheme()); + } + }); + taylor.setLabel("Taylor"); + taylor.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.setColours(new TaylorColourScheme()); + } + }); + helix.setLabel("Helix Propensity"); + helix.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.setColours(new HelixColourScheme()); + } + }); + strand.setLabel("Strand Propensity"); + strand.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.setColours(new StrandColourScheme()); + } + }); + turn.setLabel("Turn Propensity"); + turn.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.setColours(new TurnColourScheme()); + } + }); + buried.setLabel("Buried Index"); + buried.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.setColours(new BuriedColourScheme()); + } + }); + user.setLabel("User Defined..."); + user.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + pdbcanvas.bysequence = false; + new jalview.appletgui.UserDefinedColours(pdbcanvas); + } + }); jMenuBar1.add(fileMenu); jMenuBar1.add(coloursMenu); - fileMenu.add(mapping);; + jMenuBar1.add(viewMenu); + fileMenu.add(mapping);; coloursMenu.add(seqButton); coloursMenu.add(chain); - coloursMenu.add(hydro); coloursMenu.add(charge); - coloursMenu.addSeparator(); - coloursMenu.add(wire); - coloursMenu.add(depth); - coloursMenu.add(zbuffer); - coloursMenu.add(allchains); + coloursMenu.add(zappo); + coloursMenu.add(taylor); + coloursMenu.add(hydro); + coloursMenu.add(helix); + coloursMenu.add(strand); + coloursMenu.add(turn); + coloursMenu.add(buried); + coloursMenu.add(user); + viewMenu.add(wire); + viewMenu.add(depth); + viewMenu.add(zbuffer); + viewMenu.add(allchains); allchains.setState(true); } @@ -178,27 +244,27 @@ public class AppletPDBViewer extends Frame MenuItem seqButton = new MenuItem(); CheckboxMenuItem allchains = new CheckboxMenuItem(); + Menu viewMenu = new Menu(); + MenuItem turn = new MenuItem(); + MenuItem strand = new MenuItem(); + MenuItem helix = new MenuItem(); + MenuItem taylor = new MenuItem(); + MenuItem zappo = new MenuItem(); + MenuItem buried = new MenuItem(); + MenuItem user = new MenuItem(); public void charge_actionPerformed() { - clearButtonGroup(); + pdbcanvas.bysequence = false; pdbcanvas.pdb.setChargeColours(); pdbcanvas.redrawneeded=true; pdbcanvas.repaint(); } - public void hydro_actionPerformed() - { - clearButtonGroup(); - // pdbcanvas.pdb.setHydrophobicityColours(); - pdbcanvas.redrawneeded=true; - pdbcanvas.repaint(); - } - public void chain_actionPerformed() { - clearButtonGroup(); - pdbcanvas.pdb.setChainColours(); + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setChainColours(); pdbcanvas.redrawneeded=true; pdbcanvas.repaint(); } @@ -226,17 +292,11 @@ public class AppletPDBViewer extends Frame public void seqButton_actionPerformed() { - clearButtonGroup(); pdbcanvas.bysequence = true; pdbcanvas.updateSeqColours(); pdbcanvas.repaint(); } - void clearButtonGroup() - { - pdbcanvas.bysequence = false; - pdbcanvas.bymolecule = false; - } public void mapping_actionPerformed() { @@ -252,4 +312,5 @@ public class AppletPDBViewer extends Frame { pdbcanvas.setAllchainsVisible(allchains.getState()); } + } diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 7cd0391..71bcaca 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -37,6 +37,7 @@ public class UserDefinedColours Vector oldColours = new Vector(); ColourSchemeI oldColourScheme; Frame frame; + MCview.AppletPDBCanvas pdbcanvas; int R = 0, G = 0, B = 0; @@ -48,20 +49,6 @@ public class UserDefinedColours public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) { - try { - jbInit(); - } catch (Exception e) { - e.printStackTrace(); - } - frame = new Frame(); - frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, 345); - - if (sg != null) - { - frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")"); - } - this.ap = ap; seqGroup = sg; @@ -74,6 +61,34 @@ public class UserDefinedColours oldColourScheme = ap.av.getGlobalColourScheme(); } + init(); + } + + public UserDefinedColours(MCview.AppletPDBCanvas pdb) + { + this.pdbcanvas = pdb; + init(); + } + + void init() + { + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } + frame = new Frame(); + frame.add(this); + jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, 345); + + if (seqGroup != null) + { + frame.setTitle(frame.getTitle() + " (" + seqGroup.getName() + ")"); + } + for (int i = 0; i < 20; i++) { makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + @@ -86,9 +101,7 @@ public class UserDefinedColours makeButton("Gap", "'.','-',' '"); validate(); - } - protected void rText_actionPerformed(ActionEvent e) { try @@ -214,7 +227,6 @@ public class UserDefinedColours protected void applyButton_actionPerformed(ActionEvent e) { - Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) { @@ -223,19 +235,27 @@ public class UserDefinedColours } UserColourScheme ucs = new UserColourScheme(newColours); - ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); + if(ap!=null) + ucs.setThreshold(0, ap.av.getIgnoreGapsConsensus()); - if (seqGroup != null) + if(ap!=null) { - seqGroup.cs = ucs; + if (seqGroup != null) + { + seqGroup.cs = ucs; + } + else + { + ap.av.setGlobalColourScheme(ucs); + } + ap.seqPanel.seqCanvas.img = null; + ap.repaint(); } - else + else if(pdbcanvas!=null) { - ap.av.setGlobalColourScheme(ucs); + pdbcanvas.pdb.setColours(ucs); + pdbcanvas.updateSeqColours(); } - - ap.seqPanel.seqCanvas.img = null; - ap.repaint(); } @@ -251,17 +271,23 @@ public class UserDefinedColours UserColourScheme ucs = new UserColourScheme(newColours); - if (seqGroup != null) + if(ap!=null) { - seqGroup.cs = ucs; + if (seqGroup != null) + { + seqGroup.cs = ucs; + } + else + { + ap.av.setGlobalColourScheme(ucs); + } + ap.repaint(); } - else + else if(pdbcanvas!=null) { - ap.av.setGlobalColourScheme(ucs); + pdbcanvas.pdb.setColours(ucs); } - ap.repaint(); - frame.setVisible(false); }