01: /*
02: * Copyright (C) 2007 Erik Swenson - erik@oreports.com
03: *
04: * This program is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU General Public License as published by the Free Software
06: * Foundation; either version 2 of the License, or (at your option) any later
07: * version.
08: *
09: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU General Public License along with
15: * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16: * Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19:
20: package org.efs.openreports.util;
21:
22: import java.util.Date;
23:
24: import org.efs.openreports.providers.DateProvider;
25: import org.jfree.data.xy.XYDataset;
26:
27: public class TimeSeriesURLGenerator extends XYURLGenerator {
28: private static final long serialVersionUID = 5402361405136241258L;
29:
30: private DateProvider dateProvider;
31:
32: public TimeSeriesURLGenerator(String prefix,
33: String seriesParameterName, String itemParameterName) {
34: super (prefix, seriesParameterName, itemParameterName);
35: }
36:
37: public String generateURL(XYDataset dataset, int series, int item) {
38: String url = prefix;
39: boolean firstParameter = url.indexOf("?") == -1;
40:
41: url = url + (firstParameter ? "?" : "&");
42: url = url
43: + seriesParameterName
44: + "="
45: + dataset.getSeriesKey(series)
46: + "&"
47: + itemParameterName
48: + "="
49: + dateProvider.formatDate(new Date((long) dataset
50: .getXValue(series, item)));
51:
52: return url;
53: }
54:
55: public void setDateProvider(DateProvider dateProvider) {
56: this.dateProvider = dateProvider;
57: }
58: }
|