Example usage for org.jfree.chart ChartPanel ChartPanel

List of usage examples for org.jfree.chart ChartPanel ChartPanel

Introduction

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

Prototype

public ChartPanel(JFreeChart chart, boolean useBuffer) 

Source Link

Document

Constructs a panel containing a chart.

Usage

From source file:lu.lippmann.cdb.datasetview.tabs.PieChartTabView.java

/**
 * Constructor.// w  w  w.  j  a v  a 2 s. c o m
 */
public PieChartTabView() {
    super();

    this.pieDataset = new DefaultPieDataset();
    this.pieChart = ChartFactory.createPieChart("", this.pieDataset, true, true, true);
    final PiePlot plot = (PiePlot) this.pieChart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    this.chartPanel = new ChartPanel(this.pieChart, true);
}

From source file:org.jfree.chart.demo.StackedBarDemo2.java

public StackedBarDemo2(String s) {
    super(s);/*from w ww.  j  a va2 s  .  c o m*/
    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    defaultcategorydataset.addValue(1.0D, "Row 1", "Column 1");
    defaultcategorydataset.addValue(5D, "Row 1", "Column 2");
    defaultcategorydataset.addValue(3D, "Row 1", "Column 3");
    defaultcategorydataset.addValue(2D, "Row 2", "Column 1");
    defaultcategorydataset.addValue(3D, "Row 2", "Column 2");
    defaultcategorydataset.addValue(2D, "Row 2", "Column 3");
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("StackedBarDemo2", "Category", "Value",
            defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setRenderAsPercentages(true);
    ChartPanel chartpanel = new ChartPanel(jfreechart, false);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

From source file:org.jgrasstools.gears.utils.chart.PlotFrame.java

public void plot() {
    JFreeChart chart = ichart.getChart();
    ChartPanel chartPanel = new ChartPanel(chart, true);
    chartPanel.setPreferredSize(new Dimension(chartWidth, chartHeight));
    setContentPane(chartPanel);//from ww w  . j  ava2 s.co  m

    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setVisible(true);
}

From source file:edu.ucla.stat.SOCR.chart.demo.NoChart.java

public void init() {
    super.init();

    JFreeChart chart = createEmptyChart(null); //create a empty graph first
    chartPanel = new ChartPanel(chart, false);
    setChart();//  w  w  w.  j av  a 2  s.  co m
}

From source file:de.fub.maps.project.plugins.tasks.eval.RoadClassifcationDiagram.java

/**
 * Creates new form RoadClassifcationDiagram
 *///from w w  w  .  j a v  a2s  . c om
public RoadClassifcationDiagram() {
    initComponents();
    barChart = ChartFactory.createXYBarChart(null, "Degree", false, null, dataset, PlotOrientation.VERTICAL,
            true, true, true);
    barChart.setBackgroundPaint(Color.WHITE);
    barChart.getPlot().setBackgroundPaint(Color.WHITE);
    chartpanel = new ChartPanel(barChart, false);
    add(chartpanel, BorderLayout.CENTER);
}

From source file:playground.dgrether.analysis.charts.utils.DgChartFrame.java

public DgChartFrame(String title, JFreeChart chart) {
    super(title);
    ChartPanel chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(1024, 768));
    setContentPane(chartPanel);/*from   w w w.j  a v a  2 s.c o  m*/
    this.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:org.jfree.chart.demo.StackedBarDemo3.java

public StackedBarDemo3(String s) {
    super(s);//from ww w  . j av a2s .c  om
    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    defaultcategorydataset.addValue(1.0D, "Row 1", "Column 1");
    defaultcategorydataset.addValue(5D, "Row 1", "Column 2");
    defaultcategorydataset.addValue(3D, "Row 1", "Column 3");
    defaultcategorydataset.addValue(2D, "Row 2", "Column 1");
    defaultcategorydataset.addValue(3D, "Row 2", "Column 2");
    defaultcategorydataset.addValue(2D, "Row 2", "Column 3");
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("StackedBarDemo3", "Category", "Value",
            defaultcategorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setRenderAsPercentages(true);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setLabel("Percentage");
    numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%"));
    ChartPanel chartpanel = new ChartPanel(jfreechart, false);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartpanel);
}

From source file:TelasBanzos.TelaRelatorioAproveitamento.java

/**
 * Creates new form TelaNovoOrcamento//from  w  w  w  . ja  v  a  2 s. c  o m
 */
public TelaRelatorioAproveitamento() {
    initComponents();

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(80, "0", "Nota");
    dataset.setValue(70, "0", "Frequncia");

    JFreeChart chart = ChartFactory.createBarChart("Aproveitamento", "Aproveitamento", "", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    //colocar cor nas barras
    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer render = (BarRenderer) plot.getRenderer();
    render.setSeriesPaint(0, Color.blue);

    ChartPanel myChartPanel = new ChartPanel(chart, true);
    pnGraf.add(myChartPanel);

    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("BanzosIcon.png")));//para setar um icone na janela
}

From source file:bigdataproject.ScatterPlot.java

/**
 * Creates a new fast scatter plot.//  w  ww .  j  a  v  a2  s .co  m
 *
 * @param title the frame title.
 * @param samples the 2D matrix to plot.
 */
public ScatterPlot(final String title, double[][] samples, List<Cluster<DoublePoint>> list) {

    super(title);
    this.list = list;
    convertToFloat(samples);
    listToHashMap();
    HashMap<Integer, float[][]> clusterData = HashMapDoubleToFloat();
    final NumberAxis domainAxis = new NumberAxis("X1");
    domainAxis.setAutoRangeIncludesZero(false);
    final NumberAxis rangeAxis = new NumberAxis("X2");
    rangeAxis.setAutoRangeIncludesZero(false);
    final CustomFastScatterPlot plot = new CustomFastScatterPlot(this.data, domainAxis, rangeAxis, clusterData);
    final JFreeChart chart = new JFreeChart(title, plot);
    //chart.setLegend(null);

    // force aliasing of the rendered content..
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final ChartPanel panel = new ChartPanel(chart, true);
    panel.setPreferredSize(new java.awt.Dimension(1000, 540));
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(20);
    panel.setMaximumDrawWidth(2000);
    setContentPane(panel);

}

From source file:bullioneconomy.bullionchart.java

/**
 * A demonstration application showing how to create a simple time series 
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title.//  w w w .java2  s . co  m
 */
public bullionchart(String title) throws ClassNotFoundException, SQLException, ParseException {
    super(title);
    XYDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
}