2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 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
21 import jalview.analysis.AlignSeq;
\r
23 import jalview.datamodel.*;
\r
25 // JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug
\r
27 import java.awt.event.*;
\r
35 public class AppletPDBCanvas extends Panel implements MouseListener, MouseMotionListener
\r
38 MCMatrix idmat = new MCMatrix(3, 3);
\r
39 MCMatrix objmat = new MCMatrix(3, 3);
\r
40 boolean redrawneeded = true;
\r
50 float[] centre = new float[3];
\r
51 float[] width = new float[3];
\r
56 boolean bysequence = true;
\r
57 boolean depthcue = true;
\r
58 boolean wire = false;
\r
59 boolean bymolecule = false;
\r
60 boolean zbuffer = true;
\r
68 Font font = new Font("Helvetica", Font.PLAIN, 10);
\r
69 jalview.appletgui.SeqCanvas seqcanvas;
\r
70 public Sequence 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
80 public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq)
\r
82 this.seqcanvas = seqcanvas;
\r
83 this.sequence = seq;
\r
85 seqcanvas.setPDBCanvas(this);
\r
86 addKeyListener(new KeyAdapter()
\r
89 public void keyPressed(KeyEvent evt)
\r
97 public void setPDBFile(PDBfile pdb)
\r
105 AlignSeq maxAlignseq = null;;
\r
107 for (int i = 0; i < pdb.chains.size(); i++)
\r
110 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());
\r
111 mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
\r
113 // Now lets compare the sequences to get
\r
114 // the start and end points.
\r
115 // Align the sequence to the pdb
\r
116 AlignSeq as = new AlignSeq(sequence,
\r
117 ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
\r
118 as.calcScoreMatrix();
\r
119 as.traceAlignment();
\r
120 PrintStream ps = new PrintStream(System.out)
\r
122 public void print(String x) {
\r
123 mappingDetails.append(x);
\r
125 public void println()
\r
127 mappingDetails.append("\n");
\r
131 as.printAlignment(ps);
\r
133 if (as.maxscore > max) {
\r
137 pdbstart = as.seq2start;
\r
138 pdbend = as.seq2end;
\r
139 seqstart = as.seq1start + sequence.getStart()-1;
\r
140 seqend = as.seq1end + sequence.getEnd()-1;
\r
144 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
145 mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
\r
148 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
150 mainchain.pdbstart = pdbstart;
\r
151 mainchain.pdbend = pdbend;
\r
152 mainchain.seqstart = seqstart;
\r
153 mainchain.seqend = seqend;
\r
154 mainchain.isVisible = true;
\r
155 mainchain.makeExactMapping(maxAlignseq, sequence);
\r
158 this.prefsize = new Dimension(getSize().width, getSize().height);
\r
160 //Initialize the matrices to identity
\r
161 for (int i = 0; i < 3; i++) {
\r
162 for (int j = 0; j < 3; j++) {
\r
164 idmat.addElement(i, j, 0);
\r
165 objmat.addElement(i, j, 0);
\r
167 idmat.addElement(i, j, 1);
\r
168 objmat.addElement(i, j, 1);
\r
173 addMouseMotionListener(this);
\r
174 addMouseListener(this);
\r
182 scale = findScale();
\r
186 Vector visiblebonds;
\r
189 // Sort the bonds by z coord
\r
190 visiblebonds = new Vector();
\r
192 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
194 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
196 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
198 for (int i = 0; i < tmp.size(); i++)
\r
200 visiblebonds.addElement(tmp.elementAt(i));
\r
204 updateSeqColours();
\r
205 redrawneeded = true;
\r
210 public void findWidth() {
\r
211 float[] max = new float[3];
\r
212 float[] min = new float[3];
\r
214 max[0] = (float) -1e30;
\r
215 max[1] = (float) -1e30;
\r
216 max[2] = (float) -1e30;
\r
218 min[0] = (float) 1e30;
\r
219 min[1] = (float) 1e30;
\r
220 min[2] = (float) 1e30;
\r
222 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
223 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
224 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
226 for (int i = 0; i < bonds.size(); i++) {
\r
227 Bond tmp = (Bond) bonds.elementAt(i);
\r
229 if (tmp.start[0] >= max[0]) {
\r
230 max[0] = tmp.start[0];
\r
233 if (tmp.start[1] >= max[1]) {
\r
234 max[1] = tmp.start[1];
\r
237 if (tmp.start[2] >= max[2]) {
\r
238 max[2] = tmp.start[2];
\r
241 if (tmp.start[0] <= min[0]) {
\r
242 min[0] = tmp.start[0];
\r
245 if (tmp.start[1] <= min[1]) {
\r
246 min[1] = tmp.start[1];
\r
249 if (tmp.start[2] <= min[2]) {
\r
250 min[2] = tmp.start[2];
\r
253 if (tmp.end[0] >= max[0]) {
\r
254 max[0] = tmp.end[0];
\r
257 if (tmp.end[1] >= max[1]) {
\r
258 max[1] = tmp.end[1];
\r
261 if (tmp.end[2] >= max[2]) {
\r
262 max[2] = tmp.end[2];
\r
265 if (tmp.end[0] <= min[0]) {
\r
266 min[0] = tmp.end[0];
\r
269 if (tmp.end[1] <= min[1]) {
\r
270 min[1] = tmp.end[1];
\r
273 if (tmp.end[2] <= min[2]) {
\r
274 min[2] = tmp.end[2];
\r
280 width[0] = (float) Math.abs(max[0] - min[0]);
\r
281 width[1] = (float) Math.abs(max[1] - min[1]);
\r
282 width[2] = (float) Math.abs(max[2] - min[2]);
\r
284 maxwidth = width[0];
\r
286 if (width[1] > width[0]) {
\r
287 maxwidth = width[1];
\r
290 if (width[2] > width[1]) {
\r
291 maxwidth = width[2];
\r
294 // System.out.println("Maxwidth = " + maxwidth);
\r
297 public float findScale() {
\r
302 if (getSize().width != 0) {
\r
303 width = getSize().width;
\r
304 height = getSize().height;
\r
306 width = prefsize.width;
\r
307 height = prefsize.height;
\r
310 if (width < height) {
\r
316 return (float) (dim / (1.5d * maxwidth));
\r
319 public void findCentre() {
\r
326 //Find centre coordinate
\r
327 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
328 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
329 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
331 bsize += bonds.size();
\r
333 for (int i = 0; i < bonds.size(); i++) {
\r
334 xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
\r
335 ((Bond) bonds.elementAt(i)).end[0];
\r
337 ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
\r
338 ((Bond) bonds.elementAt(i)).end[1];
\r
340 ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
\r
341 ((Bond) bonds.elementAt(i)).end[2];
\r
346 centre[0] = xtot / (2 * (float) bsize);
\r
347 centre[1] = ytot / (2 * (float) bsize);
\r
348 centre[2] = ztot / (2 * (float) bsize);
\r
351 public void paint(Graphics g)
\r
356 g.setColor(Color.white);
\r
357 g.fillRect(0,0,getSize().width, getSize().height);
\r
358 g.setColor(Color.black);
\r
359 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
360 g.drawString("Error loading PDB data!!", 50, getSize().height/2);
\r
363 else if(visiblebonds==null)
\r
365 g.setColor(Color.black);
\r
366 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
367 g.drawString("Fetching PDB data...", 50, getSize().height/2);
\r
373 //Only create the image at the beginning -
\r
374 //this saves much memory usage
\r
375 if ((img == null) || (prefsize.width != getSize().width) ||
\r
376 (prefsize.height != getSize().height)) {
\r
378 try{ prefsize.width = getSize().width;
\r
379 prefsize.height = getSize().height;
\r
381 scale = findScale();
\r
382 img = createImage(prefsize.width, prefsize.height);
\r
383 ig = img.getGraphics();
\r
385 redrawneeded = true;
\r
386 }catch(Exception ex)
\r
388 ex.printStackTrace();
\r
395 drawAll(ig, prefsize.width, prefsize.height);
\r
396 redrawneeded = false;
\r
398 if(appletToolTip!=null)
\r
400 ig.setColor(Color.red);
\r
401 ig.drawString(appletToolTip, toolx, tooly);
\r
404 g.drawImage(img, 0, 0, this);
\r
409 public void drawAll(Graphics g, int width, int height)
\r
411 ig.setColor(Color.black);
\r
412 ig.fillRect(0, 0, width, height);
\r
418 public void updateSeqColours()
\r
425 if(bysequence && pdb!=null)
\r
427 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
429 colourBySequence((PDBChain) pdb.chains.elementAt(ii));
\r
438 int findTrueIndex(int pos)
\r
440 // returns the alignment position for a residue
\r
441 int j = sequence.getStart();
\r
444 while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
\r
446 if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
\r
457 if ( (j == sequence.getEnd()) && (j < pos))
\r
459 return sequence.getEnd() + 1;
\r
468 // This method has been taken out of PDBChain to allow
\r
469 // Applet and Application specific sequence renderers to be used
\r
470 void colourBySequence(PDBChain chain)
\r
472 for (int i = 0; i < chain.bonds.size(); i++)
\r
474 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
475 tmp.startCol = Color.lightGray;
\r
476 tmp.endCol = Color.lightGray;
\r
477 if(chain!=mainchain)
\r
480 if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
481 (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
\r
484 int index = findTrueIndex(tmp.at1.alignmentMapping);
\r
485 //sequence.findIndex(tmp.at1.alignmentMapping);
\r
488 tmp.startCol = seqcanvas.getSequenceRenderer().
\r
489 getResidueBoxColour( sequence, index);
\r
491 // tmp.startCol = seqcanvas.getFeatureRenderer().
\r
492 // findFeatureColour(tmp.startCol, sequence, index);
\r
496 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
497 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
500 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
501 getResidueBoxColour( sequence, index);
\r
502 // tmp.endCol = seqcanvas.getFeatureRenderer().
\r
503 // findFeatureColour(tmp.endCol, sequence, index);
\r
509 public void drawScene(Graphics g)
\r
513 Zsort.Zsort(visiblebonds);
\r
518 for (int i = 0; i < visiblebonds.size(); i++)
\r
520 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
523 xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
524 (getSize().width / 2));
\r
525 ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
526 (getSize().height / 2));
\r
528 xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
\r
529 (getSize().width / 2));
\r
530 yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
\r
531 (getSize().height / 2));
\r
533 xmid = (xend + xstart) / 2;
\r
534 ymid = (yend + ystart) / 2;
\r
536 if (depthcue && !bymolecule)
\r
538 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
539 g.setColor(tmpBond.startCol.darker().darker());
\r
540 drawLine(g, xstart, ystart, xmid, ymid);
\r
542 g.setColor(tmpBond.endCol.darker().darker());
\r
543 drawLine(g, xmid, ymid, xend, yend);
\r
544 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
545 g.setColor(tmpBond.startCol.darker());
\r
546 drawLine(g, xstart, ystart, xmid, ymid);
\r
548 g.setColor(tmpBond.endCol.darker());
\r
549 drawLine(g, xmid, ymid, xend, yend);
\r
551 g.setColor(tmpBond.startCol);
\r
552 drawLine(g, xstart, ystart, xmid, ymid);
\r
554 g.setColor(tmpBond.endCol);
\r
555 drawLine(g, xmid, ymid, xend, yend);
\r
558 } else if (depthcue && bymolecule) {
\r
559 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
560 g.setColor(Color.green.darker().darker());
\r
561 drawLine(g, xstart, ystart, xend, yend);
\r
562 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
563 g.setColor(Color.green.darker());
\r
564 drawLine(g, xstart, ystart, xend, yend);
\r
566 g.setColor(Color.green);
\r
567 drawLine(g, xstart, ystart, xend, yend);
\r
569 } else if (!depthcue && !bymolecule) {
\r
570 g.setColor(tmpBond.startCol);
\r
571 drawLine(g, xstart, ystart, xmid, ymid);
\r
572 g.setColor(tmpBond.endCol);
\r
573 drawLine(g, xmid, ymid, xend, yend);
\r
575 drawLine(g, xstart, ystart, xend, yend);
\r
578 if(highlightBond1!=null && highlightBond1==tmpBond)
\r
580 g.setColor(Color.white);
\r
581 drawLine(g, xmid, ymid, xend, yend);
\r
584 if(highlightBond2!=null && highlightBond2==tmpBond)
\r
586 g.setColor(Color.white);
\r
587 drawLine(g, xstart, ystart, xmid, ymid);
\r
593 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
595 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
596 g.drawLine(x1, y1, x2, y2);
\r
597 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
598 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
600 g.setColor(g.getColor().brighter());
\r
601 g.drawLine(x1, y1, x2, y2);
\r
602 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
603 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
606 g.drawLine(x1, y1, x2, y2);
\r
610 public Dimension minimumsize() {
\r
614 public Dimension preferredsize() {
\r
618 public void doKeyPressed(KeyEvent evt)
\r
620 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
622 scale = (float) (scale * 1.1);
\r
623 redrawneeded = true;
\r
626 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
628 scale = (float) (scale * 0.9);
\r
629 redrawneeded = true;
\r
634 public void mousePressed(MouseEvent e) {
\r
636 Atom fatom = findAtom(e.getX(), e.getY());
\r
639 fatom.isSelected = !fatom.isSelected;
\r
641 redrawneeded = true;
\r
643 if (foundchain != -1)
\r
645 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
646 if (chain == mainchain)
\r
648 if (fatom.alignmentMapping != -1)
\r
650 if (highlightRes == null)
\r
651 highlightRes = new Vector();
\r
653 if (highlightRes.contains(fatom.alignmentMapping+"" + ""))
\r
654 highlightRes.removeElement(fatom.alignmentMapping + "");
\r
656 highlightRes.addElement(fatom.alignmentMapping + "");
\r
669 public void mouseMoved(MouseEvent e) {
\r
671 if(highlightBond1!=null)
\r
673 highlightBond1.at2.isSelected = false;
\r
674 highlightBond2.at1.isSelected = false;
\r
675 highlightBond1 = null;
\r
676 highlightBond2 = null;
\r
679 Atom fatom = findAtom(e.getX(), e.getY());
\r
681 PDBChain chain = null;
\r
684 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
685 if(chain == mainchain)
\r
687 highlightSeqcanvas( fatom.alignmentMapping );
\r
691 if (fatom != null) {
\r
695 appletToolTip = chain.id+":"+ fatom.resNumber+" "+ fatom.resName;
\r
696 redrawneeded = true;
\r
699 highlightSeqcanvas( -1);
\r
700 appletToolTip = null;
\r
701 redrawneeded = true;
\r
707 void highlightSeqcanvas(int pos)
\r
709 int index = seqcanvas.getViewport().getAlignment().findIndex(sequence);
\r
711 int size = pos==-1?0:3;
\r
713 if(highlightRes!=null)
\r
714 size += highlightRes.size()*3;
\r
716 int [] array = new int[size];
\r
718 if(highlightRes!=null)
\r
720 for (i = 0; i < highlightRes.size(); i++)
\r
722 int a = Integer.parseInt(highlightRes.elementAt(
\r
724 array[i * 3] = index;
\r
725 array[ (i * 3) + 1] = a;
\r
726 array[ (i * 3) + 2] = a;
\r
732 array[i * 3] = index;
\r
733 array[i * 3 + 1] = pos+1;
\r
734 array[i * 3 + 2] = pos+1;
\r
737 seqcanvas.highlightSearchResults(array);
\r
741 public void mouseClicked(MouseEvent e) {
\r
744 public void mouseEntered(MouseEvent e) {
\r
747 public void mouseExited(MouseEvent e) {
\r
750 public void mouseDragged(MouseEvent evt) {
\r
751 int x = evt.getX();
\r
752 int y = evt.getY();
\r
756 MCMatrix objmat = new MCMatrix(3, 3);
\r
757 objmat.setIdentity();
\r
759 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
760 objmat.rotatez((float) ((mx - omx)));
\r
762 objmat.rotatex((float) ((my - omy)));
\r
763 objmat.rotatey((float) ((omx - mx)));
\r
767 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
768 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
770 for (int i = 0; i < bonds.size(); i++) {
\r
771 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
773 //Translate the bond so the centre is 0,0,0
\r
774 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
776 //Now apply the rotation matrix
\r
777 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
778 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
780 //Now translate back again
\r
781 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
792 redrawneeded = true;
\r
797 public void mouseReleased(MouseEvent evt) {
\r
802 void drawLabels(Graphics g) {
\r
804 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
806 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
808 if (chain.isVisible)
\r
810 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
812 for (int i = 0; i < bonds.size(); i++)
\r
814 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
816 if (tmpBond.at1.isSelected)
\r
818 labelAtom(g, tmpBond, 1);
\r
821 if (tmpBond.at2.isSelected)
\r
824 labelAtom(g, tmpBond, 2);
\r
831 public void labelAtom(Graphics g, Bond b, int n) {
\r
835 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
836 (getSize().width / 2));
\r
837 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
838 (getSize().height / 2));
\r
840 g.setColor(Color.red);
\r
841 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
845 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
846 (getSize().width / 2));
\r
847 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
848 (getSize().height / 2));
\r
850 g.setColor(Color.red);
\r
851 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
855 int foundchain = -1;
\r
856 public Atom findAtom(int x, int y) {
\r
861 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
863 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
867 if (chain.isVisible)
\r
869 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
871 for (int i = 0; i < bonds.size(); i++)
\r
873 tmpBond = (Bond) bonds.elementAt(i);
\r
875 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
876 (getSize().width / 2));
\r
878 if (Math.abs(truex - x) <= 2)
\r
880 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
881 (getSize().height / 2));
\r
883 if (Math.abs(truey - y) <= 2)
\r
885 fatom = tmpBond.at1;
\r
892 // Still here? Maybe its the last bond
\r
894 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
895 (getSize().width / 2));
\r
897 if (Math.abs(truex - x) <= 2)
\r
899 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
900 (getSize().height / 2));
\r
902 if (Math.abs(truey - y) <= 2)
\r
904 fatom = tmpBond.at2;
\r
912 if (fatom != null) //)&& chain.ds != null)
\r
914 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
921 public void update(Graphics g)
\r
926 public void highlightRes(int ii)
\r
929 if (highlightRes != null
\r
930 && highlightRes.contains((ii-1) + ""))
\r
937 for(index=0; index<mainchain.bonds.size(); index++)
\r
939 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
940 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
942 if (highlightBond1 != null)
\r
943 highlightBond1.at2.isSelected = false;
\r
945 if (highlightBond2 != null)
\r
946 highlightBond2.at1.isSelected = false;
\r
948 highlightBond1 = null;
\r
949 highlightBond2 = null;
\r
953 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
954 highlightBond1.at2.isSelected = true;
\r
957 if (index != mainchain.bonds.size())
\r
959 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
960 highlightBond2.at1.isSelected = true;
\r
967 redrawneeded = true;
\r
972 public void setAllchainsVisible(boolean b)
\r
974 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
976 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
977 chain.isVisible = b;
\r
979 mainchain.isVisible = true;
\r