Example usage for org.jfree.ui ApplicationFrame setPreferredSize

List of usage examples for org.jfree.ui ApplicationFrame setPreferredSize

Introduction

In this page you can find the example usage for org.jfree.ui ApplicationFrame setPreferredSize.

Prototype

public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component to a constant value.

Usage

From source file:org.jgrasstools.gears.ui.OmsMatrixCharter.java

@Execute
public void chart() throws Exception {
    if (inData == null && inDataXY == null) {
        throw new ModelsIllegalargumentException("At least one of the datasets need to be valid.", this, pm);
    }/* w ww  . j  ava  2  s  .  c o  m*/

    if (doDump) {
        checkNull(inChartPath);
    }

    JFreeChart chart = null;
    if (pType == 0) {
        chart = doLineChart();
    } else {
        chart = doBarChart();
    }
    if (inSubTitle != null) {
        TextTitle subTitle = new TextTitle(inSubTitle);
        chart.addSubtitle(subTitle);
    }
    chart.setTextAntiAlias(true);

    if (doDump) {
        File chartFile = new File(inChartPath);
        if (!chartFile.getName().endsWith(".png")) {
            chartFile = FileUtilities.substituteExtention(chartFile, "png");
        }
        BufferedImage bufferedImage = chart.createBufferedImage(pWidth, pHeight);
        ImageIO.write(bufferedImage, "png", chartFile);
    }

    if (doChart) {
        ChartPanel cp = new ChartPanel(chart);
        cp.setDomainZoomable(true);
        cp.setRangeZoomable(true);

        ApplicationFrame af = new ApplicationFrame("");
        af.setContentPane(cp);
        af.setPreferredSize(new Dimension(pWidth, pHeight));
        af.pack();
        af.setVisible(true);
        RefineryUtilities.centerFrameOnScreen(af);
    }
}