Example usage for org.jfree.chart JFreeChart getCategoryPlot

List of usage examples for org.jfree.chart JFreeChart getCategoryPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getCategoryPlot.

Prototype

public CategoryPlot getCategoryPlot() 

Source Link

Document

Returns the plot cast as a CategoryPlot .

Usage

From source file:playground.dgrether.signalsystems.utils.DgSignalPlanChart.java

public JFreeChart createSignalPlanChart(String title, String xAxisTitle, String yAxisTitle) {
    JFreeChart chart = ChartFactory.createStackedBarChart(title, xAxisTitle, yAxisTitle, this.dataset,
            PlotOrientation.HORIZONTAL, false, false, false);
    DgDefaultAxisBuilder axis = new DgDefaultAxisBuilder();
    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    CategoryAxis xAxis = axis.createCategoryAxis(xAxisTitle);
    plot.setDomainAxis(xAxis);/*from   w ww  .  jav  a2s.c o m*/
    ValueAxis yAxis = axis.createValueAxis(yAxisTitle);
    yAxis.setUpperBound(this.tMax);
    yAxis.setLowerBound(this.tMin);
    plot.setRangeAxis(yAxis);

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.findRangeBounds(dataset);
    renderer.setShadowVisible(false);
    //      renderer.setItemMargin(10.005);
    renderer.setMaximumBarWidth(0.2);
    for (Entry<Integer, Color> ee : seriesColor.entrySet()) {
        renderer.setSeriesPaint(ee.getKey(), ee.getValue());
        //         renderer.setSeriesStroke(ee.getKey(), new BasicStroke(50));
    }
    plot.setRenderer(renderer);
    //      chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    //      chart.setBackgroundPaint(ChartColor.WHITE);
    //      chart.removeLegend();
    return chart;
}

From source file:monitor.StatsWindow.java

private void jButtonRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRefreshActionPerformed

    DefaultCategoryDataset dateset = new DefaultCategoryDataset();
    dateset.setValue(Window.getIndeksWordsInSettingsWindow()[0], "", "1");
    dateset.setValue(Window.getIndeksWordsInSettingsWindow()[1], "", "2");
    dateset.setValue(Window.getIndeksWordsInSettingsWindow()[2], "", "3");
    dateset.setValue(Window.getIndeksWordsInSettingsWindow()[3], "", "4");
    dateset.setValue(Window.getIndeksWordsInSettingsWindow()[4], "", "5");

    DefaultCategoryDataset dateset2 = new DefaultCategoryDataset();
    dateset2.setValue(Window.getIndeksWordsInSettingsWindow2()[0], "", "1");
    dateset2.setValue(Window.getIndeksWordsInSettingsWindow2()[1], "", "2");
    dateset2.setValue(Window.getIndeksWordsInSettingsWindow2()[2], "", "3");
    dateset2.setValue(Window.getIndeksWordsInSettingsWindow2()[3], "", "4");
    dateset2.setValue(Window.getIndeksWordsInSettingsWindow2()[4], "", "5");

    JFreeChart chart = ChartFactory.createBarChart("Prefiks counts diagram", "", "", dateset,
            PlotOrientation.HORIZONTAL, false, false, false);
    CategoryPlot catPlot = chart.getCategoryPlot();
    catPlot.setRangeGridlinePaint(Color.BLACK);

    JFreeChart chart2 = ChartFactory.createBarChart("Sufiks counts diagram", "", "", dateset2,
            PlotOrientation.HORIZONTAL, false, false, false);
    CategoryPlot catPlot2 = chart2.getCategoryPlot();
    catPlot2.setRangeGridlinePaint(Color.BLACK);

    ChartPanel chartPanel = new ChartPanel(chart);
    jPanelDiagram.removeAll();//  w  w w .ja va2s .c  o m
    jPanelDiagram.add(chartPanel, BorderLayout.CENTER);
    jPanelDiagram.validate();

    ChartPanel chartPanel2 = new ChartPanel(chart2);
    jPanelDiagram2.removeAll();
    jPanelDiagram2.add(chartPanel2, BorderLayout.CENTER);
    jPanelDiagram2.validate();

    jTextAreaNGramWords.setText(Window.getWordsInSettingsWindow());

    jTextAreaSufiksWords.setText(Window.getWordsInSettingsWindow2());

}

From source file:Reportes.BarChart.java

public ChartPanel reporteOrdenesSede(DefaultCategoryDataset data) {
    JFreeChart chart = ChartFactory.createBarChart("Reporte de ordenes de trabajo por jefe", "Jefe de taller",
            "Cantidad", data, PlotOrientation.VERTICAL, true, true, true);

    CategoryPlot categoryP = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);//from www . jav a2s. c  o  m
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(chart, true, true, true, false, false);
    panel.setSize(ancho, alto);

    return panel;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createBulletChart(CategoryDataset dataset, double[] thresholds, Color[] colors) {
    if (thresholds.length != colors.length) {
        throw new IllegalArgumentException(
                "Inconsistant array sizes: thresholds=" + thresholds.length + " colors=" + colors.length);
    }//  w  w  w  .  ja va  2  s . co m

    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL,
            false, true, false);
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(null);
    categoryplot.setOutlinePaint(null);

    categoryplot.getDomainAxis().setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) categoryplot.getRangeAxis();
    rangeAxis.setVisible(false);
    rangeAxis.setRange(new Range(0, 1.0));

    double last = 0.0;
    for (int i = 0; i < thresholds.length; i++) {
        IntervalMarker marker = new IntervalMarker(last, thresholds[i], colors[i]);
        categoryplot.addRangeMarker(marker, Layer.BACKGROUND);
        last = thresholds[i];
    }

    BarRenderer renderer = (BarRenderer) categoryplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(0.33);
    renderer.setSeriesPaint(0, UIConstants.INTEL_DARK_GRAY);

    return jfreechart;
}

From source file:com.przemo.probabilities.gui.SimulatorPanel.java

private void addMainChart() {
    JFreeChart chart = ChartFactory.createBarChart("Account balance simulation", "Iteration", "Balance", null);
    chart.getCategoryPlot().getDomainAxis().setVisible(false);
    p = new ChartPanel(chart);
    p.setPreferredSize(new Dimension(mainChartPanel.getWidth() - 2, mainChartPanel.getHeight() - 20));
    chart.getCategoryPlot().setBackgroundPaint(Color.WHITE);
    mainChartPanel.setLayout(new FlowLayout());
    mainChartPanel.add(p);/*  w w  w  .ja  v  a  2s.  com*/
    //mainChartPanel.validate();
}

From source file:Reportes.BarChart.java

public ChartPanel reporteCantidadCotizacionesSede(DefaultCategoryDataset data) {
    JFreeChart chart = ChartFactory.createBarChart("Reporte de cantidad de cotizaciones por empleado",
            "Empleado", "Cantidad", data, PlotOrientation.VERTICAL, true, true, true);

    CategoryPlot categoryP = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);//from w  ww  .j a v  a 2  s .  co  m
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(chart, true, true, true, false, false);
    panel.setSize(ancho, alto);

    return panel;
}

From source file:Reportes.BarChart.java

public ChartPanel reporteVehiculosAgregados(DefaultCategoryDataset data) {
    JFreeChart chart = ChartFactory.createBarChart("Reporte de cantidad de vehiculos aadidos por sede",
            "Sedes", "Cantidad", data, PlotOrientation.VERTICAL, true, true, true);

    CategoryPlot categoryP = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);//w  w w .  ja  v a 2  s  .c o  m
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(chart, true, true, true, false, false);
    panel.setSize(ancho, alto);

    return panel;
}

From source file:Gui.Graficos.java

private void init(String titulo, String tituloX, String tituloY) {

    panel = new JPanel();
    panel.setBackground(Color.WHITE);

    getContentPane().add(panel);//ww  w.j  a  v a  2s. co m

    // Creando el Grafico

    JFreeChart chart = ChartFactory.createBarChart3D(titulo, tituloX, tituloY, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(new Color(225, 255, 228));
    chart.getTitle().setPaint(Color.black);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.red);

    // Mostrar Grafico

    ChartPanel chartPanel = new ChartPanel(chart);
    panel.add(chartPanel);

    // panel.setLayout(new VerticalLayout());

    panel.add(btAceptar);

    //panel.
    panel.setLayout(null);

    chartPanel.setBounds(100, 10, 1100, 600);
    btAceptar.setBounds(1065, 620, 130, 30);

}

From source file:drugsupplychain.neu.css.gui.common.pharmaco.ProductDistributionDetailJPanel.java

/**
 * show distribution//from w ww.j ava  2 s .co  m
 */
private void showDistribution() {
    // TODO add your handling code here:
    DefaultCategoryDataset barchartDataset = new DefaultCategoryDataset();
    if (null != product && null != product.getProductTracker() && product.getProductTracker().size() > 0) {
        for (String id : product.getProductTracker().keySet()) {
            TrackOrganization trackOrganization = product.getProductTracker().get(id);
            if (trackOrganization.getOrganization() instanceof Distributor) {
                barchartDataset.setValue(trackOrganization.getQuantity(), "QUANTITY",
                        trackOrganization.getOrganization().getLocation());
            }
        }
        JFreeChart barChartData = ChartFactory.createBarChart("MEDICINE DISTRIBUTION", "LOCATION", "QUANTITY",
                barchartDataset, PlotOrientation.VERTICAL, false, true, true);
        CategoryPlot barchart = barChartData.getCategoryPlot();
        barchart.setRangeGridlinePaint(Color.ORANGE);
        ChartPanel barPanel = new ChartPanel(barChartData);
        barPanelDisplay.removeAll();
        barPanelDisplay.add(barPanel, BorderLayout.CENTER);
        barPanelDisplay.validate();
    }
}

From source file:userinterface.HospitalAdminRole.DataAnalysisHospitalJPanel.java

private void seeChartBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_seeChartBtnActionPerformed
    // TODO add your handling code here:

    int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0;
    for (Network network : business.getNetworkList()) {

        for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) {
            if (enterprise instanceof HospitalEnterprise) {
                for (Organization org : enterprise.getOrganizationDirectory().getOrganizationList()) {
                    for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) {
                        String bg = request.getBloodGroup();
                        if (bg.equalsIgnoreCase("a+")) {
                            a++;//from  w ww  .  j a v  a  2  s. c o  m
                        }

                        if (bg.equalsIgnoreCase("a-")) {
                            b++;
                        }

                        if (bg.equalsIgnoreCase("b+")) {
                            c++;
                        }

                        if (bg.equalsIgnoreCase("b-")) {
                            d++;
                        }

                        if (bg.equalsIgnoreCase("ab+")) {
                            e++;
                        }

                        if (bg.equalsIgnoreCase("ab-")) {
                            f++;
                        }

                        if (bg.equalsIgnoreCase("o+")) {
                            g++;
                        }

                        if (bg.equalsIgnoreCase("o-")) {
                            h++;
                        }

                    }
                }
            }
        }

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.setValue(a, "Number", "A+");
        dataset.setValue(b, "Number", "A-");
        dataset.setValue(c, "Number", "B+");
        dataset.setValue(d, "Number", "B-");
        dataset.setValue(e, "Number", "AB+");
        dataset.setValue(f, "Number", "AB-");
        dataset.setValue(g, "Number", "O+");
        dataset.setValue(h, "Number", "O-");

        JFreeChart chart = ChartFactory.createBarChart("Hospital Demands", "Blood Types", "Number", dataset,
                PlotOrientation.VERTICAL, false, true, false);
        CategoryPlot p = chart.getCategoryPlot();
        p.setRangeGridlinePaint(Color.black);

        ChartFrame frame = new ChartFrame("Hospital Demands", chart);

        frame.setVisible(true);
        frame.setSize(450, 500);
    }

}