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:be.nbb.demetra.dfm.output.ConfidenceGraph.java

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

    XYPlot plot = result.getXYPlot();//from   www .j  a v  a 2s. c om
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

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

    XYLineAndShapeRenderer original = new LineRenderer(ORIGINAL_DATA_INDEX);
    plot.setRenderer(ORIGINAL_DATA_INDEX, original);

    for (int i = 0; i < indexes.length - 1; i++) {
        plot.setRenderer(indexes[i], getDifferenceRenderer());
        for (int j = 1; j < intermediateValues; j++) {
            plot.setRenderer(indexes[i] - j, getDifferenceRenderer());
        }
    }

    plot.setRenderer(CONFIDENCE99_INDEX, getDifferenceRenderer());

    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 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)));
}

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

private void setAlbumsChart() {
    DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedAlbums(10));
    JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ALBUM_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).getAlbumsChart()
            .setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

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

private void setArtistsChart() {
    DefaultCategoryDataset dataset = getDataSet(HandlerProxy.getRepositoryHandler().getMostPlayedArtists(10));
    JFreeChart chart = ChartFactory.createStackedBarChart3D(LanguageTool.getString("ARTIST_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).getArtistsChart()
            .setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java

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

    plot.setDataset(TRUE_DATA_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(TRUE_DATA_INDEX, trueDataRenderer);
    plot.mapDatasetToDomainAxis(TRUE_DATA_INDEX, 0);
    plot.mapDatasetToRangeAxis(TRUE_DATA_INDEX, 0);

    plot.setDataset(FCTS_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(FCTS_INDEX, forecastsRenderer);
    plot.mapDatasetToDomainAxis(FCTS_INDEX, 0);
    plot.mapDatasetToRangeAxis(FCTS_INDEX, 0);

    plot.setDataset(ARIMA_DATA_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(ARIMA_DATA_INDEX, arimaRenderer);
    plot.mapDatasetToDomainAxis(ARIMA_DATA_INDEX, 0);
    plot.mapDatasetToRangeAxis(ARIMA_DATA_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:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java

private JFreeChart createChart() {
    JFreeChart result = ChartFactory.createXYBarChart("", "", false, "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);
    result.getTitle().setFont(TsCharts.CHART_TITLE_FONT);

    XYPlot plot = result.getXYPlot();/*from  www. java2s .  c  o m*/

    plot.setDataset(DFM_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(DFM_INDEX, dfmRenderer);
    plot.mapDatasetToDomainAxis(DFM_INDEX, 0);
    plot.mapDatasetToRangeAxis(DFM_INDEX, 0);

    plot.setDataset(ARIMA_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(ARIMA_INDEX, arimaRenderer);
    plot.mapDatasetToDomainAxis(ARIMA_INDEX, 0);
    plot.mapDatasetToRangeAxis(ARIMA_INDEX, 0);

    plot.setDataset(STDEV_INDEX, Charts.emptyXYDataset());
    plot.setRenderer(STDEV_INDEX, stdevRenderer);
    plot.mapDatasetToDomainAxis(STDEV_INDEX, 0);
    plot.mapDatasetToRangeAxis(STDEV_INDEX, 0);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

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

    NumberAxis domainAxis = new NumberAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    return result;
}

From source file:com.epiq.bitshark.ui.FrequencyDomainPanel.java

/**
 * Initialize the graph//  w  w w  .j  a v a 2s  .  co m
 */
private void initGraph() {

    this.series = new BasicSeries("FFT");
    XYSeriesCollection dataset = new XYSeriesCollection(series);

    JFreeChart graph = ChartFactory.createXYLineChart(null, // title
            "", // no x-axis label
            "", // no y-axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // no legend
            false, // no tooltips
            false // no URLs
    );

    graph.setBorderVisible(false);
    graph.setPadding(new RectangleInsets(-5, 0, 0, 0));
    graph.setBackgroundPaint(null);
    graph.setBackgroundImageAlpha(0.0f);
    graph.setAntiAlias(true);

    plot = (XYPlot) graph.getPlot();

    powerAxis = new PowerAxis();
    plot.setRangeAxis(powerAxis);

    frequencyAxis = new FrequencyAxis();
    frequencyAxis.setTickLabelInsets(new RectangleInsets(10, 0, 0, 0));
    plot.setDomainAxis(frequencyAxis);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setBaseShapesFilled(true);
        renderer.setSeriesPaint(0, Common.EPIQ_GREEN);
        renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    }

    plot.setBackgroundAlpha(0.0f);
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

    // X-axis setup
    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setVisible(true);
    plot.getDomainAxis().setRange(0, FMCUartClient.BLOCK_SIZE - 1);
    plot.setDomainCrosshairVisible(false);
    plot.setDomainCrosshairPaint(new Color(46, 46, 46));

    // Y-axis setup
    plot.getRangeAxis().setAutoRange(false);
    plot.getRangeAxis().setVisible(true);
    plot.getRangeAxis().setRange(-50, 70);
    plot.setRangeCrosshairVisible(false);

    markerAnnotation.setVisible(false);
    plot.addAnnotation(markerAnnotation);
    plot.addAnnotation(markerTextAnnotation);

    this.markerTitle.setFont(new Font("Tahoma", Font.BOLD, 12));
    this.markerTitle.setFrame(new BlockBorder(new Color(46, 46, 46)));
    this.markerTitle.setBackgroundPaint(new Color(200, 200, 255, 100));
    this.markerTitle.setText("");
    this.markerTitle.setPadding(5, 15, 5, 15);
    this.markerTitle.setExpandToFitSpace(false);
    this.markerTitle.setBounds(new Rectangle2D.Double(0, 0, 100, 30));

    chartPanel = new ChartPanel(graph, false);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMouseZoomable(true);
    chartPanel.setOpaque(false);

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            markerLocked = !markerLocked;
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            updateMouseMarker(event);
        }

    });

    chartPanel.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
            if (!markerLocked) {
                markerAnnotation.setVisible(false);
                plot.setDomainCrosshairVisible(false);
                markerTitle.setVisible(false);
                markerTitle.setText("");
            }
        }

    });

    chartPanel.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            int clicks = e.getWheelRotation();
            plot.getRangeAxis().setUpperBound(plot.getRangeAxis().getUpperBound() + clicks);
            plot.getRangeAxis().setLowerBound(plot.getRangeAxis().getLowerBound() + clicks);
        }
    });

}

From source file:com.devoteam.srit.xmlloader.gui.frames.JFrameRunProfile.java

private void refreshGraph(int type) {
    ArrayList<Point> vector = runProfile.getPoints();
    this.jPanelGraph.removeAll();

    if (type == 1) // delay graph
    {//from ww  w .  ja va 2  s. c o  m
        XYSeries series = new XYSeries("Delay");
        for (Point point : vector)
            series.add(point.date / 1000, 1 / point.frequency);
        XYDataset xyDataset = new XYSeriesCollection(series);
        JFreeChart chart = ChartFactory.createXYLineChart(null, "date (s)", "delay (s)", xyDataset,
                PlotOrientation.VERTICAL, false, true, false);
        ChartPanel panel = new ChartPanel(chart);
        panel.setPreferredSize(jPanelGraph.getSize());
        this.jPanelGraph.add(panel);
        this.jPanelGraph.validate();
    } else // frequency graph
    {
        XYSeries series = new XYSeries("Frequency");
        for (Point point : vector)
            series.add(point.date / 1000, point.frequency);
        XYDataset xyDataset = new XYSeriesCollection(series);
        JFreeChart chart = ChartFactory.createXYLineChart(null, "date (s)", "frequency (hz)", xyDataset,
                PlotOrientation.VERTICAL, false, true, false);
        chart.setPadding(new RectangleInsets(0, 0, 0, 0));
        ChartPanel panel = new ChartPanel(chart);
        panel.setPreferredSize(jPanelGraph.getSize());
        this.jPanelGraph.add(panel);
        this.jPanelGraph.validate();
    }
}

From source file:org.deegree.graphics.charts.ChartsBuilder.java

/**
 * Initializes the chart with the values from the properties file config.properties
 *
 * @param chart//from   w w w  . j  ava 2s . co m
 * @param chartConfigs
 *            to configure the output chart
 * @return initialized chart
 */
protected JFreeChart configChart(JFreeChart chart, ChartConfig chartConfigs) {

    chart.setAntiAlias(chartConfigs.isGenAntiAliasing());

    chart.setBorderVisible(chartConfigs.isGenBorderVisible());

    String rectanglkeInsets = chartConfigs.getGenRectangleInsets();
    if (!rectanglkeInsets.startsWith("!")) {
        String[] insets = rectanglkeInsets.split(",");
        if (insets.length == 4) {
            try {
                double top = Double.parseDouble(insets[0]);
                double left = Double.parseDouble(insets[1]);
                double buttom = Double.parseDouble(insets[2]);
                double right = Double.parseDouble(insets[3]);
                RectangleInsets rectInsets = new RectangleInsets(top, left, buttom, right);
                chart.setPadding(rectInsets);
            } catch (Exception e) {
                LOG.logError(Messages.getMessage("GRA_CHART_BAD_FORMAT_INSETS"));
            }
        } else {
            LOG.logError(Messages.getMessage("GRA_CHART_BAD_FORMAT_INSETS"));
        }
    }

    chart.setTextAntiAlias(chartConfigs.isGenTextAntiAlias());
    chart.setBackgroundPaint(chartConfigs.getGenBackgroundColor());

    chart.getPlot().setOutlineVisible(chartConfigs.isPlotOutlineVisible());
    chart.getPlot().setForegroundAlpha((float) chartConfigs.getPlotForegroundOpacity());
    chart.getPlot().setBackgroundPaint(chartConfigs.getPlotBackgroundColor());
    return chart;
}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

private void createChart(String name, String title, String xLabel, String yLabel, double minScore,
        double maxScore) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // x axis label
            yLabel, // y axis label
            dataset, // data
            chartOrientation, // chart orientation
            showLegend, // include legend
            true, // tooltips
            false // urls
    );/*from  w ww . j av  a2  s .c  o m*/

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(false);
    renderer.setDrawOutlines(true);

    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    plot.getDomainAxis().setRange(minScore, maxScore);

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    panel.setPreferredSize(new Dimension(width, height));

    //        this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    charts.put(name, chart);

    JPanel subPanel = new JPanel();//additional panel needed to prevent gridlayout from stretching graph
    subPanel.add(panel);
    //        this.addJpgMenuItem(subPanel, panel.getPopupMenu());
    subPanel.setBackground(Color.WHITE);
    this.add(subPanel);

}