]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/ui/ChartItemIcon.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / ui / ChartItemIcon.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
3  * 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.charts.ui;
13
14 import java.awt.Color;
15
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.osgi.framework.Bundle;
18 import org.simantics.charts.Activator;
19 import org.simantics.utils.ui.gfx.CompositionImageDescriptor;
20 import org.simantics.utils.ui.gfx.RGBAdjustmentImageDescriptor;
21
22 public class ChartItemIcon {
23
24         public ImageDescriptor tagEmpty, tagLabel, binaryEmpty, binaryLabel;
25         
26         public ChartItemIcon() {
27                 Bundle bundle = Activator.getDefault().getBundle();
28         tagEmpty = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_empty.png"));
29         tagLabel = ImageDescriptor.createFromURL(bundle.getResource("icons/tag_label.png"));
30         binaryEmpty = ImageDescriptor.createFromURL(bundle.getResource("icons/binary_empty.png"));
31         binaryLabel = ImageDescriptor.createFromURL(bundle.getResource("icons/binary_label.png"));              
32         }
33         
34         public ImageDescriptor createIcon( boolean analog, Color color, boolean selected )
35         {
36         ImageDescriptor _base = analog ? tagEmpty : binaryEmpty;
37         ImageDescriptor _label = analog ? tagLabel : binaryLabel;
38         
39         if ( selected ) _base = new RGBAdjustmentImageDescriptor(_base, 200, 200, 300);
40         
41                 ImageDescriptor label = new RGBAdjustmentImageDescriptor(_label, color.getRed(), color.getGreen(), color.getBlue());
42                 ImageDescriptor icon = CompositionImageDescriptor.compose(_base, label);
43                 
44                 return icon;
45         }
46         
47 }