ingo@1022: /* ingo@1022: * Copyright (c) 2010 by Intevation GmbH ingo@1022: * ingo@1022: * This program is free software under the LGPL (>=v2.1) ingo@1022: * Read the file LGPL.txt coming with the software for details ingo@1022: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1022: */ ingo@1022: tim@29: package de.intevation.gnv.action.sessionmodel; tim@30: ingo@967: import java.text.NumberFormat; ingo@967: tim@30: import java.util.HashMap; ingo@967: import java.util.Locale; tim@30: import java.util.Map; tim@30: tim@29: /** ingo@690: * Stores key-value pairs used to save user input for changing diagram ingo@690: * attributes. sascha@699: * sascha@684: * @author Tim Englich tim@29: */ tim@29: public class DiagrammOptions { tim@29: ingo@967: private Map values = new HashMap(); tim@36: tim@29: /** tim@29: * Constructor tim@29: */ tim@29: public DiagrammOptions() { tim@29: super(); tim@29: } tim@30: tim@29: /** tim@954: * Returns the Value to a given Key tim@964: * @param key The key of the value that should be returned. ingo@690: * @return the value. tim@29: */ ingo@967: public Object getValue(String key) { tim@30: return this.values.get(key); tim@29: } tim@36: ingo@690: tim@29: /** ingo@967: * Returns the value as string. ingo@967: * @param key The key of the value that should be returned. ingo@967: * @param locale A locale object used to format numbers. ingo@967: * @return the value as string. ingo@967: */ ingo@967: public String getValue(String key, Locale locale) { ingo@967: Object obj = values.get(key); ingo@967: ingo@967: if (obj instanceof Double && locale != null) { ingo@967: Double value = (Double) obj; ingo@967: NumberFormat format = NumberFormat.getNumberInstance(locale); ingo@967: ingo@967: return format.format(value); ingo@967: } ingo@967: ingo@967: return (String) obj; ingo@967: } ingo@967: ingo@967: /** ingo@690: * Set a value with the given key. ingo@690: * ingo@690: * @param key The given key. ingo@690: * @param value The value to be stored. tim@29: */ ingo@967: public void setValue(String key, Object value) { ingo@967: values.put(key, value); tim@29: } sascha@683: } sascha@700: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :