X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBCanvas.java;h=6f76a25397c214875393eb0c69ccd1fd9cce8cc8;hb=a4780f236ded1ae07824254bca59b2aa0ea539ba;hp=ccc359bed150402cb20c756209aa32282cd7b2e7;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git
diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java
old mode 100755
new mode 100644
index ccc359b..6f76a25
--- a/src/MCview/PDBCanvas.java
+++ b/src/MCview/PDBCanvas.java
@@ -1,35 +1,56 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
*
- * This program 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.
+ * 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.
+ *
+ * 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 this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * 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.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.*;
+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
@@ -108,7 +129,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
boolean seqColoursReady = false;
- jalview.gui.FeatureRenderer fr;
+ jalview.renderer.seqfeatures.FeatureRenderer fr;
Color backgroundColour = Color.black;
@@ -125,14 +146,16 @@ public class PDBCanvas extends JPanel implements MouseListener,
this.pdbentry = pdbentry;
this.sequence = seq;
- ssm = StructureSelectionManager.getStructureSelectionManager();
+ ssm = ap.av.getStructureSelectionManager();
try
{
pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol);
if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE))
+ {
pdbentry.setFile("INLINE" + pdb.id);
+ }
} catch (Exception ex)
{
@@ -165,17 +188,17 @@ public class PDBCanvas extends JPanel implements MouseListener,
{
mappingDetails.append("\n\nPDB Sequence is :\nSequence = "
- + ((PDBChain) pdb.chains.elementAt(i)).sequence
+ + pdb.chains.elementAt(i).sequence
.getSequenceAsString());
mappingDetails.append("\nNo of residues = "
- + ((PDBChain) pdb.chains.elementAt(i)).residues.size()
+ + pdb.chains.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");
+ AlignSeq as = new AlignSeq(sequence,
+ pdb.chains.elementAt(i).sequence, "pep");
as.calcScoreMatrix();
as.traceAlignment();
PrintStream ps = new PrintStream(System.out)
@@ -208,7 +231,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
mappingDetails.append("\nSEQ start/end " + seqstart + " " + seqend);
}
- mainchain = (PDBChain) pdb.chains.elementAt(maxchain);
+ mainchain = pdb.chains.elementAt(maxchain);
mainchain.pdbstart = pdbstart;
mainchain.pdbend = pdbend;
@@ -252,9 +275,9 @@ public class PDBCanvas extends JPanel implements MouseListener,
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (pdb.chains.elementAt(ii).isVisible)
{
- Vector tmp = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector tmp = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < tmp.size(); i++)
{
@@ -284,9 +307,9 @@ public class PDBCanvas extends JPanel implements MouseListener,
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (pdb.chains.elementAt(ii).isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector bonds = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < bonds.size(); i++)
{
@@ -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];
@@ -419,9 +442,9 @@ public class PDBCanvas extends JPanel implements MouseListener,
// Find centre coordinate
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- if (((PDBChain) pdb.chains.elementAt(ii)).isVisible)
+ if (pdb.chains.elementAt(ii).isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector bonds = pdb.chains.elementAt(ii).bonds;
bsize += bonds.size();
@@ -518,7 +541,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)
{
@@ -535,7 +558,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
{
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- chain = (PDBChain) pdb.chains.elementAt(ii);
+ chain = pdb.chains.elementAt(ii);
for (int i = 0; i < chain.bonds.size(); i++)
{
@@ -749,7 +772,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
repaint();
if (foundchain != -1)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ PDBChain chain = pdb.chains.elementAt(foundchain);
if (chain == mainchain)
{
if (fatom.alignmentMapping != -1)
@@ -795,7 +818,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
PDBChain chain = null;
if (foundchain != -1)
{
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ chain = pdb.chains.elementAt(foundchain);
if (chain == mainchain)
{
mouseOverStructure(fatom.resNumber, chain.id);
@@ -838,18 +861,18 @@ 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++)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector bonds = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < bonds.size(); i++)
{
@@ -890,11 +913,11 @@ public class PDBCanvas extends JPanel implements MouseListener,
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ PDBChain chain = pdb.chains.elementAt(ii);
if (chain.isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector bonds = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < bonds.size(); i++)
{
@@ -946,13 +969,13 @@ public class PDBCanvas extends JPanel implements MouseListener,
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ PDBChain chain = pdb.chains.elementAt(ii);
int truex;
Bond tmpBond = null;
if (chain.isVisible)
{
- Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds;
+ Vector bonds = pdb.chains.elementAt(ii).bonds;
for (int i = 0; i < bonds.size(); i++)
{
@@ -993,7 +1016,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
if (fatom != null) // )&& chain.ds != null)
{
- chain = (PDBChain) pdb.chains.elementAt(foundchain);
+ chain = pdb.chains.elementAt(foundchain);
}
}
@@ -1058,7 +1081,7 @@ public class PDBCanvas extends JPanel implements MouseListener,
{
for (int ii = 0; ii < pdb.chains.size(); ii++)
{
- PDBChain chain = (PDBChain) pdb.chains.elementAt(ii);
+ PDBChain chain = pdb.chains.elementAt(ii);
chain.isVisible = b;
}
mainchain.isVisible = true;
@@ -1068,9 +1091,10 @@ public class PDBCanvas extends JPanel implements MouseListener,
// ////////////////////////////////
// /StructureListener
- public String getPdbFile()
+ public String[] getPdbFile()
{
- return pdbentry.getFile();
+ return new String[]
+ { pdbentry.getFile() };
}
String lastMessage;
@@ -1078,7 +1102,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;
}
@@ -1087,19 +1113,42 @@ 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++)
@@ -1135,9 +1184,6 @@ public class PDBCanvas extends JPanel implements MouseListener,
break;
}
}
-
- redrawneeded = true;
- repaint();
}
public Color getColour(int atomIndex, int pdbResNum, String chain,
@@ -1157,4 +1203,11 @@ public class PDBCanvas extends JPanel implements MouseListener,
repaint();
}
+ @Override
+ public void releaseReferences(Object svl)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}