|
1 /******************************************************************************* |
|
2 * Copyright (c) 2004, 2008 Tasktop Technologies and others. |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Tasktop Technologies - initial API and implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 package com.nokia.carbide.remoteconnections.internal.ui.mylyn; |
|
13 |
|
14 import org.eclipse.jface.resource.CompositeImageDescriptor; |
|
15 import org.eclipse.jface.resource.ImageDescriptor; |
|
16 import org.eclipse.swt.graphics.ImageData; |
|
17 import org.eclipse.swt.graphics.Point; |
|
18 |
|
19 /** |
|
20 * @author Mik Kersten |
|
21 */ |
|
22 public class CompositeSyncImageDescriptor extends CompositeImageDescriptor { |
|
23 |
|
24 private final ImageData base; |
|
25 |
|
26 private final ImageData background; |
|
27 |
|
28 private final boolean fillBackground; |
|
29 |
|
30 protected Point size; |
|
31 |
|
32 static int WIDTH; |
|
33 |
|
34 public CompositeSyncImageDescriptor(ImageDescriptor icon, boolean fillBackground) { |
|
35 this.base = getImageData(icon); |
|
36 this.background = getImageData(CommonImages.OVERLAY_WHITE); |
|
37 this.size = new Point(background.width, background.height); |
|
38 this.fillBackground = fillBackground; |
|
39 } |
|
40 |
|
41 @Override |
|
42 protected void drawCompositeImage(int width, int height) { |
|
43 if (fillBackground) { |
|
44 drawImage(background, 0, 0); |
|
45 } |
|
46 drawImage(base, 3, 2); |
|
47 } |
|
48 |
|
49 private ImageData getImageData(ImageDescriptor descriptor) { |
|
50 ImageData data = descriptor.getImageData(); |
|
51 // see bug 51965: getImageData can return null |
|
52 if (data == null) { |
|
53 data = DEFAULT_IMAGE_DATA; |
|
54 } |
|
55 return data; |
|
56 } |
|
57 |
|
58 @Override |
|
59 protected Point getSize() { |
|
60 return new Point(size.x, size.y); |
|
61 } |
|
62 } |