From: kiramt Date: Wed, 28 Jun 2017 11:45:50 +0000 (+0100) Subject: JAL-2600 updates following review X-Git-Tag: Release_2_10_3b1~183^2^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a41b74d63832baaf00daac0a176118dc751c3b24;p=jalview.git JAL-2600 updates following review --- diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index c658811..39b718d 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -30,6 +30,7 @@ import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.Color; import java.awt.Dimension; @@ -118,13 +119,15 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, // ap.annotationScroller.getVAdjustable().addAdjustmentListener( this ); renderer = new AnnotationRenderer(); + + av.getRanges().addPropertyChangeListener(this); } public AnnotationPanel(AlignViewport av) { this.av = av; renderer = new AnnotationRenderer(); - av.getRanges().addPropertyChangeListener(this); + } @Override @@ -758,8 +761,12 @@ public class AnnotationPanel extends Panel implements AwtRenderPanelI, public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport range changes (e.g. alignment panel was scrolled) - if (evt.getPropertyName().equals("startres") - || evt.getPropertyName().equals("endres")) + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTRES)) { fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 74bbcf5..5313b41 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -402,8 +402,12 @@ public class IdCanvas extends Panel implements ViewportListenerI public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport range changes (e.g. alignment panel was scrolled) - if (evt.getPropertyName().equals("startseq") - || evt.getPropertyName().equals("endseq")) + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTSEQ)) { fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } diff --git a/src/jalview/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 2abd65a..1737c01 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -27,6 +27,7 @@ import jalview.renderer.ScaleRenderer; import jalview.renderer.ScaleRenderer.ScaleMark; import jalview.util.MessageManager; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.Color; import java.awt.FontMetrics; @@ -464,7 +465,16 @@ public class ScalePanel extends Panel implements MouseMotionListener, public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport change events (e.g. alignment panel was scrolled) - repaint(); + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTRES)) + { + // scroll event, repaint panel + repaint(); + } } } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index da54ecf..469dec9 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -873,15 +873,17 @@ public class SeqCanvas extends Panel implements ViewportListenerI @Override public void propertyChange(PropertyChangeEvent evt) { + String eventName = evt.getPropertyName(); + if (!av.getWrapAlignment()) { - if (evt.getPropertyName().equals("startres") - || evt.getPropertyName().equals("endres")) + int scrollX = 0; + if (eventName.equals(ViewportRanges.STARTRES)) { // Make sure we're not trying to draw a panel // larger than the visible window ViewportRanges vpRanges = av.getRanges(); - int scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); + scrollX = (int) evt.getNewValue() - (int) evt.getOldValue(); if (scrollX > vpRanges.getEndRes() - vpRanges.getStartRes()) { scrollX = vpRanges.getEndRes() - vpRanges.getStartRes(); @@ -890,15 +892,24 @@ public class SeqCanvas extends Panel implements ViewportListenerI { scrollX = vpRanges.getStartRes() - vpRanges.getEndRes(); } + } + + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (eventName.equals(ViewportRanges.STARTRES)) + { + // scroll - startres and endres both change fastPaint(scrollX, 0); } - else if (evt.getPropertyName().equals("startseq") - || evt.getPropertyName().equals("endseq")) + else if (eventName.equals(ViewportRanges.STARTSEQ)) { + // scroll fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); } } - } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 1ba04b4..61099c3 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -31,6 +31,7 @@ import jalview.schemes.ResidueProperties; import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.AlphaComposite; import java.awt.Color; @@ -1170,13 +1171,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport range changes (e.g. alignment panel was scrolled) - if (evt.getPropertyName().equals("startres")) + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTRES)) { fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } - else if (evt.getPropertyName().equals("endres")) - { - // resize - do nothing - } } } diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index a8f3b24..4642741 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -524,13 +524,14 @@ public class IdCanvas extends JPanel implements ViewportListenerI public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport range changes (e.g. alignment panel was scrolled) - if (evt.getPropertyName().equals("startseq")) + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTSEQ)) { fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } - else if (evt.getPropertyName().equals("endseq")) - { - // resize - do nothing - } } } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 800dc19..e5f2be8 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -29,6 +29,7 @@ import jalview.renderer.ScaleRenderer.ScaleMark; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.Color; import java.awt.FontMetrics; @@ -546,7 +547,12 @@ public class ScalePanel extends JPanel implements MouseMotionListener, public void propertyChange(PropertyChangeEvent evt) { // Respond to viewport change events (e.g. alignment panel was scrolled) - if (evt.getPropertyName().equals("startres")) + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (evt.getPropertyName().equals(ViewportRanges.STARTRES)) { // scroll event, repaint panel repaint(); diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 690d2b1..d8b3f2a 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -988,11 +988,12 @@ public class SeqCanvas extends JComponent implements ViewportListenerI @Override public void propertyChange(PropertyChangeEvent evt) { + String eventName = evt.getPropertyName(); + if (!av.getWrapAlignment()) { int scrollX = 0; - if ((evt.getPropertyName().equals("startres")) - || (evt.getPropertyName().equals("endres"))) + if (eventName.equals(ViewportRanges.STARTRES)) { // Make sure we're not trying to draw a panel // larger than the visible window @@ -1008,24 +1009,21 @@ public class SeqCanvas extends JComponent implements ViewportListenerI } } - if (evt.getPropertyName().equals("startres")) + // Both scrolling and resizing change viewport ranges: scrolling changes + // both start and end points, but resize only changes end values. + // Here we only want to fastpaint on a scroll, with resize using a normal + // paint, so scroll events are identified as changes to the horizontal or + // vertical start value. + if (eventName.equals(ViewportRanges.STARTRES)) { // scroll - startres and endres both change fastPaint(scrollX, 0); } - else if (evt.getPropertyName().equals("endres")) - { - // resize - only endres changes - do nothing - } - else if (evt.getPropertyName().equals("startseq")) + else if (eventName.equals(ViewportRanges.STARTSEQ)) { // scroll fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); } - else if (evt.getPropertyName().equals("endseq")) - { - // resize - do nothing - } } } } diff --git a/src/jalview/viewmodel/ViewportRanges.java b/src/jalview/viewmodel/ViewportRanges.java index 4eb8c95..c2bcf3f 100644 --- a/src/jalview/viewmodel/ViewportRanges.java +++ b/src/jalview/viewmodel/ViewportRanges.java @@ -32,6 +32,14 @@ import jalview.datamodel.HiddenColumns; */ public class ViewportRanges extends ViewportProperties { + public static final String STARTRES = "startres"; + + public static final String ENDRES = "endres"; + + public static final String STARTSEQ = "startseq"; + + public static final String ENDSEQ = "endseq"; + // start residue of viewport private int startRes; @@ -148,12 +156,12 @@ public class ViewportRanges extends ViewportProperties endRes = end; } - changeSupport.firePropertyChange("startres", oldstartres, startRes); + changeSupport.firePropertyChange(STARTRES, oldstartres, startRes); if (oldstartres == startRes) { // event won't be fired if start positions are same // fire an event for the end positions in case they changed - changeSupport.firePropertyChange("endres", oldendres, endRes); + changeSupport.firePropertyChange(ENDRES, oldendres, endRes); } } @@ -233,12 +241,12 @@ public class ViewportRanges extends ViewportProperties endSeq = end; } - changeSupport.firePropertyChange("startseq", oldstartseq, startSeq); + changeSupport.firePropertyChange(STARTSEQ, oldstartseq, startSeq); if (oldstartseq == startSeq) { // event won't be fired if start positions are the same // fire in case the end positions changed - changeSupport.firePropertyChange("endseq", oldendseq, endSeq); + changeSupport.firePropertyChange(ENDSEQ, oldendseq, endSeq); } }