Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java @ 3464:0b9b2a0c4e64
Point labels can have a background color now.
flys-artifacts/trunk@5132 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 26 Jul 2012 10:02:07 +0000 |
parents | b0ba96bbf01d |
children | f7e6b35f0b5c |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Thu Jul 26 09:56:50 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java Thu Jul 26 10:02:07 2012 +0000 @@ -24,119 +24,104 @@ public class ThemeUtil { private static Logger logger = - Logger.getLogger(ThemeUtil.class); + Logger.getLogger(ThemeUtil.class); public final static String XPATH_FILL_COLOR = - "/theme/field[@name='fillcolor']/@default"; + "/theme/field[@name='fillcolor']/@default"; public final static String XPATH_LINE_COLOR = - "/theme/field[@name='linecolor']/@default"; + "/theme/field[@name='linecolor']/@default"; public static final String XPATH_LINE_SIZE = - "/theme/field[@name='linesize']/@default"; + "/theme/field[@name='linesize']/@default"; public static final String XPATH_LINE_STYLE = - "/theme/field[@name='linetype']/@default"; + "/theme/field[@name='linetype']/@default"; public static final String XPATH_POINT_SIZE = - "/theme/field[@name='pointsize']/@default"; + "/theme/field[@name='pointsize']/@default"; public static final String XPATH_POINT_COLOR = - "/theme/field[@name='pointcolor']/@default"; + "/theme/field[@name='pointcolor']/@default"; public final static String XPATH_SHOW_BORDER = - "/theme/field[@name='showborder']/@default"; + "/theme/field[@name='showborder']/@default"; public final static String XPATH_SHOW_POINTS = - "/theme/field[@name='showpoints']/@default"; + "/theme/field[@name='showpoints']/@default"; public final static String XPATH_SHOW_LINE = - "/theme/field[@name='showlines']/@default"; + "/theme/field[@name='showlines']/@default"; public final static String XPATH_SHOW_VERTICAL_LINE = - "/theme/field[@name='showverticalline']/@default"; + "/theme/field[@name='showverticalline']/@default"; public final static String XPATH_SHOW_HORIZONTAL_LINE = - "/theme/field[@name='showhorizontalline']/@default"; + "/theme/field[@name='showhorizontalline']/@default"; public final static String XPATH_SHOW_LINE_LABEL = - "/theme/field[@name='showlinelabel']/@default"; + "/theme/field[@name='showlinelabel']/@default"; public final static String XPATH_SHOW_POINT_LABEL = "/theme/field[@name='showpointlabel']/@default"; - public final static String XPATH_LINE_LABEL_FONT = - "/theme/field[@name='linelabelfont']/@default"; - - public final static String XPATH_LINE_LABEL_COLOR = - "/theme/field[@name='linelabelcolor']/@default"; - - public final static String XPATH_LINE_LABEL_SIZE = - "/theme/field[@name='linelabelsize']/@default"; - - public final static String XPATH_LINE_LABEL_STYLE = - "/theme/field[@name='linelabelstyle']/@default"; - - public final static String XPATH_LINE_LABEL_BGCOLOR = - "/theme/field[@name='linelabelbgcolor']/@default"; - - public final static String XPATH_LINE_LABEL_SHOWBG = - "/theme/field[@name='linelabelshowbg']/@default"; - public final static String XPATH_SHOW_WIDTH = - "/theme/field[@name='showwidth']/@default"; + "/theme/field[@name='showwidth']/@default"; public final static String XPATH_SHOW_LEVEL = - "/theme/field[@name='showwidth']/@default"; + "/theme/field[@name='showwidth']/@default"; public final static String XPATH_TRANSPARENCY = - "/theme/field[@name='transparent']/@default"; + "/theme/field[@name='transparent']/@default"; public final static String XPATH_TRANSPARENCY_ALPHA = - "/theme/field[@name='alpha']/@default"; + "/theme/field[@name='alpha']/@default"; public final static String XPATH_SHOW_AREA = - "/theme/field[@name='showarea']/@default"; + "/theme/field[@name='showarea']/@default"; public final static String XPATH_SHOW_MIDDLE_HEIGHT = - "/theme/field[@name='showmiddleheight']/@default"; - - public final static String XPATH_TEXT_COLOR = - "/theme/field[@name='textcolor']/@default"; + "/theme/field[@name='showmiddleheight']/@default"; - public final static String XPATH_TEXT_SIZE = - "/theme/field[@name='textsize']/@default"; + public final static String XPATH_LABEL_FONT_COLOR = + "/theme/field[@name='labelfontcolor']/@default"; - public final static String XPATH_TEXT_FONT = - "/theme/field[@name='font']/@default"; + public final static String XPATH_LABEL_FONT_SIZE = + "/theme/field[@name='labelfontsize']/@default"; - public final static String XPATH_TEXT_STYLE = - "/theme/field[@name='textstyle']/@default"; + public final static String XPATH_LABEL_FONT_FACE = + "/theme/field[@name='labelfontface']/@default"; + + public final static String XPATH_LABEL_FONT_STYLE = + "/theme/field[@name='labelfontstyle']/@default"; public final static String XPATH_TEXT_ORIENTATION = - "/theme/field[@name='textorientation']/@default"; + "/theme/field[@name='textorientation']/@default"; - public final static String XPATH_TEXT_BACKGROUND = - "/theme/field[@name='backgroundcolor']/@default"; + public final static String XPATH_LABEL_BGCOLOR = + "/theme/field[@name='labelbgcolor']/@default"; - public final static String XPATH_SHOW_BACKGROUND = - "/theme/field[@name='showbackground']/@default"; + public final static String XPATH_LABEL_SHOW_BACKGROUND = + "/theme/field[@name='labelshowbg']/@default"; + + public final static String XPATH_BACKGROUND_COLOR = + "/theme/field[@name='backgroundcolor']/@default"; public final static String XPATH_SYMBOL = - "/theme/field[@name='symbol']/@default"; + "/theme/field[@name='symbol']/@default"; public final static String XPATH_SHOW_MINIMUM = - "/theme/field[@name='showminimum']/@default"; + "/theme/field[@name='showminimum']/@default"; public final static String XPATH_SHOW_MAXIMUM = - "/theme/field[@name='showmaximum']/@default"; + "/theme/field[@name='showmaximum']/@default"; public final static String XPATH_WSPLGEN_FIELDS = - "/theme[@name='WSPLGEN']/field"; + "/theme[@name='WSPLGEN']/field"; /** XPATH to bandwidth field. */ public final static String XPATH_BANDWIDTH = - "/theme/field[@name='bandwidth']/@default"; + "/theme/field[@name='bandwidth']/@default"; /** Parse string to be boolean with default if empty or unrecognized. */ @@ -298,12 +283,7 @@ public static int parseTextSize(Document theme) { - return parseTextSize(theme, XPATH_TEXT_SIZE); - } - - - public static int parseLineLabelSize(Document theme) { - return parseTextSize(theme, XPATH_LINE_LABEL_SIZE); + return parseTextSize(theme, XPATH_LABEL_FONT_SIZE); } @@ -384,25 +364,12 @@ } - /** Parse color for line label(s text). */ - public static Color parseLineLabelTextColor(Document theme) { - return parseRGB(getLineLabelTextColorString(theme)); - } - - /** Parse bg color for line label(s text). */ - public static Color parseLineLabelBGColor(Document theme) { - return parseRGB(getLineLabelBGColorString(theme)); - } - - // TODO showbg and bg color for linelabels - - /** * Parses the font. * @param theme The theme. */ public static Font parseTextFont(Document theme) { - String font = XMLUtils.xpathString(theme, XPATH_TEXT_FONT, null); + String font = XMLUtils.xpathString(theme, XPATH_LABEL_FONT_FACE, null); if (font == null || font.length() == 0) { return null; } @@ -413,20 +380,6 @@ return f; } - /** Parse font (name, size and style) for linelabels. */ - public static Font parseLineLabelFont(Document theme) { - String font = XMLUtils.xpathString(theme, XPATH_LINE_LABEL_FONT, null); - if (font == null || font.length() == 0) { - return null; - } - - int size = parseLineLabelSize(theme); - int style = parseLineLabelStyle(theme); - - Font f = new Font (font, style, size); - return f; - } - /** * Parses the text style, defaults to 'Font.PLAIN'. @@ -451,12 +404,7 @@ public static int parseTextStyle(Document theme) { - return parseTextStyle(theme, XPATH_TEXT_STYLE); - } - - - public static int parseLineLabelStyle(Document theme) { - return parseTextStyle(theme, XPATH_LINE_LABEL_STYLE); + return parseTextStyle(theme, XPATH_LABEL_FONT_STYLE); } @@ -465,6 +413,7 @@ return parseBoolean(show, false); } + public static boolean parseShowLevel(Document theme) { String show = XMLUtils.xpathString(theme, XPATH_SHOW_LEVEL, null); return parseBoolean(show, false); @@ -490,7 +439,7 @@ * @param theme The theme. */ public static Color parseTextBackground(Document theme) { - String color = getBackgroundColorString(theme); + String color = getLabelBackgroundColorString(theme); if (color == null || color.length() == 0) { return Color.WHITE; } @@ -503,19 +452,8 @@ * false. * @param theme The theme. */ - public static boolean parseShowTextBackground(Document theme) { - String show = XMLUtils.xpathString(theme, XPATH_SHOW_BACKGROUND, null); - return parseBoolean(show, false); - } - - - /** - * Parses the attribute whether to show line labels background or not, - * defaults to false. - * @param theme The theme. - */ - public static boolean parseShowLineLabelBG(Document theme) { - String show = XMLUtils.xpathString(theme, XPATH_LINE_LABEL_SHOWBG, null); + public static boolean parseLabelShowBackground(Document theme) { + String show = XMLUtils.xpathString(theme, XPATH_LABEL_SHOW_BACKGROUND, null); return parseBoolean(show, false); } @@ -578,37 +516,40 @@ return XMLUtils.xpathString(theme, XPATH_LINE_COLOR, null); } + /** Get show border as string. */ public static String getShowBorderString(Document theme) { return XMLUtils.xpathString(theme, XPATH_SHOW_BORDER, null); } + /** Get fill color as string. */ public static String getFillColorString(Document theme) { return XMLUtils.xpathString(theme, XPATH_FILL_COLOR, null); } + + public static String getLabelBackgroundColorString(Document theme) { + return XMLUtils.xpathString(theme, XPATH_LABEL_BGCOLOR, null); + } + + public static String getBackgroundColorString(Document theme) { - return XMLUtils.xpathString(theme, XPATH_TEXT_BACKGROUND, null); + return XMLUtils.xpathString(theme, XPATH_BACKGROUND_COLOR, null); } public static String getTextColorString(Document theme) { - return XMLUtils.xpathString(theme, XPATH_TEXT_COLOR, null); + String textColor = XMLUtils.xpathString(theme, XPATH_LABEL_FONT_COLOR, null); + return textColor; } - public static String getLineLabelTextColorString(Document theme) { - return XMLUtils.xpathString(theme, XPATH_LINE_LABEL_COLOR, null); - } - - public static String getLineLabelBGColorString(Document theme) { - return XMLUtils.xpathString(theme, XPATH_LINE_LABEL_BGCOLOR, null); - } public static String getSymbol(Document theme) { return XMLUtils.xpathString(theme, XPATH_SYMBOL, null); } + public static String getTransparencyString(Document theme) { return XMLUtils.xpathString(theme, XPATH_TRANSPARENCY, null); } @@ -638,14 +579,17 @@ return parseRGB(getFillColorString(theme)); } + public static boolean parseShowBorder(Document theme) { return parseBoolean(getShowBorderString(theme), false); } + public static boolean parseTransparency(Document theme) { return parseBoolean(getTransparencyString(theme), false); } + /** * Gets color from color field. * @param theme the theme document. @@ -663,6 +607,7 @@ return parseBoolean(getShowMinimum(theme), false); } + public static boolean parseShowMaximum(Document theme) { return parseBoolean(getShowMaximum(theme), false); } @@ -670,9 +615,9 @@ public static String createWSPLGENStyle(Document theme) { NodeList categories = (NodeList) XMLUtils.xpath( - theme, - XPATH_WSPLGEN_FIELDS, - XPathConstants.NODESET); + theme, + XPATH_WSPLGEN_FIELDS, + XPathConstants.NODESET); return createWSPLGENStyle(categories).toString(); } @@ -726,7 +671,7 @@ public static String createMapserverStyle(Document theme) { String symbol = getSymbol(theme); - String backcolor = getBackgroundColorString(theme); + String backcolor = getLabelBackgroundColorString(theme); String linecolor = getLineColorString(theme); int linewidth = parseLineWidth(theme);