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:cz.cvut.kbe.crypthelper.ui.MainPanel.java

private void styleChart(JFreeChart chart) {
    chart.getTitle().setPaint(Color.BLACK);
    chart.setBackgroundPaint(new Color(1f, 1f, 1f, 0f));

    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.red);
}

From source file:info.novatec.testit.livingdoc.confluence.macros.historic.AggregationExecutionChartBuilder.java

@SuppressWarnings("deprecation")
private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(ldUtil.getText("livingdoc.historic.nodata"));

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    plot.setRenderer(renderer);/*from   w ww .j  a  va 2 s  .  c o  m*/

    int index = 0;
    renderer.setSeriesPaint(index++, GREEN_COLOR);
    if (settings.isShowIgnored()) {
        renderer.setSeriesPaint(index++, Color.yellow);
    }
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new DefaultTooltipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        @Override
        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable<?> valueKey = data.getColumnKey(category);
            ChartLongValue value = (ChartLongValue) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showHistoricChart('" + value.getId() + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0.01);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(1.0);

    if (rangeAxis instanceof NumberAxis) {
        NumberAxis numberAxis = (NumberAxis) rangeAxis;
        numberAxis.setTickUnit(new NumberTickUnit(.10));
        numberAxis.setNumberFormatOverride(PERCENT_FORMATTER);
    }

    plot.setForegroundAlpha(0.8f);
}

From source file:GeMSE.Visualization.ElbowPlot.java

public void Plot(ArrayList<Double[]> pvData, ArrayList<Double[]> dData, int cut) {
    double maxY = 0;

    float[] secYColor = new float[3];
    Color.RGBtoHSB(153, 245, 255, secYColor);

    float[] priYColor = new float[3];
    Color.RGBtoHSB(255, 255, 255, priYColor);

    float[] cutColor = new float[3];
    Color.RGBtoHSB(255, 255, 0, cutColor);

    //create the series - add some dummy data
    XYSeries pvSeries = new XYSeries("Percentage of variance        ");
    for (int i = 1; i < pvData.size(); i++) {
        pvSeries.add(pvData.get(i)[0], pvData.get(i)[1]);
        maxY = Math.max(maxY, pvData.get(i)[1]);
    }/*from   w ww .j ava  2s.c  o m*/

    XYSeries dSeries = new XYSeries("Percentage of differences between slopes        ");
    for (int i = 0; i < dData.size(); i++)
        dSeries.add(dData.get(i)[0], dData.get(i)[1]);

    XYSeries cutSeries = new XYSeries("Cut        ");
    cutSeries.add(cut, 0.0);
    cutSeries.add(cut, maxY);

    //create the datasets
    XYSeriesCollection pvDataSeries = new XYSeriesCollection();
    pvDataSeries.addSeries(pvSeries);

    XYSeriesCollection cutDataSeries = new XYSeriesCollection();
    cutDataSeries.addSeries(cutSeries);

    XYSeriesCollection dDataSeries = new XYSeriesCollection();
    dDataSeries.addSeries(dSeries);

    //construct the plot
    XYPlot plot = new XYPlot();
    plot.setDataset(0, pvDataSeries);
    plot.setDataset(1, cutDataSeries);
    plot.setDataset(2, dDataSeries);

    // use XYSplineRenderer if you want to smooth the lines.
    XYLineAndShapeRenderer pvRenderer = new XYLineAndShapeRenderer();
    pvRenderer.setSeriesPaint(0, Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2]));

    BasicStroke dstroke = new BasicStroke(2.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 1.0f, 10.0f }, 0.0f);
    XYLineAndShapeRenderer dRenderer = new XYLineAndShapeRenderer();
    dRenderer.setSeriesPaint(0, Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2]));
    dRenderer.setSeriesStroke(0, dstroke);

    BasicStroke cutStoke = new BasicStroke(4);
    // use XYSplineRenderer if you want to smooth the lines.
    //XYSplineRenderer cutRenderer = new XYSplineRenderer();
    XYLineAndShapeRenderer cutRenderer = new XYLineAndShapeRenderer();
    cutRenderer.setSeriesPaint(0, Color.getHSBColor(cutColor[0], cutColor[1], cutColor[2]));
    cutRenderer.setSeriesStroke(0, cutStoke);

    plot.setRenderer(0, pvRenderer);
    plot.setRenderer(1, cutRenderer);
    plot.setRenderer(2, dRenderer);

    plot.setRangeAxis(0, new NumberAxis("\n\nPercentage of Variance"));
    plot.setRangeAxis(1, new NumberAxis("Percentage of Difference Between Slopes"));
    plot.setDomainAxis(new NumberAxis("Number of Clusters\n\n"));

    //Map the data to the appropriate axis
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToRangeAxis(1, 0);
    plot.mapDatasetToRangeAxis(2, 1);

    float[] hsbValues = new float[3];
    Color.RGBtoHSB(16, 23, 67, hsbValues);
    plot.setBackgroundPaint(Color.getHSBColor(hsbValues[0], hsbValues[1], hsbValues[2]));

    Font axisLabelFont = new Font("Dialog", Font.PLAIN, 14);
    Font axisTickLabelFont = new Font("Dialog", Font.PLAIN, 12);
    Font legendFont = new Font("Dialog", Font.PLAIN, 14);

    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);

    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setLabelFont(axisLabelFont);
    plot.getDomainAxis().setTickLabelFont(axisTickLabelFont);

    plot.getRangeAxis().setTickLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2]));
    plot.getRangeAxis().setLabelPaint(Color.getHSBColor(priYColor[0], priYColor[1], priYColor[2]));
    plot.getRangeAxis().setLabelFont(axisLabelFont);
    plot.getRangeAxis().setTickLabelFont(axisTickLabelFont);

    plot.getRangeAxis(1).setTickLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2]));
    plot.getRangeAxis(1).setLabelPaint(Color.getHSBColor(secYColor[0], secYColor[1], secYColor[2]));
    plot.getRangeAxis(1).setLabelFont(axisLabelFont);
    plot.getRangeAxis(1).setTickLabelFont(axisTickLabelFont);

    //generate the chart
    JFreeChart chart = new JFreeChart("\nSuggested number of clusters determined using Elbow method", getFont(),
            plot, true);

    chart.getTitle().setPaint(Color.white);
    chart.getLegend().setBackgroundPaint(Color.black);
    chart.getLegend().setItemPaint(Color.white);
    chart.getLegend().setPosition(RectangleEdge.BOTTOM);
    chart.getLegend().setItemFont(legendFont);

    float[] hsbValues2 = new float[3];
    Color.RGBtoHSB(36, 43, 87, hsbValues2);
    chart.setBackgroundPaint(Color.getHSBColor(hsbValues2[0], hsbValues2[1], hsbValues2[2]));
    JPanel chartPanel = new ChartPanel(chart);

    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    chartPanel.setPreferredSize(
            new java.awt.Dimension((int) Math.round((gd.getDisplayMode().getWidth() * 1.5) / 3.0),
                    (int) Math.round((gd.getDisplayMode().getHeight() * 1.5) / 3.0)));

    setContentPane(chartPanel);
}

From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java

private void setGeneralChart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    int different = HandlerProxy.getRepositoryHandler().getDifferentSongsPlayed();
    int total = HandlerProxy.getRepositoryHandler().getSongs().size();
    dataset.setValue(LanguageTool.getString("SONGS_PLAYED"), different);
    dataset.setValue(LanguageTool.getString("SONGS_NEVER_PLAYED"), total - different);
    JFreeChart chart = ChartFactory.createPieChart3D(LanguageTool.getString("SONGS_PLAYED"), dataset, false,
            false, false);/*from   w  w  w .j a v  a2s . c  o  m*/
    chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0,
            200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    chart.getPlot()
            .setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR,
                    0, 200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    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);
    ((StatsDialog) frameControlled).getGeneralChart()
            .setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:UserInterface.DonorRole.DonorRecordsJPanel.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    int selectedRow = donorHormoneLevelsJTbl.getSelectedRow();
    if (selectedRow >= 0) {
        double lHLevel = 0.0;
        double FSH = 0.0;
        double hcg = 0.0;
        for (Employee donor : organization.getEmployeeDirectory().getEmployeeList()) {
            if (donor.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
                for (HormonalRecords hr : donor.getHormonalRecordsHistory().getHormonalRecordsList()) {
                    //hr = (HormonalRecords)donorHormoneLevelsJTbl.getValueAt(selectedRow,0);

                    lHLevel = hr.getLeutinizingHormoneLevels();
                    FSH = hr.getFollicleStimulatingHormoneLevels();
                    hcg = hr.gethCGLevels();

                }//  ww w. j  a va2  s.  c o  m
                DefaultCategoryDataset data = new DefaultCategoryDataset();
                data.setValue(lHLevel, "Value", "LH level");
                data.setValue(FSH, "Value", "FSH level");
                data.setValue(hcg, "Value", "HCG level");

                JFreeChart chart = ChartFactory.createBarChart3D("Hormonal Level Stats", "Hormonal Parameters",
                        "Values", data);
                chart.setBackgroundPaint(Color.WHITE);
                chart.getTitle().setPaint(Color.BLUE);
                CategoryPlot p = chart.getCategoryPlot();
                p.setRangeGridlinePaint(Color.RED);
                ChartFrame frame = new ChartFrame("Bar Chart for Donor", chart);
                frame.setVisible(true);
                frame.setSize(450, 350);
            }
        }

    }

    else {
        JOptionPane.showMessageDialog(null, "Please select a row from the table", "Warning",
                JOptionPane.WARNING_MESSAGE);
    }

}

From source file:com.ohalo.cn.awt.JFreeChartTest.java

public List<JFreeChart> printHardDiskCharts() throws SigarException {
    Sigar sigar = new Sigar();
    FileSystem fslist[] = sigar.getFileSystemList();
    ArrayList<JFreeChart> charts = new ArrayList<JFreeChart>();

    for (int i = 0; i < fslist.length; i++) {
        FileSystem fs = fslist[i];

        String diskName = fs.getDevName();

        FileSystemUsage usage = null;//www . ja va 2 s .com
        try {
            usage = sigar.getFileSystemUsage(fs.getDirName());
        } catch (SigarException e) {
            if (fs.getType() == 2)
                throw e;
            continue;
        }

        DefaultPieDataset dpd = new DefaultPieDataset(); // 

        if (fs.getType() == 2) {
            dpd.setValue("??(" + usage.getAvail() / 1024 / 1024 + "GB)",
                    usage.getAvail());
            dpd.setValue("?(" + usage.getUsed() / 1024 / 1024 + "GB)", usage.getUsed());
        }
        JFreeChart chart = ChartFactory.createPieChart("???", dpd, true, true,
                false);

        chart.setTitle(":" + diskName);
        Font font2 = new Font("", Font.BOLD, 12);
        chart.getTitle().setFont(font2);
        PiePlot pieplot = (PiePlot) chart.getPlot();
        pieplot.setLabelFont(font2);
        chart.getLegend().setItemFont(font2);
        charts.add(chart);
    }

    return charts;
}

From source file:UserInterface.ReciepientRole.RecepientRecordJPanel.java

private void viewStatsJBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewStatsJBtnActionPerformed
    int selectedRow = recHormonalRecordsJTbl.getSelectedRow();
    if (selectedRow >= 0) {
        double lHLevel = 0.0;
        double FSH = 0.0;
        double hcg = 0.0;
        for (Employee donor : organization.getEmployeeDirectory().getEmployeeList()) {
            if (donor.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
                for (HormonalRecords hr : donor.getHormonalRecordsHistory().getHormonalRecordsList()) {
                    //hr = (HormonalRecords)donorHormoneLevelsJTbl.getValueAt(selectedRow,0);

                    lHLevel = hr.getLeutinizingHormoneLevels();
                    FSH = hr.getFollicleStimulatingHormoneLevels();
                    hcg = hr.gethCGLevels();

                }//from   w  w w.  j a v  a2  s . co  m
                DefaultCategoryDataset data = new DefaultCategoryDataset();
                data.setValue(lHLevel, "Value", "LH level");
                data.setValue(FSH, "Value", "FSH level");
                data.setValue(hcg, "Value", "HCG level");

                JFreeChart chart = ChartFactory.createBarChart3D("Hormonal Level Stats", "Hormonal Parameters",
                        "Values", data);
                chart.setBackgroundPaint(Color.WHITE);
                chart.getTitle().setPaint(Color.BLUE);
                CategoryPlot p = chart.getCategoryPlot();
                p.setRangeGridlinePaint(Color.RED);
                ChartFrame frame = new ChartFrame("Bar Chart for Donor", chart);
                frame.setVisible(true);
                frame.setSize(450, 350);
            }
        }

    }

    else {
        JOptionPane.showMessageDialog(null, "Please select a row from the table", "Warning",
                JOptionPane.WARNING_MESSAGE);

    }
}

From source file:de.hs.mannheim.modUro.diagram.JTimeSeriesDiagram.java

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;/*www .ja va  2 s. c  o  m*/

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "f", // y-axis label
            dataset);

    String fontName = "Palatino";
    xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));

    XYPlot plot = (XYPlot) xyLineChart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLowerMargin(0.0);
    if (isMetric) {
        plot.getRangeAxis().setRange(0.0, 1.01);
    }
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    xyLineChart.getLegend().setFrame(BlockBorder.NONE);
    xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setDrawSeriesLineAsPath(true);
        // set the default stroke for all series
        renderer.setAutoPopulateSeriesStroke(false);
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setSeriesPaint(1, new Color(24, 123, 58));
        renderer.setSeriesPaint(2, new Color(149, 201, 136));
        renderer.setSeriesPaint(3, new Color(1, 62, 29));
        renderer.setSeriesPaint(4, new Color(81, 176, 86));
        renderer.setSeriesPaint(5, new Color(0, 55, 122));
        renderer.setSeriesPaint(6, new Color(0, 92, 165));
    }

    return xyLineChart;
}

From source file:GUI.Statistique.java

private ChartPanel calculerBudget() {
    ProduitDAO produitDAO = new ProduitDAO();
    List<Produit> produits = new ArrayList<>();
    produits = produitDAO.findAll();// www.j a  va2 s.  c  om
    CommandeDAO commandeDAO = new CommandeDAO();
    List<Commande> commandes = new ArrayList<>();
    commandes = commandeDAO.findAll();
    DefaultPieDataset dSet = new DefaultPieDataset();
    for (Produit produit : produits) {
        dSet.setValue(produit.getNom(), produit.getNbvente());
        System.out.println(produit.getNbvente());
    }
    JFreeChart chart = ChartFactory.createPieChart3D("liste des produits les plus vendus", dSet, true, true,
            true);
    chart.setBackgroundPaint(Color.yellow);
    chart.getTitle().setPaint(Color.RED);
    PiePlot3D p = (PiePlot3D) chart.getPlot();
    ChartPanel cp = new ChartPanel(chart, true, true, true, true, true);
    JFrame f = new JFrame();
    f.setContentPane(cp);
    f.pack();
    jpBudjet.add(cp);
    return cp;
}

From source file:net.sourceforge.atunes.kernel.controllers.stats.StatsDialogController.java

private void setSongsChart() {
    DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedSongs(10));
    JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("SONG_MOST_PLAYED"), null,
            null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
    chart.getTitle().setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    chart.setBackgroundPaint(new GradientPaint(0, 0, ColorDefinitions.GENERAL_NON_PANEL_TOP_GRADIENT_COLOR, 0,
            200, ColorDefinitions.GENERAL_NON_PANEL_BOTTOM_GRADIENT_COLOR));
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    NumberAxis axis = new NumberAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    axis.setTickLabelFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
    chart.getCategoryPlot().setRangeAxis(axis);
    chart.getCategoryPlot().setForegroundAlpha(0.6f);
    chart.getCategoryPlot().getRenderer().setPaint(Color.GREEN);

    ((StatsDialog) frameControlled).getSongsChart().setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}