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
79 boolean seqColoursReady = false;
\r
81 public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq)
\r
83 this.seqcanvas = seqcanvas;
\r
84 this.sequence = seq;
\r
86 seqcanvas.setPDBCanvas(this);
\r
87 addKeyListener(new KeyAdapter()
\r
90 public void keyPressed(KeyEvent evt)
\r
98 public void setPDBFile(PDBfile pdb)
\r
106 AlignSeq maxAlignseq = null;;
\r
108 for (int i = 0; i < pdb.chains.size(); i++)
\r
111 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());
\r
112 mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
\r
114 // Now lets compare the sequences to get
\r
115 // the start and end points.
\r
116 // Align the sequence to the pdb
\r
117 AlignSeq as = new AlignSeq(sequence,
\r
118 ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
\r
119 as.calcScoreMatrix();
\r
120 as.traceAlignment();
\r
121 PrintStream ps = new PrintStream(System.out)
\r
123 public void print(String x) {
\r
124 mappingDetails.append(x);
\r
126 public void println()
\r
128 mappingDetails.append("\n");
\r
132 as.printAlignment(ps);
\r
134 if (as.maxscore > max) {
\r
138 pdbstart = as.seq2start;
\r
139 pdbend = as.seq2end;
\r
140 seqstart = as.seq1start + sequence.getStart()-1;
\r
141 seqend = as.seq1end + sequence.getEnd()-1;
\r
145 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
146 mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
\r
149 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
151 mainchain.pdbstart = pdbstart;
\r
152 mainchain.pdbend = pdbend;
\r
153 mainchain.seqstart = seqstart;
\r
154 mainchain.seqend = seqend;
\r
155 mainchain.isVisible = true;
\r
156 mainchain.makeExactMapping(maxAlignseq, sequence);
\r
159 this.prefsize = new Dimension(getSize().width, getSize().height);
\r
161 //Initialize the matrices to identity
\r
162 for (int i = 0; i < 3; i++) {
\r
163 for (int j = 0; j < 3; j++) {
\r
165 idmat.addElement(i, j, 0);
\r
166 objmat.addElement(i, j, 0);
\r
168 idmat.addElement(i, j, 1);
\r
169 objmat.addElement(i, j, 1);
\r
174 addMouseMotionListener(this);
\r
175 addMouseListener(this);
\r
183 scale = findScale();
\r
187 Vector visiblebonds;
\r
190 seqColoursReady = false;
\r
191 // Sort the bonds by z coord
\r
192 visiblebonds = new Vector();
\r
194 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
196 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
198 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
200 for (int i = 0; i < tmp.size(); i++)
\r
202 visiblebonds.addElement(tmp.elementAt(i));
\r
206 updateSeqColours();
\r
207 seqColoursReady = true;
\r
208 redrawneeded = true;
\r
213 public void findWidth() {
\r
214 float[] max = new float[3];
\r
215 float[] min = new float[3];
\r
217 max[0] = (float) -1e30;
\r
218 max[1] = (float) -1e30;
\r
219 max[2] = (float) -1e30;
\r
221 min[0] = (float) 1e30;
\r
222 min[1] = (float) 1e30;
\r
223 min[2] = (float) 1e30;
\r
225 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
226 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
227 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
229 for (int i = 0; i < bonds.size(); i++) {
\r
230 Bond tmp = (Bond) bonds.elementAt(i);
\r
232 if (tmp.start[0] >= max[0]) {
\r
233 max[0] = tmp.start[0];
\r
236 if (tmp.start[1] >= max[1]) {
\r
237 max[1] = tmp.start[1];
\r
240 if (tmp.start[2] >= max[2]) {
\r
241 max[2] = tmp.start[2];
\r
244 if (tmp.start[0] <= min[0]) {
\r
245 min[0] = tmp.start[0];
\r
248 if (tmp.start[1] <= min[1]) {
\r
249 min[1] = tmp.start[1];
\r
252 if (tmp.start[2] <= min[2]) {
\r
253 min[2] = tmp.start[2];
\r
256 if (tmp.end[0] >= max[0]) {
\r
257 max[0] = tmp.end[0];
\r
260 if (tmp.end[1] >= max[1]) {
\r
261 max[1] = tmp.end[1];
\r
264 if (tmp.end[2] >= max[2]) {
\r
265 max[2] = tmp.end[2];
\r
268 if (tmp.end[0] <= min[0]) {
\r
269 min[0] = tmp.end[0];
\r
272 if (tmp.end[1] <= min[1]) {
\r
273 min[1] = tmp.end[1];
\r
276 if (tmp.end[2] <= min[2]) {
\r
277 min[2] = tmp.end[2];
\r
283 width[0] = (float) Math.abs(max[0] - min[0]);
\r
284 width[1] = (float) Math.abs(max[1] - min[1]);
\r
285 width[2] = (float) Math.abs(max[2] - min[2]);
\r
287 maxwidth = width[0];
\r
289 if (width[1] > width[0]) {
\r
290 maxwidth = width[1];
\r
293 if (width[2] > width[1]) {
\r
294 maxwidth = width[2];
\r
297 // System.out.println("Maxwidth = " + maxwidth);
\r
300 public float findScale() {
\r
305 if (getSize().width != 0) {
\r
306 width = getSize().width;
\r
307 height = getSize().height;
\r
309 width = prefsize.width;
\r
310 height = prefsize.height;
\r
313 if (width < height) {
\r
319 return (float) (dim / (1.5d * maxwidth));
\r
322 public void findCentre() {
\r
329 //Find centre coordinate
\r
330 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
331 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
332 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
334 bsize += bonds.size();
\r
336 for (int i = 0; i < bonds.size(); i++) {
\r
337 xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
\r
338 ((Bond) bonds.elementAt(i)).end[0];
\r
340 ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
\r
341 ((Bond) bonds.elementAt(i)).end[1];
\r
343 ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
\r
344 ((Bond) bonds.elementAt(i)).end[2];
\r
349 centre[0] = xtot / (2 * (float) bsize);
\r
350 centre[1] = ytot / (2 * (float) bsize);
\r
351 centre[2] = ztot / (2 * (float) bsize);
\r
354 public void paint(Graphics g)
\r
359 g.setColor(Color.white);
\r
360 g.fillRect(0,0,getSize().width, getSize().height);
\r
361 g.setColor(Color.black);
\r
362 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
363 g.drawString("Error loading PDB data!!", 50, getSize().height/2);
\r
366 else if( !seqColoursReady )
\r
368 g.setColor(Color.black);
\r
369 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
370 g.drawString("Fetching PDB data...", 50, getSize().height/2);
\r
376 //Only create the image at the beginning -
\r
377 //this saves much memory usage
\r
378 if ((img == null) || (prefsize.width != getSize().width) ||
\r
379 (prefsize.height != getSize().height)) {
\r
381 try{ prefsize.width = getSize().width;
\r
382 prefsize.height = getSize().height;
\r
384 scale = findScale();
\r
385 img = createImage(prefsize.width, prefsize.height);
\r
386 ig = img.getGraphics();
\r
388 redrawneeded = true;
\r
389 }catch(Exception ex)
\r
391 ex.printStackTrace();
\r
398 drawAll(ig, prefsize.width, prefsize.height);
\r
399 redrawneeded = false;
\r
401 if(appletToolTip!=null)
\r
403 ig.setColor(Color.red);
\r
404 ig.drawString(appletToolTip, toolx, tooly);
\r
407 g.drawImage(img, 0, 0, this);
\r
412 public void drawAll(Graphics g, int width, int height)
\r
414 ig.setColor(Color.black);
\r
415 ig.fillRect(0, 0, width, height);
\r
421 public void updateSeqColours()
\r
428 if(bysequence && pdb!=null)
\r
430 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
432 colourBySequence((PDBChain) pdb.chains.elementAt(ii));
\r
441 int findTrueIndex(int pos)
\r
443 // returns the alignment position for a residue
\r
444 int j = sequence.getStart();
\r
447 while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
\r
449 if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
\r
460 if ( (j == sequence.getEnd()) && (j < pos))
\r
462 return sequence.getEnd() + 1;
\r
471 // This method has been taken out of PDBChain to allow
\r
472 // Applet and Application specific sequence renderers to be used
\r
473 void colourBySequence(PDBChain chain)
\r
475 for (int i = 0; i < chain.bonds.size(); i++)
\r
477 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
478 tmp.startCol = Color.lightGray;
\r
479 tmp.endCol = Color.lightGray;
\r
480 if(chain!=mainchain)
\r
483 if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
484 (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
\r
487 int index = findTrueIndex(tmp.at1.alignmentMapping);
\r
488 //sequence.findIndex(tmp.at1.alignmentMapping);
\r
491 tmp.startCol = seqcanvas.getSequenceRenderer().
\r
492 getResidueBoxColour( sequence, index);
\r
494 // tmp.startCol = seqcanvas.getFeatureRenderer().
\r
495 // findFeatureColour(tmp.startCol, sequence, index);
\r
499 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
500 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
503 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
504 getResidueBoxColour( sequence, index);
\r
505 // tmp.endCol = seqcanvas.getFeatureRenderer().
\r
506 // findFeatureColour(tmp.endCol, sequence, index);
\r
512 public void drawScene(Graphics g)
\r
516 Zsort.Zsort(visiblebonds);
\r
521 for (int i = 0; i < visiblebonds.size(); i++)
\r
523 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
526 xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
527 (getSize().width / 2));
\r
528 ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
529 (getSize().height / 2));
\r
531 xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
\r
532 (getSize().width / 2));
\r
533 yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
\r
534 (getSize().height / 2));
\r
536 xmid = (xend + xstart) / 2;
\r
537 ymid = (yend + ystart) / 2;
\r
539 if (depthcue && !bymolecule)
\r
541 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
542 g.setColor(tmpBond.startCol.darker().darker());
\r
543 drawLine(g, xstart, ystart, xmid, ymid);
\r
545 g.setColor(tmpBond.endCol.darker().darker());
\r
546 drawLine(g, xmid, ymid, xend, yend);
\r
547 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
548 g.setColor(tmpBond.startCol.darker());
\r
549 drawLine(g, xstart, ystart, xmid, ymid);
\r
551 g.setColor(tmpBond.endCol.darker());
\r
552 drawLine(g, xmid, ymid, xend, yend);
\r
554 g.setColor(tmpBond.startCol);
\r
555 drawLine(g, xstart, ystart, xmid, ymid);
\r
557 g.setColor(tmpBond.endCol);
\r
558 drawLine(g, xmid, ymid, xend, yend);
\r
561 } else if (depthcue && bymolecule) {
\r
562 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
563 g.setColor(Color.green.darker().darker());
\r
564 drawLine(g, xstart, ystart, xend, yend);
\r
565 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
566 g.setColor(Color.green.darker());
\r
567 drawLine(g, xstart, ystart, xend, yend);
\r
569 g.setColor(Color.green);
\r
570 drawLine(g, xstart, ystart, xend, yend);
\r
572 } else if (!depthcue && !bymolecule) {
\r
573 g.setColor(tmpBond.startCol);
\r
574 drawLine(g, xstart, ystart, xmid, ymid);
\r
575 g.setColor(tmpBond.endCol);
\r
576 drawLine(g, xmid, ymid, xend, yend);
\r
578 drawLine(g, xstart, ystart, xend, yend);
\r
581 if(highlightBond1!=null && highlightBond1==tmpBond)
\r
583 g.setColor(Color.white);
\r
584 drawLine(g, xmid, ymid, xend, yend);
\r
587 if(highlightBond2!=null && highlightBond2==tmpBond)
\r
589 g.setColor(Color.white);
\r
590 drawLine(g, xstart, ystart, xmid, ymid);
\r
596 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
598 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
599 g.drawLine(x1, y1, x2, y2);
\r
600 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
601 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
603 g.setColor(g.getColor().brighter());
\r
604 g.drawLine(x1, y1, x2, y2);
\r
605 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
606 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
609 g.drawLine(x1, y1, x2, y2);
\r
613 public Dimension minimumsize() {
\r
617 public Dimension preferredsize() {
\r
621 public void doKeyPressed(KeyEvent evt)
\r
623 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
625 scale = (float) (scale * 1.1);
\r
626 redrawneeded = true;
\r
629 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
631 scale = (float) (scale * 0.9);
\r
632 redrawneeded = true;
\r
637 public void mousePressed(MouseEvent e) {
\r
639 Atom fatom = findAtom(e.getX(), e.getY());
\r
642 fatom.isSelected = !fatom.isSelected;
\r
644 redrawneeded = true;
\r
646 if (foundchain != -1)
\r
648 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
649 if (chain == mainchain)
\r
651 if (fatom.alignmentMapping != -1)
\r
653 if (highlightRes == null)
\r
654 highlightRes = new Vector();
\r
656 if (highlightRes.contains(fatom.alignmentMapping+"" + ""))
\r
657 highlightRes.removeElement(fatom.alignmentMapping + "");
\r
659 highlightRes.addElement(fatom.alignmentMapping + "");
\r
672 public void mouseMoved(MouseEvent e) {
\r
674 if(highlightBond1!=null)
\r
676 highlightBond1.at2.isSelected = false;
\r
677 highlightBond2.at1.isSelected = false;
\r
678 highlightBond1 = null;
\r
679 highlightBond2 = null;
\r
682 Atom fatom = findAtom(e.getX(), e.getY());
\r
684 PDBChain chain = null;
\r
687 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
688 if(chain == mainchain)
\r
690 highlightSeqcanvas( fatom.alignmentMapping );
\r
694 if (fatom != null) {
\r
698 appletToolTip = chain.id+":"+ fatom.resNumber+" "+ fatom.resName;
\r
699 redrawneeded = true;
\r
702 highlightSeqcanvas( -1);
\r
703 appletToolTip = null;
\r
704 redrawneeded = true;
\r
710 void highlightSeqcanvas(int pos)
\r
712 int index = seqcanvas.getViewport().getAlignment().findIndex(sequence);
\r
714 int size = pos==-1?0:3;
\r
716 if(highlightRes!=null)
\r
717 size += highlightRes.size()*3;
\r
719 int [] array = new int[size];
\r
721 if(highlightRes!=null)
\r
723 for (i = 0; i < highlightRes.size(); i++)
\r
725 int a = Integer.parseInt(highlightRes.elementAt(
\r
727 array[i * 3] = index;
\r
728 array[ (i * 3) + 1] = a;
\r
729 array[ (i * 3) + 2] = a;
\r
735 array[i * 3] = index;
\r
736 array[i * 3 + 1] = pos+1;
\r
737 array[i * 3 + 2] = pos+1;
\r
740 seqcanvas.highlightSearchResults(array);
\r
744 public void mouseClicked(MouseEvent e) {
\r
747 public void mouseEntered(MouseEvent e) {
\r
750 public void mouseExited(MouseEvent e) {
\r
753 public void mouseDragged(MouseEvent evt) {
\r
754 int x = evt.getX();
\r
755 int y = evt.getY();
\r
759 MCMatrix objmat = new MCMatrix(3, 3);
\r
760 objmat.setIdentity();
\r
762 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
763 objmat.rotatez((float) ((mx - omx)));
\r
765 objmat.rotatex((float) ((my - omy)));
\r
766 objmat.rotatey((float) ((omx - mx)));
\r
770 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
771 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
773 for (int i = 0; i < bonds.size(); i++) {
\r
774 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
776 //Translate the bond so the centre is 0,0,0
\r
777 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
779 //Now apply the rotation matrix
\r
780 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
781 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
783 //Now translate back again
\r
784 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
795 redrawneeded = true;
\r
800 public void mouseReleased(MouseEvent evt) {
\r
805 void drawLabels(Graphics g) {
\r
807 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
809 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
811 if (chain.isVisible)
\r
813 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
815 for (int i = 0; i < bonds.size(); i++)
\r
817 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
819 if (tmpBond.at1.isSelected)
\r
821 labelAtom(g, tmpBond, 1);
\r
824 if (tmpBond.at2.isSelected)
\r
827 labelAtom(g, tmpBond, 2);
\r
834 public void labelAtom(Graphics g, Bond b, int n) {
\r
838 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
839 (getSize().width / 2));
\r
840 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
841 (getSize().height / 2));
\r
843 g.setColor(Color.red);
\r
844 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
848 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
849 (getSize().width / 2));
\r
850 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
851 (getSize().height / 2));
\r
853 g.setColor(Color.red);
\r
854 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
858 int foundchain = -1;
\r
859 public Atom findAtom(int x, int y) {
\r
864 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
866 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
870 if (chain.isVisible)
\r
872 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
874 for (int i = 0; i < bonds.size(); i++)
\r
876 tmpBond = (Bond) bonds.elementAt(i);
\r
878 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
879 (getSize().width / 2));
\r
881 if (Math.abs(truex - x) <= 2)
\r
883 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
884 (getSize().height / 2));
\r
886 if (Math.abs(truey - y) <= 2)
\r
888 fatom = tmpBond.at1;
\r
895 // Still here? Maybe its the last bond
\r
897 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
898 (getSize().width / 2));
\r
900 if (Math.abs(truex - x) <= 2)
\r
902 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
903 (getSize().height / 2));
\r
905 if (Math.abs(truey - y) <= 2)
\r
907 fatom = tmpBond.at2;
\r
915 if (fatom != null) //)&& chain.ds != null)
\r
917 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
924 public void update(Graphics g)
\r
929 public void highlightRes(int ii)
\r
932 if (highlightRes != null
\r
933 && highlightRes.contains((ii-1) + ""))
\r
940 for(index=0; index<mainchain.bonds.size(); index++)
\r
942 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
943 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
945 if (highlightBond1 != null)
\r
946 highlightBond1.at2.isSelected = false;
\r
948 if (highlightBond2 != null)
\r
949 highlightBond2.at1.isSelected = false;
\r
951 highlightBond1 = null;
\r
952 highlightBond2 = null;
\r
956 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
957 highlightBond1.at2.isSelected = true;
\r
960 if (index != mainchain.bonds.size())
\r
962 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
963 highlightBond2.at1.isSelected = true;
\r
970 redrawneeded = true;
\r
975 public void setAllchainsVisible(boolean b)
\r
977 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
979 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
980 chain.isVisible = b;
\r
982 mainchain.isVisible = true;
\r