a5002366b059204bc96812165a65263857788a2d
1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.impl
;
16 import java
.net
.MalformedURLException
;
19 import org
.eclipse
.core
.runtime
.IStatus
;
20 import org
.eclipse
.core
.runtime
.Status
;
21 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
22 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.TmfUiPlugin
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.drawings
.IImage
;
24 import org
.eclipse
.swt
.graphics
.Image
;
27 * Default implementation of the IImage interface.
33 public class ImageImpl
implements IImage
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 protected Image img
= null;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 * Default constructor.
47 * @param file A file name of image file.
49 public ImageImpl(String file
) {
50 img
= getResourceImage(file
);
56 * @param img_ THe image to copy
58 public ImageImpl(Image img_
) {
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
) {
73 URL BASIC_URL
= new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
74 URL url
= new URL(BASIC_URL
, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + _name
);//$NON-NLS-1$
75 ImageDescriptor img
= ImageDescriptor
.createFromURL(url
);
76 return img
.createImage();
77 } catch (MalformedURLException e
) {
78 TmfUiPlugin
.getDefault().getLog().log(new Status(IStatus
.ERROR
, TmfUiPlugin
.PLUGIN_ID
, "Error opening image file", e
)); //$NON-NLS-1$
85 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage#getImage()
88 public Object
getImage() {
94 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage#dispose()
97 public void dispose() {
This page took 0.049244 seconds and 5 git commands to generate.