From d9c02118b8e03e6f102a46d316b6e52a41c41a27 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 22 Dec 2015 09:11:48 +0000 Subject: [PATCH] JAL-653 set showSequenceFeatures=true on loading a FeaturesSourceI --- src/jalview/api/FeaturesSourceI.java | 8 ++++++++ src/jalview/appletgui/CutAndPasteTransfer.java | 11 +++++++++++ src/jalview/gui/CutAndPasteTransfer.java | 5 +++++ src/jalview/io/FileLoader.java | 18 +++++++++++++----- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 src/jalview/api/FeaturesSourceI.java diff --git a/src/jalview/api/FeaturesSourceI.java b/src/jalview/api/FeaturesSourceI.java new file mode 100644 index 0000000..8f8d8c1 --- /dev/null +++ b/src/jalview/api/FeaturesSourceI.java @@ -0,0 +1,8 @@ +package jalview.api; + +/** + * A tagging interface to mark a source of sequence features + */ +public interface FeaturesSourceI +{ +} diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index 393506c..bbaeb68 100644 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -22,6 +22,7 @@ package jalview.appletgui; import jalview.analysis.AlignmentUtils; import jalview.api.ComplexAlignFile; +import jalview.api.FeaturesSourceI; import jalview.bin.JalviewLite; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; @@ -116,6 +117,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, addSequences.setVisible(false); } + @Override public void actionPerformed(ActionEvent evt) { if (evt.getSource() == accept) @@ -277,6 +279,10 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, { af = new AlignFrame(al, alignFrame.viewport.applet, "Cut & Paste input - " + format, false); + if (source instanceof FeaturesSourceI) + { + af.getAlignViewport().setShowSequenceFeatures(true); + } } af.statusBar @@ -490,6 +496,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, this.add(textarea, java.awt.BorderLayout.CENTER); } + @Override public void mousePressed(MouseEvent evt) { if (textarea.getText().startsWith( @@ -499,18 +506,22 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, } } + @Override public void mouseReleased(MouseEvent evt) { } + @Override public void mouseClicked(MouseEvent evt) { } + @Override public void mouseEntered(MouseEvent evt) { } + @Override public void mouseExited(MouseEvent evt) { } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 8665320..c0e59a4 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -24,6 +24,7 @@ import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.ComplexAlignFile; import jalview.api.FeaturesDisplayedI; +import jalview.api.FeaturesSourceI; import jalview.bin.Jalview; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; @@ -291,6 +292,10 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer { af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + if (source instanceof FeaturesSourceI) + { + af.getViewport().setShowSequenceFeatures(true); + } } af.currentFileFormat = format; diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index eae7a6b..b1944b4 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -22,6 +22,7 @@ package jalview.io; import jalview.api.ComplexAlignFile; import jalview.api.FeaturesDisplayedI; +import jalview.api.FeaturesSourceI; import jalview.bin.Jalview; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; @@ -100,6 +101,7 @@ public class FileLoader implements Runnable SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { loader.start(); @@ -234,6 +236,7 @@ public class FileLoader implements Runnable } } + @Override public void run() { String title = protocol.equals(AppletFormatAdapter.PASTE) ? "Copied From Clipboard" @@ -374,18 +377,15 @@ public class FileLoader implements Runnable .getColumnSelection(); SequenceI[] hiddenSeqs = ((ComplexAlignFile) source) .getHiddenSequences(); - boolean showSeqFeatures = ((ComplexAlignFile) source) - .isShowSeqFeatures(); String colourSchemeName = ((ComplexAlignFile) source) .getGlobalColourScheme(); FeaturesDisplayedI fd = ((ComplexAlignFile) source) .getDisplayedFeatures(); alignFrame = new AlignFrame(al, hiddenSeqs, colSel, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); - - alignFrame.getViewport().setShowSequenceFeatures( - showSeqFeatures); alignFrame.getViewport().setFeaturesDisplayed(fd); + alignFrame.getViewport().setShowSequenceFeatures( + ((ComplexAlignFile) source).isShowSeqFeatures()); ColourSchemeI cs = ColourSchemeMapper.getJalviewColourScheme( colourSchemeName, al); if (cs != null) @@ -397,6 +397,10 @@ public class FileLoader implements Runnable { alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + if (source instanceof FeaturesSourceI) + { + alignFrame.getViewport().setShowSequenceFeatures(true); + } } // add metadata and update ui if (!protocol.equals(AppletFormatAdapter.PASTE)) @@ -446,6 +450,7 @@ public class FileLoader implements Runnable { javax.swing.SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { JOptionPane.showInternalMessageDialog(Desktop.desktop, @@ -472,6 +477,7 @@ public class FileLoader implements Runnable { javax.swing.SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { javax.swing.JOptionPane.showInternalMessageDialog( @@ -493,6 +499,7 @@ public class FileLoader implements Runnable { javax.swing.SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { javax.swing.JOptionPane.showInternalMessageDialog( @@ -551,6 +558,7 @@ public class FileLoader implements Runnable * * @see java.lang.Object#finalize() */ + @Override protected void finalize() throws Throwable { source = null; -- 1.7.10.2