From: Jim Procter Date: Fri, 14 Sep 2018 11:04:52 +0000 (+0100) Subject: JAL-345 refactor list of sequences that are highlighted from Id Canvas to Alignment... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=36cb7e0a22de94370c4397d1d7feffcfe72a88fc;p=jalview.git JAL-345 refactor list of sequences that are highlighted from Id Canvas to Alignment Viewport --- diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 931eba6..aa98680 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -490,4 +490,8 @@ public interface AlignViewportI extends ViewStyleI public abstract TreeModel getCurrentTree(); public abstract void setCurrentTree(TreeModel tree); + + void setHighlightedSeqs(List list); + + List getHighlightedSeqs(); } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 94b38ed..0fdc9f0 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2431,7 +2431,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, viewport.setSelectionGroup(null); viewport.getColumnSelection().clear(); viewport.setSelectionGroup(null); - alignPanel.getIdPanel().getIdCanvas().searchResults = null; + viewport.setHighlightedSeqs(null); // JAL-2034 - should delegate to // alignPanel to decide if overview needs // updating. diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index cf88c90..b886552 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -61,8 +61,6 @@ public class IdCanvas extends JPanel implements ViewportListenerI boolean fastPaint = false; - List searchResults; - AnnotationPanel ap; private Font idfont; @@ -103,7 +101,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI int xPos = 0; int panelWidth = getWidth(); int charHeight = av.getCharHeight(); - + List searchResults = av.getHighlightedSeqs(); if ((searchResults != null) && searchResults.contains(s)) { g.setColor(Color.black); @@ -163,6 +161,7 @@ public class IdCanvas extends JPanel implements ViewportListenerI } ViewportRanges ranges = av.getRanges(); + List searchResults = av.getHighlightedSeqs(); gg.copyArea(0, 0, getWidth(), imgHeight, 0, -vertical * av.getCharHeight()); @@ -252,7 +251,8 @@ public class IdCanvas extends JPanel implements ViewportListenerI gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); - drawIds(gg, av, av.getRanges().getStartSeq(), av.getRanges().getEndSeq(), searchResults); + drawIds(gg, av, av.getRanges().getStartSeq(), + av.getRanges().getEndSeq(), av.getHighlightedSeqs()); g.drawImage(image, 0, 0, this); } @@ -544,18 +544,6 @@ public class IdCanvas extends JPanel implements ViewportListenerI return getIdfont(); } - /** - * DOCUMENT ME! - * - * @param list - * DOCUMENT ME! - */ - public void setHighlighted(List list) - { - searchResults = list; - repaint(); - } - public Font getIdfont() { return idfont; diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index a183144..3c7e06f 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -430,10 +430,11 @@ public class IdPanel extends JPanel */ public void highlightSearchResults(List list) { - getIdCanvas().setHighlighted(list); + av.setHighlightedSeqs(list); if (list == null) { + idCanvas.repaint(); return; } @@ -445,6 +446,11 @@ public class IdPanel extends JPanel { av.getRanges().setStartSeq(index); } + else + { + // just repaint + idCanvas.repaint(); + } } public IdCanvas getIdCanvas() diff --git a/src/jalview/gui/RedundancyPanel.java b/src/jalview/gui/RedundancyPanel.java index c4390c0..916ffeb 100755 --- a/src/jalview/gui/RedundancyPanel.java +++ b/src/jalview/gui/RedundancyPanel.java @@ -110,7 +110,8 @@ public class RedundancyPanel extends GSliderPanel implements Runnable @Override public void internalFrameClosing(InternalFrameEvent evt) { - ap.getIdPanel().getIdCanvas().setHighlighted(null); + ap.av.setHighlightedSeqs(null); + ap.getIdPanel().getIdCanvas().repaint(); } }); @@ -202,7 +203,8 @@ public class RedundancyPanel extends GSliderPanel implements Runnable redundantSequences.add(originalSequences[i]); } } - ap.getIdPanel().getIdCanvas().setHighlighted(redundantSequences); + ap.av.setHighlightedSeqs(redundantSequences); + ap.getIdPanel().getIdCanvas().repaint(); } /** diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 1366ada..ea6c6f8 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -2954,4 +2954,25 @@ public abstract class AlignmentViewport { return currentTree; } + + List highlightedSeqs = null; + + /** + * Highlight the IDs for the given sequences call alignPanel.repaint() to + * update view after setting. + * + * @param list + * List + */ + @Override + public void setHighlightedSeqs(List list) + { + highlightedSeqs = list; + } + + @Override + public List getHighlightedSeqs() + { + return highlightedSeqs; + } }