org.jfree.data.time.TimePeriodValuesCollection Java Examples
The following examples show how to use
org.jfree.data.time.TimePeriodValuesCollection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TimePeriodChartHyperlinkProvider.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; TimePeriodValuesCollection dataset = (TimePeriodValuesCollection) itemEntity.getDataset(); TimePeriodValues series = dataset.getSeries(itemEntity.getSeriesIndex()); Map<TimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey()); if (serieHyperlinks != null) { TimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem()); printHyperlink = serieHyperlinks.get(timePeriod); } } return printHyperlink; }
Example #2
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A test for bug report 1161340. I wasn't able to reproduce the problem * with this test. */ public void test1161340() { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); TimePeriodValues v1 = new TimePeriodValues("V1"); v1.add(new Day(11, 3, 2005), 1.2); v1.add(new Day(12, 3, 2005), 3.4); dataset.addSeries(v1); assertEquals(1, dataset.getSeriesCount()); dataset.removeSeries(v1); assertEquals(0, dataset.getSeriesCount()); TimePeriodValues v2 = new TimePeriodValues("V2"); v1.add(new Day(5, 3, 2005), 1.2); v1.add(new Day(6, 3, 2005), 3.4); dataset.addSeries(v2); assertEquals(1, dataset.getSeriesCount()); }
Example #3
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Tests the equals() method. */ public void testEquals() { TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); TimePeriodValuesCollection c2 = new TimePeriodValuesCollection(); assertTrue(c1.equals(c2)); c1.setXPosition(TimePeriodAnchor.END); assertFalse(c1.equals(c2)); c2.setXPosition(TimePeriodAnchor.END); assertTrue(c1.equals(c2)); TimePeriodValues v1 = new TimePeriodValues("Test"); TimePeriodValues v2 = new TimePeriodValues("Test"); c1.addSeries(v1); assertFalse(c1.equals(c2)); c2.addSeries(v2); assertTrue(c1.equals(c2)); }
Example #4
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getDomainBounds() method. */ public void testGetDomainBoundsWithoutInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Range r = dataset.getDomainBounds(false); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(false); assertEquals(1500.0, r.getLowerBound(), EPSILON); assertEquals(1500.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(false); assertEquals(1500.0, r.getLowerBound(), EPSILON); assertEquals(2250.0, r.getUpperBound(), EPSILON); }
Example #5
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A test for bug report 1161340. I wasn't able to reproduce the problem * with this test. */ public void test1161340() { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); TimePeriodValues v1 = new TimePeriodValues("V1"); v1.add(new Day(11, 3, 2005), 1.2); v1.add(new Day(12, 3, 2005), 3.4); dataset.addSeries(v1); assertEquals(1, dataset.getSeriesCount()); dataset.removeSeries(v1); assertEquals(0, dataset.getSeriesCount()); TimePeriodValues v2 = new TimePeriodValues("V2"); v1.add(new Day(5, 3, 2005), 1.2); v1.add(new Day(6, 3, 2005), 3.4); dataset.addSeries(v2); assertEquals(1, dataset.getSeriesCount()); }
Example #6
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Tests the equals() method. */ public void testEquals() { TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); TimePeriodValuesCollection c2 = new TimePeriodValuesCollection(); assertTrue(c1.equals(c2)); c1.setXPosition(TimePeriodAnchor.END); assertFalse(c1.equals(c2)); c2.setXPosition(TimePeriodAnchor.END); assertTrue(c1.equals(c2)); TimePeriodValues v1 = new TimePeriodValues("Test"); TimePeriodValues v2 = new TimePeriodValues("Test"); c1.addSeries(v1); assertFalse(c1.equals(c2)); c2.addSeries(v2); assertTrue(c1.equals(c2)); }
Example #7
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getDomainBounds() method. */ public void testGetDomainBoundsWithoutInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Range r = dataset.getDomainBounds(false); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(false); assertEquals(1500.0, r.getLowerBound(), EPSILON); assertEquals(1500.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(false); assertEquals(1500.0, r.getLowerBound(), EPSILON); assertEquals(2250.0, r.getUpperBound(), EPSILON); }
Example #8
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some more checks for the getDomainBounds() method. * * @see #testGetDomainBoundsWithoutInterval() */ public void testGetDomainBoundsWithInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Range r = dataset.getDomainBounds(true); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(2000.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(3000.0, r.getUpperBound(), EPSILON); }
Example #9
Source File: ChartUtil.java From ezScrum with GNU General Public License v2.0 | 6 votes |
private XYDataset createBarDataset() { final TimePeriodValuesCollection result = new TimePeriodValuesCollection(); Set<String> nameSet = this.m_dataSetMap.keySet(); for (String name : nameSet) { final TimePeriodValues series = new TimePeriodValues(name); Map<Date, ? extends Number> map = m_dataSetMap.get(name); Iterator<Date> ir = map.keySet().iterator(); while (ir.hasNext()) { Date key = ir.next(); series.add(new SimpleTimePeriod(key, new Date(key.getTime() + (m_interval * OneDay))), map.get(key)); } result.addSeries(series); } return result; }
Example #10
Source File: TimePeriodDatasetLabelGenerator.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String generateLabel(XYDataset dataset, int series, int item) { Comparable<?> seriesName = dataset.getSeriesKey(series); Map<TimePeriod, String> labels = labelsMap.get(seriesName); if(labels != null) { return labels.get(((TimePeriodValuesCollection)dataset).getSeries(series).getTimePeriod(item)); } return super.generateLabel( dataset, series, item ); }
Example #11
Source File: JRFillTimePeriodDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Dataset getCustomDataset() { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); if (seriesNames != null) { for(int i = 0; i < seriesNames.size(); i++) { Comparable<?> seriesName = seriesNames.get(i); dataset.addSeries(seriesMap.get(seriesName)); } } return dataset; }
Example #12
Source File: ConvertChartContext.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
private XYDataset createTimePeriodDataset() { if (sampleTimePeriodDataset == null) { TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Day today = new Day(); TimePeriodValues series1 = new TimePeriodValues("First"); TimePeriodValues series2 = new TimePeriodValues("Second"); for (int i = 0; i < 24; i++) { Minute m0 = new Minute(0, new Hour(i, today)); Minute m1 = new Minute(15, new Hour(i, today)); Minute m2 = new Minute(30, new Hour(i, today)); Minute m3 = new Minute(45, new Hour(i, today)); Minute m4 = new Minute(0, new Hour(i + 1, today)); series1.add(new SimpleTimePeriod(m0.getStart(), m1.getStart()), Math.random()); series2.add(new SimpleTimePeriod(m1.getStart(), m2.getStart()), Math.random()); series1.add(new SimpleTimePeriod(m2.getStart(), m3.getStart()), Math.random()); series2.add(new SimpleTimePeriod(m3.getStart(), m4.getStart()), Math.random()); } dataset.addSeries(series1); dataset.addSeries(series2); sampleTimePeriodDataset = dataset; } return sampleTimePeriodDataset; }
Example #13
Source File: TimePeriodValuesCollectionTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some more checks for the getDomainBounds() method. * * @see #testGetDomainBoundsWithoutInterval() */ public void testGetDomainBoundsWithInterval() { // check empty dataset TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); Range r = dataset.getDomainBounds(true); assertNull(r); // check dataset with one time period TimePeriodValues s1 = new TimePeriodValues("S1"); s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); dataset.addSeries(s1); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(2000.0, r.getUpperBound(), EPSILON); // check dataset with two time periods s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(3000.0, r.getUpperBound(), EPSILON); // add a third time period s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(7000.0, r.getUpperBound(), EPSILON); // add a fourth time period s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4); r = dataset.getDomainBounds(true); assertEquals(1000.0, r.getLowerBound(), EPSILON); assertEquals(7000.0, r.getUpperBound(), EPSILON); }