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
367 if( !seqColoursReady )
\r
369 g.setColor(Color.black);
\r
370 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
371 g.drawString("Fetching PDB data...", 50, getSize().height/2);
\r
377 //Only create the image at the beginning -
\r
378 //this saves much memory usage
\r
379 if ((img == null) || (prefsize.width != getSize().width) ||
\r
380 (prefsize.height != getSize().height)) {
\r
382 try{ prefsize.width = getSize().width;
\r
383 prefsize.height = getSize().height;
\r
385 scale = findScale();
\r
386 img = createImage(prefsize.width, prefsize.height);
\r
387 ig = img.getGraphics();
\r
389 redrawneeded = true;
\r
390 }catch(Exception ex)
\r
392 ex.printStackTrace();
\r
399 drawAll(ig, prefsize.width, prefsize.height);
\r
400 redrawneeded = false;
\r
402 if(appletToolTip!=null)
\r
404 ig.setColor(Color.red);
\r
405 ig.drawString(appletToolTip, toolx, tooly);
\r
408 g.drawImage(img, 0, 0, this);
\r
413 public void drawAll(Graphics g, int width, int height)
\r
415 ig.setColor(Color.black);
\r
416 ig.fillRect(0, 0, width, height);
\r
421 void setColours(jalview.schemes.ColourSchemeI cs)
\r
423 bysequence = false;
\r
424 pdb.setColours(cs);
\r
425 redrawneeded = true;
\r
428 public void updateSeqColours()
\r
435 if(bysequence && pdb!=null)
\r
437 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
439 colourBySequence((PDBChain) pdb.chains.elementAt(ii));
\r
448 int findTrueIndex(int pos)
\r
450 // returns the alignment position for a residue
\r
451 int j = sequence.getStart();
\r
454 while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
\r
456 if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
\r
467 if ( (j == sequence.getEnd()) && (j < pos))
\r
469 return sequence.getEnd() + 1;
\r
478 // This method has been taken out of PDBChain to allow
\r
479 // Applet and Application specific sequence renderers to be used
\r
480 void colourBySequence(PDBChain chain)
\r
482 for (int i = 0; i < chain.bonds.size(); i++)
\r
484 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
485 tmp.startCol = Color.lightGray;
\r
486 tmp.endCol = Color.lightGray;
\r
487 if(chain!=mainchain)
\r
490 if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
491 (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
\r
494 int index = findTrueIndex(tmp.at1.alignmentMapping);
\r
495 //sequence.findIndex(tmp.at1.alignmentMapping);
\r
498 tmp.startCol = seqcanvas.getSequenceRenderer().
\r
499 getResidueBoxColour( sequence, index);
\r
501 // tmp.startCol = seqcanvas.getFeatureRenderer().
\r
502 // findFeatureColour(tmp.startCol, sequence, index);
\r
506 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
507 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
510 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
511 getResidueBoxColour( sequence, index);
\r
512 // tmp.endCol = seqcanvas.getFeatureRenderer().
\r
513 // findFeatureColour(tmp.endCol, sequence, index);
\r
519 public void drawScene(Graphics g)
\r
523 Zsort.Zsort(visiblebonds);
\r
528 for (int i = 0; i < visiblebonds.size(); i++)
\r
530 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
533 xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
534 (getSize().width / 2));
\r
535 ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
536 (getSize().height / 2));
\r
538 xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
\r
539 (getSize().width / 2));
\r
540 yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
\r
541 (getSize().height / 2));
\r
543 xmid = (xend + xstart) / 2;
\r
544 ymid = (yend + ystart) / 2;
\r
546 if (depthcue && !bymolecule)
\r
548 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
549 g.setColor(tmpBond.startCol.darker().darker());
\r
550 drawLine(g, xstart, ystart, xmid, ymid);
\r
552 g.setColor(tmpBond.endCol.darker().darker());
\r
553 drawLine(g, xmid, ymid, xend, yend);
\r
554 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
555 g.setColor(tmpBond.startCol.darker());
\r
556 drawLine(g, xstart, ystart, xmid, ymid);
\r
558 g.setColor(tmpBond.endCol.darker());
\r
559 drawLine(g, xmid, ymid, xend, yend);
\r
561 g.setColor(tmpBond.startCol);
\r
562 drawLine(g, xstart, ystart, xmid, ymid);
\r
564 g.setColor(tmpBond.endCol);
\r
565 drawLine(g, xmid, ymid, xend, yend);
\r
568 } else if (depthcue && bymolecule) {
\r
569 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
570 g.setColor(Color.green.darker().darker());
\r
571 drawLine(g, xstart, ystart, xend, yend);
\r
572 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
573 g.setColor(Color.green.darker());
\r
574 drawLine(g, xstart, ystart, xend, yend);
\r
576 g.setColor(Color.green);
\r
577 drawLine(g, xstart, ystart, xend, yend);
\r
579 } else if (!depthcue && !bymolecule) {
\r
580 g.setColor(tmpBond.startCol);
\r
581 drawLine(g, xstart, ystart, xmid, ymid);
\r
582 g.setColor(tmpBond.endCol);
\r
583 drawLine(g, xmid, ymid, xend, yend);
\r
585 drawLine(g, xstart, ystart, xend, yend);
\r
588 if(highlightBond1!=null && highlightBond1==tmpBond)
\r
590 g.setColor(Color.white);
\r
591 drawLine(g, xmid, ymid, xend, yend);
\r
594 if(highlightBond2!=null && highlightBond2==tmpBond)
\r
596 g.setColor(Color.white);
\r
597 drawLine(g, xstart, ystart, xmid, ymid);
\r
603 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
605 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
606 g.drawLine(x1, y1, x2, y2);
\r
607 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
608 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
610 g.setColor(g.getColor().brighter());
\r
611 g.drawLine(x1, y1, x2, y2);
\r
612 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
613 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
616 g.drawLine(x1, y1, x2, y2);
\r
620 public Dimension minimumsize() {
\r
624 public Dimension preferredsize() {
\r
628 public void doKeyPressed(KeyEvent evt)
\r
630 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
632 scale = (float) (scale * 1.1);
\r
633 redrawneeded = true;
\r
636 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
638 scale = (float) (scale * 0.9);
\r
639 redrawneeded = true;
\r
644 public void mousePressed(MouseEvent e) {
\r
646 Atom fatom = findAtom(e.getX(), e.getY());
\r
649 fatom.isSelected = !fatom.isSelected;
\r
651 redrawneeded = true;
\r
653 if (foundchain != -1)
\r
655 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
656 if (chain == mainchain)
\r
658 if (fatom.alignmentMapping != -1)
\r
660 if (highlightRes == null)
\r
661 highlightRes = new Vector();
\r
663 if (highlightRes.contains(fatom.alignmentMapping+"" + ""))
\r
664 highlightRes.removeElement(fatom.alignmentMapping + "");
\r
666 highlightRes.addElement(fatom.alignmentMapping + "");
\r
679 public void mouseMoved(MouseEvent e) {
\r
681 if(highlightBond1!=null)
\r
683 highlightBond1.at2.isSelected = false;
\r
684 highlightBond2.at1.isSelected = false;
\r
685 highlightBond1 = null;
\r
686 highlightBond2 = null;
\r
689 Atom fatom = findAtom(e.getX(), e.getY());
\r
691 PDBChain chain = null;
\r
694 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
695 if(chain == mainchain)
\r
697 highlightSeqcanvas( fatom.alignmentMapping );
\r
701 if (fatom != null) {
\r
705 appletToolTip = chain.id+":"+ fatom.resNumber+" "+ fatom.resName;
\r
706 redrawneeded = true;
\r
709 highlightSeqcanvas( -1);
\r
710 appletToolTip = null;
\r
711 redrawneeded = true;
\r
717 void highlightSeqcanvas(int pos)
\r
719 int index = seqcanvas.getViewport().getAlignment().findIndex(sequence);
\r
721 int size = pos==-1?0:3;
\r
723 if(highlightRes!=null)
\r
724 size += highlightRes.size()*3;
\r
726 int [] array = new int[size];
\r
728 if(highlightRes!=null)
\r
730 for (i = 0; i < highlightRes.size(); i++)
\r
732 int a = Integer.parseInt(highlightRes.elementAt(
\r
734 array[i * 3] = index;
\r
735 array[ (i * 3) + 1] = a;
\r
736 array[ (i * 3) + 2] = a;
\r
742 array[i * 3] = index;
\r
743 array[i * 3 + 1] = pos+1;
\r
744 array[i * 3 + 2] = pos+1;
\r
747 seqcanvas.highlightSearchResults(array);
\r
751 public void mouseClicked(MouseEvent e) {
\r
754 public void mouseEntered(MouseEvent e) {
\r
757 public void mouseExited(MouseEvent e) {
\r
760 public void mouseDragged(MouseEvent evt) {
\r
761 int x = evt.getX();
\r
762 int y = evt.getY();
\r
766 MCMatrix objmat = new MCMatrix(3, 3);
\r
767 objmat.setIdentity();
\r
769 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
770 objmat.rotatez((float) ((mx - omx)));
\r
772 objmat.rotatex((float) ((my - omy)));
\r
773 objmat.rotatey((float) ((omx - mx)));
\r
777 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
778 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
780 for (int i = 0; i < bonds.size(); i++) {
\r
781 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
783 //Translate the bond so the centre is 0,0,0
\r
784 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
786 //Now apply the rotation matrix
\r
787 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
788 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
790 //Now translate back again
\r
791 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
802 redrawneeded = true;
\r
807 public void mouseReleased(MouseEvent evt) {
\r
812 void drawLabels(Graphics g) {
\r
814 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
816 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
818 if (chain.isVisible)
\r
820 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
822 for (int i = 0; i < bonds.size(); i++)
\r
824 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
826 if (tmpBond.at1.isSelected)
\r
828 labelAtom(g, tmpBond, 1);
\r
831 if (tmpBond.at2.isSelected)
\r
834 labelAtom(g, tmpBond, 2);
\r
841 public void labelAtom(Graphics g, Bond b, int n) {
\r
845 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
846 (getSize().width / 2));
\r
847 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
848 (getSize().height / 2));
\r
850 g.setColor(Color.red);
\r
851 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
855 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
856 (getSize().width / 2));
\r
857 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
858 (getSize().height / 2));
\r
860 g.setColor(Color.red);
\r
861 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
865 int foundchain = -1;
\r
866 public Atom findAtom(int x, int y) {
\r
871 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
873 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
877 if (chain.isVisible)
\r
879 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
881 for (int i = 0; i < bonds.size(); i++)
\r
883 tmpBond = (Bond) bonds.elementAt(i);
\r
885 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
886 (getSize().width / 2));
\r
888 if (Math.abs(truex - x) <= 2)
\r
890 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
891 (getSize().height / 2));
\r
893 if (Math.abs(truey - y) <= 2)
\r
895 fatom = tmpBond.at1;
\r
902 // Still here? Maybe its the last bond
\r
904 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
905 (getSize().width / 2));
\r
907 if (Math.abs(truex - x) <= 2)
\r
909 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
910 (getSize().height / 2));
\r
912 if (Math.abs(truey - y) <= 2)
\r
914 fatom = tmpBond.at2;
\r
922 if (fatom != null) //)&& chain.ds != null)
\r
924 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
931 public void update(Graphics g)
\r
936 public void highlightRes(int ii)
\r
938 if(!seqColoursReady)
\r
941 if (highlightRes != null
\r
942 && highlightRes.contains((ii-1) + ""))
\r
949 for(index=0; index<mainchain.bonds.size(); index++)
\r
951 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
952 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
954 if (highlightBond1 != null)
\r
955 highlightBond1.at2.isSelected = false;
\r
957 if (highlightBond2 != null)
\r
958 highlightBond2.at1.isSelected = false;
\r
960 highlightBond1 = null;
\r
961 highlightBond2 = null;
\r
965 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
966 highlightBond1.at2.isSelected = true;
\r
969 if (index != mainchain.bonds.size())
\r
971 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
972 highlightBond2.at1.isSelected = true;
\r
979 redrawneeded = true;
\r
984 public void setAllchainsVisible(boolean b)
\r
986 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
988 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
989 chain.isVisible = b;
\r
991 mainchain.isVisible = true;
\r