Vector highlightRes;\r
boolean pdbAction = false;\r
Bond highlightBond1, highlightBond2;\r
+ boolean errorLoading = false;\r
\r
public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq)\r
{\r
setupBonds();\r
\r
scale = findScale();\r
-\r
- updateSeqColours();\r
}\r
\r
\r
public void paint(Graphics g)\r
{\r
\r
- if(visiblebonds==null)\r
+ if(errorLoading)\r
{\r
+ g.setColor(Color.white);\r
+ g.fillRect(0,0,getSize().width, getSize().height);\r
g.setColor(Color.black);\r
g.setFont(new Font("Verdana", Font.BOLD, 14));\r
- g.drawString("Error Parsing Pasted PDB data!!", 50, getSize().height/2);\r
+ g.drawString("Error loading PDB data!!", 50, getSize().height/2);\r
return;\r
}\r
+ else if(visiblebonds==null)\r
+ {\r
+ g.setColor(Color.black);\r
+ g.setFont(new Font("Verdana", Font.BOLD, 14));\r
+ g.drawString("Fetching PDB data...", 50, getSize().height/2);\r
+ return;\r
+ }\r
+\r
\r
\r
//Only create the image at the beginning -\r
}catch(Exception ex)\r
{\r
ex.printStackTrace();\r
- System.out.println(getSize());\r
}\r
}\r
\r
AppletPDBCanvas pdbcanvas;\r
\r
\r
- public AppletPDBViewer(String pdbtext,\r
+ public AppletPDBViewer(String pdbtext,String type,\r
Sequence seq,\r
SeqCanvas seqcanvas)\r
{\r
jalview.bin.JalviewLite.addFrame(this,title.toString(),400, 400);\r
\r
try{\r
- PDBfile pdbfile = new PDBfile(pdbtext, "Paste");\r
+ PDBfile pdbfile = new PDBfile(pdbtext, type);\r
pdbcanvas.setPDBFile(pdbfile);\r
- }catch(Exception ex){ex.printStackTrace();}\r
+ }\r
+ catch(Exception ex){\r
+ pdbcanvas.errorLoading = true;\r
+ pdbcanvas.repaint();\r
+ }\r
}\r
\r
\r
this.endCol = bond.endCol;\r
}\r
\r
- public void print() {\r
- System.out.println("Start " + start[0] + " " + start[1] + " " +\r
- start[2]);\r
- System.out.println("End " + end[0] + " " + end[1] + " " + end[2]);\r
- }\r
-\r
public float length() {\r
float len = ((end[0] - start[0]) * (end[0] - start[0])) +\r
((end[1] - start[1]) * (end[1] - start[1])) +\r
matrix[i][j] = value;\r
}\r
\r
- public void print() {\r
- System.out.println(matrix[0][0] + " " + matrix[0][1] + " " +\r
- matrix[0][2]);\r
- System.out.println(matrix[1][0] + " " + matrix[1][1] + " " +\r
- matrix[1][2]);\r
- System.out.println(matrix[2][0] + " " + matrix[2][1] + " " +\r
- matrix[2][2]);\r
- }\r
-\r
public void rotatex(float degrees) {\r
mycos = (float) (Math.cos(degrees * myconst));\r
mysin = (float) (Math.sin(degrees * myconst));\r
makeBond(at1, at2);\r
}\r
}\r
+ else\r
+ System.out.println("not found "+i);\r
}\r
}\r
\r
noLines = lineArray.size();\r
\r
parse();\r
+ lineArray = null;\r
}\r
\r
public void parse()\r
boolean modelFlag = false;\r
boolean terFlag = false;\r
\r
+\r
for (int i = 0; i < lineArray.size(); i++)\r
{\r
\r
line = lineArray.elementAt(i).toString();\r
\r
+\r
if (line.indexOf("HEADER") == 0)\r
{\r
id = line.substring(62, 67).trim();\r
if(modelFlag && line.indexOf("ENDMDL")==0)\r
break;\r
\r
- if (line.indexOf("ATOM")==0\r
- || (line.indexOf("HETATM")==0 && !terFlag) )\r
+ if ( line.indexOf("ATOM")==0\r
+ || (line.indexOf("HETATM")==0 && !terFlag)\r
+ )\r
{\r
terFlag = false;\r
\r
- try {\r
- Atom tmpatom = new Atom(line);\r
-\r
- //Jalview is only interested in CA bonds????\r
- if(!tmpatom.name.equals("CA"))\r
- continue;\r
-\r
- tmpchain = findChain(tmpatom.chain);\r
- if ( tmpchain != null)\r
- {\r
- tmpchain.atoms.addElement(tmpatom);\r
- }\r
- else\r
- {\r
- tmpchain = new PDBChain(tmpatom.chain);\r
- chains.addElement(tmpchain);\r
- tmpchain.atoms.addElement(tmpatom);\r
- }\r
- } catch (NumberFormatException e) {\r
- System.err.println("Caught" + e);\r
- System.err.println("Record not added to PDB model:" +\r
- lineArray.elementAt(i).toString());\r
- }\r
- }\r
+\r
+ //Jalview is only interested in CA bonds????\r
+ if (!line.substring(12, 15).trim().equals("CA"))\r
+ {\r
+ continue;\r
+ }\r
+\r
+ Atom tmpatom = new Atom(line);\r
+\r
+ tmpchain = findChain(tmpatom.chain);\r
+ if (tmpchain != null)\r
+ {\r
+ tmpchain.atoms.addElement(tmpatom);\r
+ }\r
+ else\r
+ {\r
+ tmpchain = new PDBChain(tmpatom.chain);\r
+ chains.addElement(tmpchain);\r
+ tmpchain.atoms.addElement(tmpatom);\r
+ }\r
+\r
+ }\r
}\r
\r
- makeResidueList();\r
- makeCaBondList();\r
+ makeResidueList();\r
+ makeCaBondList();\r
}\r
\r
public void makeResidueList() {\r