X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBCanvas.java;h=ab172f2cb8744b7c44b0c02f5adedce21c236557;hb=ed1529065c002bb837ea2572b00d1dfdceaa6050;hp=11caf9835458d0879804331c35fc5dd867432751;hpb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;p=jalview.git
diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java
index 11caf98..ab172f2 100644
--- a/src/MCview/PDBCanvas.java
+++ b/src/MCview/PDBCanvas.java
@@ -1,38 +1,62 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package MCview;
-import java.io.*;
-import java.util.*;
-
+import jalview.analysis.AlignSeq;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.FeatureRenderer;
+import jalview.gui.SequenceRenderer;
+import jalview.io.DataSourceType;
+import jalview.io.StructureFile;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.structure.AtomSpec;
+import jalview.structure.StructureListener;
+import jalview.structure.StructureMapping;
+import jalview.structure.StructureSelectionManager;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Event;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-import jalview.analysis.*;
-import jalview.datamodel.*;
-import jalview.gui.*;
-import jalview.structure.*;
-
-public class PDBCanvas extends JPanel implements MouseListener,
- MouseMotionListener, StructureListener
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.JPanel;
+import javax.swing.ToolTipManager;
+
+public class PDBCanvas extends JPanel
+ implements MouseListener, MouseMotionListener, StructureListener
{
boolean redrawneeded = true;
@@ -44,7 +68,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
int my = 0;
- public PDBfile pdb;
+ public StructureFile pdb;
PDBEntry pdbentry;
@@ -102,13 +126,13 @@ public class PDBCanvas extends JPanel implements MouseListener,
PDBChain mainchain;
- Vector highlightRes;
+ Vector highlightRes;
boolean pdbAction = false;
boolean seqColoursReady = false;
- jalview.gui.FeatureRenderer fr;
+ jalview.renderer.seqfeatures.FeatureRenderer fr;
Color backgroundColour = Color.black;
@@ -119,7 +143,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
String errorMessage;
void init(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
- AlignmentPanel ap, String protocol)
+ AlignmentPanel ap, DataSourceType protocol)
{
this.ap = ap;
this.pdbentry = pdbentry;
@@ -129,10 +153,13 @@ public class PDBCanvas extends JPanel implements MouseListener,
try
{
- pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol);
+ pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol,
+ ap.alignFrame);
- if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE))
- pdbentry.setFile("INLINE" + pdb.id);
+ if (protocol.equals(jalview.io.DataSourceType.PASTE))
+ {
+ pdbentry.setFile("INLINE" + pdb.getId());
+ }
} catch (Exception ex)
{
@@ -145,13 +172,13 @@ public class PDBCanvas extends JPanel implements MouseListener,
errorMessage = "Error loading file: " + pdbentry.getId();
return;
}
- pdbentry.setId(pdb.id);
+ pdbentry.setId(pdb.getId());
ssm.addStructureViewerListener(this);
colourBySequence();
- int max = -10;
+ float max = -10;
int maxchain = -1;
int pdbstart = 0;
int pdbend = 0;
@@ -161,30 +188,31 @@ public class PDBCanvas extends JPanel implements MouseListener,
// JUST DEAL WITH ONE SEQUENCE FOR NOW
SequenceI sequence = seq[0];
- for (int i = 0; i < pdb.chains.size(); i++)
+ for (int i = 0; i < pdb.getChains().size(); i++)
{
mappingDetails.append("\n\nPDB Sequence is :\nSequence = "
- + ((PDBChain) pdb.chains.elementAt(i)).sequence
+ + pdb.getChains().elementAt(i).sequence
.getSequenceAsString());
mappingDetails.append("\nNo of residues = "
- + ((PDBChain) pdb.chains.elementAt(i)).residues.size()
- + "\n\n");
+ + pdb.getChains().elementAt(i).residues.size() + "\n\n");
// Now lets compare the sequences to get
// the start and end points.
// Align the sequence to the pdb
AlignSeq as = new AlignSeq(sequence,
- ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep");
+ pdb.getChains().elementAt(i).sequence, "pep");
as.calcScoreMatrix();
as.traceAlignment();
PrintStream ps = new PrintStream(System.out)
{
+ @Override
public void print(String x)
{
mappingDetails.append(x);
}
+ @Override
public void println()
{
mappingDetails.append("\n");
@@ -208,7 +236,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
mappingDetails.append("\nSEQ start/end " + seqstart + " " + seqend);
}
- mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
+ mainchain = pdb.getChains().elementAt(maxchain);
mainchain.pdbstart = pdbstart;
mainchain.pdbend = pdbend;
@@ -224,6 +252,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
addKeyListener(new KeyAdapter()
{
+ @Override
public void keyPressed(KeyEvent evt)
{
keyPressed(evt);
@@ -242,23 +271,21 @@ public class PDBCanvas extends JPanel implements MouseListener,
ToolTipManager.sharedInstance().setDismissDelay(10000);
}
- Vector visiblebonds;
+ Vector visiblebonds;
void setupBonds()
{
seqColoursReady = false;
// Sort the bonds by z coord
- visiblebonds = new Vector();
+ visiblebonds = new Vector();
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.getChains())
{
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (chain.isVisible)
{
- Vector tmp = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < tmp.size(); i++)
+ for (Bond bond : chain.bonds)
{
- visiblebonds.addElement(tmp.elementAt(i));
+ visiblebonds.addElement(bond);
}
}
}
@@ -282,16 +309,12 @@ public class PDBCanvas extends JPanel implements MouseListener,
min[1] = (float) 1e30;
min[2] = (float) 1e30;
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.getChains())
{
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (chain.isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond tmp : chain.bonds)
{
- Bond tmp = (Bond) bonds.elementAt(i);
-
if (tmp.start[0] >= max[0])
{
max[0] = tmp.start[0];
@@ -360,9 +383,9 @@ public class PDBCanvas extends JPanel implements MouseListener,
* System.out.println("zmax " + max[2] + " min " + min[2]);
*/
- width[0] = (float) Math.abs(max[0] - min[0]);
- width[1] = (float) Math.abs(max[1] - min[1]);
- width[2] = (float) Math.abs(max[2] - min[2]);
+ width[0] = Math.abs(max[0] - min[0]);
+ width[1] = Math.abs(max[1] - min[1]);
+ width[2] = Math.abs(max[2] - min[2]);
maxwidth = width[0];
@@ -417,24 +440,17 @@ public class PDBCanvas extends JPanel implements MouseListener,
int bsize = 0;
// Find centre coordinate
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.getChains())
{
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (chain.isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- bsize += bonds.size();
+ bsize += chain.bonds.size();
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond bond : chain.bonds)
{
- xtot = xtot + ((Bond) bonds.elementAt(i)).start[0]
- + ((Bond) bonds.elementAt(i)).end[0];
-
- ytot = ytot + ((Bond) bonds.elementAt(i)).start[1]
- + ((Bond) bonds.elementAt(i)).end[1];
-
- ztot = ztot + ((Bond) bonds.elementAt(i)).start[2]
- + ((Bond) bonds.elementAt(i)).end[2];
+ xtot = xtot + bond.start[0] + bond.end[0];
+ ytot = ytot + bond.start[1] + bond.end[1];
+ ztot = ztot + bond.start[2] + bond.end[2];
}
}
}
@@ -444,6 +460,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
centre[2] = ztot / (2 * (float) bsize);
}
+ @Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
@@ -518,7 +535,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());
boolean showFeatures = false;
- if (ap.av.getShowSequenceFeatures())
+ if (ap.av.isShowSequenceFeatures())
{
if (fr == null)
{
@@ -530,16 +547,17 @@ public class PDBCanvas extends JPanel implements MouseListener,
showFeatures = true;
}
+ FeatureColourFinder finder = new FeatureColourFinder(fr);
PDBChain chain;
if (bysequence && pdb != null)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (int ii = 0; ii < pdb.getChains().size(); ii++)
{
- chain = (PDBChain) pdb.chains.elementAt(ii);
+ chain = pdb.getChains().elementAt(ii);
for (int i = 0; i < chain.bonds.size(); i++)
{
- Bond tmp = (Bond) chain.bonds.elementAt(i);
+ Bond tmp = chain.bonds.elementAt(i);
tmp.startCol = Color.lightGray;
tmp.endCol = Color.lightGray;
if (chain != mainchain)
@@ -557,23 +575,15 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (pos > 0)
{
pos = sequence[s].findIndex(pos);
- tmp.startCol = sr.getResidueBoxColour(sequence[s], pos);
- if (showFeatures)
- {
- tmp.startCol = fr.findFeatureColour(tmp.startCol,
- sequence[s], pos);
- }
+ tmp.startCol = sr.getResidueColour(sequence[s], pos,
+ finder);
}
pos = mapping[m].getSeqPos(tmp.at2.resNumber) - 1;
if (pos > 0)
{
pos = sequence[s].findIndex(pos);
- tmp.endCol = sr.getResidueBoxColour(sequence[s], pos);
- if (showFeatures)
- {
- tmp.endCol = fr.findFeatureColour(tmp.endCol,
- sequence[s], pos);
- }
+ tmp.endCol = sr.getResidueColour(sequence[s], pos,
+ finder);
}
}
@@ -595,19 +605,23 @@ public class PDBCanvas extends JPanel implements MouseListener,
zsort = new Zsort();
}
- zsort.Zsort(visiblebonds);
+ zsort.sort(visiblebonds);
}
Bond tmpBond = null;
for (int i = 0; i < visiblebonds.size(); i++)
{
- tmpBond = (Bond) visiblebonds.elementAt(i);
+ tmpBond = visiblebonds.elementAt(i);
- xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getWidth() / 2));
- ystart = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getHeight() / 2));
+ xstart = (int) (((tmpBond.start[0] - centre[0]) * scale)
+ + (getWidth() / 2));
+ ystart = (int) (((centre[1] - tmpBond.start[1]) * scale)
+ + (getHeight() / 2));
- xend = (int) (((tmpBond.end[0] - centre[0]) * scale) + (getWidth() / 2));
- yend = (int) (((centre[1] - tmpBond.end[1]) * scale) + (getHeight() / 2));
+ xend = (int) (((tmpBond.end[0] - centre[0]) * scale)
+ + (getWidth() / 2));
+ yend = (int) (((centre[1] - tmpBond.end[1]) * scale)
+ + (getHeight() / 2));
xmid = (xend + xstart) / 2;
ymid = (yend + ystart) / 2;
@@ -671,8 +685,8 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (highlightBond1 != null && highlightBond1 == tmpBond)
{
- g.setColor(tmpBond.endCol.brighter().brighter().brighter()
- .brighter());
+ g.setColor(
+ tmpBond.endCol.brighter().brighter().brighter().brighter());
drawLine(g, xmid, ymid, xend, yend);
}
@@ -737,6 +751,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
}
}
+ @Override
public void mousePressed(MouseEvent e)
{
pdbAction = true;
@@ -749,23 +764,25 @@ public class PDBCanvas extends JPanel implements MouseListener,
repaint();
if (foundchain != -1)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ PDBChain chain = pdb.getChains().elementAt(foundchain);
if (chain == mainchain)
{
if (fatom.alignmentMapping != -1)
{
if (highlightRes == null)
{
- highlightRes = new Vector();
+ highlightRes = new Vector();
}
- if (highlightRes.contains(fatom.alignmentMapping + ""))
+ final String atomString = Integer
+ .toString(fatom.alignmentMapping);
+ if (highlightRes.contains(atomString))
{
- highlightRes.remove(fatom.alignmentMapping + "");
+ highlightRes.remove(atomString);
}
else
{
- highlightRes.add(fatom.alignmentMapping + "");
+ highlightRes.add(atomString);
}
}
}
@@ -779,6 +796,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
dragging = false;
}
+ @Override
public void mouseMoved(MouseEvent e)
{
pdbAction = true;
@@ -795,7 +813,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
PDBChain chain = null;
if (foundchain != -1)
{
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ chain = pdb.getChains().elementAt(foundchain);
if (chain == mainchain)
{
mouseOverStructure(fatom.resNumber, chain.id);
@@ -804,8 +822,8 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (fatom != null)
{
- this.setToolTipText(chain.id + ":" + fatom.resNumber + " "
- + fatom.resName);
+ this.setToolTipText(
+ chain.id + ":" + fatom.resNumber + " " + fatom.resName);
}
else
{
@@ -814,18 +832,22 @@ public class PDBCanvas extends JPanel implements MouseListener,
}
}
+ @Override
public void mouseClicked(MouseEvent e)
{
}
+ @Override
public void mouseEntered(MouseEvent e)
{
}
+ @Override
public void mouseExited(MouseEvent e)
{
}
+ @Override
public void mouseDragged(MouseEvent evt)
{
int x = evt.getX();
@@ -838,23 +860,19 @@ public class PDBCanvas extends JPanel implements MouseListener,
if ((evt.getModifiers() & Event.META_MASK) != 0)
{
- objmat.rotatez((float) ((mx - omx)));
+ objmat.rotatez(((mx - omx)));
}
else
{
- objmat.rotatex((float) ((my - omy)));
- objmat.rotatey((float) ((omx - mx)));
+ objmat.rotatex(((my - omy)));
+ objmat.rotatey(((omx - mx)));
}
// Alter the bonds
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.getChains())
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond tmpBond : chain.bonds)
{
- Bond tmpBond = (Bond) bonds.elementAt(i);
-
// Translate the bond so the centre is 0,0,0
tmpBond.translate(-centre[0], -centre[1], -centre[2]);
@@ -879,6 +897,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
repaint();
}
+ @Override
public void mouseReleased(MouseEvent evt)
{
dragging = false;
@@ -888,18 +907,12 @@ public class PDBCanvas extends JPanel implements MouseListener,
void drawLabels(Graphics g)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.getChains())
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
-
if (chain.isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond tmpBond : chain.bonds)
{
- Bond tmpBond = (Bond) bonds.elementAt(i);
-
if (tmpBond.at1.isSelected)
{
labelAtom(g, tmpBond, 1);
@@ -907,7 +920,6 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (tmpBond.at2.isSelected)
{
-
labelAtom(g, tmpBond, 2);
}
}
@@ -921,16 +933,20 @@ public class PDBCanvas extends JPanel implements MouseListener,
g.setColor(Color.red);
if (n == 1)
{
- int xstart = (int) (((b.start[0] - centre[0]) * scale) + (getWidth() / 2));
- int ystart = (int) (((centre[1] - b.start[1]) * scale) + (getHeight() / 2));
+ int xstart = (int) (((b.start[0] - centre[0]) * scale)
+ + (getWidth() / 2));
+ int ystart = (int) (((centre[1] - b.start[1]) * scale)
+ + (getHeight() / 2));
g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart);
}
if (n == 2)
{
- int xstart = (int) (((b.end[0] - centre[0]) * scale) + (getWidth() / 2));
- int ystart = (int) (((centre[1] - b.end[1]) * scale) + (getHeight() / 2));
+ int xstart = (int) (((b.end[0] - centre[0]) * scale)
+ + (getWidth() / 2));
+ int ystart = (int) (((centre[1] - b.end[1]) * scale)
+ + (getHeight() / 2));
g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart);
}
@@ -944,25 +960,25 @@ public class PDBCanvas extends JPanel implements MouseListener,
foundchain = -1;
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (int ii = 0; ii < pdb.getChains().size(); ii++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ PDBChain chain = pdb.getChains().elementAt(ii);
int truex;
Bond tmpBond = null;
if (chain.isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
-
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond bond : chain.bonds)
{
- tmpBond = (Bond) bonds.elementAt(i);
+ tmpBond = bond;
- truex = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getWidth() / 2));
+ truex = (int) (((tmpBond.start[0] - centre[0]) * scale)
+ + (getWidth() / 2));
if (Math.abs(truex - x) <= 2)
{
- int truey = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getHeight() / 2));
+ int truey = (int) (((centre[1] - tmpBond.start[1]) * scale)
+ + (getHeight() / 2));
if (Math.abs(truey - y) <= 2)
{
@@ -975,11 +991,13 @@ public class PDBCanvas extends JPanel implements MouseListener,
// Still here? Maybe its the last bond
- truex = (int) (((tmpBond.end[0] - centre[0]) * scale) + (getWidth() / 2));
+ truex = (int) (((tmpBond.end[0] - centre[0]) * scale)
+ + (getWidth() / 2));
if (Math.abs(truex - x) <= 2)
{
- int truey = (int) (((tmpBond.end[1] - centre[1]) * scale) + (getHeight() / 2));
+ int truey = (int) (((tmpBond.end[1] - centre[1]) * scale)
+ + (getHeight() / 2));
if (Math.abs(truey - y) <= 2)
{
@@ -992,8 +1010,8 @@ public class PDBCanvas extends JPanel implements MouseListener,
}
if (fatom != null) // )&& chain.ds != null)
- {
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ { // dead code? value of chain is either overwritten or discarded
+ chain = pdb.getChains().elementAt(foundchain);
}
}
@@ -1018,7 +1036,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
Bond tmpBond;
for (index = 0; index < mainchain.bonds.size(); index++)
{
- tmpBond = (Bond) mainchain.bonds.elementAt(index);
+ tmpBond = mainchain.bonds.elementAt(index);
if (tmpBond.at1.alignmentMapping == ii - 1)
{
if (highlightBond1 != null)
@@ -1036,13 +1054,13 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (index > 0)
{
- highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
+ highlightBond1 = mainchain.bonds.elementAt(index - 1);
highlightBond1.at2.isSelected = true;
}
if (index != mainchain.bonds.size())
{
- highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
+ highlightBond2 = mainchain.bonds.elementAt(index);
highlightBond2.at1.isSelected = true;
}
@@ -1056,9 +1074,9 @@ public class PDBCanvas extends JPanel implements MouseListener,
public void setAllchainsVisible(boolean b)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (int ii = 0; ii < pdb.getChains().size(); ii++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ PDBChain chain = pdb.getChains().elementAt(ii);
chain.isVisible = b;
}
mainchain.isVisible = true;
@@ -1068,10 +1086,10 @@ public class PDBCanvas extends JPanel implements MouseListener,
// ////////////////////////////////
// /StructureListener
- public String[] getPdbFile()
+ @Override
+ public String[] getStructureFiles()
{
- return new String[]
- { pdbentry.getFile() };
+ return new String[] { pdbentry.getFile() };
}
String lastMessage;
@@ -1079,7 +1097,9 @@ public class PDBCanvas extends JPanel implements MouseListener,
public void mouseOverStructure(int pdbResNum, String chain)
{
if (lastMessage == null || !lastMessage.equals(pdbResNum + chain))
+ {
ssm.mouseOverStructure(pdbResNum, chain, pdbentry.getFile());
+ }
lastMessage = pdbResNum + chain;
}
@@ -1088,24 +1108,47 @@ public class PDBCanvas extends JPanel implements MouseListener,
StringBuffer eval = new StringBuffer();
- public void highlightAtom(int atomIndex, int pdbResNum, String chain,
- String pdbfile)
+ /**
+ * Highlight the specified atoms in the structure.
+ *
+ * @param atoms
+ */
+ @Override
+ public void highlightAtoms(List atoms)
{
if (!seqColoursReady)
{
return;
}
- if (highlightRes != null && highlightRes.contains((atomIndex - 1) + ""))
+ for (AtomSpec atom : atoms)
{
- return;
+ int atomIndex = atom.getAtomIndex();
+ if (highlightRes != null
+ && highlightRes.contains((atomIndex - 1) + ""))
+ {
+ continue;
+ }
+
+ highlightAtom(atomIndex);
}
+ redrawneeded = true;
+ repaint();
+ }
+
+ /**
+ * Highlight the atom at the specified index.
+ *
+ * @param atomIndex
+ */
+ protected void highlightAtom(int atomIndex)
+ {
int index = -1;
Bond tmpBond;
for (index = 0; index < mainchain.bonds.size(); index++)
{
- tmpBond = (Bond) mainchain.bonds.elementAt(index);
+ tmpBond = mainchain.bonds.elementAt(index);
if (tmpBond.at1.atomIndex == atomIndex)
{
if (highlightBond1 != null)
@@ -1123,22 +1166,19 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (index > 0)
{
- highlightBond1 = (Bond) mainchain.bonds.elementAt(index - 1);
+ highlightBond1 = mainchain.bonds.elementAt(index - 1);
highlightBond1.at2.isSelected = true;
}
if (index != mainchain.bonds.size())
{
- highlightBond2 = (Bond) mainchain.bonds.elementAt(index);
+ highlightBond2 = mainchain.bonds.elementAt(index);
highlightBond2.at1.isSelected = true;
}
break;
}
}
-
- redrawneeded = true;
- repaint();
}
public Color getColour(int atomIndex, int pdbResNum, String chain,
@@ -1151,6 +1191,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
// return new Color(viewer.getAtomArgb(atomIndex));
}
+ @Override
public void updateColours(Object source)
{
colourBySequence();
@@ -1165,4 +1206,19 @@ public class PDBCanvas extends JPanel implements MouseListener,
}
+ @Override
+ public boolean isListeningFor(SequenceI seq)
+ {
+ if (sequence != null)
+ {
+ for (SequenceI s : sequence)
+ {
+ if (s == seq)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}