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