From: Mateusz Warowny Date: Mon, 27 Mar 2023 15:34:06 +0000 (+0200) Subject: JAL-4155 Replace unsafe casting to AlignmentPanel with generics X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7badfcf8cf7f860f0a652619fd49ac2453a45438;p=jalview.git JAL-4155 Replace unsafe casting to AlignmentPanel with generics --- diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 7369c3c..b42e15c 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -41,7 +41,7 @@ import jalview.viewmodel.AlignmentViewport; import java.awt.Font; import java.awt.FontMetrics; -public class AlignViewport extends AlignmentViewport +public class AlignViewport extends AlignmentViewport implements SelectionSource { boolean cursorMode = false; diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 79a16ba..04618af 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -72,7 +72,7 @@ import javax.swing.JInternalFrame; * @author $author$ * @version $Revision: 1.141 $ */ -public class AlignViewport extends AlignmentViewport +public class AlignViewport extends AlignmentViewport implements SelectionSource { public final static int NO_SPLIT = 0; @@ -528,7 +528,6 @@ public class AlignViewport extends AlignmentViewport new HiddenColumns(getAlignment().getHiddenColumns()), this); } - public boolean getSortByTree() { @@ -539,19 +538,7 @@ public class AlignViewport extends AlignmentViewport { sortByTree = sort; } - /** - * return the alignPanel 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 AlignmentPanel getAlignPanel() - { - return (AlignmentPanel) alignPanel; - } + /** * Returns the (Desktop) instance of the StructureSelectionManager */ diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 2b4074e..bdf5327 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -84,8 +84,10 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; * * @author jimp * + * @param + * implementation of the AlignmentViewPanel used by the class */ -public abstract class AlignmentViewport +public abstract class AlignmentViewport 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)