From e11ae6a7bebf2d80fc2e5a6998a4a7aa6e76d094 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 30 Nov 2005 18:14:21 +0000 Subject: [PATCH] Applet changes --- src/MCview/AppletPDBCanvas.java | 18 ++++++++---- src/MCview/AppletPDBViewer.java | 10 +++++-- src/MCview/Bond.java | 6 ---- src/MCview/MCMatrix.java | 9 ------ src/MCview/PDBChain.java | 2 ++ src/MCview/PDBfile.java | 58 ++++++++++++++++++++------------------- 6 files changed, 52 insertions(+), 51 deletions(-) diff --git a/src/MCview/AppletPDBCanvas.java b/src/MCview/AppletPDBCanvas.java index f0b7514..93d4c92 100755 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@ -75,6 +75,7 @@ public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotion Vector highlightRes; boolean pdbAction = false; Bond highlightBond1, highlightBond2; + boolean errorLoading = false; public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq) { @@ -179,8 +180,6 @@ public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotion setupBonds(); scale = findScale(); - - updateSeqColours(); } @@ -352,13 +351,23 @@ public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotion public void paint(Graphics g) { - if(visiblebonds==null) + if(errorLoading) { + g.setColor(Color.white); + g.fillRect(0,0,getSize().width, getSize().height); g.setColor(Color.black); g.setFont(new Font("Verdana", Font.BOLD, 14)); - g.drawString("Error Parsing Pasted PDB data!!", 50, getSize().height/2); + g.drawString("Error loading PDB data!!", 50, getSize().height/2); return; } + else if(visiblebonds==null) + { + g.setColor(Color.black); + g.setFont(new Font("Verdana", Font.BOLD, 14)); + g.drawString("Fetching PDB data...", 50, getSize().height/2); + return; + } + //Only create the image at the beginning - @@ -377,7 +386,6 @@ public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotion }catch(Exception ex) { ex.printStackTrace(); - System.out.println(getSize()); } } diff --git a/src/MCview/AppletPDBViewer.java b/src/MCview/AppletPDBViewer.java index 8598c8d..c3063a8 100755 --- a/src/MCview/AppletPDBViewer.java +++ b/src/MCview/AppletPDBViewer.java @@ -16,7 +16,7 @@ public class AppletPDBViewer extends Frame AppletPDBCanvas pdbcanvas; - public AppletPDBViewer(String pdbtext, + public AppletPDBViewer(String pdbtext,String type, Sequence seq, SeqCanvas seqcanvas) { @@ -40,9 +40,13 @@ public class AppletPDBViewer extends Frame jalview.bin.JalviewLite.addFrame(this,title.toString(),400, 400); try{ - PDBfile pdbfile = new PDBfile(pdbtext, "Paste"); + PDBfile pdbfile = new PDBfile(pdbtext, type); pdbcanvas.setPDBFile(pdbfile); - }catch(Exception ex){ex.printStackTrace();} + } + catch(Exception ex){ + pdbcanvas.errorLoading = true; + pdbcanvas.repaint(); + } } diff --git a/src/MCview/Bond.java b/src/MCview/Bond.java index e3f36f7..5f162b0 100755 --- a/src/MCview/Bond.java +++ b/src/MCview/Bond.java @@ -55,12 +55,6 @@ public class Bond { this.endCol = bond.endCol; } - public void print() { - System.out.println("Start " + start[0] + " " + start[1] + " " + - start[2]); - System.out.println("End " + end[0] + " " + end[1] + " " + end[2]); - } - public float length() { float len = ((end[0] - start[0]) * (end[0] - start[0])) + ((end[1] - start[1]) * (end[1] - start[1])) + diff --git a/src/MCview/MCMatrix.java b/src/MCview/MCMatrix.java index 2effba6..66c3798 100755 --- a/src/MCview/MCMatrix.java +++ b/src/MCview/MCMatrix.java @@ -34,15 +34,6 @@ public class MCMatrix { matrix[i][j] = value; } - public void print() { - System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + - matrix[0][2]); - System.out.println(matrix[1][0] + " " + matrix[1][1] + " " + - matrix[1][2]); - System.out.println(matrix[2][0] + " " + matrix[2][1] + " " + - matrix[2][2]); - } - public void rotatex(float degrees) { mycos = (float) (Math.cos(degrees * myconst)); mysin = (float) (Math.sin(degrees * myconst)); diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 1fade31..5f23a26 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -105,6 +105,8 @@ public class PDBChain { makeBond(at1, at2); } } + else + System.out.println("not found "+i); } } diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index b3e4e28..d7b7c97 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -67,6 +67,7 @@ public class PDBfile extends jalview.io.FileParse { noLines = lineArray.size(); parse(); + lineArray = null; } public void parse() @@ -76,11 +77,13 @@ public class PDBfile extends jalview.io.FileParse { boolean modelFlag = false; boolean terFlag = false; + for (int i = 0; i < lineArray.size(); i++) { line = lineArray.elementAt(i).toString(); + if (line.indexOf("HEADER") == 0) { id = line.substring(62, 67).trim(); @@ -96,39 +99,38 @@ public class PDBfile extends jalview.io.FileParse { if(modelFlag && line.indexOf("ENDMDL")==0) break; - if (line.indexOf("ATOM")==0 - || (line.indexOf("HETATM")==0 && !terFlag) ) + if ( line.indexOf("ATOM")==0 + || (line.indexOf("HETATM")==0 && !terFlag) + ) { terFlag = false; - try { - Atom tmpatom = new Atom(line); - - //Jalview is only interested in CA bonds???? - if(!tmpatom.name.equals("CA")) - continue; - - tmpchain = findChain(tmpatom.chain); - if ( tmpchain != null) - { - tmpchain.atoms.addElement(tmpatom); - } - else - { - tmpchain = new PDBChain(tmpatom.chain); - chains.addElement(tmpchain); - tmpchain.atoms.addElement(tmpatom); - } - } catch (NumberFormatException e) { - System.err.println("Caught" + e); - System.err.println("Record not added to PDB model:" + - lineArray.elementAt(i).toString()); - } - } + + //Jalview is only interested in CA bonds???? + if (!line.substring(12, 15).trim().equals("CA")) + { + continue; + } + + Atom tmpatom = new Atom(line); + + tmpchain = findChain(tmpatom.chain); + if (tmpchain != null) + { + tmpchain.atoms.addElement(tmpatom); + } + else + { + tmpchain = new PDBChain(tmpatom.chain); + chains.addElement(tmpchain); + tmpchain.atoms.addElement(tmpatom); + } + + } } - makeResidueList(); - makeCaBondList(); + makeResidueList(); + makeCaBondList(); } public void makeResidueList() { -- 1.7.10.2