1 11 package org.eclipse.compare.internal; 12 13 import org.eclipse.swt.graphics.*; 14 15 import org.eclipse.jface.resource.CompositeImageDescriptor; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 18 21 public class DiffImage extends CompositeImageDescriptor { 22 23 static final int HEIGHT= 16; 24 25 private Image fBaseImage; 26 private ImageDescriptor fOverlayImage; 27 private int fWidth; 28 private boolean fLeft= true; 29 30 public DiffImage(Image base, ImageDescriptor overlay, int w) { 31 fBaseImage= base; 32 fOverlayImage= overlay; 33 fWidth= w; 34 } 35 36 public DiffImage(Image base, ImageDescriptor overlay, int w, boolean onLeft) { 37 fBaseImage= base; 38 fOverlayImage= overlay; 39 fWidth= w; 40 fLeft= onLeft; 41 } 42 43 protected Point getSize() { 44 return new Point(fWidth, HEIGHT); 45 } 46 47 protected void drawCompositeImage(int width, int height) { 48 if (fLeft) { 49 if (fBaseImage != null) { 50 ImageData base= fBaseImage.getImageData(); 51 if (base == null) 52 base= DEFAULT_IMAGE_DATA; 53 drawImage(base, fWidth - base.width, 0); 54 } 55 56 if (fOverlayImage != null) { 57 ImageData overlay= fOverlayImage.getImageData(); 58 if (overlay == null) 59 overlay= DEFAULT_IMAGE_DATA; 60 drawImage(overlay, 0, (HEIGHT - overlay.height) / 2); 61 } 62 } else { 63 if (fBaseImage != null) { 64 ImageData base= fBaseImage.getImageData(); 65 if (base == null) 66 base= DEFAULT_IMAGE_DATA; 67 drawImage(base, 0, 0); 68 } 69 70 if (fOverlayImage != null) { 71 ImageData overlay= fOverlayImage.getImageData(); 72 if (overlay == null) 73 overlay= DEFAULT_IMAGE_DATA; 74 drawImage(overlay, fWidth - overlay.width, (HEIGHT - overlay.height) / 2); 75 } 76 } 77 } 78 } 79 | Popular Tags |