]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/MissingImageDescriptor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / MissingImageDescriptor.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.browsing.ui.graph.impl;
13
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.swt.graphics.ImageData;
16 import org.eclipse.swt.graphics.PaletteData;
17 import org.eclipse.swt.graphics.RGB;
18
19 /**
20  * A simple 16x16 white image descriptor for a missing image.
21  * <p>
22  * Use <code>MissingImageDescriptor.getInstance</code> to
23  * access the singleton instance maintained in an
24  * internal state variable.
25  * </p>
26  */
27 public class MissingImageDescriptor extends ImageDescriptor {
28     private static MissingImageDescriptor instance;
29
30     protected static final ImageData IMAGE_DATA = new ImageData(16, 16,
31             1, new PaletteData(new RGB[] { new RGB(255, 255, 255) }));
32
33     /**
34      * Constructs a new default image descriptor.
35      */
36     private MissingImageDescriptor() {
37         super();
38     }
39
40     /* (non-Javadoc)
41      * Method declared on ImageDesciptor.
42      */
43     @Override
44     public ImageData getImageData() {
45         return IMAGE_DATA;
46     }
47
48     /**
49      * Returns the shared default image descriptor instance.
50      *
51      * @return the image descriptor for a default image
52      */
53     public static MissingImageDescriptor getInstance() {
54         if (instance == null) {
55             instance = new MissingImageDescriptor();
56         }
57         return instance;
58     }
59 }