<%@ page import="javax.ccpp.Profile" %> <%@ page import="javax.ccpp.Attribute" %> <% // All CSS jsps should statically include this file. %> <%-- ****************** Initialize Locales ****************** --%> <%! /* Map a locale to a hashmap of css rules for that locale */ private static java.util.HashMap localeRulesMap; /* Default css rules to apply to any locale not found in the map */ private static java.util.HashMap defaultLocaleRules; /* Initialize servlet variables with maps definine the css rules for each locale. */ /* this initialization will occur only once per server restart for performance. */ public void jspInit() { //----------------------------------- // Create maps for the font sizes //----------------------------------- java.util.HashMap xsmallFontSizes = new java.util.HashMap(); xsmallFontSizes.put("small","xx-small"); // normal is already the smallest xsmallFontSizes.put("normal","xx-small"); xsmallFontSizes.put("large","x-small"); xsmallFontSizes.put("xlarge","small"); xsmallFontSizes.put("xxlarge","medium"); java.util.HashMap smallFontSizes = new java.util.HashMap(); smallFontSizes.put("small","xx-small"); smallFontSizes.put("normal","x-small"); smallFontSizes.put("large","small"); smallFontSizes.put("xlarge","medium"); smallFontSizes.put("xxlarge","large"); java.util.HashMap normalFontSizes = new java.util.HashMap(); normalFontSizes.put("small","x-small"); normalFontSizes.put("normal","small"); normalFontSizes.put("large","medium"); normalFontSizes.put("xlarge","large"); normalFontSizes.put("xxlarge","x-large"); java.util.HashMap largerFontSizes = new java.util.HashMap(); largerFontSizes.put("small","small"); largerFontSizes.put("normal","medium"); largerFontSizes.put("large","large"); largerFontSizes.put("xlarge","x-large"); largerFontSizes.put("xxlarge","xx-large"); // In asian fonts, small is smallest legible size, so small and normal are the same. java.util.HashMap asianFontSizes = new java.util.HashMap(); asianFontSizes.put("small","small"); asianFontSizes.put("normal","small"); asianFontSizes.put("large","medium"); asianFontSizes.put("xlarge","large"); asianFontSizes.put("xxlarge","x-large"); //----------------------------------- // Create CSS rules maps. These are the variables that will be mapped to specific locales, // then looked for each locale and then referenced throughout the CSS jsps via JSTL EL. //----------------------------------- // Create the default rules map to base all the variants on, // and to use as a fallback if an unknown locale is requested defaultLocaleRules = new java.util.HashMap(); defaultLocaleRules.put("fontFamilySansSerif","sans-serif"); defaultLocaleRules.put("fontFamilySansSerifLarge","sans-serif"); defaultLocaleRules.put("fontFamilyMonospace","monospace"); defaultLocaleRules.put("fontSize", normalFontSizes); defaultLocaleRules.put("isRTL", Boolean.FALSE); defaultLocaleRules.put("bidiLeft","left"); defaultLocaleRules.put("bidiRight","right"); java.util.HashMap latin1Rules = new java.util.HashMap(defaultLocaleRules); latin1Rules.put("fontFamilySansSerif","Verdana, Arial, Helvetica, sans-serif"); latin1Rules.put("fontFamilySansSerifLarge","Arial, Helvetica, Verdana, sans-serif"); latin1Rules.put("fontSize", smallFontSizes); java.util.HashMap bidiRules = new java.util.HashMap(defaultLocaleRules); bidiRules.put("isRTL", Boolean.TRUE); bidiRules.put("bidiLeft","right"); bidiRules.put("bidiRight","left"); bidiRules.put("bidiImageRTL","_rtl"); java.util.HashMap arRules = new java.util.HashMap(bidiRules); arRules.put("fontSize", largerFontSizes); // iw and he are the same so have only one map - // this is so bold fonts will display propertly java.util.HashMap iwRules = new java.util.HashMap(bidiRules); iwRules.put("fontSize", largerFontSizes); java.util.HashMap asianRules = new java.util.HashMap(defaultLocaleRules); asianRules.put("fontSize", asianFontSizes); // No font family is to be specified asianRules.put("fontFamilySansSerif", null); asianRules.put("fontFamilySansSerifLarge", null); java.util.HashMap jaRules = new java.util.HashMap(asianRules); jaRules.put("fontFamilySansSerif","MS PGothic"); jaRules.put("fontFamilySansSerifLarge","MS PGothic"); java.util.HashMap koRules = new java.util.HashMap(asianRules); koRules.put("fontFamilySansSerif","Gulim"); koRules.put("fontFamilySansSerifLarge","Gulim"); // zh needs to specify a special font for the // Select form element or there are problems in some browsers java.util.HashMap zhRules = new java.util.HashMap(asianRules); zhRules.put("fontFamilySansSerifSelect","SimSun-18030"); java.util.HashMap thRules = new java.util.HashMap(defaultLocaleRules); thRules.put("fontSize", largerFontSizes); // Create map between each locale and its rules map localeRulesMap = new java.util.HashMap(); // bidi locales localeRulesMap.put("ar",arRules); localeRulesMap.put("iw", iwRules); localeRulesMap.put("he", iwRules); // latin1 locales localeRulesMap.put("en", latin1Rules); localeRulesMap.put("da", latin1Rules); localeRulesMap.put("de", latin1Rules); localeRulesMap.put("es", latin1Rules); localeRulesMap.put("fi", latin1Rules); localeRulesMap.put("fr", latin1Rules); localeRulesMap.put("it", latin1Rules); localeRulesMap.put("nl", latin1Rules); localeRulesMap.put("no", latin1Rules); localeRulesMap.put("pt", latin1Rules); localeRulesMap.put("pt_BR", latin1Rules); localeRulesMap.put("sv", latin1Rules); // other latin and slavic // These languages use the same general settings and font sizes as Latin-I // but must have generic font families (i.e. NOT Verdana, Arial, etc.) localeRulesMap.put("ca", defaultLocaleRules); localeRulesMap.put("cs", defaultLocaleRules); localeRulesMap.put("el", defaultLocaleRules); localeRulesMap.put("hr", defaultLocaleRules); localeRulesMap.put("hu", defaultLocaleRules); localeRulesMap.put("pl", defaultLocaleRules); localeRulesMap.put("ro", defaultLocaleRules); localeRulesMap.put("ru", defaultLocaleRules); localeRulesMap.put("sk", defaultLocaleRules); localeRulesMap.put("sl", defaultLocaleRules); localeRulesMap.put("tr", defaultLocaleRules); localeRulesMap.put("uk", defaultLocaleRules); // asian locales localeRulesMap.put("ja", jaRules); localeRulesMap.put("ko", koRules); localeRulesMap.put("zh", zhRules); localeRulesMap.put("zh_TW", asianRules); // other locales localeRulesMap.put("th", thRules); } // end jspInit() %> <% // Store the rules map and default rules in the request request.setAttribute("localeRulesMap",localeRulesMap); request.setAttribute("defaultRules",defaultLocaleRules); %> <%-- Set Browser variables --%> <c:set var="isIE" value="${requestScope.browserVendor eq 'Microsoft'}" scope="request"/> <c:set var="isMoz" value="${requestScope.browserVendor ne 'Microsoft'}" scope="request"/> <%-- Set locale based CSS rules variables --%> <c:set var="cssRules" value="${requestScope.localeRulesMap[requestScope.locale]}" scope="request"/> <%-- If locale isnt found fallback to default--%> <c:if test="${empty requestScope.cssRules}"> <c:set var="cssRules" value="${requestScope.defaultRules}" scope="request"/> </c:if> <%-- /* DEBUGGING INFO param.browser: ${param.browser} param.locale: ${param.locale} isIE: ${requestScope.isIE} isMoz: ${requestScope.isMoz} cssRules: ${requestScope.cssRules} */ --%> <%-- ****************** Load ColorPalette ****************** --%> <%-- Load the color palette property file into a string--%> <c-rt:import url="colors/${requestScope.colorPalette}.properties" var="colorPropertiesStr" scope="page" /> <% // Parse the string into a Properties object (which is a map and can be referenced with EL easily) java.io.StringBufferInputStream sbis = new java.io.StringBufferInputStream((String)pageContext.findAttribute("colorPropertiesStr")); java.util.Properties colorProperties = new java.util.Properties(); colorProperties.load(sbis); request.setAttribute("colors", colorProperties); %>