Index: src/org/eclipse/draw2d/parts/Thumbnail.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/parts/Thumbnail.java,v retrieving revision 1.31 diff -u -r1.31 Thumbnail.java --- src/org/eclipse/draw2d/parts/Thumbnail.java 18 Apr 2006 18:08:55 -0000 1.31 +++ src/org/eclipse/draw2d/parts/Thumbnail.java 27 Jan 2009 21:36:58 -0000 @@ -26,6 +26,7 @@ import org.eclipse.draw2d.ScaledGraphics; import org.eclipse.draw2d.UpdateListener; import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; /** @@ -39,7 +40,11 @@ extends Figure implements UpdateListener { - + /** + * keeps track of the location of the source Rectangle. It is used so that + * the Thumbnail is only redrawn on an actual change not on a scroll + */ + private Point oldSourceRectLoc = null; /** * This updates the Thumbnail by breaking the thumbnail {@link Image} into * several tiles and updating each tile individually. @@ -229,7 +234,12 @@ sourceFigure.isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.NONE); thumbnailGraphics = new ScaledGraphics(new SWTGraphics(thumbnailGC)); thumbnailGraphics.scale(getScaleX()); - thumbnailGraphics.translate(getSourceRectangle().getLocation().negate()); + + /** + * this value is used to check whether the figure has been scrolled + */ + oldSourceRectLoc = getSourceRectangle().getLocation(); + thumbnailGraphics.translate(oldSourceRectLoc.negate()); Color color = sourceFigure.getForegroundColor(); if (color != null) @@ -433,18 +443,29 @@ * @see org.eclipse.draw2d.UpdateListener#notifyPainting(Rectangle, Map) */ public void notifyPainting(Rectangle damage, Map dirtyRegions) { - Iterator dirtyFigures = dirtyRegions.keySet().iterator(); - while (dirtyFigures.hasNext()) { - IFigure current = (IFigure)dirtyFigures.next(); - while (current != null) { - if (current == getSource()) { - setDirty(true); - repaint(); - return; + /** + * The method first checks to see whether the Figure is being moved. + * If it is, it updates the stored location of the Figure. If notifyPainting + * has been called for a reason other than a scroll movement, it repaints + */ + Point sourceRectLoc = getSourceRectangle().getLocation(); + if (oldSourceRectLoc==null||oldSourceRectLoc.equals(sourceRectLoc)) + { + Iterator dirtyFigures = dirtyRegions.keySet().iterator(); + while (dirtyFigures.hasNext()) { + IFigure current = (IFigure)dirtyFigures.next(); + while (current != null) { + if (current == getSource()) { + setDirty(true); + repaint(); + return; + } + current = current.getParent(); } - current = current.getParent(); } } + else + oldSourceRectLoc = sourceRectLoc; } /**