From f8c699730f0692531c9401733e494a5bd14fa979 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Mon, 27 Mar 2023 17:34:06 +0200 Subject: [PATCH] JAL-4155 Replace unsafe casting to AlignmentPanel with generics --- src/jalview/appletgui/AlignViewport.java | 2 +- src/jalview/gui/AlignViewport.java | 17 ++--------------- src/jalview/viewmodel/AlignmentViewport.java | 18 +++++++++++------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index d64cd75..c5d8abf 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 944bb6b..4b4e82a 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -79,7 +79,7 @@ import jalview.ws.params.AutoCalcSetting; * @author $author$ * @version $Revision: 1.141 $ */ -public class AlignViewport extends AlignmentViewport +public class AlignViewport extends AlignmentViewport implements SelectionSource { Font font; @@ -524,7 +524,6 @@ public class AlignViewport extends AlignmentViewport new HiddenColumns(getAlignment().getHiddenColumns()), this); } - public boolean getSortByTree() { @@ -535,19 +534,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 4f68cb5..8973124 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -83,8 +83,10 @@ import jalview.workers.StrucConsensusThread; * * @author jimp * + * @param + * implementation of the AlignmentViewPanel used by the class */ -public abstract class AlignmentViewport +public abstract class AlignmentViewport implements AlignViewportI, CommandListener, VamsasSource { protected ViewportRanges ranges; @@ -119,24 +121,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) -- 1.7.10.2