Example usage for org.eclipse.jface.viewers IDecoration UNDERLAY

List of usage examples for org.eclipse.jface.viewers IDecoration UNDERLAY

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IDecoration UNDERLAY.

Prototype

int UNDERLAY

To view the source code for org.eclipse.jface.viewers IDecoration UNDERLAY.

Click Source Link

Document

Constant for the underlay.

Usage

From source file:org.eclipse.egit.ui.internal.DecorationOverlayDescriptor.java

License:Open Source License

protected void drawCompositeImage(int width, int height) {
    if (overlays.length > IDecoration.UNDERLAY) {
        ImageDescriptor underlay = overlays[IDecoration.UNDERLAY];
        if (underlay != null)
            drawImage(underlay.getImageData(), 0, 0);
    }/*w w w .  j av a2 s  . c  om*/

    if (overlays.length > IDecoration.REPLACE && overlays[IDecoration.REPLACE] != null)
        drawImage(overlays[IDecoration.REPLACE].getImageData(), 0, 0);
    else
        drawImage(getBaseImageData(), 0, 0);

    drawOverlays(overlays);
}

From source file:org.eclipse.jpt.common.ui.internal.jface.OverlayImageDescriptor.java

License:Open Source License

/**
 * Draw the underlay image first, followed by either the base image or the
 * replacement image, followed by the overlay images in the order indicated
 * by the overlay constants defined on {@link IDecoration}.
 *//* w w  w . j  av a  2 s .c o  m*/
@Override
protected void drawCompositeImage(int width, int height) {
    if (this.overlays.length > IDecoration.UNDERLAY) {
        ImageDescriptor underlay = this.overlays[IDecoration.UNDERLAY];
        if (underlay != null) {
            this.drawImage(underlay.getImageData(), 0, 0);
        }
    }

    ImageDescriptor temp = this.base;
    if (this.overlays.length > IDecoration.REPLACE) {
        ImageDescriptor replace = this.overlays[IDecoration.REPLACE];
        if (replace != null) {
            temp = replace;
        }
    }
    this.drawImage(this.convertToImageData(temp), 0, 0);

    for (int i = 0; i < this.overlays.length; i++) {
        ImageDescriptor overlay = this.overlays[i];
        if (overlay == null) {
            continue;
        }
        ImageData overlayData = this.convertToImageData(overlay);
        switch (i) {
        case IDecoration.TOP_LEFT:
            this.drawImage(overlayData, 0, 0);
            break;
        case IDecoration.TOP_RIGHT:
            this.drawImage(overlayData, (this.size.x - overlayData.width), 0);
            break;
        case IDecoration.BOTTOM_LEFT:
            this.drawImage(overlayData, 0, (this.size.y - overlayData.height));
            break;
        case IDecoration.BOTTOM_RIGHT:
            this.drawImage(overlayData, (this.size.x - overlayData.width), (this.size.y - overlayData.height));
            break;
        default:
            // NOP
        }
    }
}

From source file:org.eclipse.ocl.examples.modelregistry.ui.icons.DecorationOverlayIcon.java

License:Open Source License

@Override
protected void drawCompositeImage(int width, int height) {
    if (overlays.length > IDecoration.UNDERLAY) {
        ImageDescriptor underlay = overlays[IDecoration.UNDERLAY];
        if (underlay != null) {
            drawImage(underlay.getImageData(), 0, 0);
        }//from w  w  w  . j  ava  2s  .c  om
    }
    drawImage(base.getImageData(), 0, 0);
    drawOverlays(overlays);
}

From source file:org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.ModelExplorerDecorationAdapter.java

License:Open Source License

/**
 * Sets the decorated image.//from ww  w  .j  ava 2s  .  c  o  m
 *
 * @param baseImage the base image
 * @param decoration the decoration
 * @param decorationPosition the decoration position
 */
public void setDecoratedImage(Image baseImage, ImageDescriptor decoration, int decorationPosition) {

    if (decoration == null || baseImage == null) {
        return;
    }

    DecorationOverlayIcon decoratedImage = null;

    // Construct a new image identifier
    String decoratedImageId = baseImage.toString().concat(decoration.toString() + decorationPosition);

    // Return the stored image if we have one
    if (Activator.getDefault().getImageRegistry().get(decoratedImageId) == null) {
        // Otherwise create a new image and store it
        switch (decorationPosition) {

        case IDecoration.TOP_LEFT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { decoration, null, null, null, null }, size16);
            break;
        case IDecoration.TOP_RIGHT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, decoration, null, null, null }, size16);
            break;
        case IDecoration.BOTTOM_LEFT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, decoration, null, null }, size16);
            break;
        case IDecoration.BOTTOM_RIGHT:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, null, decoration, null }, size16);
            break;
        case IDecoration.UNDERLAY:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, null, null, decoration }, size16);
            break;
        default:
            decoratedImage = new DecorationOverlayIcon(baseImage,
                    new ImageDescriptor[] { null, null, decoration, null, null }, size16);
            break;
        }
        Activator.getDefault().getImageRegistry().put(decoratedImageId, decoratedImage);
    }

}

From source file:org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview.ModelExplorerDecorationAdapter.java

License:Open Source License

/**
 * Sets the decoration.//from w  ww  . jav  a 2s.  c om
 *
 * @param decoration the decoration
 * @param position the position
 */
public void setDecoration(ImageDescriptor decoration, PreferedPosition position) {
    switch (position) {

    case NORTH_WEST:
        setDecoration(decoration, IDecoration.TOP_LEFT);
        break;
    case NORTH:
        setDecoration(decoration, IDecoration.TOP_RIGHT);
        break;
    case NORTH_EAST:
        setDecoration(decoration, IDecoration.TOP_RIGHT);
        break;
    case EAST:
        setDecoration(decoration, IDecoration.BOTTOM_RIGHT);
        break;
    case SOUTH_EAST:
        setDecoration(decoration, IDecoration.BOTTOM_RIGHT);
        break;
    case SOUTH:
        setDecoration(decoration, IDecoration.BOTTOM_LEFT);
        break;
    case SOUTH_WEST:
        setDecoration(decoration, IDecoration.BOTTOM_LEFT);
        break;
    case WEST:
        setDecoration(decoration, IDecoration.TOP_LEFT);
        break;
    case CENTER:
        setDecoration(decoration, IDecoration.UNDERLAY);
        break;
    default:
        setDecoration(decoration, IDecoration.BOTTOM_LEFT);
        break;

    }
}

From source file:org.eclipse.ui.tests.decorators.TestLightweightDecoratorMultipleQuadrantContributor.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
 *//*from w ww .ja  va  2s .  c  o m*/
public void decorate(Object element, IDecoration decoration) {
    decoration.addOverlay(getOverlay(element), IDecoration.BOTTOM_LEFT);
    decoration.addOverlay(getOverlay(element), IDecoration.BOTTOM_RIGHT);
    decoration.addOverlay(getOverlay(element), IDecoration.TOP_LEFT);
    decoration.addOverlay(getOverlay(element), IDecoration.TOP_RIGHT);
    decoration.addOverlay(getOverlay(element), IDecoration.UNDERLAY);
}