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
76 jalview.gui.FeatureRenderer fr;
\r
78 public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq)
\r
80 this.seqcanvas = seqcanvas;
\r
81 this.sequence = seq;
\r
82 seqcanvas.setPDBCanvas(this);
\r
85 public void setPDBFile(PDBfile pdb)
\r
93 AlignSeq maxAlignseq = null;
\r
95 for (int i = 0; i < pdb.chains.size(); i++)
\r
98 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());
\r
99 mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
\r
101 // Now lets compare the sequences to get
\r
102 // the start and end points.
\r
103 // Align the sequence to the pdb
\r
104 AlignSeq as = new AlignSeq(sequence,
\r
105 ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
\r
106 as.calcScoreMatrix();
\r
107 as.traceAlignment();
\r
108 PrintStream ps = new PrintStream(System.out)
\r
110 public void print(String x) {
\r
111 mappingDetails.append(x);
\r
113 public void println()
\r
115 mappingDetails.append("\n");
\r
119 as.printAlignment(ps);
\r
123 if (as.maxscore > max)
\r
127 pdbstart = as.seq2start;
\r
128 pdbend = as.seq2end;
\r
129 seqstart = as.seq1start + sequence.getStart()-1;
\r
130 seqend = as.seq1end + sequence.getEnd()-1;
\r
134 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
135 mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
\r
138 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
140 mainchain.pdbstart = pdbstart;
\r
141 mainchain.pdbend = pdbend;
\r
142 mainchain.seqstart = seqstart;
\r
143 mainchain.seqend = seqend;
\r
144 mainchain.isVisible = true;
\r
145 mainchain.makeExactMapping(maxAlignseq, sequence);
\r
148 this.prefsize = new Dimension(getWidth(), getHeight());
\r
150 //Initialize the matrices to identity
\r
151 for (int i = 0; i < 3; i++) {
\r
152 for (int j = 0; j < 3; j++) {
\r
154 idmat.addElement(i, j, 0);
\r
155 objmat.addElement(i, j, 0);
\r
157 idmat.addElement(i, j, 1);
\r
158 objmat.addElement(i, j, 1);
\r
163 addMouseMotionListener(this);
\r
164 addMouseListener(this);
\r
166 addMouseWheelListener(new MouseWheelListener()
\r
168 public void mouseWheelMoved(MouseWheelEvent e)
\r
170 if (e.getWheelRotation() > 0)
\r
172 scale = (float) (scale * 1.1);
\r
173 redrawneeded = true;
\r
179 scale = (float) (scale * 0.9);
\r
180 redrawneeded = true;
\r
192 scale = findScale();
\r
194 ToolTipManager.sharedInstance().registerComponent(this);
\r
195 ToolTipManager.sharedInstance().setInitialDelay(0);
\r
196 ToolTipManager.sharedInstance().setDismissDelay(10000);
\r
200 Vector visiblebonds;
\r
203 seqColoursReady = false;
\r
204 // Sort the bonds by z coord
\r
205 visiblebonds = new Vector();
\r
207 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
209 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
211 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
213 for (int i = 0; i < tmp.size(); i++)
\r
215 visiblebonds.addElement(tmp.elementAt(i));
\r
220 updateSeqColours();
\r
221 seqColoursReady = true;
\r
222 redrawneeded = true;
\r
227 public void findWidth() {
\r
228 float[] max = new float[3];
\r
229 float[] min = new float[3];
\r
231 max[0] = (float) -1e30;
\r
232 max[1] = (float) -1e30;
\r
233 max[2] = (float) -1e30;
\r
235 min[0] = (float) 1e30;
\r
236 min[1] = (float) 1e30;
\r
237 min[2] = (float) 1e30;
\r
239 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
240 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
241 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
243 for (int i = 0; i < bonds.size(); i++) {
\r
244 Bond tmp = (Bond) bonds.elementAt(i);
\r
246 if (tmp.start[0] >= max[0]) {
\r
247 max[0] = tmp.start[0];
\r
250 if (tmp.start[1] >= max[1]) {
\r
251 max[1] = tmp.start[1];
\r
254 if (tmp.start[2] >= max[2]) {
\r
255 max[2] = tmp.start[2];
\r
258 if (tmp.start[0] <= min[0]) {
\r
259 min[0] = tmp.start[0];
\r
262 if (tmp.start[1] <= min[1]) {
\r
263 min[1] = tmp.start[1];
\r
266 if (tmp.start[2] <= min[2]) {
\r
267 min[2] = tmp.start[2];
\r
270 if (tmp.end[0] >= max[0]) {
\r
271 max[0] = tmp.end[0];
\r
274 if (tmp.end[1] >= max[1]) {
\r
275 max[1] = tmp.end[1];
\r
278 if (tmp.end[2] >= max[2]) {
\r
279 max[2] = tmp.end[2];
\r
282 if (tmp.end[0] <= min[0]) {
\r
283 min[0] = tmp.end[0];
\r
286 if (tmp.end[1] <= min[1]) {
\r
287 min[1] = tmp.end[1];
\r
290 if (tmp.end[2] <= min[2]) {
\r
291 min[2] = tmp.end[2];
\r
297 System.out.println("xmax " + max[0] + " min " + min[0]);
\r
298 System.out.println("ymax " + max[1] + " min " + min[1]);
\r
299 System.out.println("zmax " + max[2] + " min " + min[2]);*/
\r
301 width[0] = (float) Math.abs(max[0] - min[0]);
\r
302 width[1] = (float) Math.abs(max[1] - min[1]);
\r
303 width[2] = (float) Math.abs(max[2] - min[2]);
\r
305 maxwidth = width[0];
\r
307 if (width[1] > width[0]) {
\r
308 maxwidth = width[1];
\r
311 if (width[2] > width[1]) {
\r
312 maxwidth = width[2];
\r
315 // System.out.println("Maxwidth = " + maxwidth);
\r
318 public float findScale() {
\r
323 if (getWidth() != 0) {
\r
324 width = getWidth();
\r
325 height = getHeight();
\r
327 width = prefsize.width;
\r
328 height = prefsize.height;
\r
331 if (width < height) {
\r
337 return (float) (dim / (1.5d * maxwidth));
\r
340 public void findCentre() {
\r
347 //Find centre coordinate
\r
348 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
349 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
350 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
352 bsize += bonds.size();
\r
354 for (int i = 0; i < bonds.size(); i++) {
\r
355 xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
\r
356 ((Bond) bonds.elementAt(i)).end[0];
\r
358 ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
\r
359 ((Bond) bonds.elementAt(i)).end[1];
\r
361 ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
\r
362 ((Bond) bonds.elementAt(i)).end[2];
\r
367 centre[0] = xtot / (2 * (float) bsize);
\r
368 centre[1] = ytot / (2 * (float) bsize);
\r
369 centre[2] = ztot / (2 * (float) bsize);
\r
372 public void paintComponent(Graphics g)
\r
374 super.paintComponent(g);
\r
376 if(!seqColoursReady)
\r
378 g.setColor(Color.black);
\r
379 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
380 g.drawString("Retrieving PDB data....", 20, getHeight()/2);
\r
385 //Only create the image at the beginning -
\r
386 //this saves much memory usage
\r
388 || (prefsize.width != getWidth())
\r
389 || (prefsize.height != getHeight()))
\r
392 prefsize.width = getWidth();
\r
393 prefsize.height = getHeight();
\r
395 scale = findScale();
\r
396 img = createImage(prefsize.width, prefsize.height);
\r
397 ig = img.getGraphics();
\r
398 Graphics2D ig2 = (Graphics2D) ig;
\r
400 ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
401 RenderingHints.VALUE_ANTIALIAS_ON);
\r
403 redrawneeded = true;
\r
409 drawAll(ig, prefsize.width, prefsize.height);
\r
410 redrawneeded = false;
\r
413 g.drawImage(img, 0, 0, this);
\r
418 public void drawAll(Graphics g, int width, int height)
\r
420 g.setColor(Color.black);
\r
421 g.fillRect(0, 0, width, height);
\r
427 public void updateSeqColours()
\r
434 // System.out.println("update seq colours");
\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
447 int findTrueIndex(int pos)
\r
449 // returns the alignment position for a residue
\r
450 int j = sequence.getStart();
\r
453 while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
\r
455 if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
\r
466 if ( (j == sequence.getEnd()) && (j < pos))
\r
468 return sequence.getEnd() + 1;
\r
476 // This method has been taken out of PDBChain to allow
\r
477 // Applet and Application specific sequence renderers to be used
\r
478 void colourBySequence(PDBChain chain)
\r
480 // System.out.println("colour by seq");
\r
481 boolean showFeatures = false;
\r
482 if(seqcanvas.getViewport().getShowSequenceFeatures())
\r
484 showFeatures = true;
\r
486 fr = new jalview.gui.FeatureRenderer(seqcanvas.getViewport());
\r
488 fr.transferSettings( seqcanvas.getFeatureRenderer() );
\r
491 for (int i = 0; i < chain.bonds.size(); i++)
\r
493 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
494 tmp.startCol = Color.lightGray;
\r
495 tmp.endCol = Color.lightGray;
\r
497 if(chain!=mainchain)
\r
500 if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
501 (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
\r
503 int index = findTrueIndex(tmp.at1.alignmentMapping);
\r
504 //sequence.findIndex(tmp.at1.alignmentMapping);
\r
507 tmp.startCol = seqcanvas.getSequenceRenderer().
\r
508 getResidueBoxColour( sequence, index);
\r
509 if(tmp.startCol==null)
\r
510 tmp.startCol = Color.white;
\r
513 tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
\r
517 if ( (tmp.at2.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
518 (tmp.at2.resNumber <= ( (chain.pdbend + chain.offset) - 1)))
\r
521 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
522 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
525 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
526 getResidueBoxColour( sequence, index);
\r
527 if(tmp.endCol==null)
\r
528 tmp.endCol = Color.white;
\r
530 tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
\r
538 public void drawScene(Graphics g)
\r
543 zsort = new Zsort();
\r
545 zsort.Zsort(visiblebonds);
\r
549 for (int i = 0; i < visiblebonds.size(); i++)
\r
551 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
553 xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
555 ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
556 (getHeight() / 2));
\r
558 xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
\r
560 yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
\r
561 (getHeight() / 2));
\r
563 xmid = (xend + xstart) / 2;
\r
564 ymid = (yend + ystart) / 2;
\r
566 if (depthcue && !bymolecule)
\r
568 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
\r
570 g.setColor(tmpBond.startCol.darker().darker());
\r
571 drawLine(g, xstart, ystart, xmid, ymid);
\r
572 g.setColor(tmpBond.endCol.darker().darker());
\r
573 drawLine(g, xmid, ymid, xend, yend);
\r
574 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
575 g.setColor(tmpBond.startCol.darker());
\r
576 drawLine(g, xstart, ystart, xmid, ymid);
\r
578 g.setColor(tmpBond.endCol.darker());
\r
579 drawLine(g, xmid, ymid, xend, yend);
\r
581 g.setColor(tmpBond.startCol);
\r
582 drawLine(g, xstart, ystart, xmid, ymid);
\r
584 g.setColor(tmpBond.endCol);
\r
585 drawLine(g, xmid, ymid, xend, yend);
\r
587 } else if (depthcue && bymolecule) {
\r
588 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
589 g.setColor(Color.green.darker().darker());
\r
590 drawLine(g, xstart, ystart, xend, yend);
\r
591 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
592 g.setColor(Color.green.darker());
\r
593 drawLine(g, xstart, ystart, xend, yend);
\r
595 g.setColor(Color.green);
\r
596 drawLine(g, xstart, ystart, xend, yend);
\r
598 } else if (!depthcue && !bymolecule) {
\r
599 g.setColor(tmpBond.startCol);
\r
600 drawLine(g, xstart, ystart, xmid, ymid);
\r
601 g.setColor(tmpBond.endCol);
\r
602 drawLine(g, xmid, ymid, xend, yend);
\r
604 drawLine(g, xstart, ystart, xend, yend);
\r
607 if(highlightBond1!=null && highlightBond1==tmpBond)
\r
609 g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter());
\r
610 drawLine(g, xmid, ymid, xend, yend);
\r
613 if(highlightBond2!=null && highlightBond2==tmpBond)
\r
615 g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter());
\r
616 drawLine(g, xstart, ystart, xmid, ymid);
\r
624 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
626 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
627 g.drawLine(x1, y1, x2, y2);
\r
628 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
629 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
631 g.setColor(g.getColor().brighter());
\r
632 g.drawLine(x1, y1, x2, y2);
\r
633 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
634 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
637 g.drawLine(x1, y1, x2, y2);
\r
641 public Dimension minimumsize() {
\r
645 public Dimension preferredsize() {
\r
649 public void keyPressed(KeyEvent evt)
\r
651 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
653 scale = (float) (scale * 1.1);
\r
654 redrawneeded = true;
\r
657 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
659 scale = (float) (scale * 0.9);
\r
660 redrawneeded = true;
\r
665 public void mousePressed(MouseEvent e)
\r
668 Atom fatom = findAtom(e.getX(), e.getY());
\r
671 fatom.isSelected = !fatom.isSelected;
\r
673 redrawneeded = true;
\r
675 if (foundchain != -1)
\r
677 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
678 if (chain == mainchain)
\r
680 if (fatom.alignmentMapping != -1)
\r
682 if (highlightRes == null)
\r
683 highlightRes = new Vector();
\r
685 if (highlightRes.contains(fatom.alignmentMapping+""))
\r
686 highlightRes.remove(fatom.alignmentMapping + "");
\r
688 highlightRes.add(fatom.alignmentMapping + "");
\r
701 public void mouseMoved(MouseEvent e)
\r
704 if(highlightBond1!=null)
\r
706 highlightBond1.at2.isSelected = false;
\r
707 highlightBond2.at1.isSelected = false;
\r
708 highlightBond1 = null;
\r
709 highlightBond2 = null;
\r
712 Atom fatom = findAtom(e.getX(), e.getY());
\r
714 PDBChain chain = null;
\r
717 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
718 if(chain == mainchain)
\r
720 highlightSeqcanvas( fatom.alignmentMapping );
\r
726 this.setToolTipText(chain.id+":"+ fatom.resNumber+" "+ fatom.resName);
\r
729 highlightSeqcanvas( -1);
\r
730 this.setToolTipText(null);
\r
735 void highlightSeqcanvas(int pos)
\r
737 SearchResults searchResults = new SearchResults();
\r
738 if(highlightRes!=null)
\r
740 for (int i = 0; i < highlightRes.size(); i++)
\r
742 int a = Integer.parseInt(highlightRes.elementAt(
\r
745 searchResults.addResult(sequence, a, a);
\r
751 searchResults.addResult(sequence, pos+1, pos+1);
\r
754 seqcanvas.highlightSearchResults(searchResults);
\r
758 public void mouseClicked(MouseEvent e) { }
\r
760 public void mouseEntered(MouseEvent e) { }
\r
762 public void mouseExited(MouseEvent e) { }
\r
764 public void mouseDragged(MouseEvent evt)
\r
766 int x = evt.getX();
\r
767 int y = evt.getY();
\r
772 MCMatrix objmat = new MCMatrix(3, 3);
\r
773 objmat.setIdentity();
\r
775 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
776 objmat.rotatez((float) ((mx - omx)));
\r
778 objmat.rotatex((float) ((my - omy)));
\r
779 objmat.rotatey((float) ((omx - mx)));
\r
783 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
784 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
786 for (int i = 0; i < bonds.size(); i++) {
\r
787 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
789 //Translate the bond so the centre is 0,0,0
\r
790 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
792 //Now apply the rotation matrix
\r
793 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
794 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
796 //Now translate back again
\r
797 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
808 redrawneeded = true;
\r
813 public void mouseReleased(MouseEvent evt)
\r
819 void drawLabels(Graphics g) {
\r
821 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
823 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
825 if (chain.isVisible)
\r
827 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
829 for (int i = 0; i < bonds.size(); i++)
\r
831 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
833 if (tmpBond.at1.isSelected)
\r
835 labelAtom(g, tmpBond, 1);
\r
838 if (tmpBond.at2.isSelected)
\r
841 labelAtom(g, tmpBond, 2);
\r
848 public void labelAtom(Graphics g, Bond b, int n) {
\r
850 g.setColor(Color.red);
\r
853 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
855 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
856 (getHeight() / 2));
\r
858 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
862 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
864 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
865 (getHeight() / 2));
\r
867 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
871 int foundchain = -1;
\r
872 public Atom findAtom(int x, int y) {
\r
877 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
879 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
883 if (chain.isVisible)
\r
885 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
887 for (int i = 0; i < bonds.size(); i++)
\r
889 tmpBond = (Bond) bonds.elementAt(i);
\r
891 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
894 if (Math.abs(truex - x) <= 2)
\r
896 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
897 (getHeight() / 2));
\r
899 if (Math.abs(truey - y) <= 2)
\r
901 fatom = tmpBond.at1;
\r
908 // Still here? Maybe its the last bond
\r
910 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
913 if (Math.abs(truex - x) <= 2)
\r
915 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
916 (getHeight() / 2));
\r
918 if (Math.abs(truey - y) <= 2)
\r
920 fatom = tmpBond.at2;
\r
928 if (fatom != null) //)&& chain.ds != null)
\r
930 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
937 Bond highlightBond1, highlightBond2;
\r
938 public void highlightRes(int ii)
\r
940 if( !seqColoursReady )
\r
943 if (highlightRes != null
\r
944 && highlightRes.contains((ii-1) + ""))
\r
951 for(index=0; index<mainchain.bonds.size(); index++)
\r
953 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
954 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
956 if (highlightBond1 != null)
\r
957 highlightBond1.at2.isSelected = false;
\r
959 if (highlightBond2 != null)
\r
960 highlightBond2.at1.isSelected = false;
\r
962 highlightBond1 = null;
\r
963 highlightBond2 = null;
\r
967 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
968 highlightBond1.at2.isSelected = true;
\r
971 if (index != mainchain.bonds.size())
\r
973 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
974 highlightBond2.at1.isSelected = true;
\r
981 redrawneeded = true;
\r
985 public void setAllchainsVisible(boolean b)
\r
987 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
989 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
990 chain.isVisible = b;
\r
992 mainchain.isVisible = true;
\r