cbf60ecafff2e45e561ca1cd91f1fe346001bf30
1 /**********************************************************************
2 * Copyright (c) 2005, 2012 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
);
77 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage#getImage()
80 public Object
getImage() {
86 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage#dispose()
89 public void dispose() {
96 * Returns Image object from file name.
98 * @param name File name of image file
99 * @return image object or <code>null</code>
101 private static Image
createResourceImage(String name
) {
103 URL BASIC_URL
= new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
104 URL url
= new URL(BASIC_URL
, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + name
);//$NON-NLS-1$
105 ImageDescriptor img
= ImageDescriptor
.createFromURL(url
);
106 return img
.createImage();
107 } catch (MalformedURLException e
) {
108 Activator
.getDefault().logError("Error opening image file", e
); //$NON-NLS-1$
This page took 0.032772 seconds and 5 git commands to generate.