*/
package MCview;
-import jalview.analysis.AlignSeq;
-import jalview.appletgui.AlignmentPanel;
-import jalview.appletgui.FeatureRenderer;
-import jalview.appletgui.SequenceRenderer;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SequenceI;
-import jalview.structure.AtomSpec;
-import jalview.structure.StructureListener;
-import jalview.structure.StructureMapping;
-import jalview.structure.StructureSelectionManager;
-import jalview.util.MessageManager;
-
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.util.List;
import java.util.Vector;
+import jalview.analysis.AlignSeq;
+import jalview.appletgui.AlignmentPanel;
+import jalview.appletgui.FeatureRenderer;
+import jalview.appletgui.SequenceRenderer;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.structure.AtomSpec;
+import jalview.structure.StructureListener;
+import jalview.structure.StructureMapping;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.MessageManager;
+
public class AppletPDBCanvas extends Panel implements MouseListener,
MouseMotionListener, StructureListener
{
PDBChain mainchain;
- Vector highlightRes;
+ Vector<String> highlightRes;
boolean pdbAction = false;
scale = findScale();
}
- Vector visiblebonds;
+ Vector<Bond> visiblebonds;
void setupBonds()
{
seqColoursReady = false;
// Sort the bonds by z coord
- visiblebonds = new Vector();
+ visiblebonds = new Vector<Bond>();
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
if (pdb.chains.elementAt(ii).isVisible)
{
- Vector tmp = pdb.chains.elementAt(ii).bonds;
+ Vector<Bond> tmp = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < tmp.size(); i++)
{
{
if (pdb.chains.elementAt(ii).isVisible)
{
- Vector bonds = pdb.chains.elementAt(ii).bonds;
+ Vector<Bond> bonds = pdb.chains.elementAt(ii).bonds;
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond tmp : bonds)
{
- Bond tmp = (Bond) bonds.elementAt(i);
-
if (tmp.start[0] >= max[0])
{
max[0] = tmp.start[0];
{
if (pdb.chains.elementAt(ii).isVisible)
{
- Vector bonds = pdb.chains.elementAt(ii).bonds;
+ Vector<Bond> bonds = pdb.chains.elementAt(ii).bonds;
bsize += bonds.size();
- for (int i = 0; i < bonds.size(); i++)
+ for (Bond b : 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 + b.start[0] + b.end[0];
+ ytot = ytot + b.start[1] + b.end[1];
+ ztot = ztot + b.start[2] + b.end[2];
}
}
}
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)
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) + (getSize().width / 2));
ystart = (int) (((centre[1] - tmpBond.start[1]) * scale) + (getSize().height / 2));
{
if (highlightRes == null)
{
- highlightRes = new Vector();
+ highlightRes = new Vector<String>();
}
- if (highlightRes.contains(fatom.alignmentMapping + "" + ""))
+ final String atomString = Integer
+ .toString(fatom.alignmentMapping);
+ if (highlightRes.contains(atomString))
{
- highlightRes.removeElement(fatom.alignmentMapping + "");
+ highlightRes.removeElement(atomString);
}
else
{
- highlightRes.addElement(fatom.alignmentMapping + "");
+ highlightRes.addElement(atomString);
}
}
}
}
// Alter the bonds
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.chains)
{
- Vector bonds = 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]);
void drawLabels(Graphics g)
{
- for (int ii = 0; ii < pdb.chains.size(); ii++)
+ for (PDBChain chain : pdb.chains)
{
- PDBChain chain = pdb.chains.elementAt(ii);
-
if (chain.isVisible)
{
- Vector bonds = 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);
if (tmpBond.at2.isSelected)
{
-
labelAtom(g, tmpBond, 2);
}
}
if (chain.isVisible)
{
- Vector bonds = pdb.chains.elementAt(ii).bonds;
+ Vector<Bond> bonds = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < bonds.size(); i++)
{
- tmpBond = (Bond) bonds.elementAt(i);
+ tmpBond = bonds.elementAt(i);
truex = (int) (((tmpBond.start[0] - centre[0]) * scale) + (getSize().width / 2));
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)
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;
}
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)
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;
}
}
+ @Override
+ public boolean isListeningFor(SequenceI seq)
+ {
+ if (sequence != null)
+ {
+ for (SequenceI s : sequence)
+ {
+ if (s == seq)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}