import jalview.analysis.AlignmentUtils;
import jalview.api.ComplexAlignFile;
+import jalview.api.FeaturesSourceI;
import jalview.bin.JalviewLite;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentFileReaderI;
import jalview.io.AnnotationFile;
import jalview.io.AppletFormatAdapter;
-import jalview.io.FileParse;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
import jalview.io.IdentifyFile;
import jalview.io.NewickFile;
import jalview.io.TCoffeeScoreFile;
+import jalview.json.binding.biojson.v1.ColourSchemeMapper;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.TCoffeeColourScheme;
import jalview.util.MessageManager;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import java.io.IOException;
-public class CutAndPasteTransfer extends Panel implements ActionListener,
- MouseListener
+public class CutAndPasteTransfer extends Panel
+ implements ActionListener, MouseListener
{
boolean pdbImport = false;
AlignFrame alignFrame;
- FileParse source = null;
+ AlignmentFileReaderI source = null;
public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame)
{
addSequences.setVisible(false);
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == accept)
{
try
{
- NewickFile fin = new NewickFile(textarea.getText(), "Paste");
+ NewickFile fin = new NewickFile(textarea.getText(),
+ DataSourceType.PASTE);
fin.parse();
if (fin.getTree() != null)
{
AlignmentI al = null;
- String format = new IdentifyFile().Identify(text,
- AppletFormatAdapter.PASTE);
- AppletFormatAdapter afa = new AppletFormatAdapter(alignFrame.alignPanel);
try
{
- al = afa.readFile(text, AppletFormatAdapter.PASTE, format);
+ FileFormatI format = new IdentifyFile().identify(text,
+ DataSourceType.PASTE);
+ AppletFormatAdapter afa = new AppletFormatAdapter(
+ alignFrame.alignPanel);
+ al = afa.readFile(text, DataSourceType.PASTE, format);
source = afa.getAlignFile();
- } catch (java.io.IOException ex)
- {
- ex.printStackTrace();
- }
- if (al != null)
- {
- al.setDataset(null); // set dataset on alignment/sequences
-
- /*
- * SplitFrame option dependent on applet parameter for now.
- */
- boolean allowSplitFrame = alignFrame.viewport.applet
- .getDefaultParameter("enableSplitFrame", false);
- if (allowSplitFrame && openSplitFrame(al, format))
- {
- return;
- }
- if (newWindow)
+ if (al != null)
{
- AlignFrame af;
-
- if (source instanceof ComplexAlignFile)
+ al.setDataset(null); // set dataset on alignment/sequences
+
+ /*
+ * SplitFrame option dependent on applet parameter for now.
+ */
+ boolean allowSplitFrame = alignFrame.viewport.applet
+ .getDefaultParameter("enableSplitFrame", false);
+ if (allowSplitFrame && openSplitFrame(al, format))
+ {
+ return;
+ }
+ if (newWindow)
{
- ColumnSelection colSel = ((ComplexAlignFile) source)
- .getColumnSelection();
- SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
- .getHiddenSequences();
- boolean showSeqFeatures = ((ComplexAlignFile) source)
- .isShowSeqFeatures();
- ColourSchemeI cs = ((ComplexAlignFile) source).getColourScheme();
- af = new AlignFrame(al, hiddenSeqs, colSel,
- alignFrame.viewport.applet, "Cut & Paste input - "
- + format, false);
- af.getAlignViewport().setShowSequenceFeatures(showSeqFeatures);
- af.changeColour(cs);
+ AlignFrame af;
+
+ if (source instanceof ComplexAlignFile)
+ {
+ HiddenColumns colSel = ((ComplexAlignFile) source)
+ .getHiddenColumns();
+ SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+ .getHiddenSequences();
+ boolean showSeqFeatures = ((ComplexAlignFile) source)
+ .isShowSeqFeatures();
+ String colourSchemeName = ((ComplexAlignFile) source)
+ .getGlobalColourScheme();
+ af = new AlignFrame(al, hiddenSeqs, colSel,
+ alignFrame.viewport.applet,
+ "Cut & Paste input - " + format, false);
+ af.getAlignViewport().setShowSequenceFeatures(showSeqFeatures);
+ ColourSchemeI cs = ColourSchemeMapper
+ .getJalviewColourScheme(colourSchemeName, al);
+ if (cs != null)
+ {
+ af.changeColour(cs);
+ }
+ }
+ else
+ {
+ af = new AlignFrame(al, alignFrame.viewport.applet,
+ "Cut & Paste input - " + format, false);
+ if (source instanceof FeaturesSourceI)
+ {
+ af.getAlignViewport().setShowSequenceFeatures(true);
+ }
+ }
+
+ af.statusBar.setText(MessageManager.getString(
+ "label.successfully_pasted_annotation_to_alignment"));
}
else
{
- af = new AlignFrame(al, alignFrame.viewport.applet,
- "Cut & Paste input - " + format, false);
+ alignFrame.addSequences(al.getSequencesArray());
+ alignFrame.statusBar.setText(MessageManager
+ .getString("label.successfully_pasted_alignment_file"));
}
-
- af.statusBar
- .setText(MessageManager
- .getString("label.successfully_pasted_annotation_to_alignment"));
- }
- else
- {
- alignFrame.addSequences(al.getSequencesArray());
- alignFrame.statusBar.setText(MessageManager
- .getString("label.successfully_pasted_alignment_file"));
}
+ } catch (IOException ex)
+ {
+ ex.printStackTrace();
}
}
* @param al
* @return
*/
- protected boolean openSplitFrame(AlignmentI al, String format)
+ protected boolean openSplitFrame(AlignmentI al, FileFormatI format)
{
- final AlignmentI thisAlignment = this.alignFrame.getAlignViewport().getAlignment();
+ final AlignmentI thisAlignment = this.alignFrame.getAlignViewport()
+ .getAlignment();
if (thisAlignment.isNucleotide() == al.isNucleotide())
{
// both nucleotide or both protein
}
AlignmentI protein = thisAlignment.isNucleotide() ? al : thisAlignment;
AlignmentI dna = thisAlignment.isNucleotide() ? thisAlignment : al;
- boolean mapped = AlignmentUtils.mapProteinToCdna(protein, dna);
+ boolean mapped = AlignmentUtils.mapProteinAlignmentToCdna(protein, dna);
if (!mapped)
{
return false;
dialog.setMainPanel(question);
dialog.setVisible(true);
dialog.toFront();
-
+
if (!dialog.accept)
{
return false;
}
/*
+ * 'align' the added alignment to match the current one
+ */
+ al.alignAs(thisAlignment);
+
+ /*
* Open SplitFrame with DNA above and protein below, including the alignment
* from textbox and a copy of the original.
*/
AlignFrame newFrame = new AlignFrame(al, alignFrame.viewport.applet,
"Cut & Paste input - " + format, false, false);
AlignFrame dnaFrame = al.isNucleotide() ? newFrame : copyFrame;
- AlignFrame proteinFrame = al.isNucleotide() ? copyFrame
- : newFrame;
+ AlignFrame proteinFrame = al.isNucleotide() ? copyFrame : newFrame;
SplitFrame sf = new SplitFrame(dnaFrame, proteinFrame);
sf.addToDisplay(false, applet);
return true;
try
{
tcf = new TCoffeeScoreFile(textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE);
+ jalview.io.DataSourceType.PASTE);
if (tcf.isValid())
{
- if (tcf.annotateAlignment(alignFrame.viewport.getAlignment(),
- true))
+ if (tcf.annotateAlignment(alignFrame.viewport.getAlignment(), true))
{
alignFrame.tcoffeeColour.setEnabled(true);
alignFrame.alignPanel.fontChanged();
alignFrame.changeColour(new TCoffeeColourScheme(
alignFrame.viewport.getAlignment()));
- alignFrame.statusBar
- .setText(MessageManager
- .getString("label.successfully_pasted_tcoffee_scores_to_alignment"));
+ alignFrame.statusBar.setText(MessageManager.getString(
+ "label.successfully_pasted_tcoffee_scores_to_alignment"));
}
else
{
// file valid but didn't get added to alignment for some reason
alignFrame.statusBar.setText(MessageManager.formatMessage(
- "label.failed_add_tcoffee_scores",
- new Object[]
- { (tcf.getWarningMessage() != null ? tcf
- .getWarningMessage() : "") }));
+ "label.failed_add_tcoffee_scores", new Object[]
+ { (tcf.getWarningMessage() != null
+ ? tcf.getWarningMessage()
+ : "") }));
}
}
else
if (tcf == null)
{
if (new AnnotationFile().annotateAlignmentView(alignFrame.viewport,
- textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE))
+ textarea.getText(), jalview.io.DataSourceType.PASTE))
{
alignFrame.alignPanel.fontChanged();
alignFrame.alignPanel.setScrollValues(0, 0);
- alignFrame.statusBar
- .setText(MessageManager
- .getString("label.successfully_pasted_annotation_to_alignment"));
+ alignFrame.statusBar.setText(MessageManager.getString(
+ "label.successfully_pasted_annotation_to_alignment"));
}
else
{
if (!alignFrame.parseFeaturesFile(textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE))
+ jalview.io.DataSourceType.PASTE))
{
- alignFrame.statusBar
- .setText(MessageManager
- .getString("label.couldnt_parse_pasted_text_as_valid_annotation_feature_GFF_tcoffee_file"));
+ alignFrame.statusBar.setText(MessageManager.getString(
+ "label.couldnt_parse_pasted_text_as_valid_annotation_feature_GFF_tcoffee_file"));
}
}
}
if (alignFrame.alignPanel.av.applet.jmolAvailable)
{
- new jalview.appletgui.AppletJmol(pdb, new SequenceI[]
- { seq }, null, alignFrame.alignPanel, AppletFormatAdapter.PASTE);
+ new jalview.appletgui.AppletJmol(pdb, new SequenceI[] { seq }, null,
+ alignFrame.alignPanel, DataSourceType.PASTE);
}
else
{
- new MCview.AppletPDBViewer(pdb, new SequenceI[]
- { seq }, null, alignFrame.alignPanel, AppletFormatAdapter.PASTE);
+ new mc_view.AppletPDBViewer(pdb, new SequenceI[] { seq }, null,
+ alignFrame.alignPanel, DataSourceType.PASTE);
}
}
private void jbInit() throws Exception
{
textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 10));
- textarea.setText(MessageManager
- .getString("label.paste_your_alignment_file"));
+ textarea.setText(
+ MessageManager.getString("label.paste_your_alignment_file"));
textarea.addMouseListener(this);
this.setLayout(borderLayout1);
accept.addActionListener(this);
this.add(textarea, java.awt.BorderLayout.CENTER);
}
+ @Override
public void mousePressed(MouseEvent evt)
{
- if (textarea.getText().startsWith(
- MessageManager.getString("label.paste_your")))
+ if (textarea.getText()
+ .startsWith(MessageManager.getString("label.paste_your")))
{
textarea.setText("");
}
}
+ @Override
public void mouseReleased(MouseEvent evt)
{
}
+ @Override
public void mouseClicked(MouseEvent evt)
{
}
+ @Override
public void mouseEntered(MouseEvent evt)
{
}
+ @Override
public void mouseExited(MouseEvent evt)
{
}