Java Code Examples for org.jfree.data.time.Day#parseDay()

The following examples show how to use org.jfree.data.time.Day#parseDay() . 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: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 2
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 3
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 4
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 5
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 6
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 7
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 8
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 9
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 10
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 11
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}
 
Example 12
Source File: ComplexChartPlotter.java    From Design-Patterns-and-SOLID-Principles-with-Java with MIT License 4 votes vote down vote up
@Override
void doPlot(Report report, OutputStream out) throws IOException {
    List<String> labels = report.getLabels();
    List<List<Report.Field>> records = report.getRecords();

    String dateLabel = labels.get(dateIndex);
    List<String> valueLabels = labels
        .stream()
        .filter(l -> !l.equals(dateLabel))
        .collect(Collectors.toList());

    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    for (String valueLabel : valueLabels) {
        seriesCollection.addSeries(new TimeSeries(valueLabel));
    }

    for (List<Report.Field> record : records) {
        Report.Field dateField = record.get(dateIndex);
        Day day = Day.parseDay(dateField.getAsString());
        List<Number> values = record.stream()
            .filter(f -> !f.equals(dateField))
            .map(Report.Field::getAsNumber)
            .collect(Collectors.toList());

        for (int j = 0; j < values.size(); j++) {
            Number value = values.get(j);
            TimeSeries series = seriesCollection.getSeries(j);
            series.add(day, value);
        }
    }

    JFreeChart chart;
    if (chartType == ChartType.LINE) {
        chart = createTimeSeriesChart(
            reportType.getDisplayName(),
            dateLabel,
            null,
            seriesCollection
        );
    } else if (chartType == ChartType.BAR) {
        chart = createXYBarChart(
            reportType.getDisplayName(),
            dateLabel,
            true,
            null,
            seriesCollection
        );
    } else {
        throw new IllegalStateException(String.format("Chart type %s not handled.", chartType));
    }
    writeChartAsPNG(out, chart, PNG_WIDTH, PNG_HEIGHT);
}