/******************************************************************************* * Copyright (c) 2015 Pivotal, Inc. * 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: * Pivotal, Inc. and others - initial API and implementation *******************************************************************************/ package org.springframework.ide.eclipse.editor.support.util; 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 { public static final RGB GREY = new RGB(128,128,128); public static final RGB CYAN = new RGB(0,128,128); private static ColorManager instance; protected Map<RGB,Color> fColorTable = new HashMap<RGB,Color>(); public Color getColor(RGB rgb) { Color color = fColorTable.get(rgb); if (color == null) { color = new Color(Display.getCurrent(), rgb); fColorTable.put(rgb, color); } return color; } public static ColorManager getInstance() { if (instance==null) { instance = new ColorManager(); } return instance; } }