00001 package org.swtchart.ext.internal.properties;
00002
00003 import java.util.HashMap;
00004 import java.util.Map;
00005 import java.util.Map.Entry;
00006
00007 import org.eclipse.swt.graphics.Color;
00008 import org.eclipse.swt.graphics.Font;
00009
00013 public class PropertiesResources {
00014
00016 private Map<String, Font> fonts;
00017
00019 private Map<String, Color> colors;
00020
00024 public PropertiesResources() {
00025 fonts = new HashMap<String, Font>();
00026 colors = new HashMap<String, Color>();
00027 }
00028
00036 public Font getFont(String key) {
00037 return fonts.get(key);
00038 }
00039
00047 public Color getColor(String key) {
00048 return colors.get(key);
00049 }
00050
00064 public void put(String key, Font font) {
00065 Font oldFont = fonts.get(key);
00066 if (oldFont != null) {
00067 oldFont.dispose();
00068 }
00069 fonts.put(key, font);
00070 }
00071
00082 public void put(String key, Color color) {
00083 Color oldColor = colors.get(key);
00084 if (oldColor != null) {
00085 oldColor.dispose();
00086 }
00087 colors.put(key, color);
00088 }
00089
00097 public void removeFont(String key) {
00098 Font font = fonts.get(key);
00099 if (font != null) {
00100 fonts.remove(key);
00101 font.dispose();
00102 }
00103 }
00104
00112 public void removeColor(String key) {
00113 Color color = colors.get(key);
00114 if (color != null) {
00115 colors.remove(key);
00116 color.dispose();
00117 }
00118 }
00119
00123 public void dispose() {
00124 for (Entry<String, Font> entry : fonts.entrySet()) {
00125 entry.getValue().dispose();
00126 }
00127 for (Entry<String, Color> entry : colors.entrySet()) {
00128 entry.getValue().dispose();
00129 }
00130 }
00131 }