Example usage for org.jfree.chart JFreeChart setPadding

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

Introduction

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

Prototype

public void setPadding(RectangleInsets padding) 

Source Link

Document

Sets the padding between the chart border and the chart drawing area, and sends a ChartChangeEvent to all registered listeners.

Usage

From source file:ec.ui.view.RevisionSaSeriesView.java

private JFreeChart createMainChart() {
    XYPlot plot = new XYPlot();
    configureAxis(plot);//from  w  w w .  j  a  va2 s .  c  o m

    plot.setRenderer(S_INDEX, sRenderer);

    plot.setRenderer(REV_INDEX, revRenderer);

    plot.setNoDataMessage("Not enough data to compute revision history !");
    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);
    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

From source file:be.nbb.demetra.dfm.output.FactorChart.java

private JFreeChart createMarginViewChart() {
    JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    XYPlot plot = result.getXYPlot();/*w  w w  .  j a v a  2  s  .co  m*/
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer factor = new LineRenderer(FACTOR_INDEX);
    plot.setRenderer(FACTOR_INDEX, factor);

    XYLineAndShapeRenderer filtered = new LineRenderer(FILTERED_INDEX);
    plot.setRenderer(FILTERED_INDEX, filtered);

    XYDifferenceRenderer difference = new XYDifferenceRenderer();
    difference.setAutoPopulateSeriesPaint(false);
    difference.setAutoPopulateSeriesStroke(false);
    difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness));
    plot.setRenderer(DIFFERENCE_INDEX, difference);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a sparkline chart.//from   w  w w  .  ja  v a  2 s  .c  om
 *
 * @return A sparkline chart.
 */
private static JFreeChart createSparklineChart() {
    GXYPlot plot = new GXYPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);
    JFreeChart chart = new JFreeChart(plot);
    chart.setPadding(RectangleInsets.ZERO_INSETS);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    renderer.setBasePaint(new Color(0xFF9900));
    renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:ec.ui.view.StabilityView.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    plot.setDataset(SMOOTH_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(SMOOTH_INDEX, smoothRenderer);
    plot.mapDatasetToDomainAxis(SMOOTH_INDEX, 0);
    plot.mapDatasetToRangeAxis(SMOOTH_INDEX, 0);

    plot.setDataset(MEAN_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(MEAN_INDEX, meanRenderer);
    plot.mapDatasetToDomainAxis(MEAN_INDEX, 0);
    plot.mapDatasetToRangeAxis(MEAN_INDEX, 0);

    plot.setDataset(POINTS_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(POINTS_INDEX, pointsRenderer);
    plot.mapDatasetToDomainAxis(POINTS_INDEX, 0);
    plot.mapDatasetToRangeAxis(POINTS_INDEX, 0);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);
    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

From source file:com.opensourcestrategies.activities.reports.ActivitiesChartsService.java

private String createPieChart(DefaultPieDataset dataset, String title)
        throws InfrastructureException, IOException {
    Debug.logInfo("Charting dashboard [" + title + "]", MODULE);
    // set up the chart
    JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, // include legend
            true, // tooltips
            false // urls
    );/*w  w w .j av a  2  s.  c  om*/
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // get a reference to the plot for further customization...
    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setCircular(true);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {1} / {2}",
            NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
    plot.setNoDataMessage("No data available");

    Color[] colors = {
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_NEW_COLOR)),
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_OLD_COLOR)),
            Color.decode("#" + infrastructure.getConfigurationValue(
                    OpentapsConfigurationTypeConstants.ACTIVITIES_DASHBOARD_LEADS_NO_ACTIVITY_COLOR)) };
    for (int i = 0; i < dataset.getItemCount(); i++) {
        Comparable<?> key = dataset.getKey(i);
        plot.setSectionPaint(key, colors[i]);
    }

    // save as a png and return the file name
    return ServletUtilities.saveChartAsPNG(chart, chartWidth, chartHeight, null);
}

From source file:ec.nbdemetra.ui.chart3d.functions.Functions2DChart.java

private JFreeChart createChart() {
    XYPlot plot = new XYPlot();

    plot.setDataset(0, Charts.emptyXYDataset());
    plot.setRenderer(0, functionRenderer);
    plot.mapDatasetToDomainAxis(0, 0);/*from  w  ww.  j  a v a 2s. com*/
    plot.mapDatasetToRangeAxis(0, 0);

    plot.setDataset(1, Charts.emptyXYDataset());
    plot.setRenderer(1, optimumRenderer);
    plot.mapDatasetToDomainAxis(1, 0);
    plot.mapDatasetToRangeAxis(1, 0);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false);

    LegendTitle legend = new LegendTitle(result.getPlot());
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.white);
    legend.setPosition(RectangleEdge.BOTTOM);
    result.addLegend(legend);

    result.setPadding(TsCharts.CHART_PADDING);
    return result;
}

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

/**
 * Puts image with chart in given label, with title and data provided
 * /*  w  ww  .  j  a  v  a  2 s  .co  m*/
 * @param data
 * @param titleKey
 * @param chartLabel
 */
private void setChart(final List<?> data, final String titleKey, final JLabel chartLabel) {
    DefaultCategoryDataset dataset = getDataSet(data);
    JFreeChart chart = ChartFactory.createStackedBarChart3D(I18nUtils.getString(titleKey), null, null, dataset,
            PlotOrientation.HORIZONTAL, false, false, false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    NumberAxis axis = new NumberAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.setBackgroundPaint(GuiUtils.getBackgroundColor());
    chart.getTitle().setPaint(GuiUtils.getForegroundColor());
    chart.getCategoryPlot().setRangeAxis(axis);
    chart.getCategoryPlot().setForegroundAlpha(1f);
    chart.getCategoryPlot().getRenderer().setSeriesPaint(0, Color.GREEN);
    chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(GuiUtils.getForegroundColor());
    chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(GuiUtils.getForegroundColor());
    chart.getPlot().setBackgroundPaint(GuiUtils.getBackgroundColor());
    chartLabel.setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:ec.ui.view.MarginView.java

private JFreeChart createMarginViewChart() {
    JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    XYPlot plot = result.getXYPlot();/*from w w w  . j a  v a2 s . co  m*/
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer main = new LineRenderer();
    plot.setRenderer(MAIN_INDEX, main);

    XYDifferenceRenderer difference = new XYDifferenceRenderer();
    difference.setAutoPopulateSeriesPaint(false);
    difference.setAutoPopulateSeriesStroke(false);
    difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness));
    plot.setRenderer(DIFFERENCE_INDEX, difference);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

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 va2  s . 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:net.sourceforge.atunes.kernel.modules.statistics.StatsDialogController.java

/**
 * Sets the general chart./*from w ww.  j av  a 2s. com*/
 */
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)));
}