1 11 package org.eclipse.ui.internal; 12 13 import java.util.Iterator ; 14 15 import org.eclipse.jface.util.Geometry; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.graphics.Color; 18 import org.eclipse.swt.graphics.Rectangle; 19 import org.eclipse.swt.graphics.Region; 20 import org.eclipse.swt.widgets.Display; 21 import org.eclipse.swt.widgets.Shell; 22 23 30 public class LegacyAnimationFeedback extends RectangleAnimationFeedbackBase { 31 private static final int LINE_WIDTH = 1; 32 33 private Display display; 34 private Region shellRegion; 35 36 private Shell theShell; 37 38 public LegacyAnimationFeedback(Shell parentShell, Rectangle start, 39 Rectangle end) { 40 super(parentShell, start, end); 41 } 42 43 public void renderStep(AnimationEngine engine) { 44 if (shellRegion != null) { 45 shellRegion.dispose(); 46 shellRegion = new Region(display); 47 } 48 49 Iterator currentRects = getCurrentRects(engine.amount()).iterator(); 51 while (currentRects.hasNext()) { 52 Rectangle curRect = (Rectangle) currentRects.next(); 53 Rectangle rect = Geometry.toControl(theShell, curRect); 54 shellRegion.add(rect); 55 rect.x += LINE_WIDTH; 56 rect.y += LINE_WIDTH; 57 rect.width = Math.max(0, rect.width - 2 * LINE_WIDTH); 58 rect.height = Math.max(0, rect.height - 2 * LINE_WIDTH); 59 60 shellRegion.subtract(rect); 61 } 62 63 theShell.setRegion(shellRegion); 64 65 display.update(); 66 } 67 68 71 public void initialize(AnimationEngine engine) { 72 73 theShell = new Shell(getAnimationShell(), SWT.NO_TRIM | SWT.ON_TOP); 74 display = theShell.getDisplay(); 75 Color color = display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW); 76 theShell.setBackground(color); 77 78 shellRegion = new Region(display); 80 theShell.setRegion(shellRegion); 81 } 82 83 86 public void dispose() { 87 theShell.setVisible(false); 88 theShell.dispose(); 89 shellRegion.dispose(); 90 } 91 92 96 public boolean jobInit(AnimationEngine engine) { 97 if (!super.jobInit(engine)) 98 return false; 99 100 Rectangle shellBounds = Geometry.copy((Rectangle) getStartRects() 102 .get(0)); 103 Iterator startIter = getStartRects().iterator(); 104 Iterator endIter = getEndRects().iterator(); 105 while (startIter.hasNext()) { 106 shellBounds.add((Rectangle) startIter.next()); 107 shellBounds.add((Rectangle) endIter.next()); 108 } 109 theShell.setBounds(shellBounds); 110 theShell.setVisible(true); 113 114 return true; } 116 117 } 118 | Popular Tags |