Example usage for org.jfree.chart.plot CombinedDomainCategoryPlot CombinedDomainCategoryPlot

List of usage examples for org.jfree.chart.plot CombinedDomainCategoryPlot CombinedDomainCategoryPlot

Introduction

In this page you can find the example usage for org.jfree.chart.plot CombinedDomainCategoryPlot CombinedDomainCategoryPlot.

Prototype

public CombinedDomainCategoryPlot(CategoryAxis domainAxis) 

Source Link

Document

Creates a new plot.

Usage

From source file:playground.yu.utils.charts.DoubleBarChart.java

public DoubleBarChart(final String categoryAxisLabel, final String[] valueAxisLabels, final String[] categories,
        final int numberOfSubPlots) {
    this.plot = new CombinedDomainCategoryPlot(new CategoryAxis(categoryAxisLabel));
    this.subCharts = new BarChart[numberOfSubPlots];
    for (int i = 0; i < numberOfSubPlots; i++)
        subCharts[i] = new BarChart(null, null, valueAxisLabels[i], categories);
}

From source file:playground.yu.utils.charts.DoubleBarChart.java

/**
 * @param args/*  w w w  .  j av a 2  s . c o m*/
 */
public static void run0(String[] args) {
    String chartFilename = "../matsimTests/charts/barChart.png";
    BarChart chartA = new BarChart("", "", "Wegdistanz - MZ05",
            new String[] { "Arbeit (work)", "Rueckkehr nach Hause bzw. auswaertige Unterkunft (home)",
                    "Freizeit (leisure)", "Einkauf (shopping)", "Ausbildung/Schule (education)", "Andere",
                    "Geschaeftliche Taetigkeit und Dienstfahrt", "Service- und Begleitwege", "total" });
    chartA.addSeries("MIV (car)", new double[] { 9.04, 33.90, 12.20, 7.15, 6.83, 6.28, 14.39, 4.48, 10.16 });
    chartA.addSeries("OeV (pt)", new double[] { 10.86, 36.80, 15.04, 5.67, 10.06, 54.11, 33.04, 9.02, 12.19 });
    chartA.addSeries("LV (walk)", new double[] { 1.19, 0.24, 0.81, 0.70, 2.17, 0.57, 1.93, 0.75, 1.04 });
    chartA.addSeries("Andere (others)",
            new double[] { 18.16, 22.23, 10.78, 5.19, 0.84, 12.97, 44.90, 3.7, 11.76 });
    CategoryPlot subplotA = chartA.getChart().getCategoryPlot();

    BarChart chartB = new BarChart("", "", "Wegdistanz - Matsim-run698",
            new String[] { "Arbeit (work)", "Rueckkehr nach Hause bzw. auswaertige Unterkunft (home)",
                    "Freizeit (leisure)", "Einkauf (shopping)", "Ausbildung/Schule (education)", "Andere",
                    "Geschaeftliche Taetigkeit und Dienstfahrt", "Service- und Begleitwege", "total" });
    chartB.addSeries("MIV (car)", new double[] { 10.71, 7.79, 6.28, 5.77, 6.65, 0, 0, 0, 8.05 });
    chartB.addSeries("OeV (pt)", new double[] { 6.37, 6.10, 4.10, 4.10, 4.64, 0, 0, 0, 5.44 });
    chartB.addSeries("LV (walk)", new double[] { 0.88, 0.85, 0.75, 0.75, 0.81, 0, 0, 0, 0.81 });
    chartB.addSeries("Andere (others)", new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 });
    CategoryPlot subplotB = chartB.getChart().getCategoryPlot();

    final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(
            new CategoryAxis("Verkehrszwecke/ travel destinations"));
    plot.add(subplotA, 1);
    plot.add(subplotB, 1);

    final JFreeChart result = new JFreeChart("MZ05 vs MATSim - mittlere Wegdistanz",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    try {
        ChartUtilities.saveChartAsPNG(new File(chartFilename), result, 1024, 768, null, true, 9);
    } catch (IOException e) {
        e.printStackTrace();
    }
    // chartA.saveAsPng(chartFilename, 800, 600);
}

From source file:scheduler.benchmarker.manager.CreateCombinedCategoryPlot.java

public ChartPanel createChartPanel() {
    CustomBarRenderer renderer = new CustomBarRenderer(pluginColors);
    CategoryPlot subplot1 = new CategoryPlot(createDataset1(), new CategoryAxis("Category"),
            new NumberAxis("Value"), renderer);
    subplot1.setDomainGridlinesVisible(true);

    CategoryPlot subplot2 = new CategoryPlot(createDataset2(), new CategoryAxis("Category"),
            new NumberAxis("Value"), renderer);
    subplot2.setDomainGridlinesVisible(true);

    final CategoryAxis domainAxis = new CategoryAxis("Category");
    final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
    plot.add(subplot1, 1);/*from  w  w w  .j a  v  a2 s .  com*/
    plot.add(subplot2, 1);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    plot.setFixedLegendItems(createCustomLegend());
    plot.setRenderer(renderer);

    subplot1.setBackgroundPaint(new Color(246, 244, 242));
    subplot2.setBackgroundPaint(new Color(246, 244, 242));

    subplot1.addRangeMarker(generateMarker("CLASSIFICATION FINISH FOR '" + schedNames[0] + "'",
            dataSource[0].getSumTotalTime()), Layer.FOREGROUND);
    subplot2.addRangeMarker(generateMarker("CLASSIFICATION FINISH FOR '" + schedNames[1] + "'",
            dataSource[1].getSumTotalTime()), Layer.FOREGROUND);

    final JFreeChart result = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 12), plot, true);

    cPanel = new ChartPanel(result);
    cPanel.setForeground(new Color(76, 76, 76));
    cPanel.setBackground(new Color(246, 244, 242));

    return cPanel;

}

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

/**
 * Creates a chart./* w  w w.  j ava 2 s.c  o  m*/
 *
 * @return A chart.
 */
private JFreeChart createChart() {

    final CategoryDataset dataset1 = createDataset1();
    final NumberAxis rangeAxis1 = new NumberAxis("Value");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    final LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    final CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
    subplot1.setDomainGridlinesVisible(true);

    final CategoryDataset dataset2 = createDataset2();
    final NumberAxis rangeAxis2 = new NumberAxis("Value");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    final BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    final CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    final CategoryAxis domainAxis = new CategoryAxis("Category");
    final CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);

    final JFreeChart result = new JFreeChart("Combined Domain Category Plot Demo",
            new Font("SansSerif", Font.BOLD, 12), plot, true);
    //      result.getLegend().setAnchor(Legend.SOUTH);
    return result;

}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendChart.java

public JFreeChart createChart(SelectedChart chart) {
    assert (chart != null);

    CategoryAxis domainAxis = new CategoryAxis("Date");
    plot = new CombinedDomainCategoryPlot(domainAxis);
    if (drawingSupplier == null) {
        drawingSupplier = plot.getDrawingSupplier();
    } else {//  ww  w. ja  v  a  2s  .  c  o m
        plot.setDrawingSupplier(drawingSupplier);
    }

    switch (chart) {
    case LINE:
        plot.add(trendPlot, 1);
        break;

    case BAR:
        plot.add(sizePlot, 1);
        break;

    case BOTH:
        plot.add(trendPlot, 1);
        plot.add(sizePlot, 2);
        break;

    default:
        assert (false);
    }

    JFreeChart result = new JFreeChart(null, null, plot, true);

    result.removeLegend();

    return result;
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.DistributionChart.java

public JFreeChart createChart(SelectedChart chart) {
    CategoryAxis domainAxis = new CategoryAxis("Date");
    plot = new CombinedDomainCategoryPlot(domainAxis);
    if (drawingSupplier == null) {
        drawingSupplier = plot.getDrawingSupplier();
    } else {//from   ww w .  java 2s. c o m
        plot.setDrawingSupplier(drawingSupplier);
    }

    switch (chart) {
    case DISTRIBUTION:
        plot.add(boxPlot, 1);
        break;

    case SIZE:
        plot.add(sizePlot, 1);
        break;

    case BOTH:
        plot.add(boxPlot, 1);
        plot.add(sizePlot, 2);
        break;

    default:
        assert (false);
    }

    JFreeChart result = new JFreeChart(null, null, plot, true);

    return result;
}

From source file:charts.Chart.java

public static Vector MultipleStepChartOverlayed(CategoryDataset[] datasets1, CategoryDataset[] datasets2,
        String title, String x_axis_label, String y_axis_label, boolean showlegend, float maxvalue,
        float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    //if (minvalue == 0 && maxvalue == 0) {
    //    rangeAxis.setAutoRange(true);
    //} else {//  w  w  w.  ja  va 2 s.c  om
    //    rangeAxis.setRange(minvalue, maxvalue);
    //}
    rangeAxis.setAutoRange(true);

    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));

    for (int i = 0; i < datasets1.length; i++) {
        CategoryItemRenderer renderer1 = new CategoryStepRenderer(true);
        renderer1.setBaseStroke(new BasicStroke(2.0f));
        renderer1.setBaseSeriesVisibleInLegend(showlegend);

        CategoryPlot subplot = new CategoryPlot(datasets1[i], domainAxis, rangeAxis, renderer1);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);

        DefaultCategoryItemRenderer renderer2 = new DefaultCategoryItemRenderer();
        renderer2.setSeriesPaint(0, Color.LIGHT_GRAY);
        renderer2.setBaseStroke(new BasicStroke(2.0f));
        renderer2.setShapesVisible(true);
        renderer2.setBaseSeriesVisibleInLegend(false);

        subplot.setDataset(1, datasets2[i]);
        subplot.setRenderer(1, renderer2);
        //subplot.setDrawSharedDomainAxis(true);
        parent.add(subplot, 1);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    //if (showchart) {
    JFrame chartwindow = new JFrame(title);
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
    //}
    Vector res = new Vector();
    res.add(0, jfreechart);
    res.add(1, chartwindow);
    return res;
}

From source file:charts.Chart.java

public static Vector MultipleStepChartOverlayedMA(CategoryDataset[] datasets, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    rangeAxis.setAutoRange(true);//  w  ww.  j a  v  a2s  . c o m
    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));
    DefaultCategoryItemRenderer renderer0 = new DefaultCategoryItemRenderer();
    renderer0.setBaseStroke(new BasicStroke(2.0f));
    renderer0.setBaseSeriesVisibleInLegend(showlegend);
    renderer0.setSeriesPaint(0, Color.RED);//sinal original
    renderer0.setShapesVisible(false);
    CategoryPlot subplot = new CategoryPlot(datasets[0], domainAxis, rangeAxis, renderer0);
    subplot.setBackgroundPaint(Color.white);
    subplot.setRangeGridlinePaint(Color.black);
    subplot.setDomainGridlinesVisible(true);
    parent.add(subplot);

    CategoryAxis domainAxis1 = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis1 = new NumberAxis(y_axis_label);
    rangeAxis1.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    rangeAxis1.setAutoRange(true);

    CategoryItemRenderer renderer1 = new CategoryStepRenderer(true);
    renderer1.setBaseStroke(new BasicStroke(2.0f));
    renderer1.setBaseSeriesVisibleInLegend(showlegend);
    renderer1.setSeriesPaint(0, Color.BLUE);//sinal quantizado
    CategoryPlot subplot1 = new CategoryPlot(datasets[1], domainAxis1, rangeAxis1, renderer1);
    //subplot.setDataset(1, datasets[1]);
    //subplot.setRenderer(1, renderer1);
    parent.add(subplot1);

    DefaultCategoryItemRenderer renderer2 = new DefaultCategoryItemRenderer();
    renderer2.setBaseStroke(new BasicStroke(2.0f));
    renderer2.setBaseSeriesVisibleInLegend(showlegend);
    renderer2.setShapesVisible(false);
    renderer2.setSeriesPaint(0, Color.BLACK);//sinal normalizado
    subplot1.setDataset(1, datasets[2]);
    subplot1.setRenderer(1, renderer2);

    for (int i = 3; i < datasets.length; i++) {
        DefaultCategoryItemRenderer renderer3 = new DefaultCategoryItemRenderer();
        renderer3.setBaseStroke(new BasicStroke(2.0f));
        renderer3.setBaseSeriesVisibleInLegend(showlegend);
        renderer3.setShapesVisible(false);
        renderer3.setSeriesPaint(0, Color.LIGHT_GRAY);//limiares utilizados para quantizacao.
        subplot1.setDataset(i - 1, datasets[i]);
        subplot1.setRenderer(i - 1, renderer3);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    JPanel retorno = new ChartPanel(jfreechart);
    retorno.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    JFrame chartwindow = new JFrame(title);
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(showchart);
    Vector res = new Vector();
    res.add(0, jfreechart);
    res.add(1, chartwindow);
    res.add(2, retorno);
    return res;
}

From source file:charts.Chart.java

public static Vector MultipleLineChart(CategoryDataset[] datasets, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRange(true);//  w w w .jav a  2  s  .  co m
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }
    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));

    for (int i = 0; i < datasets.length; i++) {
        CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();//new CategoryStepRenderer(true);
        renderer.setBaseStroke(new BasicStroke(2.0f));
        renderer.setBaseSeriesVisibleInLegend(showlegend);
        CategoryPlot subplot = new CategoryPlot(datasets[i], domainAxis, rangeAxis, renderer);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);
        //subplot.setDrawSharedDomainAxis(true);
        parent.add(subplot, 1);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    //if (showchart) {
    JFrame chartwindow = new JFrame(title);
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
    //}
    Vector res = new Vector();
    res.add(0, jfreechart);
    res.add(1, chartwindow);
    return res;
}

From source file:charts.Chart.java

public static JFreeChart MultipleStepChart(CategoryDataset[] datasets, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRange(true);/*from w  ww  . j a  v  a2s .c  o m*/
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }
    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));

    for (int i = 0; i < datasets.length; i++) {
        CategoryItemRenderer renderer = new CategoryStepRenderer(true);
        renderer.setBaseStroke(new BasicStroke(2.0f));
        CategoryPlot subplot = new CategoryPlot(datasets[i], domainAxis, rangeAxis, renderer);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);
        //subplot.setDrawSharedDomainAxis(true);
        parent.add(subplot, 1);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    if (showchart) {
        JFrame chartwindow = new JFrame(title);
        chartwindow.setContentPane(jpanel);
        chartwindow.pack();
        RefineryUtilities.centerFrameOnScreen(chartwindow);
        chartwindow.setVisible(true);
    }
    return jfreechart;
}