import jalview.commands.RemoveGapsCommand;
import jalview.commands.SlideSequencesCommand;
import jalview.commands.TrimRegionCommand;
+import jalview.controller.AlignViewController;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentProperties;
import jalview.io.AnnotationFile;
import jalview.io.AppletFormatAdapter;
import jalview.io.FeaturesFile;
+import jalview.io.NewickFile;
+import jalview.io.AlignFile;
import jalview.io.TCoffeeScoreFile;
+import jalview.jsdev.GenericFileAdapter;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.ClustalxColourScheme;
import jalview.schemes.ZappoColourScheme;
import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
+import jalview.util.Comparison;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
import java.awt.BorderLayout;
-import java.awt.Canvas;
-import java.awt.CheckboxMenuItem;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Frame;
import java.awt.Graphics;
-import java.awt.Label;
-import java.awt.Menu;
-import java.awt.MenuBar;
-import java.awt.MenuItem;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.util.StringTokenizer;
import java.util.Vector;
+import awt2swing.Canvas;
+import awt2swing.CheckboxMenuItem;
+import awt2swing.Frame;
+import awt2swing.Label;
+import awt2swing.Menu;
+import awt2swing.MenuBar;
+import awt2swing.MenuItem;
+
+//import org.jmol.viewer.Viewer;
+
public class AlignFrame extends EmbmenuFrame implements ActionListener,
ItemListener, KeyListener, AlignViewControllerGuiI
{
if (hiddenSeqs != null && hiddenSeqs.length > 0)
{
viewport.hideSequence(hiddenSeqs);
- viewport.setHasHiddenRows(true);
}
if (columnSelection != null)
{
}
alignPanel = new AlignmentPanel(this, viewport);
- avc = new jalview.controller.AlignViewController(this, viewport,
+ avc = new AlignViewController(this, viewport,
alignPanel);
viewport.updateConservation(alignPanel);
viewport.updateConsensus(alignPanel);
boolean featuresFile = false;
try
{
- featuresFile = new jalview.io.FeaturesFile(file, type)
+ featuresFile = new FeaturesFile(file, type)
.parse(viewport.getAlignment(), alignPanel.seqPanel.seqCanvas
.getFeatureRenderer().getFeatureColours(), featureLinks,
true, viewport.applet.getDefaultParameter(
viewport.featureSettings.refreshTable();
}
alignPanel.paintAlignment(true);
- statusBar.setText(MessageManager
+ setStatus(MessageManager
.getString("label.successfully_added_features_alignment"));
}
return featuresFile;
case KeyEvent.VK_F2:
viewport.cursorMode = !viewport.cursorMode;
- statusBar.setText(MessageManager.formatMessage(
+ setStatus(MessageManager.formatMessage(
"label.keyboard_editing_mode", new String[]
{ (viewport.cursorMode ? "on" : "off") }));
if (viewport.cursorMode)
: showForSequences);
aa.visible = visible;
}
- alignPanel.validateAnnotationDimensions(false);
+ alignPanel.validateAnnotationDimensions(true);
+ validate();
+ repaint();
}
private void setAnnotationSortOrder(SequenceAnnotationOrder order)
}
else if (source == alProperties)
{
- StringBuffer contents = new jalview.io.AlignmentProperties(
+ StringBuffer contents = new AlignmentProperties(
viewport.getAlignment()).formatAsString();
CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
cap.setText(contents.toString());
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+ JalviewLite.addFrame(frame, MessageManager.formatMessage(
"label.alignment_properties", new String[]
{ getTitle() }), 400, 250);
}
CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("label.input_cut_paste"), 500, 500);
}
CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+ JalviewLite.addFrame(frame, MessageManager.formatMessage(
"label.alignment_output_command", new Object[]
{ e.getActionCommand() }), 600, 500);
FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
- viewport.setFeatureRenderer(fr);
- cap.setText(new AppletFormatAdapter(viewport).formatSequences(
+ cap.setText(new AppletFormatAdapter(alignPanel).formatSequences(
e.getActionCommand(), viewport.getAlignment(),
viewport.getShowJVSuffix()));
}
cap.setAnnotationImport();
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("action.paste_annotations"), 400, 300);
}
CutAndPasteTransfer cap = new CutAndPasteTransfer(false, this);
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("label.annotations"), 600, 500);
cap.setText(annotation);
}
}
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("label.features"), 600, 500);
cap.setText(features);
}
for (int j = 0; j < sg.getEndRes() + 1 && j < seq.getLength(); j++)
{
ch = seq.getCharAt(j);
- if (!jalview.util.Comparison.isGap((ch)))
+ if (!Comparison.isGap((ch)))
{
endRes++;
}
}
}
- jalview.bin.JalviewLite.addFrame(af, newtitle, frameWidth,
+ JalviewLite.addFrame(af, newtitle, frameWidth,
frameHeight);
}
else
viewport.getSelectionGroup());
}
- statusBar.setText(MessageManager.formatMessage(
+ setStatus(MessageManager.formatMessage(
"label.removed_columns", new String[]
{ Integer.valueOf(trimRegion.getSize()).toString() }));
addHistoryItem(trimRegion);
addHistoryItem(removeGapCols);
- statusBar.setText(MessageManager.formatMessage(
+ setStatus(MessageManager.formatMessage(
"label.removed_empty_columns", new String[]
{ Integer.valueOf(removeGapCols.getSize()).toString() }));
OverviewPanel overview = new OverviewPanel(alignPanel);
frame.add(overview);
// +50 must allow for applet frame window
- jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+ JalviewLite.addFrame(frame, MessageManager.formatMessage(
"label.overview_params", new String[]
{ this.getTitle() }), overview.getPreferredSize().width,
overview.getPreferredSize().height + 50);
alignPanel.getOverviewPanel().updateOverviewImage();
}
- jalview.structure.StructureSelectionManager
- .getStructureSelectionManager(viewport.applet)
+ StructureSelectionManager.getStructureSelectionManager(viewport.applet)
.sequenceColoursChanged(alignPanel);
alignPanel.paintAlignment(true);
{
Frame frame = new Frame();
frame.add(new PairwiseAlignPanel(alignPanel));
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("action.pairwise_alignment"), 600,
500);
}
addTreeMenuItem(tp, title);
- jalview.bin.JalviewLite.addFrame(tp, title, 600, 500);
+ JalviewLite.addFrame(tp, title, 600, 500);
}
}
cap.setTreeImport();
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("label.paste_newick_file"), 400, 300);
}
- public void loadTree(jalview.io.NewickFile tree, String treeFile)
+ public void loadTree(NewickFile tree, String treeFile)
{
TreePanel tp = new TreePanel(alignPanel, treeFile,
MessageManager.getString("label.load_tree_from_file"), tree);
- jalview.bin.JalviewLite.addFrame(tp, treeFile, 600, 500);
+ JalviewLite.addFrame(tp, treeFile, 600, 500);
addTreeMenuItem(tp, treeFile);
}
}
@Override
- public void paint(Graphics g)
+ public void paintComponent(Graphics g)
{
g.setColor(Color.white);
g.fillRect(0, 0, getSize().width, getSize().height);
FontMetrics fm = g.getFontMetrics();
int fh = fm.getHeight();
int y = 5, x = 7;
- g.setColor(Color.black);
+ g.setColor(Color.black);
// TODO: update this text for each release or centrally store it for
// lite and application
g.setFont(new Font("Helvetica", Font.BOLD, 14));
Frame frame = new Frame();
frame.add(new AboutPanel(JalviewLite.getVersion(), JalviewLite
.getBuildDate()));
- jalview.bin.JalviewLite.addFrame(frame,
+ JalviewLite.addFrame(frame,
MessageManager.getString("label.jalview"), 580, 220);
}
BorderLayout borderLayout1 = new BorderLayout();
- public Label statusBar = new Label();
+ Label statusBar = new Label();
MenuItem clustalColour = new MenuItem();
inputText.addActionListener(this);
Menu outputTextboxMenu = new Menu(
MessageManager.getString("label.out_to_textbox"));
- for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
+ for (int i = 0; i < AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
{
- MenuItem item = new MenuItem(
- jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
+ MenuItem item = new MenuItem(AppletFormatAdapter.WRITEABLE_FORMATS[i]);
item.addActionListener(new java.awt.event.ActionListener()
{
*/
statusBar.setBackground(Color.white);
statusBar.setFont(new java.awt.Font("Verdana", 0, 11));
- statusBar.setText(MessageManager.getString("label.status_bar"));
+ setStatus(MessageManager.getString("label.status_bar"));
this.add(statusBar, BorderLayout.SOUTH);
}
- public void setStatus(String string)
+ public void setStatus(String string)
{
statusBar.setText(string);
};
add(statusBar, BorderLayout.SOUTH);
add(alignPanel, BorderLayout.CENTER);
// and register with the applet so it can pass external API calls to us
- jalview.bin.JalviewLite.addFrame(this, this.getTitle(),
+ JalviewLite.addFrame(this, this.getTitle(),
frameWidth,
frameHeight);
}
theApplet.validate();
}
- /**
- * 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 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
- */
- public SequenceStructureBinding addStructureViewInstance(
- Object jmolviewer, String[] sequenceIds)
- {
- org.jmol.api.JmolViewer viewer = null;
- try
- {
- viewer = (org.jmol.api.JmolViewer) jmolviewer;
- } catch (ClassCastException ex)
- {
- System.err.println("Unsupported viewer object :"
- + jmolviewer.getClass());
- }
- if (viewer == null)
- {
- 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)
- {
- seqs = viewport.getAlignment().getSequencesArray();
- }
- else
- {
- Vector sqi = new Vector();
- AlignmentI al = viewport.getAlignment();
- for (int sid = 0; sid < sequenceIds.length; sid++)
- {
- SequenceI sq = al.findName(sequenceIds[sid]);
- if (sq != null)
- {
- sqi.addElement(sq);
- }
- }
- if (sqi.size() > 0)
- {
- seqs = new SequenceI[sqi.size()];
- for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
- {
- seqs[sid] = (SequenceI) sqi.elementAt(sid);
- }
- }
- else
- {
- return null;
- }
- }
- AAStructureBindingModel jmv = null;
- // TODO: search for a jmv that involves viewer
- if (jmv == null)
- { // create a new viewer/jalview binding.
- jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][]
- { seqs });
- }
- return jmv;
-
- }
+ /**
+ * 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 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
+ */
+ public SequenceStructureBinding addStructureViewInstance(Object jmolviewer,
+ String[] sequenceIds) {
+ return null;
+ // Viewer viewer = null;
+ // try
+ // {
+ // viewer = (Viewer) jmolviewer;
+ // } catch (ClassCastException ex)
+ // {
+ // System.err.println("Unsupported viewer object :"
+ // + jmolviewer.getClass());
+ // }
+ // if (viewer == null)
+ // {
+ // 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)
+ // {
+ // seqs = viewport.getAlignment().getSequencesArray();
+ // }
+ // else
+ // {
+ // Vector sqi = new Vector();
+ // AlignmentI al = viewport.getAlignment();
+ // for (int sid = 0; sid < sequenceIds.length; sid++)
+ // {
+ // SequenceI sq = al.findName(sequenceIds[sid]);
+ // if (sq != null)
+ // {
+ // sqi.addElement(sq);
+ // }
+ // }
+ // if (sqi.size() > 0)
+ // {
+ // seqs = new SequenceI[sqi.size()];
+ // for (int sid = 0, sSize = sqi.size(); sid < sSize; sid++)
+ // {
+ // seqs[sid] = (SequenceI) sqi.elementAt(sid);
+ // }
+ // }
+ // else
+ // {
+ // return null;
+ // }
+ // }
+ // AAStructureBindingModel jmv = null;
+ // // TODO: search for a jmv that involves viewer
+ // if (jmv == null)
+ // { // create a new viewer/jalview binding.
+ // jmv = new ExtJmol(viewer, alignPanel, new SequenceI[][]
+ // { seqs });
+ // }
+ // return jmv;
+ //
+ }
/**
* bind a pdb file to a sequence in the current view
}
- public void newStructureView(JalviewLite applet, PDBEntry pdb,
- SequenceI[] seqs, String[] chains, String protocol)
- {
- // Scrub any null sequences from the array
- Object[] sqch = cleanSeqChainArrays(seqs, chains);
- seqs = (SequenceI[]) sqch[0];
- chains = (String[]) sqch[1];
- if (seqs == null || seqs.length == 0)
- {
- System.err
- .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
- }
- if (protocol == null || protocol.trim().length() == 0
- || protocol.equals("null"))
- {
- protocol = (String) pdb.getProperty().get("protocol");
- if (protocol == null)
- {
- System.err.println("Couldn't work out protocol to open structure: "
- + pdb.getId());
- return;
- }
- }
- if (applet.useXtrnalSviewer)
- {
- // register the association(s) and quit, don't create any windows.
- if (StructureSelectionManager.getStructureSelectionManager(applet)
- .setMapping(seqs, chains, pdb.getFile(), protocol) == null)
- {
- System.err.println("Failed to map " + pdb.getFile() + " ("
- + protocol + ") to any sequences");
- }
- return;
- }
- if (applet.isAlignPdbStructures() && applet.jmolAvailable)
- {
- // can only do alignments with Jmol
- // find the last jmol window assigned to this alignment
- jalview.appletgui.AppletJmol ajm = null, tajm;
- Vector jmols = applet
- .getAppletWindow(jalview.appletgui.AppletJmol.class);
- for (int i = 0, iSize = jmols.size(); i < iSize; i++)
- {
- tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i);
- if (tajm.ap.alignFrame == this)
- {
- ajm = tajm;
- break;
- }
- }
- if (ajm != null)
- {
- 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;
- }
- }
- // otherwise, create a new window
- if (applet.jmolAvailable)
- {
- new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel,
- protocol);
- applet.lastFrameX += 40;
- applet.lastFrameY += 40;
- }
- else
- {
- new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
- }
-
- }
+ public void newStructureView(JalviewLite applet, PDBEntry pdb,
+ SequenceI[] seqs, String[] chains, String protocol) {
+ // Scrub any null sequences from the array
+ Object[] sqch = cleanSeqChainArrays(seqs, chains);
+ seqs = (SequenceI[]) sqch[0];
+ chains = (String[]) sqch[1];
+ if (seqs == null || seqs.length == 0) {
+ System.err
+ .println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
+ }
+ if (protocol == null || protocol.trim().length() == 0
+ || protocol.equals("null")) {
+ protocol = (String) pdb.getProperty().get("protocol");
+ if (protocol == null) {
+ System.err.println("Couldn't work out protocol to open structure: "
+ + pdb.getId());
+ return;
+ }
+ }
+ if (applet.useXtrnalSviewer) {
+ // register the association(s) and quit, don't create any windows.
+ if (StructureSelectionManager.getStructureSelectionManager(applet)
+ .setMapping(seqs, chains, pdb.getFile(), protocol) == null) {
+ System.err.println("Failed to map " + pdb.getFile() + " (" + protocol
+ + ") to any sequences");
+ }
+ return;
+ }
+ if (applet.isAlignPdbStructures() && applet.jmolAvailable) {
+ // can only do alignments with Jmol
+ // find the last jmol window assigned to this alignment
+ AppletJmol ajm = null, tajm;
+ Vector jmols = applet.getAppletWindow(AppletJmol.class);
+ for (int i = 0, iSize = jmols.size(); i < iSize; i++) {
+ tajm = (AppletJmol) jmols.elementAt(i);
+ if (tajm.ap.alignFrame == this) {
+ ajm = tajm;
+ break;
+ }
+ }
+ if (ajm != null) {
+ 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;
+ }
+ }
+ // otherwise, create a new window
+ // if (applet.jmolAvailable)
+ // {
+ new AppletJmol(pdb, seqs, chains, alignPanel, protocol);
+ applet.lastFrameX += 40;
+ applet.lastFrameY += 40;
+ // }
+ // else
+ // {
+ // new MCview.AppletPDBViewer(pdb, seqs, chains, alignPanel, protocol);
+ // }
+
+ }
public void alignedStructureView(JalviewLite applet, PDBEntry[] pdb,
SequenceI[][] seqs, String[][] chains, String[] protocols)
/**
* Load the (T-Coffee) score file from the specified url
*
- * @param source
+ * @param inFile
* File/URL/T-COFFEE score file contents
* @throws IOException
* @return true if alignment was annotated with data from source
*/
- public boolean loadScoreFile(String source) throws IOException
+ public boolean loadScoreFile(String inFile) throws IOException
{
- TCoffeeScoreFile file = new TCoffeeScoreFile(source,
- AppletFormatAdapter.checkProtocol(source));
+ TCoffeeScoreFile file = (TCoffeeScoreFile) GenericFileAdapter.getFile("TCoffeeScoreFile", inFile,
+ AppletFormatAdapter.checkProtocol(inFile));
if (!file.isValid())
{
// TODO: raise dialog for gui
System.err.println("Problems parsing T-Coffee scores: "
+ file.getWarningMessage());
- System.err.println("Origin was:\n" + source);
+ System.err.println("Origin was:\n" + inFile);
return false;
}