Contribution for Bug352466: [TMF] Implement UML2 Sequence Diagram
[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
15import java.net.URL;
16
17import org.eclipse.jface.resource.ImageDescriptor;
18import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IImage;
19import org.eclipse.swt.graphics.Image;
20
21/**
22 * @author sveyrier
23 *
24 */
25public class ImageImpl implements IImage {
26
27 protected Image img = null;
28
29 public ImageImpl(String file) {
30 img = getResourceImage(file);
31 }
32
33 public ImageImpl(Image img_) {
34 img = img_;
35 }
36
37 protected static URL BASIC_URL = null;
38 static {
39 // URL to get images from plug-ins
40 // perhaps we can found better code to load images ...
41 // but at this time I know this:
42 try {
43 BASIC_URL = new URL("platform", "localhost", "plugin");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
44 } catch (Exception E) {
45 System.err.println(E);
46 }
47 }
48
49 public Image getResourceImage(String _name) {
50 try {
51 // FIXME: bhufmann: don't use org.eclipse.linuxtools.tmf.ui
52 URL url = new URL(BASIC_URL, "plugin/org.eclipse.linuxtools.tmf.ui/icons/" + _name);//$NON-NLS-1$
53 ImageDescriptor img = ImageDescriptor.createFromURL(url);
54 return img.createImage();
55 } catch (Exception E) {
56 System.err.println(E);
57 }
58 return null;
59 }
60
61 @Override
62 public Object getImage() {
63 return img;
64 }
65
66 @Override
67 public void dispose() {
68 if (img != null)
69 img.dispose();
70 }
71}
This page took 0.025724 seconds and 5 git commands to generate.