Example usage for org.jfree.chart ChartPanel setPreferredSize

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

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java

/**
 * Creates a new demo.//w ww .  ja va  2  s .  co  m
 *
 * @param title  the frame title.
 */
public CompassChartGUI(final String title) {

    super(title);

    final XYDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);

    final XYPlot plot = chart.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60); // 60 seconds

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

    //        new Thread(new ChartUpdater(chart.getXYPlot())).start();
}

From source file:edu.uara.tableeditor.TableFigure.java

/**
 * view chart in a new frame/*w w  w  .  ja  v a 2  s  . c  o  m*/
 */
public void chartPreview() {

    java.awt.EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            JFrame chartFrame = new JFrame(title);
            JFreeChart ch = chart.getChart();
            ChartPanel chartPanel = new ChartPanel(ch);
            chartPanel.setPreferredSize(new Dimension(500, 300));
            chartFrame.setContentPane(chartPanel);
            chartFrame.pack();
            RefineryUtilities.centerFrameOnScreen(chartFrame);
            chartFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            chartFrame.setVisible(true);
            chartFrame.setAlwaysOnTop(true);
        }
    });

}

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

/**
 * Constructs a new demonstration application.
 *
 * @param title  the frame title./*from  w  w w . ja  va2 s .co  m*/
 */
public CombinedXYPlotDemo1(final String title) {

    super(title);
    final JFreeChart chart = createCombinedChart();
    final ChartPanel panel = new ChartPanel(chart, true, true, true, false, true);
    panel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(panel);

}

From source file:org.jfree.chart.demo.selection.SelectionDemo1.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * /*from   ww  w  . j ava  2 s. c o m*/
 * @param title  the frame title.
 */
public SelectionDemo1(String title) {
    super(title);
    ChartPanel chartPanel = (ChartPanel) createDemoPanel();
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    JFreeChart chart = chartPanel.getChart();
    XYPlot plot = (XYPlot) chart.getPlot();
    this.dataset = (TimeSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "Period:", "Value:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(3).setCellRenderer(new NumberCellRenderer());
    JPanel p = new JPanel(new BorderLayout());
    JScrollPane scroller = new JScrollPane(this.table);
    p.add(scroller);
    p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "),
            new EmptyBorder(4, 4, 4, 4)));
    split.add(p);
    setContentPane(split);

}

From source file:fuel.gui.stats.PieChartPanel.java

public PieChartPanel(DefaultPieDataset pieDataset, String message) {
    JFreeChart pieChart = ChartFactory.createPieChart3D("", pieDataset, true, true, false);
    PiePlot3D plot1 = (PiePlot3D) pieChart.getPlot();
    plot1.setForegroundAlpha(0.6f);/*from  ww w.  j a v a2  s  .c o  m*/
    //plot3.setCircular(true);

    ChartPanel barChartPanel = new ChartPanel(pieChart);
    barChartPanel.getChartRenderingInfo().setEntityCollection(null);
    barChartPanel.setBorder(BorderFactory.createTitledBorder(message));
    barChartPanel.setPreferredSize(new java.awt.Dimension(320, 240));
    barChartPanel.setLayout(new BorderLayout());
    setLayout(new BorderLayout());
    add(barChartPanel);
}

From source file:Interface.Graphe.java

public Graphe(String applicationTitle, String chartTitle) {
    super(applicationTitle);

    JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Annes", "Montant", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(600, 400));
    setContentPane(chartPanel);//www  .  j  a va 2s.co  m

}

From source file:j2se.jfreechart.barchart.BarChartDemo7.java

/**
 * Creates a new demo instance.//from  w w  w .  j  a  va  2  s . com
 *
 * @param title  the frame title.
 */
public BarChartDemo7(final String title) {
    super(title);
    final CategoryDataset dataset = createDataset();
    final JFreeChart chart = createChart(dataset);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartPanel);
}

From source file:DualAxisDemo4.java

/**
 * Creates a new demo instance.//from   w  w w  .  java 2  s.  com
 *
 * @param title  the frame title.
 */
public DualAxisDemo4(final String title) {

    super(title);

    final CategoryDataset dataset1 = createDataset1();

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart3D("Dual Axis Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset1, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, false);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC));
    //        chart.getLegend().setAnchor(Legend.SOUTH);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    final CategoryItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.yellow);
    renderer1.setSeriesPaint(2, Color.green);
    final CategoryDataset dataset2 = createDataset2();
    final ValueAxis axis2 = new NumberAxis3D("Secondary");
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setSeriesPaint(0, Color.blue);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:gui.images.CodebookVectorProfilePanel.java

/**
 * Sets the data to be shown.//from w  w w .j a v  a 2s .co m
 *
 * @param occurrenceProfile Double array that is the neighbor occurrence
 * profile of this visual word.
 * @param codebookIndex Integer that is the index of this visual word.
 * @param classColors Color[] of class colors.
 * @param classNames String[] of class names.
 */
public void setResults(double[] occurrenceProfile, int codebookIndex, Color[] classColors,
        String[] classNames) {
    int numClasses = Math.min(classNames.length, occurrenceProfile.length);
    this.codebookIndex = codebookIndex;
    this.occurrenceProfile = occurrenceProfile;
    DefaultPieDataset pieData = new DefaultPieDataset();
    for (int cIndex = 0; cIndex < numClasses; cIndex++) {
        pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]);
    }
    JFreeChart chart = ChartFactory.createPieChart3D("codebook vect " + codebookIndex, pieData, true, true,
            false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    PieRenderer prend = new PieRenderer(classColors);
    prend.setColor(plot, pieData);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(140, 140));
    chartPanel.setVisible(true);
    chartPanel.revalidate();
    chartPanel.repaint();
    JPanel jp = new JPanel();
    jp.setPreferredSize(new Dimension(140, 140));
    jp.setMinimumSize(new Dimension(140, 140));
    jp.setMaximumSize(new Dimension(140, 140));
    jp.setSize(new Dimension(140, 140));
    jp.setLayout(new FlowLayout());
    jp.add(chartPanel);
    jp.setVisible(true);
    jp.validate();
    jp.repaint();

    JFrame frame = new JFrame();
    frame.setBackground(Color.WHITE);
    frame.setUndecorated(true);
    frame.getContentPane().add(jp);
    frame.pack();
    BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D graphics = bi.createGraphics();
    jp.print(graphics);
    graphics.dispose();
    frame.dispose();
    imPanel.removeAll();
    imPanel.setImage(bi);
    imPanel.setVisible(true);
    imPanel.revalidate();
    imPanel.repaint();
}

From source file:org.encog.workbench.dialogs.validate.ResultValidationChart.java

/**
 * Create the initial chart.//from w  w w.  j av a2  s .  c o  m
 * 
 * @return The chart.
 */
private void createChart() {
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Result", "Increment", null,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(600, 360));
    chartPanel.setDomainZoomable(true);
    chartPanel.setRangeZoomable(true);

    charts.add(chart);
    chartPanels.add(chartPanel);
}