2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2006 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
77 Color backgroundColour = Color.black;
\r
79 public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq)
\r
81 this.seqcanvas = seqcanvas;
\r
82 this.sequence = seq;
\r
83 seqcanvas.setPDBCanvas(this);
\r
86 public void setPDBFile(PDBfile pdb)
\r
94 AlignSeq maxAlignseq = null;
\r
96 for (int i = 0; i < pdb.chains.size(); i++)
\r
99 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());
\r
100 mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
\r
102 // Now lets compare the sequences to get
\r
103 // the start and end points.
\r
104 // Align the sequence to the pdb
\r
105 AlignSeq as = new AlignSeq(sequence,
\r
106 ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
\r
107 as.calcScoreMatrix();
\r
108 as.traceAlignment();
\r
109 PrintStream ps = new PrintStream(System.out)
\r
111 public void print(String x) {
\r
112 mappingDetails.append(x);
\r
114 public void println()
\r
116 mappingDetails.append("\n");
\r
120 as.printAlignment(ps);
\r
124 if (as.maxscore > max)
\r
128 pdbstart = as.seq2start;
\r
129 pdbend = as.seq2end;
\r
130 seqstart = as.seq1start + sequence.getStart()-1;
\r
131 seqend = as.seq1end + sequence.getEnd()-1;
\r
135 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
136 mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
\r
139 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
141 mainchain.pdbstart = pdbstart;
\r
142 mainchain.pdbend = pdbend;
\r
143 mainchain.seqstart = seqstart;
\r
144 mainchain.seqend = seqend;
\r
145 mainchain.isVisible = true;
\r
146 mainchain.makeExactMapping(maxAlignseq, sequence);
\r
149 this.prefsize = new Dimension(getWidth(), getHeight());
\r
151 //Initialize the matrices to identity
\r
152 for (int i = 0; i < 3; i++) {
\r
153 for (int j = 0; j < 3; j++) {
\r
155 idmat.addElement(i, j, 0);
\r
156 objmat.addElement(i, j, 0);
\r
158 idmat.addElement(i, j, 1);
\r
159 objmat.addElement(i, j, 1);
\r
164 addMouseMotionListener(this);
\r
165 addMouseListener(this);
\r
167 addMouseWheelListener(new MouseWheelListener()
\r
169 public void mouseWheelMoved(MouseWheelEvent e)
\r
171 if (e.getWheelRotation() > 0)
\r
173 scale = (float) (scale * 1.1);
\r
174 redrawneeded = true;
\r
180 scale = (float) (scale * 0.9);
\r
181 redrawneeded = true;
\r
193 scale = findScale();
\r
195 ToolTipManager.sharedInstance().registerComponent(this);
\r
196 ToolTipManager.sharedInstance().setInitialDelay(0);
\r
197 ToolTipManager.sharedInstance().setDismissDelay(10000);
\r
201 Vector visiblebonds;
\r
204 seqColoursReady = false;
\r
205 // Sort the bonds by z coord
\r
206 visiblebonds = new Vector();
\r
208 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
210 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
212 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
214 for (int i = 0; i < tmp.size(); i++)
\r
216 visiblebonds.addElement(tmp.elementAt(i));
\r
221 updateSeqColours();
\r
222 seqColoursReady = true;
\r
223 redrawneeded = true;
\r
228 public void findWidth() {
\r
229 float[] max = new float[3];
\r
230 float[] min = new float[3];
\r
232 max[0] = (float) -1e30;
\r
233 max[1] = (float) -1e30;
\r
234 max[2] = (float) -1e30;
\r
236 min[0] = (float) 1e30;
\r
237 min[1] = (float) 1e30;
\r
238 min[2] = (float) 1e30;
\r
240 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
241 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
242 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
244 for (int i = 0; i < bonds.size(); i++) {
\r
245 Bond tmp = (Bond) bonds.elementAt(i);
\r
247 if (tmp.start[0] >= max[0]) {
\r
248 max[0] = tmp.start[0];
\r
251 if (tmp.start[1] >= max[1]) {
\r
252 max[1] = tmp.start[1];
\r
255 if (tmp.start[2] >= max[2]) {
\r
256 max[2] = tmp.start[2];
\r
259 if (tmp.start[0] <= min[0]) {
\r
260 min[0] = tmp.start[0];
\r
263 if (tmp.start[1] <= min[1]) {
\r
264 min[1] = tmp.start[1];
\r
267 if (tmp.start[2] <= min[2]) {
\r
268 min[2] = tmp.start[2];
\r
271 if (tmp.end[0] >= max[0]) {
\r
272 max[0] = tmp.end[0];
\r
275 if (tmp.end[1] >= max[1]) {
\r
276 max[1] = tmp.end[1];
\r
279 if (tmp.end[2] >= max[2]) {
\r
280 max[2] = tmp.end[2];
\r
283 if (tmp.end[0] <= min[0]) {
\r
284 min[0] = tmp.end[0];
\r
287 if (tmp.end[1] <= min[1]) {
\r
288 min[1] = tmp.end[1];
\r
291 if (tmp.end[2] <= min[2]) {
\r
292 min[2] = tmp.end[2];
\r
298 System.out.println("xmax " + max[0] + " min " + min[0]);
\r
299 System.out.println("ymax " + max[1] + " min " + min[1]);
\r
300 System.out.println("zmax " + max[2] + " min " + min[2]);*/
\r
302 width[0] = (float) Math.abs(max[0] - min[0]);
\r
303 width[1] = (float) Math.abs(max[1] - min[1]);
\r
304 width[2] = (float) Math.abs(max[2] - min[2]);
\r
306 maxwidth = width[0];
\r
308 if (width[1] > width[0]) {
\r
309 maxwidth = width[1];
\r
312 if (width[2] > width[1]) {
\r
313 maxwidth = width[2];
\r
316 // System.out.println("Maxwidth = " + maxwidth);
\r
319 public float findScale() {
\r
324 if (getWidth() != 0) {
\r
325 width = getWidth();
\r
326 height = getHeight();
\r
328 width = prefsize.width;
\r
329 height = prefsize.height;
\r
332 if (width < height) {
\r
338 return (float) (dim / (1.5d * maxwidth));
\r
341 public void findCentre() {
\r
348 //Find centre coordinate
\r
349 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
350 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
351 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
353 bsize += bonds.size();
\r
355 for (int i = 0; i < bonds.size(); i++) {
\r
356 xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
\r
357 ((Bond) bonds.elementAt(i)).end[0];
\r
359 ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
\r
360 ((Bond) bonds.elementAt(i)).end[1];
\r
362 ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
\r
363 ((Bond) bonds.elementAt(i)).end[2];
\r
368 centre[0] = xtot / (2 * (float) bsize);
\r
369 centre[1] = ytot / (2 * (float) bsize);
\r
370 centre[2] = ztot / (2 * (float) bsize);
\r
373 public void paintComponent(Graphics g)
\r
375 super.paintComponent(g);
\r
377 if(!seqColoursReady)
\r
379 g.setColor(Color.black);
\r
380 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
381 g.drawString("Retrieving PDB data....", 20, getHeight()/2);
\r
386 //Only create the image at the beginning -
\r
387 //this saves much memory usage
\r
389 || (prefsize.width != getWidth())
\r
390 || (prefsize.height != getHeight()))
\r
393 prefsize.width = getWidth();
\r
394 prefsize.height = getHeight();
\r
396 scale = findScale();
\r
397 img = createImage(prefsize.width, prefsize.height);
\r
398 ig = img.getGraphics();
\r
399 Graphics2D ig2 = (Graphics2D) ig;
\r
401 ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
\r
402 RenderingHints.VALUE_ANTIALIAS_ON);
\r
404 redrawneeded = true;
\r
410 drawAll(ig, prefsize.width, prefsize.height);
\r
411 redrawneeded = false;
\r
414 g.drawImage(img, 0, 0, this);
\r
419 public void drawAll(Graphics g, int width, int height)
\r
421 g.setColor(backgroundColour);
\r
422 g.fillRect(0, 0, width, height);
\r
428 public void updateSeqColours()
\r
435 // System.out.println("update seq colours");
\r
436 if(bysequence && pdb!=null)
\r
438 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
440 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
477 // This method has been taken out of PDBChain to allow
\r
478 // Applet and Application specific sequence renderers to be used
\r
479 void colourBySequence(PDBChain chain)
\r
481 // System.out.println("colour by seq");
\r
482 boolean showFeatures = false;
\r
483 if(seqcanvas.getViewport().getShowSequenceFeatures())
\r
485 showFeatures = true;
\r
487 fr = new jalview.gui.FeatureRenderer(seqcanvas.getViewport());
\r
489 fr.transferSettings( seqcanvas.getFeatureRenderer() );
\r
493 for (int i = 0; i < chain.bonds.size(); i++)
\r
495 tmp = (Bond) chain.bonds.elementAt(i);
\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
511 tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
\r
513 if(tmp.startCol==null)
\r
514 tmp.startCol = Color.white;
\r
518 if ( (tmp.at2.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
519 (tmp.at2.resNumber <= ( (chain.pdbend + chain.offset) - 1)))
\r
522 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
523 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
526 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
527 getResidueBoxColour( sequence, index);
\r
530 tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
\r
532 if(tmp.endCol==null)
\r
533 tmp.endCol = Color.white;
\r
541 public void drawScene(Graphics g)
\r
546 zsort = new Zsort();
\r
548 zsort.Zsort(visiblebonds);
\r
551 Bond tmpBond = null;
\r
552 for (int i = 0; i < visiblebonds.size(); i++)
\r
554 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
556 xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) +
\r
558 ystart = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) +
\r
559 (getHeight() / 2));
\r
561 xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
563 yend = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
564 (getHeight() / 2));
\r
566 xmid = (xend + xstart) / 2;
\r
567 ymid = (yend + ystart) / 2;
\r
568 if (depthcue && !bymolecule)
\r
570 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
\r
573 g.setColor(tmpBond.startCol.darker().darker());
\r
574 drawLine(g, xstart, ystart, xmid, ymid);
\r
575 g.setColor(tmpBond.endCol.darker().darker());
\r
576 drawLine(g, xmid, ymid, xend, yend);
\r
579 else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
\r
581 g.setColor(tmpBond.startCol.darker());
\r
582 drawLine(g, xstart, ystart, xmid, ymid);
\r
584 g.setColor(tmpBond.endCol.darker());
\r
585 drawLine(g, xmid, ymid, xend, yend);
\r
589 g.setColor(tmpBond.startCol);
\r
590 drawLine(g, xstart, ystart, xmid, ymid);
\r
592 g.setColor(tmpBond.endCol);
\r
593 drawLine(g, xmid, ymid, xend, yend);
\r
596 else if (depthcue && bymolecule)
\r
598 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6)))
\r
600 g.setColor(Color.green.darker().darker());
\r
601 drawLine(g, xstart, ystart, xend, yend);
\r
603 else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6)))
\r
605 g.setColor(Color.green.darker());
\r
606 drawLine(g, xstart, ystart, xend, yend);
\r
610 g.setColor(Color.green);
\r
611 drawLine(g, xstart, ystart, xend, yend);
\r
614 else if (!depthcue && !bymolecule)
\r
616 g.setColor(tmpBond.startCol);
\r
617 drawLine(g, xstart, ystart, xmid, ymid);
\r
618 g.setColor(tmpBond.endCol);
\r
619 drawLine(g, xmid, ymid, xend, yend);
\r
623 drawLine(g, xstart, ystart, xend, yend);
\r
626 if (highlightBond1 != null && highlightBond1 == tmpBond)
\r
628 g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter());
\r
629 drawLine(g, xmid, ymid, xend, yend);
\r
632 if (highlightBond2 != null && highlightBond2 == tmpBond)
\r
634 g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter());
\r
635 drawLine(g, xstart, ystart, xmid, ymid);
\r
643 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
645 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
646 g.drawLine(x1, y1, x2, y2);
\r
647 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
648 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
650 g.setColor(g.getColor().brighter());
\r
651 g.drawLine(x1, y1, x2, y2);
\r
652 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
653 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
656 g.drawLine(x1, y1, x2, y2);
\r
660 public Dimension minimumsize() {
\r
664 public Dimension preferredsize() {
\r
668 public void keyPressed(KeyEvent evt)
\r
670 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
672 scale = (float) (scale * 1.1);
\r
673 redrawneeded = true;
\r
676 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
678 scale = (float) (scale * 0.9);
\r
679 redrawneeded = true;
\r
684 public void mousePressed(MouseEvent e)
\r
687 Atom fatom = findAtom(e.getX(), e.getY());
\r
690 fatom.isSelected = !fatom.isSelected;
\r
692 redrawneeded = true;
\r
694 if (foundchain != -1)
\r
696 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
697 if (chain == mainchain)
\r
699 if (fatom.alignmentMapping != -1)
\r
701 if (highlightRes == null)
\r
702 highlightRes = new Vector();
\r
704 if (highlightRes.contains(fatom.alignmentMapping+""))
\r
705 highlightRes.remove(fatom.alignmentMapping + "");
\r
707 highlightRes.add(fatom.alignmentMapping + "");
\r
720 public void mouseMoved(MouseEvent e)
\r
723 if(highlightBond1!=null)
\r
725 highlightBond1.at2.isSelected = false;
\r
726 highlightBond2.at1.isSelected = false;
\r
727 highlightBond1 = null;
\r
728 highlightBond2 = null;
\r
731 Atom fatom = findAtom(e.getX(), e.getY());
\r
733 PDBChain chain = null;
\r
736 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
737 if(chain == mainchain)
\r
739 highlightSeqcanvas( fatom.alignmentMapping );
\r
745 this.setToolTipText(chain.id+":"+ fatom.resNumber+" "+ fatom.resName);
\r
748 highlightSeqcanvas( -1);
\r
749 this.setToolTipText(null);
\r
754 void highlightSeqcanvas(int pos)
\r
756 SearchResults searchResults = new SearchResults();
\r
757 if(highlightRes!=null)
\r
759 for (int i = 0; i < highlightRes.size(); i++)
\r
761 int a = Integer.parseInt(highlightRes.elementAt(
\r
764 searchResults.addResult(sequence, a, a);
\r
770 searchResults.addResult(sequence, pos+1, pos+1);
\r
773 seqcanvas.highlightSearchResults(searchResults);
\r
777 public void mouseClicked(MouseEvent e) { }
\r
779 public void mouseEntered(MouseEvent e) { }
\r
781 public void mouseExited(MouseEvent e) { }
\r
783 public void mouseDragged(MouseEvent evt)
\r
785 int x = evt.getX();
\r
786 int y = evt.getY();
\r
791 MCMatrix objmat = new MCMatrix(3, 3);
\r
792 objmat.setIdentity();
\r
794 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
795 objmat.rotatez((float) ((mx - omx)));
\r
797 objmat.rotatex((float) ((my - omy)));
\r
798 objmat.rotatey((float) ((omx - mx)));
\r
802 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
803 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
805 for (int i = 0; i < bonds.size(); i++) {
\r
806 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
808 //Translate the bond so the centre is 0,0,0
\r
809 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
811 //Now apply the rotation matrix
\r
812 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
813 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
815 //Now translate back again
\r
816 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
827 redrawneeded = true;
\r
832 public void mouseReleased(MouseEvent evt)
\r
838 void drawLabels(Graphics g) {
\r
840 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
842 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
844 if (chain.isVisible)
\r
846 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
848 for (int i = 0; i < bonds.size(); i++)
\r
850 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
852 if (tmpBond.at1.isSelected)
\r
854 labelAtom(g, tmpBond, 1);
\r
857 if (tmpBond.at2.isSelected)
\r
860 labelAtom(g, tmpBond, 2);
\r
867 public void labelAtom(Graphics g, Bond b, int n) {
\r
869 g.setColor(Color.red);
\r
872 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
874 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
875 (getHeight() / 2));
\r
877 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
881 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
883 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
884 (getHeight() / 2));
\r
886 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
890 int foundchain = -1;
\r
891 public Atom findAtom(int x, int y) {
\r
896 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
898 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
902 if (chain.isVisible)
\r
904 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
906 for (int i = 0; i < bonds.size(); i++)
\r
908 tmpBond = (Bond) bonds.elementAt(i);
\r
910 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
913 if (Math.abs(truex - x) <= 2)
\r
915 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
916 (getHeight() / 2));
\r
918 if (Math.abs(truey - y) <= 2)
\r
920 fatom = tmpBond.at1;
\r
927 // Still here? Maybe its the last bond
\r
929 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
932 if (Math.abs(truex - x) <= 2)
\r
934 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
935 (getHeight() / 2));
\r
937 if (Math.abs(truey - y) <= 2)
\r
939 fatom = tmpBond.at2;
\r
947 if (fatom != null) //)&& chain.ds != null)
\r
949 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
956 Bond highlightBond1, highlightBond2;
\r
957 public void highlightRes(int ii)
\r
959 if( !seqColoursReady )
\r
962 if (highlightRes != null
\r
963 && highlightRes.contains((ii-1) + ""))
\r
970 for(index=0; index<mainchain.bonds.size(); index++)
\r
972 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
973 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
975 if (highlightBond1 != null)
\r
976 highlightBond1.at2.isSelected = false;
\r
978 if (highlightBond2 != null)
\r
979 highlightBond2.at1.isSelected = false;
\r
981 highlightBond1 = null;
\r
982 highlightBond2 = null;
\r
986 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
987 highlightBond1.at2.isSelected = true;
\r
990 if (index != mainchain.bonds.size())
\r
992 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
993 highlightBond2.at1.isSelected = true;
\r
1000 redrawneeded = true;
\r
1004 public void setAllchainsVisible(boolean b)
\r
1006 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
1008 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
1009 chain.isVisible = b;
\r
1011 mainchain.isVisible = true;
\r