From 14033157f9235c071763ae61cb8d2785b07ec96f Mon Sep 17 00:00:00 2001 From: kiramt Date: Fri, 12 May 2017 13:43:16 +0100 Subject: [PATCH] JAL-2491 Renamed comp scrolling flag for consistency; small tweaks --- src/jalview/appletgui/AlignViewport.java | 4 ++-- src/jalview/appletgui/AlignmentPanel.java | 22 +++++++++---------- src/jalview/appletgui/OverviewPanel.java | 2 +- src/jalview/appletgui/SeqPanel.java | 4 ++-- src/jalview/gui/AlignViewport.java | 4 ++-- src/jalview/gui/AlignmentPanel.java | 29 ++++++++++++++++--------- src/jalview/gui/OverviewPanel.java | 5 +++-- src/jalview/gui/SeqCanvas.java | 2 +- src/jalview/gui/SeqPanel.java | 4 ++-- src/jalview/viewmodel/OverviewDimensions.java | 10 +++++---- 10 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 13332d3..f17703a 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -438,9 +438,9 @@ public class AlignViewport extends AlignmentViewport implements int seqOffset = findComplementScrollTarget(sr); if (!sr.isEmpty()) { - complementPanel.setFollowingComplementScroll(false); + complementPanel.setToScrollComplementPanel(false); complementPanel.scrollToCentre(sr, seqOffset); - complementPanel.setFollowingComplementScroll(true); + complementPanel.setToScrollComplementPanel(true); } } diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 4ecf05f..c3458f9 100644 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -779,7 +779,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, } vpRanges.setViewportStartAndWidth(x, width); - if (av.getWrapAlignment() || !fastPaint || av.MAC) + if (av.getWrapAlignment() || !fastPaint) { repaint(); } @@ -823,7 +823,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, } vpRanges.setViewportStartAndHeight(offy, height); } - if (av.getWrapAlignment() || !fastPaint || av.MAC) + if (av.getWrapAlignment() || !fastPaint) { repaint(); } @@ -1022,9 +1022,9 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, /* * Flag set while scrolling to follow complementary cDNA/protein scroll. When - * true, suppresses invoking the same method recursively. + * false, suppresses invoking the same method recursively. */ - private boolean followingComplementScroll = true; + private boolean scrollComplementaryPanel = true; private void jbInit() throws Exception { @@ -1133,14 +1133,14 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, * * @param b */ - protected void setFollowingComplementScroll(boolean b) + protected void setToScrollComplementPanel(boolean b) { - this.followingComplementScroll = b; + this.scrollComplementaryPanel = b; } - protected boolean isFollowingComplementScroll() + protected boolean isSetToScrollComplementPanel() { - return this.followingComplementScroll; + return this.scrollComplementaryPanel; } @Override @@ -1157,11 +1157,11 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, // now update any complementary alignment (its viewport ranges object // is different so does not get automatically updated) - if (isFollowingComplementScroll()) + if (isSetToScrollComplementPanel()) { - setFollowingComplementScroll(false); + setToScrollComplementPanel(false); av.scrollComplementaryAlignment(getComplementPanel()); - setFollowingComplementScroll(true); + setToScrollComplementPanel(true); } } diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 786e9c2..0f37544 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -151,7 +151,7 @@ public class OverviewPanel extends Panel implements Runnable, od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment() .getHiddenSequences(), av.getColumnSelection(), av .getRanges()); - ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); + // ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); ap.paintAlignment(false); } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 347cceb..76f1275 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -744,12 +744,12 @@ public class SeqPanel extends Panel implements MouseMotionListener, // panel,as this sets up a feedback loop (scrolling panel 1 causes moused // over residue to change abruptly, causing highlighted residue in panel 2 // to change, causing a scroll in panel 1 etc) - ap.setFollowingComplementScroll(false); + ap.setToScrollComplementPanel(false); if (ap.scrollToPosition(results, true)) { ap.alignFrame.repaint(); } - ap.setFollowingComplementScroll(true); + ap.setToScrollComplementPanel(true); } setStatusMessage(results); seqCanvas.highlightSearchResults(results); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 5653340..e2cff80 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1047,9 +1047,9 @@ public class AlignViewport extends AlignmentViewport implements // TODO would like next line without cast but needs more refactoring... final AlignmentPanel complementPanel = ((AlignViewport) getCodingComplement()) .getAlignPanel(); - complementPanel.setDontScrollComplement(true); + complementPanel.setToScrollComplementPanel(false); complementPanel.scrollToCentre(sr, verticalOffset); - complementPanel.setDontScrollComplement(false); + complementPanel.setToScrollComplementPanel(true); } } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 673c008..769dc86 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -104,9 +104,9 @@ public class AlignmentPanel extends GAlignmentPanel implements /* * Flag set while scrolling to follow complementary cDNA/protein scroll. When - * true, suppresses invoking the same method recursively. + * false, suppresses invoking the same method recursively. */ - private boolean dontScrollComplement = false; + private boolean scrollComplementaryPanel = true; private PropertyChangeListener propertyChangeListener; @@ -769,7 +769,16 @@ public class AlignmentPanel extends GAlignmentPanel implements @Override public void run() { - setScrollValues(vpRanges.getStartRes(), vpRanges.getStartSeq()); + // When updating scrolling to use ViewportChange events, this code + // could not be validated and it is not clear if it is now being + // called. Log warning here in case it is called and unforeseen + // problems occur + Cache.log + .warn("Unexpected path through code: Wrapped jar file opened with wrap alignment set in preferences"); + + // scroll to start of panel + vpRanges.setStartRes(0); + vpRanges.setStartSeq(0); } }); } @@ -1827,14 +1836,14 @@ public class AlignmentPanel extends GAlignmentPanel implements * * @param b */ - protected void setDontScrollComplement(boolean b) + protected void setToScrollComplementPanel(boolean b) { - this.dontScrollComplement = b; + this.scrollComplementaryPanel = b; } - protected boolean isDontScrollComplement() + protected boolean isSetToScrollComplementPanel() { - return this.dontScrollComplement; + return this.scrollComplementaryPanel; } /** @@ -1873,11 +1882,11 @@ public class AlignmentPanel extends GAlignmentPanel implements // now update any complementary alignment (its viewport ranges object // is different so does not get automatically updated) - if (!isDontScrollComplement()) + if (isSetToScrollComplementPanel()) { - setDontScrollComplement(true); + setToScrollComplementPanel(false); av.scrollComplementaryAlignment(); - setDontScrollComplement(false); + setToScrollComplementPanel(true); } } } diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index da2cdbb..1b047a3 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -124,7 +124,7 @@ public class OverviewPanel extends JPanel implements Runnable, .getColumnSelection(), av.getRanges()); // TODO set via ViewportRanges in overview dimensions once JAL-2388 is // merged - ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); + // ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); } } }); @@ -141,7 +141,8 @@ public class OverviewPanel extends JPanel implements Runnable, .getColumnSelection(), av.getRanges()); // TODO set via ViewportRanges in overview dimensions once JAL-2388 is // merged - ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); + + // ap.setScrollValues(od.getScrollCol(), od.getScrollRow()); } } }); diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index cd69bdc..26f8e9e 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -982,7 +982,7 @@ public class SeqCanvas extends JComponent implements ViewportListenerI @Override public void propertyChange(PropertyChangeEvent evt) { - if (av.getWrapAlignment()) + if (!av.getWrapAlignment()) { if (evt.getPropertyName().equals("startres") || evt.getPropertyName().equals("endres")) diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index ef2f782..ca79342 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -668,12 +668,12 @@ public class SeqPanel extends JPanel implements MouseListener, // panel,as this sets up a feedback loop (scrolling panel 1 causes moused // over residue to change abruptly, causing highlighted residue in panel 2 // to change, causing a scroll in panel 1 etc) - ap.setDontScrollComplement(true); + ap.setToScrollComplementPanel(false); if (ap.scrollToPosition(results, false)) { seqCanvas.revalidate(); } - ap.setDontScrollComplement(false); + ap.setToScrollComplementPanel(true); } setStatusMessage(results); seqCanvas.highlightSearchResults(results); diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 56060ab..e4c24e1 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -217,9 +217,11 @@ public class OverviewDimensions } // update scroll values - scrollCol = visXAsRes; - scrollRow = visYAsRes; + // scrollCol = visXAsRes; + // scrollRow = visYAsRes; + ranges.setStartRes(visXAsRes); + ranges.setStartSeq(visYAsRes); } /** @@ -274,7 +276,7 @@ public class OverviewDimensions g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } - public int getScrollCol() + /*public int getScrollCol() { return scrollCol; } @@ -282,7 +284,7 @@ public class OverviewDimensions public int getScrollRow() { return scrollRow; - } + }*/ // TODO should be removed, when unit test has mock Graphics object available // to check boxX/boxY -- 1.7.10.2