/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
* Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
* This file is part of Jalview.
import java.net.*;
import java.util.*;
-import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
-import org.jmol.api.JmolViewer;
-
import jalview.analysis.*;
import jalview.api.SequenceStructureBinding;
import jalview.bin.JalviewLite;
annotationPanelMenuItem.setState(viewport.showAnnotation);
displayNonconservedMenuItem.setState(viewport.getShowunconserved());
+ followMouseOverFlag.setState(viewport.getFollowHighlight());
seqLimits.setState(viewport.showJVSuffix);
}
else if (source == alProperties)
{
- StringBuffer contents = new StringBuffer();
-
- float avg = 0;
- int min = Integer.MAX_VALUE, max = 0;
- for (int i = 0; i < viewport.alignment.getHeight(); i++)
- {
- int size = viewport.alignment.getSequenceAt(i).getEnd()
- - viewport.alignment.getSequenceAt(i).getStart();
- avg += size;
- if (size > max)
- max = size;
- if (size < min)
- min = size;
- }
- avg = avg / (float) viewport.alignment.getHeight();
-
- contents.append("\nSequences: " + viewport.alignment.getHeight());
- contents.append("\nMinimum Sequence Length: " + min);
- contents.append("\nMaximum Sequence Length: " + max);
- contents.append("\nAverage Length: " + (int) avg);
-
- if (((Alignment) viewport.alignment).alignmentProperties != null)
- {
- Hashtable props = ((Alignment) viewport.alignment).alignmentProperties;
- Enumeration en = props.keys();
- while (en.hasMoreElements())
- {
- String key = en.nextElement().toString();
- contents.append("\n" + key + "\t" + props.get(key));
- }
- }
-
+ StringBuffer contents = new jalview.io.AlignmentProperties(
+ viewport.alignment).formatAsString();
CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
cap.setText(contents.toString());
Frame frame = new Frame();
{
this.setVisible(false);
}
+ viewport.sendSelection();
}
protected void makeGrpsFromSelection_actionPerformed()
viewport.setSelectionGroup(sg);
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
public void deselectAllSequenceMenuItem_actionPerformed()
alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
public void invertSequenceMenuItem_actionPerformed()
}
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
public void invertColSel_actionPerformed()
viewport.invertColumnSelection();
alignPanel.paintAlignment(true);
PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId());
+ viewport.sendSelection();
}
void trimAlignment(boolean trimLeft)
g.drawString("Build date: " + builddate, x, y += fh);
g.setFont(new Font("Helvetica", Font.PLAIN, 12));
g.drawString(
- "Authors: Andrew Waterhouse, Jim Procter, Michele Clamp, James Cuff, Steve Searle,",
+ "Authors: Jim Procter, Andrew Waterhouse, Michele Clamp, James Cuff, Steve Searle,",
x, y += fh * 1.5);
g.drawString("David Martin & Geoff Barton.", x + 50, y += fh);
g.drawString(
viewport.applet.getSize().height - embeddedMenu.HEIGHT
- statusBar.HEIGHT);
viewport.applet.add(alignPanel, BorderLayout.CENTER);
+ final AlignFrame me = this;
+ viewport.applet.addFocusListener(new FocusListener()
+ {
+
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ if (me.viewport.applet.currentAlignFrame==me) {
+ me.viewport.applet.currentAlignFrame = null;
+ }}
+
+ @Override
+ public void focusGained(FocusEvent e)
+ {
+ me.viewport.applet.currentAlignFrame = me;
+ }
+ });
viewport.applet.validate();
}
else
* create a new binding between structures in an existing jmol viewer instance
* and an alignpanel with sequences that have existing PDBFile entries. Note,
* this does not open a new Jmol window, or modify the display of the
- * structures in the original jmol window. Note
+ * structures in the original jmol window. Note This method doesn't work
+ * without an additional javascript library to exchange messages between the
+ * distinct applets. See http://issues.jalview.org/browse/JAL-621
*
* @param viewer
* JmolViewer instance
* @param sequenceIds
* - sequence Ids to search for associations
- * This method doesn't work. See http://issues.jalview.org/browse/JAL-621
- *
- public SequenceStructureBinding addStructureViewInstance(Object jmolviewer, String[] sequenceIds)
+ */
+ public SequenceStructureBinding addStructureViewInstance(
+ Object jmolviewer, String[] sequenceIds)
{
- org.jmol.api.JmolViewer viewer=null;
- try {
+ org.jmol.api.JmolViewer viewer = null;
+ try
+ {
viewer = (org.jmol.api.JmolViewer) jmolviewer;
- }
- catch (ClassCastException ex) {
- System.err.println("Unsupported viewer object :"+jmolviewer.getClass());
+ } catch (ClassCastException ex)
+ {
+ System.err.println("Unsupported viewer object :"
+ + jmolviewer.getClass());
}
- if (viewer==null)
+ if (viewer == null)
{
- System.err.println("Can't use this object as a structure viewer:"+jmolviewer.getClass());
+ System.err.println("Can't use this object as a structure viewer:"
+ + jmolviewer.getClass());
return null;
}
- SequenceI[] seqs=null;
- if (sequenceIds==null || sequenceIds.length==0)
+ SequenceI[] seqs = null;
+ if (sequenceIds == null || sequenceIds.length == 0)
{
seqs = viewport.getAlignment().getSequencesArray();
- } else {
- Vector sqi=new Vector();
+ }
+ else
+ {
+ Vector sqi = new Vector();
AlignmentI al = viewport.getAlignment();
- for (int sid=0;sid<sequenceIds.length;sid++) {
+ for (int sid = 0; sid < sequenceIds.length; sid++)
+ {
SequenceI sq = al.findName(sequenceIds[sid]);
- if (sq!=null) {
+ if (sq != null)
+ {
sqi.addElement(sq);
}
}
- if (sqi.size()>0) {
+ if (sqi.size() > 0)
+ {
seqs = new SequenceI[sqi.size()];
- for (int sid=0,sSize=sqi.size();sid<sSize;sid++)
+ for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
{
seqs[sid] = (SequenceI) sqi.elementAt(sid);
}
- } else {
+ }
+ else
+ {
return null;
}
}
- ExtJmol jmv=null;
+ ExtJmol jmv = null;
// TODO: search for a jmv that involves viewer
- if (jmv==null){
- // create a new viewer/jalview binding.
- jmv = new ExtJmol(viewer, alignPanel, seqs);
+ if (jmv == null)
+ { // create a new viewer/jalview binding.
+ jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][] {seqs});
}
return jmv;
-
+
}
- **/
+
public boolean addPdbFile(String sequenceId, String pdbEntryString,
String pdbFile)
{
if (needtoadd)
{
// make a note of the access mode and add
- if (pdbentry.getProperty()==null)
- {pdbentry.setProperty(new Hashtable());}
+ if (pdbentry.getProperty() == null)
+ {
+ pdbentry.setProperty(new Hashtable());
+ }
pdbentry.getProperty().put("protocol", protocol);
toaddpdb.addPDBId(pdbentry);
}
}
return true;
}
+
private Object[] cleanSeqChainArrays(SequenceI[] seqs, String[] chains)
{
if (seqs != null)
{
if (seqs[i] != null)
{
- sequences.addElement(new Object[] { seqs[i], (chains!=null) ? chains[i] : null});
+ sequences.addElement(new Object[]
+ { seqs[i], (chains != null) ? chains[i] : null });
}
}
seqs = new SequenceI[sequences.size()];
chains[i] = (String) oj[1];
}
}
- return new Object[] { seqs, chains};
+ return new Object[]
+ { seqs, chains };
}
+
public void newStructureView(JalviewLite applet, PDBEntry pdb,
SequenceI[] seqs, String[] chains, String protocol)
{
break;
}
}
- if (ajm!=null)
+ if (ajm != null)
{
- System.err.println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
+ System.err
+ .println("Incremental adding and aligning structure to existing Jmol view not yet implemented.");
// try and add the pdb structure
// ajm.addS
ajm = null;
// TODO Auto-generated method stub
System.err.println("Aligned Structure View: Not yet implemented.");
}
+
+ /**
+ * modify the current selection, providing the user has not made a selection already.
+ * @param sel - sequences from this alignment
+ * @param csel - columns to be selected on the alignment
+ */
+ public void select(SequenceGroup sel, ColumnSelection csel)
+ {
+ alignPanel.seqPanel.selection(sel, csel, null);
+ }
}