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

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

Introduction

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

Prototype

@Deprecated
public ImageData getImageData() 

Source Link

Document

Creates and returns a new SWT ImageData object for this image descriptor.

Usage

From source file:bndtools.release.OverlayImageDescriptor.java

License:Open Source License

@Override
protected void drawCompositeImage(int width, int height) {

    Image id = reg.get(baseImage);

    // Draw the base image using the base image's image data
    drawImage(id.getImageData(), 0, 0);/*from ww  w. j a v  a 2 s .c o  m*/

    // Overlaying the icon in the top left corner i.e. x and y
    // coordinates are both zero
    ImageDescriptor imgDescr = reg.getDescriptor(overlayImage);
    if (imgDescr == null) {
        return;
    }
    drawImage(imgDescr.getImageData(), xValue, yValue);
}

From source file:br.org.archimedes.gui.rca.editor.DrawingEditor.java

License:Open Source License

/**
 * @param path/*from ww w.j a  v a 2 s  .  c o m*/
 *            The path to the cursor image.
 * @return The created cursor or null if the image couldn't be found.
 */
private static Cursor createCursor(String path) {

    ImageDescriptor imageDescriptor = Activator.getImageDescriptor(path); //$NON-NLS-1$
    Cursor openHandCursor = null;
    if (imageDescriptor != null) { // found the image
        ImageData openHand = imageDescriptor.getImageData();
        openHandCursor = new Cursor(Display.getCurrent(), openHand, 12, 12);
    }
    return openHandCursor;
}

From source file:com.archimatetool.editor.ui.components.CompositeMultiImageDescriptor.java

License:Open Source License

@Override
protected void drawCompositeImage(int width, int height) {
    for (ImageDescriptor overlay : fOverlays) {
        if (overlay != null) {
            drawImage(overlay.getImageData(), 0, 0);
        }/*from   w  w w  .  ja  va  2 s. com*/
    }
}

From source file:com.archimatetool.editor.ui.components.CompositeMultiImageDescriptor.java

License:Open Source License

@Override
protected Point getSize() {
    // Find the largest size of all the images
    if (fSize == null) {
        fSize = new Point(1, 1);
        for (ImageDescriptor overlay : fOverlays) {
            if (overlay != null) {
                ImageData id = overlay.getImageData();
                fSize.x = Math.max(fSize.x, id.width);
                fSize.y = Math.max(fSize.y, id.height);
            }/*  w ww  .j  a v a  2 s . c o  m*/
        }
    }
    return fSize;
}

From source file:com.archimatetool.editor.ui.factory.AbstractElementUIProvider.java

License:Open Source License

/**
 * Create a new ImageDescriptor substituting the user's preference for fill color
 *//*w w  w. j  av a  2 s  .  c o m*/
protected ImageDescriptor getImageDescriptorWithUserFillColor(String imageName) {
    // Not a preference
    if (!Preferences.STORE.getBoolean(IPreferenceConstants.SHOW_FILL_COLORS_IN_GUI)) {
        return IArchimateImages.ImageFactory.getImageDescriptor(imageName);
    }

    ImageDescriptor newImageDescriptor = fImageRegistry.getDescriptor(imageName);

    // Create new ImageDescriptor
    if (newImageDescriptor == null) {
        ImageDescriptor originalImageDescriptor = IArchimateImages.ImageFactory.getImageDescriptor(imageName);

        Color color = ColorFactory.getUserDefaultFillColor(providerFor());

        // No user default color
        if (color == null) {
            return originalImageDescriptor;
        }

        ImageData imageData = originalImageDescriptor.getImageData();

        for (int i = 0; i < imageData.width; i++) {
            for (int j = 0; j < imageData.height; j++) {
                RGB rgb = imageData.palette.getRGB(imageData.getPixel(i, j));
                if (rgb.red > 0) {
                    imageData.setPixel(i, j, ColorFactory.getPixelValue(color.getRGB()));
                }
            }
        }

        newImageDescriptor = ImageDescriptor.createFromImageData(imageData);
        fImageRegistry.put(imageName, newImageDescriptor);
    }

    return newImageDescriptor;
}

From source file:com.archimatetool.editor.ui.factory.elements.AbstractArchimateElementUIProvider.java

License:Open Source License

/**
 * Create a new ImageDescriptor substituting the user's preference for fill color
 *//*w  w w .j av a2  s. co m*/
protected ImageDescriptor getImageDescriptorWithUserFillColor(String imageName) {
    // Not a preference
    if (!Preferences.STORE.getBoolean(IPreferenceConstants.SHOW_FILL_COLORS_IN_GUI)) {
        return IArchiImages.ImageFactory.getImageDescriptor(imageName);
    }

    ImageDescriptor newImageDescriptor = fImageRegistry.getDescriptor(imageName);

    // Create new ImageDescriptor
    if (newImageDescriptor == null) {
        ImageDescriptor originalImageDescriptor = IArchiImages.ImageFactory.getImageDescriptor(imageName);

        Color color = ColorFactory.getUserDefaultFillColor(providerFor());

        // No user default color
        if (color == null) {
            return originalImageDescriptor;
        }

        ImageData imageData = originalImageDescriptor.getImageData();

        for (int i = 0; i < imageData.width; i++) {
            for (int j = 0; j < imageData.height; j++) {
                RGB rgb = imageData.palette.getRGB(imageData.getPixel(i, j));
                if (rgb.red > 0) {
                    imageData.setPixel(i, j, ColorFactory.getPixelValue(color.getRGB()));
                }
            }
        }

        newImageDescriptor = ImageDescriptor.createFromImageData(imageData);
        fImageRegistry.put(imageName, newImageDescriptor);
    }

    return newImageDescriptor;
}

From source file:com.architexa.org.eclipse.gef.SharedCursors.java

License:Open Source License

private static Cursor createCursor(String sourceName, String maskName) {
    ImageDescriptor src = ImageDescriptor.createFromFile(Internal.class, sourceName);
    ImageDescriptor mask = ImageDescriptor.createFromFile(Internal.class, maskName);
    return new Cursor(null, src.getImageData(), mask.getImageData(), 0, 0);
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * This method should not be used to create buttons for the button bar.  Use
 * {@link Dialog#createButton(Composite, int, String, boolean)} for that.   This method
 * can be used to create any other button in the dialog.  The parent 
 * <code>Composite</code> must have a GridLayout.  These buttons will be  available
 * through {@link #getButton(int)} and {@link #getWidget(int)}.  Ensure that the various
 * buttons created by this method are given unique IDs.  Pass in a <code>null</code> image
 * descriptor if  you don't want the button to have an icon.  This method will take care
 * of  disposing the images that it creates.  {@link #buttonPressed(int)} will be called
 * when any of the buttons created by this method are clicked (selected).
 * /*from   w  ww.j ava2s  .c  om*/
 * @param   parent      The composite in which the button is to be created
 * @param   id         The button's unique ID
 * @param   label      The button's text
 * @param   stylebits   The style bits for creating the button (eg., 
 *                   <code>SWT.PUSH</code> or <code>SWT.CHECK</code>)
 * @param   descriptor   The ImageDescriptor from which the image/icon for this
 *                   button should be created
 * @return            The newly created button for convenience
 */
protected Button createButton(Composite parent, int id, String label, int stylebits,
        ImageDescriptor descriptor) {
    Button button = new Button(parent, stylebits);
    button.setText(label);
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    button.setLayoutData(data);

    button.setData(new Integer(id));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            buttonPressed(((Integer) event.widget.getData()).intValue());
        }
    });
    widgets.put(new Integer(id), button);

    if (descriptor != null) {
        button.setImage(new Image(parent.getDisplay(), descriptor.getImageData()));
        button.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
                Image img = ((Button) e.getSource()).getImage();
                if (img != null && !img.isDisposed()) {
                    img.dispose();
                }
            }
        });
    }

    return button;
}

From source file:com.axmor.eclipse.typescript.editor.TypeScriptImageDescriptor.java

License:Open Source License

/**
 * Gets image data for a given descriptor
 *  //from w w w  .j  av a2  s  . co m
 * @param descriptor 
 * @return the image data
 */
private ImageData getImageData(ImageDescriptor descriptor) {
    ImageData data = descriptor.getImageData();
    if (data == null) {
        data = DEFAULT_IMAGE_DATA;
    }
    return data;
}

From source file:com.dubture.symfony.ui.viewsupport.ImagesOnFileSystemRegistry.java

License:Open Source License

@SuppressWarnings("unchecked")
public URL getImageURL(ImageDescriptor descriptor) {
    if (fTempDir == null)
        return null;

    URL url = (URL) fURLMap.get(descriptor);
    if (url != null)
        return url;

    File imageFile = getNewFile();
    ImageData imageData = descriptor.getImageData();
    if (imageData == null) {
        return null;
    }/*from w  w  w  .  j  ava 2s . c o m*/

    ImageLoader loader = new ImageLoader();
    loader.data = new ImageData[] { imageData };
    loader.save(imageFile.getAbsolutePath(), SWT.IMAGE_PNG);

    try {
        url = imageFile.toURI().toURL();
        fURLMap.put(descriptor, url);
        return url;
    } catch (MalformedURLException e) {
        //         SymfonyUiPlugin.log(e);
    }
    return null;
}