Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2003-09-10 14:40:42 -0400
committerJean Michel-Lemieux2003-09-10 14:40:42 -0400
commitba7e4312188694331aed1085e3a91433f5467361 (patch)
treee00751a55ff19763f1d314b01ecf02c8cdd559a5
parenta79cf367092adf84a9bd0f0d4496c40d805e5c10 (diff)
downloadeclipse.platform.team-ba7e4312188694331aed1085e3a91433f5467361.tar.gz
eclipse.platform.team-ba7e4312188694331aed1085e3a91433f5467361.tar.xz
eclipse.platform.team-ba7e4312188694331aed1085e3a91433f5467361.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java99
1 files changed, 99 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java
new file mode 100644
index 000000000..801bd250e
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ui;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * An OverlayIcon consists of a main icon and several adornments.
+ */
+public class OverlayIcon extends CompositeImageDescriptor {
+ // the base image
+ private Image base;
+ // the overlay images
+ private ImageDescriptor[] overlays;
+ // the size
+ private Point size;
+ // the locations
+ private int[] locations;
+
+ public static final int TOP_LEFT = 0;
+ public static final int TOP_RIGHT = 1;
+ public static final int BOTTOM_LEFT = 2;
+ public static final int BOTTOM_RIGHT = 3;
+
+ /**
+ * OverlayIcon constructor.
+ *
+ * @param base the base image
+ * @param overlays the overlay images
+ * @param locations the location of each image
+ * @param size the size
+ */
+ public OverlayIcon(Image base, ImageDescriptor[] overlays, int[] locations, Point size) {
+ this.base = base;
+ this.overlays = overlays;
+ this.locations = locations;
+ this.size = size;
+ }
+
+ protected void drawOverlays(ImageDescriptor[] overlays, int[] locations) {
+ Point size = getSize();
+ for (int i = 0; i < overlays.length; i++) {
+ ImageDescriptor overlay = overlays[i];
+ ImageData overlayData = overlay.getImageData();
+ switch (locations[i]) {
+ case TOP_LEFT:
+ drawImage(overlayData, 0, 0);
+ break;
+ case TOP_RIGHT:
+ drawImage(overlayData, size.x - overlayData.width, 0);
+ break;
+ case BOTTOM_LEFT:
+ drawImage(overlayData, 0, size.y - overlayData.height);
+ break;
+ case BOTTOM_RIGHT:
+ drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height);
+ break;
+ }
+ }
+ }
+
+ public boolean equals(Object o) {
+ if (! (o instanceof OverlayIcon)) return false;
+ OverlayIcon other = (OverlayIcon) o;
+ return base.equals(other.base) && Arrays.equals(overlays, other.overlays);
+ }
+
+ public int hashCode() {
+ int code = base.hashCode();
+ for (int i = 0; i < overlays.length; i++) {
+ code ^= overlays[i].hashCode();
+ }
+ return code;
+ }
+
+
+ protected void drawCompositeImage(int width, int height) {
+ drawImage(base.getImageData(), 0, 0);
+ drawOverlays(overlays, locations);
+ }
+
+ protected Point getSize() {
+ return size;
+ }
+}

Back to the top