Improve test cases, speed and accuracy.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / drawings / impl / ImageImpl.java
CommitLineData
73005152
BH
1/**********************************************************************
2 * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
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
7 * $Id: ImageImpl.java,v 1.3 2008/01/24 02:28:50 apnan Exp $
8 *
9 * Contributors:
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13package org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl;
14
e6ace8bb 15import java.net.MalformedURLException;
73005152
BH
16import java.net.URL;
17
18import org.eclipse.jface.resource.ImageDescriptor;
19import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
20import org.eclipse.swt.graphics.Image;
21
22/**
23 * @author sveyrier
24 *
25 */
26public class ImageImpl implements IImage {
27
28 protected Image img = null;
29
30 public ImageImpl(String file) {
31 img = getResourceImage(file);
32 }
33
34 public ImageImpl(Image img_) {
35 img = img_;
36 }
e6ace8bb 37
73005152
BH
38 public Image getResourceImage(String _name) {
39 try {
e6ace8bb 40 URL BASIC_URL = new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
73005152
BH
41 URL url = new URL(BASIC_URL, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + _name);//$NON-NLS-1$
42 ImageDescriptor img = ImageDescriptor.createFromURL(url);
43 return img.createImage();
e6ace8bb 44 } catch (MalformedURLException E) {
73005152
BH
45 System.err.println(E);
46 }
47 return null;
48 }
49
50 @Override
51 public Object getImage() {
52 return img;
53 }
54
55 @Override
56 public void dispose() {
57 if (img != null)
58 img.dispose();
59 }
60}
This page took 0.02785 seconds and 5 git commands to generate.