JAL-4155 Replace unsafe casting to AlignmentPanel with generics
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 2b4074e..bdf5327 100644 (file)
@@ -84,8 +84,10 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
  * 
  * @author jimp
  * 
+ * @param <AlignmentPanelT>
+ *          implementation of the AlignmentViewPanel used by the class
  */
-public abstract class AlignmentViewport
+public abstract class AlignmentViewport<AlignmentPanelT extends AlignmentViewPanel>
         implements AlignViewportI, CommandListener, VamsasSource
 {
   public static final String PROPERTY_ALIGNMENT = "alignment";
@@ -138,24 +140,26 @@ public abstract class AlignmentViewport
     ranges = new ViewportRanges(al);
   }
 
-  protected AlignmentViewPanel alignPanel=null;
-  public void setAlignPanel(AlignmentViewPanel ap)
+  protected AlignmentPanelT alignPanel = null;
+
+  public void setAlignPanel(AlignmentPanelT ap)
   {
     alignPanel = ap;
   }
+
   /**
-   * return the AlignmentViewPanel containing the given viewport. Use this to get the
-   * components currently handling the given viewport.
+   * return the AlignmentViewPanel containing the given viewport. Use this to
+   * get the components currently handling the given viewport.
    * 
    * @param av
    * @return null or an alignPanel guaranteed to have non-null alignFrame
    *         reference
    */
-  
-  public AlignmentViewPanel getAlignPanel()
+  public AlignmentPanelT getAlignPanel()
   {
     return alignPanel;
   }
+
   /**
    * @param name
    * @see jalview.api.ViewStyleI#setFontName(java.lang.String)