1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.charts.ui;
14 import java.awt.Color;
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;
22 public class ChartItemIcon {
24 public ImageDescriptor tagEmpty, tagLabel, binaryEmpty, binaryLabel;
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"));
34 public ImageDescriptor createIcon( boolean analog, Color color, boolean selected )
36 ImageDescriptor _base = analog ? tagEmpty : binaryEmpty;
37 ImageDescriptor _label = analog ? tagLabel : binaryLabel;
39 if ( selected ) _base = new RGBAdjustmentImageDescriptor(_base, 200, 200, 300);
41 ImageDescriptor label = new RGBAdjustmentImageDescriptor(_label, color.getRed(), color.getGreen(), color.getBlue());
42 ImageDescriptor icon = CompositionImageDescriptor.compose(_base, label);