comparison artifacts/src/main/java/org/dive4elements/river/utils/ThemeUtil.java @ 6244:8b03a7589101

Enhance WSPLGEN legend's class names (#767).
author Christian Lins <christian.lins@intevation.de>
date Mon, 10 Jun 2013 13:43:53 +0200
parents 194a99865d73
children 7a9cbb3a3d5a
comparison
equal deleted inserted replaced
6243:9e4dc7f4d254 6244:8b03a7589101
17 import org.dive4elements.river.artifacts.model.MapserverStyle.Style; 17 import org.dive4elements.river.artifacts.model.MapserverStyle.Style;
18 import org.dive4elements.river.artifacts.resources.Resources; 18 import org.dive4elements.river.artifacts.resources.Resources;
19 19
20 import java.awt.Color; 20 import java.awt.Color;
21 import java.awt.Font; 21 import java.awt.Font;
22 import java.text.NumberFormat;
23 import java.util.Locale;
24 22
25 import org.apache.log4j.Logger; 23 import org.apache.log4j.Logger;
26 import org.w3c.dom.Document; 24 import org.w3c.dom.Document;
27 25
28 26
32 public class ThemeUtil { 30 public class ThemeUtil {
33 31
34 /** Private logger. */ 32 /** Private logger. */
35 private static Logger logger = 33 private static Logger logger =
36 Logger.getLogger(ThemeUtil.class); 34 Logger.getLogger(ThemeUtil.class);
35
36 private static final String MSG_ISOBATH_CLASS = "floodmap.isobath.class";
37
38 private static final String MSG_ISOBATH_LASTCLASS = "floodmap.isobath.lastclass";
37 39
38 public final static String XPATH_FILL_COLOR = 40 public final static String XPATH_FILL_COLOR =
39 "/theme/field[@name='fillcolor']/@default"; 41 "/theme/field[@name='fillcolor']/@default";
40 42
41 public final static String XPATH_LINE_COLOR = 43 public final static String XPATH_LINE_COLOR =
729 else { 731 else {
730 return "[DIFF] >= " + val; 732 return "[DIFF] >= " + val;
731 } 733 }
732 } 734 }
733 735
734 // FIXME: i18n 736 /**
737 * Creates a class name for the mapfile style that visualizes a floodmap.
738 * The class names are used in the map's legend.
739 *
740 * @param val Current isobath value.
741 * @param step Difference between to class values.
742 * @param idx Current class index that is being processed.
743 * @param maxIdx Highest class index.
744 * @param meta Caller meta object used to determine locale.
745 * @return
746 */
735 protected static String createWSPLGENClassName(float val, float step, int idx, int maxIdx, CallMeta meta) { 747 protected static String createWSPLGENClassName(float val, float step, int idx, int maxIdx, CallMeta meta) {
736 Locale locale = Resources.getLocale(meta); 748 assert meta != null : "CallMeta instance is null";
737 NumberFormat nf = NumberFormat.getInstance(locale); 749
738 if (idx < maxIdx) { 750 if (idx < maxIdx) {
739 return "[Differenz] >= " 751 return Resources.getMsg(meta, MSG_ISOBATH_CLASS,
740 + nf.format(val) 752 new Object[] {val, val + step});
741 + " m UND [Differenz] < "
742 + nf.format(val + step)
743 + " m";
744 } 753 }
745 else { 754 else {
746 return "[Differenz] >= " 755 return Resources.getMsg(meta, MSG_ISOBATH_LASTCLASS,
747 + nf.format(val) + " m"; 756 new Object[] {val});
748 } 757 }
749 } 758 }
750 759
751 760
752 public static String createMapserverStyle(Document theme) { 761 public static String createMapserverStyle(Document theme) {

http://dive4elements.wald.intevation.org