List of usage examples for org.eclipse.jface.resource ImageDescriptor getImageData
@Deprecated
public ImageData getImageData()
ImageData
object for this image descriptor. From source file:org.eclipse.sirius.diagram.ui.tools.internal.properties.LabelColorAndFontPropertySection.java
License:Open Source License
@Override protected RGB changeColor(final SelectionEvent event, final Button button, final String propertyId, final String commandName, final ImageDescriptor imageDescriptor) { RGB colorToReturn = null;// w w w.jav a 2 s . c o m if (!Properties.ID_FILLCOLOR.equals(propertyId) && !Properties.ID_LINECOLOR.equals(propertyId) && !Properties.ID_FONTCOLOR.equals(propertyId)) { colorToReturn = super.changeColor(event, button, propertyId, commandName, imageDescriptor); } else { final ColorPalettePopup popup = new ColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); final Rectangle r = button.getBounds(); final Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { return null; } // selectedColor should be null if we are to use the default color final RGB selectedColor = popup.getSelectedColor(); final EStructuralFeature feature = (EStructuralFeature) PackageUtil.getElement(propertyId); // Update model in response to user final List<ICommand> commands = new ArrayList<ICommand>(); final Iterator<?> it = getInputIterator(); colorToReturn = selectedColor; RGB color = selectedColor; while (it.hasNext()) { final IGraphicalEditPart ep = (IGraphicalEditPart) it.next(); color = selectedColor; if (popup.useDefaultColor()) { final Object preferredValue = ep.getPreferredValue(feature); if (preferredValue instanceof Integer) { color = FigureUtilities.integerToRGB((Integer) preferredValue); } } // If we are using default colors, we want to return the color // of the first selected element to be consistent if (colorToReturn == null) { colorToReturn = color; } if (color != null) { final RGB finalColor = color; // need a final variable commands.add(createCommand(commandName, ((View) ep.getModel()).eResource(), new Runnable() { @Override public void run() { final ENamedElement element = PackageUtil.getElement(propertyId); if (element instanceof EStructuralFeature) { ep.setStructuralFeatureValue(feature, FigureUtilities.RGBToInteger(finalColor)); } // get the view. final View view = (View) ep.getModel(); // change the color. final UserFixedColor newColor = DescriptionFactory.eINSTANCE.createUserFixedColor(); newColor.setName("<anonymous>"); newColor.setBlue(finalColor.blue); newColor.setGreen(finalColor.green); newColor.setRed(finalColor.red); IInterpreter interpreter = new EObjectQuery(view).getSession().getInterpreter(); // new // ViewPropertiesSynchronizer().synchronizeDDiagramElementStyleProperties(view); new ViewPropertiesSynchronizer().synchronizeDDiagramElementStyleColorProperties(view, newColor, propertyId, interpreter); } })); } } if (!commands.isEmpty()) { executeAsCompositeCommand(commandName, commands); final Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), color) .createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); } } return colorToReturn; }
From source file:org.eclipse.stp.bpmn.properties.section.ColorsAndFontsPropertySectionEx.java
License:Open Source License
/** * @param event -//from www .j ava 2s . c o m * selection event * @param button - * event source * @param propertyId - * id of the property * @param commandName - * name of the command * @param imageDescriptor - * the image to draw overlay on the button after the new color is * set * @return - new RGB color, or null if none selected */ protected RGB changeColor(SelectionEvent event, Button button, final String propertyId, String commandName, ImageDescriptor imageDescriptor) { ColorPalettePopup popup = new ColorPalettePopup(button.getParent().getShell(), IDialogConstants.BUTTON_BAR_HEIGHT); // popup.setPreviousColor(previousColor); Rectangle r = button.getBounds(); Point location = button.getParent().toDisplay(r.x, r.y); popup.open(new Point(location.x, location.y + r.height)); if (popup.getSelectedColor() == null && !popup.useDefaultColor()) { return null; } // selectedColor should be null if we are to use the default color final RGB selectedColor = popup.getSelectedColor(); final EStructuralFeature feature = (EStructuralFeature) PackageUtil.getElement(propertyId); // Update model in response to user List commands = new ArrayList(); Iterator it = getInputIterator(); RGB colorToReturn = selectedColor; RGB color = selectedColor; while (it.hasNext()) { final IGraphicalEditPart ep = (IGraphicalEditPart) it.next(); color = selectedColor; if (popup.useDefaultColor()) { Object preferredValue = ep.getPreferredValue(feature); if (preferredValue instanceof Integer) { color = FigureUtilities.integerToRGB((Integer) preferredValue); } } // If we are using default colors, we want to return the color of the first selected element to be consistent if (colorToReturn == null) { colorToReturn = color; } if (color != null) { final RGB finalColor = color; // need a final variable commands.add(createCommand(commandName, ((View) ep.getModel()).eResource(), new Runnable() { public void run() { ENamedElement element = PackageUtil.getElement(propertyId); if (element instanceof EStructuralFeature) { IGraphicalEditPart editP = ep; if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { editP = (IGraphicalEditPart) editP.getParent(); } editP.setStructuralFeatureValue(feature, FigureUtilities.RGBToInteger(finalColor)); } } })); } } if (!commands.isEmpty()) { executeAsCompositeCommand(commandName, commands); Image overlyedImage = new ColorOverlayImageDescriptor(imageDescriptor.getImageData(), color) .createImage(); disposeImage(button.getImage()); button.setImage(overlyedImage); } return colorToReturn; }
From source file:org.eclipse.tcf.internal.debug.ui.ImageCache.java
License:Open Source License
public static synchronized ImageDescriptor addOverlay(ImageDescriptor descriptor, String name, final int x, final int y) { if (descriptor == null || name == null) return descriptor; String key = name + ':' + x + ':' + y; Map<ImageDescriptor, ImageDescriptor> map = overlay_cache.get(key); if (map == null) overlay_cache.put(key, map = new HashMap<ImageDescriptor, ImageDescriptor>()); ImageDescriptor res = map.get(descriptor); if (res != null) return res; final ImageData base = descriptor.getImageData(); final ImageData overlay = getImageDescriptor(name).getImageData(); res = new CompositeImageDescriptor() { @Override//from w w w . j a va 2 s . c om protected void drawCompositeImage(int width, int height) { drawImage(base, 0, 0); drawImage(overlay, x, y); } @Override protected Point getSize() { return new Point(base.width, base.height); } }; map.put(descriptor, res); return res; }
From source file:org.eclipse.ui.internal.DragCursors.java
License:Open Source License
/** * Return the cursor for a drop scenario, as identified by code. Code must be one of INVALID, * LEFT, RIGHT, TOP, etc. If the code is not found default to INVALID. * /* www .j a va 2 s . c o m*/ * @param code the code * @return the cursor */ public static Cursor getCursor(int code) { Display display = Display.getCurrent(); if (cursors[code] == null) { ImageDescriptor source = null; ImageDescriptor mask = null; switch (code) { case LEFT: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_LEFT_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_LEFT_MASK); cursors[LEFT] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; case RIGHT: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_RIGHT_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_RIGHT_MASK); cursors[RIGHT] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; case TOP: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_TOP_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_TOP_MASK); cursors[TOP] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; case BOTTOM: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_BOTTOM_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_BOTTOM_MASK); cursors[BOTTOM] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; case CENTER: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_STACK_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_STACK_MASK); cursors[CENTER] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; case OFFSCREEN: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_OFFSCREEN_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_OFFSCREEN_MASK); cursors[OFFSCREEN] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; case FASTVIEW: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_TOFASTVIEW_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_TOFASTVIEW_MASK); cursors[FASTVIEW] = new Cursor(Display.getCurrent(), source.getImageData(), mask.getImageData(), 16, 16); break; default: case INVALID: source = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_INVALID_SOURCE); mask = WorkbenchImages.getImageDescriptor(ISharedImages.IMG_OBJS_DND_INVALID_MASK); cursors[INVALID] = new Cursor(display, source.getImageData(), mask.getImageData(), 16, 16); break; } } return cursors[code]; }
From source file:org.eclipse.ui.internal.OverlayIcon.java
License:Open Source License
/** * @param overlay the additional image (a pin for example) * to be drawn on top of the main image/* w ww .j av a 2 s . c o m*/ */ protected void drawTopRight(ImageDescriptor overlay) { if (overlay == null) { return; } int x = getSize().x; ImageData id = overlay.getImageData(); x -= id.width; drawImage(id, x, 0); }
From source file:org.eclipse.wb.internal.rcp.model.rcp.ActionFactoryCreationSupport.java
License:Open Source License
/** * @return the implementation of {@link ImageDescriptor} that returns same {@link ImageData} as * given source {@link ImageDescriptor}. */// ww w. j a va 2 s. co m private static Object createID(ClassLoader classLoader, ImageDescriptor sourceID) throws Exception { // prepare ImageData final ImageData imageData = sourceID.getImageData(); // prepare ImageDescriptor Enhancer enhancer = new Enhancer(); Class<?> imageDescriptorClass = classLoader.loadClass("org.eclipse.jface.resource.ImageDescriptor"); enhancer.setClassLoader(classLoader); enhancer.setSuperclass(imageDescriptorClass); enhancer.setCallback(new MethodInterceptor() { public Object intercept(Object obj, java.lang.reflect.Method method, Object[] args, MethodProxy proxy) throws Throwable { if (method.getName().equals("getImageData") && args.length == 0) { return imageData; } return proxy.invokeSuper(obj, args); } }); return enhancer.create(); }
From source file:org.eclipse.wst.common.project.facet.ui.internal.util.ProblemOverlayImageDescriptor.java
License:Open Source License
public ProblemOverlayImageDescriptor(final ImageDescriptor base, final int severity) { this.base = base.getImageData(); this.overlay = getOverlay(severity); this.size = new Point(this.base.width, this.base.height); }
From source file:org.eclipse.wst.html.webresources.internal.ui.ImageResource.java
License:Open Source License
public static URL getImageURL(ImageDescriptor descriptor) { if (fTempDir == null) return null; 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 a va 2 s . c om 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) { Trace.trace(Trace.SEVERE, "Failed to create image directory ", e); //$NON-NLS-1$ } return null; }
From source file:org.eclipse.wst.jsdt.internal.ui.callhierarchy.CallHierarchyImageDescriptor.java
License:Open Source License
private ImageData getImageData(ImageDescriptor descriptor) { ImageData data = descriptor.getImageData(); // see bug 51965: getImageData can return null if (data == null) { data = DEFAULT_IMAGE_DATA;/*from w w w. j a va 2 s . c o m*/ JavaScriptPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$ } return data; }
From source file:org.eclipse.wst.json.ui.internal.editor.JSONEditorPluginImageHelper.java
License:Open Source License
public URL getImageURL(ImageDescriptor descriptor) { if (fTempDir == null) return null; 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 a v a2 s . co 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) { Logger.logException("Failed to create image directory ", e); //$NON-NLS-1$ } return null; }