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
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
80 jalview.appletgui.FeatureRenderer fr;
\r
82 public AppletPDBCanvas(jalview.appletgui.SeqCanvas seqcanvas, Sequence seq)
\r
84 this.seqcanvas = seqcanvas;
\r
85 this.sequence = seq;
\r
87 seqcanvas.setPDBCanvas(this);
\r
88 addKeyListener(new KeyAdapter()
\r
91 public void keyPressed(KeyEvent evt)
\r
99 public void setPDBFile(PDBfile pdb)
\r
107 AlignSeq maxAlignseq = null;;
\r
109 for (int i = 0; i < pdb.chains.size(); i++)
\r
112 mappingDetails.append("\n\nPDB Sequence is :\nSequence = " + ((PDBChain) pdb.chains.elementAt(i)).sequence.getSequence());
\r
113 mappingDetails.append("\nNo of residues = " + ((PDBChain) pdb.chains.elementAt(i)).residues.size()+"\n\n");
\r
115 // Now lets compare the sequences to get
\r
116 // the start and end points.
\r
117 // Align the sequence to the pdb
\r
118 AlignSeq as = new AlignSeq(sequence,
\r
119 ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
\r
120 as.calcScoreMatrix();
\r
121 as.traceAlignment();
\r
122 PrintStream ps = new PrintStream(System.out)
\r
124 public void print(String x) {
\r
125 mappingDetails.append(x);
\r
127 public void println()
\r
129 mappingDetails.append("\n");
\r
133 as.printAlignment(ps);
\r
135 if (as.maxscore > max) {
\r
139 pdbstart = as.seq2start;
\r
140 pdbend = as.seq2end;
\r
141 seqstart = as.seq1start + sequence.getStart()-1;
\r
142 seqend = as.seq1end + sequence.getEnd()-1;
\r
146 mappingDetails.append("\nPDB start/end " + pdbstart + " " + pdbend);
\r
147 mappingDetails.append("\nSEQ start/end "+ seqstart + " " + seqend);
\r
150 mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
\r
152 mainchain.pdbstart = pdbstart;
\r
153 mainchain.pdbend = pdbend;
\r
154 mainchain.seqstart = seqstart;
\r
155 mainchain.seqend = seqend;
\r
156 mainchain.isVisible = true;
\r
157 mainchain.makeExactMapping(maxAlignseq, sequence);
\r
160 this.prefsize = new Dimension(getSize().width, getSize().height);
\r
162 //Initialize the matrices to identity
\r
163 for (int i = 0; i < 3; i++) {
\r
164 for (int j = 0; j < 3; j++) {
\r
166 idmat.addElement(i, j, 0);
\r
167 objmat.addElement(i, j, 0);
\r
169 idmat.addElement(i, j, 1);
\r
170 objmat.addElement(i, j, 1);
\r
175 addMouseMotionListener(this);
\r
176 addMouseListener(this);
\r
184 scale = findScale();
\r
188 Vector visiblebonds;
\r
191 seqColoursReady = false;
\r
192 // Sort the bonds by z coord
\r
193 visiblebonds = new Vector();
\r
195 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
197 if ( ( (PDBChain) pdb.chains.elementAt(ii)).isVisible)
\r
199 Vector tmp = ( (PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
201 for (int i = 0; i < tmp.size(); i++)
\r
203 visiblebonds.addElement(tmp.elementAt(i));
\r
207 updateSeqColours();
\r
208 seqColoursReady = true;
\r
209 redrawneeded = true;
\r
214 public void findWidth() {
\r
215 float[] max = new float[3];
\r
216 float[] min = new float[3];
\r
218 max[0] = (float) -1e30;
\r
219 max[1] = (float) -1e30;
\r
220 max[2] = (float) -1e30;
\r
222 min[0] = (float) 1e30;
\r
223 min[1] = (float) 1e30;
\r
224 min[2] = (float) 1e30;
\r
226 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
227 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
228 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
230 for (int i = 0; i < bonds.size(); i++) {
\r
231 Bond tmp = (Bond) bonds.elementAt(i);
\r
233 if (tmp.start[0] >= max[0]) {
\r
234 max[0] = tmp.start[0];
\r
237 if (tmp.start[1] >= max[1]) {
\r
238 max[1] = tmp.start[1];
\r
241 if (tmp.start[2] >= max[2]) {
\r
242 max[2] = tmp.start[2];
\r
245 if (tmp.start[0] <= min[0]) {
\r
246 min[0] = tmp.start[0];
\r
249 if (tmp.start[1] <= min[1]) {
\r
250 min[1] = tmp.start[1];
\r
253 if (tmp.start[2] <= min[2]) {
\r
254 min[2] = tmp.start[2];
\r
257 if (tmp.end[0] >= max[0]) {
\r
258 max[0] = tmp.end[0];
\r
261 if (tmp.end[1] >= max[1]) {
\r
262 max[1] = tmp.end[1];
\r
265 if (tmp.end[2] >= max[2]) {
\r
266 max[2] = tmp.end[2];
\r
269 if (tmp.end[0] <= min[0]) {
\r
270 min[0] = tmp.end[0];
\r
273 if (tmp.end[1] <= min[1]) {
\r
274 min[1] = tmp.end[1];
\r
277 if (tmp.end[2] <= min[2]) {
\r
278 min[2] = tmp.end[2];
\r
284 width[0] = (float) Math.abs(max[0] - min[0]);
\r
285 width[1] = (float) Math.abs(max[1] - min[1]);
\r
286 width[2] = (float) Math.abs(max[2] - min[2]);
\r
288 maxwidth = width[0];
\r
290 if (width[1] > width[0]) {
\r
291 maxwidth = width[1];
\r
294 if (width[2] > width[1]) {
\r
295 maxwidth = width[2];
\r
298 // System.out.println("Maxwidth = " + maxwidth);
\r
301 public float findScale() {
\r
306 if (getSize().width != 0) {
\r
307 width = getSize().width;
\r
308 height = getSize().height;
\r
310 width = prefsize.width;
\r
311 height = prefsize.height;
\r
314 if (width < height) {
\r
320 return (float) (dim / (1.5d * maxwidth));
\r
323 public void findCentre() {
\r
330 //Find centre coordinate
\r
331 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
332 if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) {
\r
333 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
335 bsize += bonds.size();
\r
337 for (int i = 0; i < bonds.size(); i++) {
\r
338 xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] +
\r
339 ((Bond) bonds.elementAt(i)).end[0];
\r
341 ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] +
\r
342 ((Bond) bonds.elementAt(i)).end[1];
\r
344 ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] +
\r
345 ((Bond) bonds.elementAt(i)).end[2];
\r
350 centre[0] = xtot / (2 * (float) bsize);
\r
351 centre[1] = ytot / (2 * (float) bsize);
\r
352 centre[2] = ztot / (2 * (float) bsize);
\r
355 public void paint(Graphics g)
\r
360 g.setColor(Color.white);
\r
361 g.fillRect(0,0,getSize().width, getSize().height);
\r
362 g.setColor(Color.black);
\r
363 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
364 g.drawString("Error loading PDB data!!", 50, getSize().height/2);
\r
368 if( !seqColoursReady )
\r
370 g.setColor(Color.black);
\r
371 g.setFont(new Font("Verdana", Font.BOLD, 14));
\r
372 g.drawString("Fetching PDB data...", 50, getSize().height/2);
\r
378 //Only create the image at the beginning -
\r
379 //this saves much memory usage
\r
380 if ((img == null) || (prefsize.width != getSize().width) ||
\r
381 (prefsize.height != getSize().height)) {
\r
383 try{ prefsize.width = getSize().width;
\r
384 prefsize.height = getSize().height;
\r
386 scale = findScale();
\r
387 img = createImage(prefsize.width, prefsize.height);
\r
388 ig = img.getGraphics();
\r
390 redrawneeded = true;
\r
391 }catch(Exception ex)
\r
393 ex.printStackTrace();
\r
400 drawAll(ig, prefsize.width, prefsize.height);
\r
401 redrawneeded = false;
\r
403 if(appletToolTip!=null)
\r
405 ig.setColor(Color.red);
\r
406 ig.drawString(appletToolTip, toolx, tooly);
\r
409 g.drawImage(img, 0, 0, this);
\r
414 public void drawAll(Graphics g, int width, int height)
\r
416 ig.setColor(Color.black);
\r
417 ig.fillRect(0, 0, width, height);
\r
422 void setColours(jalview.schemes.ColourSchemeI cs)
\r
424 bysequence = false;
\r
425 pdb.setColours(cs);
\r
426 redrawneeded = true;
\r
429 public void updateSeqColours()
\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
449 int findTrueIndex(int pos)
\r
451 // returns the alignment position for a residue
\r
452 int j = sequence.getStart();
\r
455 while ( (i < sequence.getLength()) && (j <= sequence.getEnd()) && (j <= pos+1))
\r
457 if (!jalview.util.Comparison.isGap(sequence.getCharAt(i)))
\r
468 if ( (j == sequence.getEnd()) && (j < pos))
\r
470 return sequence.getEnd() + 1;
\r
479 // This method has been taken out of PDBChain to allow
\r
480 // Applet and Application specific sequence renderers to be used
\r
481 void colourBySequence(PDBChain chain)
\r
483 boolean showFeatures = false;
\r
485 if(seqcanvas.getViewport().getShowSequenceFeatures())
\r
489 fr = new jalview.appletgui.FeatureRenderer(seqcanvas.getViewport());
\r
491 fr.transferSettings( seqcanvas.getFeatureRenderer());
\r
492 showFeatures = true;
\r
495 for (int i = 0; i < chain.bonds.size(); i++)
\r
497 Bond tmp = (Bond) chain.bonds.elementAt(i);
\r
498 tmp.startCol = Color.lightGray;
\r
499 tmp.endCol = Color.lightGray;
\r
500 if(chain!=mainchain)
\r
503 if ( (tmp.at1.resNumber >= ( (chain.offset + chain.pdbstart) - 1)) &&
\r
504 (tmp.at1.resNumber <= ( (chain.offset + chain.pdbend) - 1)))
\r
507 int index = findTrueIndex(tmp.at1.alignmentMapping);
\r
508 //sequence.findIndex(tmp.at1.alignmentMapping);
\r
511 tmp.startCol = seqcanvas.getSequenceRenderer().
\r
512 getResidueBoxColour( sequence, index);
\r
515 tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index);
\r
519 int index = findTrueIndex(tmp.at2.alignmentMapping);
\r
520 //sequence.findIndex( tmp.at2.alignmentMapping );
\r
523 tmp.endCol = seqcanvas.getSequenceRenderer().
\r
524 getResidueBoxColour( sequence, index);
\r
527 tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index);
\r
534 public void drawScene(Graphics g)
\r
539 zsort = new Zsort();
\r
541 zsort.Zsort(visiblebonds);
\r
546 for (int i = 0; i < visiblebonds.size(); i++)
\r
548 tmpBond = (Bond) visiblebonds.elementAt(i);
\r
551 xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
552 (getSize().width / 2));
\r
553 ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
554 (getSize().height / 2));
\r
556 xend = (int) (((tmpBond.end[0] - centre[0]) * scale) +
\r
557 (getSize().width / 2));
\r
558 yend = (int) (((tmpBond.end[1] - centre[1]) * scale) +
\r
559 (getSize().height / 2));
\r
561 xmid = (xend + xstart) / 2;
\r
562 ymid = (yend + ystart) / 2;
\r
564 if (depthcue && !bymolecule)
\r
566 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
567 g.setColor(tmpBond.startCol.darker().darker());
\r
568 drawLine(g, xstart, ystart, xmid, ymid);
\r
570 g.setColor(tmpBond.endCol.darker().darker());
\r
571 drawLine(g, xmid, ymid, xend, yend);
\r
572 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
573 g.setColor(tmpBond.startCol.darker());
\r
574 drawLine(g, xstart, ystart, xmid, ymid);
\r
576 g.setColor(tmpBond.endCol.darker());
\r
577 drawLine(g, xmid, ymid, xend, yend);
\r
579 g.setColor(tmpBond.startCol);
\r
580 drawLine(g, xstart, ystart, xmid, ymid);
\r
582 g.setColor(tmpBond.endCol);
\r
583 drawLine(g, xmid, ymid, xend, yend);
\r
586 } else if (depthcue && bymolecule) {
\r
587 if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) {
\r
588 g.setColor(Color.green.darker().darker());
\r
589 drawLine(g, xstart, ystart, xend, yend);
\r
590 } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) {
\r
591 g.setColor(Color.green.darker());
\r
592 drawLine(g, xstart, ystart, xend, yend);
\r
594 g.setColor(Color.green);
\r
595 drawLine(g, xstart, ystart, xend, yend);
\r
597 } else if (!depthcue && !bymolecule) {
\r
598 g.setColor(tmpBond.startCol);
\r
599 drawLine(g, xstart, ystart, xmid, ymid);
\r
600 g.setColor(tmpBond.endCol);
\r
601 drawLine(g, xmid, ymid, xend, yend);
\r
603 drawLine(g, xstart, ystart, xend, yend);
\r
606 if(highlightBond1!=null && highlightBond1==tmpBond)
\r
608 g.setColor(Color.white);
\r
609 drawLine(g, xmid, ymid, xend, yend);
\r
612 if(highlightBond2!=null && highlightBond2==tmpBond)
\r
614 g.setColor(Color.white);
\r
615 drawLine(g, xstart, ystart, xmid, ymid);
\r
621 public void drawLine(Graphics g, int x1, int y1, int x2, int y2) {
\r
623 if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) {
\r
624 g.drawLine(x1, y1, x2, y2);
\r
625 g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1);
\r
626 g.drawLine(x1, y1 - 1, x2, y2 - 1);
\r
628 g.setColor(g.getColor().brighter());
\r
629 g.drawLine(x1, y1, x2, y2);
\r
630 g.drawLine(x1 + 1, y1, x2 + 1, y2);
\r
631 g.drawLine(x1 - 1, y1, x2 - 1, y2);
\r
634 g.drawLine(x1, y1, x2, y2);
\r
638 public Dimension minimumsize() {
\r
642 public Dimension preferredsize() {
\r
646 public void doKeyPressed(KeyEvent evt)
\r
648 if (evt.getKeyCode() == KeyEvent.VK_UP)
\r
650 scale = (float) (scale * 1.1);
\r
651 redrawneeded = true;
\r
654 else if (evt.getKeyCode() == KeyEvent.VK_DOWN)
\r
656 scale = (float) (scale * 0.9);
\r
657 redrawneeded = true;
\r
662 public void mousePressed(MouseEvent e) {
\r
664 Atom fatom = findAtom(e.getX(), e.getY());
\r
667 fatom.isSelected = !fatom.isSelected;
\r
669 redrawneeded = true;
\r
671 if (foundchain != -1)
\r
673 PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
674 if (chain == mainchain)
\r
676 if (fatom.alignmentMapping != -1)
\r
678 if (highlightRes == null)
\r
679 highlightRes = new Vector();
\r
681 if (highlightRes.contains(fatom.alignmentMapping+"" + ""))
\r
682 highlightRes.removeElement(fatom.alignmentMapping + "");
\r
684 highlightRes.addElement(fatom.alignmentMapping + "");
\r
697 public void mouseMoved(MouseEvent e) {
\r
699 if(highlightBond1!=null)
\r
701 highlightBond1.at2.isSelected = false;
\r
702 highlightBond2.at1.isSelected = false;
\r
703 highlightBond1 = null;
\r
704 highlightBond2 = null;
\r
707 Atom fatom = findAtom(e.getX(), e.getY());
\r
709 PDBChain chain = null;
\r
712 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
713 if(chain == mainchain)
\r
715 highlightSeqcanvas( fatom.alignmentMapping );
\r
719 if (fatom != null) {
\r
723 appletToolTip = chain.id+":"+ fatom.resNumber+" "+ fatom.resName;
\r
724 redrawneeded = true;
\r
727 highlightSeqcanvas( -1);
\r
728 appletToolTip = null;
\r
729 redrawneeded = true;
\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
761 public void mouseEntered(MouseEvent e) {
\r
764 public void mouseExited(MouseEvent e) {
\r
767 public void mouseDragged(MouseEvent evt) {
\r
768 int x = evt.getX();
\r
769 int y = evt.getY();
\r
773 MCMatrix objmat = new MCMatrix(3, 3);
\r
774 objmat.setIdentity();
\r
776 if ((evt.getModifiers() & Event.META_MASK) != 0) {
\r
777 objmat.rotatez((float) ((mx - omx)));
\r
779 objmat.rotatex((float) ((my - omy)));
\r
780 objmat.rotatey((float) ((omx - mx)));
\r
784 for (int ii = 0; ii < pdb.chains.size(); ii++) {
\r
785 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
787 for (int i = 0; i < bonds.size(); i++) {
\r
788 Bond tmpBond = (Bond) bonds.elementAt(i);
\r
790 //Translate the bond so the centre is 0,0,0
\r
791 tmpBond.translate(-centre[0], -centre[1], -centre[2]);
\r
793 //Now apply the rotation matrix
\r
794 tmpBond.start = objmat.vectorMultiply(tmpBond.start);
\r
795 tmpBond.end = objmat.vectorMultiply(tmpBond.end);
\r
797 //Now translate back again
\r
798 tmpBond.translate(centre[0], centre[1], centre[2]);
\r
809 redrawneeded = true;
\r
814 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
852 int xstart = (int) (((b.start[0] - centre[0]) * scale) +
\r
853 (getSize().width / 2));
\r
854 int ystart = (int) (((b.start[1] - centre[1]) * scale) +
\r
855 (getSize().height / 2));
\r
857 g.setColor(Color.red);
\r
858 g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
\r
862 int xstart = (int) (((b.end[0] - centre[0]) * scale) +
\r
863 (getSize().width / 2));
\r
864 int ystart = (int) (((b.end[1] - centre[1]) * scale) +
\r
865 (getSize().height / 2));
\r
867 g.setColor(Color.red);
\r
868 g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
\r
872 int foundchain = -1;
\r
873 public Atom findAtom(int x, int y) {
\r
878 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
880 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
884 if (chain.isVisible)
\r
886 Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
\r
888 for (int i = 0; i < bonds.size(); i++)
\r
890 tmpBond = (Bond) bonds.elementAt(i);
\r
892 truex = (int) (((tmpBond.start[0] - centre[0]) * scale) +
\r
893 (getSize().width / 2));
\r
895 if (Math.abs(truex - x) <= 2)
\r
897 int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) +
\r
898 (getSize().height / 2));
\r
900 if (Math.abs(truey - y) <= 2)
\r
902 fatom = tmpBond.at1;
\r
909 // Still here? Maybe its the last bond
\r
911 truex = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) +
\r
912 (getSize().width / 2));
\r
914 if (Math.abs(truex - x) <= 2)
\r
916 int truey = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) +
\r
917 (getSize().height / 2));
\r
919 if (Math.abs(truey - y) <= 2)
\r
921 fatom = tmpBond.at2;
\r
929 if (fatom != null) //)&& chain.ds != null)
\r
931 chain = (PDBChain) pdb.chains.elementAt(foundchain);
\r
938 public void update(Graphics g)
\r
943 public void highlightRes(int ii)
\r
945 if(!seqColoursReady)
\r
948 if (highlightRes != null
\r
949 && highlightRes.contains((ii-1) + ""))
\r
956 for(index=0; index<mainchain.bonds.size(); index++)
\r
958 tmpBond = (Bond) mainchain.bonds.elementAt(index);
\r
959 if (tmpBond.at1.alignmentMapping == ii - 1)
\r
961 if (highlightBond1 != null)
\r
962 highlightBond1.at2.isSelected = false;
\r
964 if (highlightBond2 != null)
\r
965 highlightBond2.at1.isSelected = false;
\r
967 highlightBond1 = null;
\r
968 highlightBond2 = null;
\r
972 highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
\r
973 highlightBond1.at2.isSelected = true;
\r
976 if (index != mainchain.bonds.size())
\r
978 highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
\r
979 highlightBond2.at1.isSelected = true;
\r
986 redrawneeded = true;
\r
991 public void setAllchainsVisible(boolean b)
\r
993 for (int ii = 0; ii < pdb.chains.size(); ii++)
\r
995 PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
\r
996 chain.isVisible = b;
\r
998 mainchain.isVisible = true;
\r