List of usage examples for org.eclipse.jface.resource ImageDescriptor createImage
public Image createImage()
From source file:de.instanttouch.ui.scaffolding.swt.Activator.java
License:Open Source License
/** * Gets an image from this plugin's image registry. If the image is not yet * part of the registry, it will be added. * //from w w w.j a v a2 s . co m * @param path * of the image to retrieve * @return An image from the registry */ public static Image getImage(String bundle, String path) { Image image = getDefault().getImageRegistry().get(bundle + ":" + path); if (image == null) { ImageDescriptor descriptor = getImageDescriptor(bundle, path); if (descriptor != null) { image = descriptor.createImage(); getDefault().getImageRegistry().put(bundle + ":" + path, descriptor); descriptor.getImageData(); } } return image; }
From source file:de.instanttouch.ui.scaffolding.swt.Activator.java
License:Open Source License
/** * get registered image with a special height * //from w ww.j a va 2 s . c o m * @param bundle * @param path * @param width * @return */ public static Image getImage(String bundle, String path, int prefWidth, int prefHeight) { Image image = getDefault().getImageRegistry().get(bundle + ":" + path + ":" + prefWidth + "," + prefHeight); if (image == null) { ImageDescriptor descriptor = getImageDescriptor(bundle, path); if (descriptor != null) { image = descriptor.createImage(); double width = image.getBounds().width; double height = image.getBounds().height; double scaleX = prefWidth / width; double scaleY = prefHeight / height; double scale = Math.min(scaleX, scaleY); double minWidth = width * scale; double minHeight = height * scale; ImageData imageData = image.getImageData(); ImageData newData = imageData.scaledTo((int) minWidth, (int) minHeight); image = new Image(image.getDevice(), newData); getDefault().putImage(image, bundle, path, prefWidth, prefHeight); } } return image; }
From source file:de.instanttouch.ui.scaffolding.swt.Activator.java
License:Open Source License
/** * get registered image with a special height * // w ww.j a v a2 s . c o m * @param bundle * @param path * @param height2 * @param width * @return */ public static void putImage(Image image, String bundle, String path, int width, int height) { ImageDescriptor descriptor = ImageDescriptor.createFromImage(image); image = descriptor.createImage(); getDefault().getImageRegistry().put(bundle + ":" + path + ":" + width + "," + height, descriptor); }
From source file:de.instanttouch.ui.scaffolding.swt.util.SnakeSwtUtils.java
License:Open Source License
public static Image createImage(String urlStr) { if (urlStr != null && urlStr.length() > 0) { try {// w w w . j a v a 2 s.co m URL url = new URL(urlStr); ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); Image image = imageDescriptor.createImage(); return image; } catch (Exception e) { try { Image image = new Image(Display.getCurrent(), urlStr); return image; } catch (Exception e1) { } } } return null; }
From source file:de.jaret.examples.timebars.simple.swt.renderer.CheckBoxHeaderRenderer.java
License:Open Source License
/** * Retrieve the image registry used by the renderer (lazy initializing). * /*w w w. ja v a 2 s. c o m*/ * @return initialized image regsitry containing the resources */ private ImageRegistry getImageRegistry() { if (_imageRegistry == null) { _imageRegistry = new ImageRegistry(); ImageDescriptor imgDesc = new ResourceImageDescriptor(_checkedRscName, this.getClass()); _imageRegistry.put(CHECKED, imgDesc.createImage()); imgDesc = new ResourceImageDescriptor(_uncheckedRscName, this.getClass()); _imageRegistry.put(UNCHECKED, imgDesc.createImage()); } return _imageRegistry; }
From source file:de.jaret.util.ui.table.renderer.DefaultTableHeaderRenderer.java
License:Open Source License
private ImageRegistry getImageRegistry() { if (_imageRegistry == null) { _imageRegistry = new ImageRegistry(); ImageDescriptor imgDesc = new LocalResourceImageDescriptor( "/de/jaret/util/ui/table/resource/smallarrow_down.gif"); _imageRegistry.put(DOWN, imgDesc.createImage()); imgDesc = new LocalResourceImageDescriptor("/de/jaret/util/ui/table/resource/smallarrow_up.gif"); _imageRegistry.put(UP, imgDesc.createImage()); }/* w w w .ja v a 2 s . c o m*/ return _imageRegistry; }
From source file:de.jaret.util.ui.timebars.swt.renderer.DefaultHierarchyRenderer.java
License:Open Source License
/** * Retrieve initialized image registry./*from w ww . ja v a 2 s . com*/ * * @return initialized registry */ private ImageRegistry getImageRegistry() { if (_imageRegistry == null) { _imageRegistry = new ImageRegistry(); ImageDescriptor imgDesc = new ResourceImageDescriptor(_plusRscName, this.getClass()); _imageRegistry.put(PLUS, imgDesc.createImage()); imgDesc = new ResourceImageDescriptor(_minusRscName, this.getClass()); _imageRegistry.put(MINUS, imgDesc.createImage()); imgDesc = new ResourceImageDescriptor(_leafRscName, this.getClass()); _imageRegistry.put(LEAF, imgDesc.createImage()); } return _imageRegistry; }
From source file:de.jaret.util.ui.timebars.swt.renderer.DefaultTitleRenderer.java
License:Open Source License
/** * Retrieve initialized image registry.//from ww w .j a v a2 s .c om * * @return initialized registry */ private ImageRegistry getImageRegistry() { if (_imageRegistry == null && _backgroundRscName != null) { _imageRegistry = new ImageRegistry(); ImageDescriptor imgDesc = new ResourceImageDescriptor(_backgroundRscName, this.getClass()); _imageRegistry.put(BACKGROUND, imgDesc.createImage()); } return _imageRegistry; }
From source file:de.jcup.egradle.eclipse.api.EGradleUtil.java
License:Apache License
/** * Get image by path from image registry. If not already registered a new * image will be created and registered. If not createable a fallback image * is used instead/*from ww w .j ava2 s.c o m*/ * * @param path * @param pluginId * - plugin id to identify which plugin image should be loaded * @return image */ public static Image getImage(String path, String pluginId) { ImageRegistry imageRegistry = getImageRegistry(); if (imageRegistry == null) { return null; } Image image = imageRegistry.get(path); if (image == null) { ImageDescriptor imageDesc = createImageDescriptor(path, pluginId); image = imageDesc.createImage(); if (image == null) { image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } imageRegistry.put(path, image); } return image; }
From source file:de.jcup.egradle.eclipse.util.EclipseUtil.java
License:Apache License
/** * Get image by path from image registry. If not already registered a new * image will be created and registered. If not createable a fallback image * is used instead/*from www. j a v a 2 s . c o m*/ * * @param path * @param pluginId * - plugin id to identify which plugin image should be loaded * @return image */ public static Image getImage(String path, String pluginId) { ImageRegistry imageRegistry = getImageRegistry(); if (imageRegistry == null) { logWarning("No image registry found!"); return null; } Image image = imageRegistry.get(path); if (image == null) { ImageDescriptor imageDesc = createImageDescriptor(path, pluginId); image = imageDesc.createImage(); if (image == null) { image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); } imageRegistry.put(path, image); } return image; }