2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
24 // JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug
\r
26 import java.awt.event.*;
\r
28 import jalview.analysis.*;
\r
29 import jalview.datamodel.*;
\r
31 import jalview.appletgui.*;
\r
32 import jalview.structure.*;
\r
34 public class AppletPDBCanvas
\r
35 extends Panel implements MouseListener, MouseMotionListener, StructureListener
\r
38 MCMatrix idmat = new MCMatrix(3, 3);
\r
39 MCMatrix objmat = new MCMatrix(3, 3);
\r
40 boolean redrawneeded = true;
\r
51 float[] centre = new float[3];
\r
52 float[] width = new float[3];
\r
57 boolean bysequence = true;
\r
58 boolean depthcue = true;
\r
59 boolean wire = false;
\r
60 boolean bymolecule = false;
\r
61 boolean zbuffer = true;
\r
69 Font font = new Font("Helvetica", Font.PLAIN, 10);
\r
70 public SequenceI [] sequence;
\r
71 final StringBuffer mappingDetails = new StringBuffer();
\r
72 String appletToolTip = null;
\r
75 Vector highlightRes;
\r
76 boolean pdbAction = false;
\r
77 Bond highlightBond1, highlightBond2;
\r
78 boolean errorLoading = false;
\r
79 boolean seqColoursReady = false;
\r
82 StructureSelectionManager ssm;
\r
84 public AppletPDBCanvas(PDBEntry pdbentry,
\r
91 this.pdbentry = pdbentry;
\r
92 this.sequence = seq;
\r
94 ssm = StructureSelectionManager.getStructureSelectionManager();
\r
97 pdb = ssm.setMapping(seq, pdbentry.getFile(), protocol);
\r
98 }catch(Exception ex)
\r
100 ex.printStackTrace();
\r
104 pdbentry.setId(pdb.id);
\r
106 ssm.addStructureViewerListener(this);
\r
108 colourBySequence(ap.getSequenceRenderer(),
\r
109 ap.av.getShowSequenceFeatures() ?
\r
110 ap.getFeatureRenderer() : null);
\r
118 AlignSeq maxAlignseq = null;
\r
120 //JUST DEAL WITH ONE SEQUENCE FOR NOW
\r
121 SequenceI sequence = seq[0];
\r
123 for (int i = 0; i < pdb.chains.size(); i++)
\r
126 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " +
\r
127 ( (PDBChain) pdb.chains.elementAt(i)).sequence.
\r
128 getSequenceAsString());
\r
129 mappingDetails.append("\nNo of residues = " +
\r
130 ( (PDBChain) pdb.chains.elementAt(i)).residues.size() +
\r
133 // Now lets compare the sequences to get
\r
134 // the start and end points.
\r
135 // Align the sequence to the pdb
\r
136 AlignSeq as = new AlignSeq(sequence,
\r
137 ( (PDBChain) pdb.chains.elementAt(i)).sequence,
\r
139 as.calcScoreMatrix();
\r
140 as.traceAlignment();
\r
141 PrintStream ps = new PrintStream(System.out)
\r
143 public void print(String x)
\r
145 mappingDetails.append(x);
\r
148 public void println()
\r
150 mappingDetails.append("\n");
\r
154 as.printAlignment(ps);
\r
156 if (as.maxscore > max)
\r
161 pdbstart = as.seq2start;
\r
162 pdbend = as.seq2end;
\r
163 seqstart = as.seq1start + sequence.getStart() - 1;
\r
164 seqend = as.seq1end + sequence.getEnd() - 1;
\r
168 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
169 mappingDetails.append("\nSEQ start/end " + seqstart + " " + seqend);
\r
172 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
174 mainchain.pdbstart = pdbstart;
\r
175 mainchain.pdbend = pdbend;
\r
176 mainchain.seqstart = seqstart;
\r
177 mainchain.seqend = seqend;
\r
178 mainchain.isVisible = true;
\r
179 // mainchain.makeExactMapping(maxAlignseq, sequence);
\r
180 // mainchain.transferRESNUMFeatures(sequence, null);
\r
182 this.prefsize = new Dimension(getSize().width, getSize().height);
\r
184 //Initialize the matrices to identity
\r
185 for (int i = 0; i < 3; i++)
\r
187 for (int j = 0; j < 3; j++)
\r
191 idmat.addElement(i, j, 0);
\r
192 objmat.addElement(i, j, 0);
\r
196 idmat.addElement(i, j, 1);
\r
197 objmat.addElement(i, j, 1);
\r
202 addMouseMotionListener(this);
\r
203 addMouseListener(this);
\r
205 addKeyListener(new KeyAdapter()
\r
207 public void keyPressed(KeyEvent evt)
\r
218 scale = findScale();
\r
221 Vector visiblebonds;
\r
224 seqColoursReady = false;
\r
225 // Sort the bonds by z coord
\r
226 visiblebonds = new Vector();
\r
228 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
230 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
232 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
234 for (int i = 0; i < tmp.size(); i++)
\r
236 visiblebonds.addElement(tmp.elementAt(i));
\r
240 seqColoursReady = true;
\r
241 colourBySequence(ap.getSequenceRenderer(),
\r
242 ap.av.getShowSequenceFeatures() ?
\r
243 ap.getFeatureRenderer() : null);
\r
244 redrawneeded = true;
\r
248 public void findWidth()
\r
250 float[] max = new float[3];
\r
251 float[] min = new float[3];
\r
253 max[0] = (float) - 1e30;
\r
254 max[1] = (float) - 1e30;
\r
255 max[2] = (float) - 1e30;
\r
257 min[0] = (float) 1e30;
\r
258 min[1] = (float) 1e30;
\r
259 min[2] = (float) 1e30;
\r
261 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
263 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
265 Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
267 for (int i = 0; i < bonds.size(); i++)
\r
269 Bond tmp = (Bond) bonds.elementAt(i);
\r
271 if (tmp.start[0] >= max[0])
\r
273 max[0] = tmp.start[0];
\r
276 if (tmp.start[1] >= max[1])
\r
278 max[1] = tmp.start[1];
\r
281 if (tmp.start[2] >= max[2])
\r
283 max[2] = tmp.start[2];
\r
286 if (tmp.start[0] <= min[0])
\r
288 min[0] = tmp.start[0];
\r
291 if (tmp.start[1] <= min[1])
\r
293 min[1] = tmp.start[1];
\r
296 if (tmp.start[2] <= min[2])
\r
298 min[2] = tmp.start[2];
\r
301 if (tmp.end[0] >= max[0])
\r
303 max[0] = tmp.end[0];
\r
306 if (tmp.end[1] >= max[1])
\r
308 max[1] = tmp.end[1];
\r
311 if (tmp.end[2] >= max[2])
\r
313 max[2] = tmp.end[2];
\r
316 if (tmp.end[0] <= min[0])
\r
318 min[0] = tmp.end[0];
\r
321 if (tmp.end[1] <= min[1])
\r
323 min[1] = tmp.end[1];
\r
326 if (tmp.end[2] <= min[2])
\r
328 min[2] = tmp.end[2];
\r
334 width[0] = (float) Math.abs(max[0] - min[0]);
\r
335 width[1] = (float) Math.abs(max[1] - min[1]);
\r
336 width[2] = (float) Math.abs(max[2] - min[2]);
\r
338 maxwidth = width[0];
\r
340 if (width[1] > width[0])
\r
342 maxwidth = width[1];
\r
345 if (width[2] > width[1])
\r
347 maxwidth = width[2];
\r
350 // System.out.println("Maxwidth = " + maxwidth);
\r
353 public float findScale()
\r
359 if (getSize().width != 0)
\r
361 width = getSize().width;
\r
362 height = getSize().height;
\r
366 width = prefsize.width;
\r
367 height = prefsize.height;
\r
370 if (width < height)
\r
379 return (float) (dim / (1.5d * maxwidth));
\r
382 public void findCentre()
\r
390 //Find centre coordinate
\r
391 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
393 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
395 Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
397 bsize += bonds.size();
\r
399 for (int i = 0; i < bonds.size(); i++)
\r
401 xtot = xtot + ( (Bond) bonds.elementAt(i)).start[0] +
\r
402 ( (Bond) bonds.elementAt(i)).end[0];
\r
404 ytot = ytot + ( (Bond) bonds.elementAt(i)).start[1] +
\r
405 ( (Bond) bonds.elementAt(i)).end[1];
\r
407 ztot = ztot + ( (Bond) bonds.elementAt(i)).start[2] +
\r
408 ( (Bond) bonds.elementAt(i)).end[2];
\r
413 centre[0] = xtot / (2 * (float) bsize);
\r
414 centre[1] = ytot / (2 * (float) bsize);
\r
415 centre[2] = ztot / (2 * (float) bsize);
\r
418 public void paint(Graphics g)
\r
423 g.setColor(Color.white);
\r
424 g.fillRect(0, 0, getSize().width, getSize().height);
\r
425 g.setColor(Color.black);
\r
426 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
427 g.drawString("Error loading PDB data!!", 50, getSize().height / 2);
\r
431 if (!seqColoursReady)
\r
433 g.setColor(Color.black);
\r
434 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
435 g.drawString("Fetching PDB data...", 50, getSize().height / 2);
\r
439 //Only create the image at the beginning -
\r
440 //this saves much memory usage
\r
441 if ( (img == null) || (prefsize.width != getSize().width) ||
\r
442 (prefsize.height != getSize().height))
\r
447 prefsize.width = getSize().width;
\r
448 prefsize.height = getSize().height;
\r
450 scale = findScale();
\r
451 img = createImage(prefsize.width, prefsize.height);
\r
452 ig = img.getGraphics();
\r
454 redrawneeded = true;
\r
456 catch (Exception ex)
\r
458 ex.printStackTrace();
\r
464 drawAll(ig, prefsize.width, prefsize.height);
\r
465 redrawneeded = false;
\r
467 if (appletToolTip != null)
\r
469 ig.setColor(Color.red);
\r
470 ig.drawString(appletToolTip, toolx, tooly);
\r
473 g.drawImage(img, 0, 0, this);
\r
478 public void drawAll(Graphics g, int width, int height)
\r
480 ig.setColor(Color.black);
\r
481 ig.fillRect(0, 0, width, height);
\r
486 public void setColours(jalview.schemes.ColourSchemeI cs)
\r
488 bysequence = false;
\r
489 pdb.setColours(cs);
\r
490 redrawneeded = true;
\r
496 // This method has been taken out of PDBChain to allow
\r
497 // Applet and Application specific sequence renderers to be used
\r
498 void colourBySequence(SequenceRenderer sr, FeatureRenderer fr)
\r
500 StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());
\r
502 boolean showFeatures = false;
\r
507 fr = new jalview.appletgui.FeatureRenderer(ap.av);
\r
509 fr.transferSettings(fr);
\r
510 showFeatures = true;
\r
514 if (bysequence && pdb != null)
\r
516 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
518 chain = (PDBChain) pdb.chains.elementAt(ii);
\r
520 for (int i = 0; i < chain.bonds.size(); i++)
\r
522 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
523 tmp.startCol = Color.lightGray;
\r
524 tmp.endCol = Color.lightGray;
\r
525 if (chain != mainchain)
\r
530 for (int s = 0; s < sequence.length; s++)
\r
532 for (int m = 0; m < mapping.length; m++)
\r
534 if (mapping[m].getSequence() == sequence[s])
\r
536 int pos = mapping[m].getSeqPos(tmp.at1.resNumber)-1;
\r
539 pos = sequence[s].findIndex(pos);
\r
540 tmp.startCol = sr.getResidueBoxColour(sequence[s], pos);
\r
543 tmp.startCol = fr.findFeatureColour(tmp.startCol,
\r
548 pos = mapping[m].getSeqPos(tmp.at2.resNumber)-1;
\r
551 pos = sequence[s].findIndex(pos);
\r
552 tmp.endCol = sr.getResidueBoxColour(sequence[s], pos);
\r
555 tmp.endCol = fr.findFeatureColour(tmp.endCol,
\r
570 public void drawScene(Graphics g)
\r
576 zsort = new Zsort();
\r
579 zsort.Zsort(visiblebonds);
\r
582 Bond tmpBond = null;
\r
583 for (int i = 0; i < visiblebonds.size(); i++)
\r
585 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
587 xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
\r
588 (getSize().width / 2));
\r
589 ystart = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
\r
590 (getSize().height / 2));
\r
592 xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
593 (getSize().width / 2));
\r
594 yend = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
595 (getSize().height / 2));
\r
597 xmid = (xend + xstart) / 2;
\r
598 ymid = (yend + ystart) / 2;
\r
600 if (depthcue && !bymolecule)
\r
602 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
\r
604 g.setColor(tmpBond.startCol.darker().darker());
\r
605 drawLine(g, xstart, ystart, xmid, ymid);
\r
607 g.setColor(tmpBond.endCol.darker().darker());
\r
608 drawLine(g, xmid, ymid, xend, yend);
\r
610 else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
\r
612 g.setColor(tmpBond.startCol.darker());
\r
613 drawLine(g, xstart, ystart, xmid, ymid);
\r
615 g.setColor(tmpBond.endCol.darker());
\r
616 drawLine(g, xmid, ymid, xend, yend);
\r
620 g.setColor(tmpBond.startCol);
\r
621 drawLine(g, xstart, ystart, xmid, ymid);
\r
623 g.setColor(tmpBond.endCol);
\r
624 drawLine(g, xmid, ymid, xend, yend);
\r
628 else if (depthcue && bymolecule)
\r
630 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
\r
632 g.setColor(Color.green.darker().darker());
\r
633 drawLine(g, xstart, ystart, xend, yend);
\r
635 else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
\r
637 g.setColor(Color.green.darker());
\r
638 drawLine(g, xstart, ystart, xend, yend);
\r
642 g.setColor(Color.green);
\r
643 drawLine(g, xstart, ystart, xend, yend);
\r
646 else if (!depthcue && !bymolecule)
\r
648 g.setColor(tmpBond.startCol);
\r
649 drawLine(g, xstart, ystart, xmid, ymid);
\r
650 g.setColor(tmpBond.endCol);
\r
651 drawLine(g, xmid, ymid, xend, yend);
\r
655 drawLine(g, xstart, ystart, xend, yend);
\r
658 if (highlightBond1 != null && highlightBond1 == tmpBond)
\r
660 g.setColor(Color.white);
\r
661 drawLine(g, xmid, ymid, xend, yend);
\r
664 if (highlightBond2 != null && highlightBond2 == tmpBond)
\r
666 g.setColor(Color.white);
\r
667 drawLine(g, xstart, ystart, xmid, ymid);
\r
673 public void drawLine(Graphics g, int x1, int y1, int x2, int y2)
\r
677 if ( ( (float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5)
\r
679 g.drawLine(x1, y1, x2, y2);
\r
680 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
681 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
685 g.setColor(g.getColor().brighter());
\r
686 g.drawLine(x1, y1, x2, y2);
\r
687 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
688 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
693 g.drawLine(x1, y1, x2, y2);
\r
697 public Dimension minimumsize()
\r
702 public Dimension preferredsize()
\r
707 public void doKeyPressed(KeyEvent evt)
\r
709 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
711 scale = (float) (scale * 1.1);
\r
712 redrawneeded = true;
\r
715 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
717 scale = (float) (scale * 0.9);
\r
718 redrawneeded = true;
\r
723 public void mousePressed(MouseEvent e)
\r
726 Atom fatom = findAtom(e.getX(), e.getY());
\r
729 fatom.isSelected = !fatom.isSelected;
\r
731 redrawneeded = true;
\r
733 if (foundchain != -1)
\r
735 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
736 if (chain == mainchain)
\r
738 if (fatom.alignmentMapping != -1)
\r
740 if (highlightRes == null)
\r
742 highlightRes = new Vector();
\r
745 if (highlightRes.contains(fatom.alignmentMapping + "" + ""))
\r
747 highlightRes.removeElement(fatom.alignmentMapping + "");
\r
751 highlightRes.addElement(fatom.alignmentMapping + "");
\r
765 public void mouseMoved(MouseEvent e)
\r
768 if (highlightBond1 != null)
\r
770 highlightBond1.at2.isSelected = false;
\r
771 highlightBond2.at1.isSelected = false;
\r
772 highlightBond1 = null;
\r
773 highlightBond2 = null;
\r
776 Atom fatom = findAtom(e.getX(), e.getY());
\r
778 PDBChain chain = null;
\r
779 if (foundchain != -1)
\r
781 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
782 if (chain == mainchain)
\r
784 mouseOverStructure(fatom.resNumber, chain.id);
\r
793 appletToolTip = chain.id + ":" + fatom.resNumber + " " + fatom.resName;
\r
794 redrawneeded = true;
\r
799 mouseOverStructure(-1, chain!=null?chain.id:null);
\r
800 appletToolTip = null;
\r
801 redrawneeded = true;
\r
806 public void mouseClicked(MouseEvent e)
\r
810 public void mouseEntered(MouseEvent e)
\r
814 public void mouseExited(MouseEvent e)
\r
818 public void mouseDragged(MouseEvent evt)
\r
820 int x = evt.getX();
\r
821 int y = evt.getY();
\r
825 MCMatrix objmat = new MCMatrix(3, 3);
\r
826 objmat.setIdentity();
\r
828 if ( (evt.getModifiers() & Event.META_MASK) != 0)
\r
830 objmat.rotatez( (float) ( (mx - omx)));
\r
834 objmat.rotatex( (float) ( (my - omy)));
\r
835 objmat.rotatey( (float) ( (omx - mx)));
\r
839 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
841 Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
843 for (int i = 0; i < bonds.size(); i++)
\r
845 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
847 //Translate the bond so the centre is 0,0,0
\r
848 tmpBond.translate( -centre[0], -centre[1], -centre[2]);
\r
850 //Now apply the rotation matrix
\r
851 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
852 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
854 //Now translate back again
\r
855 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
866 redrawneeded = true;
\r
871 public void mouseReleased(MouseEvent evt)
\r
877 void drawLabels(Graphics g)
\r
880 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
882 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
884 if (chain.isVisible)
\r
886 Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
888 for (int i = 0; i < bonds.size(); i++)
\r
890 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
892 if (tmpBond.at1.isSelected)
\r
894 labelAtom(g, tmpBond, 1);
\r
897 if (tmpBond.at2.isSelected)
\r
900 labelAtom(g, tmpBond, 2);
\r
907 public void labelAtom(Graphics g, Bond b, int n)
\r
913 int xstart = (int) ( ( (b.start[0] - centre[0]) * scale) +
\r
914 (getSize().width / 2));
\r
915 int ystart = (int) ( ( (b.start[1] - centre[1]) * scale) +
\r
916 (getSize().height / 2));
\r
918 g.setColor(Color.red);
\r
919 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
924 int xstart = (int) ( ( (b.end[0] - centre[0]) * scale) +
\r
925 (getSize().width / 2));
\r
926 int ystart = (int) ( ( (b.end[1] - centre[1]) * scale) +
\r
927 (getSize().height / 2));
\r
929 g.setColor(Color.red);
\r
930 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
934 int foundchain = -1;
\r
935 public Atom findAtom(int x, int y)
\r
941 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
943 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
945 Bond tmpBond = null;
\r
947 if (chain.isVisible)
\r
949 Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
951 for (int i = 0; i < bonds.size(); i++)
\r
953 tmpBond = (Bond) bonds.elementAt(i);
\r
955 truex = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
\r
956 (getSize().width / 2));
\r
958 if (Math.abs(truex - x) <= 2)
\r
960 int truey = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
\r
961 (getSize().height / 2));
\r
963 if (Math.abs(truey - y) <= 2)
\r
965 fatom = tmpBond.at1;
\r
972 // Still here? Maybe its the last bond
\r
974 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
975 (getSize().width / 2));
\r
977 if (Math.abs(truex - x) <= 2)
\r
979 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
980 (getSize().height / 2));
\r
982 if (Math.abs(truey - y) <= 2)
\r
984 fatom = tmpBond.at2;
\r
992 if (fatom != null) //)&& chain.ds != null)
\r
994 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
1001 public void update(Graphics g)
\r
1006 public void highlightRes(int ii)
\r
1008 if (!seqColoursReady)
\r
1013 if (highlightRes != null
\r
1014 && highlightRes.contains( (ii - 1) + ""))
\r
1021 for (index = 0; index < mainchain.bonds.size(); index++)
\r
1023 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
1024 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
1026 if (highlightBond1 != null)
\r
1028 highlightBond1.at2.isSelected = false;
\r
1031 if (highlightBond2 != null)
\r
1033 highlightBond2.at1.isSelected = false;
\r
1036 highlightBond1 = null;
\r
1037 highlightBond2 = null;
\r
1041 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
1042 highlightBond1.at2.isSelected = true;
\r
1045 if (index != mainchain.bonds.size())
\r
1047 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
1048 highlightBond2.at1.isSelected = true;
\r
1055 redrawneeded = true;
\r
1059 public void setAllchainsVisible(boolean b)
\r
1061 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
1063 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
1064 chain.isVisible = b;
\r
1066 mainchain.isVisible = true;
\r
1072 //////////////////////////////////
\r
1073 ///StructureListener
\r
1074 public String getPdbFile()
\r
1080 String lastMessage;
\r
1081 public void mouseOverStructure(int pdbResNum, String chain)
\r
1083 if (lastMessage == null || !lastMessage.equals(pdbResNum+chain))
\r
1084 ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile());
\r
1086 lastMessage = pdbResNum+chain;
\r
1089 StringBuffer resetLastRes = new StringBuffer();
\r
1090 StringBuffer eval = new StringBuffer();
\r
1092 public void highlightAtom(int atomIndex, int pdbResNum, String chain, String pdbfile)
\r
1094 if (!seqColoursReady)
\r
1099 if (highlightRes != null
\r
1100 && highlightRes.contains( (atomIndex - 1) + ""))
\r
1107 for (index = 0; index < mainchain.bonds.size(); index++)
\r
1109 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
1110 if (tmpBond.at1.atomIndex == atomIndex)
\r
1112 if (highlightBond1 != null)
\r
1114 highlightBond1.at2.isSelected = false;
\r
1117 if (highlightBond2 != null)
\r
1119 highlightBond2.at1.isSelected = false;
\r
1122 highlightBond1 = null;
\r
1123 highlightBond2 = null;
\r
1127 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
1128 highlightBond1.at2.isSelected = true;
\r
1131 if (index != mainchain.bonds.size())
\r
1133 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
1134 highlightBond2.at1.isSelected = true;
\r
1141 redrawneeded = true;
\r
1145 public void updateColours(Object source)
\r
1147 AlignmentPanel ap = (AlignmentPanel) source;
\r
1148 colourBySequence(ap.getSequenceRenderer(),
\r
1149 ap.av.getShowSequenceFeatures() ?
\r
1150 ap.getFeatureRenderer() : null);
\r
1151 redrawneeded = true;
\r