After merge
authoramwaterhouse <Andrew Waterhouse>
Tue, 6 Dec 2005 12:03:46 +0000 (12:03 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 6 Dec 2005 12:03:46 +0000 (12:03 +0000)
24 files changed:
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AlignmentPanel.java
src/jalview/gui/CutAndPasteTransfer.java
src/jalview/gui/Desktop.java
src/jalview/gui/EPSOptions.java
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/FeatureSettings.java [new file with mode: 0755]
src/jalview/gui/FontChooser.java
src/jalview/gui/GFeatureSelector.java [new file with mode: 0755]
src/jalview/gui/IdCanvas.java
src/jalview/gui/IdPanel.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/OverviewPanel.java
src/jalview/gui/PCAPanel.java
src/jalview/gui/PairwiseAlignPanel.java
src/jalview/gui/PopupMenu.java
src/jalview/gui/Preferences.java
src/jalview/gui/RotatableCanvas.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/SequenceFetcher.java [new file with mode: 0755]
src/jalview/gui/SequenceRenderer.java
src/jalview/gui/SplashScreen.java

index d6be387..8c31ed0 100755 (executable)
@@ -34,6 +34,7 @@ import jalview.io.*;
 import jalview.jbgui.*;\r
 import jalview.schemes.*;\r
 import jalview.ws.*;\r
+import javax.swing.event.AncestorEvent;\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -42,15 +43,18 @@ 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
 \r
   /** DOCUMENT ME!! */\r
   public static final int NEW_WINDOW_HEIGHT = 500;\r
-  final AlignmentPanel alignPanel;\r
-  final AlignViewport viewport;\r
+  AlignmentPanel alignPanel;\r
+  AlignViewport viewport;\r
+\r
+  Vector viewports = new Vector();\r
+  Vector alignPanels = new Vector();\r
 \r
   /** DOCUMENT ME!! */\r
   public String currentFileFormat = null;\r
@@ -58,6 +62,7 @@ public class AlignFrame
   Stack redoList = new Stack();\r
   private int treeCount = 0;\r
 \r
+\r
   /**\r
    * Creates a new AlignFrame object.\r
    *\r
@@ -66,10 +71,12 @@ public class AlignFrame
   public AlignFrame(AlignmentI al)\r
   {\r
     viewport = new AlignViewport(al);\r
+    viewports.add(viewport);\r
+\r
 \r
     if(viewport.vconsensus==null)\r
     {\r
-      //Out of memory caluclating consensus.\r
+      //Out of memory calculating consensus.\r
       BLOSUM62Colour.setEnabled(false);\r
       PIDColour.setEnabled(false);\r
       conservationMenuItem.setEnabled(false);\r
@@ -79,12 +86,7 @@ public class AlignFrame
     }\r
 \r
     alignPanel = new AlignmentPanel(this, viewport);\r
-    alignPanel.annotationPanel.adjustPanelHeight();\r
-    alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.\r
-        annotationPanel.getPreferredSize());\r
-    alignPanel.annotationScroller.setPreferredSize(alignPanel.annotationPanel.\r
-        getPreferredSize());\r
-    alignPanel.setAnnotationVisible(viewport.getShowAnnotation());\r
+    alignPanels.add(alignPanel);\r
 \r
     String sortby = jalview.bin.Cache.getDefault("SORT_ALIGNMENT", "No sort");\r
 \r
@@ -93,7 +95,26 @@ public class AlignFrame
     else if(sortby.equals("Pairwise Identity"))\r
       sortPairwiseMenuItem_actionPerformed(null);\r
 \r
-    getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER);\r
+   // remove(tabbedPane);\r
+    getContentPane().add(alignPanel, BorderLayout.CENTER);\r
+\r
+\r
+\r
+  //  tabbedPane.add(al.isNucleotide() ? "DNA":"Protein", alignPanel);\r
+\r
+    ///Dataset tab\r
+    /////////////////////////\r
+    if(al.getDataset()==null)\r
+    {\r
+      al.setDataset(null);\r
+    }\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
+  //  alignPanels.add(dap);\r
+    /////////////////////////\r
+\r
 \r
     viewport.addPropertyChangeListener(new PropertyChangeListener()\r
     {\r
@@ -106,8 +127,12 @@ public class AlignFrame
      }\r
    });\r
 \r
-       if(Desktop.desktop!=null)\r
+\r
+  if (Desktop.desktop != null)\r
+  {\r
     addServiceListeners();\r
+    setGUINucleotide(al.isNucleotide());\r
+  }\r
   }\r
 \r
   /* Set up intrinsic listeners for dynamically generated GUI bits. */\r
@@ -144,6 +169,36 @@ public class AlignFrame
 \r
   }\r
 \r
+  public void setGUINucleotide(boolean nucleotide)\r
+  {\r
+    showTranslation.setVisible( nucleotide );\r
+    sequenceFeatures.setVisible(!nucleotide );\r
+    featureSettings.setVisible( !nucleotide );\r
+    conservationMenuItem.setVisible( !nucleotide );\r
+    modifyConservation.setVisible(   !nucleotide );\r
+\r
+    //Deal with separators\r
+    //Remember AlignFrame always starts as protein\r
+    if(nucleotide)\r
+    {\r
+      viewMenu.remove(viewMenu.getItemCount()-2);\r
+    }\r
+    else\r
+    {\r
+      calculateMenu.remove(calculateMenu.getItemCount()-2);\r
+    }\r
+  }\r
+\r
+\r
+  /*\r
+   Added so Castor Mapping file can obtain Jalview Version\r
+  */\r
+  public String getVersion()\r
+  {\r
+    return  jalview.bin.Cache.getProperty("VERSION");\r
+  }\r
+\r
+\r
   /**\r
    * DOCUMENT ME!\r
    *\r
@@ -156,24 +211,28 @@ public class AlignFrame
     {\r
       BufferedReader in = new BufferedReader(new FileReader(file));\r
       SequenceI seq = null;\r
-      String line, text, token;\r
-      UserColourScheme ucs;\r
+      String line, type, desc, token;\r
+\r
       int index, start, end;\r
       StringTokenizer st;\r
-      SequenceGroup sg;\r
+      SequenceFeature sf;\r
+      FeatureRenderer fr = alignPanel.seqPanel.seqCanvas.getFeatureRenderer();\r
+      int lineNo = 0;\r
       while ( (line = in.readLine()) != null)\r
       {\r
+        lineNo++;\r
         st = new StringTokenizer(line, "\t");\r
-        if (st.countTokens() != 6)\r
+        if (st.countTokens() == 2)\r
         {\r
-          System.out.println("Groups file " + file +\r
-                             " is invalid. Read help file.");\r
-          System.exit(1);\r
+          type = st.nextToken();\r
+          UserColourScheme ucs = new UserColourScheme(st.nextToken());\r
+          fr.setColour(type, ucs.findColour("A"));\r
+          continue;\r
         }\r
 \r
         while (st.hasMoreElements())\r
         {\r
-          text = st.nextToken();\r
+          desc = st.nextToken();\r
           token = st.nextToken();\r
           if (!token.equals("ID_NOT_SPECIFIED"))\r
           {\r
@@ -188,19 +247,38 @@ public class AlignFrame
 \r
           start = Integer.parseInt(st.nextToken());\r
           end = Integer.parseInt(st.nextToken());\r
-          ucs = new UserColourScheme(st.nextToken());\r
 \r
           seq = viewport.alignment.getSequenceAt(index);\r
           start = seq.findIndex(start) - 1;\r
           end = seq.findIndex(end) - 1;\r
 \r
-          sg = new SequenceGroup(text, ucs, true, true, false, start, end);\r
-          sg.addSequence(seq, true);\r
+          type = st.nextToken();\r
+\r
+          if (fr.getColour(type) == null)\r
+          {\r
+            // Probably the old style groups file\r
+            UserColourScheme ucs = new UserColourScheme(type);\r
+            fr.setColour(type, ucs.findColour("A"));\r
+          }\r
+\r
+\r
+          sf = new SequenceFeature(type, desc, "", start, end);\r
+\r
+          seq.addSequenceFeature(sf);\r
+\r
+\r
+         // sg = new SequenceGroup(text, ucs, true, true, false, start, end);\r
+         // sg.addSequence(seq, false);\r
+\r
+         // viewport.alignment.addGroup(sg);\r
 \r
-          viewport.alignment.addGroup(sg);\r
         }\r
       }\r
 \r
+      viewport.showSequenceFeatures = true;\r
+\r
+      alignPanel.repaint();\r
+\r
     }\r
     catch (Exception ex)\r
     {\r
@@ -208,6 +286,12 @@ public class AlignFrame
     }\r
   }\r
 \r
+  public void fetchSequence_actionPerformed(ActionEvent e)\r
+  {\r
+    new SequenceFetcher(this);\r
+  }\r
+\r
+\r
   /**\r
    * DOCUMENT ME!\r
    *\r
@@ -326,7 +410,9 @@ public class AlignFrame
    */\r
   protected void htmlMenuItem_actionPerformed(ActionEvent e)\r
   {\r
-    new HTMLOutput(viewport);\r
+    new HTMLOutput(viewport,\r
+                   alignPanel.seqPanel.seqCanvas.getSequenceRenderer(),\r
+        alignPanel.seqPanel.seqCanvas.getFeatureRenderer());\r
   }\r
 \r
   public void createImageMap(File file, String image)\r
@@ -561,6 +647,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
@@ -570,7 +662,6 @@ public class AlignFrame
   {\r
     if (viewport.getSelectionGroup() == null)\r
     {\r
-      System.out.println("null here");\r
       return;\r
     }\r
 \r
@@ -579,7 +670,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
@@ -610,7 +701,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
@@ -634,12 +724,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
 \r
-    c.setContents(new StringSelection(FastaFile.print(seqs)), null);\r
+    FastaFile ff = new FastaFile();\r
+    ff.addJVSuffix( viewport.showJVSuffix );\r
+    c.setContents(new StringSelection( ff.print(seqs)), this);\r
+    Desktop.jalviewClipboard = new Object[]{seqs,  viewport.alignment.getDataset()};\r
   }\r
 \r
   /**\r
@@ -682,14 +780,35 @@ public class AlignFrame
       }\r
 \r
       String str = (String) contents.getTransferData(DataFlavor.stringFlavor);\r
+      if(str.length()<1)\r
+        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
+     {\r
+       sequences = new FormatAdapter().readFile(str, "Paste", format);\r
+     }\r
 \r
       if (newAlignment)\r
       {\r
-        AlignFrame af = new AlignFrame(new Alignment(sequences));\r
+\r
+        Alignment alignment = new Alignment(sequences);\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
         if (title.startsWith("Copied sequences"))\r
@@ -708,8 +827,25 @@ public class AlignFrame
       {\r
         //!newAlignment\r
         for (int i = 0; i < sequences.length; i++)\r
-          viewport.alignment.addSequence(sequences[i]);\r
+        {\r
+          Sequence newseq = new Sequence(sequences[i].getName(),\r
+              sequences[i].getSequence(), sequences[i].getStart(),\r
+              sequences[i].getEnd());\r
+          viewport.alignment.addSequence(newseq);\r
+          if(sequences[i].getDatasetSequence()==null)\r
+          {\r
+             ////////////////////////////\r
+            //Datset needs extension;\r
+            /////////////////////////////\r
+            Sequence ds = new Sequence(sequences[i].getName(),\r
+                                       AlignSeq.extractGaps("-. ", sequences[i].getSequence()),\r
+                                       sequences[i].getStart(),\r
+                                       sequences[i].getEnd());\r
+            newseq.setDatasetSequence(ds);\r
+            viewport.alignment.getDataset().addSequence(ds);\r
+          }\r
 \r
+        }\r
         viewport.setEndSeq(viewport.alignment.getHeight());\r
         viewport.alignment.getWidth();\r
         viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());\r
@@ -842,6 +978,7 @@ public class AlignFrame
     viewport.setSelectionGroup(null);\r
     viewport.getColumnSelection().clear();\r
     viewport.setSelectionGroup(null);\r
+    alignPanel.seqPanel.seqCanvas.highlightSearchResults(null);\r
     alignPanel.annotationPanel.activeRes = null;\r
     PaintRefresher.Refresh(null, viewport.alignment);\r
   }\r
@@ -1167,14 +1304,15 @@ 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
+\r
   /**\r
    * DOCUMENT ME!\r
    *\r
@@ -1276,15 +1414,15 @@ public class AlignFrame
   {\r
     viewport.showSequenceFeatures(sequenceFeatures.isSelected());\r
 \r
-    if (viewport.showSequenceFeatures &&\r
-        ! ( (Alignment) viewport.alignment).featuresAdded)\r
+    if (viewport.showSequenceFeatures)\r
     {\r
       new SequenceFeatureFetcher(viewport.\r
-          alignment,\r
+         alignment,\r
           alignPanel);\r
-      ( (Alignment) viewport.alignment).featuresAdded = true;\r
     }\r
 \r
+    featureSettings.setEnabled(true);\r
+\r
     alignPanel.repaint();\r
   }\r
 \r
@@ -2260,7 +2398,7 @@ public class AlignFrame
             {\r
               SequenceI[] msa = gatherSequencesForAlignment();\r
               new jalview.ws.MsaWSClient(sh, title, msa,\r
-                  false, true);\r
+                  false, true, viewport.getAlignment().getDataset());\r
 \r
             }\r
 \r
@@ -2277,7 +2415,7 @@ public class AlignFrame
               {\r
                 SequenceI[] msa = gatherSequencesForAlignment();\r
                 new jalview.ws.MsaWSClient(sh, title, msa,\r
-                    true, true);\r
+                    true, true, viewport.getAlignment().getDataset());\r
 \r
               }\r
 \r
@@ -2338,4 +2476,136 @@ public class AlignFrame
     // TODO: group services by location as well as function.\r
   }\r
 \r
+ /* public void vamsasStore_actionPerformed(ActionEvent e)\r
+  {\r
+    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.\r
+        getProperty("LAST_DIRECTORY"));\r
+\r
+    chooser.setFileView(new JalviewFileView());\r
+    chooser.setDialogTitle("Export to Vamsas file");\r
+    chooser.setToolTipText("Export");\r
+\r
+    int value = chooser.showSaveDialog(this);\r
+\r
+    if (value == JalviewFileChooser.APPROVE_OPTION)\r
+    {\r
+      jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(viewport);\r
+      //vs.store(chooser.getSelectedFile().getAbsolutePath()   );\r
+      vs.storeJalview( chooser.getSelectedFile().getAbsolutePath(), this);\r
+    }\r
+  }*/\r
+\r
+  public void featureSettings_actionPerformed(ActionEvent e)\r
+  {\r
+    new FeatureSettings(viewport, alignPanel);\r
+  }\r
+\r
+\r
+\r
+public void showTranslation_actionPerformed(ActionEvent e)\r
+{\r
+  int s, sSize = viewport.alignment.getHeight();\r
+  SequenceI [] newSeq = new SequenceI[sSize];\r
+\r
+  int res, resSize;\r
+  StringBuffer protein;\r
+  String seq;\r
+  for(s=0; s<sSize; s++)\r
+  {\r
+    protein = new StringBuffer();\r
+    seq = AlignSeq.extractGaps("-. ", viewport.alignment.getSequenceAt(s).getSequence());\r
+    resSize = seq.length();\r
+    for(res = 0; res < resSize; res+=3)\r
+    {\r
+      String codon = seq.substring(res, res+3);\r
+      codon = codon.replace('U', 'T');\r
+      String aa = ResidueProperties.codonTranslate(codon);\r
+      if(aa==null)\r
+        protein.append(viewport.getGapCharacter());\r
+      else if(aa.equals("STOP"))\r
+        protein.append("X");\r
+      else\r
+        protein.append( aa );\r
+    }\r
+    newSeq[s] = new Sequence(viewport.alignment.getSequenceAt(s).getName(), protein.toString());\r
+  }\r
+\r
+\r
+  AlignmentI al = new Alignment(newSeq);\r
+  al.setDataset(null);\r
+\r
+\r
+  ////////////////////////////////\r
+  // Copy annotations across\r
+  jalview.datamodel.AlignmentAnnotation[] annotations\r
+      = viewport.alignment.getAlignmentAnnotation();\r
+  int a, aSize;\r
+  for (int i = 0; i < annotations.length; i++)\r
+  {\r
+\r
+    if (annotations[i].label.equals("Quality") ||\r
+        annotations[i].label.equals("Conservation") ||\r
+        annotations[i].label.equals("Consensus"))\r
+    {\r
+      continue;\r
+    }\r
+\r
+\r
+    aSize = viewport.alignment.getWidth()/3;\r
+    jalview.datamodel.Annotation [] anots =\r
+        new jalview.datamodel.Annotation[aSize];\r
+\r
+    for(a=0; a<viewport.alignment.getWidth(); a++)\r
+    {\r
+     if( annotations[i].annotations[a]==null\r
+      || annotations[i].annotations[a]==null)\r
+       continue;\r
+\r
+      anots[a/3] = new Annotation(\r
+     annotations[i].annotations[a].displayCharacter,\r
+     annotations[i].annotations[a].description,\r
+     annotations[i].annotations[a].secondaryStructure,\r
+     annotations[i].annotations[a].value,\r
+     annotations[i].annotations[a].colour);\r
+    }\r
+\r
+    jalview.datamodel.AlignmentAnnotation aa\r
+          = new jalview.datamodel.AlignmentAnnotation(annotations[i].label,\r
+       annotations[i].description, anots );\r
+     al.addAnnotation(aa);\r
+  }\r
+\r
+\r
+    AlignFrame af = new AlignFrame(al);\r
+    Desktop.addInternalFrame(af, "Translation of "+this.getTitle(),\r
+                             NEW_WINDOW_WIDTH,\r
+                             NEW_WINDOW_HEIGHT);\r
+\r
+\r
+   // AlignViewport newViewport = new AlignViewport(al);\r
+   // AlignmentPanel ap = new AlignmentPanel(this, newViewport);\r
+   // tabbedPane.add("Protein", ap);\r
+   // viewports.add(newViewport);\r
+  //  alignPanels.add(ap);\r
+\r
+    ///Dataset tab\r
+  /////////////////////////\r
+\r
+  //  AlignViewport ds = new AlignViewport(al.getDataset());\r
+  //  ds.setDataset(true);\r
+  //  AlignmentPanel dap = new AlignmentPanel(this, ds);\r
+  //  tabbedPane.add("Dataset", dap);\r
+  //  viewports.add(ds);\r
+  //  alignPanels.add(dap);\r
+  /////////////////////////\r
+\r
+\r
+}\r
+\r
+/*public void tabSelected()\r
+ {\r
+  int index = tabbedPane.getSelectedIndex();\r
+  viewport = (AlignViewport)viewports.elementAt(index);\r
+  alignPanel = (AlignmentPanel)alignPanels.elementAt(index);\r
+ }*/\r
 }\r
index 2922f09..7f86753 100755 (executable)
@@ -43,7 +43,7 @@ public class AlignViewport
     int endRes;\r
     int startSeq;\r
     int endSeq;\r
-    boolean showFullId = false;\r
+    boolean showJVSuffix = true;\r
     boolean showText = true;\r
     boolean showColourText = false;\r
     boolean showBoxes = true;\r
@@ -86,6 +86,15 @@ public class AlignViewport
 \r
     boolean ignoreGapsInConsensusCalculation = false;\r
 \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
@@ -94,20 +103,17 @@ public class AlignViewport
     public AlignViewport(AlignmentI al)\r
     {\r
         setAlignment(al);\r
-        this.startRes = 0;\r
-        this.endRes = al.getWidth() - 1;\r
-        this.startSeq = 0;\r
-        this.endSeq = al.getHeight() - 1;\r
-\r
-        updateFromPreferences();\r
+        init();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void updateFromPreferences()\r
+    void init()\r
     {\r
-      showFullId = Cache.getDefault("SHOW_FULL_ID", true);\r
+        this.startRes = 0;\r
+        this.endRes = alignment.getWidth() - 1;\r
+        this.startSeq = 0;\r
+        this.endSeq = alignment.getHeight() - 1;\r
+\r
+      showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);\r
       showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);\r
       showConservation = Cache.getDefault("SHOW_CONSERVATION", true);\r
 \r
@@ -137,9 +143,11 @@ public class AlignViewport
 \r
         // We must set conservation and consensus before setting colour,\r
         // as Blosum and Clustal require this to be done\r
-        updateConservation();\r
-\r
-        updateConsensus();\r
+        if(vconsensus==null && !isDataset)\r
+        {\r
+          updateConservation();\r
+          updateConsensus();\r
+        }\r
 \r
         if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)\r
         {\r
@@ -914,9 +922,9 @@ public class AlignViewport
      *\r
      * @return DOCUMENT ME!\r
      */\r
-    public boolean getShowFullId()\r
+    public boolean getShowJVSuffix()\r
     {\r
-        return showFullId;\r
+        return showJVSuffix;\r
     }\r
 \r
     /**\r
@@ -924,11 +932,12 @@ public class AlignViewport
      *\r
      * @param b DOCUMENT ME!\r
      */\r
-    public void setShowFullId(boolean b)\r
+    public void setShowJVSuffix(boolean b)\r
     {\r
-        showFullId = b;\r
+        showJVSuffix = b;\r
     }\r
 \r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -1058,4 +1067,14 @@ public class AlignViewport
     {\r
      return ignoreGapsInConsensusCalculation;\r
     }\r
+\r
+    public void setDataset(boolean b)\r
+    {\r
+      isDataset = b;\r
+    }\r
+\r
+    public boolean isDataset()\r
+    {\r
+      return isDataset;\r
+    }\r
 }\r
index e31134b..ed00d33 100755 (executable)
@@ -24,17 +24,12 @@ import jalview.jbgui.*;
 \r
 import jalview.schemes.*;\r
 \r
-import org.jibble.epsgraphics.*;\r
-\r
 import java.awt.*;\r
 import java.awt.event.*;\r
-import java.awt.image.*;\r
 import java.awt.print.*;\r
 \r
 import java.io.*;\r
 \r
-import javax.imageio.*;\r
-\r
 import javax.swing.*;\r
 \r
 \r
@@ -47,1081 +42,946 @@ import javax.swing.*;
 public class AlignmentPanel extends GAlignmentPanel\r
     implements AdjustmentListener, Printable\r
 {\r
-    public AlignViewport av;\r
-    OverviewPanel overviewPanel;\r
-    SeqPanel seqPanel;\r
-    IdPanel idPanel;\r
-    IdwidthAdjuster idwidthAdjuster;\r
-\r
-    /** DOCUMENT ME!! */\r
-    public AlignFrame alignFrame;\r
-    ScalePanel scalePanel;\r
-    AnnotationPanel annotationPanel;\r
-    AnnotationLabels alabels;\r
-\r
-    // this value is set false when selection area being dragged\r
-    boolean fastPaint = true;\r
-    int hextent = 0;\r
-    int vextent = 0;\r
-\r
-    /**\r
-     * Creates a new AlignmentPanel object.\r
-     *\r
-     * @param af DOCUMENT ME!\r
-     * @param av DOCUMENT ME!\r
-     */\r
-    public AlignmentPanel(AlignFrame af, final AlignViewport av)\r
+  public AlignViewport av;\r
+  OverviewPanel overviewPanel;\r
+  SeqPanel seqPanel;\r
+  IdPanel idPanel;\r
+  IdwidthAdjuster idwidthAdjuster;\r
+\r
+  /** DOCUMENT ME!! */\r
+  public AlignFrame alignFrame;\r
+  ScalePanel scalePanel;\r
+  AnnotationPanel annotationPanel;\r
+  AnnotationLabels alabels;\r
+\r
+  // this value is set false when selection area being dragged\r
+  boolean fastPaint = true;\r
+  int hextent = 0;\r
+  int vextent = 0;\r
+\r
+  /**\r
+   * Creates a new AlignmentPanel object.\r
+   *\r
+   * @param af DOCUMENT ME!\r
+   * @param av DOCUMENT ME!\r
+   */\r
+  public AlignmentPanel(AlignFrame af, final AlignViewport av)\r
+  {\r
+    alignFrame = af;\r
+    this.av = av;\r
+    seqPanel = new SeqPanel(av, this);\r
+    idPanel = new IdPanel(av, this);\r
+\r
+    scalePanel = new ScalePanel(av, this);\r
+\r
+    idPanelHolder.add(idPanel, BorderLayout.CENTER);\r
+    idwidthAdjuster = new IdwidthAdjuster(this);\r
+    idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);\r
+\r
+    annotationPanel = new AnnotationPanel(this);\r
+    alabels = new AnnotationLabels(this);\r
+\r
+    annotationSpaceFillerHolder.setPreferredSize(annotationPanel.\r
+                                                 getPreferredSize());\r
+    annotationScroller.setPreferredSize(annotationPanel.getPreferredSize());\r
+    annotationScroller.setViewportView(annotationPanel);\r
+    annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);\r
+\r
+    fontChanged();\r
+\r
+    scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
+    seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
+\r
+    setScrollValues(0, 0);\r
+\r
+    annotationPanel.adjustPanelHeight();\r
+    annotationSpaceFillerHolder.setPreferredSize(annotationPanel.\r
+                                                 getPreferredSize());\r
+    annotationScroller.setPreferredSize(annotationPanel.\r
+                                        getPreferredSize());\r
+    setAnnotationVisible(av.getShowAnnotation());\r
+\r
+    hscroll.addAdjustmentListener(this);\r
+    vscroll.addAdjustmentListener(this);\r
+\r
+    af.addKeyListener(new KeyAdapter()\r
     {\r
-        alignFrame = af;\r
-        this.av = av;\r
-        seqPanel = new SeqPanel(av, this);\r
-        idPanel = new IdPanel(av, this);\r
-\r
-        scalePanel = new ScalePanel(av, this);\r
-\r
-        idPanelHolder.add(idPanel, BorderLayout.CENTER);\r
-        idwidthAdjuster = new IdwidthAdjuster(this);\r
-        idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER);\r
+      public void keyPressed(KeyEvent evt)\r
+      {\r
+        switch (evt.getKeyCode())\r
+        {\r
+          case 27: // escape key\r
+            av.setSelectionGroup(null);\r
+            repaint();\r
 \r
-        annotationPanel = new AnnotationPanel(this);\r
-        alabels = new AnnotationLabels(this);\r
+            break;\r
 \r
-        annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize());\r
-        annotationScroller.setPreferredSize(annotationPanel.getPreferredSize());\r
-        annotationScroller.setViewportView(annotationPanel);\r
-        annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER);\r
+          case KeyEvent.VK_DOWN:\r
+            alignFrame.moveSelectedSequences(false);\r
 \r
-        fontChanged();\r
+            break;\r
 \r
-        scalePanelHolder.add(scalePanel, BorderLayout.CENTER);\r
-        seqPanelHolder.add(seqPanel, BorderLayout.CENTER);\r
+          case KeyEvent.VK_UP:\r
+            alignFrame.moveSelectedSequences(true);\r
 \r
-        setScrollValues(0, 0);\r
+            break;\r
 \r
-        hscroll.addAdjustmentListener(this);\r
-        vscroll.addAdjustmentListener(this);\r
+          case KeyEvent.VK_BACK_SPACE:\r
+          case KeyEvent.VK_DELETE:\r
+            alignFrame.cut_actionPerformed(null);\r
+            break;\r
 \r
-        af.addKeyListener(new KeyAdapter()\r
-            {\r
-                public void keyPressed(KeyEvent evt)\r
-                {\r
-                    switch (evt.getKeyCode())\r
-                    {\r
-                    case 27: // escape key\r
-                        av.setSelectionGroup(null);\r
-                        repaint();\r
-\r
-                        break;\r
-\r
-                    case KeyEvent.VK_DOWN:\r
-                        alignFrame.moveSelectedSequences(false);\r
-\r
-                        break;\r
-\r
-                    case KeyEvent.VK_UP:\r
-                        alignFrame.moveSelectedSequences(true);\r
-\r
-                        break;\r
-\r
-                    case KeyEvent.VK_BACK_SPACE:\r
-                    case KeyEvent.VK_DELETE:\r
-                      alignFrame.cut_actionPerformed(null);\r
-                      break;\r
-\r
-                    case KeyEvent.VK_P:\r
-                      seqPanel.seqCanvas.increaseAARatio();\r
-                      break;\r
-                    case KeyEvent.VK_L:\r
-                      seqPanel.seqCanvas.decreaseAARation();\r
-                      break;\r
-                    }\r
-                }\r
-            });\r
+          case KeyEvent.VK_P:\r
+            seqPanel.seqCanvas.increaseAARatio();\r
+            break;\r
+          case KeyEvent.VK_L:\r
+            seqPanel.seqCanvas.decreaseAARation();\r
+            break;\r
+        }\r
+      }\r
+    });\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   */\r
+  public void fontChanged()\r
+  {\r
+    // set idCanvas bufferedImage to null\r
+    // to prevent drawing old image\r
+    FontMetrics fm = getFontMetrics(av.getFont());\r
+\r
+    scalePanelHolder.setPreferredSize(new Dimension(10,\r
+        av.charHeight + fm.getDescent()));\r
+    idSpaceFillerPanel1.setPreferredSize(new Dimension(10,\r
+        av.charHeight + fm.getDescent()));\r
+\r
+    idPanel.idCanvas.gg = null;\r
+    seqPanel.seqCanvas.img = null;\r
+    annotationPanel.adjustPanelHeight();\r
+\r
+    Dimension d = calculateIdWidth();\r
+    d.setSize(d.width + 4, d.height);\r
+    idPanel.idCanvas.setPreferredSize(d);\r
+    hscrollFillerPanel.setPreferredSize(d);\r
+\r
+    if (av.getWrapAlignment())\r
+    {\r
+      int max = av.alignment.getWidth() /\r
+          seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
+      vscroll.setMaximum(max);\r
+      vscroll.setUnitIncrement(1);\r
+      vscroll.setVisibleAmount(1);\r
     }\r
-\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void fontChanged()\r
+    else\r
     {\r
-        // set idCanvas bufferedImage to null\r
-        // to prevent drawing old image\r
-        FontMetrics fm = getFontMetrics(av.getFont());\r
-\r
-        scalePanelHolder.setPreferredSize(new Dimension(10,\r
-                av.charHeight + fm.getDescent()));\r
-        idSpaceFillerPanel1.setPreferredSize(new Dimension(10,\r
-                av.charHeight + fm.getDescent()));\r
+      setScrollValues(av.getStartRes(), av.getStartSeq());\r
+    }\r
 \r
-        idPanel.idCanvas.gg = null;\r
-        seqPanel.seqCanvas.img = null;\r
-        annotationPanel.adjustPanelHeight();\r
+    if (overviewPanel != null)\r
+      overviewPanel.setBoxPosition();\r
 \r
-        Dimension d = calculateIdWidth();\r
-        d.setSize(d.width + 4, d.height);\r
-        idPanel.idCanvas.setPreferredSize(d);\r
-        hscrollFillerPanel.setPreferredSize(d);\r
+    repaint();\r
+  }\r
 \r
-        if (av.getWrapAlignment())\r
-        {\r
-          int max = av.alignment.getWidth() /\r
-              seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
-          vscroll.setMaximum(max);\r
-          vscroll.setUnitIncrement(1);\r
-          vscroll.setVisibleAmount(1);\r
-        }\r
-        else\r
-        {\r
-          setScrollValues(av.getStartRes(), av.getStartSeq());\r
-        }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public Dimension calculateIdWidth()\r
+  {\r
+    Container c = new Container();\r
 \r
-        if(overviewPanel!=null)\r
-          overviewPanel.setBoxPosition();\r
+    FontMetrics fm = c.getFontMetrics(av.font);\r
+    AlignmentI al = av.getAlignment();\r
 \r
-        repaint();\r
-    }\r
+    int i = 0;\r
+    int idWidth = 0;\r
+    String id;\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Dimension calculateIdWidth()\r
+    while ( (i < al.getHeight()) && (al.getSequenceAt(i) != null))\r
     {\r
-      Container c = new Container();\r
+      SequenceI s = al.getSequenceAt(i);\r
 \r
-        FontMetrics fm = c.getFontMetrics(av.font);\r
-        AlignmentI al = av.getAlignment();\r
+      id = s.getDisplayId(av.getShowJVSuffix());\r
 \r
-        int i = 0;\r
-        int idWidth = 0;\r
-        String id;\r
-\r
-        while ((i < al.getHeight()) && (al.getSequenceAt(i) != null))\r
-        {\r
-            SequenceI s = al.getSequenceAt(i);\r
+      if (fm.stringWidth(id) > idWidth)\r
+      {\r
+        idWidth = fm.stringWidth(id);\r
+      }\r
 \r
-            if (av.getShowFullId())\r
-            {\r
-                id = s.getDisplayId();\r
-            }\r
-            else\r
-            {\r
-                id = s.getName();\r
-            }\r
+      i++;\r
+    }\r
 \r
-            if (fm.stringWidth(id) > idWidth)\r
-            {\r
-                idWidth = fm.stringWidth(id);\r
-            }\r
+    // Also check annotation label widths\r
+    i = 0;\r
 \r
-            i++;\r
-        }\r
+    if (al.getAlignmentAnnotation() != null)\r
+    {\r
+      fm = c.getFontMetrics(alabels.getFont());\r
 \r
-        // Also check annotation label widths\r
-        i = 0;\r
+      while (i < al.getAlignmentAnnotation().length)\r
+      {\r
+        String label = al.getAlignmentAnnotation()[i].label;\r
 \r
-        if (al.getAlignmentAnnotation() != null)\r
+        if (fm.stringWidth(label) > idWidth)\r
         {\r
-            fm = c.getFontMetrics(alabels.getFont());\r
-\r
-            while (i < al.getAlignmentAnnotation().length)\r
-            {\r
-                String label = al.getAlignmentAnnotation()[i].label;\r
-\r
-                if (fm.stringWidth(label) > idWidth)\r
-                {\r
-                    idWidth = fm.stringWidth(label);\r
-                }\r
-\r
-                i++;\r
-            }\r
+          idWidth = fm.stringWidth(label);\r
         }\r
 \r
-        return new Dimension(idWidth, 12);\r
+        i++;\r
+      }\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param results DOCUMENT ME!\r
-     */\r
-    public void highlightSearchResults(int[] results)\r
-    {\r
-        seqPanel.seqCanvas.highlightSearchResults(results);\r
+    return new Dimension(idWidth, 12);\r
+  }\r
 \r
-        // do we need to scroll the panel?\r
-        if (results != null)\r
-        {\r
-            SequenceI seq = av.alignment.getSequenceAt(results[0]);\r
-            int start = seq.findIndex(results[1]) - 1;\r
-            int end = seq.findIndex(results[2]) - 1;\r
-\r
-            if ((av.getStartRes() > start) || (av.getEndRes() < end) ||\r
-                    ((av.getStartSeq() > results[0]) ||\r
-                    (av.getEndSeq() < results[0])))\r
-            {\r
-                setScrollValues(start, results[0]);\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public OverviewPanel getOverviewPanel()\r
-    {\r
-        return overviewPanel;\r
-    }\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param results DOCUMENT ME!\r
+   */\r
+  public void highlightSearchResults(int[] results)\r
+  {\r
+    seqPanel.seqCanvas.highlightSearchResults(results);\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param op DOCUMENT ME!\r
-     */\r
-    public void setOverviewPanel(OverviewPanel op)\r
+    // do we need to scroll the panel?\r
+    if (results != null)\r
     {\r
-        overviewPanel = op;\r
-    }\r
+      SequenceI seq = av.alignment.getSequenceAt(results[0]);\r
+      int start = seq.findIndex(results[1]) - 1;\r
+      int end = seq.findIndex(results[2]) - 1;\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param b DOCUMENT ME!\r
-     */\r
-    public void setAnnotationVisible(boolean b)\r
-    {\r
-      if (!av.wrapAlignment)\r
+      if ( (av.getStartRes() > start) || (av.getEndRes() < end) ||\r
+          ( (av.getStartSeq() > results[0]) ||\r
+           (av.getEndSeq() < results[0])))\r
       {\r
-        annotationSpaceFillerHolder.setVisible(b);\r
-        annotationScroller.setVisible(b);\r
+        setScrollValues(start, results[0]);\r
       }\r
-      repaint();\r
     }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param wrap DOCUMENT ME!\r
-     */\r
-    public void setWrapAlignment(boolean wrap)\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public OverviewPanel getOverviewPanel()\r
+  {\r
+    return overviewPanel;\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param op DOCUMENT ME!\r
+   */\r
+  public void setOverviewPanel(OverviewPanel op)\r
+  {\r
+    overviewPanel = op;\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param b DOCUMENT ME!\r
+   */\r
+  public void setAnnotationVisible(boolean b)\r
+  {\r
+    if (!av.wrapAlignment)\r
     {\r
-        av.startSeq = 0;\r
-        scalePanelHolder.setVisible(!wrap);\r
-        hscroll.setVisible(!wrap);\r
-        idwidthAdjuster.setVisible(!wrap);\r
-\r
-       if(wrap)\r
-       {\r
-         annotationScroller.setVisible(false);\r
-         annotationSpaceFillerHolder.setVisible(false);\r
-       }\r
-       else if(av.showAnnotation)\r
-       {\r
-         annotationScroller.setVisible(true);\r
-         annotationSpaceFillerHolder.setVisible(true);\r
-       }\r
-\r
-       idSpaceFillerPanel1.setVisible(!wrap);\r
-\r
-        repaint();\r
+      annotationSpaceFillerHolder.setVisible(b);\r
+      annotationScroller.setVisible(b);\r
     }\r
-\r
-\r
-    // return value is true if the scroll is valid\r
-    public boolean scrollUp(boolean up)\r
+    repaint();\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param wrap DOCUMENT ME!\r
+   */\r
+  public void setWrapAlignment(boolean wrap)\r
+  {\r
+    av.startSeq = 0;\r
+    scalePanelHolder.setVisible(!wrap);\r
+    hscroll.setVisible(!wrap);\r
+    idwidthAdjuster.setVisible(!wrap);\r
+\r
+    if (wrap)\r
     {\r
-        if (up)\r
-        {\r
-            if (vscroll.getValue() < 1)\r
-            {\r
-                return false;\r
-            }\r
-\r
-            fastPaint = false;\r
-            vscroll.setValue(vscroll.getValue() - 1);\r
-        }\r
-        else\r
-        {\r
-            if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight())\r
-            {\r
-                return false;\r
-            }\r
-\r
-            fastPaint = false;\r
-            vscroll.setValue(vscroll.getValue() + 1);\r
-        }\r
-\r
-        fastPaint = true;\r
-\r
-        return true;\r
+      annotationScroller.setVisible(false);\r
+      annotationSpaceFillerHolder.setVisible(false);\r
     }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param right DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public boolean scrollRight(boolean right)\r
+    else if (av.showAnnotation)\r
     {\r
-        if (right)\r
-        {\r
-            if (hscroll.getValue() < 1)\r
-            {\r
-                return false;\r
-            }\r
+      annotationScroller.setVisible(true);\r
+      annotationSpaceFillerHolder.setVisible(true);\r
+    }\r
 \r
-            fastPaint = false;\r
-            hscroll.setValue(hscroll.getValue() - 1);\r
-        }\r
-        else\r
-        {\r
-            if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth())\r
-            {\r
-                return false;\r
-            }\r
+    idSpaceFillerPanel1.setVisible(!wrap);\r
 \r
-            fastPaint = false;\r
-            hscroll.setValue(hscroll.getValue() + 1);\r
-        }\r
+    repaint();\r
+  }\r
 \r
-        fastPaint = true;\r
+  // return value is true if the scroll is valid\r
+  public boolean scrollUp(boolean up)\r
+  {\r
+    if (up)\r
+    {\r
+      if (vscroll.getValue() < 1)\r
+      {\r
+        return false;\r
+      }\r
 \r
-        return true;\r
+      fastPaint = false;\r
+      vscroll.setValue(vscroll.getValue() - 1);\r
     }\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param x DOCUMENT ME!\r
-     * @param y DOCUMENT ME!\r
-     */\r
-    public void setScrollValues(int x, int y)\r
+    else\r
     {\r
-        av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) -\r
-            1);\r
-\r
-        hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;\r
-        vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;\r
-\r
-        if (hextent > av.alignment.getWidth())\r
-        {\r
-            hextent = av.alignment.getWidth();\r
-        }\r
-\r
-        if (vextent > av.alignment.getHeight())\r
-        {\r
-            vextent = av.alignment.getHeight();\r
-        }\r
-\r
-        if ((hextent + x) > av.getAlignment().getWidth())\r
-        {\r
-            x = av.getAlignment().getWidth() - hextent;\r
-        }\r
-\r
-        if ((vextent + y) > av.getAlignment().getHeight())\r
-        {\r
-            y = av.getAlignment().getHeight() - vextent;\r
-        }\r
-\r
-        if (y < 0)\r
-        {\r
-            y = 0;\r
-        }\r
-\r
-        if (x < 0)\r
-        {\r
-            x = 0;\r
-        }\r
+      if ( (vextent + vscroll.getValue()) >= av.getAlignment().getHeight())\r
+      {\r
+        return false;\r
+      }\r
 \r
-        hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth());\r
-        vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight());\r
+      fastPaint = false;\r
+      vscroll.setValue(vscroll.getValue() + 1);\r
     }\r
 \r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param evt DOCUMENT ME!\r
-     */\r
-    public void adjustmentValueChanged(AdjustmentEvent evt)\r
+    fastPaint = true;\r
+\r
+    return true;\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param right DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   */\r
+  public boolean scrollRight(boolean right)\r
+  {\r
+    if (right)\r
     {\r
+      if (hscroll.getValue() < 1)\r
+      {\r
+        return false;\r
+      }\r
 \r
-        int oldX = av.getStartRes();\r
-        int oldY = av.getStartSeq();\r
-\r
-        if (evt.getSource() == hscroll)\r
-        {\r
-            int x = hscroll.getValue();\r
-            av.setStartRes(x);\r
-            av.setEndRes((x +\r
-                (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);\r
-        }\r
-\r
-        if (evt.getSource() == vscroll)\r
-        {\r
-            int offy = vscroll.getValue();\r
+      fastPaint = false;\r
+      hscroll.setValue(hscroll.getValue() - 1);\r
+    }\r
+    else\r
+    {\r
+      if ( (hextent + hscroll.getValue()) >= av.getAlignment().getWidth())\r
+      {\r
+        return false;\r
+      }\r
 \r
-            if (av.getWrapAlignment())\r
-            {\r
-                int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
-                av.setStartRes(vscroll.getValue() * rowSize);\r
-                av.setEndRes((vscroll.getValue() + 1) * rowSize);\r
-            }\r
-            else\r
-            {\r
-                av.setStartSeq(offy);\r
-                av.setEndSeq(offy +\r
-                    (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));\r
-            }\r
-        }\r
+      fastPaint = false;\r
+      hscroll.setValue(hscroll.getValue() + 1);\r
+    }\r
 \r
-        if (overviewPanel != null)\r
-        {\r
-            overviewPanel.setBoxPosition();\r
-        }\r
+    fastPaint = true;\r
 \r
-        int xShift = av.getStartRes() - oldX;\r
-        int yShift = av.getStartSeq() - oldY;\r
+    return true;\r
+  }\r
 \r
-        if ( (xShift != 0 && yShift != 0) ||\r
-            (Math.abs(xShift) > av.getEndRes() - av.getStartRes()\r
-             || Math.abs(yShift) > av.getEndSeq() - av.getStartSeq())\r
-             || av.getWrapAlignment()\r
-             || !fastPaint)\r
-        {\r
-          // Either no shift at all, or shift greater than visible amount\r
-          repaint();\r
-        }\r
-        else\r
-        {\r
-            idPanel.idCanvas.fastPaint(yShift);\r
-            seqPanel.seqCanvas.fastPaint(xShift, yShift);\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param x DOCUMENT ME!\r
+   * @param y DOCUMENT ME!\r
+   */\r
+  public void setScrollValues(int x, int y)\r
+  {\r
+    av.setEndRes( (x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) -\r
+                 1);\r
 \r
-            scalePanel.repaint();\r
+    hextent = seqPanel.seqCanvas.getWidth() / av.charWidth;\r
+    vextent = seqPanel.seqCanvas.getHeight() / av.charHeight;\r
 \r
-            if (av.getShowAnnotation())\r
-            {\r
-                annotationPanel.fastPaint(xShift);\r
-            }\r
-        }\r
+    if (hextent > av.alignment.getWidth())\r
+    {\r
+      hextent = av.alignment.getWidth();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param g DOCUMENT ME!\r
-     */\r
-    public void paintComponent(Graphics g)\r
+    if (vextent > av.alignment.getHeight())\r
     {\r
-        invalidate();\r
-\r
-        Dimension d = idPanel.idCanvas.getPreferredSize();\r
-        idPanelHolder.setPreferredSize(d);\r
-        hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
-        validate();\r
-\r
-        if (av.getWrapAlignment())\r
-        {\r
-            int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth());\r
-            vscroll.setMaximum(max);\r
-            vscroll.setUnitIncrement(1);\r
-            vscroll.setVisibleAmount(1);\r
-        }\r
-        else\r
-        {\r
-            setScrollValues(av.getStartRes(), av.getStartSeq());\r
-        }\r
+      vextent = av.alignment.getHeight();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param pg DOCUMENT ME!\r
-     * @param pf DOCUMENT ME!\r
-     * @param pi DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     *\r
-     * @throws PrinterException DOCUMENT ME!\r
-     */\r
-    public int print(Graphics pg, PageFormat pf, int pi)\r
-        throws PrinterException\r
+    if ( (hextent + x) > av.getAlignment().getWidth())\r
     {\r
-        pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());\r
-\r
-        int pwidth = (int) pf.getImageableWidth();\r
-        int pheight = (int) pf.getImageableHeight();\r
-\r
-        if (av.getWrapAlignment())\r
-        {\r
-            return printWrappedAlignment(pg, pwidth, pheight, pi);\r
-        }\r
-        else\r
-        {\r
-            return printUnwrapped(pg, pwidth, pheight, pi);\r
-        }\r
+      x = av.getAlignment().getWidth() - hextent;\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param pg DOCUMENT ME!\r
-     * @param pwidth DOCUMENT ME!\r
-     * @param pheight DOCUMENT ME!\r
-     * @param pi DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     *\r
-     * @throws PrinterException DOCUMENT ME!\r
-     */\r
-    public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)\r
-        throws PrinterException\r
+    if ( (vextent + y) > av.getAlignment().getHeight())\r
     {\r
-        int idWidth = calculateIdWidth().width + 4;\r
-        FontMetrics fm = getFontMetrics(av.getFont());\r
-        int scaleHeight = av.charHeight + fm.getDescent();\r
-\r
-        pg.setColor(Color.white);\r
-        pg.fillRect(0, 0, pwidth, pheight);\r
-        pg.setFont(av.getFont());\r
-\r
-        ////////////////////////////////////\r
-        /// How many sequences and residues can we fit on a printable page?\r
-        int totalRes = (pwidth - idWidth) / av.getCharWidth();\r
-\r
-        int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) -\r
-            1;\r
+      y = av.getAlignment().getHeight() - vextent;\r
+    }\r
 \r
-        int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;\r
+    if (y < 0)\r
+    {\r
+      y = 0;\r
+    }\r
 \r
-        /////////////////////////////\r
-        /// Only print these sequences and residues on this page\r
-        int startRes;\r
+    if (x < 0)\r
+    {\r
+      x = 0;\r
+    }\r
 \r
-        /////////////////////////////\r
-        /// Only print these sequences and residues on this page\r
-        int endRes;\r
+    hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth());\r
+    vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight());\r
+  }\r
 \r
-        /////////////////////////////\r
-        /// Only print these sequences and residues on this page\r
-        int startSeq;\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param evt DOCUMENT ME!\r
+   */\r
+  public void adjustmentValueChanged(AdjustmentEvent evt)\r
+  {\r
 \r
-        /////////////////////////////\r
-        /// Only print these sequences and residues on this page\r
-        int endSeq;\r
-        startRes = (pi % pagesWide) * totalRes;\r
-        endRes = (startRes + totalRes) - 1;\r
+    int oldX = av.getStartRes();\r
+    int oldY = av.getStartSeq();\r
 \r
-        if (endRes > (av.getAlignment().getWidth() - 1))\r
-        {\r
-            endRes = av.getAlignment().getWidth() - 1;\r
-        }\r
+    if (evt.getSource() == hscroll)\r
+    {\r
+      int x = hscroll.getValue();\r
+      av.setStartRes(x);\r
+      av.setEndRes( (x +\r
+                     (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1);\r
+    }\r
 \r
-        startSeq = (pi / pagesWide) * totalSeq;\r
-        endSeq = startSeq + totalSeq;\r
+    if (evt.getSource() == vscroll)\r
+    {\r
+      int offy = vscroll.getValue();\r
 \r
-        if (endSeq > av.getAlignment().getHeight())\r
-        {\r
-            endSeq = av.getAlignment().getHeight();\r
-        }\r
+      if (av.getWrapAlignment())\r
+      {\r
+        int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.\r
+            seqCanvas.getWidth());\r
+        av.setStartRes(vscroll.getValue() * rowSize);\r
+        av.setEndRes( (vscroll.getValue() + 1) * rowSize);\r
+      }\r
+      else\r
+      {\r
+        av.setStartSeq(offy);\r
+        av.setEndSeq(offy +\r
+                     (seqPanel.seqCanvas.getHeight() / av.getCharHeight()));\r
+      }\r
+    }\r
 \r
-        int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight;\r
+    if (overviewPanel != null)\r
+    {\r
+      overviewPanel.setBoxPosition();\r
+    }\r
 \r
-        if (av.showAnnotation)\r
-        {\r
-            pagesHigh += annotationPanel.adjustPanelHeight()+3;\r
-        }\r
+    int xShift = av.getStartRes() - oldX;\r
+    int yShift = av.getStartSeq() - oldY;\r
 \r
-        pagesHigh /= pheight;\r
+    if ( (xShift != 0 && yShift != 0) ||\r
+        (Math.abs(xShift) > av.getEndRes() - av.getStartRes()\r
+         || Math.abs(yShift) > av.getEndSeq() - av.getStartSeq())\r
+        || av.getWrapAlignment()\r
+        || !fastPaint)\r
+    {\r
+      // Either no shift at all, or shift greater than visible amount\r
+      repaint();\r
+    }\r
+    else\r
+    {\r
+      idPanel.idCanvas.fastPaint(yShift);\r
+      seqPanel.seqCanvas.fastPaint(xShift, yShift);\r
 \r
-        if (pi >= (pagesWide * pagesHigh))\r
-        {\r
-            return Printable.NO_SUCH_PAGE;\r
-        }\r
+      scalePanel.repaint();\r
 \r
-        //draw Scale\r
-        pg.translate(idWidth, 0);\r
-        scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);\r
-        pg.translate(-idWidth, scaleHeight);\r
+      if (av.getShowAnnotation())\r
+      {\r
+        annotationPanel.fastPaint(xShift);\r
+      }\r
+    }\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param g DOCUMENT ME!\r
+   */\r
+  public void paintComponent(Graphics g)\r
+  {\r
+    invalidate();\r
+\r
+    Dimension d = idPanel.idCanvas.getPreferredSize();\r
+    idPanelHolder.setPreferredSize(d);\r
+    hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12));\r
+    validate();\r
+\r
+    if (av.getWrapAlignment())\r
+    {\r
+      int max = av.alignment.getWidth() /\r
+          seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()) +1;\r
+      vscroll.setMaximum(max);\r
+      vscroll.setUnitIncrement(1);\r
+      vscroll.setVisibleAmount(1);\r
+    }\r
+    else\r
+    {\r
+      setScrollValues(av.getStartRes(), av.getStartSeq());\r
+    }\r
 \r
-        ////////////////\r
-        // Draw the ids\r
-        Color currentColor = null;\r
-        Color currentTextColor = null;\r
 \r
-        for (int i = startSeq; i < endSeq; i++)\r
-        {\r
-            if ((av.getSelectionGroup() != null) &&\r
-                    av.getSelectionGroup().sequences.contains(\r
-                        av.getAlignment().getSequenceAt(i)))\r
-            {\r
-                currentColor = Color.gray;\r
-                currentTextColor = Color.black;\r
-            }\r
-            else\r
-            {\r
-                currentColor = av.getAlignment().getSequenceAt(i).getColor();\r
-                currentTextColor = Color.black;\r
-            }\r
+    if( this.getVisibleRect().getBounds() == g.getClipBounds() )\r
+    {\r
+      if (overviewPanel != null)\r
+        overviewPanel.updateOverviewImage();\r
+    }\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param pg DOCUMENT ME!\r
+   * @param pf DOCUMENT ME!\r
+   * @param pi DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   *\r
+   * @throws PrinterException DOCUMENT ME!\r
+   */\r
+  public int print(Graphics pg, PageFormat pf, int pi)\r
+      throws PrinterException\r
+  {\r
+    pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY());\r
+\r
+    int pwidth = (int) pf.getImageableWidth();\r
+    int pheight = (int) pf.getImageableHeight();\r
+\r
+    if (av.getWrapAlignment())\r
+    {\r
+      return printWrappedAlignment(pg, pwidth, pheight, pi);\r
+    }\r
+    else\r
+    {\r
+      return printUnwrapped(pg, pwidth, pheight, pi);\r
+    }\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param pg DOCUMENT ME!\r
+   * @param pwidth DOCUMENT ME!\r
+   * @param pheight DOCUMENT ME!\r
+   * @param pi DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   *\r
+   * @throws PrinterException DOCUMENT ME!\r
+   */\r
+  public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi)\r
+      throws PrinterException\r
+  {\r
+    int idWidth = calculateIdWidth().width + 4;\r
+    FontMetrics fm = getFontMetrics(av.getFont());\r
+    int scaleHeight = av.charHeight + fm.getDescent();\r
+\r
+    pg.setColor(Color.white);\r
+    pg.fillRect(0, 0, pwidth, pheight);\r
+    pg.setFont(av.getFont());\r
+\r
+    ////////////////////////////////////\r
+    /// How many sequences and residues can we fit on a printable page?\r
+    int totalRes = (pwidth - idWidth) / av.getCharWidth();\r
+\r
+    int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) -\r
+        1;\r
+\r
+    int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1;\r
+\r
+    /////////////////////////////\r
+    /// Only print these sequences and residues on this page\r
+    int startRes;\r
+\r
+    /////////////////////////////\r
+    /// Only print these sequences and residues on this page\r
+    int endRes;\r
+\r
+    /////////////////////////////\r
+    /// Only print these sequences and residues on this page\r
+    int startSeq;\r
+\r
+    /////////////////////////////\r
+    /// Only print these sequences and residues on this page\r
+    int endSeq;\r
+    startRes = (pi % pagesWide) * totalRes;\r
+    endRes = (startRes + totalRes) - 1;\r
+\r
+    if (endRes > (av.getAlignment().getWidth() - 1))\r
+    {\r
+      endRes = av.getAlignment().getWidth() - 1;\r
+    }\r
 \r
-            pg.setColor(currentColor);\r
-            pg.fillRect(0, (i-startSeq) * av.charHeight, idWidth,\r
-                av.getCharHeight());\r
+    startSeq = (pi / pagesWide) * totalSeq;\r
+    endSeq = startSeq + totalSeq;\r
 \r
-            pg.setColor(currentTextColor);\r
+    if (endSeq > av.getAlignment().getHeight())\r
+    {\r
+      endSeq = av.getAlignment().getHeight();\r
+    }\r
 \r
-            String string = av.getAlignment().getSequenceAt(i).getName();\r
+    int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight;\r
 \r
-            if (av.getShowFullId())\r
-            {\r
-                string = av.getAlignment().getSequenceAt(i).getDisplayId();\r
-            }\r
+    if (av.showAnnotation)\r
+    {\r
+      pagesHigh += annotationPanel.adjustPanelHeight() + 3;\r
+    }\r
 \r
-            pg.drawString(string, 0,\r
-                (((i-startSeq) * av.charHeight) + av.getCharHeight()) -\r
-                (av.getCharHeight() / 5));\r
-        }\r
+    pagesHigh /= pheight;\r
 \r
-        // draw main sequence panel\r
-        pg.translate(idWidth, 0);\r
-        seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq,\r
-            startRes, startSeq, 0);\r
+    if (pi >= (pagesWide * pagesHigh))\r
+    {\r
+      return Printable.NO_SUCH_PAGE;\r
+    }\r
 \r
-        if (av.showAnnotation && (endSeq == av.alignment.getHeight()))\r
-        {\r
-            pg.translate(-idWidth, (endSeq - startSeq) * av.charHeight +3);\r
-            alabels.drawComponent((Graphics2D) pg, idWidth);\r
-            pg.translate(idWidth, 0);\r
-            annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes +\r
-                1);\r
-        }\r
+    //draw Scale\r
+    pg.translate(idWidth, 0);\r
+    scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight);\r
+    pg.translate( -idWidth, scaleHeight);\r
 \r
-        return Printable.PAGE_EXISTS;\r
-    }\r
+    ////////////////\r
+    // Draw the ids\r
+    Color currentColor = null;\r
+    Color currentTextColor = null;\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param pg DOCUMENT ME!\r
-     * @param pwidth DOCUMENT ME!\r
-     * @param pheight DOCUMENT ME!\r
-     * @param pi DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     *\r
-     * @throws PrinterException DOCUMENT ME!\r
-     */\r
-    public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,\r
-        int pi) throws PrinterException\r
+    for (int i = startSeq; i < endSeq; i++)\r
     {\r
-\r
-      int annotationHeight = 0;\r
-      AnnotationLabels labels = null;\r
-      if (av.showAnnotation)\r
+      if ( (av.getSelectionGroup() != null) &&\r
+          av.getSelectionGroup().sequences.contains(\r
+              av.getAlignment().getSequenceAt(i)))\r
       {\r
-        annotationHeight = annotationPanel.adjustPanelHeight();\r
-        labels = new AnnotationLabels(av);\r
+        currentColor = Color.gray;\r
+        currentTextColor = Color.black;\r
+      }\r
+      else\r
+      {\r
+        currentColor = av.getAlignment().getSequenceAt(i).getColor();\r
+        currentTextColor = Color.black;\r
       }\r
 \r
-      int hgap = av.charHeight;\r
-      if (av.scaleAboveWrapped)\r
-        hgap += av.charHeight;\r
-\r
-      int cHeight = av.getAlignment().getHeight() * av.charHeight\r
-          + hgap\r
-          + annotationHeight;\r
-\r
-\r
-      int idWidth = calculateIdWidth().width + 4;\r
-\r
-        int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -\r
-                idWidth);\r
+      pg.setColor(currentColor);\r
+      pg.fillRect(0, (i - startSeq) * av.charHeight, idWidth,\r
+                  av.getCharHeight());\r
 \r
-        int totalHeight = cHeight * (av.alignment.getWidth() / resWidth +1);\r
+      pg.setColor(currentTextColor);\r
 \r
-        pg.setColor(Color.white);\r
-        pg.fillRect(0, 0, pwidth, pheight);\r
-        pg.setFont(av.getFont());\r
+      String string = av.getAlignment().getSequenceAt(i).getDisplayId\r
+          ( av.getShowJVSuffix());\r
 \r
+      pg.drawString(string, 0,\r
+                    ( ( (i - startSeq) * av.charHeight) + av.getCharHeight()) -\r
+                    (av.getCharHeight() / 5));\r
+    }\r
 \r
-        ////////////////\r
-        // Draw the ids\r
-        pg.setColor(Color.black);\r
+    // draw main sequence panel\r
+    pg.translate(idWidth, 0);\r
+    seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq,\r
+                                 startRes, startSeq, 0);\r
 \r
-        pg.translate(0, -pi * pheight);\r
+    if (av.showAnnotation && (endSeq == av.alignment.getHeight()))\r
+    {\r
+      pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight + 3);\r
+      alabels.drawComponent( (Graphics2D) pg, idWidth);\r
+      pg.translate(idWidth, 0);\r
+      annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes +\r
+                                    1);\r
+    }\r
 \r
-        pg.setClip(0, pi * pheight, pwidth, pheight);\r
+    return Printable.PAGE_EXISTS;\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @param pg DOCUMENT ME!\r
+   * @param pwidth DOCUMENT ME!\r
+   * @param pheight DOCUMENT ME!\r
+   * @param pi DOCUMENT ME!\r
+   *\r
+   * @return DOCUMENT ME!\r
+   *\r
+   * @throws PrinterException DOCUMENT ME!\r
+   */\r
+  public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,\r
+                                   int pi)\r
+      throws PrinterException\r
+  {\r
+\r
+    int annotationHeight = 0;\r
+    AnnotationLabels labels = null;\r
+    if (av.showAnnotation)\r
+    {\r
+      annotationHeight = annotationPanel.adjustPanelHeight();\r
+      labels = new AnnotationLabels(av);\r
+    }\r
 \r
-        int ypos = hgap;\r
-        Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
-                             av.getFont().getSize());\r
-        pg.setFont(italic);\r
+    int hgap = av.charHeight;\r
+    if (av.scaleAboveWrapped)\r
+      hgap += av.charHeight;\r
 \r
+    int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+        + hgap\r
+        + annotationHeight;\r
 \r
-        do\r
-        {\r
-          for (int i = 0; i < av.alignment.getHeight(); i++)\r
-          {\r
-            SequenceI s = av.alignment.getSequenceAt(i);\r
-            String string = s.getName();\r
+    int idWidth = calculateIdWidth().width + 4;\r
 \r
-            if (av.getShowFullId())\r
-            {\r
-              string = s.getDisplayId();\r
-            }\r
+    int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -\r
+        idWidth);\r
 \r
-            pg.drawString(string, 0,\r
-                          ( (i * av.charHeight) + ypos + av.charHeight) -\r
-                          (av.charHeight / 5));\r
-          }\r
-            if (labels != null)\r
-            {\r
-              pg.translate(0,\r
-                           ypos +\r
-                           (av.getAlignment().getHeight() * av.charHeight));\r
-\r
-              pg.setFont(av.getFont());\r
-              labels.drawComponent( pg, idWidth );\r
-              pg.setFont(italic);\r
-              pg.translate(0,\r
-                           -ypos -\r
-                           (av.getAlignment().getHeight() * av.charHeight));\r
-            }\r
+    int totalHeight = cHeight * (av.alignment.getWidth() / resWidth + 1);\r
 \r
-            ypos += cHeight;\r
-        }\r
-        while (ypos < totalHeight);\r
+    pg.setColor(Color.white);\r
+    pg.fillRect(0, 0, pwidth, pheight);\r
+    pg.setFont(av.getFont());\r
 \r
-        pg.translate(idWidth, 0);\r
+    ////////////////\r
+    // Draw the ids\r
+    pg.setColor(Color.black);\r
 \r
-        seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);\r
+    pg.translate(0, -pi * pheight);\r
 \r
-        if ((pi * pheight) < totalHeight)\r
-        {\r
-            return Printable.PAGE_EXISTS;\r
+    pg.setClip(0, pi * pheight, pwidth, pheight);\r
 \r
-        }\r
-     else\r
-        {\r
-            return Printable.NO_SUCH_PAGE;\r
-        }\r
-    }\r
+    int ypos = hgap;\r
+    Font italic = new Font(av.getFont().getName(), Font.ITALIC,\r
+                           av.getFont().getSize());\r
+    pg.setFont(italic);\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void makeEPS(File epsFile)\r
+    do\r
     {\r
-      boolean accurateText = true;\r
-\r
-      String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING",\r
-          "Prompt each time");\r
-\r
-      // If we need to prompt, and if the GUI is visible then\r
-      // Prompt for EPS rendering style\r
-      if (renderStyle.equalsIgnoreCase("Prompt each time")\r
-          && !\r
-          (System.getProperty("java.awt.headless") != null\r
-           && System.getProperty("java.awt.headless").equals("true")))\r
+      for (int i = 0; i < av.alignment.getHeight(); i++)\r
       {\r
-        EPSOptions eps = new EPSOptions();\r
-        renderStyle = eps.getValue();\r
-\r
-        if(eps.cancelled || renderStyle==null)\r
-          return;\r
+        SequenceI s = av.alignment.getSequenceAt(i);\r
+        String string = s.getDisplayId( av.getShowJVSuffix());\r
 \r
-        renderStyle = eps.getValue();\r
+        pg.drawString(string, 0,\r
+                      ( (i * av.charHeight) + ypos + av.charHeight) -\r
+                      (av.charHeight / 5));\r
       }\r
-\r
-      if (renderStyle.equalsIgnoreCase("text"))\r
+      if (labels != null)\r
       {\r
-        accurateText = false;\r
-      }\r
-\r
+        pg.translate(0,\r
+                     ypos +\r
+                     (av.getAlignment().getHeight() * av.charHeight));\r
 \r
-        if(epsFile == null)\r
-        {\r
-          jalview.io.JalviewFileChooser chooser = new jalview.io.\r
-              JalviewFileChooser(jalview.bin.Cache.getProperty(\r
-                  "LAST_DIRECTORY"), new String[]\r
-                                 {"eps"},\r
-                                 new String[]\r
-                                 {"Encapsulated Postscript"},\r
-                                 "Encapsulated Postscript");\r
-          chooser.setFileView(new jalview.io.JalviewFileView());\r
-          chooser.setDialogTitle("Create EPS file from alignment");\r
-          chooser.setToolTipText("Save");\r
-\r
-          int value = chooser.showSaveDialog(this);\r
-\r
-          if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
-          {\r
-            return;\r
-          }\r
-\r
-          epsFile = chooser.getSelectedFile();\r
-\r
-          jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
-                                        chooser.getSelectedFile().getParent());\r
-        }\r
-\r
-\r
-        int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
-        int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
-\r
-\r
-        if (av.getWrapAlignment())\r
-        {\r
-          height = getWrappedHeight();\r
-          width = seqPanel.getWidth() + idPanel.getWidth();\r
-        }\r
-        else if (av.getShowAnnotation())\r
-        {\r
-          height += annotationPanel.adjustPanelHeight()+3;\r
-        }\r
+        pg.setFont(av.getFont());\r
+        labels.drawComponent(pg, idWidth);\r
+        pg.setFont(italic);\r
+        pg.translate(0,\r
+                     -ypos -\r
+                     (av.getAlignment().getHeight() * av.charHeight));\r
+      }\r
 \r
+      ypos += cHeight;\r
+    }\r
+    while (ypos < totalHeight);\r
 \r
-        try\r
-         {\r
-           FileOutputStream out = new FileOutputStream(epsFile);\r
-           EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width,\r
-                                                height);\r
+    pg.translate(idWidth, 0);\r
 \r
-           pg.setAccurateTextMode(accurateText);\r
+    seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0);\r
 \r
-           if (av.getWrapAlignment())\r
-           {\r
-                printWrappedAlignment(pg, width, height, 0);\r
-            }\r
-            else\r
-            {\r
-                printUnwrapped(pg, width, height, 0);\r
-            }\r
+    if ( (pi * pheight) < totalHeight)\r
+    {\r
+      return Printable.PAGE_EXISTS;\r
 \r
-            pg.flush();\r
-            pg.close();\r
-          }\r
-          catch (OutOfMemoryError err)\r
-          {\r
-            System.out.println("########################\n"\r
-                               + "OUT OF MEMORY " + epsFile + "\n"\r
-                               + "########################");\r
-\r
-            JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
-                                                  "Out of memory creating EPS file!!"\r
-                                                  +\r
-                                                  "\nSee help files for increasing Java Virtual Machine memory."\r
-                                                  , "Out of memory",\r
-                                                  JOptionPane.WARNING_MESSAGE);\r
-            System.out.println("Create EPS: " + err);\r
-            System.gc();\r
-          }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
     }\r
+    else\r
+    {\r
+      return Printable.NO_SUCH_PAGE;\r
+    }\r
+  }\r
 \r
+  void makeAlignmentImage(int type, File file)\r
+  {\r
+    int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
+    int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
 \r
-    public void makePNGImageMap(File imgMapFile, String imageName)\r
+    if (av.getWrapAlignment())\r
     {\r
-      ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS\r
-      //////////////////////////////////////////////\r
-      int idWidth = calculateIdWidth().width + 4;\r
-      FontMetrics fm = getFontMetrics(av.getFont());\r
-      int scaleHeight = av.charHeight + fm.getDescent();\r
-\r
-        // Gen image map\r
-         //////////////////////////////////\r
-         if(imgMapFile!=null)\r
-         {\r
-           try\r
-           {\r
-             PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));\r
-             out.println(jalview.io.HTMLOutput.getImageMapHTML());\r
-             out.println("<img src=\"" + imageName +\r
-                       "\" border=\"0\" usemap=\"#Map\" >"\r
-                       +"<map name=\"Map\">");\r
-\r
-             for (int s = 0; s < av.alignment.getHeight(); s++)\r
-             {\r
-               SequenceI seq = av.alignment.getSequenceAt(s);\r
-               SequenceGroup[] groups = av.alignment.findAllGroups(seq);\r
-               for (int i = 0; i < groups.length; i++)\r
-               {\r
-                 int sy = s * av.charHeight + scaleHeight;\r
-                 for (int res = groups[i].getStartRes();\r
-                      res < groups[i].getEndRes() + 1; res++)\r
-                 {\r
-                   int alIndex = seq.findPosition(res);\r
-                   Object obj = ResidueProperties.aa2Triplet.get(\r
-                       seq.getCharAt(res) + "");\r
-                   if (obj == null)\r
-                     continue;\r
-\r
-                   String triplet = obj.toString();\r
-\r
-                   out.println(\r
-                       "<area shape=\"rect\" coords=\""\r
-                       + (idWidth + res * av.charWidth) + ","\r
-                       + sy + ","\r
-                       + (idWidth + (res + 1) * av.charWidth) + ","\r
-                       + (av.charHeight + sy) + "\""\r
-                       + " onMouseOver=\"toolTip('"\r
-                       + alIndex + " " + triplet +\r
-                       "<br><em>" + groups[i].getName() +\r
-                       "</em>')\"; onMouseOut=\"toolTip()\"; "\r
-                       + " href=\"#\">");\r
-                 }\r
-               }\r
-             }\r
-\r
-             out.println("</map></body></html>");\r
-             out.close();\r
-\r
-           }\r
-           catch (Exception ex)\r
-           {\r
-             ex.printStackTrace();\r
-           }\r
-         }///////////END OF IMAGE MAP\r
-\r
+      height = getWrappedHeight();\r
+      width = seqPanel.getWidth() + idPanel.getWidth();\r
     }\r
-\r
-    int getWrappedHeight()\r
+    else if (av.getShowAnnotation())\r
     {\r
+      height += annotationPanel.adjustPanelHeight() + 3;\r
+    }\r
 \r
-      int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(\r
-        seqPanel.seqCanvas.getWidth());\r
-\r
-      int hgap = av.charHeight;\r
-      if (av.scaleAboveWrapped)\r
-        hgap += av.charHeight;\r
-\r
-      int annotationHeight = 0;\r
-      if (av.showAnnotation)\r
+    jalview.util.ImageMaker im;\r
+    if(type==jalview.util.ImageMaker.PNG)\r
+      im  = new jalview.util.ImageMaker(this,\r
+                                        jalview.util.ImageMaker.PNG,\r
+                                        "Create PNG image from alignment",\r
+                                        width, height, file, null);\r
+    else\r
+      im = new jalview.util.ImageMaker(this,\r
+                                        jalview.util.ImageMaker.EPS,\r
+                                       "Create EPS file from alignment",\r
+                                        width, height, file, alignFrame.getTitle() );\r
+\r
+    try\r
+    {\r
+      if (av.getWrapAlignment())\r
       {\r
-        annotationHeight = annotationPanel.adjustPanelHeight();\r
+        if(im.getGraphics()!=null)\r
+          printWrappedAlignment(im.getGraphics(), width, height, 0);\r
+      }\r
+      else\r
+      {\r
+        if(im.getGraphics()!=null)\r
+          printUnwrapped(im.getGraphics(), width, height, 0);\r
       }\r
 \r
-      int cHeight = av.getAlignment().getHeight() * av.charHeight\r
-          + hgap\r
-          + annotationHeight;\r
-\r
-\r
-      int height =  ( (av.alignment.getWidth() / chunkWidth) + 1) * cHeight;\r
-\r
-      return height;\r
+      im.writeImage();\r
     }\r
+    catch (OutOfMemoryError err)\r
+    {\r
+      System.out.println("########################\n"\r
+                         + "OUT OF MEMORY " + file + "\n"\r
+                         + "########################");\r
+\r
+      JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+                                            "Out of Memory Creating Image!!"\r
+                                            +\r
+                                            "\nSee help files for increasing Java Virtual Machine memory."\r
+                                            , "Out of memory",\r
+                                            JOptionPane.WARNING_MESSAGE);\r
+      System.out.println("Create IMAGE: " + err);\r
+      System.gc();\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     */\r
-    public void makePNG(File pngFile)\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+  }\r
+  /**\r
+   * DOCUMENT ME!\r
+   */\r
+  public void makeEPS(File epsFile)\r
+  {\r
+    makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   */\r
+  public void makePNG(File pngFile)\r
+  {\r
+    makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);\r
+  }\r
+\r
+  public void makePNGImageMap(File imgMapFile, String imageName)\r
+  {\r
+    ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS\r
+    //////////////////////////////////////////////\r
+    int idWidth = calculateIdWidth().width + 4;\r
+    FontMetrics fm = getFontMetrics(av.getFont());\r
+    int scaleHeight = av.charHeight + fm.getDescent();\r
+\r
+    // Gen image map\r
+    //////////////////////////////////\r
+    if (imgMapFile != null)\r
     {\r
-      if(pngFile==null)\r
+      try\r
       {\r
-        jalview.io.JalviewFileChooser chooser = new jalview.io.\r
-            JalviewFileChooser(jalview.bin.Cache.getProperty(\r
-                "LAST_DIRECTORY"), new String[]\r
-                               {"png"},\r
-                               new String[]\r
-                               {"Portable network graphics"},\r
-                               "Portable network graphics");\r
-        chooser.setFileView(new jalview.io.JalviewFileView());\r
-        chooser.setDialogTitle("Create EPS file from alignment");\r
-        chooser.setToolTipText("Save");\r
-\r
-        int value = chooser.showSaveDialog(this);\r
-\r
-        if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
+        PrintWriter out = new PrintWriter(new FileWriter(imgMapFile));\r
+        out.println(jalview.io.HTMLOutput.getImageMapHTML());\r
+        out.println("<img src=\"" + imageName +\r
+                    "\" border=\"0\" usemap=\"#Map\" >"\r
+                    + "<map name=\"Map\">");\r
+\r
+        for (int s = 0; s < av.alignment.getHeight(); s++)\r
         {\r
-          return;\r
+          SequenceI seq = av.alignment.getSequenceAt(s);\r
+          SequenceGroup[] groups = av.alignment.findAllGroups(seq);\r
+          for (int i = 0; i < groups.length; i++)\r
+          {\r
+            int sy = s * av.charHeight + scaleHeight;\r
+            for (int res = groups[i].getStartRes();\r
+                 res < groups[i].getEndRes() + 1; res++)\r
+            {\r
+              int alIndex = seq.findPosition(res);\r
+              Object obj = ResidueProperties.aa2Triplet.get(\r
+                  seq.getCharAt(res) + "");\r
+              if (obj == null)\r
+                continue;\r
+\r
+              String triplet = obj.toString();\r
+\r
+              out.println(\r
+                  "<area shape=\"rect\" coords=\""\r
+                  + (idWidth + res * av.charWidth) + ","\r
+                  + sy + ","\r
+                  + (idWidth + (res + 1) * av.charWidth) + ","\r
+                  + (av.charHeight + sy) + "\""\r
+                  + " onMouseOver=\"toolTip('"\r
+                  + alIndex + " " + triplet +\r
+                  "<br><em>" + groups[i].getName() +\r
+                  "</em>')\"; onMouseOut=\"toolTip()\"; "\r
+                  + " href=\"#\">");\r
+            }\r
+          }\r
         }\r
 \r
-        pngFile = chooser.getSelectedFile();\r
+        out.println("</map></body></html>");\r
+        out.close();\r
 \r
-        jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
-                                      chooser.getSelectedFile().getParent());\r
       }\r
-\r
-\r
-\r
-      int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
-      int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
-\r
-      if (av.getWrapAlignment())\r
+      catch (Exception ex)\r
       {\r
-        height = getWrappedHeight();\r
-        width = seqPanel.getWidth() + idPanel.getWidth();\r
+        ex.printStackTrace();\r
       }\r
-      else if (av.getShowAnnotation())\r
-        {\r
-            height += annotationPanel.adjustPanelHeight()+3;\r
-        }\r
+    } ///////////END OF IMAGE MAP\r
 \r
-        try\r
-        {\r
+  }\r
 \r
-            FileOutputStream out = new FileOutputStream(pngFile);\r
+  int getWrappedHeight()\r
+  {\r
 \r
-            BufferedImage bi = new BufferedImage(width, height,\r
-                    BufferedImage.TYPE_INT_RGB);\r
-            Graphics2D png = (Graphics2D) bi.getGraphics();\r
+    int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(\r
+        seqPanel.seqCanvas.getWidth());\r
 \r
-            png.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
-                RenderingHints.VALUE_ANTIALIAS_ON);\r
+    int hgap = av.charHeight;\r
+    if (av.scaleAboveWrapped)\r
+      hgap += av.charHeight;\r
 \r
-            if (av.getWrapAlignment())\r
-            {\r
-                printWrappedAlignment(png, width, height, 0);\r
-            }\r
-            else\r
-            {\r
-                printUnwrapped(png, width, height, 0);\r
-            }\r
+    int annotationHeight = 0;\r
+    if (av.showAnnotation)\r
+    {\r
+      annotationHeight = annotationPanel.adjustPanelHeight();\r
+    }\r
 \r
-            ImageIO.write(bi, "png", out);\r
-            out.close();\r
-        }\r
-        catch (OutOfMemoryError err)\r
-        {\r
-          System.out.println("########################\n"\r
-                             + "OUT OF MEMORY " + pngFile + "\n"\r
-                             + "########################");\r
-\r
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
-                                                "Out of memory creating PNG!!"\r
-                                                +\r
-                                                "\nSee help files for increasing Java Virtual Machine memory."\r
-                                                , "Out of memory",\r
-                                                JOptionPane.WARNING_MESSAGE);\r
-          System.out.println("Create PNG: " + err);\r
-          System.gc();\r
+    int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+        + hgap\r
+        + annotationHeight;\r
 \r
-        }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
-    }\r
-}\r
+    int height = ( (av.alignment.getWidth() / chunkWidth) + 1) * cHeight;\r
 \r
+    return height;\r
+  }\r
 \r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-class Preview extends JFrame\r
-{\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @author $author$\r
+   * @version $Revision$\r
+   */\r
+  class Preview\r
+      extends JFrame\r
+  {\r
     /**\r
      * Creates a new Preview object.\r
      *\r
@@ -1129,25 +989,25 @@ class Preview extends JFrame
      */\r
     public Preview(Image image)\r
     {\r
-        setResizable(true);\r
-        setSize(image.getWidth(this), image.getHeight(this));\r
-        setVisible(true);\r
-        getContentPane().setLayout(new BorderLayout());\r
-        getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER);\r
-        validate();\r
-        repaint();\r
+      setResizable(true);\r
+      setSize(image.getWidth(this), image.getHeight(this));\r
+      setVisible(true);\r
+      getContentPane().setLayout(new BorderLayout());\r
+      getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER);\r
+      validate();\r
+      repaint();\r
     }\r
-}\r
-\r
-\r
-/**\r
- * DOCUMENT ME!\r
- *\r
- * @author $author$\r
- * @version $Revision$\r
- */\r
-class PreviewPanel extends JPanel\r
-{\r
+  }\r
+\r
+  /**\r
+   * DOCUMENT ME!\r
+   *\r
+   * @author $author$\r
+   * @version $Revision$\r
+   */\r
+  class PreviewPanel\r
+      extends JPanel\r
+  {\r
     Image image;\r
 \r
     /**\r
@@ -1157,7 +1017,7 @@ class PreviewPanel extends JPanel
      */\r
     public PreviewPanel(Image image)\r
     {\r
-        this.image = image;\r
+      this.image = image;\r
     }\r
 \r
     /**\r
@@ -1167,13 +1027,14 @@ class PreviewPanel extends JPanel
      */\r
     public void paintComponent(Graphics g)\r
     {\r
-        if (image != null)\r
-        {\r
-            g.drawImage(image, 0, 0, this);\r
-        }\r
-        else\r
-        {\r
-            System.out.println("DEBUG:image is null");\r
-        }\r
+      if (image != null)\r
+      {\r
+        g.drawImage(image, 0, 0, this);\r
+      }\r
+      else\r
+      {\r
+        System.out.println("DEBUG:image is null");\r
+      }\r
     }\r
+  }\r
 }\r
index a10f433..be2cf97 100755 (executable)
@@ -80,6 +80,11 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer
         textarea.setText(text);\r
     }\r
 \r
+    public void appendText(String text)\r
+    {\r
+      textarea.append(text);\r
+    }\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
index 4186090..3acefe7 100755 (executable)
@@ -43,6 +43,10 @@ public class Desktop extends jalview.jbgui.GDesktop
     static final int xOffset = 30;
     static final int yOffset = 30;
     public static jalview.ws.Discoverer discoverer;
+
+    public static Object [] jalviewClipboard;
+
+
     /**
      * Creates a new Desktop object.
      */
@@ -50,6 +54,7 @@ public class Desktop extends jalview.jbgui.GDesktop
     {
         Image image = null;
 
+
         try
         {
             java.net.URL url = getClass().getResource("/images/logo.gif");
@@ -68,7 +73,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         {
         }
 
-        setTitle("Jalview 2005");
+        setTitle("Jalview "+jalview.bin.Cache.getProperty("VERSION"));
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         desktop = new JDesktopPane();
         desktop.setBackground(Color.white);
@@ -221,6 +226,7 @@ public class Desktop extends jalview.jbgui.GDesktop
         {}
     }
 
+
     /**
      * DOCUMENT ME!
      *
@@ -434,7 +440,7 @@ public class Desktop extends jalview.jbgui.GDesktop
      */
     public void aboutMenuItem_actionPerformed(ActionEvent e)
     {
-      StringBuffer message = new StringBuffer("JalView 2005 version " +
+      StringBuffer message = new StringBuffer("JalView version " +
                                               jalview.bin.Cache.getProperty(
           "VERSION") +
                                               "; last updated: " +
@@ -544,5 +550,31 @@ public class Desktop extends jalview.jbgui.GDesktop
         }
     }
 
+  /*  public void vamsasLoad_actionPerformed(ActionEvent e)
+    {
+      JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
+          getProperty("LAST_DIRECTORY"));
+
+      chooser.setFileView(new JalviewFileView());
+      chooser.setDialogTitle("Load Vamsas file");
+      chooser.setToolTipText("Import");
+
+      int value = chooser.showOpenDialog(this);
+
+      if (value == JalviewFileChooser.APPROVE_OPTION)
+      {
+        jalview.io.VamsasDatastore vs = new jalview.io.VamsasDatastore(null);
+        vs.load(
+            chooser.getSelectedFile().getAbsolutePath()
+            );
+      }
+
+    }*/
+
+
+    public void inputSequence_actionPerformed(ActionEvent e)
+    {
+      SequenceFetcher sf = new SequenceFetcher(null);
+    }
 }
 
index 5926563..a9a60f2 100755 (executable)
@@ -27,7 +27,7 @@ public class EPSOptions
     extends JPanel\r
 {\r
   JDialog dialog;\r
-  boolean cancelled = false;\r
+  public boolean cancelled = false;\r
   String value;\r
 \r
   public EPSOptions()\r
index 8a94a89..03080bd 100755 (executable)
@@ -24,6 +24,8 @@ import java.awt.*;
 \r
 import java.util.*;\r
 \r
+import java.awt.image.*;\r
+\r
 \r
 /**\r
  * DOCUMENT ME!\r
@@ -34,10 +36,15 @@ import java.util.*;
 public class FeatureRenderer\r
 {\r
     AlignViewport av;\r
-    SequenceGroup currentSequenceGroup = null;\r
-    SequenceGroup[] allGroups = null;\r
     Color resBoxColour;\r
-    Graphics graphics;\r
+    float transparency = 1.0f;\r
+    FontMetrics fm;\r
+    int charOffset;\r
+    boolean drawText = true;\r
+\r
+    // The following vector holds the features which are\r
+    // to be added, in the correct order or rendering\r
+    Vector featuresDisplayed = null;\r
 \r
     /**\r
      * Creates a new FeatureRenderer object.\r
@@ -47,8 +54,33 @@ public class FeatureRenderer
     public FeatureRenderer(AlignViewport av)\r
     {\r
         this.av = av;\r
+        initColours();\r
+    }\r
+\r
+    /**\r
+     * This is used by the Molecule Viewer to get the accurate colour\r
+     * of the rendered sequence\r
+     */\r
+    BufferedImage bi;\r
+    public synchronized Color findFeatureColour(Color initialCol, SequenceI seq, int i)\r
+    {\r
+      if(!av.showSequenceFeatures)\r
+        return initialCol;\r
+\r
+      if (bi == null)\r
+        bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);\r
+\r
+      bi.setRGB(0,0, initialCol.getRGB());\r
+\r
+      drawText = false;\r
+\r
+      drawSequence(bi.getGraphics(), seq, i, i, 0, 0, 1, 1);\r
+      drawText = true;\r
+\r
+      return new Color(bi.getRGB(0, 0));\r
     }\r
 \r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -62,76 +94,222 @@ public class FeatureRenderer
      * @param width DOCUMENT ME!\r
      * @param height DOCUMENT ME!\r
      */\r
-    public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
-        int start, int end, int x1, int y1, int width, int height)\r
+    public void drawSequence(Graphics g, SequenceI seq,\r
+                             int start, int end, int x1, int y1, int width, int height)\r
     {\r
-        Vector features = seq.getSequenceFeatures();\r
-        Enumeration e = features.elements();\r
 \r
-        while (e.hasMoreElements())\r
+//System.out.println(start+" "+end+" "+x1+" "+y1);\r
+      if (seq.getDatasetSequence().getSequenceFeatures() == null\r
+          || seq.getDatasetSequence().getSequenceFeatures().size()==0)\r
+        return;\r
+\r
+      fm = g.getFontMetrics();\r
+\r
+      if (transparency != 1)\r
+      {\r
+        Graphics2D g2 = (Graphics2D) g;\r
+        g2.setComposite(\r
+            AlphaComposite.getInstance(\r
+                AlphaComposite.SRC_OVER, transparency));\r
+      }\r
+\r
+      String type;\r
+      SequenceFeature sf;\r
+      if (featuresDisplayed == null)\r
+        findAllFeatures();\r
+\r
+      Enumeration e = featuresDisplayed.elements(), e2;\r
+\r
+      // Loop through each visible feature\r
+      while (e.hasMoreElements())\r
+      {\r
+\r
+        type = e.nextElement().toString();\r
+        e2 = seq.getDatasetSequence().getSequenceFeatures().elements();\r
+        // loop through all features in sequence to find\r
+        // current feature to render\r
+          while (e2.hasMoreElements())\r
         {\r
-            SequenceFeature sf = (SequenceFeature) e.nextElement();\r
 \r
-            if (sf.getStart() > seq.getEnd())\r
-            {\r
-                continue;\r
-            }\r
+          sf = (SequenceFeature) e2.nextElement();\r
+          if (!type.equals(sf.getType()))\r
+            continue;\r
+\r
+          if (sf.getBegin() > seq.getEnd())\r
+            continue;\r
+\r
+          if (type.equals("disulfide bond"))\r
+          {\r
+\r
+            renderFeature(g, seq,\r
+                          seq.findIndex(sf.getBegin()) - 1,\r
+                          seq.findIndex(sf.getBegin()) - 1,\r
+                          type, start, end, x1, y1, width, height);\r
+            renderFeature(g, seq,\r
+                          seq.findIndex(sf.getEnd()) - 1,\r
+                          seq.findIndex(sf.getEnd()) - 1,\r
+                          type, start, end, x1, y1, width, height);\r
+\r
+          }\r
+          else\r
+            renderFeature(g, seq,\r
+                          seq.findIndex(sf.getBegin()) - 1,\r
+                          seq.findIndex(sf.getEnd()) - 1,\r
+                          type, start, end, x1, y1, width, height);\r
+        }\r
+      }\r
+\r
+        if(transparency!=1.0f)\r
+        {\r
+          Graphics2D g2 = (Graphics2D) g;\r
+          g2.setComposite(\r
+              AlphaComposite.getInstance(\r
+                  AlphaComposite.SRC_OVER, 1.0f));\r
+        }\r
+    }\r
+\r
 \r
-            int fstart = seq.findIndex(sf.getStart()) - 1;\r
-            int fend = seq.findIndex(sf.getEnd()) - 1;\r
+    void renderFeature(Graphics g, SequenceI seq,\r
+                       int fstart, int fend, String type, int start, int end, int x1, int y1, int width, int height)\r
+    {\r
+\r
+      if (((fstart <= end) && (fend >= start)))\r
+      {\r
+          if (fstart < start)\r
+          { // fix for if the feature we have starts before the sequence start,\r
+              fstart = start; // but the feature end is still valid!!\r
+          }\r
 \r
-            if (((fstart <= end) && (fend >= start)))\r
+          if (fend >= end)\r
+          {\r
+            fend = end;\r
+          }\r
+          for (int i = fstart; i <= fend; i++)\r
+          {\r
+            char s = seq.getSequence().charAt(i);\r
+\r
+            if (jalview.util.Comparison.isGap(s))\r
             {\r
-                if (fstart < start)\r
-                { // fix for if the feature we have starts before the sequence start,\r
-                    fstart = start; // but the feature end is still valid!!\r
-                }\r
-\r
-                if (fend >= end)\r
-                {\r
-                    fend = end;\r
-                }\r
-\r
-                if (fstart == fend)\r
-                {\r
-                    g.setColor(Color.red);\r
-                    g.fillRoundRect((fstart - start) * width, y1, width,\r
-                        height, 4, 4);\r
-                    g.setColor(Color.white);\r
-\r
-                    char s = seq.getSequence().charAt(fstart);\r
-                    FontMetrics fm = g.getFontMetrics();\r
-                    int charOffset = (width - fm.charWidth(s)) / 2;\r
-                    int pady = height / 5;\r
-                    g.drawString(String.valueOf(s),\r
-                        charOffset + x1 + (width * (fstart - start)),\r
-                        (y1 + height) - pady);\r
-                }\r
-                else\r
-                {\r
-                    for (int i = fstart; i <= fend; i++)\r
-                    {\r
-                        char s = seq.getSequence().charAt(i);\r
-\r
-                        if (jalview.util.Comparison.isGap(s))\r
-                        {\r
-                            continue;\r
-                        }\r
-\r
-                        g.setColor(Color.blue);\r
-                        g.fillRect((i - start) * width, y1, width, height);\r
-\r
-                        g.setColor(Color.white);\r
-\r
-                        FontMetrics fm = g.getFontMetrics();\r
-                        int charOffset = (width - fm.charWidth(s)) / 2;\r
-                        int pady = height / 5;\r
-                        g.drawString(String.valueOf(s),\r
-                            charOffset + x1 + (width * (i - start)),\r
-                            (y1 + height) - pady);\r
-                    }\r
-                }\r
+              continue;\r
             }\r
+\r
+            g.setColor(getColour(type));\r
+\r
+            g.fillRect( (i - start) * width, y1, width, height);\r
+\r
+            if(drawText)\r
+           {\r
+             g.setColor(Color.white);\r
+             charOffset = (width - fm.charWidth(s)) / 2;\r
+             g.drawString(String.valueOf(s),\r
+                          charOffset + x1 + (width * (i - start)),\r
+                          (y1 + height) - height / 5); //pady = height / 5;\r
+           }\r
+          }\r
+        }\r
+    }\r
+\r
+    void findAllFeatures()\r
+    {\r
+      Vector features = new Vector();\r
+      SequenceFeature sf;\r
+      featuresDisplayed = new Vector();\r
+      Enumeration e;\r
+      for (int i = 0; i < av.alignment.getHeight(); i++)\r
+      {\r
+        features = av.alignment.getSequenceAt(i).getDatasetSequence().\r
+            getSequenceFeatures();\r
+        if (features == null)\r
+          continue;\r
+\r
+        e = features.elements();\r
+        while (e.hasMoreElements())\r
+        {\r
+          sf = (SequenceFeature) e.nextElement();\r
+          if (!featuresDisplayed.contains(sf.getType()))\r
+          {\r
+            featuresDisplayed.addElement(sf.getType());\r
+          }\r
         }\r
+      }\r
+    }\r
+\r
+    public Color getColour(String featureType)\r
+    {\r
+      return (Color)featureColours.get(featureType);\r
     }\r
+\r
+    public void setColour(String featureType, Color col)\r
+    {\r
+      featureColours.put(featureType, col);\r
+    }\r
+\r
+    public void setTransparency(float value)\r
+    {\r
+      transparency = value;\r
+    }\r
+\r
+    public float getTransparency()\r
+    {\r
+      return transparency;\r
+    }\r
+\r
+    public void setFeaturePriority(Object [][] data)\r
+    {\r
+      // The feature table will display high priority\r
+      // features at the top, but theses are the ones\r
+      // we need to render last, so invert the data\r
+      featuresDisplayed.clear();\r
+      for(int i=data.length-1; i>-1; i--)\r
+      {\r
+       String type = data[i][0].toString();\r
+       setColour(type, (Color)data[i][1]);\r
+       if( ((Boolean)data[i][2]).booleanValue() )\r
+         featuresDisplayed.addElement(type);\r
+      }\r
+    }\r
+\r
+    Hashtable featureColours = new Hashtable();\r
+    void initColours()\r
+    {\r
+      featureColours.put("active site", new Color(255, 75, 0));\r
+      featureColours.put("binding site", new Color(245, 85, 0));\r
+      featureColours.put("calcium-binding region", new Color(235, 95, 0));\r
+      featureColours.put("chain", new Color(225, 105, 0));\r
+      featureColours.put("coiled-coil region", new Color(215, 115, 0));\r
+      featureColours.put("compositionally biased region", new Color(205, 125, 0));\r
+      featureColours.put("cross-link", new Color(195, 135, 0));\r
+      featureColours.put("disulfide bond", new Color(230,230,0));\r
+      featureColours.put("DNA-binding region", new Color(175, 155, 0));\r
+      featureColours.put("domain", new Color(165, 165, 0));\r
+      featureColours.put("glycosylation site", new Color(155, 175, 0));\r
+      featureColours.put("helix", new Color(145, 185, 0));\r
+      featureColours.put("initiator methionine", new Color(135, 195, 5));\r
+      featureColours.put("lipid moiety-binding region", new Color(125, 205, 15));\r
+      featureColours.put("metal ion-binding site", new Color(115, 215, 25));\r
+      featureColours.put("modified residue", new Color(105, 225, 35));\r
+      featureColours.put("mutagenesis site", new Color(95, 235, 45));\r
+      featureColours.put("non-consecutive residues", new Color(85, 245, 55));\r
+      featureColours.put("non-terminal residue", new Color(75, 255, 65));\r
+      featureColours.put("nucleotide phosphate-binding region",new Color(65, 245, 75));\r
+      featureColours.put("peptide", new Color(55, 235, 85));\r
+      featureColours.put("propeptide", new Color(45, 225, 95));\r
+      featureColours.put("region of interest", new Color(35, 215, 105));\r
+      featureColours.put("repeat", new Color(25, 205, 115));\r
+      featureColours.put("selenocysteine", new Color(15, 195, 125));\r
+      featureColours.put("sequence conflict", new Color(5, 185, 135));\r
+      featureColours.put("sequence variant", new Color(0, 175, 145));\r
+      featureColours.put("short sequence motif", new Color(0, 165, 155));\r
+      featureColours.put("signal peptide", new Color(0, 155, 165));\r
+      featureColours.put("site", new Color(0, 145, 175));\r
+      featureColours.put("splice variant", new Color(0, 135, 185));\r
+      featureColours.put("strand", new Color(0, 125, 195));\r
+      featureColours.put("topological domain", new Color(0, 115, 205));\r
+      featureColours.put("transit peptide", new Color(0, 105, 215));\r
+      featureColours.put("transmembrane region", new Color(0, 95, 225));\r
+      featureColours.put("turn", new Color(0, 85, 235));\r
+      featureColours.put("unsure residue", new Color(0, 75, 245));\r
+      featureColours.put("zinc finger region", new Color(0, 65, 255));\r
+    }\r
+\r
 }\r
diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java
new file mode 100755 (executable)
index 0000000..5325180
--- /dev/null
@@ -0,0 +1,478 @@
+package jalview.gui;\r
+\r
+import jalview.datamodel.*;\r
+import javax.swing.*;\r
+import javax.swing.event.*;\r
+import java.awt.*;\r
+import java.util.*;\r
+import javax.swing.BorderFactory;\r
+import java.awt.event.*;\r
+import javax.swing.table.*;\r
+import java.io.*;\r
+import jalview.io.JalviewFileChooser;\r
+\r
+public class FeatureSettings extends JPanel\r
+{\r
+\r
+  final FeatureRenderer fr;\r
+  final AlignmentPanel ap;\r
+  final AlignViewport av;\r
+  Object [][] originalData;\r
+  final JInternalFrame frame;\r
+  JScrollPane scrollPane = new JScrollPane();\r
+  JTable table;\r
+\r
+  public FeatureSettings(AlignViewport av, final AlignmentPanel ap)\r
+  {\r
+    this.ap = ap;\r
+    this.av = av;\r
+    fr = ap.seqPanel.seqCanvas.getFeatureRenderer();\r
+    av.alignment.getSequences();\r
+    frame = new JInternalFrame();\r
+    frame.setContentPane(this);\r
+    Desktop.addInternalFrame(frame, "Sequence Feature Settings", 400, 300);\r
+\r
+    setTableData();\r
+\r
+    final JSlider transparency = new JSlider(0, 70, 0);\r
+    transparency.addChangeListener(new ChangeListener()\r
+    {\r
+      public void stateChanged(ChangeEvent evt)\r
+      {\r
+        fr.setTransparency( (float) (100 - transparency.getValue()) / 100f);\r
+        ap.repaint();\r
+      }\r
+    });\r
+\r
+    JPanel transPanel = new JPanel(new FlowLayout());\r
+    transPanel.add(new JLabel("Transparency"));\r
+    transPanel.add(transparency);\r
+\r
+    //////////////////////////////////////////////\r
+    //We're going to need those OK cancel buttons\r
+    JPanel buttonPanel = new JPanel(new FlowLayout());\r
+    JButton button = new JButton("OK");\r
+    button.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent evt)\r
+      {\r
+        try\r
+        {\r
+          frame.setClosed(true);\r
+        }\r
+        catch (Exception exe)\r
+        {}\r
+      }\r
+    });\r
+    buttonPanel.add(button);\r
+    button = new JButton("Cancel");\r
+    button.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent evt)\r
+      {\r
+        try\r
+        {\r
+          updateFeatureRenderer(originalData);\r
+          frame.setClosed(true);\r
+        }\r
+        catch (Exception exe)\r
+        {}\r
+      }\r
+    });\r
+    buttonPanel.add(button);\r
+\r
+    button = new JButton("Load Colours");\r
+    button.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent evt)\r
+      {\r
+        load();\r
+      }\r
+    });\r
+    buttonPanel.add(button);\r
+    button = new JButton("Save Colours");\r
+    button.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent evt)\r
+      {\r
+        save();\r
+      }\r
+    });\r
+    buttonPanel.add(button);\r
+\r
+    this.setLayout(new BorderLayout());\r
+    JPanel bigPanel = new JPanel(new BorderLayout());\r
+    bigPanel.add(transPanel, BorderLayout.SOUTH);\r
+    bigPanel.add(scrollPane, BorderLayout.CENTER);\r
+\r
+    add(bigPanel, BorderLayout.CENTER);\r
+    add(buttonPanel, BorderLayout.SOUTH);\r
+\r
+\r
+  }\r
+\r
+  void setTableData()\r
+  {\r
+    Vector allFeatures = new Vector();\r
+    Vector features;\r
+    Enumeration e;\r
+    SequenceFeature sf;\r
+\r
+    for(int i=0; i< av.alignment.getHeight(); i++)\r
+    {\r
+       features = av.alignment.getSequenceAt(i).getDatasetSequence().getSequenceFeatures();\r
+       if(features==null)\r
+         continue;\r
+\r
+       e = features.elements();\r
+       while(e.hasMoreElements())\r
+       {\r
+         sf = (SequenceFeature)e.nextElement();\r
+         if(!allFeatures.contains(sf.getType()))\r
+         {\r
+           allFeatures.addElement(sf.getType());\r
+         }\r
+       }\r
+    }\r
+    if(allFeatures.size()<1)\r
+     {\r
+       try{\r
+         frame.setClosed(true);\r
+       }catch(Exception ex){}\r
+       return;\r
+     }\r
+\r
+    int fSize = allFeatures.size();\r
+\r
+    String type;\r
+    boolean originalExists = false;\r
+    if(originalData!=null)\r
+      originalExists = true;\r
+    else\r
+      originalData = new Object[fSize][3];\r
+\r
+    Object [][] data = new Object[fSize][3];\r
+    for(int i=0; i<fSize; i++)\r
+    {\r
+      type = allFeatures.elementAt(i).toString();\r
+      Color col = fr.getColour(type);\r
+      data[i][0]=type;\r
+      data[i][1]=col;\r
+      if(fr.featuresDisplayed!=null)\r
+         data[i][2] = new Boolean(fr.featuresDisplayed.contains(type));\r
+      else\r
+        data[i][2] = new Boolean(true);\r
+\r
+      if(!originalExists)\r
+      {\r
+        originalData[i][0] = type;\r
+        originalData[i][1] = col;\r
+        if (fr.featuresDisplayed != null)\r
+          originalData[i][2] = new Boolean(fr.featuresDisplayed.contains(type));\r
+        else\r
+          originalData[i][2] = new Boolean(true);\r
+      }\r
+    }\r
+    ////////////////////////////////////\r
+        //Now build the table\r
+        table = new JTable(new FeatureTableModel(data));\r
+        scrollPane.setViewportView(table);\r
+        table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));\r
+        table.setFont(new Font("Verdana", Font.PLAIN, 12));\r
+        table.setDefaultRenderer(Color.class,\r
+                             new ColorRenderer());\r
+\r
+        table.setDefaultEditor(Color.class,\r
+                          new ColorEditor());\r
+\r
+        table.getColumnModel().getColumn(0).setPreferredWidth(200);\r
+\r
+        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+\r
+        table.addMouseListener(new MouseAdapter()\r
+            {\r
+              public void mousePressed(MouseEvent evt)\r
+              {\r
+                selectedRow = table.rowAtPoint(evt.getPoint());\r
+              }\r
+            });\r
+\r
+        table.addMouseMotionListener(new MouseMotionAdapter()\r
+            {\r
+              public void mouseDragged(MouseEvent evt)\r
+              {\r
+                int newRow = table.rowAtPoint(evt.getPoint());\r
+                if(newRow!=selectedRow\r
+                   && selectedRow!=-1\r
+                   && newRow!=-1)\r
+                {\r
+                  Object[] temp = new Object[3];\r
+                  temp[0] = table.getValueAt(selectedRow, 0);\r
+                  temp[1] = table.getValueAt(selectedRow, 1);\r
+                  temp[2] = table.getValueAt(selectedRow, 2);\r
+\r
+                  table.setValueAt(table.getValueAt(newRow, 0), selectedRow, 0);\r
+                  table.setValueAt(table.getValueAt(newRow, 1), selectedRow, 1);\r
+                  table.setValueAt(table.getValueAt(newRow, 2), selectedRow, 2);\r
+\r
+                  table.setValueAt(temp[0], newRow, 0);\r
+                  table.setValueAt(temp[1], newRow, 1);\r
+                  table.setValueAt(temp[2], newRow, 2);\r
+\r
+                  selectedRow = newRow;\r
+                }\r
+              }\r
+        });\r
+\r
+  }\r
+\r
+  void load()\r
+  {\r
+    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty(\r
+                 "LAST_DIRECTORY"), new String[] { "fc" },\r
+             new String[] { "Sequence Feature Colours" }, "Sequence Feature Colours");\r
+     chooser.setFileView(new jalview.io.JalviewFileView());\r
+     chooser.setDialogTitle("Load Feature Colours");\r
+     chooser.setToolTipText("Load");\r
+\r
+     int value = chooser.showOpenDialog(this);\r
+\r
+     if (value == JalviewFileChooser.APPROVE_OPTION)\r
+     {\r
+       File file = chooser.getSelectedFile();\r
+\r
+       try\r
+       {\r
+         InputStreamReader in = new InputStreamReader(new FileInputStream(\r
+             file), "UTF-8");\r
+\r
+         jalview.binding.JalviewUserColours jucs = new jalview.binding.\r
+             JalviewUserColours();\r
+         jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in);\r
+\r
+\r
+         for (int i = 0; i < jucs.getColourCount(); i++)\r
+         {\r
+           fr.setColour( jucs.getColour(i).getName(),\r
+                          new Color(Integer.parseInt( jucs.getColour(i).getRGB(), 16)));\r
+         }\r
+\r
+         setTableData();\r
+         ap.repaint();\r
+       }\r
+       catch (Exception ex)\r
+       {\r
+         System.out.println("Error loading User ColourFile\n" + ex);\r
+       }\r
+     }\r
+  }\r
+\r
+  void save()\r
+  {\r
+    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty(\r
+                "LAST_DIRECTORY"), new String[] { "fc" },\r
+            new String[] { "Sequence Feature Colours" }, "Sequence Feature Colours");\r
+    chooser.setFileView(new jalview.io.JalviewFileView());\r
+    chooser.setDialogTitle("Save Feature Colour Scheme");\r
+    chooser.setToolTipText("Save");\r
+\r
+    int value = chooser.showSaveDialog(this);\r
+\r
+    if (value == JalviewFileChooser.APPROVE_OPTION)\r
+    {\r
+        String choice = chooser.getSelectedFile().getPath();\r
+        jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours();\r
+        ucs.setSchemeName("Sequence Features");\r
+        try\r
+        {\r
+            PrintWriter out = new PrintWriter(new OutputStreamWriter(\r
+                        new FileOutputStream(choice), "UTF-8"));\r
+\r
+            Enumeration e = fr.featureColours.keys();\r
+           while(e.hasMoreElements())\r
+           {\r
+\r
+\r
+                jalview.binding.Colour col = new jalview.binding.Colour();\r
+                col.setName(e.nextElement().toString());\r
+                col.setRGB(jalview.util.Format.getHexString(\r
+                        fr.getColour(col.getName())));\r
+                ucs.addColour(col);\r
+            }\r
+\r
+            ucs.marshal(out);\r
+            out.close();\r
+        }\r
+        catch (Exception ex)\r
+        {\r
+            ex.printStackTrace();\r
+        }\r
+    }\r
+\r
+  }\r
+\r
+  public void updateFeatureRenderer(Object [][] data)\r
+  {\r
+    fr.setFeaturePriority( data );\r
+    ap.repaint();\r
+  }\r
+\r
+  int selectedRow =-1;\r
+\r
+\r
+  /////////////////////////////////////////////////////////////////////////\r
+  // http://java.sun.com/docs/books/tutorial/uiswing/components/table.html\r
+  /////////////////////////////////////////////////////////////////////////\r
+  class FeatureTableModel\r
+      extends AbstractTableModel\r
+  {\r
+    FeatureTableModel(Object[][] data)\r
+    {\r
+      this.data = data;\r
+    }\r
+\r
+    private String[] columnNames = {"Feature Type", "Colour","Display"};\r
+          private Object[][] data;\r
+\r
+          public Object[][] getData()\r
+          {\r
+            return data;\r
+          }\r
+\r
+          public int getColumnCount() {\r
+              return columnNames.length;\r
+          }\r
+\r
+          public Object[] getRow(int row)\r
+          {\r
+            return data[row];\r
+          }\r
+\r
+          public int getRowCount() {\r
+              return data.length;\r
+          }\r
+\r
+          public String getColumnName(int col) {\r
+              return columnNames[col];\r
+          }\r
+\r
+          public Object getValueAt(int row, int col) {\r
+              return data[row][col];\r
+          }\r
+\r
+          public Class getColumnClass(int c) {\r
+              return getValueAt(0, c).getClass();\r
+          }\r
+\r
+          public boolean isCellEditable(int row, int col) {\r
+              return col==0 ? false:true;\r
+          }\r
+\r
+          public void setValueAt(Object value, int row, int col) {\r
+              data[row][col] = value;\r
+              fireTableCellUpdated(row, col);\r
+              updateFeatureRenderer(data);\r
+          }\r
+\r
+    }\r
+    class ColorRenderer extends JLabel\r
+                              implements TableCellRenderer {\r
+       javax.swing.border.Border unselectedBorder = null;\r
+       javax.swing.border.Border selectedBorder = null;\r
+\r
+       public ColorRenderer() {\r
+           setOpaque(true); //MUST do this for background to show up.\r
+       }\r
+\r
+       public Component getTableCellRendererComponent(\r
+                               JTable table, Object color,\r
+                               boolean isSelected, boolean hasFocus,\r
+                               int row, int column) {\r
+           Color newColor = (Color)color;\r
+           setBackground(newColor);\r
+               if (isSelected) {\r
+                   if (selectedBorder == null) {\r
+                       selectedBorder = BorderFactory.createMatteBorder(2,5,2,5,\r
+                                                 table.getSelectionBackground());\r
+                   }\r
+                   setBorder(selectedBorder);\r
+               } else {\r
+                   if (unselectedBorder == null) {\r
+                       unselectedBorder = BorderFactory.createMatteBorder(2,5,2,5,\r
+                                                 table.getBackground());\r
+                   }\r
+                   setBorder(unselectedBorder);\r
+               }\r
+\r
+           setToolTipText("RGB value: " + newColor.getRed() + ", "\r
+                                        + newColor.getGreen() + ", "\r
+                                        + newColor.getBlue());\r
+           return this;\r
+       }\r
+   }\r
+}\r
+\r
+ class ColorEditor extends AbstractCellEditor\r
+                          implements TableCellEditor,\r
+                                     ActionListener {\r
+     Color currentColor;\r
+     JButton button;\r
+     JColorChooser colorChooser;\r
+     JDialog dialog;\r
+     protected static final String EDIT = "edit";\r
+\r
+     public ColorEditor() {\r
+         //Set up the editor (from the table's point of view),\r
+         //which is a button.\r
+         //This button brings up the color chooser dialog,\r
+         //which is the editor from the user's point of view.\r
+         button = new JButton();\r
+         button.setActionCommand(EDIT);\r
+         button.addActionListener(this);\r
+         button.setBorderPainted(false);\r
+         //Set up the dialog that the button brings up.\r
+         colorChooser = new JColorChooser();\r
+         dialog = JColorChooser.createDialog(button,\r
+                                         "Select new Colour",\r
+                                         true,  //modal\r
+                                         colorChooser,\r
+                                         this,  //OK button handler\r
+                                         null); //no CANCEL button handler\r
+     }\r
+\r
+     /**\r
+      * Handles events from the editor button and from\r
+      * the dialog's OK button.\r
+      */\r
+     public void actionPerformed(ActionEvent e) {\r
+\r
+          if (EDIT.equals(e.getActionCommand())) {\r
+             //The user has clicked the cell, so\r
+             //bring up the dialog.\r
+             button.setBackground(currentColor);\r
+             colorChooser.setColor(currentColor);\r
+             dialog.setVisible(true);\r
+\r
+             //Make the renderer reappear.\r
+             fireEditingStopped();\r
+\r
+         } else { //User pressed dialog's "OK" button.\r
+             currentColor = colorChooser.getColor();\r
+         }\r
+     }\r
+\r
+     //Implement the one CellEditor method that AbstractCellEditor doesn't.\r
+     public Object getCellEditorValue() {\r
+         return currentColor;\r
+     }\r
+\r
+     //Implement the one method defined by TableCellEditor.\r
+     public Component getTableCellEditorComponent(JTable table,\r
+                                                  Object value,\r
+                                                  boolean isSelected,\r
+                                                  int row,\r
+                                                  int column) {\r
+         currentColor = (Color)value;\r
+         return button;\r
+     }\r
+}\r
index ddaf4aa..33bb9de 100755 (executable)
@@ -85,7 +85,7 @@ public class FontChooser extends GFontChooser
             fontName.addItem(fonts[i]);\r
         }\r
 \r
-        for (int i = 1; i < 31; i++)\r
+        for (int i = 1; i < 51; i++)\r
         {\r
             fontSize.addItem(i + "");\r
         }\r
diff --git a/src/jalview/gui/GFeatureSelector.java b/src/jalview/gui/GFeatureSelector.java
new file mode 100755 (executable)
index 0000000..af5d135
--- /dev/null
@@ -0,0 +1,28 @@
+package jalview.gui;\r
+\r
+import javax.swing.*;\r
+\r
+public class GFeatureSelector\r
+    extends JPanel\r
+{\r
+  public GFeatureSelector()\r
+  {\r
+    try\r
+    {\r
+      jbInit();\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+  }\r
+\r
+  private void jbInit()\r
+      throws Exception\r
+  {\r
+    jLabel1.setText("Feature");\r
+    this.add(jLabel1);\r
+  }\r
+\r
+  JLabel jLabel1 = new JLabel();\r
+}\r
index 9b1f10d..0c6da36 100755 (executable)
@@ -93,15 +93,9 @@ public class IdCanvas extends JPanel
             gg.setColor(Color.black);\r
         }\r
 \r
-        String string = s.getName();\r
 \r
-        if (av.getShowFullId())\r
-        {\r
-            string = s.getDisplayId();\r
-        }\r
-\r
-        gg.drawString(string, 0,\r
-            (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));\r
+        gg.drawString( s.getDisplayId(av.getShowJVSuffix()),\r
+                      0, (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5));\r
     }\r
 \r
     /**\r
@@ -290,12 +284,7 @@ public class IdCanvas extends JPanel
 \r
                 gg.setColor(currentTextColor);\r
 \r
-                String string = av.alignment.getSequenceAt(i).getName();\r
-\r
-                if (av.getShowFullId())\r
-                {\r
-                    string = av.alignment.getSequenceAt(i).getDisplayId();\r
-                }\r
+                String string = av.alignment.getSequenceAt(i).getDisplayId( av.getShowJVSuffix());\r
 \r
                 gg.drawString(string, 0,\r
                     (((i - starty) * av.charHeight) + av.charHeight) -\r
index 011502b..8ff3df2 100755 (executable)
@@ -59,6 +59,7 @@ public class IdPanel extends JPanel implements MouseListener,
         add(idCanvas, BorderLayout.CENTER);\r
         addMouseListener(this);\r
         addMouseMotionListener(this);\r
+        ToolTipManager.sharedInstance().registerComponent(this);\r
     }\r
 \r
     /**\r
@@ -68,6 +69,28 @@ public class IdPanel extends JPanel implements MouseListener,
      */\r
     public void mouseMoved(MouseEvent e)\r
     {\r
+      int y = e.getY();\r
+\r
+      if (av.getWrapAlignment())\r
+      {\r
+        y = getWrappedY(y);\r
+      }\r
+\r
+      int seq = av.getIndex(y);\r
+      if(seq!=-1)\r
+      {\r
+        StringBuffer tip = new StringBuffer("<html>");\r
+        tip.append(av.alignment.getSequenceAt(seq).getDisplayId(true));\r
+        if (av.alignment.getSequenceAt(seq).getDescription() != null)\r
+        {\r
+          tip.append("<table width=250 border=0><tr><td><i>");\r
+          tip.append(av.alignment.getSequenceAt(seq).getDescription());\r
+          tip.append("</i></td></tr></table>");\r
+        }\r
+        tip.append("</html>");\r
+        setToolTipText(tip.toString());\r
+      }\r
+\r
     }\r
 \r
     int getWrappedY(int y)\r
@@ -124,7 +147,7 @@ public class IdPanel extends JPanel implements MouseListener,
      */\r
     public void mouseClicked(MouseEvent e)\r
     {\r
-        if (e.getClickCount() < 2)\r
+      if (e.getClickCount() < 2)\r
         return;\r
 \r
       java.util.Vector links = Preferences.sequenceURLLinks;\r
@@ -141,6 +164,9 @@ public class IdPanel extends JPanel implements MouseListener,
       //DEFAULT LINK IS FIRST IN THE LINK LIST\r
       int seq = av.getIndex(y);\r
       String id = av.getAlignment().getSequenceAt(seq).getName();\r
+      if (id.indexOf("|") > -1)\r
+        id = id.substring(id.lastIndexOf("|") + 1);\r
+\r
 \r
       String url = links.elementAt(0).toString();\r
       url = url.substring(url.indexOf("|")+1);\r
@@ -295,6 +321,9 @@ public class IdPanel extends JPanel implements MouseListener,
      */\r
     void selectSeqs(int start, int end)\r
     {\r
+      if(av.getSelectionGroup()==null)\r
+            return;\r
+\r
         lastid = start;\r
 \r
         if (end < start)\r
@@ -307,7 +336,7 @@ public class IdPanel extends JPanel implements MouseListener,
 \r
         for (int i = start; i <= end; i++)\r
         {\r
-            av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),\r
+          av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i),\r
                 true);\r
         }\r
     }\r
index 9ab6419..08b3903 100755 (executable)
@@ -27,6 +27,7 @@ import java.io.*;
 import java.net.*;\r
 \r
 import java.util.*;\r
+\r
 import java.util.jar.*;\r
 \r
 import javax.swing.*;\r
@@ -191,6 +192,56 @@ public class Jalview2XML
 \r
             jseq.setId(id);\r
 \r
+            if(jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures()!=null)\r
+            {\r
+              Enumeration en = jal.getSequenceAt(i).getDatasetSequence().getSequenceFeatures().elements();\r
+              while(en.hasMoreElements())\r
+              {\r
+                Features features = new Features();\r
+                jalview.datamodel.SequenceFeature sf\r
+                   = (jalview.datamodel.SequenceFeature)en.nextElement();\r
+\r
+                features.setBegin(sf.getBegin());\r
+                features.setEnd(sf.getEnd());\r
+                features.setDescription(sf.getDescription());\r
+                features.setStatus(sf.getStatus());\r
+                features.setType(sf.getType());\r
+                jseq.addFeatures(features);\r
+              }\r
+            }\r
+\r
+            if(jal.getSequenceAt(i).getDatasetSequence().getPDBId()!=null)\r
+            {\r
+              Enumeration en = jal.getSequenceAt(i).getDatasetSequence().getPDBId().elements();\r
+              while(en.hasMoreElements())\r
+              {\r
+                Pdbids pdb = new Pdbids();\r
+                jalview.datamodel.PDBEntry entry\r
+                   = (jalview.datamodel.PDBEntry)en.nextElement();\r
+\r
+                pdb.setId(entry.getId());\r
+                pdb.setType(entry.getType());\r
+\r
+                if(entry.getProperty()!=null)\r
+                {\r
+                  PdbentryItem item = new PdbentryItem();\r
+                  Hashtable properties = entry.getProperty();\r
+                  Enumeration en2 = properties.keys();\r
+                  while(en2.hasMoreElements())\r
+                  {\r
+                    Property prop = new Property();\r
+                    String key = en2.nextElement().toString();\r
+                    prop.setName(key);\r
+                    prop.setValue( properties.get(key).toString() );\r
+                    item.addProperty(prop);\r
+                  }\r
+                  pdb.addPdbentryItem(item);\r
+                }\r
+\r
+                jseq.addPdbids(pdb);\r
+              }\r
+            }\r
+\r
             jms.addJSeq(jseq);\r
             vamsasSet.addSequence(vamsasSeq);\r
             id++;\r
@@ -345,6 +396,7 @@ public class Jalview2XML
             jms.setJGroup(groups);\r
         }\r
 \r
+\r
         ///////////SAVE VIEWPORT\r
         Viewport view = new Viewport();\r
         view.setTitle(af.getTitle());\r
@@ -393,15 +445,40 @@ public class Jalview2XML
         view.setShowBoxes(av.getShowBoxes());\r
         view.setShowColourText(av.getColourText());\r
         view.setShowConservation(av.showConservation);\r
-        view.setShowFullId(av.getShowFullId());\r
+        view.setShowFullId(av.getShowJVSuffix());\r
         view.setShowIdentity(av.showIdentity);\r
         view.setShowQuality(av.showQuality);\r
         view.setShowSequenceFeatures(av.showSequenceFeatures);\r
         view.setShowText(av.getShowText());\r
         view.setWrapAlignment(av.getWrapAlignment());\r
 \r
+        if(af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed!=null)\r
+        {\r
+          jalview.binding.FeatureSettings fs = new jalview.binding.FeatureSettings();\r
+\r
+          Enumeration e = af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours.keys();\r
+          while (e.hasMoreElements())\r
+          {\r
+            String type = e.nextElement().toString();\r
+            Setting setting = new Setting();\r
+            setting.setType(type);\r
+            setting.setColour(\r
+                af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().getColour(type).getRGB()\r
+                );\r
+            setting.setDisplay(\r
+                af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed.contains(type)\r
+                );\r
+\r
+            fs.addSetting(setting);\r
+\r
+          }\r
+          jms.setFeatureSettings(fs);\r
+\r
+        }\r
+\r
         jms.addViewport(view);\r
 \r
+\r
         object.setJalviewModelSequence(jms);\r
         object.getVamsasModel().addSequenceSet(vamsasSet);\r
 \r
@@ -569,7 +646,6 @@ public class Jalview2XML
         //LOAD SEQUENCES\r
         jalview.datamodel.Sequence[] jseqs = new jalview.datamodel.Sequence[vamsasSeq.length];\r
         JSeq[] JSEQ = object.getJalviewModelSequence().getJSeq();\r
-\r
         for (int i = 0; i < vamsasSeq.length; i++)\r
         {\r
             jseqs[i] = new jalview.datamodel.Sequence(vamsasSeq[i].getName(),\r
@@ -581,9 +657,41 @@ public class Jalview2XML
             seqids.add(jseqs[i]);\r
         }\r
 \r
+        ///SequenceFeatures are added to the DatasetSequence,\r
+        // so we must create the dataset before loading features\r
         /////////////////////////////////\r
         jalview.datamodel.Alignment al = new jalview.datamodel.Alignment(jseqs);\r
+        al.setDataset(null);\r
+        /////////////////////////////////\r
 \r
+        for (int i = 0; i < vamsasSeq.length; i++)\r
+        {\r
+          if (JSEQ[i].getFeaturesCount() > 0)\r
+          {\r
+            Features[] features = JSEQ[i].getFeatures();\r
+            for (int f = 0; f < features.length; f++)\r
+            {\r
+              //features[f].getBegin()\r
+              jalview.datamodel.SequenceFeature sf\r
+                  = new jalview.datamodel.SequenceFeature(features[f].getType(),\r
+                  features[f].getDescription(), features[f].getStatus(),\r
+                  features[f].getBegin(), features[f].getEnd());\r
+              al.getSequenceAt(i).getDatasetSequence().addSequenceFeature(sf);\r
+            }\r
+          }\r
+          if (JSEQ[i].getPdbidsCount() > 0)\r
+          {\r
+            Pdbids[] ids = JSEQ[i].getPdbids();\r
+            for (int p = 0; p < ids.length; p++)\r
+            {\r
+              jalview.datamodel.PDBEntry entry = new jalview.datamodel.PDBEntry();\r
+              entry.setId(ids[p].getId());\r
+              entry.setType(ids[p].getType());\r
+              al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);\r
+            }\r
+\r
+          }\r
+        }\r
         /////////////////////////////////\r
         //////////////////////////////////\r
         //LOAD ANNOTATIONS\r
@@ -628,6 +736,7 @@ public class Jalview2XML
 \r
         AlignFrame af = new AlignFrame(al);\r
 \r
+\r
         //  af.changeColour() );\r
         /////////////////////////\r
         //LOAD GROUPS\r
@@ -700,8 +809,8 @@ public class Jalview2XML
         af.viewport.setConservationSelected(view.getConservationSelected());\r
         af.conservationMenuItem.setSelected(view.getConservationSelected());\r
 \r
-        af.viewport.setShowFullId(view.getShowFullId());\r
-        af.fullSeqId.setSelected(view.getShowFullId());\r
+        af.viewport.setShowJVSuffix(view.getShowFullId());\r
+        af.seqLimits.setSelected(view.getShowFullId());\r
 \r
         af.viewport.setFont(new java.awt.Font(view.getFontName(),\r
                 view.getFontStyle(), view.getFontSize()));\r
@@ -762,10 +871,25 @@ public class Jalview2XML
 \r
         if (view.getShowSequenceFeatures())\r
         {\r
-            af.viewport.showSequenceFeatures = true;\r
-            af.sequenceFeatures.setSelected(true);\r
-            new SequenceFeatureFetcher(al, af.alignPanel);\r
-            al.featuresAdded = true;\r
+           af.featureSettings.setEnabled(true);\r
+           af.viewport.showSequenceFeatures = true;\r
+           af.sequenceFeatures.setSelected(true);\r
+        }\r
+\r
+        if(jms.getFeatureSettings()!=null)\r
+        {\r
+          af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed = new Vector();\r
+         // af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed!=null)\r
+         // jalview.binding.FeatureSettings fs = new jalview.binding.FeatureSettings();\r
+         for(int fs=0; fs<jms.getFeatureSettings().getSettingCount(); fs++)\r
+         {\r
+           Setting setting = jms.getFeatureSettings().getSetting(fs);\r
+\r
+           af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(setting.getType(),\r
+               new java.awt.Color(setting.getColour()));\r
+           if(setting.getDisplay())\r
+             af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed.addElement(setting.getType());\r
+         }\r
         }\r
 \r
         Desktop.addInternalFrame(af, view.getTitle(),\r
index 635e455..3662ec2 100755 (executable)
@@ -49,7 +49,8 @@ public class OverviewPanel extends JPanel implements Runnable
 \r
     // Can set different properties in this seqCanvas than\r
     // main visible SeqCanvas\r
-    SeqCanvas overviewSeq;\r
+    SequenceRenderer sr;\r
+    FeatureRenderer fr;\r
 \r
     /**\r
      * Creates a new OverviewPanel object.\r
@@ -62,14 +63,16 @@ public class OverviewPanel extends JPanel implements Runnable
         this.ap = ap;\r
         setLayout(null);\r
 \r
-        overviewSeq = new SeqCanvas(av);\r
-        overviewSeq.isOverview = true;\r
-        overviewSeq.sr.renderGaps = false;\r
+        sr = new SequenceRenderer(av);\r
+        sr.renderGaps( false );\r
+        fr = new FeatureRenderer(av);\r
+        fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency;\r
+        fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed;\r
 \r
         // scale the initial size of overviewpanel to shape of alignment\r
         float initialScale = (float) av.alignment.getWidth() / (float) av.alignment.getHeight();\r
 \r
-        if(av.vconsensus==null)\r
+        if(av.conservation==null)\r
           graphHeight = 0;\r
 \r
 \r
@@ -257,34 +260,50 @@ public class OverviewPanel extends JPanel implements Runnable
 \r
 \r
         Graphics mg = miniMe.getGraphics();\r
+        mg.setColor(Color.orange);\r
+        mg.fillRect(0,0,width, miniMe.getHeight());\r
 \r
         float sampleCol = (float) alwidth / (float) width;\r
         float sampleRow = (float) alheight / (float) sequencesHeight;\r
 \r
+        int lastcol=-1, lastrow=-1;\r
+        Color color = Color.white;\r
         for (int col = 0; col < width; col++)\r
         {\r
           for (int row = 0; row < sequencesHeight; row++)\r
           {\r
-            overviewSeq.drawPanel(mg,\r
-                                            (int) (col * sampleCol),\r
-                                            (int) (col * sampleCol),\r
-                                            (int) (row * sampleRow),\r
-                                            (int) (row * sampleRow) + 1,\r
-                                            (int) (col * sampleCol),\r
-                                            (int) (row * sampleRow), 0);\r
-            mg.translate(0, 1);\r
+            if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow)\r
+            {\r
+              miniMe.setRGB(col,row,color.getRGB());\r
+              continue;\r
+            }\r
+\r
+            lastrow = (int)(row*sampleRow);\r
+            lastcol = (int)(col*sampleCol);\r
+\r
+            color = sr.getResidueBoxColour(\r
+                av.alignment.getSequenceAt(lastrow), lastcol);\r
+\r
+            if(av.showSequenceFeatures)\r
+            {\r
+              color = fr.findFeatureColour(color,\r
+                                                       av.alignment.getSequenceAt(lastrow),\r
+                                                       lastcol);\r
+            }\r
+\r
+            miniMe.setRGB(col,row,color.getRGB());\r
 \r
             if (av.conservation != null)\r
+            {\r
+              mg.translate(col, sequencesHeight);\r
               ap.annotationPanel.drawGraph(mg, av.conservation,\r
                                            (int) (sampleCol) + 1,\r
                                            graphHeight,\r
                                            (int) (col * sampleCol),\r
                                            (int) (col * sampleCol) + 1);\r
-\r
+              mg.translate(-col, -sequencesHeight);\r
+            }\r
           }\r
-          mg.translate(0, -sequencesHeight);\r
-          mg.translate(1, 0);\r
-\r
         }\r
 \r
         System.gc();\r
index 71891aa..e680dde 100755 (executable)
@@ -29,10 +29,6 @@ import java.awt.event.*;
 \r
 import java.util.*;\r
 import javax.swing.*;\r
-import java.io.FileOutputStream;\r
-import org.jibble.epsgraphics.EpsGraphics2D;\r
-import javax.imageio.ImageIO;\r
-import java.awt.image.BufferedImage;\r
 import java.awt.print.*;\r
 \r
 \r
@@ -313,7 +309,6 @@ public class PCAPanel extends GPCAPanel implements Runnable
 \r
 \r
 \r
-\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -321,79 +316,7 @@ public class PCAPanel extends GPCAPanel implements Runnable
      */\r
     public void eps_actionPerformed(ActionEvent e)\r
     {\r
-      boolean accurateText = true;\r
-\r
-      String renderStyle = jalview.bin.Cache.getDefault("EPS_RENDERING",\r
-          "Prompt each time");\r
-\r
-  // If we need to prompt, and if the GUI is visible then\r
-  // Prompt for EPS rendering style\r
-      if (renderStyle.equalsIgnoreCase("Prompt each time")\r
-          && !\r
-          (System.getProperty("java.awt.headless") != null\r
-           && System.getProperty("java.awt.headless").equals("true")))\r
-      {\r
-        EPSOptions eps = new EPSOptions();\r
-        renderStyle = eps.getValue();\r
-\r
-        if (renderStyle == null || eps.cancelled)\r
-          return;\r
-\r
-      }\r
-\r
-      if (renderStyle.equalsIgnoreCase("text"))\r
-      {\r
-        accurateText = false;\r
-      }\r
-\r
-      int width = rc.getWidth();\r
-      int height = rc.getHeight();\r
-\r
-      try\r
-      {\r
-        jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(\r
-            jalview.bin.Cache.getProperty(\r
-                "LAST_DIRECTORY"), new String[]\r
-            {"eps"},\r
-            new String[]\r
-            {"Encapsulated Postscript"},\r
-            "Encapsulated Postscript");\r
-        chooser.setFileView(new jalview.io.JalviewFileView());\r
-        chooser.setDialogTitle("Create EPS file from PCA");\r
-        chooser.setToolTipText("Save");\r
-\r
-        int value = chooser.showSaveDialog(this);\r
-\r
-        if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
-        {\r
-          return;\r
-        }\r
-\r
-        jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
-                                      chooser.getSelectedFile().getParent());\r
-\r
-        FileOutputStream out = new FileOutputStream(chooser.getSelectedFile());\r
-        EpsGraphics2D pg = new EpsGraphics2D("PCA", out, 0, 0, width,\r
-                                             height);\r
-\r
-        pg.setAccurateTextMode(accurateText);\r
-\r
-        rc.drawBackground(pg, rc.bgColour);\r
-        rc.drawScene(pg);\r
-\r
-        if (rc.drawAxes == true)\r
-        {\r
-          rc.drawAxes(pg);\r
-        }\r
-\r
-\r
-        pg.flush();\r
-        pg.close();\r
-      }\r
-      catch (Exception ex)\r
-      {\r
-        ex.printStackTrace();\r
-      }\r
+      makePCAImage(jalview.util.ImageMaker.EPS);\r
     }\r
 \r
     /**\r
@@ -403,48 +326,38 @@ public class PCAPanel extends GPCAPanel implements Runnable
      */\r
     public void png_actionPerformed(ActionEvent e)\r
     {\r
+       makePCAImage(jalview.util.ImageMaker.PNG);\r
+    }\r
+\r
+    void makePCAImage(int type)\r
+    {\r
       int width = rc.getWidth();\r
       int height = rc.getHeight();\r
 \r
-      try\r
-      {\r
-        jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(\r
-            jalview.bin.Cache.getProperty(\r
-                "LAST_DIRECTORY"), new String[]\r
-            {"png"},\r
-            new String[]\r
-            {"Portable network graphics"},\r
-            "Portable network graphics");\r
-\r
-        chooser.setFileView(new jalview.io.JalviewFileView());\r
-        chooser.setDialogTitle("Create PNG image from PCA");\r
-        chooser.setToolTipText("Save");\r
-\r
-        int value = chooser.showSaveDialog(this);\r
+      jalview.util.ImageMaker im;\r
 \r
-        if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION)\r
-        {\r
-          return;\r
-        }\r
-\r
-        jalview.bin.Cache.setProperty("LAST_DIRECTORY",\r
-                                      chooser.getSelectedFile().getParent());\r
-\r
-        FileOutputStream out = new FileOutputStream(chooser.getSelectedFile());\r
-\r
-        BufferedImage bi = new BufferedImage(width, height,\r
-                                             BufferedImage.TYPE_INT_RGB);\r
-        Graphics big = bi.getGraphics();\r
-\r
-        big.drawImage(rc.img,0,0,this);\r
-\r
-        ImageIO.write(bi, "png", out);\r
-        out.close();\r
-      }\r
-      catch (Exception ex)\r
-      {\r
-        ex.printStackTrace();\r
-      }\r
+      if(type == jalview.util.ImageMaker.PNG)\r
+        im = new jalview.util.ImageMaker(this,\r
+                                         jalview.util.ImageMaker.PNG,\r
+                                         "Make PNG image from PCA",\r
+                                         width, height,\r
+                                         null, null);\r
+        else\r
+          im = new jalview.util.ImageMaker(this,\r
+                                 jalview.util.ImageMaker.EPS,\r
+                                 "Make EPS file from PCA",\r
+                                 width, height,\r
+                                 null, this.getTitle());\r
+\r
+      if(im.getGraphics()!=null)\r
+       {\r
+         rc.drawBackground(im.getGraphics(), Color.black);\r
+         rc.drawScene(im.getGraphics());\r
+         if (rc.drawAxes == true)\r
+         {\r
+           rc.drawAxes(im.getGraphics());\r
+         }\r
+         im.writeImage();\r
+       }\r
     }\r
-\r
   }\r
index 6509063..31efd84 100755 (executable)
@@ -77,7 +77,7 @@ public class PairwiseAlignPanel extends GPairwiseAlignPanel
                         (SequenceI) selsubset.elementAt(j), "pep");\r
                 as.calcScoreMatrix();\r
                 as.traceAlignment();\r
-                as.printAlignment();\r
+                as.printAlignment(System.out);\r
                 scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length;\r
                 totscore = totscore + scores[i][j];\r
 \r
index 1377de2..f9e0d19 100755 (executable)
@@ -24,7 +24,6 @@ import jalview.analysis.*;
 \r
 import jalview.datamodel.*;\r
 \r
-import jalview.io.*;\r
 \r
 import jalview.schemes.*;\r
 \r
@@ -63,7 +62,6 @@ public class PopupMenu extends JPopupMenu
     JMenuItem sequenceName = new JMenuItem();\r
     Sequence sequence;\r
     JMenuItem unGroupMenuItem = new JMenuItem();\r
-    JMenuItem pdbMenuItem = new JMenuItem();\r
     JMenuItem outline = new JMenuItem();\r
     JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();\r
     JMenu colourMenu = new JMenu();\r
@@ -77,7 +75,7 @@ public class PopupMenu extends JPopupMenu
      * @param ap DOCUMENT ME!\r
      * @param seq DOCUMENT ME!\r
      */\r
-    public PopupMenu(AlignmentPanel ap, Sequence seq)\r
+    public PopupMenu(final AlignmentPanel ap, Sequence seq)\r
     {\r
         ///////////////////////////////////////////////////////////\r
         // If this is activated from the sequence panel, the user may want to\r
@@ -112,9 +110,27 @@ public class PopupMenu extends JPopupMenu
             e.printStackTrace();\r
         }\r
 \r
-        if ((seq == null) || (seq.getPDBId() == null))\r
+\r
+        if ((seq != null)\r
+            && seq.getDatasetSequence().getPDBId() != null)\r
         {\r
-            pdbMenuItem.setVisible(false);\r
+          java.util.Enumeration e = seq.getDatasetSequence().getPDBId().elements();\r
+          while(e.hasMoreElements())\r
+          {\r
+            final PDBEntry pdb = (PDBEntry)e.nextElement();\r
+\r
+            JMenuItem pdbMenuItem = new JMenuItem();\r
+            pdbMenuItem.setText("View PDB entry: "+pdb.getId());\r
+            pdbMenuItem.addActionListener(new java.awt.event.ActionListener()\r
+            {\r
+                public void actionPerformed(ActionEvent e)\r
+                {\r
+                  new PDBViewer(pdb, sequence, ap.seqPanel.seqCanvas);\r
+                }\r
+            });\r
+            sequenceMenu.add(pdbMenuItem);\r
+          }\r
+\r
         }\r
 \r
         SequenceGroup sg = ap.av.getSelectionGroup();\r
@@ -206,9 +222,12 @@ public class PopupMenu extends JPopupMenu
             String link = links.elementAt(i).toString();\r
 \r
             item = new JMenuItem(link.substring(0, link.indexOf("|")));\r
+            String id = sequence.getName();\r
+            if(id.indexOf("|")>-1)\r
+              id = id.substring(id.lastIndexOf("|")+1);\r
 \r
             final String url = link.substring(link.indexOf("|")+1, link.indexOf("$SEQUENCE_ID$"))\r
-                + sequence.getName() +\r
+                + id +\r
                 link.substring(link.indexOf("$SEQUENCE_ID$") + 13);\r
 \r
 \r
@@ -261,14 +280,7 @@ public class PopupMenu extends JPopupMenu
                     unGroupMenuItem_actionPerformed(e);\r
                 }\r
             });\r
-        pdbMenuItem.setText("View PDB structure");\r
-        pdbMenuItem.addActionListener(new java.awt.event.ActionListener()\r
-            {\r
-                public void actionPerformed(ActionEvent e)\r
-                {\r
-                    pdbMenuItem_actionPerformed(e);\r
-                }\r
-            });\r
+\r
         outline.setText("Border colour");\r
         outline.addActionListener(new java.awt.event.ActionListener()\r
             {\r
@@ -325,7 +337,6 @@ public class PopupMenu extends JPopupMenu
         groupMenu.addSeparator();\r
         groupMenu.add(outline);\r
         sequenceMenu.add(sequenceName);\r
-        sequenceMenu.add(pdbMenuItem);\r
         colourMenu.add(noColourmenuItem);\r
         colourMenu.add(clustalColour);\r
         colourMenu.add(BLOSUM62Colour);\r
@@ -830,37 +841,6 @@ public class PopupMenu extends JPopupMenu
         refresh();\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param e DOCUMENT ME!\r
-     */\r
-    void pdbMenuItem_actionPerformed(ActionEvent e)\r
-    {\r
-        if (sequence.getPDBId() == null)\r
-        {\r
-            return;\r
-        }\r
-\r
-        try\r
-        {\r
-            EBIFetchClient ebi = new EBIFetchClient();\r
-            String[] result = ebi.fetchData("pdb:" + sequence.getPDBId(), null,\r
-                    null);\r
-\r
-            PDBfile pdb = new PDBfile(result);\r
-\r
-            rotCanvas rc = new rotCanvas(pdb, sequence, ap.av);\r
-            JInternalFrame frame = new JInternalFrame();\r
-            frame.setContentPane(rc);\r
-            Desktop.addInternalFrame(frame,\r
-                sequence.getName() + " " + sequence.getPDBId(), 400, 400);\r
-        }\r
-        catch (Exception ex)\r
-        {\r
-            ex.printStackTrace();\r
-        }\r
-    }\r
 \r
     /**\r
      * DOCUMENT ME!\r
index 32aad84..2243a3d 100755 (executable)
@@ -79,7 +79,7 @@ public class Preferences extends GPreferences
         Desktop.addInternalFrame(frame, "Preferences", 480, 390);\r
         frame.setMinimumSize(new Dimension(480,390));\r
 \r
-        fullID.setSelected(      Cache.getDefault("SHOW_FULL_ID", true));\r
+        seqLimit.setSelected(    Cache.getDefault("SHOW_JVSUFFIX", true));\r
         fullScreen.setSelected(  Cache.getDefault("SHOW_FULLSCREEN", false));\r
         annotations.setSelected( Cache.getDefault("SHOW_ANNOTATIONS", true));\r
 \r
@@ -140,6 +140,14 @@ public class Preferences extends GPreferences
         epsRendering.addItem("Text");\r
         epsRendering.setSelectedItem( Cache.getDefault("EPS_RENDERING", "Prompt each time"));\r
 \r
+        blcjv.setSelected( Cache.getDefault("BLC_JVSUFFIX", true) );\r
+        clustaljv.setSelected( Cache.getDefault("CLUSTAL_JVSUFFIX", true) );\r
+        fastajv.setSelected( Cache.getDefault("FASTA_JVSUFFIX", true) );\r
+        msfjv.setSelected( Cache.getDefault("MSF_JVSUFFIX", true) );\r
+        pfamjv.setSelected( Cache.getDefault("PFAM_JVSUFFIX", true) );\r
+        pileupjv.setSelected( Cache.getDefault("PILEUP_JVSUFFIX", true) );\r
+        pirjv.setSelected( Cache.getDefault("PIR_JVSUFFIX", true) );\r
+\r
   /****************************************************\r
    * Set up Connections\r
    */\r
@@ -181,7 +189,7 @@ public class Preferences extends GPreferences
     public void ok_actionPerformed(ActionEvent e)\r
     {\r
 \r
-      Cache.applicationProperties.setProperty("SHOW_FULL_ID", Boolean.toString(fullID.isSelected()));\r
+      Cache.applicationProperties.setProperty("SHOW_JVSUFFIX", Boolean.toString(seqLimit.isSelected()));\r
       Cache.applicationProperties.setProperty("SHOW_FULLSCREEN", Boolean.toString(fullScreen.isSelected()));\r
 \r
       Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", Boolean.toString(annotations.isSelected()));\r
@@ -257,6 +265,14 @@ public class Preferences extends GPreferences
         }\r
 \r
 \r
+        Cache.applicationProperties.setProperty("BLC_JVSUFFIX", Boolean.toString(blcjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX", Boolean.toString(clustaljv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("FASTA_JVSUFFIX", Boolean.toString(fastajv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("MSF_JVSUFFIX", Boolean.toString(msfjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PFAM_JVSUFFIX", Boolean.toString(pfamjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX", Boolean.toString(pileupjv.isSelected()) );\r
+        Cache.applicationProperties.setProperty("PIR_JVSUFFIX", Boolean.toString(pirjv.isSelected()) );\r
+\r
 \r
         Cache.saveProperties();\r
         try\r
index 92abbf6..fc72b4b 100755 (executable)
@@ -303,9 +303,13 @@ public class RotatableCanvas extends JPanel implements MouseListener,
      *\r
      * @param g DOCUMENT ME!\r
      */\r
-    public void paintComponent(Graphics g)\r
+    public void paintComponent(Graphics g1)\r
     {\r
 \r
+      Graphics2D g = (Graphics2D) g1;\r
+\r
+      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
+                         RenderingHints.VALUE_ANTIALIAS_ON);\r
       if(points==null)\r
       {\r
         g.setFont(new Font("Verdana", Font.PLAIN, 18));\r
@@ -345,12 +349,8 @@ public class RotatableCanvas extends JPanel implements MouseListener,
      *\r
      * @param g DOCUMENT ME!\r
      */\r
-    public void drawAxes(Graphics g1)\r
+    public void drawAxes(Graphics g)\r
     {\r
-      Graphics2D g = (Graphics2D) g1;\r
-\r
-      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,\r
-                         RenderingHints.VALUE_ANTIALIAS_ON);\r
 \r
         g.setColor(Color.yellow);\r
 \r
@@ -486,8 +486,6 @@ public class RotatableCanvas extends JPanel implements MouseListener,
      */\r
     public void keyPressed(KeyEvent evt)\r
     {\r
-        requestFocus();\r
-\r
         if (evt.getKeyCode() == KeyEvent.VK_UP)\r
         {\r
             scalefactor = (float) (scalefactor * 1.1);\r
index 7f9ee97..42424d9 100755 (executable)
@@ -24,6 +24,7 @@ import java.awt.*;
 import java.awt.image.*;\r
 \r
 import javax.swing.*;\r
+import jalview.schemes.*;\r
 \r
 \r
 /**\r
@@ -47,8 +48,6 @@ public class SeqCanvas extends JComponent
     int LABEL_WEST;\r
     int LABEL_EAST;\r
 \r
-    boolean isOverview = false;\r
-\r
     /**\r
      * Creates a new SeqCanvas object.\r
      *\r
@@ -64,6 +63,28 @@ public class SeqCanvas extends JComponent
         setBackground(Color.white);\r
     }\r
 \r
+    MCview.PDBCanvas pdbCanvas;\r
+    public SequenceRenderer getSequenceRenderer()\r
+    {\r
+      return sr;\r
+    }\r
+\r
+    public FeatureRenderer getFeatureRenderer()\r
+    {\r
+      return fr;\r
+    }\r
+\r
+    public void setPDBCanvas(MCview.PDBCanvas pc)\r
+    {\r
+      pdbCanvas = pc;\r
+    }\r
+\r
+    public AlignViewport getViewport()\r
+    {\r
+      return av;\r
+    }\r
+\r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -258,18 +279,20 @@ public class SeqCanvas extends JComponent
     // Set this to false to force a full panel paint\r
     public void paintComponent(Graphics g)\r
     {\r
+        super.paintComponent(g);\r
+\r
         sr.renderGaps(av.renderGaps);\r
 \r
-        if ((img != null) &&\r
-                (fastPaint || (getWidth() != g.getClipBounds().width) ||\r
-                (getHeight() != g.getClipBounds().height)))\r
+        if ( img != null && (fastPaint\r
+             || (getVisibleRect().width != g.getClipBounds().width)\r
+             || (getVisibleRect().height != g.getClipBounds().height)))\r
         {\r
             g.drawImage(img, 0, 0, this);\r
             fastPaint = false;\r
-\r
             return;\r
         }\r
 \r
+\r
         // this draws the whole of the alignment\r
         imgWidth = getWidth();\r
         imgHeight = getHeight();\r
@@ -282,7 +305,6 @@ public class SeqCanvas extends JComponent
             return;\r
         }\r
 \r
-\r
         img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);\r
         gg = (Graphics2D) img.getGraphics();\r
         gg.setFont(av.getFont());\r
@@ -304,6 +326,12 @@ public class SeqCanvas extends JComponent
         }\r
 \r
         g.drawImage(img, 0, 0, this);\r
+\r
+        if (pdbCanvas != null)\r
+        {\r
+         pdbCanvas.updateSeqColours();\r
+        }\r
+\r
     }\r
 \r
     /**\r
@@ -510,36 +538,83 @@ public class SeqCanvas extends JComponent
       repaint();\r
     }\r
 \r
+\r
     synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1,\r
         int y2, int startx, int starty, int offset)\r
     {\r
-        Graphics2D g = (Graphics2D) g1;\r
-        g.setFont(av.getFont());\r
+      Graphics2D g = (Graphics2D) g1;\r
+      g.setFont(av.getFont());\r
 \r
+      SequenceI nextSeq, dna = null;\r
+      int aaHeight = av.charHeight, dnaHeight = av.charHeight;\r
+      Font dnafont = null, aafont = av.getFont();\r
 \r
-  SequenceI nextSeq;\r
+ /*     if (av.getShowTranslation())\r
+      {\r
+        aaHeight = (int) (av.getCharHeight() * aaRatio);\r
+        dnaHeight = (int) (av.getCharHeight() * (1 - aaRatio));\r
+        java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();\r
+        transform.scale(1f / 3f, 1);\r
+        dnafont = new Font(av.getFont().getName(), av.getFont().getStyle(),\r
+                                dnaHeight);\r
+        dnafont = dnafont.deriveFont(transform);\r
+\r
+        aafont = new Font(av.getFont().getName(), av.getFont().getStyle(),\r
+                               aaHeight);\r
+        transform = new java.awt.geom.AffineTransform();\r
+        transform.scale(1 / aaRatio, 1);\r
+        aafont = aafont.deriveFont(transform);\r
+      }\r
+*/\r
 \r
+      ColourSchemeI cs = av.getGlobalColourScheme();\r
 \r
         /// First draw the sequences\r
         /////////////////////////////\r
         for (int i = y1; i < y2; i++)\r
         {\r
             nextSeq = av.alignment.getSequenceAt(i);\r
-            g.setFont(av.getFont());\r
-\r
+            g.setFont(aafont);\r
+         /*   if(av.getShowTranslation())\r
+            {\r
+              dna = nextSeq;\r
+              StringBuffer sb = new StringBuffer();\r
+              for(int r = 0; r<nextSeq.getLength(); r+=3)\r
+              {\r
+                String codon = nextSeq.getSequence(r, r+3);\r
+                codon = codon.replace('U', 'T');\r
+                String res = ResidueProperties.codonTranslate(codon);\r
+                if(res !=null )\r
+                {\r
+                  if (res.equals("STOP"))\r
+                    sb.append("X");\r
+                  else\r
+                    sb.append(res);\r
+                }\r
+              }\r
+              nextSeq = new Sequence("d", sb.toString());\r
+            }*/\r
 \r
             sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq),\r
                             x1, x2, (x1 - startx) * av.charWidth,\r
                             offset + ( (i - starty) * av.charHeight), av.charWidth,\r
-                            av.charHeight);\r
-\r
-\r
+                            aaHeight);\r
 \r
+         /*   if(av.getShowTranslation())\r
+            {\r
+              av.setGlobalColourScheme(new NucleotideColourScheme());\r
+              g.setFont(dnafont);\r
+              sr.drawSequence(g, dna, null,\r
+                              x1*3, (x2+2) * 3, ( (x1 - startx) * av.charWidth) / 3,\r
+                              offset + ( (i - starty) * av.charHeight) + aaHeight,\r
+                              av.charWidth / 3,\r
+                              dnaHeight);\r
+              av.setGlobalColourScheme(cs);\r
+            }*/\r
 \r
             if (av.showSequenceFeatures)\r
             {\r
-                fr.drawSequence(g, nextSeq,\r
-                    av.alignment.findAllGroups(nextSeq), x1, x2,\r
+                fr.drawSequence(g, nextSeq, x1, x2,\r
                     (x1 - startx) * av.charWidth,\r
                     offset + ((i - starty) * av.charHeight), av.charWidth,\r
                     av.charHeight);\r
@@ -551,21 +626,19 @@ public class SeqCanvas extends JComponent
         // Now outline any areas if necessary\r
         /////////////////////////////////////\r
         SequenceGroup group = av.getSelectionGroup();\r
-        java.util.Vector groups = av.alignment.getGroups();\r
 \r
         int sx = -1;\r
         int sy = -1;\r
         int ex = -1;\r
         int groupIndex = -1;\r
 \r
-        if ((group == null) && (groups.size() > 0))\r
+        if ((group == null) && (av.alignment.getGroups().size() > 0))\r
         {\r
-            group = (SequenceGroup) groups.elementAt(0);\r
+            group = (SequenceGroup) av.alignment.getGroups().elementAt(0);\r
             groupIndex = 0;\r
         }\r
 \r
-\r
-        if (group != null && !isOverview)\r
+        if (group != null)\r
         {\r
             do\r
             {\r
@@ -701,14 +774,14 @@ public class SeqCanvas extends JComponent
 \r
                 groupIndex++;\r
 \r
-                if (groupIndex >= groups.size())\r
+                if (groupIndex >= av.alignment.getGroups().size())\r
                 {\r
                     break;\r
                 }\r
 \r
-                group = (SequenceGroup) groups.elementAt(groupIndex);\r
+                group = (SequenceGroup) av.alignment.getGroups().elementAt(groupIndex);\r
             }\r
-            while (groupIndex < groups.size());\r
+            while (groupIndex < av.alignment.getGroups().size());\r
         }\r
 \r
         /// Highlight search Results once all sequences have been drawn\r
index a68b226..3209960 100755 (executable)
@@ -89,21 +89,31 @@ public class SeqPanel extends JPanel
 \r
         ap = p;\r
 \r
+\r
         addMouseMotionListener(new MouseMotionAdapter()\r
             {\r
                 public void mouseMoved(MouseEvent evt)\r
                 {\r
                     doMouseMoved(evt);\r
+                    if (editingSeqs)\r
+                    {\r
+                      // This is because MacOSX creates a mouseMoved\r
+                      // If control is down\r
+                      if(!av.isDataset())\r
+                        doMouseDragged(evt);\r
+                    }\r
                 }\r
 \r
                 public void mouseDragged(MouseEvent evt)\r
                 {\r
                     if (editingSeqs)\r
                     {\r
+                      if(!av.isDataset())\r
                         doMouseDragged(evt);\r
                     }\r
                     else\r
                     {\r
+                      if(!av.isDataset())\r
                         doMouseDraggedDefineMode(evt);\r
                     }\r
                 }\r
@@ -118,7 +128,7 @@ public class SeqPanel extends JPanel
            {\r
              Font font = av.getFont();\r
              int fontSize = font.getSize();\r
-             if (e.getWheelRotation() > 0 && fontSize < 30)\r
+             if (e.getWheelRotation() > 0 && fontSize < 51)\r
                fontSize++;\r
              else if (fontSize > 1)\r
                fontSize--;\r
@@ -138,67 +148,71 @@ public class SeqPanel extends JPanel
        });\r
 \r
 \r
-        addMouseListener(new MouseAdapter()\r
-            {\r
-                public void mouseReleased(MouseEvent evt)\r
-                {\r
-                    mouseWheelPressed = false;\r
-\r
-                    if (editingSeqs)\r
-                    {\r
-                        doMouseReleased(evt);\r
-                    }\r
-                    else\r
-                    {\r
-                        doMouseReleasedDefineMode(evt);\r
-                    }\r
-                }\r
-\r
-                public void mousePressed(MouseEvent evt)\r
-                {\r
-                  if( javax.swing.SwingUtilities.isMiddleMouseButton(evt))\r
-                  {\r
-                    mouseWheelPressed = true;\r
-                    return;\r
-                  }\r
+       if(!av.isDataset())\r
+       {\r
+         addMouseListener(new MouseAdapter()\r
+         {\r
+           public void mouseReleased(MouseEvent evt)\r
+           {\r
+             mouseWheelPressed = false;\r
 \r
-                    if (evt.isShiftDown() || evt.isAltDown() ||\r
-                            evt.isControlDown())\r
-                    {\r
-                        if (evt.isAltDown() || evt.isControlDown())\r
-                        {\r
-                            groupEditing = true;\r
-                        }\r
+             if (editingSeqs)\r
+             {\r
+               doMouseReleased(evt);\r
+             }\r
+             else\r
+             {\r
+               doMouseReleasedDefineMode(evt);\r
+             }\r
+           }\r
 \r
-                        editingSeqs = true;\r
-                        doMousePressed(evt);\r
-                    }\r
-                    else\r
-                    {\r
-                        doMousePressedDefineMode(evt);\r
-                    }\r
-                }\r
+           public void mousePressed(MouseEvent evt)\r
+           {\r
+             if (javax.swing.SwingUtilities.isMiddleMouseButton(evt))\r
+             {\r
+               mouseWheelPressed = true;\r
+               return;\r
+             }\r
+\r
+             if (evt.isShiftDown() || evt.isAltDown() ||\r
+                 evt.isControlDown())\r
+             {\r
+               if (evt.isAltDown() || evt.isControlDown())\r
+               {\r
+                 groupEditing = true;\r
+\r
+               }\r
+\r
+               editingSeqs = true;\r
+               doMousePressed(evt);\r
+             }\r
+             else\r
+             {\r
+               doMousePressedDefineMode(evt);\r
+             }\r
+           }\r
 \r
-                public void mouseExited(MouseEvent evt)\r
-                {\r
-                  if (editingSeqs)\r
-                  {\r
-                    return;\r
-                  }\r
+           public void mouseExited(MouseEvent evt)\r
+           {\r
+             if (editingSeqs)\r
+             {\r
+               return;\r
+             }\r
 \r
-                  doMouseExitedDefineMode(evt);\r
-                }\r
+             doMouseExitedDefineMode(evt);\r
+           }\r
 \r
-                public void mouseEntered(MouseEvent evt)\r
-                {\r
-                  if (editingSeqs)\r
-                  {\r
-                    return;\r
-                  }\r
+           public void mouseEntered(MouseEvent evt)\r
+           {\r
+             if (editingSeqs)\r
+             {\r
+               return;\r
+             }\r
 \r
-                    doMouseEnteredDefineMode(evt);\r
-                }\r
-            });\r
+             doMouseEnteredDefineMode(evt);\r
+           }\r
+         });\r
+       }\r
     }\r
 \r
     int startWrapBlock=-1;\r
@@ -343,6 +357,12 @@ public class SeqPanel extends JPanel
         return;\r
       }\r
 \r
+      if(seqCanvas.pdbCanvas!=null && sequence==seqCanvas.pdbCanvas.sequence)\r
+      {\r
+        seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res));\r
+      }\r
+\r
+\r
         StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " +\r
                 sequence.getName());\r
 \r
@@ -376,32 +396,54 @@ public class SeqPanel extends JPanel
         // use aa to see if the mouse pointer is on a\r
         if (av.showSequenceFeatures)\r
         {\r
-            Vector features = sequence.getSequenceFeatures();\r
-            Enumeration e = features.elements();\r
-            StringBuffer sbuffer = new StringBuffer();\r
-\r
-            while (e.hasMoreElements())\r
+            Vector features = sequence.getDatasetSequence().getSequenceFeatures();\r
+            if(features!=null)\r
             {\r
-                SequenceFeature sf = (SequenceFeature) e.nextElement();\r
+              StringBuffer sbuffer = new StringBuffer("<html>");\r
 \r
-                if ((sf.getStart() <= sequence.findPosition(res)) &&\r
-                        (sf.getEnd() >= sequence.findPosition(res)))\r
+              for (int i = 0; i < features.size(); i++)\r
+              {\r
+                SequenceFeature sf = (SequenceFeature) features.elementAt(i);\r
+\r
+                if ( (sf.getBegin() <= sequence.findPosition(res)) &&\r
+                    (sf.getEnd() >= sequence.findPosition(res)))\r
                 {\r
-                    if (sbuffer.length() > 0)\r
+                  if (sf.getType().equals("disulfide bond"))\r
+                  {\r
+                    if (sf.getBegin() == sequence.findPosition(res)\r
+                        || sf.getEnd() == sequence.findPosition(res))\r
                     {\r
-                        sbuffer.append("; ");\r
+                      if (sbuffer.length() > 6)\r
+                        sbuffer.append("<br>");\r
+                      sbuffer.append("disulfide bond " + sf.getBegin() + ":" +\r
+                                     sf.getEnd());\r
                     }\r
+                  }\r
+                  else\r
+                  {\r
+                    if (sbuffer.length() > 6)\r
+                      sbuffer.append("<br>");\r
+                    sbuffer.append(sf.getType());\r
+                    if (sf.getDescription() != null)\r
+                      sbuffer.append(" " + sf.getDescription());\r
 \r
-                    sbuffer.append(sf.getType() + " " + sf.getDescription());\r
-\r
-                    if (sf.getStatus().length() > 0)\r
+                    if (sf.getStatus() != null)\r
                     {\r
-                        sbuffer.append(" (" + sf.getStatus() + ")");\r
+                      sbuffer.append(" (" + sf.getStatus() + ")");\r
                     }\r
+                  }\r
                 }\r
-            }\r
 \r
-            this.setToolTipText(sbuffer.toString());\r
+              }\r
+\r
+              sbuffer.append("</html>");\r
+              if(sbuffer.length()==13) // <html></html>\r
+                setToolTipText("");\r
+              else\r
+               setToolTipText(sbuffer.toString());\r
+            }\r
+            else\r
+              setToolTipText("");\r
         }\r
     }\r
 \r
@@ -967,7 +1009,7 @@ public class SeqPanel extends JPanel
 \r
                 try\r
                 {\r
-                    Thread.sleep(75);\r
+                    Thread.sleep(20);\r
                 }\r
                 catch (Exception ex)\r
                 {\r
diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java
new file mode 100755 (executable)
index 0000000..fc3bd41
--- /dev/null
@@ -0,0 +1,347 @@
+package jalview.gui;\r
+\r
+import javax.swing.*;\r
+import java.awt.*;\r
+import java.awt.event.*;\r
+import jalview.io.EBIFetchClient;\r
+import MCview.*;\r
+import jalview.datamodel.*;\r
+import jalview.analysis.AlignSeq;\r
+import java.io.File;\r
+import jalview.io.*;\r
+import java.util.*;\r
+\r
+\r
+public class SequenceFetcher\r
+    extends JPanel implements Runnable\r
+{\r
+  JInternalFrame frame;\r
+  AlignFrame alignFrame;\r
+  StringBuffer result;\r
+  public SequenceFetcher(AlignFrame af)\r
+  {\r
+    alignFrame = af;\r
+    database.addItem("-- Select Database --");\r
+    database.addItem("Uniprot");\r
+    database.addItem("EMBL");\r
+    database.addItem("EMBLCDS");\r
+    database.addItem("PDB");\r
+\r
+    try\r
+    {\r
+      jbInit();\r
+    }\r
+    catch (Exception ex)\r
+    {\r
+      ex.printStackTrace();\r
+    }\r
+\r
+    frame = new JInternalFrame();\r
+    frame.setContentPane(this);\r
+    if(System.getProperty("os.name").startsWith("Mac"))\r
+      Desktop.addInternalFrame(frame, "Sequence Fetcher (WSDBfetch@EBI)", 400, 140);\r
+    else\r
+      Desktop.addInternalFrame(frame, "Sequence Fetcher (WSDBfetch@EBI)", 400, 120);\r
+  }\r
+\r
+  private void jbInit()\r
+      throws Exception\r
+  {\r
+    this.setLayout(gridBagLayout1);\r
+\r
+    database.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    database.setMinimumSize(new Dimension(160, 21));\r
+    database.setPreferredSize(new Dimension(160, 21));\r
+    jLabel1.setFont(new java.awt.Font("Verdana", Font.ITALIC, 11));\r
+    jLabel1.setText(\r
+        "Separate multiple accession ids with semi colon \";\"");\r
+    ok.setText("OK");\r
+    ok.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        ok_actionPerformed(e);\r
+      }\r
+    });\r
+    cancel.setText("Cancel");\r
+    cancel.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        cancel_actionPerformed(e);\r
+      }\r
+    });\r
+    textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));\r
+    textfield.addActionListener(new ActionListener()\r
+    {\r
+      public void actionPerformed(ActionEvent e)\r
+      {\r
+        ok_actionPerformed(e);\r
+      }\r
+    });\r
+    jPanel1.add(ok);\r
+    jPanel1.add(cancel);\r
+    this.add(jLabel1, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0\r
+                                             , GridBagConstraints.WEST,\r
+                                             GridBagConstraints.NONE,\r
+                                             new Insets(7, 4, 0, 6), 77, 6));\r
+    this.add(jPanel1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0\r
+                                             , GridBagConstraints.WEST,\r
+                                             GridBagConstraints.BOTH,\r
+                                             new Insets(7, -2, 7, 12), 241, -2));\r
+    this.add(database, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0\r
+                                              , GridBagConstraints.WEST,\r
+                                              GridBagConstraints.NONE,\r
+                                              new Insets(0, 4, 0, 0), 1, 0));\r
+    this.add(textfield, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0\r
+                                               , GridBagConstraints.CENTER,\r
+                                               GridBagConstraints.HORIZONTAL,\r
+                                               new Insets(0, 0, 0, 6), 200, 1));\r
+  }\r
+\r
+  JComboBox database = new JComboBox();\r
+  JLabel jLabel1 = new JLabel();\r
+  JButton ok = new JButton();\r
+  JButton cancel = new JButton();\r
+  JPanel jPanel1 = new JPanel();\r
+  JTextField textfield = new JTextField();\r
+  GridBagLayout gridBagLayout1 = new GridBagLayout();\r
+  public void cancel_actionPerformed(ActionEvent e)\r
+  {\r
+    try\r
+    {\r
+      frame.setClosed(true);\r
+    }\r
+    catch (Exception ex)\r
+    {}\r
+  }\r
+\r
+  public void ok_actionPerformed(ActionEvent e)\r
+  {\r
+    frame.setTitle("Sequence Fetcher (WSDBfetch@EBI) - Fetching Sequence...");\r
+    database.setEnabled(false);\r
+    textfield.setEnabled(false);\r
+    ok.setEnabled(false);\r
+    cancel.setEnabled(false);\r
+\r
+    Thread worker = new Thread(this);\r
+    worker.start();\r
+  }\r
+\r
+  public void run()\r
+  {\r
+   result = new StringBuffer();\r
+    if (database.getSelectedItem().equals("Uniprot"))\r
+    {\r
+      getUniprotFile(textfield.getText());\r
+    }\r
+    else if (database.getSelectedItem().equals("EMBL")\r
+        || database.getSelectedItem().equals("EMBLCDS"))\r
+    {\r
+      EBIFetchClient dbFetch = new EBIFetchClient();\r
+      String[] reply = dbFetch.fetchData(\r
+          database.getSelectedItem().toString().toLowerCase(\r
+          ) + ":" + textfield.getText(),\r
+          "fasta", "raw");\r
+\r
+      for (int i = 0; i < reply.length; i++)\r
+        result.append(reply[i] + "\n");\r
+\r
+      parseResult(result.toString());\r
+    }\r
+    else if (database.getSelectedItem().equals("PDB"))\r
+    {\r
+      result = getPDBFile(textfield.getText().toUpperCase());\r
+      parseResult(result.toString());\r
+    }\r
+\r
+\r
+    if (result == null || result.length() == 0)\r
+      showErrorMessage("Error retrieving " + textfield.getText()\r
+                       + " from " + database.getSelectedItem());\r
+\r
+\r
+      database.setEnabled(true);\r
+      textfield.setEnabled(true);\r
+      ok.setEnabled(true);\r
+      cancel.setEnabled(true);\r
+      frame.setTitle("Sequence Fetcher (WSDBfetch@EBI)");\r
+  }\r
+\r
+  void getUniprotFile(String id)\r
+  {\r
+    EBIFetchClient ebi = new EBIFetchClient();\r
+    File file = ebi.fetchDataAsFile("uniprot:"+id,"xml", null);\r
+    SequenceFeatureFetcher sff = new SequenceFeatureFetcher();\r
+    Vector entries = sff.getUniprotEntries(file);\r
+\r
+    if(entries!=null)\r
+    {\r
+      //First, make the new sequences\r
+      Enumeration en = entries.elements();\r
+      while (en.hasMoreElements())\r
+      {\r
+        UniprotEntry entry = (UniprotEntry) en.nextElement();\r
+        StringBuffer name = new StringBuffer( ">Uniprot/Swiss-Prot" );\r
+        Enumeration en2 = entry.getAccession().elements();\r
+        while(en2.hasMoreElements())\r
+        {\r
+          name.append("|");\r
+          name.append(en2.nextElement());\r
+        }\r
+        en2 = entry.getName().elements();\r
+        while(en2.hasMoreElements())\r
+        {\r
+          name.append("|");\r
+          name.append(en2.nextElement());\r
+        }\r
+\r
+        if(entry.getProteinName()!=null)\r
+          name.append(" "+entry.getProteinName().elementAt(0));\r
+\r
+        result.append(name +"\n"+entry.getUniprotSequence().getContent());\r
+\r
+      }\r
+\r
+      //Then read in the features and apply them to the dataset\r
+      SequenceI [] sequence = parseResult(result.toString());\r
+      for(int i=0; i<entries.size(); i++)\r
+      {\r
+        UniprotEntry entry = (UniprotEntry) entries.elementAt(i);\r
+        Enumeration e = entry.getDbReference().elements();\r
+        Vector onlyPdbEntries = new Vector();\r
+        while (e.hasMoreElements())\r
+        {\r
+          PDBEntry pdb = (PDBEntry) e.nextElement();\r
+          if (!pdb.getType().equals("PDB"))\r
+            continue;\r
+\r
+          onlyPdbEntries.addElement(pdb);\r
+        }\r
+\r
+        sequence[i].getDatasetSequence().setPDBId(onlyPdbEntries);\r
+        sequence[i].getDatasetSequence().setSequenceFeatures(entry.getFeature());\r
+\r
+      }\r
+    }\r
+  }\r
+\r
+    StringBuffer getPDBFile(String id)\r
+    {\r
+      StringBuffer result = new StringBuffer();\r
+      String chain = null;\r
+      if (id.indexOf(":") > -1)\r
+      {\r
+        chain = id.substring(id.indexOf(":") + 1);\r
+        id = id.substring(0, id.indexOf(":"));\r
+      }\r
+\r
+      EBIFetchClient ebi = new EBIFetchClient();\r
+      String[] reply = ebi.fetchData("pdb:" + id, "pdb", "raw");\r
+      try\r
+      {\r
+        PDBfile pdbfile = new PDBfile(reply);\r
+        for (int i = 0; i < pdbfile.chains.size(); i++)\r
+        {\r
+          if (chain == null ||\r
+              ( (PDBChain) pdbfile.chains.elementAt(i)).id.\r
+              toUpperCase().equals(chain))\r
+            result.append("\n>PDB|" + id + "|" +\r
+                          ( (PDBChain) pdbfile.chains.elementAt(i)).sequence.\r
+                          getName() +\r
+                          "\n"\r
+                          +\r
+                          ( (PDBChain) pdbfile.chains.elementAt(i)).sequence.\r
+                          getSequence());\r
+        }\r
+      }\r
+      catch (Exception ex) // Problem parsing PDB file\r
+      {\r
+        showErrorMessage("Error retrieving " + textfield.getText() + " from " +\r
+            database.getSelectedItem());\r
+        return null;\r
+      }\r
+\r
+      return result;\r
+    }\r
+\r
+    SequenceI[] parseResult(String result)\r
+    {\r
+      String format = IdentifyFile.Identify(result, "Paste");\r
+      SequenceI[] sequences = null;\r
+\r
+      if (FormatAdapter.formats.contains(format))\r
+      {\r
+        sequences = new FormatAdapter().readFile(result.toString(), "Paste", format);\r
+        if (sequences != null && sequences.length>0)\r
+        {\r
+          if(alignFrame==null)\r
+          {\r
+            AlignFrame af = new AlignFrame(new Alignment(sequences));\r
+            af.currentFileFormat = format;\r
+            Desktop.addInternalFrame(af, "Retrieved from "+database.getSelectedItem(),\r
+                                     AlignFrame.NEW_WINDOW_WIDTH,\r
+                                     AlignFrame.NEW_WINDOW_HEIGHT);\r
+            af.statusBar.setText("Successfully pasted alignment file");\r
+            try\r
+            {\r
+              af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", false));\r
+            }\r
+            catch (Exception ex)\r
+            {}\r
+          }\r
+          else\r
+          {\r
+            for (int i = 0; i < sequences.length; i++)\r
+            {\r
+              alignFrame.viewport.alignment.addSequence(sequences[i]);\r
+\r
+              ////////////////////////////\r
+              //Datset needs extension;\r
+              /////////////////////////////\r
+              Sequence ds = new Sequence(sequences[i].getName(),\r
+                                         AlignSeq.extractGaps("-. ",\r
+                  sequences[i].getSequence()),\r
+                                         sequences[i].getStart(),\r
+                                         sequences[i].getEnd());\r
+              sequences[i].setDatasetSequence(ds);\r
+              alignFrame.viewport.alignment.getDataset().addSequence(ds);\r
+            }\r
+            alignFrame.viewport.setEndSeq(alignFrame.viewport.alignment.\r
+                                          getHeight());\r
+            alignFrame.viewport.alignment.getWidth();\r
+            alignFrame.viewport.firePropertyChange("alignment", null,\r
+            alignFrame.viewport.getAlignment().getSequences());\r
+\r
+          }\r
+\r
+          if (database.getSelectedItem().equals("PDB"))\r
+          {\r
+            for (int i = 0; i < sequences.length; i++)\r
+            {\r
+              PDBEntry entry = new PDBEntry();\r
+              entry.setId(textfield.getText());\r
+              sequences[i].getDatasetSequence().addPDBId(entry);\r
+            }\r
+          }\r
+\r
+        }\r
+        else\r
+          showErrorMessage( "Error retrieving "+textfield.getText()\r
+                            +" from "+database.getSelectedItem());\r
+      }\r
+\r
+      return sequences;\r
+\r
+  }\r
+\r
+  void showErrorMessage(String error)\r
+  {\r
+    JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+         error, "Error Retrieving Data", JOptionPane.WARNING_MESSAGE);\r
+  }\r
+}\r
+\r
+\r
+\r
+\r
index 6bf4d40..57cd0fc 100755 (executable)
@@ -24,7 +24,6 @@ import jalview.schemes.*;
 \r
 import java.awt.*;\r
 \r
-\r
 /**\r
  * DOCUMENT ME!\r
  *\r
@@ -61,22 +60,27 @@ public class SequenceRenderer
         renderGaps = b;\r
     }\r
 \r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param cs DOCUMENT ME!\r
-     * @param seq DOCUMENT ME!\r
-     * @param i DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i)\r
+\r
+    public Color getResidueBoxColour(SequenceI seq, int i)\r
     {\r
-        getBoxColour(cs, seq, i);\r
+      allGroups = av.alignment.findAllGroups(seq);\r
 \r
-        return resBoxColour;\r
+      if (inCurrentSequenceGroup(i))\r
+      {\r
+        if (currentSequenceGroup.getDisplayBoxes())\r
+        {\r
+          getBoxColour(currentSequenceGroup.cs, seq, i);\r
+        }\r
+      }\r
+      else if (av.getShowBoxes())\r
+      {\r
+          getBoxColour(av.globalColourScheme, seq, i);\r
+      }\r
+\r
+      return resBoxColour;\r
     }\r
 \r
+\r
     /**\r
      * DOCUMENT ME!\r
      *\r
@@ -116,10 +120,10 @@ public class SequenceRenderer
 \r
         graphics = g;\r
 \r
-        drawBoxes(seq, start, end, x1, y1, width, height);\r
+        drawBoxes(seq, start, end, x1, y1, (int) width, height);\r
 \r
         fm = g.getFontMetrics();\r
-        drawText(seq, start, end, x1, y1,  width, height);\r
+        drawText(seq, start, end, x1, y1, (int) width, height);\r
     }\r
 \r
     /**\r
@@ -133,61 +137,62 @@ public class SequenceRenderer
      * @param width DOCUMENT ME!\r
      * @param height DOCUMENT ME!\r
      */\r
-    public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,\r
+    public synchronized void drawBoxes(SequenceI seq, int start, int end, int x1, int y1,\r
         int width, int height)\r
     {\r
-        int i = start;\r
-        int length = seq.getLength();\r
+      int i = start;\r
+      int length = seq.getLength();\r
 \r
-        int curStart = -1;\r
-        int curWidth = width;\r
+      int curStart = -1;\r
+      int curWidth = width;\r
 \r
-        Color tempColour = null;\r
+      Color tempColour = null;\r
 \r
-        while (i <= end)\r
-        {\r
-          resBoxColour = Color.white;\r
+      while (i <= end)\r
+      {\r
+        resBoxColour = Color.white;\r
 \r
-          if (i < length)\r
+        if (i < length)\r
+        {\r
+          if (inCurrentSequenceGroup(i))\r
           {\r
-            if (inCurrentSequenceGroup(i))\r
-            {\r
-              if (currentSequenceGroup.getDisplayBoxes())\r
-              {\r
-                getBoxColour(currentSequenceGroup.cs, seq, i);\r
-              }\r
-            }\r
-            else if (av.getShowBoxes())\r
+            if (currentSequenceGroup.getDisplayBoxes())\r
             {\r
-              getBoxColour(av.getGlobalColourScheme(), seq, i);\r
+              getBoxColour(currentSequenceGroup.cs, seq, i);\r
             }\r
-\r
+          }\r
+          else if (av.getShowBoxes())\r
+          {\r
+            getBoxColour(av.globalColourScheme, seq, i);\r
           }\r
 \r
-            if (resBoxColour != tempColour)\r
-            {\r
-                if (tempColour != null)\r
-                {\r
-                    graphics.fillRect(x1 + (width * (curStart - start)), y1,\r
-                        curWidth, height);\r
-                }\r
+        }\r
 \r
-                graphics.setColor(resBoxColour);\r
+          if (resBoxColour != tempColour)\r
+          {\r
+              if (tempColour != null)\r
+              {\r
+                  graphics.fillRect(x1 + (width * (curStart - start)), y1,\r
+                      curWidth, height);\r
+              }\r
 \r
-                curStart = i;\r
-                curWidth = width;\r
-                tempColour = resBoxColour;\r
-            }\r
-            else\r
-            {\r
-                curWidth += width;\r
-            }\r
+              graphics.setColor(resBoxColour);\r
 \r
-            i++;\r
-        }\r
+              curStart = i;\r
+              curWidth = width;\r
+              tempColour = resBoxColour;\r
+          }\r
+          else\r
+          {\r
+              curWidth += width;\r
+          }\r
+\r
+          i++;\r
+      }\r
+\r
+      graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth,\r
+          height);\r
 \r
-        graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth,\r
-            height);\r
     }\r
 \r
     /**\r
@@ -208,6 +213,7 @@ public class SequenceRenderer
         int charOffset = 0;\r
         char s;\r
 \r
+\r
         // Need to find the sequence position here.\r
         String sequence = seq.getSequence();\r
 \r
@@ -247,7 +253,7 @@ public class SequenceRenderer
 \r
                 if (av.getColourText())\r
                 {\r
-                    getBoxColour(av.getGlobalColourScheme(), seq, i);\r
+                    getBoxColour(av.globalColourScheme, seq, i);\r
 \r
                     if (av.getShowBoxes())\r
                     {\r
@@ -263,6 +269,7 @@ public class SequenceRenderer
             charOffset = (width - fm.charWidth(s)) / 2;\r
             graphics.drawString(String.valueOf(s),\r
                 charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady);\r
+\r
         }\r
     }\r
 \r
index 20624af..05f412f 100755 (executable)
@@ -127,11 +127,13 @@ public class SplashScreen extends JPanel implements Runnable
 \r
         int y = yoffset;\r
 \r
-        g.drawString("Jalview 2005 ", 50, y);\r
+        g.drawString("Jalview "+jalview.bin.Cache.getProperty("VERSION"), 50, y);\r
+\r
+        FontMetrics fm = g.getFontMetrics();\r
+        int vwidth = fm.stringWidth("Jalview "+jalview.bin.Cache.getProperty("VERSION"));\r
         g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2));\r
-        g.drawString("Version " + jalview.bin.Cache.getProperty("VERSION") +\r
-                     "; Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),\r
-                     180, y);\r
+        g.drawString("Last updated: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"),\r
+                     50 + vwidth +5, y);\r
 \r
         if (jalview.bin.Cache.getDefault("LATEST_VERSION", "Checking").equals("Checking"))\r
         {\r