Example usage for org.jfree.chart JFreeChart removeSubtitle

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

Introduction

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

Prototype

public void removeSubtitle(Title title) 

Source Link

Document

Removes the specified subtitle and sends a ChartChangeEvent to all registered listeners.

Usage

From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java

public static ChartPanel CreateChartPanel(XYDataset dataset, Color[] colors) {
    XYPlot xy = createXYPlot(dataset, colors);
    JFreeChart chart = new JFreeChart(xy);
    ChartPanel chartPanel = new SpectrumChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setMouseZoomable(true);/*w ww .jav a 2s  .  com*/
    // Remove the autogenerated subtitle
    if (chart.getSubtitleCount() == 1)
        chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1));
    return chartPanel;
}

From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java

public static ChartPanel CreateChartPanel(java.util.List datasets, Color[] colors) {
    if (datasets.size() == 1)
        return CreateChartPanel((XYSeriesCollection) datasets.get(0), colors);

    CombinedDomainXYPlot combined = new CombinedDomainXYPlot();
    for (Iterator it = datasets.iterator(); it.hasNext();) {
        XYSeriesCollection series = (XYSeriesCollection) it.next();
        XYPlot xy = createXYPlot(series, colors);
        combined.add(xy);//from   ww w.j  av  a 2  s .  c  o m
    }
    NumberAxis axisDomain = new NumberAxis();
    axisDomain.setAutoRangeIncludesZero(false);
    //      axisDomain.setRange(400.0, 1600.0);
    combined.setDomainAxis(axisDomain);

    JFreeChart chart = new JFreeChart(combined);
    ChartPanel chartPanel = new SpectrumChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setMouseZoomable(true);
    // Remove the autogenerated subtitle
    if (chart.getSubtitleCount() == 1)
        chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1));
    return chartPanel;
}

From source file:org.yccheok.jstock.gui.charting.DynamicChart.java

/** Creates new form DynamicChart */
public DynamicChart() {
    this.price = new TimeSeries("Price");
    // Sets the maximumItemAge attribute, which specifies the maximum age of data items in the series
    // (in terms of the RegularTimePeriod type used by this series). Whenever a new data value is
    // added, any data items that are older than the limit specified by maximumItemAge are automatically
    // discarded/*w  w w  .jav  a 2 s. c o  m*/
    // Maximum 2 hours.
    this.price.setMaximumItemAge(2 * 60 * 60);

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(this.price);

    JFreeChart freeChart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, true, false);

    freeChart.setAntiAlias(true);
    while (freeChart.getSubtitleCount() > 0) {
        freeChart.removeSubtitle(freeChart.getSubtitle(0));
    }

    // Due to limited spacing, we remove all information regarding x and y axis
    // as well.
    XYPlot plot = freeChart.getXYPlot();
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setVisible(false);

    XYItemRenderer renderer1 = plot.getRenderer();
    renderer1.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#")));

    org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart);

    // Disable zoom.
    chartPanel = new ChartPanel(freeChart, true, true, true, false, true);
    chartPanel.setMouseZoomable(false);
}

From source file:org.martus.client.swingui.actions.ActionMenuCharts.java

private void runChart(ChartAnswers answers) {
    try {/*from   w  w  w . ja  v  a 2  s  . c  o m*/
        SearchTreeNode searchTree = getMainWindow().askUserForSearchCriteria();
        if (searchTree == null)
            return;

        MiniFieldSpec fieldToCount = answers.getFieldToCount();
        MiniFieldSpec[] extraSpecs = new MiniFieldSpec[] { fieldToCount };
        SortableBulletinList sortableList = doSearch(searchTree, extraSpecs, new MiniFieldSpec[] {},
                "ReportSearchProgress");
        if (sortableList == null)
            return;

        HashMap<String, Integer> counts = extractBulletinCounts(fieldToCount, sortableList);

        // TODO: Use or delete these
        //         ChartRenderingInfo info = new ChartRenderingInfo();
        //         EntityCollection entities = new StandardEntityCollection();

        //         JFreeChart bar3dChart = create3DBarChart(counts, labelText);

        JFreeChart chart = createChart(answers, fieldToCount, counts);

        chart.removeSubtitle(new DateTitle());

        UiChartPreviewDlg preview = new UiChartPreviewDlg(getMainWindow(), chart);
        preview.setVisible(true);
        if (preview.wasCancelButtonPressed())
            return;
        boolean sendToDisk = preview.wantsPrintToDisk();

        boolean didPrint = false;
        if (sendToDisk)
            didPrint = printToDisk(chart);
        else
            didPrint = printToPrinter(chart);

        if (didPrint)
            mainWindow.notifyDlg("ChartCompleted");
    } catch (Exception e) {
        MartusLogger.logException(e);
        getMainWindow().notifyDlg("ChartUnknownError");
    }
}