From: amwaterhouse Date: Mon, 14 Nov 2005 18:35:31 +0000 (+0000) Subject: Modifications for Applet PDB X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0083bf4d00fcc93d81890dafd5ba8ba413705533;p=jalview.git Modifications for Applet PDB --- diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index 2bc934f..b1d8805 100755 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -421,7 +421,7 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe { for (int ii = 0; ii < pdb.chains.size(); ii++) { - ( (PDBChain) pdb.chains.elementAt(ii)).colourBySequence(sr, fr); + colourBySequence( (PDBChain) pdb.chains.elementAt(ii) ); } } @@ -430,6 +430,50 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe } + // This method has been taken out of PDBChain to allow + // Applet and Application specific sequence renderers to be used + void colourBySequence(PDBChain chain) + { + for (int i = 0; i < chain.bonds.size(); i++) + { + Bond tmp = (Bond) chain.bonds.elementAt(i); + + if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) && + (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1))) + { + int pos = chain.seqstart + + (tmp.at1.resNumber - chain.pdbstart - chain.offset); + + int index = sequence.findIndex(pos); + + tmp.startCol = sr.findSequenceColour(tmp.startCol, sequence, index); + + tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index); + + } + else + { + tmp.startCol = Color.gray; + } + + if ( (tmp.at2.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) && + (tmp.at2.resNumber <= ( (chain.pdbend + chain.offset) - 1))) + { + int pos = chain.seqstart + + (tmp.at2.resNumber - chain.pdbstart - chain.offset); + int index = sequence.findIndex(pos); + + tmp.endCol = sr.findSequenceColour(tmp.endCol, sequence, index); + tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index); + } + else + { + tmp.endCol = Color.gray; + } + } + } + + public void drawScene(Graphics g) { // Sort the bonds by z coord Vector bonds = new Vector(); diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 166e537..208ecd0 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -143,8 +143,8 @@ public class PDBChain { } sequence = new Sequence("PDB_seq", seq, 1, seq.length()); - // System.out.println("PDB Sequence is :\nSequence = " + seq); - // System.out.println("No of residues = " + residues.size()); + // System.out.println("PDB Sequence is :\nSequence = " + seq); + // System.out.println("No of residues = " + residues.size()); } public void setChargeColours() { @@ -229,47 +229,7 @@ public class PDBChain { } } - public void colourBySequence(jalview.gui.SequenceRenderer sr, - jalview.gui.FeatureRenderer fr) - { - for (int i = 0; i < bonds.size(); i++) - { - Bond tmp = (Bond) bonds.elementAt(i); - - if ((tmp.at1.resNumber >= ((offset + pdbstart) - 1)) && - (tmp.at1.resNumber <= ((offset + pdbend) - 1))) - { - int pos = seqstart + - (tmp.at1.resNumber - pdbstart - offset); - - - int index = sequence.findIndex(pos); - - tmp.startCol = sr.findSequenceColour(Color.gray, sequence, index); - - tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index); - - } else - { - tmp.startCol = Color.gray; - } - - if ((tmp.at2.resNumber >= ((offset + pdbstart) - 1)) && - (tmp.at2.resNumber <= ((pdbend + offset) - 1))) { - int pos = seqstart + - (tmp.at2.resNumber - pdbstart - offset); - int index = sequence.findIndex(pos); - - tmp.endCol = sr.findSequenceColour(Color.gray, sequence, index); - tmp.endCol = fr.findFeatureColour( tmp.endCol, sequence, index); - } - else - { - tmp.endCol = Color.gray; - } - } - } public void setChainColours() { for (int i = 0; i < bonds.size(); i++) { diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index 8cbe37d..f9d842f 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -48,6 +48,10 @@ public class PDBfile extends jalview.io.FileParse { if (inType.equals("File")) { dataIn = new BufferedReader(new FileReader(inFile)); } + else if(inType.equals("Paste")) + { + dataIn = new BufferedReader(new StringReader(inFile)); + } else { URL url = new URL(inFile); this.fileSize = 0; @@ -79,7 +83,6 @@ public class PDBfile extends jalview.io.FileParse { // System.out.println("Adding to chain " + tmpatom.chain); findChain(tmpatom.chain).atoms.addElement(tmpatom); } else { - // System.out.println("Making chain " + tmpatom.chain); PDBChain tmpchain = new PDBChain(tmpatom.chain); chains.addElement(tmpchain); tmpchain.atoms.addElement(tmpatom); @@ -132,10 +135,11 @@ public class PDBfile extends jalview.io.FileParse { } } - public void colourBySequence(jalview.gui.SequenceRenderer sr, - jalview.gui.FeatureRenderer fr) { + public void colourBySequence()//jalview.gui.SequenceRenderer sr, + // jalview.gui.FeatureRenderer fr) + { for (int i = 0; i < chains.size(); i++) { - ((PDBChain)chains.elementAt(i)).colourBySequence(sr,fr); + //((PDBChain)chains.elementAt(i)).colourBySequence(sr,fr); } }