JAL-3253-applet removes references to JalviewLite interface
[jalview.git] / src / jalview / bin / JalviewAppLoader.java
index 51a0330..a7c5042 100644 (file)
@@ -1,6 +1,5 @@
 package jalview.bin;
 
-import jalview.api.AlignFrameI;
 import jalview.api.JalviewApp;
 import jalview.api.StructureSelectionManagerProvider;
 import jalview.datamodel.Alignment;
@@ -761,14 +760,14 @@ public class JalviewAppLoader
     return arrayToSeparatorList(array, separator);
   }
 
-  public String getSelectedSequencesFrom(AlignFrameI alf, String sep)
+  public String getSelectedSequencesFrom(AlignFrame alf, String sep)
   {
     StringBuffer result = new StringBuffer("");
     if (sep == null || sep.length() == 0)
     {
       sep = separator; // "+0x00AC;
     }
-    AlignViewport v = ((AlignFrame) alf).getViewport();
+    AlignViewport v = alf.getViewport();
     if (v.getSelectionGroup() != null)
     {
       SequenceI[] seqs = v.getSelectionGroup()
@@ -784,7 +783,7 @@ public class JalviewAppLoader
     return result.toString();
   }
 
-  public void setFeatureGroupStateOn(final AlignFrameI alf,
+  public void setFeatureGroupStateOn(final AlignFrame alf,
           final String groups, boolean state)
   {
     java.awt.EventQueue.invokeLater(new Runnable()
@@ -792,19 +791,19 @@ public class JalviewAppLoader
       @Override
       public void run()
       {
-        ((AlignFrame) alf).setFeatureGroupState(
+        alf.setFeatureGroupState(
                 separatorListToArray(groups, separator), state);
       }
     });
   }
 
-  public String getFeatureGroupsOfStateOn(AlignFrameI alf, boolean visible)
+  public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible)
   {
     return arrayToSeparatorList(
-            ((AlignFrame) alf).getFeatureGroupsOfState(visible));
+            alf.getFeatureGroupsOfState(visible));
   }
 
-  public void scrollViewToIn(final AlignFrameI alf, final String topRow,
+  public void scrollViewToIn(final AlignFrame alf, final String topRow,
           final String leftHandColumn)
   {
     java.awt.EventQueue.invokeLater(new Runnable()
@@ -814,8 +813,8 @@ public class JalviewAppLoader
       {
         try
         {
-          ((AlignFrame) alf).scrollTo(new Integer(topRow).intValue(),
-                  new Integer(leftHandColumn).intValue());
+          alf.scrollTo(Integer.valueOf(topRow).intValue(),
+                  Integer.valueOf(leftHandColumn).intValue());
 
         } catch (Exception ex)
         {
@@ -828,7 +827,7 @@ public class JalviewAppLoader
     });
   }
 
-  public void scrollViewToRowIn(final AlignFrameI alf, final String topRow)
+  public void scrollViewToRowIn(final AlignFrame alf, final String topRow)
   {
 
     java.awt.EventQueue.invokeLater(new Runnable()
@@ -838,7 +837,7 @@ public class JalviewAppLoader
       {
         try
         {
-          ((AlignFrame) alf).scrollToRow(new Integer(topRow).intValue());
+          alf.scrollToRow(Integer.valueOf(topRow).intValue());
 
         } catch (Exception ex)
         {
@@ -851,7 +850,7 @@ public class JalviewAppLoader
     });
   }
 
-  public void scrollViewToColumnIn(final AlignFrameI alf,
+  public void scrollViewToColumnIn(final AlignFrame alf,
           final String leftHandColumn)
   {
     java.awt.EventQueue.invokeLater(new Runnable()
@@ -862,8 +861,9 @@ public class JalviewAppLoader
       {
         try
         {
-          ((AlignFrame) alf)
-                  .scrollToColumn(new Integer(leftHandColumn).intValue());
+          alf
+                  .scrollToColumn(
+                          Integer.valueOf(leftHandColumn).intValue());
 
         } catch (Exception ex)
         {
@@ -877,10 +877,10 @@ public class JalviewAppLoader
 
   }
 
-  public boolean addPdbFile(AlignFrameI alf, String sequenceId,
+  public boolean addPdbFile(AlignFrame alf, String sequenceId,
           String pdbEntryString, String pdbFile)
   {
-    AlignFrame alFrame = (AlignFrame) alf;
+    AlignFrame alFrame = alf;
     SequenceI toaddpdb = alFrame.getViewport().getAlignment()
             .findName(sequenceId);
     boolean needtoadd = false;
@@ -930,7 +930,7 @@ public class JalviewAppLoader
     return true;
   }
 
-  public AlignFrameI loadAlignment(String text, int width, int height,
+  public AlignFrame loadAlignment(String text, int width, int height,
           String title)
   {
     AlignmentI al = null;
@@ -952,18 +952,18 @@ public class JalviewAppLoader
     return null;
   }
 
-  public String getFeatureGroupsOn(AlignFrameI alf)
+  public String getFeatureGroupsOn(AlignFrame alf)
   {
     return arrayToSeparatorList(
-            ((AlignFrame) alf).getFeatureGroups());
+            alf.getFeatureGroups());
   }
 
-  public void highlightIn(final AlignFrameI alf, final String sequenceId,
+  public void highlightIn(final AlignFrame alf, final String sequenceId,
           final String position, final String alignedPosition)
   {
     // TODO: could try to highlight in all alignments if alf==null
     jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
-            ((AlignFrame) alf).getViewport().getAlignment()
+            alf.getViewport().getAlignment()
                     .getSequencesArray());
     final SequenceI sq = matcher.findIdMatch(sequenceId);
     if (sq != null)
@@ -971,7 +971,7 @@ public class JalviewAppLoader
       int apos = -1;
       try
       {
-        apos = new Integer(position).intValue();
+        apos = Integer.valueOf(position).intValue();
         apos--;
       } catch (NumberFormatException ex)
       {
@@ -1009,7 +1009,7 @@ public class JalviewAppLoader
     }
   }
 
-  public void selectIn(final AlignFrameI alf, String sequenceIds,
+  public void selectIn(final AlignFrame alf, String sequenceIds,
           String columns, String sep)
   {
     if (sep == null || sep.length() == 0)
@@ -1029,9 +1029,9 @@ public class JalviewAppLoader
     String[] cols = JalviewAppLoader.separatorListToArray(columns, sep);
     final SequenceGroup sel = new SequenceGroup();
     final ColumnSelection csel = new ColumnSelection();
-    AlignmentI al = ((AlignFrame) alf).getViewport().getAlignment();
+    AlignmentI al = alf.getViewport().getAlignment();
     jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
-            ((AlignFrame) alf).getViewport().getAlignment()
+            alf.getViewport().getAlignment()
                     .getSequencesArray());
     int start = 0, end = al.getWidth(), alw = al.getWidth();
     boolean seqsfound = true;
@@ -1069,7 +1069,7 @@ public class JalviewAppLoader
           int from = -1, to = -1;
           try
           {
-            from = new Integer(cl.substring(0, p)).intValue();
+            from = Integer.valueOf(cl.substring(0, p)).intValue();
             from--;
           } catch (NumberFormatException ex)
           {
@@ -1080,7 +1080,7 @@ public class JalviewAppLoader
           }
           try
           {
-            to = new Integer(cl.substring(p + 1)).intValue();
+            to = Integer.valueOf(cl.substring(p + 1)).intValue();
             to--;
           } catch (NumberFormatException ex)
           {
@@ -1140,7 +1140,7 @@ public class JalviewAppLoader
           int r = -1;
           try
           {
-            r = new Integer(cl).intValue();
+            r = Integer.valueOf(cl).intValue();
             r--;
           } catch (NumberFormatException ex)
           {
@@ -1216,16 +1216,16 @@ public class JalviewAppLoader
         @Override
         public void run()
         {
-          ((AlignFrame) alf).select(sel, csel, ((AlignFrame) alf)
+          alf.select(sel, csel, alf
                   .getCurrentView().getAlignment().getHiddenColumns());
         }
       });
     }
   }
 
-  public String getAlignmentOrderFrom(AlignFrameI alf, String sep)
+  public String getAlignmentOrderFrom(AlignFrame alf, String sep)
   {
-    AlignmentI alorder = ((AlignFrame) alf).getViewport().getAlignment();
+    AlignmentI alorder = alf.getViewport().getAlignment();
     String[] order = new String[alorder.getHeight()];
     for (int i = 0; i < order.length; i++)
     {
@@ -1234,12 +1234,12 @@ public class JalviewAppLoader
     return arrayToSeparatorList(order, sep);
   }
 
-  public String getSelectedSequencesAsAlignmentFrom(AlignFrameI alf,
+  public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
           String format, String suffix)
   {
     try
     {
-      AlignViewport vp = ((AlignFrame) alf).getViewport();
+      AlignViewport vp = alf.getViewport();
       FileFormatI theFormat = FileFormats.getInstance().forName(format);
       boolean seqlimits = (suffix == null
               || suffix.equalsIgnoreCase("true"));
@@ -1262,7 +1262,7 @@ public class JalviewAppLoader
     return "";
   }
 
-  public String orderAlignmentBy(AlignFrameI alf, String order,
+  public String orderAlignmentBy(AlignFrame alf, String order,
           String undoName, String sep)
   {
     if (sep == null || sep.length() == 0)
@@ -1274,7 +1274,7 @@ public class JalviewAppLoader
     if (ids != null && ids.length > 0)
     {
       jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher(
-              ((AlignFrame) alf).getViewport().getAlignment()
+              alf.getViewport().getAlignment()
                       .getSequencesArray());
       int s = 0;
       sqs = new SequenceI[ids.length];
@@ -1315,10 +1315,10 @@ public class JalviewAppLoader
     final String _undoName = undoName;
     // TODO: deal with synchronization here: cannot raise any events until after
     // this has returned.
-    return ((AlignFrame) alf).sortBy(aorder, _undoName) ? "true" : "";
+    return alf.sortBy(aorder, _undoName) ? "true" : "";
   }
 
-  public String getAlignmentFrom(AlignFrameI alf, String format,
+  public String getAlignmentFrom(AlignFrame alf, String format,
           String suffix)
   {
     try
@@ -1328,7 +1328,7 @@ public class JalviewAppLoader
 
       FileFormatI theFormat = FileFormats.getInstance().forName(format);
       String reply = new AppletFormatAdapter().formatSequences(theFormat,
-              ((AlignFrame) alf).getViewport().getAlignment(), seqlimits);
+              alf.getViewport().getAlignment(), seqlimits);
       return reply;
     } catch (IllegalArgumentException ex)
     {
@@ -1338,26 +1338,26 @@ public class JalviewAppLoader
     }
   }
 
-  public void loadAnnotationFrom(AlignFrameI alf, String annotation)
+  public void loadAnnotationFrom(AlignFrame alf, String annotation)
   {
     if (new AnnotationFile().annotateAlignmentView(
-            ((AlignFrame) alf).getViewport(), annotation,
+            alf.getViewport(), annotation,
             DataSourceType.PASTE))
     {
-      ((AlignFrame) alf).alignPanel.fontChanged();
-      ((AlignFrame) alf).alignPanel.setScrollValues(0, 0);
+      alf.alignPanel.fontChanged();
+      alf.alignPanel.setScrollValues(0, 0);
     }
     else
     {
-      ((AlignFrame) alf).parseFeaturesFile(annotation,
+      alf.parseFeaturesFile(annotation,
               DataSourceType.PASTE);
     }
   }
 
-  public boolean loadFeaturesFrom(AlignFrameI alf, String features,
+  public boolean loadFeaturesFrom(AlignFrame alf, String features,
           boolean autoenabledisplay)
   {
-    boolean ret = ((AlignFrame) alf).parseFeaturesFile(features,
+    boolean ret = alf.parseFeaturesFile(features,
             DataSourceType.PASTE);
     if (!ret)
     {
@@ -1365,16 +1365,16 @@ public class JalviewAppLoader
     }
     if (autoenabledisplay)
     {
-      ((AlignFrame) alf).getViewport().setShowSequenceFeatures(true);
+      alf.getViewport().setShowSequenceFeatures(true);
       // this next was for a checkbox in JalviewLite
       // ((AlignFrame) alf).getViewport().sequenceFeatures.setState(true);
     }
     return true;
   }
 
-  public String getFeaturesFrom(AlignFrameI alf, String format)
+  public String getFeaturesFrom(AlignFrame alf, String format)
   {
-    AlignFrame f = ((AlignFrame) alf);
+    AlignFrame f = (alf);
 
     String features;
     FeaturesFile formatter = new FeaturesFile();
@@ -1399,25 +1399,25 @@ public class JalviewAppLoader
 
   }
 
-  public String getAnnotationFrom(AlignFrameI alf)
+  public String getAnnotationFrom(AlignFrame alf)
   {
-    AlignFrame f = (AlignFrame) alf;
+    AlignFrame f = alf;
     String annotation = new AnnotationFile()
             .printAnnotationsForView(f.getViewport());
     return annotation;
   }
 
-  public AlignFrameI newViewFrom(AlignFrameI alf, String name)
-  {
-    return (AlignFrameI) ((AlignFrame) alf).newView(name, true);
-  }
-
+  // public AlignFrame newViewFrom(AlignFrame alf, String name)
+  // {
+  // return (AlignFrame) alf.newView(name, true);
+  // }
+  //
   public String[] separatorListToArray(String list)
   {
     return separatorListToArray(list, separator);
   }
 
-  public Object[] getSelectionForListener(AlignFrameI currentFrame,
+  public Object[] getSelectionForListener(AlignFrame currentFrame,
           SequenceGroup seqsel, ColumnSelection colsel,
           HiddenColumns hidden, SelectionSource source, Object alignFrame)
   {
@@ -1428,10 +1428,10 @@ public class JalviewAppLoader
     if (source != null)
     {
       if (source instanceof AlignViewport
-              && ((AlignFrame) currentFrame).getViewport() == source)
+              && currentFrame.getViewport() == source)
       {
         // should be valid if it just generated an event!
-        src = (AlignFrame) currentFrame;
+        src = currentFrame;
 
       }
     }