Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorustieber2011-05-13 02:32:25 -0400
committerustieber2011-05-13 02:32:25 -0400
commited3a671f1c7a8420d4f778f22ecc6a806b5cbe2c (patch)
tree8debb9a01ffd0eb0d73d9a401c1d5b52412c6a66
parenta181e1b9e9b9db4cafa7ce79aeaf82a57ec1bb02 (diff)
downloadorg.eclipse.tcf-ed3a671f1c7a8420d4f778f22ecc6a806b5cbe2c.tar.gz
org.eclipse.tcf-ed3a671f1c7a8420d4f778f22ecc6a806b5cbe2c.tar.xz
org.eclipse.tcf-ed3a671f1c7a8420d4f778f22ecc6a806b5cbe2c.zip
Target Explorer: Add missing javadoc to AbstractImageDescriptor
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageDescriptor.java173
3 files changed, 137 insertions, 40 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java
index 430400522..10642047a 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/activator/UIPlugin.java
@@ -124,7 +124,7 @@ public class UIPlugin extends AbstractUIPlugin {
public static Image getSharedImage(AbstractImageDescriptor descriptor) {
ImageRegistry registry = getDefault().getImageRegistry();
- String imageKey = descriptor.getKey();
+ String imageKey = descriptor.getDecriptorKey();
Image image = registry.get(imageKey);
if (image == null) {
registry.put(imageKey, descriptor);
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java
index 220372242..068825745 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/images/PeerImageDescriptor.java
@@ -71,7 +71,7 @@ public class PeerImageDescriptor extends AbstractImageDescriptor {
hashCode + ":" + //$NON-NLS-1$
fState;
- setKey(key);
+ setDecriptorKey(key);
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageDescriptor.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageDescriptor.java
index 626617b0a..290d47496 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageDescriptor.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/images/AbstractImageDescriptor.java
@@ -9,6 +9,7 @@
*******************************************************************************/
package org.eclipse.tm.te.ui.images;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
@@ -16,33 +17,79 @@ import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
/**
- * Target Explorer: Image descriptor for creating overlays.
+ * Target Explorer: Extended composite image descriptor.
+ * <p>
+ * The image descriptor implementation adds method for easily drawing overlay
+ * images on different positions on top of a base image.
*/
public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
+ // The parent image registry providing the images for drawing
+ private final ImageRegistry parentImageRegistry;
- private String fKey;
- private ImageRegistry fRegistry;
+ // The image descriptor key
+ private String descriptorKey = null;
- public AbstractImageDescriptor(ImageRegistry reg) {
- fRegistry = reg;
+ /**
+ * Constructor.
+ *
+ * @param parent The parent image registry. Must not be <code>null</code>.
+ */
+ public AbstractImageDescriptor(ImageRegistry parent) {
+ super();
+
+ Assert.isNotNull(parent);
+ parentImageRegistry = parent;
}
- protected void setKey(String key) {
- fKey = key;
+ /**
+ * Returns the parent image registry.
+ *
+ * @return The parent image registry instance.
+ */
+ protected final ImageRegistry getParentImageRegistry() {
+ return parentImageRegistry;
}
- public String getKey() {
- return fKey;
+ /**
+ * Set the image descriptor key.
+ *
+ * @param key The image descriptor key. Must not be <code>null</code>.
+ */
+ protected final void setDecriptorKey(String key) {
+ Assert.isNotNull(key);
+ descriptorKey = key;
}
- protected ImageRegistry getRegistry() {
- return fRegistry;
+ /**
+ * Returns the image descriptor key.
+ *
+ * @return The image descriptor key, or <code>null</code> if not set.
+ */
+ public final String getDecriptorKey() {
+ return descriptorKey;
}
+ /**
+ * Draw the image, found under the specified key, centered within the
+ * rectangle given by width x height.
+ *
+ * @param key The image key. Must not be <code>null</code>.
+ * @param width The width of the rectangle to center the image in.
+ * @param height The height of the rectangle to center the image in.
+ */
protected void drawCentered(String key, int width, int height) {
- drawCentered(fRegistry.get(key), width, height);
+ Assert.isNotNull(key);
+ drawCentered(parentImageRegistry.get(key), width, height);
}
+ /**
+ * Draw the given image centered within the rectangle
+ * defined by the specified width x height.
+ *
+ * @param image The image. Must not be <code>null</code>.
+ * @param width The width of the rectangle to center the image in.
+ * @param height The height of the rectangle to center the image in.
+ */
protected void drawCentered(Image image, int width, int height) {
if (image != null) {
ImageData imageData = image.getImageData();
@@ -54,8 +101,16 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, centered right on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ * @param width The width of the overlay image.
+ * @param height The height of the overlay image.
+ */
protected void drawCenterRight(String key, int width, int height) {
- Image baseImage = fRegistry.get(key);
+ Image baseImage = parentImageRegistry.get(key);
if (baseImage != null) {
ImageData imageData = baseImage.getImageData();
if (imageData != null) {
@@ -66,8 +121,14 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, top left on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ */
protected void drawTopLeft(String key) {
- Image baseImage = fRegistry.get(key);
+ Image baseImage = parentImageRegistry.get(key);
if (baseImage != null) {
ImageData imageData = baseImage.getImageData();
if (imageData != null) {
@@ -76,8 +137,16 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, top right on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ * @param width The width of the overlay image.
+ * @param height The height of the overlay image.
+ */
protected void drawTopRight(String key, int width, int height) {
- Image baseImage = fRegistry.get(key);
+ Image baseImage = parentImageRegistry.get(key);
if (baseImage != null) {
ImageData imageData = baseImage.getImageData();
if (imageData != null) {
@@ -87,8 +156,16 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, bottom center on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ * @param width The width of the overlay image.
+ * @param height The height of the overlay image.
+ */
protected void drawBottomCenter(String key, int width, int height) {
- Image image = fRegistry.get(key);
+ Image image = parentImageRegistry.get(key);
if (image != null) {
ImageData imageData = image.getImageData();
if (imageData != null) {
@@ -99,18 +176,16 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
- protected void drawBottomLeft(String key) {
- if (getSize() != null) {
- Point size = getSize();
- drawBottomLeft(key, size.x, size.y);
- } else {
- // the default eclipse style guide recommendation is 16x16
- drawBottomLeft(key, 16, 16);
- }
- }
-
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, bottom left on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ * @param width The width of the overlay image.
+ * @param height The height of the overlay image.
+ */
protected void drawBottomLeft(String key, int width, int height) {
- Image image = fRegistry.get(key);
+ Image image = parentImageRegistry.get(key);
if (image != null) {
ImageData imageData = image.getImageData();
if (imageData != null) {
@@ -120,8 +195,16 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, center left on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ * @param width The width of the overlay image.
+ * @param height The height of the overlay image.
+ */
protected void drawCenterLeft(String key, int width, int height) {
- Image image = fRegistry.get(key);
+ Image image = parentImageRegistry.get(key);
if (image != null) {
ImageData imageData = image.getImageData();
if (imageData != null) {
@@ -131,6 +214,12 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, bottom right on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ */
protected void drawBottomRight(String key) {
if (getSize() != null) {
Point size = getSize();
@@ -141,8 +230,16 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Draw the overlay image, found under the specified key in the parent
+ * image registry, bottom right on top of the base image.
+ *
+ * @param key The overlay image key. Must not be <code>null</code>.
+ * @param width The width of the overlay image.
+ * @param height The height of the overlay image.
+ */
protected void drawBottomRight(String key, int width, int height) {
- Image image = fRegistry.get(key);
+ Image image = parentImageRegistry.get(key);
if (image != null) {
ImageData imageData = image.getImageData();
if (imageData != null) {
@@ -153,6 +250,15 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
}
+ /**
+ * Returns the base image used for the combined image description. This
+ * method is called from <code>getTransparentPixel()</code> to query the
+ * transparent color of the palette.
+ *
+ * @return The base image or <code>null</code> if none.
+ */
+ protected abstract Image getBaseImage();
+
/* (non-Javadoc)
* @see org.eclipse.jface.resource.CompositeImageDescriptor#getTransparentPixel()
*/
@@ -164,13 +270,4 @@ public abstract class AbstractImageDescriptor extends CompositeImageDescriptor {
}
return super.getTransparentPixel();
}
-
- /**
- * Returns the base image used for the combined image description. This
- * method is called from <code>getTransparentPixel()</code> to query the
- * transparent color of the palette.
- *
- * @return The base image or <code>null</code> if none.
- */
- protected abstract Image getBaseImage();
}

Back to the top