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.tencent.wstt.apt.chart.CPURealTimeChart.java

@Override
public JFreeChart createChart() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU", "", "CPU%", dataset,
            true, true, false);//from   ww  w.  ja v  a2s .  co  m

    //??
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));

    XYPlot xyPlot = (XYPlot) chart.getXYPlot();
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    ValueAxis rangeAxis = xyPlot.getRangeAxis();

    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

    rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
    rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    return chart;
}

From source file:userInterface.MonitoringTeamRole.DashBoarJPanel.java

private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked
    // TODO add your handling code here:

    JFreeChart chart = createChart(createDataset());
    chart.setBackgroundPaint(Color.YELLOW);
    chart.getTitle().setPaint(Color.red);

    ChartFrame frame = new ChartFrame("XYChart", chart);
    frame.setVisible(true);/*from w  w  w .  j ava  2 s  .co  m*/
    frame.setSize(450, 500);
}

From source file:userInterface.MonitoringTeamRole.DashBoarJPanel.java

private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked
    // TODO add your handling code here:

    JFreeChart chart1 = createChart1(createDataset1());
    chart1.setBackgroundPaint(Color.YELLOW);
    chart1.getTitle().setPaint(Color.red);

    ChartFrame frame = new ChartFrame("XYChart", chart1);
    frame.setVisible(true);/*from  ww  w.j  a v a2 s. c  o  m*/
    frame.setSize(450, 500);
}

From source file:com.tencent.wstt.apt.chart.MemoryRealTimeChart.java

@Override
public JFreeChart createChart() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "",
            "kB", dataset, true, true, false);

    //??//ww w.  j  a v  a2 s.  c o m
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));

    XYPlot xyPlot = (XYPlot) chart.getXYPlot();
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    ValueAxis rangeAxis = xyPlot.getRangeAxis();

    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

    rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
    rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    //rangeAxis.setAutoRange(true);

    //rangeAxis.setAutoTickUnitSelection(true);

    return chart;
}

From source file:userInterface.MonitoringTeamRole.AnalysisJPanel.java

private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked
    // TODO add your handling code here:

    JFreeChart chart = createChart(createDataset());
    chart.setBackgroundPaint(Color.YELLOW);
    chart.getTitle().setPaint(Color.red);

    ChartFrame frame = new ChartFrame("XYChart", chart);
    frame.setVisible(true);/*  ww  w .ja  va  2s .co  m*/
    frame.setSize(450, 500);
}

From source file:net.relet.freimap.NodeInfo.java

private void sexupLayout(JFreeChart chart) {
    chart.setAntiAlias(true);//w  w w  .  ja v  a 2 s .c o m
    chart.setBackgroundPaint(VisorFrame.bgcolor);
    chart.setBorderVisible(false);
    TextTitle title = chart.getTitle();
    title.setFont(VisorFrame.smallerfont);
    title.setPaint(VisorFrame.fgcolor);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(VisorFrame.bgcolor);
    plot.setDomainAxis(new DateAxis());
    sexupAxis(plot.getDomainAxis());
    sexupAxis(plot.getRangeAxis());
}

From source file:org.apache.qpid.disttest.charting.chartbuilder.ChartProductionTest.java

private void assertChartTitlesAndWriteToFile(ChartBuilder builder) {
    JFreeChart chart = builder.buildChart(_chartingDefinition);
    assertEquals(TEST_CHARTTITLE, chart.getTitle().getText());
    assertEquals(TEST_CHARTSUBTITLE, ((ShortTextTitle) chart.getSubtitle(1)).getText());
    assertEquals(TEST_SERIESLEGEND, chart.getPlot().getLegendItems().get(0).getLabel());

    if (chart.getPlot() instanceof XYPlot) {
        assertEquals(1, chart.getXYPlot().getDatasetCount());
    } else {/*from   w w w.j  a  v  a 2  s.  co  m*/
        assertEquals(1, chart.getCategoryPlot().getDatasetCount());
    }

    _writer.writeChartToFileSystem(chart, _chartingDefinition);
}

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

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;//from  w w w. ja va  2  s.  com

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "n", // 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);
    // 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();
    // set the default stroke for all series
    int i = 0;
    for (String celltype : getTimeSeries().getDataSeriesNames()) {
        r.setSeriesPaint(i, CellTypeColor.getColor(celltype));
        i++;
    }
    r.setSeriesPaint(i, Color.BLACK);
    return xyLineChart;
}

From source file:no.imr.sea2data.guibase.chart.XYBarChart.java

public XYBarChart() {
    dataset = new XYSeriesCollection(new XYSeries("Series 1"));
    JFreeChart chart = ChartFactory.createXYBarChart("", "X axis", false, "Y axis", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setBackgroundPaint(Color.white);
    chart.getTitle().setPaint(Color.black);
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, 12));
    chart.addSubtitle(trendLegend);//  w ww .  j  a  va 2s  .  c  o m
    chart.addSubtitle(trendLegend2);
    trendLegend.setPosition(RectangleEdge.TOP);
    trendLegend2.setPosition(RectangleEdge.TOP);
    plot = (XYPlot) chart.getPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setShadowVisible(false);
    chartPanel = new ChartPanel(chart);
    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
}

From source file:lectorarchivos.MostrarGraficaCSV.java

/**
 * Creates new form MostrarGraficaCSV/*from www  .j  av  a  2  s. com*/
 */
public MostrarGraficaCSV(JTable jTableInfoCSV) {
    initComponents();
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    panel = new JPanel();
    getContentPane().add(panel);

    //Fuente de datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //Recorremos la columna del consumo de la tabla
    for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) {
        if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0)
            dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo",
                    jTableInfoCSV.getValueAt(i, 0).toString());
    }

    //Creando el grfico
    JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.cyan);
    chart.getTitle().setPaint(Color.black);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    //Cambiar color de barras
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setSeriesPaint(0, Color.decode("#5882FA"));

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("CONSUMO", chart);
    frame.pack();
    frame.getChartPanel().setMouseZoomable(false);
    frame.setVisible(true);

    panel.add(frame);

}