From: amwaterhouse Date: Fri, 9 Dec 2005 13:34:46 +0000 (+0000) Subject: All colours added to Structure viewer X-Git-Tag: Release_2_07~19 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c44b1974aea543db46790f6cb88f5ac0aae10a94;p=jalview.git All colours added to Structure viewer --- diff --git a/src/MCview/AppletPDBViewer.java b/src/MCview/AppletPDBViewer.java index b2931ae..901297b 100755 --- a/src/MCview/AppletPDBViewer.java +++ b/src/MCview/AppletPDBViewer.java @@ -190,7 +190,7 @@ public class AppletPDBViewer extends Frame public void hydro_actionPerformed() { clearButtonGroup(); - pdbcanvas.pdb.setHydrophobicityColours(); + // pdbcanvas.pdb.setHydrophobicityColours(); pdbcanvas.redrawneeded=true; pdbcanvas.repaint(); } diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index d5af60f..6014455 100755 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -932,6 +932,8 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe Bond highlightBond1, highlightBond2; public void highlightRes(int ii) { + if( !seqColoursReady ) + return; if (highlightRes != null && highlightRes.contains((ii-1) + "")) diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 0715b6a..fa4bbf9 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -228,44 +228,27 @@ public class PDBChain { } } - public void setHydrophobicityColours() { - float hydmin = (float) ResidueProperties.getHydmin(); - float hydmax = (float) ResidueProperties.getHydmax(); - double[] hyd = ResidueProperties.getHyd(); - - Hashtable AA3Hash = ResidueProperties.getAA3Hash(); + public void setChainColours(jalview.schemes.ColourSchemeI cs) + { + Bond b; for (int i = 0; i < bonds.size(); i++) { try { - Bond b = (Bond) bonds.elementAt(i); - - int atno = ((Integer) AA3Hash.get(b.at1.resName.toUpperCase())).intValue(); - float red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin); - - if (red > (float) 1.0) { - red = (float) 1.0; - } - - if (red < (float) 0.0) { - red = (float) 0.0; - } + b = (Bond) bonds.elementAt(i); - b.startCol = new Color(red, (float) 0.0, (float) 1.0 - red); - atno = ((Integer) AA3Hash.get(b.at2.resName.toUpperCase())).intValue(); + ( (Bond) bonds.elementAt(i)).startCol = cs.findColour( + ResidueProperties.aa[ ( (Integer) ResidueProperties.aa3Hash. + get(b.at1.resName)).intValue()] + ); - red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin); + b.endCol = cs.findColour( + ResidueProperties.aa[ ( (Integer) ResidueProperties.aa3Hash. + get(b.at2.resName)).intValue()] + ); - if (red > (float) 1.0) { - red = (float) 1.0; - } - - if (red < (float) 0.0) { - red = (float) 0.0; - } - - b.endCol = new Color(red, (float) 0.2, (float) 1.0 - red); - } catch (Exception e) { - Bond b = (Bond) bonds.elementAt(i); + } catch (Exception e) + { + b = (Bond) bonds.elementAt(i); b.startCol = Color.gray; b.endCol = Color.gray; } diff --git a/src/MCview/PDBViewer.java b/src/MCview/PDBViewer.java index 817e59d..50a4a36 100755 --- a/src/MCview/PDBViewer.java +++ b/src/MCview/PDBViewer.java @@ -21,6 +21,7 @@ package MCview; import javax.swing.*; import java.awt.event.*; import jalview.datamodel.*; +import jalview.schemes.*; import jalview.gui.*; import jalview.io.EBIFetchClient; import java.awt.event.ActionListener; @@ -37,13 +38,7 @@ public class PDBViewer extends JInternalFrame implements Runnable Sequence seq, SeqCanvas seqcanvas) { - - pdb = entry; - sequence = seq; - - Thread worker = new Thread(this); - worker.start(); - + /*Uncomment this to modify in Jbuilder try { jbInit(); @@ -51,7 +46,14 @@ public class PDBViewer extends JInternalFrame implements Runnable catch (Exception ex) { ex.printStackTrace(); - } + }*/ + + + pdb = entry; + sequence = seq; + + Thread worker = new Thread(this); + worker.start(); pdbcanvas = new PDBCanvas(seqcanvas, seq); @@ -79,6 +81,14 @@ public class PDBViewer extends JInternalFrame implements Runnable pdbcanvas.setPDBFile(pdbfile); + try + { + jbInit(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } catch (Exception ex) { @@ -160,14 +170,6 @@ public class PDBViewer extends JInternalFrame implements Runnable charge_actionPerformed(e); } }); - hydro.setText("Hydrophobicity"); - hydro.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - hydro_actionPerformed(e); - } - }); chain.setText("By Chain"); chain.addActionListener(new ActionListener() { @@ -185,14 +187,6 @@ public class PDBViewer extends JInternalFrame implements Runnable seqButton_actionPerformed(e); } }); - molecule.setText("By Molecule"); - molecule.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - molecule_actionPerformed(e); - } - }); allchains.setSelected(true); allchains.setText("Show All Chains"); allchains.addItemListener(new ItemListener() @@ -202,27 +196,157 @@ public class PDBViewer extends JInternalFrame implements Runnable allchains_itemStateChanged(e); } }); + zappo.setText("Zappo"); + zappo.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + zappo_actionPerformed(e); + } + }); + taylor.setText("Taylor"); + taylor.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + taylor_actionPerformed(e); + } + }); + hydro.setText("Hydro"); + hydro.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + hydro_actionPerformed(e); + } + }); + helix.setText("Helix"); + helix.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + helix_actionPerformed(e); + } + }); + strand.setText("Strand"); + strand.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + strand_actionPerformed(e); + } + }); + turn.setText("Turn"); + turn.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + turn_actionPerformed(e); + } + }); + buried.setText("Buried"); + buried.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + buried_actionPerformed(e); + } + }); + user.setText("User Defined..."); + user.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + user_actionPerformed(e); + } + }); + viewMenu.setText("View"); jMenuBar1.add(fileMenu); jMenuBar1.add(coloursMenu); + jMenuBar1.add(viewMenu); fileMenu.add(saveMenu); fileMenu.add(mapping); saveMenu.add(png); saveMenu.add(eps); 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(molecule); - 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); ButtonGroup bg = new ButtonGroup(); bg.add(seqButton); bg.add(chain); - bg.add(hydro); bg.add(charge); + bg.add(zappo); + bg.add(taylor); + bg.add(hydro); + bg.add(helix); + bg.add(strand); + bg.add(turn); + bg.add(buried); + bg.add(user); + + + if(jalview.gui.UserDefinedColours.getUserColourSchemes()!=null) + { + java.util.Enumeration userColours = jalview.gui.UserDefinedColours. + getUserColourSchemes().keys(); + + while (userColours.hasMoreElements()) + { + final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(userColours. + nextElement().toString()); + radioItem.setName("USER_DEFINED"); + radioItem.addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent evt) + { + if(evt.isControlDown() || SwingUtilities.isRightMouseButton(evt)) + { + radioItem.removeActionListener(radioItem.getActionListeners()[0]); + + int option = JOptionPane.showInternalConfirmDialog(jalview.gui.Desktop.desktop, + "Remove from default list?", + "Remove user defined colour", + JOptionPane.YES_NO_OPTION); + if(option == JOptionPane.YES_OPTION) + { + jalview.gui.UserDefinedColours.removeColourFromDefaults(radioItem.getText()); + coloursMenu.remove(radioItem); + } + else + radioItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + user_actionPerformed(evt); + } + }); + } + } + }); + radioItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent evt) + { + user_actionPerformed(evt); + } + }); + coloursMenu.add(radioItem); + bg.add(radioItem); + } + } + + viewMenu.add(wire); + viewMenu.add(depth); + viewMenu.add(zbuffer); + viewMenu.add(allchains); } JMenuBar jMenuBar1 = new JMenuBar(); @@ -235,12 +359,20 @@ public class PDBViewer extends JInternalFrame implements Runnable JCheckBoxMenuItem wire = new JCheckBoxMenuItem(); JCheckBoxMenuItem depth = new JCheckBoxMenuItem(); JCheckBoxMenuItem zbuffer = new JCheckBoxMenuItem(); + JCheckBoxMenuItem allchains = new JCheckBoxMenuItem(); + JRadioButtonMenuItem charge = new JRadioButtonMenuItem(); - JRadioButtonMenuItem hydro = new JRadioButtonMenuItem(); JRadioButtonMenuItem chain = new JRadioButtonMenuItem(); JRadioButtonMenuItem seqButton = new JRadioButtonMenuItem(); - JCheckBoxMenuItem molecule = new JCheckBoxMenuItem(); - JCheckBoxMenuItem allchains = new JCheckBoxMenuItem(); + JRadioButtonMenuItem hydro = new JRadioButtonMenuItem(); + JRadioButtonMenuItem taylor = new JRadioButtonMenuItem(); + JRadioButtonMenuItem zappo = new JRadioButtonMenuItem(); + JRadioButtonMenuItem user = new JRadioButtonMenuItem(); + JRadioButtonMenuItem buried = new JRadioButtonMenuItem(); + JRadioButtonMenuItem turn = new JRadioButtonMenuItem(); + JRadioButtonMenuItem strand = new JRadioButtonMenuItem(); + JRadioButtonMenuItem helix = new JRadioButtonMenuItem(); + JMenu viewMenu = new JMenu(); /** * DOCUMENT ME! @@ -290,7 +422,7 @@ public class PDBViewer extends JInternalFrame implements Runnable } public void charge_actionPerformed(ActionEvent e) { - clearButtonGroup(); + pdbcanvas.bysequence = false; pdbcanvas.pdb.setChargeColours(); pdbcanvas.redrawneeded=true; pdbcanvas.repaint(); @@ -298,15 +430,15 @@ public class PDBViewer extends JInternalFrame implements Runnable public void hydro_actionPerformed(ActionEvent e) { - clearButtonGroup(); - pdbcanvas.pdb.setHydrophobicityColours(); + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new HydrophobicColourScheme()); pdbcanvas.redrawneeded=true; pdbcanvas.repaint(); } public void chain_actionPerformed(ActionEvent e) { - clearButtonGroup(); + pdbcanvas.bysequence = false; pdbcanvas.pdb.setChainColours(); pdbcanvas.redrawneeded=true; pdbcanvas.repaint(); @@ -342,16 +474,10 @@ public class PDBViewer extends JInternalFrame implements Runnable public void seqButton_actionPerformed(ActionEvent e) { - clearButtonGroup(); - pdbcanvas.bysequence = seqButton.isSelected(); + pdbcanvas.bysequence = true; pdbcanvas.updateSeqColours(); } - void clearButtonGroup() - { - pdbcanvas.bysequence = false; - pdbcanvas.bymolecule = false; - } public void mapping_actionPerformed(ActionEvent e) { @@ -364,4 +490,69 @@ public class PDBViewer extends JInternalFrame implements Runnable { pdbcanvas.setAllchainsVisible(allchains.getState()); } + + public void zappo_actionPerformed(ActionEvent e) + { + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new ZappoColourScheme()); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + + public void taylor_actionPerformed(ActionEvent e) + { + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new TaylorColourScheme()); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + + public void helix_actionPerformed(ActionEvent e) + { + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new HelixColourScheme()); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + + public void strand_actionPerformed(ActionEvent e) + { + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new StrandColourScheme()); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + + public void turn_actionPerformed(ActionEvent e) + { + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new TurnColourScheme()); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + + public void buried_actionPerformed(ActionEvent e) + { + pdbcanvas.bysequence = false; + pdbcanvas.pdb.setColours(new BuriedColourScheme()); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + + public void user_actionPerformed(ActionEvent e) + { + if (e.getActionCommand().equals("User Defined...")) + { + new UserDefinedColours(pdbcanvas, null); + } + else + { + UserColourScheme udc = (UserColourScheme) UserDefinedColours. + getUserColourSchemes().get(e.getActionCommand()); + + pdbcanvas.pdb.setColours(udc); + pdbcanvas.redrawneeded=true; + pdbcanvas.repaint(); + } + } } diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index d7b7c97..26f1701 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -161,9 +161,9 @@ public class PDBfile extends jalview.io.FileParse { } } - public void setHydrophobicityColours() { + public void setColours(jalview.schemes.ColourSchemeI cs) { for (int i = 0; i < chains.size(); i++) { - ((PDBChain) chains.elementAt(i)).setHydrophobicityColours(); + ((PDBChain) chains.elementAt(i)).setChainColours(cs); } }