]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemIcon.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / ui / ChartItemIcon.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.charts.ui;\r
13 \r
14 import java.awt.Color;\r
15 \r
16 import org.eclipse.jface.resource.ImageDescriptor;\r
17 import org.osgi.framework.Bundle;\r
18 import org.simantics.charts.Activator;\r
19 import org.simantics.utils.ui.gfx.CompositionImageDescriptor;\r
20 import org.simantics.utils.ui.gfx.RGBAdjustmentImageDescriptor;\r
21 \r
22 public class ChartItemIcon {\r
23 \r
24         public ImageDescriptor tagEmpty, tagLabel, binaryEmpty, binaryLabel;\r
25         \r
26         public ChartItemIcon() {\r
27                 Bundle bundle = Activator.getDefault().getBundle();\r
28         tagEmpty = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_empty.png"));\r
29         tagLabel = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_label.png"));\r
30         binaryEmpty = ImageDescriptor.createFromURL(bundle.getResource("icons/binary_empty.png"));\r
31         binaryLabel = ImageDescriptor.createFromURL(bundle.getResource("icons/binary_label.png"));              \r
32         }\r
33         \r
34         public ImageDescriptor createIcon( boolean analog, Color color, boolean selected )\r
35         {\r
36         ImageDescriptor _base = analog ? tagEmpty : binaryEmpty;\r
37         ImageDescriptor _label = analog ? tagLabel : binaryLabel;\r
38         \r
39         if ( selected ) _base = new RGBAdjustmentImageDescriptor(_base, 200, 200, 300);\r
40         \r
41                 ImageDescriptor label = new RGBAdjustmentImageDescriptor(_label, color.getRed(), color.getGreen(), color.getBlue());\r
42                 ImageDescriptor icon = CompositionImageDescriptor.compose(_base, label);\r
43                 \r
44                 return icon;\r
45         }\r
46         \r
47 }\r