Example usage for org.jfree.data.time Month Month

List of usage examples for org.jfree.data.time Month Month

Introduction

In this page you can find the example usage for org.jfree.data.time Month Month.

Prototype

public Month(Date time, TimeZone zone) 

Source Link

Document

Constructs a new Month instance, based on a date/time and a time zone.

Usage

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

private static XYDataset createDataset() {

    TimeSeries s1 = new TimeSeries("L&G European Index Trust");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
    s2.add(new Month(2, 2001), 129.6);
    s2.add(new Month(3, 2001), 123.2);
    s2.add(new Month(4, 2001), 117.2);
    s2.add(new Month(5, 2001), 124.1);
    s2.add(new Month(6, 2001), 122.6);
    s2.add(new Month(7, 2001), 119.2);
    s2.add(new Month(8, 2001), 116.5);
    s2.add(new Month(9, 2001), 112.7);
    s2.add(new Month(10, 2001), 101.5);
    s2.add(new Month(11, 2001), 106.1);
    s2.add(new Month(12, 2001), 110.3);
    s2.add(new Month(1, 2002), 111.7);
    s2.add(new Month(2, 2002), 111.0);
    s2.add(new Month(3, 2002), 109.6);
    s2.add(new Month(4, 2002), 113.2);
    s2.add(new Month(5, 2002), 111.6);
    s2.add(new Month(6, 2002), 108.8);
    s2.add(new Month(7, 2002), 101.6);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s2);//from w w  w .  j a  v a  2 s .  c  o  m
    dataset.addSeries(s1);

    return dataset;
}

From source file:cit.workflow.engine.manager.test.SWTTimeSeriesDemo.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 *
 * @return The dataset./*www .  j a va2 s.c om*/
 */
private static XYDataset createDataset() {

    TimeSeries s1 = new TimeSeries("L&G European Index Trust");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
    s2.add(new Month(2, 2001), 129.6);
    s2.add(new Month(3, 2001), 123.2);
    s2.add(new Month(4, 2001), 117.2);
    s2.add(new Month(5, 2001), 124.1);
    s2.add(new Month(6, 2001), 122.6);
    s2.add(new Month(7, 2001), 119.2);
    s2.add(new Month(8, 2001), 116.5);
    s2.add(new Month(9, 2001), 112.7);
    s2.add(new Month(10, 2001), 101.5);
    s2.add(new Month(11, 2001), 106.1);
    s2.add(new Month(12, 2001), 110.3);
    s2.add(new Month(1, 2002), 111.7);
    s2.add(new Month(2, 2002), 111.0);
    s2.add(new Month(3, 2002), 109.6);
    s2.add(new Month(4, 2002), 113.2);
    s2.add(new Month(5, 2002), 111.6);
    s2.add(new Month(6, 2002), 108.8);
    s2.add(new Month(7, 2002), 101.6);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);

    return dataset;
}

From source file:org.jfree.graphics2d.demo.SVGChartWithAnnotationsDemo1.java

/**
 * Creates a sample chart.//from w ww. j av  a2  s.  c om
 *
 * @param dataset  a dataset for the chart.
 *
 * @return A sample chart.
 */
private static JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million",
            dataset);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    DateAxis xAxis = (DateAxis) plot.getDomainAxis();
    xAxis.setLowerMargin(0.2);
    xAxis.setUpperMargin(0.2);
    xAxis.setStandardTickUnits(createStandardDateTickUnits());

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setLowerMargin(0.2);
    yAxis.setUpperMargin(0.2);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseLinesVisible(true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
    renderer.setSeriesShape(1, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 5.0f,
            new float[] { 10.0f, 5.0f }, 0.0f));
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesFillPaint(1, Color.white);
    renderer.setUseFillPaint(true);

    renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);

    renderer.addAnnotation(new XYDrawableAnnotation(new Month(4, 2005).getFirstMillisecond(), 600, 180, 100,
            3.0, createPieChart()));
    renderer.addAnnotation(new XYDrawableAnnotation(new Month(9, 2007).getFirstMillisecond(), 1250, 120, 100,
            2.0, createBarChart()));
    plot.setRenderer(renderer);
    return chart;
}

From source file:org.jfree.data.time.junit.MonthTest.java

/**
 * Common test setup.//  www . j  a  v a 2s.  c o m
 */
@Override
protected void setUp() {
    this.jan1900 = new Month(MonthConstants.JANUARY, 1900);
    this.feb1900 = new Month(MonthConstants.FEBRUARY, 1900);
    this.nov9999 = new Month(MonthConstants.NOVEMBER, 9999);
    this.dec9999 = new Month(MonthConstants.DECEMBER, 9999);
}

From source file:org.jfree.data.time.MonthTest.java

/**
 * Tests the equals method./*from www  .j  a  va2  s  .  co  m*/
 */
@Test
public void testEquals() {
    Month m1 = new Month(MonthConstants.MAY, 2002);
    Month m2 = new Month(MonthConstants.MAY, 2002);
    assertTrue(m1.equals(m2));
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.WinLose.java

@Override
public DatasetMap calculateValue() throws Exception {
    logger.debug("IN");

    DatasetMap datasets = super.calculateValue();
    if (datasets == null || yearsDefined == null) {
        logger.error("Error in TrargetCharts calculate value");
        return null;
    }//w  w  w.  j a v a 2  s .  c  o  m
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    datasets.addDataset("1", dataset);

    if (datasets != null && yearsDefined.isEmpty()) {
        logger.warn("no rows found with dataset");
    } else {

        // Check if defining target and baseline
        Double mainTarget = null;
        Double mainBaseline = null;
        if (mainThreshold == null) {
            logger.error("No main target or baseline defined, not possible to draw the chart");
        } else {
            if (useTargets)
                mainTarget = mainThreshold;
            else
                mainBaseline = mainThreshold;
            nullValues = new Vector<String>();

            // run all the years defined
            for (Iterator iterator = yearsDefined.iterator(); iterator.hasNext();) {
                String currentYearS = (String) iterator.next();
                int currentYear = Integer.valueOf(currentYearS).intValue();
                boolean stop = false;
                for (int i = 1; i < 13 && stop == false; i++) {
                    Month currentMonth = new Month(i, currentYear);
                    // if it is the first year and th ecurrent month is previous than the first month
                    if (currentYearS.equalsIgnoreCase(yearsDefined.first()) && i < firstMonth.getMonth()) {
                        // continue
                    } else {
                        TimeSeriesDataItem item = timeSeries.getDataItem(currentMonth);
                        if (item != null && item.getValue() != null) {
                            double v = item.getValue().doubleValue();
                            double result = 0;
                            if (mainTarget != null) {
                                result = (v >= mainTarget.doubleValue()) ? WIN : LOSE;
                            } else if (mainBaseline != null) {
                                result = (v > mainBaseline.doubleValue()) ? LOSE : WIN;
                            } else {
                                logger.warn("could not find a threshold");
                            }

                            dataset.addValue(result, timeSeries.getKey(), "" + i + "-" + currentYear);

                        } else {
                            if (wlt_mode.doubleValue() == 5) {
                                dataset.addValue(0.001, timeSeries.getKey(), "" + i + "-" + currentYear);
                                nullValues.add("" + i + "-" + currentYear);
                            } else {
                                dataset.addValue(0.0, timeSeries.getKey(), "" + i + "-" + currentYear);
                            }
                        }
                        // if it is last year and current month is after the last month stop 
                        if (currentYearS.equalsIgnoreCase(lastYear) && i >= lastMonth.getMonth()) {
                            stop = true;
                        }

                    }
                }

            }
        }
    }
    logger.debug("OUT");
    return datasets;
}

From source file:org.jfree.chart.demo.CompareToPreviousYearDemo.java

private static XYDataset createDataset2007() {
    TimeSeries timeseries = new TimeSeries("Sales 2007");
    timeseries.add(new Month(1, 2007), 163.90000000000001D);
    timeseries.add(new Month(2, 2007), 163.80000000000001D);
    timeseries.add(new Month(3, 2007), 162D);
    timeseries.add(new Month(4, 2007), 167.09999999999999D);
    timeseries.add(new Month(5, 2007), 170D);
    timeseries.add(new Month(6, 2007), 175.69999999999999D);
    timeseries.add(new Month(7, 2007), 171.90000000000001D);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(timeseries);
    timeseriescollection.setXPosition(TimePeriodAnchor.MIDDLE);
    return timeseriescollection;
}

From source file:com.twocents.report.charts.TimeSeriesChartDemo1.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 *
 * @return The dataset.//from  w  w w  .j ava  2 s . c  om
 */
private static XYDataset createDataset() {

    TimeSeries s1 = new TimeSeries("L&G European Index Trust");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
    s2.add(new Month(2, 2001), 129.6);
    s2.add(new Month(3, 2001), 123.2);
    s2.add(new Month(4, 2001), 117.2);
    s2.add(new Month(5, 2001), 124.1);
    s2.add(new Month(6, 2001), 122.6);
    s2.add(new Month(7, 2001), 119.2);
    s2.add(new Month(8, 2001), 116.5);
    s2.add(new Month(9, 2001), 112.7);
    s2.add(new Month(10, 2001), 101.5);
    s2.add(new Month(11, 2001), 106.1);
    s2.add(new Month(12, 2001), 110.3);
    s2.add(new Month(1, 2002), 111.7);
    s2.add(new Month(2, 2002), 111.0);
    s2.add(new Month(3, 2002), 109.6);
    s2.add(new Month(4, 2002), 113.2);
    s2.add(new Month(5, 2002), 111.6);
    s2.add(new Month(6, 2002), 108.8);
    s2.add(new Month(7, 2002), 101.6);

    // ******************************************************************
    //  More than 150 demo applications are included with the JFreeChart
    //  Developer Guide...for more information, see:
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);

    return dataset;

}

From source file:aplicacion.asterisk.manager.logic.TimeSeriesChartDemo1.java

/**
 * Creates a dataset, consisting of two series of monthly data.
 *
 * @return The dataset./*from   www  .j av  a  2  s.c  om*/
 */
private static XYDataset createDataset() {

    TimeSeries s1 = new TimeSeries("L&G European Index Trust");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);
    /*
            TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
            s2.add(new Month(2, 2001), 129.6);
            s2.add(new Month(3, 2001), 123.2);
            s2.add(new Month(4, 2001), 117.2);
            s2.add(new Month(5, 2001), 124.1);
            s2.add(new Month(6, 2001), 122.6);
            s2.add(new Month(7, 2001), 119.2);
            s2.add(new Month(8, 2001), 116.5);
            s2.add(new Month(9, 2001), 112.7);
            s2.add(new Month(10, 2001), 101.5);
            s2.add(new Month(11, 2001), 106.1);
            s2.add(new Month(12, 2001), 110.3);
            s2.add(new Month(1, 2002), 111.7);
            s2.add(new Month(2, 2002), 111.0);
            s2.add(new Month(3, 2002), 109.6);
            s2.add(new Month(4, 2002), 113.2);
            s2.add(new Month(5, 2002), 111.6);
            s2.add(new Month(6, 2002), 108.8);
            s2.add(new Month(7, 2002), 101.6);*/

    // ******************************************************************
    //  More than 150 demo applications are included with the JFreeChart
    //  Developer Guide...for more information, see:
    //
    //  >   http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);
    //dataset.addSeries(s2);

    return dataset;

}

From source file:org.jfree.chart.demo.MovingAverageDemo.java

/**
 * Creates a dataset, one series containing unit trust prices, the other a moving average.
 *
 * @return the dataset.// w w w.j  a  v  a  2  s  . c om
 */
public XYDataset createDataset() {

    final TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class);
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    final TimeSeries s2 = MovingAverage.createMovingAverage(s1, "Six Month Moving Average", 6, 0);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);

    return dataset;

}