dbPrefix and jvsuffix added
authoramwaterhouse <Andrew Waterhouse>
Mon, 31 Oct 2005 15:57:24 +0000 (15:57 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 31 Oct 2005 15:57:24 +0000 (15:57 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java

index 7b394a3..1d408db 100755 (executable)
@@ -42,7 +42,7 @@ import jalview.ws.*;
  * @version $Revision$\r
  */\r
 public class AlignFrame\r
-    extends GAlignFrame\r
+    extends GAlignFrame implements ClipboardOwner\r
 {\r
   /** DOCUMENT ME!! */\r
   public static final int NEW_WINDOW_WIDTH = 700;\r
@@ -103,8 +103,7 @@ public class AlignFrame
       al.setDataset(null);\r
     }\r
 \r
-    AlignViewport ds = new AlignViewport(al.getDataset());\r
-    ds.setDataset(true);\r
+    AlignViewport ds = new AlignViewport(al.getDataset(), true);\r
     AlignmentPanel dap = new AlignmentPanel(this, ds);\r
     tabbedPane.add("Dataset", dap);\r
     viewports.add(ds);\r
@@ -603,6 +602,12 @@ public class AlignFrame
     alignPanel.repaint();\r
   }\r
 \r
+  public void lostOwnership(Clipboard clipboard, Transferable contents)\r
+  {\r
+    Desktop.jalviewClipboard = null;\r
+  }\r
+\r
+\r
   /**\r
    * DOCUMENT ME!\r
    *\r
@@ -612,7 +617,7 @@ public class AlignFrame
   {\r
     if (viewport.getSelectionGroup() == null)\r
     {\r
-      System.out.println("null here");\r
+      System.out.println("nothing selected");\r
       return;\r
     }\r
 \r
@@ -621,7 +626,7 @@ public class AlignFrame
     Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();\r
 \r
     Hashtable orderedSeqs = new Hashtable();\r
-    SequenceI [] seqs = new SequenceI[sg.getSize()];\r
+    SequenceI[] seqs = new SequenceI[sg.getSize()];\r
 \r
     for (int i = 0; i < sg.getSize(); i++)\r
     {\r
@@ -652,7 +657,6 @@ public class AlignFrame
         }\r
       }\r
 \r
-\r
       //FIND START RES\r
       //Returns residue following index if gap\r
       startRes = seq.findPosition(sg.getStartRes());\r
@@ -676,12 +680,20 @@ public class AlignFrame
       }\r
 \r
       seqs[i] = new Sequence(seq.getName(),\r
-                             seq.getSequence(sg.getStartRes(), sg.getEndRes()+1),\r
+                             seq.getSequence(sg.getStartRes(), sg.getEndRes() + 1),\r
                              startRes,\r
                              endRes);\r
+      seqs[i].setDescription(seq.getDescription());\r
+      seqs[i].setDBRef(seq.getDBRef());\r
+      seqs[i].setSequenceFeatures(seq.getSequenceFeatures());\r
+      seqs[i].setDatasetSequence(seq.getDatasetSequence());\r
     }\r
 \r
-    c.setContents(new StringSelection(new FastaFile().print(seqs)), null);\r
+    Desktop.jalviewClipboard = new Object[]{seqs,  viewport.alignment.getDataset()};\r
+    FastaFile ff = new FastaFile();\r
+    ff.addDBPrefix( viewport.showDBPrefix );\r
+    ff.addJVSuffix( viewport.showJVSuffix );\r
+    c.setContents(new StringSelection( ff.print(seqs)), this);\r
   }\r
 \r
   /**\r
@@ -728,13 +740,29 @@ public class AlignFrame
         return;\r
 \r
       String format = IdentifyFile.Identify(str, "Paste");\r
-      SequenceI[] sequences = new FormatAdapter().readFile(str, "Paste", format);\r
+      SequenceI[] sequences;\r
+\r
+     if(Desktop.jalviewClipboard!=null)\r
+     {\r
+       // The clipboard was filled from within Jalview, we must use the sequences\r
+       // And dataset from the copied alignment\r
+       sequences = (SequenceI[])Desktop.jalviewClipboard[0];\r
+     }\r
+     else\r
+       sequences = new FormatAdapter().readFile(str, "Paste", format);\r
 \r
 \r
       if (newAlignment)\r
       {\r
+\r
         Alignment alignment = new Alignment(sequences);\r
-        alignment.setDataset( viewport.alignment.getDataset() );\r
+\r
+        if(Desktop.jalviewClipboard!=null)\r
+           alignment.setDataset( (Alignment)Desktop.jalviewClipboard[1] );\r
+        else\r
+           alignment.setDataset( null );\r
+\r
+\r
         AlignFrame af = new AlignFrame(alignment);\r
         String newtitle = new String("Copied sequences");\r
 \r
@@ -1223,14 +1251,23 @@ public class AlignFrame
    *\r
    * @param e DOCUMENT ME!\r
    */\r
-  protected void fullSeqId_actionPerformed(ActionEvent e)\r
+  protected void seqLimit_actionPerformed(ActionEvent e)\r
   {\r
-    viewport.setShowFullId(fullSeqId.isSelected());\r
+    viewport.setShowJVSuffix(seqLimits.isSelected());\r
 \r
     alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());\r
     alignPanel.repaint();\r
   }\r
 \r
+  public void seqDBRef_actionPerformed(ActionEvent e)\r
+  {\r
+    viewport.setShowDBPrefix(seqDBRef.isSelected());\r
+\r
+    alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth());\r
+    alignPanel.repaint();\r
+  }\r
+\r
+\r
   /**\r
    * DOCUMENT ME!\r
    *\r
@@ -1332,12 +1369,13 @@ public class AlignFrame
   {\r
     viewport.showSequenceFeatures(sequenceFeatures.isSelected());\r
 \r
-    if (viewport.showSequenceFeatures &&\r
-        ! ( (Alignment) viewport.alignment).featuresAdded)\r
+   // if (viewport.showSequenceFeatures &&\r
+     //   ! ( (Alignment) viewport.alignment.getDataset()).featuresAdded)\r
     {\r
-      new SequenceFeatureFetcher(viewport.\r
-          alignment,\r
-          alignPanel);\r
+     // System.out.println("new fetcher");\r
+    //  new SequenceFeatureFetcher(viewport.\r
+     //     alignment,\r
+     //     alignPanel);\r
     }\r
 \r
     featureSettings.setEnabled(true);\r
index f57e993..3ed2a7c 100755 (executable)
@@ -43,7 +43,8 @@ public class AlignViewport
     int endRes;\r
     int startSeq;\r
     int endSeq;\r
-    boolean showFullId = false;\r
+    boolean showDBPrefix = true;\r
+    boolean showJVSuffix = true;\r
     boolean showText = true;\r
     boolean showColourText = false;\r
     boolean showBoxes = true;\r
@@ -90,6 +91,13 @@ public class AlignViewport
 \r
     boolean isDataset = false;\r
 \r
+\r
+    public AlignViewport(AlignmentI al, boolean dataset)\r
+    {\r
+      isDataset = dataset;\r
+      setAlignment(al);\r
+      init();\r
+    }\r
     /**\r
      * Creates a new AlignViewport object.\r
      *\r
@@ -98,13 +106,18 @@ public class AlignViewport
     public AlignViewport(AlignmentI al)\r
     {\r
         setAlignment(al);\r
+        init();\r
+    }\r
+\r
+    void init()\r
+    {\r
         this.startRes = 0;\r
-        this.endRes = al.getWidth() - 1;\r
+        this.endRes = alignment.getWidth() - 1;\r
         this.startSeq = 0;\r
-        this.endSeq = al.getHeight() - 1;\r
+        this.endSeq = alignment.getHeight() - 1;\r
 \r
-\r
-      showFullId = Cache.getDefault("SHOW_FULL_ID", true);\r
+      showDBPrefix = Cache.getDefault("SHOW_DBPREFIX", true);\r
+      showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);\r
       showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);\r
       showConservation = Cache.getDefault("SHOW_CONSERVATION", true);\r
 \r
@@ -134,7 +147,7 @@ public class AlignViewport
 \r
         // We must set conservation and consensus before setting colour,\r
         // as Blosum and Clustal require this to be done\r
-        if(vconsensus==null)\r
+        if(vconsensus==null && !isDataset)\r
         {\r
           updateConservation();\r
           updateConsensus();\r
@@ -913,9 +926,29 @@ public class AlignViewport
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public boolean getShowFullId()\r
+    public boolean getShowJVSuffix()\r
+    {\r
+        return showJVSuffix;\r
+    }\r
+\r
+    /**\r
+     * DOCUMENT ME!\r
+     *\r
+     * @param b DOCUMENT ME!\r
+     */\r
+    public void setShowJVSuffix(boolean b)\r
+    {\r
+        showJVSuffix = b;\r
+    }\r
+\r
+    /**\r
+     * DOCUMENT ME!\r
+     *\r
+     * @return DOCUMENT ME!\r
+     */\r
+    public boolean getShowDBPrefix()\r
     {\r
-        return showFullId;\r
+        return showDBPrefix;\r
     }\r
 \r
     /**\r
@@ -923,9 +956,9 @@ public class AlignViewport
      *\r
      * @param b DOCUMENT ME!\r
      */\r
-    public void setShowFullId(boolean b)\r
+    public void setShowDBPrefix(boolean b)\r
     {\r
-        showFullId = b;\r
+        showDBPrefix = b;\r
     }\r
 \r
     /**\r