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
33 import javax.swing.*;
\r
36 public class PDBCanvas extends JPanel 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.gui.SeqCanvas seqcanvas;
\r
70 public Sequence sequence;
\r
71 final StringBuffer mappingDetails = new StringBuffer();
\r
73 Vector highlightRes;
\r
74 boolean pdbAction = false;
\r
75 boolean seqColoursReady = false;
\r
77 public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq)
\r
79 this.seqcanvas = seqcanvas;
\r
80 this.sequence = seq;
\r
81 seqcanvas.setPDBCanvas(this);
\r
84 public void setPDBFile(PDBfile pdb)
\r
92 AlignSeq maxAlignseq = null;
\r
94 for (int i = 0; i < pdb.chains.size(); i++)
\r
97 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());
\r
98 mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
\r
100 // Now lets compare the sequences to get
\r
101 // the start and end points.
\r
102 // Align the sequence to the pdb
\r
103 AlignSeq as = new AlignSeq(sequence,
\r
104 ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
\r
105 as.calcScoreMatrix();
\r
106 as.traceAlignment();
\r
107 PrintStream ps = new PrintStream(System.out)
\r
109 public void print(String x) {
\r
110 mappingDetails.append(x);
\r
112 public void println()
\r
114 mappingDetails.append("\n");
\r
118 as.printAlignment(ps);
\r
122 if (as.maxscore > max)
\r
126 pdbstart = as.seq2start;
\r
127 pdbend = as.seq2end;
\r
128 seqstart = as.seq1start + sequence.getStart()-1;
\r
129 seqend = as.seq1end + sequence.getEnd()-1;
\r
133 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
134 mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
\r
137 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
139 mainchain.pdbstart = pdbstart;
\r
140 mainchain.pdbend = pdbend;
\r
141 mainchain.seqstart = seqstart;
\r
142 mainchain.seqend = seqend;
\r
143 mainchain.isVisible = true;
\r
144 mainchain.makeExactMapping(maxAlignseq, sequence);
\r
147 this.prefsize = new Dimension(getWidth(), getHeight());
\r
149 //Initialize the matrices to identity
\r
150 for (int i = 0; i < 3; i++) {
\r
151 for (int j = 0; j < 3; j++) {
\r
153 idmat.addElement(i, j, 0);
\r
154 objmat.addElement(i, j, 0);
\r
156 idmat.addElement(i, j, 1);
\r
157 objmat.addElement(i, j, 1);
\r
162 addMouseMotionListener(this);
\r
163 addMouseListener(this);
\r
165 addMouseWheelListener(new MouseWheelListener()
\r
167 public void mouseWheelMoved(MouseWheelEvent e)
\r
169 if (e.getWheelRotation() > 0)
\r
171 scale = (float) (scale * 1.1);
\r
172 redrawneeded = true;
\r
178 scale = (float) (scale * 0.9);
\r
179 redrawneeded = true;
\r
191 scale = findScale();
\r
193 ToolTipManager.sharedInstance().registerComponent(this);
\r
194 ToolTipManager.sharedInstance().setInitialDelay(0);
\r
195 ToolTipManager.sharedInstance().setDismissDelay(10000);
\r
199 Vector visiblebonds;
\r
202 seqColoursReady = false;
\r
203 // Sort the bonds by z coord
\r
204 visiblebonds = new Vector();
\r
206 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
208 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
210 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
212 for (int i = 0; i < tmp.size(); i++)
\r
214 visiblebonds.addElement(tmp.elementAt(i));
\r
219 updateSeqColours();
\r
220 seqColoursReady = true;
\r
221 redrawneeded = true;
\r
226 public void findWidth() {
\r
227 float[] max = new float[3];
\r
228 float[] min = new float[3];
\r
230 max[0] = (float) -1e30;
\r
231 max[1] = (float) -1e30;
\r
232 max[2] = (float) -1e30;
\r
234 min[0] = (float) 1e30;
\r
235 min[1] = (float) 1e30;
\r
236 min[2] = (float) 1e30;
\r
238 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
239 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
240 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
242 for (int i = 0; i < bonds.size(); i++) {
\r
243 Bond tmp = (Bond) bonds.elementAt(i);
\r
245 if (tmp.start[0] >= max[0]) {
\r
246 max[0] = tmp.start[0];
\r
249 if (tmp.start[1] >= max[1]) {
\r
250 max[1] = tmp.start[1];
\r
253 if (tmp.start[2] >= max[2]) {
\r
254 max[2] = tmp.start[2];
\r
257 if (tmp.start[0] <= min[0]) {
\r
258 min[0] = tmp.start[0];
\r
261 if (tmp.start[1] <= min[1]) {
\r
262 min[1] = tmp.start[1];
\r
265 if (tmp.start[2] <= min[2]) {
\r
266 min[2] = tmp.start[2];
\r
269 if (tmp.end[0] >= max[0]) {
\r
270 max[0] = tmp.end[0];
\r
273 if (tmp.end[1] >= max[1]) {
\r
274 max[1] = tmp.end[1];
\r
277 if (tmp.end[2] >= max[2]) {
\r
278 max[2] = tmp.end[2];
\r
281 if (tmp.end[0] <= min[0]) {
\r
282 min[0] = tmp.end[0];
\r
285 if (tmp.end[1] <= min[1]) {
\r
286 min[1] = tmp.end[1];
\r
289 if (tmp.end[2] <= min[2]) {
\r
290 min[2] = tmp.end[2];
\r
296 System.out.println("xmax " + max[0] + " min " + min[0]);
\r
297 System.out.println("ymax " + max[1] + " min " + min[1]);
\r
298 System.out.println("zmax " + max[2] + " min " + min[2]);*/
\r
300 width[0] = (float) Math.abs(max[0] - min[0]);
\r
301 width[1] = (float) Math.abs(max[1] - min[1]);
\r
302 width[2] = (float) Math.abs(max[2] - min[2]);
\r
304 maxwidth = width[0];
\r
306 if (width[1] > width[0]) {
\r
307 maxwidth = width[1];
\r
310 if (width[2] > width[1]) {
\r
311 maxwidth = width[2];
\r
314 // System.out.println("Maxwidth = " + maxwidth);
\r
317 public float findScale() {
\r
322 if (getWidth() != 0) {
\r
323 width = getWidth();
\r
324 height = getHeight();
\r
326 width = prefsize.width;
\r
327 height = prefsize.height;
\r
330 if (width < height) {
\r
336 return (float) (dim / (1.5d * maxwidth));
\r
339 public void findCentre() {
\r
346 //Find centre coordinate
\r
347 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
348 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
349 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
351 bsize += bonds.size();
\r
353 for (int i = 0; i < bonds.size(); i++) {
\r
354 xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
\r
355 ((Bond) bonds.elementAt(i)).end[0];
\r
357 ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
\r
358 ((Bond) bonds.elementAt(i)).end[1];
\r
360 ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
\r
361 ((Bond) bonds.elementAt(i)).end[2];
\r
366 centre[0] = xtot / (2 * (float) bsize);
\r
367 centre[1] = ytot / (2 * (float) bsize);
\r
368 centre[2] = ztot / (2 * (float) bsize);
\r
371 public void paintComponent(Graphics g)
\r
373 super.paintComponent(g);
\r
375 if(!seqColoursReady)
\r
377 g.setColor(Color.black);
\r
378 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
379 g.drawString("Retrieving PDB data....", 20, getHeight()/2);
\r
384 //Only create the image at the beginning -
\r
385 //this saves much memory usage
\r
387 || (prefsize.width != getWidth())
\r
388 || (prefsize.height != getHeight()))
\r
391 prefsize.width = getWidth();
\r
392 prefsize.height = getHeight();
\r
394 scale = findScale();
\r
395 img = createImage(prefsize.width, prefsize.height);
\r
396 ig = img.getGraphics();
\r
397 Graphics2D ig2 = (Graphics2D) ig;
\r
399 ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
400 RenderingHints.VALUE_ANTIALIAS_ON);
\r
402 redrawneeded = true;
\r
408 drawAll(ig, prefsize.width, prefsize.height);
\r
409 redrawneeded = false;
\r
412 g.drawImage(img, 0, 0, this);
\r
417 public void drawAll(Graphics g, int width, int height)
\r
419 g.setColor(Color.black);
\r
420 g.fillRect(0, 0, width, height);
\r
426 public void updateSeqColours()
\r
433 // System.out.println("update seq colours");
\r
434 if(bysequence && pdb!=null)
\r
436 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
438 colourBySequence( (PDBChain) pdb.chains.elementAt(ii));
\r
446 int findTrueIndex(int pos)
\r
448 // returns the alignment position for a residue
\r
449 int j = sequence.getStart();
\r
452 while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
\r
454 if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
\r
465 if ( (j == sequence.getEnd()) && (j < pos))
\r
467 return sequence.getEnd() + 1;
\r
475 // This method has been taken out of PDBChain to allow
\r
476 // Applet and Application specific sequence renderers to be used
\r
477 void colourBySequence(PDBChain chain)
\r
479 // System.out.println("colour by seq");
\r
480 for (int i = 0; i < chain.bonds.size(); i++)
\r
482 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
483 tmp.startCol = Color.lightGray;
\r
484 tmp.endCol = Color.lightGray;
\r
486 if(chain!=mainchain)
\r
489 if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
490 (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
\r
492 int index = findTrueIndex(tmp.at1.alignmentMapping);
\r
493 //sequence.findIndex(tmp.at1.alignmentMapping);
\r
496 tmp.startCol = seqcanvas.getSequenceRenderer().
\r
497 getResidueBoxColour( sequence, index);
\r
498 if(tmp.startCol==null)
\r
499 tmp.startCol = Color.white;
\r
501 tmp.startCol = seqcanvas.getFeatureRenderer().
\r
502 findFeatureColour(tmp.startCol, sequence, index);
\r
506 if ( (tmp.at2.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
507 (tmp.at2.resNumber <= ( (chain.pdbend + chain.offset) - 1)))
\r
510 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
511 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
514 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
515 getResidueBoxColour( sequence, index);
\r
516 if(tmp.endCol==null)
\r
517 tmp.endCol = Color.white;
\r
518 tmp.endCol = seqcanvas.getFeatureRenderer().
\r
519 findFeatureColour(tmp.endCol, sequence, index);
\r
526 public void drawScene(Graphics g)
\r
530 Zsort.Zsort(visiblebonds);
\r
534 for (int i = 0; i < visiblebonds.size(); i++)
\r
536 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
538 xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
540 ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
541 (getHeight() / 2));
\r
543 xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
\r
545 yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
\r
546 (getHeight() / 2));
\r
548 xmid = (xend + xstart) / 2;
\r
549 ymid = (yend + ystart) / 2;
\r
551 if (depthcue && !bymolecule)
\r
553 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
554 g.setColor(tmpBond.startCol.darker().darker());
\r
555 drawLine(g, xstart, ystart, xmid, ymid);
\r
556 g.setColor(tmpBond.endCol.darker().darker());
\r
557 drawLine(g, xmid, ymid, xend, yend);
\r
558 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
559 g.setColor(tmpBond.startCol.darker());
\r
560 drawLine(g, xstart, ystart, xmid, ymid);
\r
562 g.setColor(tmpBond.endCol.darker());
\r
563 drawLine(g, xmid, ymid, xend, yend);
\r
565 g.setColor(tmpBond.startCol);
\r
566 drawLine(g, xstart, ystart, xmid, ymid);
\r
568 g.setColor(tmpBond.endCol);
\r
569 drawLine(g, xmid, ymid, xend, yend);
\r
571 } else if (depthcue && bymolecule) {
\r
572 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
573 g.setColor(Color.green.darker().darker());
\r
574 drawLine(g, xstart, ystart, xend, yend);
\r
575 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
576 g.setColor(Color.green.darker());
\r
577 drawLine(g, xstart, ystart, xend, yend);
\r
579 g.setColor(Color.green);
\r
580 drawLine(g, xstart, ystart, xend, yend);
\r
582 } else if (!depthcue && !bymolecule) {
\r
583 g.setColor(tmpBond.startCol);
\r
584 drawLine(g, xstart, ystart, xmid, ymid);
\r
585 g.setColor(tmpBond.endCol);
\r
586 drawLine(g, xmid, ymid, xend, yend);
\r
588 drawLine(g, xstart, ystart, xend, yend);
\r
591 if(highlightBond1!=null && highlightBond1==tmpBond)
\r
593 g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter());
\r
594 drawLine(g, xmid, ymid, xend, yend);
\r
597 if(highlightBond2!=null && highlightBond2==tmpBond)
\r
599 g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter());
\r
600 drawLine(g, xstart, ystart, xmid, ymid);
\r
608 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
610 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
611 g.drawLine(x1, y1, x2, y2);
\r
612 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
613 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
615 g.setColor(g.getColor().brighter());
\r
616 g.drawLine(x1, y1, x2, y2);
\r
617 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
618 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
621 g.drawLine(x1, y1, x2, y2);
\r
625 public Dimension minimumsize() {
\r
629 public Dimension preferredsize() {
\r
633 public void keyPressed(KeyEvent evt)
\r
635 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
637 scale = (float) (scale * 1.1);
\r
638 redrawneeded = true;
\r
641 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
643 scale = (float) (scale * 0.9);
\r
644 redrawneeded = true;
\r
649 public void mousePressed(MouseEvent e)
\r
652 Atom fatom = findAtom(e.getX(), e.getY());
\r
655 fatom.isSelected = !fatom.isSelected;
\r
657 redrawneeded = true;
\r
659 if (foundchain != -1)
\r
661 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
662 if (chain == mainchain)
\r
664 if (fatom.alignmentMapping != -1)
\r
666 if (highlightRes == null)
\r
667 highlightRes = new Vector();
\r
669 if (highlightRes.contains(fatom.alignmentMapping+"" + ""))
\r
670 highlightRes.remove(fatom.alignmentMapping + "");
\r
672 highlightRes.add(fatom.alignmentMapping + "");
\r
685 public void mouseMoved(MouseEvent e)
\r
688 if(highlightBond1!=null)
\r
690 highlightBond1.at2.isSelected = false;
\r
691 highlightBond2.at1.isSelected = false;
\r
692 highlightBond1 = null;
\r
693 highlightBond2 = null;
\r
696 Atom fatom = findAtom(e.getX(), e.getY());
\r
698 PDBChain chain = null;
\r
701 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
702 if(chain == mainchain)
\r
704 highlightSeqcanvas( fatom.alignmentMapping );
\r
710 this.setToolTipText(chain.id+":"+ fatom.resNumber+" "+ fatom.resName);
\r
713 highlightSeqcanvas( -1);
\r
714 this.setToolTipText(null);
\r
719 void highlightSeqcanvas(int pos)
\r
721 int index = seqcanvas.getViewport().getAlignment().findIndex(sequence);
\r
723 int size = pos==-1?0:3;
\r
725 if(highlightRes!=null)
\r
726 size += highlightRes.size()*3;
\r
728 int [] array = new int[size];
\r
730 if(highlightRes!=null)
\r
732 for (i = 0; i < highlightRes.size(); i++)
\r
734 int a = Integer.parseInt(highlightRes.elementAt(
\r
736 array[i * 3] = index;
\r
737 array[ (i * 3) + 1] = a;
\r
738 array[ (i * 3) + 2] = a;
\r
744 array[i * 3] = index;
\r
745 array[i * 3 + 1] = pos+1;
\r
746 array[i * 3 + 2] = pos+1;
\r
749 seqcanvas.highlightSearchResults(array);
\r
753 public void mouseClicked(MouseEvent e) { }
\r
755 public void mouseEntered(MouseEvent e) { }
\r
757 public void mouseExited(MouseEvent e) { }
\r
759 public void mouseDragged(MouseEvent evt)
\r
761 int x = evt.getX();
\r
762 int y = evt.getY();
\r
767 MCMatrix objmat = new MCMatrix(3, 3);
\r
768 objmat.setIdentity();
\r
770 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
771 objmat.rotatez((float) ((mx - omx)));
\r
773 objmat.rotatex((float) ((my - omy)));
\r
774 objmat.rotatey((float) ((omx - mx)));
\r
778 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
779 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
781 for (int i = 0; i < bonds.size(); i++) {
\r
782 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
784 //Translate the bond so the centre is 0,0,0
\r
785 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
787 //Now apply the rotation matrix
\r
788 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
789 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
791 //Now translate back again
\r
792 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
803 redrawneeded = true;
\r
808 public void mouseReleased(MouseEvent evt)
\r
814 void drawLabels(Graphics g) {
\r
816 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
818 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
820 if (chain.isVisible)
\r
822 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
824 for (int i = 0; i < bonds.size(); i++)
\r
826 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
828 if (tmpBond.at1.isSelected)
\r
830 labelAtom(g, tmpBond, 1);
\r
833 if (tmpBond.at2.isSelected)
\r
836 labelAtom(g, tmpBond, 2);
\r
843 public void labelAtom(Graphics g, Bond b, int n) {
\r
845 g.setColor(Color.red);
\r
848 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
850 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
851 (getHeight() / 2));
\r
853 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
857 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
859 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
860 (getHeight() / 2));
\r
862 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
866 int foundchain = -1;
\r
867 public Atom findAtom(int x, int y) {
\r
872 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
874 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
878 if (chain.isVisible)
\r
880 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
882 for (int i = 0; i < bonds.size(); i++)
\r
884 tmpBond = (Bond) bonds.elementAt(i);
\r
886 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
889 if (Math.abs(truex - x) <= 2)
\r
891 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
892 (getHeight() / 2));
\r
894 if (Math.abs(truey - y) <= 2)
\r
896 fatom = tmpBond.at1;
\r
903 // Still here? Maybe its the last bond
\r
905 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
908 if (Math.abs(truex - x) <= 2)
\r
910 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
911 (getHeight() / 2));
\r
913 if (Math.abs(truey - y) <= 2)
\r
915 fatom = tmpBond.at2;
\r
923 if (fatom != null) //)&& chain.ds != null)
\r
925 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
932 Bond highlightBond1, highlightBond2;
\r
933 public void highlightRes(int ii)
\r
935 if( !seqColoursReady )
\r
938 if (highlightRes != null
\r
939 && highlightRes.contains((ii-1) + ""))
\r
946 for(index=0; index<mainchain.bonds.size(); index++)
\r
948 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
949 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
951 if (highlightBond1 != null)
\r
952 highlightBond1.at2.isSelected = false;
\r
954 if (highlightBond2 != null)
\r
955 highlightBond2.at1.isSelected = false;
\r
957 highlightBond1 = null;
\r
958 highlightBond2 = null;
\r
962 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
963 highlightBond1.at2.isSelected = true;
\r
966 if (index != mainchain.bonds.size())
\r
968 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
969 highlightBond2.at1.isSelected = true;
\r
976 redrawneeded = true;
\r
980 public void setAllchainsVisible(boolean b)
\r
982 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
984 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
985 chain.isVisible = b;
\r
987 mainchain.isVisible = true;
\r