Author: aron.gombas Date: 2005-11-20 08:21:12 -0500 (Sun, 20 Nov 2005) New Revision: 1602 Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/cc/CcMonitoringPortlet.java trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/sf/SfMonitoringPortlet.java trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/svn/SvnMonitoringPortlet.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataHandler.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcConstants.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraConstants.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/sf/SfServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java trunk/labs/kosmos/web-server/WEB-INF/web.xml Log: Initial impl. of localized charts Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/cc/CcMonitoringPortlet.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/cc/CcMonitoringPortlet.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/cc/CcMonitoringPortlet.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -66,7 +66,7 @@ log.error("Unable to connect to the service", ex); } - // get file-release list if the service was successfully set-up + // get project list if the service was successfully set-up Date timestamp = null; List<CcProject> projects = null; if(service != null) { Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/sf/SfMonitoringPortlet.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/sf/SfMonitoringPortlet.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/sf/SfMonitoringPortlet.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -65,7 +65,7 @@ log.error("Unable to connect to the service", ex); } - // get release list if the service was successfully set-up + // get file-release list if the service was successfully set-up Date timestamp = null; List<SfRelease> releases = null; if(service != null) { Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/svn/SvnMonitoringPortlet.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/svn/SvnMonitoringPortlet.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/portlet/svn/SvnMonitoringPortlet.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -66,7 +66,7 @@ log.error("Unable to connect to the service", ex); } - // get file-release list if the service was successfully set-up + // get repository list if the service was successfully set-up Date timestamp = null; List<SvnRepository> repositories = null; if(service != null) { Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/AbstractKosmosService.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -9,10 +9,17 @@ import java.io.InputStream; import java.util.Date; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.ResourceBundle; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.web.context.WebApplicationContext; /** * Each Kosmos service must extend this baseclass. Services are implemented as POJOs. @@ -20,12 +27,15 @@ * @author <a href="mailto:aro...@mi...">Aron Gombas</a> * @version $Id$ */ -public abstract class AbstractKosmosService { +public abstract class AbstractKosmosService implements ApplicationContextAware { private final static Log log = LogFactory.getLog(AbstractKosmosService.class); /** Cache timeout in milliseconds: a new request over this period will receive the cached result. */ - private static final int CACHE_TIMEOUT = 10*60*1000;// TODO should be externally configurable + private static final int CACHE_TIMEOUT = 10*60*1000; + /** Spring web-application context. */ + WebApplicationContext ctx; + /** * Caches the result to return by the concrete service. * The key is a service-specific unique string (e.g. a URL or dir name) and the value is a service-specific object. @@ -37,6 +47,10 @@ /** Pluggable cached data store implementation. */ private CachedDataStore store; + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + ctx = (WebApplicationContext)applicationContext; + } + public void setStore(CachedDataStore store) { this.store = store; } @@ -51,13 +65,18 @@ throw new IllegalStateException("Timestamp was not initialized yet. Call the service method before!"); return timestamp; - } + } + /** Updates the timestamp at cache updates. */ + private void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** * Returns an object through the cache. * @see #cache */ - protected Object getFromCache(Object key, CachedDataHandler handler) { + protected Object getFromCache(Object key, CachedDataHandler handler) { // return info from cache if not expired yet and available Date now = new Date(); Object value = cache.get(key); @@ -67,7 +86,7 @@ } // retrieve info in case of cache miss - timestamp = now; + setTimestamp(now); if((value == null) || !handler.isDataUptodate(key)) { log.debug(String.format("Reloading \"%s\"...", key)); value = handler.reloadData(key); @@ -81,6 +100,20 @@ return value; } + /** TODO */ + protected String getResourcexxx(String baseName, String key) {// TODO rename + ResourceBundle res = null; + + // TODO lazy-init + if(res == null) { + String locale = ctx.getServletContext().getInitParameter("locale"); + log.info(" =======================================> locale: " + locale); + res = StringUtils.isBlank(locale) ? ResourceBundle.getBundle(baseName) : ResourceBundle.getBundle(baseName, new Locale(locale)); + } + + return res.getString(key); + } + /** * Stores the passed stream to an implementation-dependent "storage". * @return the absolute URL that points to the resulted file. Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataHandler.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataHandler.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataHandler.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -19,9 +19,17 @@ * still up-to-date, even if there was a cache miss caused by timeout. * Implement it simply by returning <code>false</code> if it's not possible to detect * whether the data is still up-to-date without recalculating everything. + * + * @param language can be ignored if the data and the resources referenced by the + * data are not language-dependent. */ - public boolean isDataUptodate(Object key); + public boolean isDataUptodate(Object key);// TODO language ne legyen itt es csak azt vizsgalja, h az adatforras megvaltozott-e => isDataSourceUnchanged() - /** Reloads the service-specific data in the case of stale data (cache miss). */ + /** + * Reloads the service-specific data in the case of stale data (cache miss). + * + * @param language can be ignored if the data and the resources referenced by the + * data are not language-dependent. + */ public Object reloadData(Object key); } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/CachedDataStore.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -21,5 +21,5 @@ * Stores the passed stream to an implementation-dependent "storage". * @return the absolute URL that points to the resulted file. */ - public String storeFile(String fileName, InputStream in) throws Exception; // TODO exception? + public String storeFile(String fileName, InputStream in) throws Exception; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcConstants.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcConstants.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcConstants.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -6,6 +6,7 @@ */ package hu.midori.kosmos.server.cc; +import java.awt.Color; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -20,7 +21,7 @@ public final static DateFormat CC_BUILD_DATEFORMAT = new SimpleDateFormat("yyyyMMddhhmmss"); /** Color code for the test categories. */ - public final static int SUCCESS_COLOR = 0x00FF00; - public final static int FAILURE_COLOR = 0xFF0000; - public final static int ERROR_COLOR = 0xDD0000; + public final static Color SUCCESS_COLOR = new Color(0x00FF00); + public final static Color FAILURE_COLOR = new Color(0xFF0000); + public final static Color ERROR_COLOR = new Color(0xDD0000); } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/cc/CcServiceImpl.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -14,6 +14,7 @@ import hu.midori.kosmos.server.AbstractKosmosService; import hu.midori.kosmos.server.CachedDataHandler; import hu.midori.kosmos.server.util.ChartUtils; +import hu.midori.kosmos.server.util.ColorCodedKey; import hu.midori.kosmos.server.util.ScrapingUtils; import java.io.ByteArrayInputStream; @@ -128,16 +129,16 @@ testCases.add(new CcTest(result_, className, testCaseName)); } - + // generate chart - List<Map.Entry<Integer, Integer>> testsPerCategory = new ArrayList<Map.Entry<Integer, Integer>>(); + List<Map.Entry<ColorCodedKey, Integer>> testsPerCategory = new ArrayList<Map.Entry<ColorCodedKey, Integer>>(); int success = tests - errors - failures; if(success > 0) - testsPerCategory.addAll(Collections.singletonMap(CcConstants.SUCCESS_COLOR, success).entrySet()); + testsPerCategory.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.cc.ccmonitoringportlet", "ccproject.testsSucceded"), CcConstants.SUCCESS_COLOR), success).entrySet()); if(failures > 0) - testsPerCategory.addAll(Collections.singletonMap(CcConstants.FAILURE_COLOR, failures).entrySet()); + testsPerCategory.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.cc.ccmonitoringportlet", "ccproject.failures"), CcConstants.FAILURE_COLOR), failures).entrySet()); if(errors > 0) - testsPerCategory.addAll(Collections.singletonMap(CcConstants.ERROR_COLOR, errors).entrySet()); + testsPerCategory.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.cc.ccmonitoringportlet", "ccproject.errors"), CcConstants.ERROR_COLOR), errors).entrySet()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.collectionToPieDataset(testsPerCategory)), out); @@ -160,10 +161,10 @@ /** Finds the latest <i>CruiseControl</i> logfile in the dir. */ protected File findLatestLog(String dirName) { - File dir = new File(dirName); - if(!dir.isDirectory()) - throw new IllegalArgumentException(String.format("Unable to process CruiseControl logs from \"%s\"", dir)); - File files[] = dir.listFiles(new FilenameFilter() { + File monitoredDir = new File(dirName); + if(!monitoredDir.isDirectory()) + throw new IllegalArgumentException(String.format("Unable to process CruiseControl logs from \"%s\"", monitoredDir)); + File files[] = monitoredDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".xml"); } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraConstants.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraConstants.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraConstants.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -6,6 +6,8 @@ */ package hu.midori.kosmos.server.jira; +import java.awt.Color; + /** * <i>JIRA</i>-related constants. * @@ -14,17 +16,17 @@ */ public class JiraConstants { /** Color codes for the issue statuses. */ - public final static int OPEN_COLOR = 0xFF0000; - public final static int CODING_IN_PROGRESS_COLOR = 0xFFFF00; - public final static int REOPENED_COLOR = 0xDD0000; - public final static int RESOLVED_COLOR = 0x00FF00; - public final static int CLOSED_COLOR = 0xDDDDDD; + public final static Color OPEN_COLOR = new Color(0xFF0000); + public final static Color CODING_IN_PROGRESS_COLOR = new Color(0xFFFF00); + public final static Color REOPENED_COLOR = new Color(0xDD0000); + public final static Color RESOLVED_COLOR = new Color(0x00FF00); + public final static Color CLOSED_COLOR = new Color(0xDDDDDD); /** Color codes for issue priorities. */ - public final static int BLOCKER_COLOR = 0xFF0000; - public final static int CRITICAL_COLOR = 0xEE0000; - public final static int MAJOR_COLOR = 0xDD0000; - public final static int MINOR_COLOR = 0xFFFF00; - public final static int TRIVIAL_COLOR = 0xEEEE00; - public final static int OPTIONAL_COLOR = 0xDDDDDD; + public final static Color BLOCKER_COLOR = new Color(0xFF0000); + public final static Color CRITICAL_COLOR = new Color(0xEE0000); + public final static Color MAJOR_COLOR = new Color(0xDD0000); + public final static Color MINOR_COLOR = new Color(0xFFFF00); + public final static Color TRIVIAL_COLOR = new Color(0xEEEE00); + public final static Color OPTIONAL_COLOR = new Color(0xDDDDDD); } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/jira/JiraServiceImpl.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -11,6 +11,7 @@ import hu.midori.kosmos.server.AbstractKosmosService; import hu.midori.kosmos.server.CachedDataHandler; import hu.midori.kosmos.server.util.ChartUtils; +import hu.midori.kosmos.server.util.ColorCodedKey; import hu.midori.kosmos.server.util.ScrapingUtils; import java.io.ByteArrayInputStream; @@ -58,9 +59,12 @@ * </ul> */ private class JiraDataHandler implements CachedDataHandler { - /** There is no quick way to decide if the data is stale. */ + /** + * Returns <code>false</code> as there is no way to decide if the data is stale + * without completely recalculating everything. + */ public boolean isDataUptodate(Object key) { - return false; + return false; } public Object reloadData(Object key) { @@ -218,36 +222,36 @@ String openIssuesPerAssigneeChartUrl = storeFile(prefix + "_open_issues_per_assignee.png", new ByteArrayInputStream(out.toByteArray())); // generate issues-per-status chart - List<Map.Entry<Integer, Integer>> issuesPerStatusMap = new ArrayList<Map.Entry<Integer, Integer>>(); + List<Map.Entry<ColorCodedKey, Integer>> issuesPerStatusMap = new ArrayList<Map.Entry<ColorCodedKey, Integer>>(); if(openIssues > 0) - issuesPerStatusMap.addAll(Collections.singletonMap(JiraConstants.OPEN_COLOR, openIssues).entrySet()); + issuesPerStatusMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.openIssues"), JiraConstants.OPEN_COLOR), openIssues).entrySet()); if(codingInProgressIssues > 0) - issuesPerStatusMap.addAll(Collections.singletonMap(JiraConstants.CODING_IN_PROGRESS_COLOR, codingInProgressIssues).entrySet()); + issuesPerStatusMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.codingInProgressIssues"), JiraConstants.CODING_IN_PROGRESS_COLOR), codingInProgressIssues).entrySet()); if(reopenedIssues > 0) - issuesPerStatusMap.addAll(Collections.singletonMap(JiraConstants.REOPENED_COLOR, reopenedIssues).entrySet()); + issuesPerStatusMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.reopenedIssues"), JiraConstants.REOPENED_COLOR), reopenedIssues).entrySet()); if(resolvedIssues > 0) - issuesPerStatusMap.addAll(Collections.singletonMap(JiraConstants.RESOLVED_COLOR, resolvedIssues).entrySet()); + issuesPerStatusMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.resolvedIssues"), JiraConstants.RESOLVED_COLOR), resolvedIssues).entrySet()); if(closedIssues > 0) - issuesPerStatusMap.addAll(Collections.singletonMap(JiraConstants.CLOSED_COLOR, closedIssues).entrySet()); + issuesPerStatusMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.closedIssues"), JiraConstants.CLOSED_COLOR), closedIssues).entrySet()); out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.collectionToPieDataset(issuesPerStatusMap)), out); String issuesPerStatusChartUrl = storeFile(prefix + "_issues_per_status.png", new ByteArrayInputStream(out.toByteArray())); // generate issues-per-priority chart - List<Map.Entry<Integer, Integer>> openIssuesPerPriorityMap = new ArrayList<Map.Entry<Integer, Integer>>(); + List<Map.Entry<ColorCodedKey, Integer>> openIssuesPerPriorityMap = new ArrayList<Map.Entry<ColorCodedKey, Integer>>(); if(blockerOpenIssues > 0) - openIssuesPerPriorityMap.addAll(Collections.singletonMap(JiraConstants.BLOCKER_COLOR, blockerOpenIssues).entrySet()); + openIssuesPerPriorityMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.blockerOpenIssues"), JiraConstants.BLOCKER_COLOR), blockerOpenIssues).entrySet()); if(criticalOpenIssues > 0) - openIssuesPerPriorityMap.addAll(Collections.singletonMap(JiraConstants.CRITICAL_COLOR, criticalOpenIssues).entrySet()); + openIssuesPerPriorityMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.criticalOpenIssues"), JiraConstants.CRITICAL_COLOR), criticalOpenIssues).entrySet()); if(majorOpenIssues > 0) - openIssuesPerPriorityMap.addAll(Collections.singletonMap(JiraConstants.MAJOR_COLOR, majorOpenIssues).entrySet()); + openIssuesPerPriorityMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.majorOpenIssues"), JiraConstants.MAJOR_COLOR), majorOpenIssues).entrySet()); if(minorOpenIssues > 0) - openIssuesPerPriorityMap.addAll(Collections.singletonMap(JiraConstants.MINOR_COLOR, minorOpenIssues).entrySet()); + openIssuesPerPriorityMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.minorOpenIssues"), JiraConstants.MINOR_COLOR), minorOpenIssues).entrySet()); if(trivialOpenIssues > 0) - openIssuesPerPriorityMap.addAll(Collections.singletonMap(JiraConstants.TRIVIAL_COLOR, trivialOpenIssues).entrySet()); + openIssuesPerPriorityMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.trivialOpenIssues"), JiraConstants.TRIVIAL_COLOR), trivialOpenIssues).entrySet()); if(optionalOpenIssues > 0) - openIssuesPerPriorityMap.addAll(Collections.singletonMap(JiraConstants.OPTIONAL_COLOR, optionalOpenIssues).entrySet()); + openIssuesPerPriorityMap.addAll(Collections.singletonMap(new ColorCodedKey(getResourcexxx("hu.midori.kosmos.server.jira.jiramonitoringportlet", "jiraproject.optionalOpenIssues"), JiraConstants.OPTIONAL_COLOR), optionalOpenIssues).entrySet()); out.reset(); ChartUtils.writeChartAsPng(ChartUtils.generateColorCodedPieChart(ChartUtils.collectionToPieDataset(openIssuesPerPriorityMap)), out); Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/sf/SfServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/sf/SfServiceImpl.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/sf/SfServiceImpl.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -48,6 +48,7 @@ * from the <i>SourceForge</i> pages. */ private class SfDataHandler implements CachedDataHandler { + /** Returns <code>false</code> as it is very cheap to reload the SF page again. */ public boolean isDataUptodate(Object key) { return false; } Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/svn/SvnServiceImpl.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -96,7 +96,7 @@ } } - public Object reloadData(Object key) { + public Object reloadData(Object key) {// TODO localize charts String url = key.toString(); List<SvnRepository> repositories = new ArrayList<SvnRepository>(); Modified: trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java =================================================================== --- trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/src/java/hu/midori/kosmos/server/util/ChartUtils.java 2005-11-20 13:21:12 UTC (rev 1602) @@ -21,7 +21,6 @@ import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; -import org.jfree.chart.labels.PieSectionLabelGenerator; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.general.DefaultPieDataset; @@ -69,10 +68,9 @@ } /** - * Returns the pie-chart generated from the passed data. - * The keys in the dataset are <code>Integer</code> objects to use as - * RGB color values with the appropriate pie sections. It also means - * that the keys won't appear in the pie labels. + * Returns the color-coded pie-chart generated from the passed data. + * The keys in the dataset are <code>ColorCodedKey</code> objects that + * specify both the pie section labels and the pie section colors. */ public static JFreeChart generateColorCodedPieChart(PieDataset dataset) { // generate chart @@ -81,14 +79,7 @@ // apply color-codes PiePlot plot = (PiePlot)chart.getPlot(); for(int i = 0; i < dataset.getItemCount(); i++) - plot.setSectionPaint(i, new Color((Integer)dataset.getKey(i))); - - // remove keys from the labels - plot.setLabelGenerator(new PieSectionLabelGenerator() { - public String generateSectionLabel(PieDataset dataset, Comparable key) { - return dataset.getValue(key).toString(); - } - }); + plot.setSectionPaint(i, ((ColorCodedKey)dataset.getKey(i)).getColor()); return chart; } Modified: trunk/labs/kosmos/web-server/WEB-INF/web.xml =================================================================== --- trunk/labs/kosmos/web-server/WEB-INF/web.xml 2005-11-20 11:54:52 UTC (rev 1601) +++ trunk/labs/kosmos/web-server/WEB-INF/web.xml 2005-11-20 13:21:12 UTC (rev 1602) @@ -8,7 +8,12 @@ <display-name>Kosmos Services Servlet</display-name> <description>Server component of Kosmos. Runs as a regular web application.</description> - + + <context-param> + <param-name>locale</param-name> + <param-value>en</param-value> + </context-param> + <servlet> <servlet-name>kosmos-services</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> @@ -18,4 +23,5 @@ <servlet-name>kosmos-services</servlet-name> <url-pattern>/kosmos-services/*</url-pattern> </servlet-mapping> + </web-app> |