JAL-653 set showSequenceFeatures=true on loading a FeaturesSourceI
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 22 Dec 2015 09:11:48 +0000 (09:11 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 22 Dec 2015 09:11:48 +0000 (09:11 +0000)
src/jalview/api/FeaturesSourceI.java [new file with mode: 0644]
src/jalview/appletgui/CutAndPasteTransfer.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/io/FileLoader.java

diff --git a/src/jalview/api/FeaturesSourceI.java b/src/jalview/api/FeaturesSourceI.java
new file mode 100644 (file)
index 0000000..8f8d8c1
--- /dev/null
@@ -0,0 +1,8 @@
+package jalview.api;
+
+/**
+ * A tagging interface to mark a source of sequence features
+ */
+public interface FeaturesSourceI
+{
+}
index 393506c..bbaeb68 100644 (file)
@@ -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)
   {
   }
index 8665320..c0e59a4 100644 (file)
@@ -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;
index eae7a6b..b1944b4 100755 (executable)
@@ -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;