| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.utils.img; |
| |
| import java.io.InputStream; |
| import java.net.URI; |
| |
| import com.vaadin.server.Resource; |
| |
| public class ImageService { |
| |
| public static Resource getImage(String resourceURL) { |
| return ExternalPluginResource.getResource(ExternalPluginResource.IMAGE_RESOURCEPATH+resourceURL); |
| } |
| |
| public static Resource getImage(String resourceURL, boolean small) { |
| return ExternalPluginResource.getResource(ExternalPluginResource.IMAGE_RESOURCEPATH+resourceURL, small); |
| } |
| |
| public static String getImageURL(String resourceURL) { |
| return ExternalPluginResource.getURL(ExternalPluginResource.IMAGE_RESOURCEPATH+resourceURL, false); |
| } |
| |
| public static InputStream getImageInputStream(String resourceURL) { |
| return ExternalPluginResource.getInputStream(ExternalPluginResource.IMAGE_RESOURCEPATH+resourceURL, false); |
| } |
| |
| |
| /* ********************************************************************************************** */ |
| /** Overloaded version of the method with possibility to determine whether default image |
| * shell be returned in case of requested image missing, and if yes, its size. |
| * |
| * @param resourceURL URL to image file |
| * @param withDefault Get default image in case of requested image missing |
| * @param small Return small sized default image (no effect when {@code withDefault} is false) |
| * |
| * @return Reference to image instance if requested image file was found, reference to instance of |
| * default image if requested image file was not found and {@code withDefault} is true, |
| * null otherwise. |
| * |
| * @since @D 150916, gu |
| * @date @D yymmdd, name |
| */ /* ******************************************************************************************* */ |
| public static InputStream getImageInputStream ( String resourceURL, boolean withDefault, boolean small ) { |
| InputStream input = null; |
| |
| if ( withDefault ) |
| input = ExternalPluginResource.getInputStream( ExternalPluginResource.IMAGE_RESOURCEPATH + resourceURL, small ); |
| else |
| input = ExternalPluginResource.getInputStream( ExternalPluginResource.IMAGE_RESOURCEPATH + resourceURL, small, DefaultPicture.NONE ); |
| |
| return input; |
| } |
| |
| |
| } |