Package de.innovationgate.eclipse.editors.helpers

Source Code of de.innovationgate.eclipse.editors.helpers.ColorManager

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.helpers;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;

public class ColorManager {

  private Map<RGB, Color> _colorTable = new HashMap<RGB, Color>();
 
  private static ColorManager _instance;
 
  public static ColorManager getInstance() {
    if (_instance == null) {
      _instance = new ColorManager();
    }
    return _instance;
  }

  private ColorManager() {   
  }
 
  public Color getColor(RGB rgb) {
    Color color = (Color) _colorTable.get(rgb);
    if (color == null) {
      color = new Color(Display.getCurrent(), rgb);
      _colorTable.put(rgb, color);
    }
    return color;
  }
}
TOP

Related Classes of de.innovationgate.eclipse.editors.helpers.ColorManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.