/** * Get an image using the provided classLoader and path. An attempt will be made to load the image with the * classLoader first using SVG (regardless of extension), and falling back to PNG. If the image cannot be * loaded with the provided classLoader, the search path will be expanded to include the file system (ui/images). * * @param display the device to render the image to * @param classLoader the classLoader to use to load the image resource * @param filename the path to the image * @param width the width to scale the image to * @param height the height to scale the image to * @return an swt Image with width/height dimensions */ public static Image getImage( Display display, ClassLoader classLoader, String filename, int width, int height ) { SwtUniversalImage u = getUniversalImage( display, classLoader, filename ); return u.getAsBitmapForSize( display, width, height ); }
/** * Loads an image from a location once. The second time, the image comes from a cache. Because of this, it's important * to never dispose of the image you get from here. (easy!) The images are automatically disposed when the application * ends. * * @param location the location of the image resource to load * @param classLoader the ClassLoader to use to locate resources * @param width The height to resize the image to * @param height The width to resize the image to * @return the loaded image */ public Image getImage( String location, ClassLoader classLoader, int width, int height ) { Image image = imageMap.get( location ); if ( image == null ) { SwtUniversalImage svg = SwtSvgImageUtil.getUniversalImage( display, classLoader, location ); image = new Image( display, svg.getAsBitmapForSize( display, width, height ), SWT.IMAGE_COPY ); svg.dispose(); imageMap.put( location, image ); } return image; }
try { ClassLoader classLoader = registry.getClassLoader( plugin ); image = SwtSvgImageUtil.getUniversalImage( display, classLoader, filename ); } catch ( Throwable t ) { log.logError( "Error occurred loading image [" + filename + "] for plugin " + plugin.getIds()[ 0 ], t );
try { ClassLoader classLoader = registry.getClassLoader( step ); image = SwtSvgImageUtil.getUniversalImage( display, classLoader, filename ); } catch ( Throwable t ) { log.logError( "Error occurred loading image [" + filename + "] for plugin " + step, t );
SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler .getProperty( "BOL_image" ) ); SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler .getProperty( "STR_image" ) ); SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler .getProperty( "DUM_image" ) ); SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler .getProperty( "MIS_image" ) ); imageBackEnabled = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler.getProperty( "BackEnabled" ) ); imageBackDisabled = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler.getProperty( "BackDisabled" ) ); imageForwardEnabled = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler.getProperty( "ForwardEnabled" ) ); imageForwardDisabled = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler.getProperty( "ForwardDisabled" ) ); imageRefreshEnabled = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler.getProperty( "RefreshEnabled" ) ); imageRefreshDisabled = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), BasePropertyHandler.getProperty( "RefreshDisabled" ) );
private Image getHadoopClusterImage( Display display ) { final SwtUniversalImage swtImage = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), "hadoop_clusters.svg" ); Image image = swtImage.getAsBitmapForSize( display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE ); display.addListener( SWT.Dispose, new Listener() { public void handleEvent( Event event ) { swtImage.dispose(); } } ); return image; } }
private Image getHadoopClusterImage( Display display ) { final SwtUniversalImage swtImage = SwtSvgImageUtil.getUniversalImage( display, getClass().getClassLoader(), "hadoop_clusters.svg" ); Image image = swtImage.getAsBitmapForSize( display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE ); display.addListener( SWT.Dispose, event -> swtImage.dispose() ); return image; } }