source: vlo/branches/to-wicket-1.6-twagoo/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/Theme.java @ 4214

Last change on this file since 4214 was 4214, checked in by twagoo, 10 years ago

Made Theme serializable; session contained objects need to be serializable

File size: 4.1 KB
Line 
1package eu.clarin.cmdi.vlo;
2
3import eu.clarin.cmdi.vlo.config.VloConfig;
4import java.io.Serializable;
5
6/**
7 *
8 * @author keeloo
9 *
10 * A theme is composed from a page title, a CSS file, two image files, and a
11 * partner link map relating coordinates in the right image to partner links
12 */
13public class Theme implements Serializable {
14
15    public final String name, pageTitle, topLeftImage, topRightImage, cssFile,
16            partnerLinkMap;
17
18    /**
19     * Compose a theme<br><br>
20     *
21     * @param themeName the name of the theme to be composed
22     */
23    public Theme(String themeName) {
24
25        String prefix = VloConfig.getReverseProxyPrefix();
26
27        if (themeName.matches("CLARIN-D")) {
28            // select the CLARIN-D theme's components
29
30            pageTitle = "CLARIN-D Virtual Language Observatory - Resources";
31            topLeftImage = "Images/topleft-clarin-d.png";
32            topRightImage = "Images/topright-clarin-d.png";
33            if (prefix.length() == 0) {
34                cssFile = "css/clarin-d.css";
35            } else {
36                cssFile = prefix + "css/clarin-d.css";
37            }
38            partnerLinkMap = getClarinDPartnerLinkMap();
39            name = "CLARIN-D";
40        } else {
41            // select the default theme elements
42            pageTitle = "CLARIN Virtual Language Observatory - Resources";
43            topLeftImage = "Images/topleftvlo.gif";
44            topRightImage = "Images/toprightvlo.gif";
45
46            if (prefix.length() == 0) {
47                cssFile = "css/main.css";
48            } else {
49                cssFile = prefix + "css/main.css";
50            }
51            partnerLinkMap = getDefaultPartnerLinkMap();
52            name = "defaultTheme";
53        }
54        // remember the theme as a persistent parameter
55        // getPersistentParameters.put("theme", name);
56    }
57
58    /**
59     * Compose a map to be included in the HTML document, designating the
60     * positions of the links to partner web sites
61     *
62     * @return the map
63     */
64    private String getDefaultPartnerLinkMap() {
65        String map;
66
67        map = "<map name=\"partnerLinks\">\n";
68        map = appendToPartnerLinkMap(map,
69                "114.00,65,167.50,104",
70                "http://www.clarin.eu",
71                "clarin link");
72        map = appendToPartnerLinkMap(map,
73                "177.00,65,214,104",
74                "http://wals.info",
75                "wals link");
76        map = appendToPartnerLinkMap(map,
77                "229,65,279,104",
78                "http://linguistlist.org",
79                "linguistlist link");
80        map = appendToPartnerLinkMap(map,
81                "290,65,320,104",
82                "http://www.elra.info",
83                "elra link");
84        map = appendToPartnerLinkMap(map,
85                "328,65,370,104",
86                "http://www.mpi.nl/dobes",
87                "dobes link");
88        map = appendToPartnerLinkMap(map,
89                "379,65,428,104",
90                "http://www.dfki.de/web",
91                "dfki link");
92        map = appendToPartnerLinkMap(map,
93                "434,65,484,104",
94                "http://www.delaman.org",
95                "deleman link");
96
97        map = map + "</map>";
98
99        return map;
100    }
101
102    /**
103     * Compose a map to be included in the HTML document, designating the
104     * positions of the links to partner web sites
105     *
106     * @return the map
107     */
108    private String getClarinDPartnerLinkMap() {
109        String map;
110
111        map = "<map name=\"partnerLinks\">\n";
112        map = map + "</map>";
113
114        return map;
115    }
116
117    /**
118     * Add a link location to the map indicating the partner links
119     *
120     * @param map
121     * @return
122     */
123    private String appendToPartnerLinkMap(String map, String coordinates,
124            String URL, String alt) {
125
126        if (map == null) {
127            map = "<map name=\"partnerLinks\">\n";
128        } else if (map.equals("")) {
129            map = "<map name=\"partnerLinks\">\n";
130        }
131
132        map = map + "<AREA SHAPE=\"rect\" COORDS=\"" + coordinates + "\" HREF=\""
133                + URL + "\" alt=\"" + alt + "\"/>\n";
134
135        return map;
136    }
137}
Note: See TracBrowser for help on using the repository browser.