Example usage for org.jfree.ui RefineryUtilities centerFrameOnScreen

List of usage examples for org.jfree.ui RefineryUtilities centerFrameOnScreen

Introduction

In this page you can find the example usage for org.jfree.ui RefineryUtilities centerFrameOnScreen.

Prototype

public static void centerFrameOnScreen(final Window frame) 

Source Link

Document

Positions the specified frame in the middle of the screen.

Usage

From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo3.java

public static void main(String[] args) {
    DatasetVisibleDemo3 demo = new DatasetVisibleDemo3("Dataset Visible Demo 3");
    demo.pack();//from   w w  w .j  ava  2  s .co  m
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}

From source file:cgpanalyser.gui.EvoInfoChart.java

/**
 * Creates a new demo.// w w w. j  a  va  2 s  . co 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:trendgraph.XYLineChart_AWT.java

public XYLineChart_AWT(int yearStart, int yearEnd, String[] creditUnionName, String columnName)
        throws SQLException {
    super("Graph");
    super.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.yearStart = yearStart;
    this.yearEnd = yearEnd;
    this.creditUnionName = creditUnionName;
    this.columnName = columnName;
    saveGraphButton = new JButton("Save Graph");
    saveGraphButton.setBorderPainted(false);
    saveGraphButton.setFocusPainted(false);

    JFreeChart xylineChart = ChartFactory.createXYLineChart("CU Report", "Year (YYYY)", //X-axis
            columnName, //Y-axis (replace with columnName
            createDataset(), PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(1000, 800)); //(x, y)
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setSeriesPaint(0, Color.RED); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(0, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(1, Color.BLUE); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(1, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(2, Color.GREEN); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(2, new BasicStroke(3.0f)); //Font size

    renderer.setSeriesPaint(3, Color.yellow); //can be GREEN, YELLOW, ETC.

    renderer.setSeriesStroke(3, new BasicStroke(3.0f)); //Font size

    plot.setRenderer(renderer);/*from w w w  . j a v  a 2s .  c o  m*/
    chartPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    chartPanel.add(saveGraphButton);
    setContentPane(chartPanel);
    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setVisible(true);

    saveGraphButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Rectangle rect = chartPanel.getBounds();
            FileChooser chooser = new FileChooser();

            //get chosen path and save the variable
            String path = chooser.getPath();
            path = path.replace("\\", "/");

            String format = "png";
            String fileName = path + "." + format;
            BufferedImage captureImage = new BufferedImage(rect.width, rect.height,
                    BufferedImage.TYPE_INT_ARGB);
            chartPanel.paint(captureImage.getGraphics());

            File file = new File(fileName);

            try {
                ImageIO.write(captureImage, format, file);

                //write data to file
            } catch (IOException ex) {
                Logger.getLogger(XYLineChart_AWT.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortCounterCrossHairXYplot.java

/**
 * Starting point for the demonstration application.
 * /*from w  w w.j  a v  a2  s.  c  om*/
 * @param args
 *          ignored.
 */
public static void main(String[] args) {
    PortCounterCrossHairXYplot plot = new PortCounterCrossHairXYplot("PortCounterCrossHairXYplot");
    plot.pack();
    RefineryUtilities.centerFrameOnScreen(plot);
    plot.setVisible(true);
}

From source file:com.stableapps.anglewraparounddemo.AngleWrapDemoMain.java

/**
 * Starting point for the demonstration application.
 *
 * @param args ignored./*w  w  w  . jav  a 2 s .  c  o  m*/
 */
public static void main(final String[] args) {
    final AngleWrapDemoMain demo = new AngleWrapDemoMain("Angle Wrap Demo");
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}

From source file:org.hammurapi.inspectors.metrics.reporting.LocCharts.java

public JFreeChart generateChart() {
    JFreeChart chart;//from w  ww .j  a v a 2s .c  o m

    new DescriptiveStatistic().frequencies(locList, distinctValues, frequencies);
    //!! job: wrong method name and tailoring
    chart = this.copyDeepXYSeries(distinctValues, frequencies);
    // System.out.println( distinctValues );
    // System.out.println( frequencies );
    customizeChartBars(chart);
    this.pack();

    if (chartDebugWindow.intValue() > 0) {
        RefineryUtilities.centerFrameOnScreen(this);
        this.setVisible(true);
    }
    return chart;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

public static void main(String[] args) {
    XYDatasetDemo demo = new XYDatasetDemo("XY Dataset Chart Demo");
    demo.pack();//from w  ww .j av a2 s . c o  m
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}

From source file:ta4jexamples.analysis.CashFlowToChart.java

/**
 * Displays a chart in a frame./*from ww w . j av  a 2  s.  c  om*/
 * @param chart the chart to be displayed
 */
private static void displayChart(JFreeChart chart) {
    // Chart panel
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new Dimension(1024, 400));
    // Application frame
    ApplicationFrame frame = new ApplicationFrame("Ta4j example - Cash flow to chart");
    frame.setContentPane(panel);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
}

From source file:gui.BarChart.java

/**
  * Diagramm erstellen und anzeigen//from ww w .ja v a2  s.  c o m
  *
  * @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:pfg.graphic.Chart.java

/**
 * L'initialisation se fait  part afin de ne pas ouvrir une fentre ds qu'on cre un objet
 *//*w  w  w .  j ava2s  .  c  o m*/
private void init() {
    init = true;
    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            xAxisLabel, // x-axis label
            yAxisLabel, // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    panel.setPreferredSize(new java.awt.Dimension(1024, 600));
    setContentPane(panel);

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