Example usage for org.jfree.chart JFreeChart getTitle

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

Introduction

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

Prototype

public TextTitle getTitle() 

Source Link

Document

Returns the main chart title.

Usage

From source file:com.pusksesmas.form_statistik.statistik_keuangan_administrasi.java

private void tabelDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDataMouseClicked

    if (vpil.getSelectedIndex() == 1) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 0)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 1)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 2)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 3)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 4)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 6)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 7)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 8)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 9)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 10)).toString();
        String des = (tabelData.getModel().getValueAt(row, 11)).toString();

        DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
        //        pieDataset.setValue("Diagnosa", new Integer(jan));
        pieDataset.setValue(new Integer(jan), "", "Januari");
        pieDataset.setValue(new Integer(feb), "", "Februari");
        pieDataset.setValue(new Integer(mar), "", "Maret");
        pieDataset.setValue(new Integer(apr), "", "April");
        pieDataset.setValue(new Integer(mei), "", "Mei");
        pieDataset.setValue(new Integer(jun), "", "Juni");
        pieDataset.setValue(new Integer(jul), "", "Juli");
        pieDataset.setValue(new Integer(agus), "", "Agustus");
        pieDataset.setValue(new Integer(sept), "", "September");
        pieDataset.setValue(new Integer(okt), "", "Oktober");
        pieDataset.setValue(new Integer(nov), "", "November");
        pieDataset.setValue(new Integer(des), "", "Desember");
        JFreeChart chart = ChartFactory.createBarChart3D("STATISTIK KEUANGAN ADMINISTRASI", "BULAN", "JUMLAH",
                (CategoryDataset) pieDataset, PlotOrientation.VERTICAL, false, true, false);
        chart.setBackgroundPaint(Color.yellow);
        chart.getTitle().setPaint(Color.red);

        final CategoryPlot p = chart.getCategoryPlot();

        BarRenderer renderer = (BarRenderer) p.getRenderer();
        DecimalFormat sdf = new DecimalFormat("RP #,##0");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", sdf));
        p.setRenderer(renderer);/*from  w w w  .j  a  v  a2 s.c om*/
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_LEFT));
        renderer.setItemLabelsVisible(true);
        chart.getCategoryPlot().setRenderer(renderer);

        p.setRangeGridlinePaint(Color.blue);
        p.setBackgroundPaint(Color.white);
        ChartFrame frame = new ChartFrame("barchart", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else if (vpil.getSelectedIndex() == 2) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 0)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 1)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 2)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 3)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 4)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 6)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 7)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 8)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 9)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 10)).toString();
        String des = (tabelData.getModel().getValueAt(row, 11)).toString();
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Januari", new Integer(jan));
        pieDataset.setValue("Februari", new Integer(feb));
        pieDataset.setValue("Maret", new Integer(mar));
        pieDataset.setValue("April", new Integer(apr));
        pieDataset.setValue("Mei", new Integer(mei));
        pieDataset.setValue("Juni", new Integer(jun));
        pieDataset.setValue("Juli", new Integer(jul));
        pieDataset.setValue("Agustus", new Integer(agus));
        pieDataset.setValue("September", new Integer(sept));
        pieDataset.setValue("Oktober", new Integer(okt));
        pieDataset.setValue("November", new Integer(nov));
        pieDataset.setValue("Desember", new Integer(des));
        JFreeChart chart = ChartFactory.createPieChart("STATISTIK KEUANGAN ADMINISTRASI", pieDataset, true,
                true, true);
        //        PiePlot3D P = (PiePlot3D)chart.getPlot();
        PiePlot P = (PiePlot) chart.getPlot();
        //P.setForegroundAlpha(TOP_ALIGNMENT);
        ChartFrame frame = new ChartFrame("STATISTIK KEUANGAN ADMINISTRASI", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else {

    }

}

From source file:com.manydesigns.portofino.chart.Chart2DGenerator.java

public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    java.util.List<Object[]> result;
    String query = chartDefinition.getQuery();
    logger.info(query);/* w  ww .  j a v  a 2  s . c  o  m*/
    Session session = persistence.getSession(chartDefinition.getDatabase());
    result = QueryUtils.runSql(session, query);
    for (Object[] current : result) {
        ComparableWrapper x = new ComparableWrapper((Comparable) current[0]);
        ComparableWrapper y = new ComparableWrapper((Comparable) current[1]);
        if (current.length > 3) {
            x.setLabel(current[3].toString());
        }
        if (current.length > 4) {
            y.setLabel(current[4].toString());
        }
        dataset.setValue((Number) current[2], x, y);
    }

    PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL;
    if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) {
        plotOrientation = PlotOrientation.VERTICAL;
    }

    JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation);

    chart.setAntiAlias(antiAlias);

    // impostiamo il bordo invisibile
    // eventualmente e' il css a fornirne uno
    chart.setBorderVisible(borderVisible);

    // impostiamo il titolo
    TextTitle title = chart.getTitle();
    title.setFont(titleFont);
    title.setMargin(10.0, 0.0, 0.0, 0.0);

    // ottieni il Plot
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    CategoryItemRenderer renderer = plot.getRenderer();
    String urlExpression = chartDefinition.getUrlExpression();
    if (!StringUtils.isBlank(urlExpression)) {
        CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression());
        renderer.setBaseItemURLGenerator(urlGenerator);
    } else {
        renderer.setBaseItemURLGenerator(null);
    }
    renderer.setBaseOutlinePaint(Color.BLACK);

    // ///////////////
    if (renderer instanceof BarRenderer) {
        BarRenderer barRenderer = (BarRenderer) renderer;

        barRenderer.setDrawBarOutline(true);
        barRenderer.setShadowVisible(false);
        barRenderer.setBarPainter(new StandardBarPainter());
    }
    // ///////////////

    // il plot ha sfondo e bordo trasparente
    // (quindi si vede il colore del chart)
    plot.setBackgroundPaint(transparentColor);
    plot.setOutlinePaint(transparentColor);

    // Modifico il toolTip
    // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})"));

    // imposta il messaggio se non ci sono dati
    plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available"));
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

    // Category axis
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setAxisLinePaint(Color.BLACK);
    categoryAxis.setLabelFont(axisFont);
    categoryAxis.setAxisLineVisible(true);

    // impostiamo la rotazione dell'etichetta
    if (plot.getOrientation() == PlotOrientation.VERTICAL) {
        CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT,
                TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0,
                CategoryLabelWidthType.CATEGORY, 100);
        CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos);
        categoryAxis.setCategoryLabelPositions(positions);
        categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f);
        height = 333;
    } else {
        categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f);

        // recuperiamo 8 pixel a sinistra
        plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0));

        height = 74;

        // contiamo gli elementi nel dataset
        height += 23 * dataset.getColumnCount();

        height += 57;
    }

    Axis rangeAxis = plot.getRangeAxis();
    rangeAxis.setAxisLinePaint(Color.BLACK);
    rangeAxis.setLabelFont(axisFont);

    DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier());
    plot.setDrawingSupplier(supplier);
    // ?
    plot.setForegroundAlpha(1.0f);
    // impostiamo il titolo della legenda
    String legendString = chartDefinition.getLegend();
    Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM,
            HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0));
    subtitle.setMargin(0, 0, 5, 0);
    chart.addSubtitle(subtitle);

    // impostiamo la legenda
    LegendTitle legend = chart.getLegend();
    legend.setBorder(0, 0, 0, 0);
    legend.setItemFont(legendItemFont);
    int legendMargin = 10;
    legend.setMargin(0.0, legendMargin, legendMargin, legendMargin);
    legend.setBackgroundPaint(transparentColor);

    // impostiamo un gradiente orizzontale
    Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE);
    chart.setBackgroundPaint(chartBgPaint);
    return chart;
}

From source file:net.sourceforge.atunes.kernel.modules.statistics.StatsDialogController.java

/**
 * Sets the general chart./*  w  w  w . j a va  2s .  c o  m*/
 */
private void setGeneralChart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    int different = this.statisticsHandler.getDifferentAudioObjectsPlayed();
    int total = this.repositoryHandler.getAudioFilesList().size();
    dataset.setValue(I18nUtils.getString("SONGS_PLAYED"), different);
    dataset.setValue(I18nUtils.getString("SONGS_NEVER_PLAYED"), total - different);
    JFreeChart chart = ChartFactory.createPieChart3D(I18nUtils.getString("SONGS_PLAYED"), dataset, false, false,
            false);
    chart.setBackgroundPaint(GuiUtils.getBackgroundColor());
    chart.getTitle().setPaint(GuiUtils.getForegroundColor());
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(
            new Paint[] { new Color(0, 1, 0, 0.6f), new Color(1, 0, 0, 0.6f) },
            new Paint[] { new Color(0, 1, 0, 0.4f), new Color(1, 0, 0, 0.4f) },
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE);
    chart.getPlot().setDrawingSupplier(drawingSupplier);
    ((PiePlot3D) chart.getPlot()).setOutlineVisible(false);
    ((PiePlot3D) chart.getPlot()).setBackgroundPaint(GuiUtils.getBackgroundColor());
    getComponentControlled().getGeneralChart().setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java

private JFreeChart initializeChart() {

    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("overview.traceoverview.title"), null, null, createDataset(),
            PlotOrientation.HORIZONTAL, false, true, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis valueRangeAxis = plot.getDomainAxis();
    valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    valueRangeAxis.setMaximumCategoryLabelLines(2);
    valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentile"));
    rangeAxis.setRange(0.0, 100.0);//from ww w .  ja v  a2s  .  c  o m
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String traceInfo = "";
            switch (arg2) {
            case TRACE_AVERAGE:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.avg");
                break;
            case TRACE_ENERGY:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.engy");
                break;
            case TRACE_OVERHEAD:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.ovrhd");
                break;
            default:
                break;
            }

            return traceInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;

}

From source file:com.pusksesmas.form_statistik.statistik_obat_masuk.java

private void tabelDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDataMouseClicked

    if (vpil.getSelectedIndex() == 1) {
        int row = tabelData.getSelectedRow();
        String namaObat = (tabelData.getModel().getValueAt(row, 0)).toString();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();

        DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
        //        pieDataset.setValue("Diagnosa", new Integer(jan));
        pieDataset.setValue(new Integer(jan), "", "Januari");
        pieDataset.setValue(new Integer(feb), "", "Februari");
        pieDataset.setValue(new Integer(mar), "", "Maret");
        pieDataset.setValue(new Integer(apr), "", "April");
        pieDataset.setValue(new Integer(mei), "", "Mei");
        pieDataset.setValue(new Integer(jun), "", "Juni");
        pieDataset.setValue(new Integer(jul), "", "Juli");
        pieDataset.setValue(new Integer(agus), "", "Agustus");
        pieDataset.setValue(new Integer(sept), "", "September");
        pieDataset.setValue(new Integer(okt), "", "Oktober");
        pieDataset.setValue(new Integer(nov), "", "November");
        pieDataset.setValue(new Integer(des), "", "Desember");
        JFreeChart chart = ChartFactory.createBarChart3D("STATISTIK PENERIMAAN OBAT\nNAMA OBAT: " + namaObat,
                "BULAN", "JUMLAH", (CategoryDataset) pieDataset, PlotOrientation.VERTICAL, false, true, false);
        chart.setBackgroundPaint(Color.yellow);
        chart.getTitle().setPaint(Color.red);

        final CategoryPlot p = chart.getCategoryPlot();

        BarRenderer renderer = (BarRenderer) p.getRenderer();
        DecimalFormat sdf = new DecimalFormat("#,##0");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", sdf));
        p.setRenderer(renderer);//from ww w.ja  v a2  s .  c  o m
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
        renderer.setItemLabelsVisible(true);
        chart.getCategoryPlot().setRenderer(renderer);

        p.setRangeGridlinePaint(Color.blue);
        ChartFrame frame = new ChartFrame("barchart", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else if (vpil.getSelectedIndex() == 2) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Januari", new Integer(jan));
        pieDataset.setValue("Februari", new Integer(feb));
        pieDataset.setValue("Maret", new Integer(mar));
        pieDataset.setValue("April", new Integer(apr));
        pieDataset.setValue("Mei", new Integer(mei));
        pieDataset.setValue("Juni", new Integer(jun));
        pieDataset.setValue("Juli", new Integer(jul));
        pieDataset.setValue("Agustus", new Integer(agus));
        pieDataset.setValue("September", new Integer(sept));
        pieDataset.setValue("Oktober", new Integer(okt));
        pieDataset.setValue("November", new Integer(nov));
        pieDataset.setValue("Desember", new Integer(des));
        JFreeChart chart = ChartFactory.createPieChart("STATISTIK PENERIMAAN OBAT", pieDataset, true, true,
                true);
        //        PiePlot3D P = (PiePlot3D)chart.getPlot();
        PiePlot P = (PiePlot) chart.getPlot();
        //P.setForegroundAlpha(TOP_ALIGNMENT);
        ChartFrame frame = new ChartFrame("STATISTIK PENERIMAAN OBAT", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else {

    }

}

From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java

public JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("overview.sessionoverview.title"), null, null,
            createDataset(), PlotOrientation.HORIZONTAL, false, false, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    domainAxis.setMaximumCategoryLabelLines(2);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentage"));
    rangeAxis.setRange(0.0, 100.0);//from   w  w  w.  ja va2  s .c  o  m
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);

    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String sessionInfo = "";
            switch (arg2) {
            case SESSION_TERMINATION:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTermination");
                break;
            case SESSION_TIGHT_CONN:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTightConn");
                break;
            case SESSION_BURST:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionBurst");
                break;
            case SESSION_LONG_BURST:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionLongBurst");
                break;
            default:
                break;
            }

            return sessionInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;
}

From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java

private JFreeChart createDonorsReportsChart(CategoryDataset dataset) {
    JFreeChart barChart = ChartFactory.createBarChart("No Of Registered Donors", "Year", "Registered Donors",
            dataset, PlotOrientation.VERTICAL, true, true, false);
    barChart.setBackgroundPaint(Color.white);
    // Set the background color of the chart
    barChart.getTitle().setPaint(Color.DARK_GRAY);
    barChart.setBorderVisible(true);//w w w  .  ja v a  2  s . c  o m
    // Adjust the color of the title
    CategoryPlot plot = barChart.getCategoryPlot();
    plot.getRangeAxis().setLowerBound(0.0);
    // Get the Plot object for a bar graph
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.blue);
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.decode("#00008B"));
    //return chart;
    return barChart;
}

From source file:uom.research.thalassemia.util.PieChartCreator.java

/**
 * Creates a chart./*from  w  w  w. j a  va 2s . c o m*/
 *
 * @param dataset the dataset.
 *
 * @return A chart.
 */
private JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            true, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    int itemIndex = 0;
    for (Object col : pieDataset.getKeys()) {
        plot.setSectionPaint(col.toString(), gradientPaints[itemIndex]);
        if (itemIndex == pieDataset.getItemCount() - 1) {
            itemIndex = 0;
        }
        itemIndex++;
    }

    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:userinterface.StateNetworkAdminRole.StateReportsJPanel.java

private JFreeChart createpatientDonorReportsChart(CategoryDataset dataset) {
    JFreeChart barChart = ChartFactory.createBarChart("Patients:Donor in the state", "Year",
            "Number of Donors/Patients", dataset, PlotOrientation.VERTICAL, true, true, false);

    barChart.setBackgroundPaint(Color.white);
    // Set the background color of the chart
    barChart.getTitle().setPaint(Color.DARK_GRAY);
    barChart.setBorderVisible(true);// w  w w .ja v  a 2  s  .c  o  m
    // Adjust the color of the title
    CategoryPlot plot = barChart.getCategoryPlot();
    plot.getRangeAxis().setLowerBound(0.0);
    // Get the Plot object for a bar graph
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.blue);
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.decode("#00008B"));
    //return chart;
    return barChart;
}

From source file:com.pusksesmas.form_statistik.statistik_diagnosa.java

private void tabelDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDataMouseClicked

    if (vpil.getSelectedIndex() == 1) {
        int row = tabelData.getSelectedRow();
        String namaPenyakit = (tabelData.getModel().getValueAt(row, 0)).toString();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();

        DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
        //        pieDataset.setValue("Diagnosa", new Integer(jan));
        pieDataset.setValue(new Integer(jan), "", "Januari");
        pieDataset.setValue(new Integer(feb), "", "Februari");
        pieDataset.setValue(new Integer(mar), "", "Maret");
        pieDataset.setValue(new Integer(apr), "", "April");
        pieDataset.setValue(new Integer(mei), "", "Mei");
        pieDataset.setValue(new Integer(jun), "", "Juni");
        pieDataset.setValue(new Integer(jul), "", "Juli");
        pieDataset.setValue(new Integer(agus), "", "Agustus");
        pieDataset.setValue(new Integer(sept), "", "September");
        pieDataset.setValue(new Integer(okt), "", "Oktober");
        pieDataset.setValue(new Integer(nov), "", "November");
        pieDataset.setValue(new Integer(des), "", "Desember");
        JFreeChart chart = ChartFactory.createBarChart3D(
                "STATISTIK HASIL DIGNOSA\nNAMA PENYAKIT: " + namaPenyakit, "BULAN", "JUMLAH",
                (CategoryDataset) pieDataset, PlotOrientation.VERTICAL, false, true, false);
        chart.setBackgroundPaint(Color.yellow);
        chart.getTitle().setPaint(Color.red);

        final CategoryPlot p = chart.getCategoryPlot();

        BarRenderer renderer = (BarRenderer) p.getRenderer();
        DecimalFormat sdf = new DecimalFormat("#,##0");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", sdf));
        p.setRenderer(renderer);/*from  ww  w  .j a  v a 2s .  c  o m*/
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
        renderer.setItemLabelsVisible(true);
        chart.getCategoryPlot().setRenderer(renderer);

        p.setRangeGridlinePaint(Color.blue);
        ChartFrame frame = new ChartFrame("barchart", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else if (vpil.getSelectedIndex() == 2) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Januari", new Integer(jan));
        pieDataset.setValue("Februari", new Integer(feb));
        pieDataset.setValue("Maret", new Integer(mar));
        pieDataset.setValue("April", new Integer(apr));
        pieDataset.setValue("Mei", new Integer(mei));
        pieDataset.setValue("Juni", new Integer(jun));
        pieDataset.setValue("Juli", new Integer(jul));
        pieDataset.setValue("Agustus", new Integer(agus));
        pieDataset.setValue("September", new Integer(sept));
        pieDataset.setValue("Oktober", new Integer(okt));
        pieDataset.setValue("November", new Integer(nov));
        pieDataset.setValue("Desember", new Integer(des));
        JFreeChart chart = ChartFactory.createPieChart("STATISTIK HASIL DIGNOSA", pieDataset, true, true, true);
        //        PiePlot3D P = (PiePlot3D)chart.getPlot();
        PiePlot P = (PiePlot) chart.getPlot();
        //P.setForegroundAlpha(TOP_ALIGNMENT);
        ChartFrame frame = new ChartFrame("STATISTIK HASIL DIGNOSA", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else {

    }

}