List of usage examples for org.eclipse.jface.resource ImageDescriptor createFromImageData
@Deprecated public static ImageDescriptor createFromImageData(ImageData data)
From source file:org.jkiss.dbeaver.ui.DBIconBinary.java
License:Open Source License
public DBIconBinary(final String location, final ImageData data) { this.location = "binary:" + location; this.image = new Image(null, data); imageDescriptor = ImageDescriptor.createFromImageData(data); }
From source file:org.kalypso.ogc.gml.wms.provider.images.ImageCacheThread.java
License:Open Source License
private ImageDescriptor createScaledImage(final Image image) { final ImageData data = image.getImageData(); if (data.width <= 16 && data.height <= 16) return ImageDescriptor.createFromImageData(data); final ImageData scaledData = data.scaledTo(16, 16); return ImageDescriptor.createFromImageData(scaledData); }
From source file:org.kalypsodeegree_impl.graphics.sld.ExternalGraphic_Impl.java
License:Open Source License
/** * implementation taken from http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg10712.html<br/> * FIXME: move into helper//from w w w. jav a 2 s . c o m */ private static Image makeSWTImage(final java.awt.Image ai) throws Exception { // TODO transparent pixel (ATM transparent pixels are converted into black pixels) final int width = ai.getWidth(null); final int height = ai.getHeight(null); final BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); final Graphics2D g2d = bufferedImage.createGraphics(); g2d.drawImage(ai, 0, 0, null); g2d.dispose(); final int[] data = ((DataBufferInt) bufferedImage.getData().getDataBuffer()).getData(); final ImageData imageData = new ImageData(width, height, 24, new PaletteData(0xFF0000, 0x00FF00, 0x0000FF)); imageData.setPixels(0, 0, data.length, data, 0); final ImageDescriptor descriptor = ImageDescriptor.createFromImageData(imageData); return descriptor.createImage(); }
From source file:org.locationtech.udig.catalog.internal.wms.WMSGeoResourceImpl.java
License:Open Source License
private static ImageDescriptor loadImageDescriptor(WebMapServer wms, GetLegendGraphicRequest request, String desiredFormat) throws IOException, ServiceException { if (desiredFormat == null) { return null; }//www. j a va 2 s.c om try { ImageDescriptor imageDescriptor; request.setFormat(desiredFormat); if (wms.getCapabilities().getVersion().startsWith("1.3")) { // NO STYLE as it is optional } else { request.setStyle(""); //$NON-NLS-1$ } System.out.println(request.getFinalURL().toExternalForm()); GetLegendGraphicResponse response = wms.issueRequest(request); imageDescriptor = ImageDescriptor.createFromImageData(getImageData(response.getInputStream())); return imageDescriptor; } catch (SWTException exc) { WmsPlugin.trace("Icon is not available or has unsupported format", exc); //$NON-NLS-1$ return null; } }
From source file:org.mxupdate.eclipse.Activator.java
License:Apache License
@Override public void start(final BundleContext _context) throws Exception { try {//from w w w .j ava2 s. c o m super.start(_context); Activator.plugIn = this; this.console = new Console(); this.console.activate(); ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { this.console }); final Properties properties = new Properties(); final String propStr = this.getPreferenceStore().getString("pluginProperties"); //$NON-NLS-1$ if (propStr != null) { final InputStream is = new ByteArrayInputStream(propStr.getBytes()); properties.load(is); } // extract all admin type names final Set<String> admins = new HashSet<String>(); for (final Object keyObj : properties.keySet()) { final String key = keyObj.toString().replaceAll("\\..*", ""); //$NON-NLS-1$ //$NON-NLS-2$ admins.add(key); } // prepare image cache for (final String admin : admins) { final String prefix = properties.getProperty(admin + ".FilePrefix"); //$NON-NLS-1$ final String suffix = properties.getProperty(admin + ".FileSuffix"); //$NON-NLS-1$ final String iconStr = properties.getProperty(admin + ".Icon"); //$NON-NLS-1$ final byte[] bin = Base64.decodeBase64(iconStr.getBytes()); final InputStream in = new ByteArrayInputStream(bin); final ImageData ret = new ImageData(in); Map<String, ImageDescriptor> mapPrefix = Activator.IMAGEMAP.get(suffix); if (mapPrefix == null) { mapPrefix = new HashMap<String, ImageDescriptor>(); Activator.IMAGEMAP.put(suffix, mapPrefix); } mapPrefix.put(prefix, ImageDescriptor.createFromImageData(ret)); } } catch (final Throwable e) { e.printStackTrace(System.out); this.console.logError("ERROR", e); //$NON-NLS-1$ } this.adapter = new MXAdapter(this.getPreferenceStore(), this.console); }
From source file:org.mxupdate.eclipse.mxadapter.MXAdapter.java
License:Apache License
/** * Initializes the image descriptors read from the plug in properties. * * @see #imageMap// w w w . j a v a 2 s .com * @see #typeDef2Image */ protected void initImageDescriptors() { final Properties imageConfig = new Properties(); if (this.properties.getImageConfig() != null) { final InputStream is = new ByteArrayInputStream(this.properties.getImageConfig().getBytes()); try { imageConfig.load(is); } catch (final IOException e) { this.console.logError("MXAdapter.ExceptionInitImageDescriptorsLoadPropertiesFailed", e); } } // extract all admin type names final Set<String> admins = new HashSet<String>(); for (final Object keyObj : imageConfig.keySet()) { final String key = keyObj.toString().replaceAll("\\..*", ""); //$NON-NLS-1$ //$NON-NLS-2$ admins.add(key); } // remove already stored images this.typeDef2Image.clear(); this.imageMap.clear(); // prepare image cache for (final String admin : admins) { final String prefix = imageConfig.getProperty(admin + ".FilePrefix"); //$NON-NLS-1$ final String suffix = imageConfig.getProperty(admin + ".FileSuffix"); //$NON-NLS-1$ final String iconStr = imageConfig.getProperty(admin + ".Icon"); //$NON-NLS-1$ final byte[] bin = Base64.decodeBase64(iconStr.getBytes()); final InputStream in = new ByteArrayInputStream(bin); final ImageDescriptor imageDesriptor = ImageDescriptor.createFromImageData(new ImageData(in)); // mapping between file prefix / extension and image Map<String, ImageDescriptor> mapPrefix = this.imageMap.get(suffix); if (mapPrefix == null) { mapPrefix = new HashMap<String, ImageDescriptor>(); this.imageMap.put(suffix, mapPrefix); } mapPrefix.put(prefix, imageDesriptor); // mapping between type definition and image this.typeDef2Image.put(admin, imageDesriptor); } }
From source file:org.netxms.ui.eclipse.objecttools.api.ObjectToolsCache.java
License:Open Source License
/** * Reload object tools from server/*from ww w . j av a2s . c o m*/ */ private void reload() { try { List<ObjectTool> list = session.getObjectTools(); synchronized (objectTools) { objectTools.clear(); for (ObjectTool tool : list) { if (tool.getType() != ObjectTool.TYPE_LOCAL_COMMAND) objectTools.put(tool.getId(), tool); } } synchronized (icons) { icons.clear(); for (ObjectTool tool : list) { byte[] imageBytes = tool.getImageData(); if ((imageBytes == null) || (imageBytes.length == 0)) continue; ByteArrayInputStream input = new ByteArrayInputStream(imageBytes); try { icons.put(tool.getId(), ImageDescriptor.createFromImageData(new ImageData(input))); } catch (Exception e) { Activator.logError( String.format("Exception in ObjectToolsCache.reload(): toolId=%d, toolName=%s", //$NON-NLS-1$ tool.getId(), tool.getName()), e); } } } } catch (Exception e) { Activator.logError("Exception in ObjectToolsCache.reload()", e); //$NON-NLS-1$ } }
From source file:org.netxms.ui.eclipse.objecttools.propertypages.General.java
License:Open Source License
/** * Create icon/* w w w. j av a2 s . c o m*/ */ private void createIcon() { if (icon != null) { icon.dispose(); icon = null; } byte[] imageBytes = objectTool.getImageData(); if ((imageBytes == null) || (imageBytes.length == 0)) return; ByteArrayInputStream input = new ByteArrayInputStream(imageBytes); try { ImageDescriptor d = ImageDescriptor.createFromImageData(new ImageData(input)); icon = d.createImage(); } catch (Exception e) { Activator.logError("Exception in General.createIcon()", e); //$NON-NLS-1$ } }
From source file:org.neuro4j.studio.core.diagram.part.Neuro4jDiagramEditorPlugin.java
License:Apache License
public Image getImageFromLocalRegister(String name) { Image image = getImageRegistry().get(name); if (image != null) { return image; }// w w w. j av a 2 s . c o m if (excludeImageRegister.contains(name)) { return null; } InputStream is = ClassloaderHelper.loadImage(name); if (is != null) { ImageDescriptor id = ImageDescriptor.createFromImageData(new ImageData(is)); if (id != null) { image = id.createImage(); getImageRegistry().put(name, image); } } else { excludeImageRegister.add(name); } return image; }
From source file:org.nightlabs.base.ui.language.LanguageManager.java
License:Open Source License
public ImageDescriptor getFlag16x16ImageDescriptor(String languageID) { String imageRegistryKey = getImageRegistryKeyForFlag16x16(languageID); ImageRegistry imageRegistry = NLBasePlugin.getDefault().getImageRegistry(); ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(imageRegistryKey); if (imageDescriptor == null) { LanguageCf languageCf = getLanguage(languageID, true); byte[] flagData = languageCf._getFlagIcon16x16(); InputStream in = flagData != null ? new ByteArrayInputStream(flagData) : I18nUtil.class.getResourceAsStream("resource/country/Flag-fallback.16x16.png"); //$NON-NLS-1$ try {//from w w w.ja v a2s .c o m ImageData imageData = new ImageData(in); imageDescriptor = ImageDescriptor.createFromImageData(imageData); } finally { try { in.close(); } catch (IOException e) { throw new RuntimeException(e); } } imageRegistry.put(imageRegistryKey, imageDescriptor); } return imageDescriptor; }