Example usage for org.eclipse.jface.resource ImageDescriptor createFromImageData

List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromImageData

Introduction

In this page you can find the example usage for org.eclipse.jface.resource ImageDescriptor createFromImageData.

Prototype

@Deprecated
public static ImageDescriptor createFromImageData(ImageData data) 

Source Link

Document

Creates and returns a new image descriptor given ImageData describing the image.

Usage

From source file:com.nokia.carbide.cpp.internal.ui.images.MaskedFileImageModel.java

License:Open Source License

public ImageDescriptor getImageDescriptor(Point size) throws CoreException {
    if (size == null) {
        if (composedImageDescriptor != null) {
            return composedImageDescriptor;
        }// w w w  . ja v a 2  s .co  m
    }

    ImageDescriptor descriptor = null;
    ImageData combined;
    ImageData imageData;
    ImageData maskData;

    if (maskSourceLocation != null) {
        if (method == MaskCompositionMethod.TILING) {
            // Get image and mask in the original size, then scale the whole thing, else
            // the tiling won't work
            imageData = getImageData(null);
            maskData = getMaskData(null);

            combined = combineImageAndMask(imageData, maskData);

            // scale the combined image
            if (size != null && (size.x != combined.width || size.y != combined.height)) {
                combined = ImageUtils.scaleImageData(combined, size, false, false);
            }
        } else {
            // Scale the image and mask to the same size, then combine
            imageData = getImageData(size);
            maskData = getMaskData(size);
            Check.checkState(imageData != null);
            combined = combineImageAndMask(imageData, maskData);
        }

    } else {
        // no mask, just get image at desired size
        imageData = getImageData(size);
        combined = combineImageAndMask(imageData, null);
    }

    descriptor = ImageDescriptor.createFromImageData(combined);
    if (size == null) {
        composedImageDescriptor = descriptor;
    }

    return descriptor;
}

From source file:com.nokia.carbide.cpp.uiq.components.sbbCustomizer.SBBCustomizerComposite.java

License:Open Source License

private static synchronized Image loadThumb(String key) {
    Image result = (Image) getImageMap().get(key);
    if (result == null) {
        try {//from   w  w  w.  j av a  2  s  . c  o  m
            ImageData id = new ImageData(key);
            ImageDescriptor idesc = ImageDescriptor.createFromImageData(id);
            result = idesc.createImage();
            getImageMap().put(key, result);
        } catch (Exception e) {
            Logging.log(ComponentSystemPlugin.getDefault(),
                    Logging.newStatus(ComponentSystemPlugin.getDefault(), e));
            result = new Image(Display.getDefault(), 1, 1);
        }
    }
    return result;
}

From source file:com.nokia.s60tools.ui.UiUtils.java

License:Open Source License

/**
 * Method for retrieving wizard banner background for the given icon.
 * @param toolWizardIcon Tool's wizard icon to be added on top of background banner.
 * @return given icon with the wizard banner background
 *///from  www  . j  a  v a 2 s  .c o  m
public static ImageDescriptor getBannerImageDescriptor(ImageDescriptor toolWizardIcon) {

    // Getting background image.
    ImageDescriptor bannerDesc = S60ToolsUiPlugin.getImageDescriptorForKey(NOKIA_TOOLS_BANNER);

    // If icon is null, return only the banner
    if (toolWizardIcon == null)
        return bannerDesc;

    Image bannerImage = bannerDesc.createImage();
    Image iconImage = toolWizardIcon.createImage();

    GC imageGC = new GC(bannerImage);

    // Draw icon over the banner, in the middle
    imageGC.drawImage(iconImage, bannerImage.getBounds().width / 2 - iconImage.getBounds().width / 2,
            bannerImage.getBounds().height / 2 - iconImage.getBounds().height / 2);

    ImageDescriptor finalDesc = ImageDescriptor.createFromImageData(bannerImage.getImageData());

    // Dispose graphics
    imageGC.dispose();
    bannerImage.dispose();
    iconImage.dispose();

    return finalDesc;
}

From source file:com.nokia.sdt.component.symbian.designerimages.DesignerImageAdapter.java

License:Open Source License

private static synchronized Image loadImage(String key) {
    Image result = (Image) getImageMap().get(key);
    if (result == null) {
        try {/*from w  w w. ja  v  a 2s .  c o  m*/
            ImageData id = new ImageData(key);
            ImageDescriptor idesc = ImageDescriptor.createFromImageData(id);
            result = idesc.createImage();
            getImageMap().put(key, result);
            //             System.out.println("Loading image: " + id);
        } catch (Exception e) {
            Logging.log(ComponentSystemPlugin.getDefault(),
                    Logging.newStatus(ComponentSystemPlugin.getDefault(), e));
            result = new Image(Display.getDefault(), 1, 1);
        }
    }
    return result;
}

From source file:com.nokia.tools.carbide.ct.confml.ui.PluginImages.java

License:Open Source License

/**
 * Preloads image into backbuffer and then wraps into
 * {@link ImageDescriptor}//from   ww w  .  jav a2  s . c  om
 * 
 * @param name
 *            image name
 * @return
 */
private static ImageDescriptor loadImage(String name) {
    try {
        URL entry = ConfMLUIActivator.getDefault().getBundle().getEntry("icons/" + name);
        ImageData id = new ImageData(entry.openStream());
        return ImageDescriptor.createFromImageData(id);
    } catch (Exception ex) {
        ConfMLUIActivator.getDefault().getLog()
                .log(new Status(IStatus.ERROR, ConfMLUIActivator.PLUGIN_ID, "Failed to load icon " + name, ex));
        return null;
    }
}

From source file:com.nokia.tools.carbide.ct.crml.ui.PluginImages.java

License:Open Source License

/**
 * Preloads image into backbuffer and then wraps into
 * {@link ImageDescriptor}/*  w ww  .j a va 2  s.co  m*/
 * 
 * @param name
 *            image name
 * @return
 */
private static ImageDescriptor loadImage(String name) {
    try {
        URL entry = CRMLUIActivator.getDefault().getBundle().getEntry("icons/" + name);
        ImageData id = new ImageData(entry.openStream());
        return ImageDescriptor.createFromImageData(id);
    } catch (Exception ex) {
        CRMLUIActivator.getDefault().getLog()
                .log(new Status(IStatus.ERROR, CRMLUIActivator.PLUGIN_ID, "Failed to load icon " + name, ex));
        return null;
    }
}

From source file:com.nokia.tools.s60.editor.actions.AddToColorGrpsAction.java

License:Open Source License

public void setColorGroups(ColorGroups grps) {
    this.grps = grps;
    // adding the color icon in the menu
    ImageDescriptor desc = null;//from ww  w.j a  va2  s .c o m
    ColorGroup cg = grps == null ? null : grps.getGroupByName(targetGroupName);
    if (cg == null) {
        // otherwise npe destroys the context menu of layers page
        return;
    }
    RGB rgb = cg.getGroupColor();
    PaletteData paletteData = new PaletteData(new RGB[] { rgb });
    ImageData imageData = new ImageData(10, 10, 1, paletteData);
    desc = ((ImageDescriptor.createFromImageData(imageData)));

    if (grps.getGroupByName(targetGroupName).getGroupItems().size() == 0) {

        setImageDescriptor(desc);
    } else {
        setImageDescriptor(getDescriptorForOvalImage(rgb));

    }

}

From source file:com.nokia.tools.s60.editor.actions.AddToGroupAction.java

License:Open Source License

public void setColorGroups(ColorGroups grps) {
    this.grps = grps;
    // adding the color icon in the menu
    ImageDescriptor desc = null;/* w w  w  .  j ava2  s  . co m*/
    ColorGroup cg = grps == null ? null : grps.getGroupByName(targetGroupName);
    if (cg == null) {
        // otherwise npe destroys the context menu of layers page
        return;
    }
    RGB rgb = cg.getGroupColor();
    PaletteData paletteData = new PaletteData(new RGB[] { rgb });
    ImageData imageData = new ImageData(10, 10, 1, paletteData);
    desc = ((ImageDescriptor.createFromImageData(imageData)));

    if (grps.getGroupByName(targetGroupName).getGroupItems().size() == 0) {// unused
        // color
        setImageDescriptor(desc);
    } else {// used(linked) colour
        setImageDescriptor(getDescriptorForOvalImage(rgb));

    }

}

From source file:com.nokia.tools.s60.ide.actions.ThemeModelDropDownAction.java

License:Open Source License

public ImageDescriptor getCustomImageDescriptor(String id, String text) {
    FontData fd = JFaceResources.getDefaultFont().getFontData()[0];
    Font bigFont = new Font(Display.getDefault(), fd.getName(), 9, SWT.BOLD);
    Font smallFont = new Font(Display.getDefault(), fd.getName(), 5, SWT.NORMAL);
    Font normalFont = new Font(Display.getDefault(), fd.getName(), 7, SWT.NORMAL);
    ImageDescriptor desc = S60WorkspacePlugin.getImageDescriptor("icons/platform/platform_base.png");

    Image bannerImage = null;//from w ww. j a  va2  s  .com
    GC imageGC = null;
    int logoSpace;
    Color color1 = new Color(Display.getDefault(), 128, 132, 135);
    Color color2 = new Color(Display.getDefault(), 183, 83, 176);
    Color color3 = new Color(Display.getDefault(), 143, 0, 96);

    try {
        bannerImage = desc.createImage();
        int imageWidth = bannerImage.getBounds().width;
        imageGC = new GC(bannerImage);
        if (id.contains("60")) {
            logoSpace = FigureUtilities.getTextWidth("S60", bigFont) + 2;
            imageGC.setForeground(color1);
            imageGC.setFont(bigFont);
            imageGC.drawString("S60", 1, 1, true);
        } else {
            logoSpace = 0;
        }
        imageGC.setForeground(ColorConstants.black);
        imageGC.setFont(normalFont);
        text = filtrateText(text);
        int freeSpace = imageWidth - logoSpace - 2;
        int textWidth = FigureUtilities.getTextWidth(text, normalFont);

        if (textWidth > freeSpace) {
            text = ScreenUtil.toShorterWithDots(text, freeSpace, normalFont);
            textWidth = FigureUtilities.getTextWidth(text, normalFont);
        }
        int x = (int) (((freeSpace) - textWidth) / 2) + logoSpace;
        imageGC.drawString(text, x, 3, true);
        ImageData data = bannerImage.getImageData();
        data.transparentPixel = new java.awt.Color(192, 192, 192).getRGB();
        return ImageDescriptor.createFromImageData(data);
    } finally {
        if (imageGC != null) {
            imageGC.dispose();
        }
        if (bannerImage != null) {
            bannerImage.dispose();
        }
        if (bigFont != null) {
            bigFont.dispose();
        }
        if (normalFont != null) {
            normalFont.dispose();
        }
        if (smallFont != null) {
            smallFont.dispose();
        }
        if (color1 != null) {
            color1.dispose();
        }
        if (color2 != null) {
            color2.dispose();
        }
        if (color3 != null) {
            color3.dispose();
        }
    }
}

From source file:com.nokia.tools.s60ct.confml.editor.PluginImages.java

License:Open Source License

/**
 * Preloads image into backbuffer and then wraps into
 * {@link ImageDescriptor}/*w ww  .  j a  va2 s.c om*/
 * 
 * @param name
 *            image name
 * @return
 */
private static ImageDescriptor loadImage(String name) {
    try {
        URL entry = Activator.getDefault().getBundle().getEntry("icons/" + name);
        ImageData id = new ImageData(entry.openStream());
        return ImageDescriptor.createFromImageData(id);
    } catch (Exception ex) {
        Activator.getDefault().getLog()
                .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to load icon " + name, ex));
        return null;
    }
}