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:cgpanalyser.gui.EvoInfoChart.java

/**
 * Creates a new demo.//from   w w w .  j  a  v a  2  s. c o  m
 *
 * @param title the frame title.
 */
public EvoInfoChart(final String title, long[] gateFuncsCounts, GateFuctionsAll gateFuncsAll) {
    super(title);
    final CategoryDataset dataset = createDataset(gateFuncsCounts, gateFuncsAll);
    final JFreeChart chart = createChart(dataset, gateFuncsCounts, gateFuncsAll);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(700, 400));
    chartPanel.setPopupMenu(null);
    chartPanel.setRangeZoomable(false);
    chartPanel.setDomainZoomable(false);
    setContentPane(chartPanel);
    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setVisible(true);
}

From source file:cn.edu.thss.iise.bpmdemo.charts.PieChartDemo4.java

/**
 * Default constructor./*from   www.j  av a 2s.  co m*/
 *
 * @param title
 *            the frame title.
 */
public PieChartDemo4(final String title) {

    super(title);
    final PieDataset dataset = createDataset(14);

    // create the chart...
    final JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 4", // chart title
            dataset, // dataset
            false, // include legend
            true, false);

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(222, 222, 255));

    final PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setCircular(true);
    plot.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(),
            NumberFormat.getPercentInstance()));
    plot.setNoDataMessage("No data available");

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

    // add table
    Object[][] data = { { "Kathy0", new Integer(0) }, { "Kathy1", new Integer(2) },
            { "Kathy2", new Integer(5) }, { "Kathy3", new Integer(5) }, { "Kathy4", new Integer(5) },
            { "Kathy5", new Integer(5) }, { "Kathy6", new Integer(5) }, { "Kathy7", new Integer(5) },
            { "Kathy8", new Integer(5) }, { "Kathy9", new Integer(5) } };
    String[] columnNames = { "Model Name", "Reuse Number" };
    JTable table = new JTable(data, columnNames);
    final JPanel panel = new JPanel();
    panel.add(chartPanel);
    panel.add(table);
    setContentPane(panel);
    final Rotator rotator = new Rotator(plot);
    rotator.start();

}

From source file:ui.Graph.java

public Graph(final String title, ArrayList<Setpoint> data, ArrayList<Setpoint> traj, Gains gains) {
    super(title);
    this.gains = gains;

    JFreeChart chart = createChart(data, traj);

    File imageFile = new File(ConfigFile.getInstance("config.txt").getString("outputPng"));
    int width = 1280;
    int height = 960;

    try {/*from   w w  w  .  ja v a2 s .c  om*/
        ChartUtilities.saveChartAsPNG(imageFile, chart, width, height);
    } catch (IOException ex) {
        System.err.println(ex);
    }
    final ChartPanel panel = new ChartPanel(chart);
    panel.setPreferredSize(new java.awt.Dimension(1500, 800));
    this.setContentPane(panel);
}

From source file:chart.JChart.java

/**
 * Creates a new demo instance.//  ww  w .  j a v  a 2  s  .  c  om
 *
 * @param title the frame title.
 */
private JChart(final String title, NTimeSeries series, List<NSubsequence> anomalies) {

    super(title);
    final XYDataset dataset = createDataset(series);
    final JFreeChart chart = createChart(dataset, anomalies);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);

}

From source file:gui.BarChart.java

/**
  * Diagramm erstellen und anzeigen/*  w  w w.  j a v  a 2  s.  c om*/
  *
  * @param dataset Datenstze fr das Diagramm
  * @param title berschrift Diagramm und Frame
  * @param label_x_axis Beschriftung x Achse
  * @param label_y_axis Beschriftung y Achse
  * 
  */
public BarChart(final DefaultCategoryDataset dataset, final String title, final String label_x_axis,
        final String label_y_axis) {

    super(title);
    super.setIconImage(new ImageIcon("./icons/ViewerMiniIcon.gif").getImage());

    this.dataset = dataset;
    this.title = title;
    this.label_x_axis = label_x_axis;
    this.label_y_axis = label_y_axis;

    final JFreeChart chart = createChart();
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(800, 600));
    setContentPane(chartPanel);

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

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

/**
 * A demonstration application showing a scatter plot.
 *
 * @param title  the frame title.//  w w w  .jav  a 2  s .  co  m
 */
public SelectionDemo2(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 = (XYSeriesCollection) plot.getDataset();
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.add(chartPanel);

    this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0);
    this.table = new JTable(this.model);
    TableColumnModel tcm = this.table.getColumnModel();
    tcm.getColumn(2).setCellRenderer(new NumberCellRenderer());
    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:org.jfree.chart.demo.CombinedCategoryPlotDemo2.java

/**
 * Creates a new demo instance./*  w  w w. ja  v a2 s  .  c  o m*/
 *
 * @param title  the frame title.
 */
public CombinedCategoryPlotDemo2(final String title) {

    super(title);

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

}

From source file:eu.choreos.vv.chart.YIntervalChart.java

public YIntervalChart(String applicationTitle, String chartTitle, List<PlotData> reports, String xLabel,
        String yLabel) {//from  w  w  w  .  j  a v  a2 s . c o m
    super(applicationTitle);

    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();

    for (PlotData report : reports) {
        createDataset(dataset, (StatisticalData) report);
    }
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, chartTitle, xLabel, yLabel);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

From source file:org.mwc.debrief.sensorfusion.views.MouseClickSolutionDemo.java

/**
 * @param title//from ww  w. ja v  a 2s  . com
 *            the frame title.
 */
public MouseClickSolutionDemo(final String title) {
    super(title);

    final TimeSeries s1 = new TimeSeries("Series to click");
    s1.add(new Month(2, 2001), 181.8);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 152.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("[Alt]-click to switch orientation", // title
            "Time axis", // x-axis label
            "Value axis", // y-axis label
            dataset, // data
            false, // create legend?
            false, // generate tooltips?
            false // generate URLs?
    );

    //FIX IS HERE
    fixProblem(chart);

    final ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    chartPanel.addChartMouseListener(new ChartMouseListener() {
        public void chartMouseMoved(final ChartMouseEvent arg0) {
        }

        public void chartMouseClicked(final ChartMouseEvent arg0) {
            System.out.println("clicked on:" + arg0.getEntity());

            if (arg0.getTrigger().isAltDown()) {
                if (chart.getXYPlot().getOrientation() == PlotOrientation.HORIZONTAL)
                    chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);
                else
                    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
            }
        }
    });
    setContentPane(chartPanel);
}

From source file:GeMSE.Visualization.BoxAndWhiskerPlot.java

private void Plot() {
    BoxAndWhiskerCategoryDataset dataset = CreateDataset();
    CategoryAxis xAxis = new CategoryAxis("Type");
    NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);//from   w  w  w.  j  a va 2 s  .c o m
    renderer.setArtifactPaint(Color.BLACK);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(new Color(0, 0, 0, 0));

    JFreeChart chart = new JFreeChart(null, new Font("Courier New", Font.PLAIN, 10), plot, true);
    chart.removeLegend();
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(450, 270));
    PlotPanel.setViewportView(chartPanel);
}