Package org.jfree.data.time

Examples of org.jfree.data.time.TimePeriodValues


    JRPrintHyperlink printHyperlink = null;
    if (hasHyperlinks() && entity instanceof XYItemEntity)
    {
      XYItemEntity itemEntity = (XYItemEntity) entity;
      TimePeriodValuesCollection dataset = (TimePeriodValuesCollection) itemEntity.getDataset();
      TimePeriodValues series = dataset.getSeries(itemEntity.getSeriesIndex());
      Map serieHyperlinks = (Map) itemHyperlinks.get(series.getKey());
      if (serieHyperlinks != null)
      {
        TimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem());
        printHyperlink = (JRPrintHyperlink) serieHyperlinks.get(timePeriod);
      }
    }
    return printHyperlink;
  }
View Full Code Here


    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);
     
View Full Code Here

        if (seriesName == null)
        {
          throw new JRRuntimeException("Time period series name is null.");
        }

        TimePeriodValues timePeriodValues = (TimePeriodValues)seriesMap.get(seriesName);
        if (timePeriodValues == null)
        {
          timePeriodValues = new TimePeriodValues(seriesName.toString());
          seriesNames.add(seriesName);
          seriesMap.put(seriesName, timePeriodValues);
        }

        SimpleTimePeriod stp =
          new SimpleTimePeriod(
            crtTimePeriodSeries.getStartDate(),
            crtTimePeriodSeries.getEndDate()
            );
       
        timePeriodValues.add(stp, crtTimePeriodSeries.getValue());
       
        if (crtTimePeriodSeries.getLabelExpression() != null)
        {
          Map seriesLabels = (Map)labelsMap.get(seriesName);
          if (seriesLabels == null)
View Full Code Here

    /**
     * Common test setup.
     */
    protected void setUp() {

        this.seriesA = new TimePeriodValues("Series A");
        try {
            this.seriesA.add(new Year(2000), new Integer(102000));
            this.seriesA.add(new Year(2001), new Integer(102001));
            this.seriesA.add(new Year(2002), new Integer(102002));
            this.seriesA.add(new Year(2003), new Integer(102003));
            this.seriesA.add(new Year(2004), new Integer(102004));
            this.seriesA.add(new Year(2005), new Integer(102005));
        }
        catch (SeriesException e) {
            System.err.println("Problem creating series.");
        }

        this.seriesB = new TimePeriodValues("Series B");
        try {
            this.seriesB.add(new Year(2006), new Integer(202006));
            this.seriesB.add(new Year(2007), new Integer(202007));
            this.seriesB.add(new Year(2008), new Integer(202008));
        }
        catch (SeriesException e) {
            System.err.println("Problem creating series.");
        }

        this.seriesC = new TimePeriodValues("Series C");
        try {
            this.seriesC.add(new Year(1999), new Integer(301999));
            this.seriesC.add(new Year(2000), new Integer(302000));
            this.seriesC.add(new Year(2002), new Integer(302002));
        }
View Full Code Here

     * Set up a quarter equal to Q1 1900.  Request the previous quarter, it
     * should be null.
     */
    public void testClone() {

        TimePeriodValues series = new TimePeriodValues("Test Series");

        RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002);
        try {
            series.add(jan1st2002, new Integer(42));
        }
        catch (SeriesException e) {
            System.err.println("Problem adding to collection.");
        }

        TimePeriodValues clone = null;
        try {
            clone = (TimePeriodValues) series.clone();
            clone.setKey("Clone Series");
            try {
                clone.update(0, new Integer(10));
            }
            catch (SeriesException e) {
                System.err.println("Problem updating series.");
            }
        }
        catch (CloneNotSupportedException e) {
            assertTrue(false);
        }

        int seriesValue = series.getValue(0).intValue();
        int cloneValue = clone.getValue(0).intValue();

        assertEquals(42, seriesValue);
        assertEquals(10, cloneValue);
        assertEquals("Test Series", series.getKey());
        assertEquals("Clone Series", clone.getKey());

    }
View Full Code Here

    /**
     * Add a value to series A for 1999.  It should be added at index 0.
     */
    public void testAddValue() {

        TimePeriodValues tpvs = new TimePeriodValues("Test");
        try {
            tpvs.add(new Year(1999), new Integer(1));
        }
        catch (SeriesException e) {
            System.err.println("Problem adding to series.");
        }

        int value = tpvs.getValue(0).intValue();
        assertEquals(1, value);

    }
View Full Code Here

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        TimePeriodValues s1 = new TimePeriodValues("A test");
        s1.add(new Year(2000), 13.75);
        s1.add(new Year(2001), 11.90);
        s1.add(new Year(2002), null);
        s1.add(new Year(2005), 19.32);
        s1.add(new Year(2007), 16.89);
        TimePeriodValues s2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(s1);
View Full Code Here

    /**
     * Tests the equals method.
     */
    public void testEquals() {
        TimePeriodValues s1 = new TimePeriodValues("Time Series 1");
        TimePeriodValues s2 = new TimePeriodValues("Time Series 2");
        boolean b1 = s1.equals(s2);
        assertFalse("b1", b1);

        s2.setKey("Time Series 1");
        boolean b2 = s1.equals(s2);
        assertTrue("b2", b2);

        // domain description
        s1.setDomainDescription("XYZ");
        assertFalse(s1.equals(s2));
        s2.setDomainDescription("XYZ");
        assertTrue(s1.equals(s2));
       
        // domain description - null
        s1.setDomainDescription(null);
        assertFalse(s1.equals(s2));
        s2.setDomainDescription(null);
        assertTrue(s1.equals(s2));
       
        // range description
        s1.setRangeDescription("XYZ");
        assertFalse(s1.equals(s2));
        s2.setRangeDescription("XYZ");
        assertTrue(s1.equals(s2));
       
        // range description - null
        s1.setRangeDescription(null);
        assertFalse(s1.equals(s2));
        s2.setRangeDescription(null);
        assertTrue(s1.equals(s2));

        RegularTimePeriod p1 = new Day();
        RegularTimePeriod p2 = p1.next();
        s1.add(p1, 100.0);
        s1.add(p2, 200.0);
        boolean b3 = s1.equals(s2);
        assertFalse("b3", b3);

        s2.add(p1, 100.0);
        s2.add(p2, 200.0);
        boolean b4 = s1.equals(s2);
        assertTrue("b4", b4);

    }
View Full Code Here

   
    /**
     * A test for bug report 1161329.
     */
    public void test1161329() {
        TimePeriodValues tpv = new TimePeriodValues("Test");
        RegularTimePeriod t = new Day();
        tpv.add(t, 1.0);
        t = t.next();
        tpv.add(t, 2.0);
        tpv.delete(0, 1);
        assertEquals(0, tpv.getItemCount());
        tpv.add(t, 2.0);
        assertEquals(1, tpv.getItemCount());
    }
View Full Code Here

   
    /**
     * Some checks for the add() methods.
     */
    public void testAdd() {
        TimePeriodValues tpv = new TimePeriodValues("Test");
        MySeriesChangeListener listener = new MySeriesChangeListener();
        tpv.addChangeListener(listener);
        tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L),
                new Date(3L)), 99.0));
        assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON);
        assertEquals(tpv, listener.getLastEvent().getSource());
       
        // a null item should throw an IllegalArgumentException
        boolean pass = false;
        try {
            tpv.add((TimePeriodValue) null);
        }
        catch (IllegalArgumentException e) {
            pass = true;
        }
        assertTrue(pass);
View Full Code Here

TOP

Related Classes of org.jfree.data.time.TimePeriodValues

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.