64c7ec5d235df5f86c7e93b28415ad95e770d99c
1 /**********************************************************************
2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.impl
;
15 import java
.net
.MalformedURLException
;
18 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
19 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IImage
;
21 import org
.eclipse
.swt
.graphics
.Image
;
24 * Default implementation of the IImage interface.
30 public class ImageImpl
implements IImage
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
39 protected Image fImage
= null;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 * Default constructor.
47 * @param file A file name of image file.
49 public ImageImpl(String file
) {
50 fImage
= createResourceImage(file
);
56 * @param image THe image to copy
58 public ImageImpl(Image image
) {
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
66 * Returns Image object from file name.
68 * @param name File name of image file
69 * @return image object or <code>null</code>
71 public Image
getResourceImage(String name
) {
72 return createResourceImage(name
);
76 public Object
getImage() {
81 public void dispose() {
88 * Returns Image object from file name.
90 * @param name File name of image file
91 * @return image object or <code>null</code>
93 private static Image
createResourceImage(String name
) {
95 URL BASIC_URL
= new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
96 URL url
= new URL(BASIC_URL
, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + name
);//$NON-NLS-1$
97 ImageDescriptor img
= ImageDescriptor
.createFromURL(url
);
98 return img
.createImage();
99 } catch (MalformedURLException e
) {
100 Activator
.getDefault().logError("Error opening image file", e
); //$NON-NLS-1$
This page took 0.032166 seconds and 5 git commands to generate.