JAL-1432 updated copyright notices
[jalview.git] / src / jalview / gui / FeatureSettings.java
index 2139da5..9f73873 100755 (executable)
@@ -1,29 +1,29 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.gui;
 
 import java.io.*;
 import java.util.*;
+import java.util.List;
 
 import java.awt.*;
 import java.awt.event.*;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
@@ -38,6 +38,7 @@ import jalview.datamodel.*;
 import jalview.io.*;
 import jalview.schemes.AnnotationColourGradient;
 import jalview.schemes.GraduatedColor;
+import jalview.ws.dbsources.das.api.jalviewSourceI;
 
 public class FeatureSettings extends JPanel
 {
@@ -165,21 +166,22 @@ public class FeatureSettings extends JPanel
     frame.setContentPane(this);
     if (new jalview.util.Platform().isAMac())
     {
-       Desktop.addInternalFrame(frame, "Sequence Feature Settings", 475, 480);
-    } else {
-       Desktop.addInternalFrame(frame, "Sequence Feature Settings", 400, 450);
+      Desktop.addInternalFrame(frame, "Sequence Feature Settings", 475, 480);
     }
-    
-    frame
-            .addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
-            {
-              public void internalFrameClosed(
-                      javax.swing.event.InternalFrameEvent evt)
-              {
-                fr.removePropertyChangeListener(change);
-                dassourceBrowser.fs = null;
-              };
-            });
+    else
+    {
+      Desktop.addInternalFrame(frame, "Sequence Feature Settings", 400, 450);
+    }
+
+    frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+    {
+      public void internalFrameClosed(
+              javax.swing.event.InternalFrameEvent evt)
+      {
+        fr.removePropertyChangeListener(change);
+        dassourceBrowser.fs = null;
+      };
+    });
     frame.setLayer(JLayeredPane.PALETTE_LAYER);
   }
 
@@ -279,8 +281,9 @@ public class FeatureSettings extends JPanel
                 // probably the color chooser!
                 table.setValueAt(colorChooser.getColor(), selectedRow, 1);
                 table.validate();
-                me.updateFeatureRenderer(((FeatureTableModel) table
-                        .getModel()).getData(), false);
+                me.updateFeatureRenderer(
+                        ((FeatureTableModel) table.getModel()).getData(),
+                        false);
               }
             }
           }
@@ -311,15 +314,15 @@ public class FeatureSettings extends JPanel
     Vector allGroups = new Vector();
     SequenceFeature[] tmpfeatures;
     String group;
-    for (int i = 0; i < af.getViewport().alignment.getHeight(); i++)
+    for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
     {
-      if (af.getViewport().alignment.getSequenceAt(i).getDatasetSequence()
-              .getSequenceFeatures() == null)
+      if (af.getViewport().getAlignment().getSequenceAt(i)
+              .getDatasetSequence().getSequenceFeatures() == null)
       {
         continue;
       }
 
-      tmpfeatures = af.getViewport().alignment.getSequenceAt(i)
+      tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
               .getDatasetSequence().getSequenceFeatures();
 
       int index = 0;
@@ -404,8 +407,8 @@ public class FeatureSettings extends JPanel
     {
       public void itemStateChanged(ItemEvent evt)
       {
-        fr.featureGroups.put(check.getText(), new Boolean(check
-                .isSelected()));
+        fr.featureGroups.put(check.getText(),
+                new Boolean(check.isSelected()));
         af.alignPanel.seqPanel.seqCanvas.repaint();
         if (af.alignPanel.overviewPanel != null)
         {
@@ -440,10 +443,10 @@ public class FeatureSettings extends JPanel
     // Find out which features should be visible depending on which groups
     // are selected / deselected
     // and recompute average width ordering
-    for (int i = 0; i < af.getViewport().alignment.getHeight(); i++)
+    for (int i = 0; i < af.getViewport().getAlignment().getHeight(); i++)
     {
 
-      tmpfeatures = af.getViewport().alignment.getSequenceAt(i)
+      tmpfeatures = af.getViewport().getAlignment().getSequenceAt(i)
               .getDatasetSequence().getSequenceFeatures();
       if (tmpfeatures == null)
       {
@@ -519,8 +522,8 @@ public class FeatureSettings extends JPanel
 
         data[dataIndex][0] = type;
         data[dataIndex][1] = fr.getFeatureStyle(type);
-        data[dataIndex][2] = new Boolean(af.getViewport().featuresDisplayed
-                .containsKey(type));
+        data[dataIndex][2] = new Boolean(
+                af.getViewport().featuresDisplayed.containsKey(type));
         dataIndex++;
         visibleChecks.removeElement(type);
       }
@@ -594,10 +597,10 @@ public class FeatureSettings extends JPanel
 
   void load()
   {
-    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
-            .getProperty("LAST_DIRECTORY"), new String[]
-    { "fc" }, new String[]
-    { "Sequence Feature Colours" }, "Sequence Feature Colours");
+    JalviewFileChooser chooser = new JalviewFileChooser(
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
+            { "fc" }, new String[]
+            { "Sequence Feature Colours" }, "Sequence Feature Colours");
     chooser.setFileView(new jalview.io.JalviewFileView());
     chooser.setDialogTitle("Load Feature Colours");
     chooser.setToolTipText("Load");
@@ -634,8 +637,8 @@ public class FeatureSettings extends JPanel
               Cache.log.warn("Couldn't parse out graduated feature color.",
                       e);
             }
-            GraduatedColor gcol = new GraduatedColor(mincol, maxcol, newcol
-                    .getMin(), newcol.getMax());
+            GraduatedColor gcol = new GraduatedColor(mincol, maxcol,
+                    newcol.getMin(), newcol.getMax());
             if (newcol.hasAutoScale())
             {
               gcol.setAutoScaled(newcol.getAutoScale());
@@ -658,13 +661,11 @@ public class FeatureSettings extends JPanel
               }
               if (ttyp.equalsIgnoreCase("ABOVE"))
               {
-                gcol
-                        .setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD);
+                gcol.setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD);
               }
               if (ttyp.equalsIgnoreCase("BELOW"))
               {
-                gcol
-                        .setThreshType(AnnotationColourGradient.BELOW_THRESHOLD);
+                gcol.setThreshType(AnnotationColourGradient.BELOW_THRESHOLD);
               }
             }
             fr.setColour(name = newcol.getName(), gcol);
@@ -694,10 +695,10 @@ public class FeatureSettings extends JPanel
 
   void save()
   {
-    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache
-            .getProperty("LAST_DIRECTORY"), new String[]
-    { "fc" }, new String[]
-    { "Sequence Feature Colours" }, "Sequence Feature Colours");
+    JalviewFileChooser chooser = new JalviewFileChooser(
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
+            { "fc" }, new String[]
+            { "Sequence Feature Colours" }, "Sequence Feature Colours");
     chooser.setFileView(new jalview.io.JalviewFileView());
     chooser.setDialogTitle("Save Feature Colour Scheme");
     chooser.setToolTipText("Save");
@@ -714,13 +715,13 @@ public class FeatureSettings extends JPanel
         PrintWriter out = new PrintWriter(new OutputStreamWriter(
                 new FileOutputStream(choice), "UTF-8"));
 
-        Enumeration e = fr.featureColours.keys();
+        Iterator e = fr.featureColours.keySet().iterator();
         float[] sortOrder = new float[fr.featureColours.size()];
         String[] sortTypes = new String[fr.featureColours.size()];
         int i = 0;
-        while (e.hasMoreElements())
+        while (e.hasNext())
         {
-          sortTypes[i] = e.nextElement().toString();
+          sortTypes[i] = e.next().toString();
           sortOrder[i] = fr.getOrder(sortTypes[i]);
           i++;
         }
@@ -904,7 +905,7 @@ public class FeatureSettings extends JPanel
     settingsPane.setLayout(borderLayout2);
     dasSettingsPane.setLayout(borderLayout3);
     bigPanel.setLayout(borderLayout4);
-    invert.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    invert.setFont(JvSwingUtils.getLabelFont());
     invert.setText("Invert Selection");
     invert.addActionListener(new ActionListener()
     {
@@ -913,7 +914,7 @@ public class FeatureSettings extends JPanel
         invertSelection();
       }
     });
-    optimizeOrder.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    optimizeOrder.setFont(JvSwingUtils.getLabelFont());
     optimizeOrder.setText("Optimise Order");
     optimizeOrder.addActionListener(new ActionListener()
     {
@@ -922,7 +923,7 @@ public class FeatureSettings extends JPanel
         orderByAvWidth();
       }
     });
-    sortByScore.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    sortByScore.setFont(JvSwingUtils.getLabelFont());
     sortByScore.setText("Seq sort by Score");
     sortByScore.addActionListener(new ActionListener()
     {
@@ -931,7 +932,7 @@ public class FeatureSettings extends JPanel
         sortByScore(null);
       }
     });
-    sortByDens.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    sortByDens.setFont(JvSwingUtils.getLabelFont());
     sortByDens.setText("Seq Sort by density");
     sortByDens.addActionListener(new ActionListener()
     {
@@ -940,7 +941,7 @@ public class FeatureSettings extends JPanel
         sortByDens(null);
       }
     });
-    cancel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    cancel.setFont(JvSwingUtils.getLabelFont());
     cancel.setText("Cancel");
     cancel.addActionListener(new ActionListener()
     {
@@ -950,7 +951,7 @@ public class FeatureSettings extends JPanel
         close();
       }
     });
-    ok.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    ok.setFont(JvSwingUtils.getLabelFont());
     ok.setText("OK");
     ok.addActionListener(new ActionListener()
     {
@@ -959,7 +960,7 @@ public class FeatureSettings extends JPanel
         close();
       }
     });
-    loadColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    loadColours.setFont(JvSwingUtils.getLabelFont());
     loadColours.setText("Load Colours");
     loadColours.addActionListener(new ActionListener()
     {
@@ -968,7 +969,7 @@ public class FeatureSettings extends JPanel
         load();
       }
     });
-    saveColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11));
+    saveColours.setFont(JvSwingUtils.getLabelFont());
     saveColours.setText("Save Colours");
     saveColours.addActionListener(new ActionListener()
     {
@@ -1134,13 +1135,13 @@ public class FeatureSettings extends JPanel
 
       if (fr.featureGroups != null)
       {
-        Enumeration en = fr.featureGroups.keys();
+        Iterator en = fr.featureGroups.keySet().iterator();
         gps = new String[fr.featureColours.size()];
         int g = 0;
         boolean valid = false;
-        while (en.hasMoreElements())
+        while (en.hasNext())
         {
-          String gp = (String) en.nextElement();
+          String gp = (String) en.next();
           Boolean on = (Boolean) fr.featureGroups.get(gp);
           if (on != null && on.booleanValue())
           {
@@ -1177,7 +1178,7 @@ public class FeatureSettings extends JPanel
    * @param checkDbRefs
    * @param promptFetchDbRefs
    */
-  private void doDasFeatureFetch(Vector selectedSources,
+  private void doDasFeatureFetch(List<jalviewSourceI> selectedSources,
           boolean checkDbRefs, boolean promptFetchDbRefs)
   {
     SequenceI[] dataset, seqs;
@@ -1225,9 +1226,9 @@ public class FeatureSettings extends JPanel
    *          Vector of Strings to resolve to DAS source nicknames.
    * @return sources that are present in source list.
    */
-  public Vector resolveSourceNicknames(Vector sources)
+  public List<jalviewSourceI> resolveSourceNicknames(Vector sources)
   {
-    return dassourceBrowser.resolveSourceNicknames(sources);
+    return dassourceBrowser.sourceRegistry.resolveSourceNicknames(sources);
   }
 
   /**
@@ -1253,14 +1254,15 @@ public class FeatureSettings extends JPanel
   public void fetchDasFeatures(Vector sources, boolean block)
   {
     initDasSources();
-    Vector resolved = resolveSourceNicknames(sources);
+    List<jalviewSourceI> resolved = dassourceBrowser.sourceRegistry
+            .resolveSourceNicknames(sources);
     if (resolved.size() == 0)
     {
       resolved = dassourceBrowser.getSelectedSources();
     }
     if (resolved.size() > 0)
     {
-      final Vector dassources = resolved;
+      final List<jalviewSourceI> dassources = resolved;
       fetchDAS.setEnabled(false);
       // cancelDAS.setEnabled(true); doDasFetch does this.
       Runnable fetcher = new Runnable()
@@ -1294,7 +1296,7 @@ public class FeatureSettings extends JPanel
     fetchDAS.setEnabled(true);
     cancelDAS.setEnabled(false);
     dassourceBrowser.setGuiEnabled(true);
-    
+
   }
 
   public void cancelDAS_actionPerformed(ActionEvent e)