List of usage examples for org.jfree.chart ChartFrame setResizable
public void setResizable(boolean resizable)
From source file:spectrex.Charts.java
/** * @param data initial data for chart creation * @param title text which would be displayed at the top of the frame and in * the frame's title//from w w w . j a va 2 s . c o m * @param columnLabel text which would be displayed on the left of the * Y-axis * @param rowLabel text which would be displayed under X-axis * @param frameSize size of chart frame * @return Bar chart JFrame link * @author ReaLgressA */ public static JFrame createBarChart(ChartData data, String title, String columnLabel, String rowLabel, Dimension frameSize) { JFreeChart chart = ChartFactory.createStackedBarChart(title, columnLabel, rowLabel, data.getDataset(), PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame(title, chart, true); frame.setVisible(true); frame.setSize(frameSize); frame.setResizable(true); return (JFrame) frame; }
From source file:com.imaging100x.tracker.TrackerUtils.java
/** * Create a frame with a plot of the data given in XYSeries *///from w w w . j a v a 2 s . c o m public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation, int yLocation) { // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data); JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesLinesVisible(0, true); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); renderer.setUseFillPaint(true); ChartFrame graphFrame = new ChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.setPreferredSize(new Dimension(SIZE, SIZE)); graphFrame.setResizable(true); graphFrame.pack(); graphFrame.setLocation(xLocation, yLocation); graphFrame.setVisible(true); dataset.addChangeListener(new DatasetChangeListener() { public void datasetChanged(DatasetChangeEvent dce) { double xRange = data.getMaxX() - data.getMinX(); double yRange = data.getMaxY() - data.getMinY(); double xAvg = (data.getMaxX() + data.getMinX()) / 2; double yAvg = (data.getMaxY() + data.getMinY()) / 2; double range = xRange; if (yRange > range) { range = yRange; } double offset = 0.55 * range; plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset); plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset); } }); }
From source file:library.ChartGUI.java
private void btArea2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btArea2ActionPerformed try {/*from w ww . j av a 2 s. com*/ // TODO add your handling code here: JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql1); JFreeChart chart = ChartFactory.createAreaChart("Sum New Readers", "Month", "Count", dataset, PlotOrientation.VERTICAL, false, true, true); BarRenderer renderer = null; CategoryPlot plot = null; renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Sum New Readers Chart", chart); frame.setVisible(true); frame.setSize(1250, 700); frame.setResizable(false); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }
From source file:library.ChartGUI.java
private void btBar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBar2ActionPerformed try {//ww w. j a v a2 s . c o m // TODO add your handling code here: JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql1); JFreeChart chart = ChartFactory.createBarChart3D("Sum New Readers", "Month", "Count", dataset, PlotOrientation.VERTICAL, false, true, true); BarRenderer renderer = null; CategoryPlot plot = null; renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Sum New Readers Chart", chart); frame.setVisible(true); frame.setSize(1250, 700); frame.setResizable(false); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }
From source file:library.ChartGUI.java
private void btLine2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLine2ActionPerformed // TODO add your handling code here: try {/*from w w w . j a v a2s .c om*/ // TODO add your handling code here: JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql1); JFreeChart chart = ChartFactory.createLineChart3D("Sum New Readers", "Month", "Count", dataset, PlotOrientation.VERTICAL, false, true, true); BarRenderer renderer = null; CategoryPlot plot = null; renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Sum New Readers Chart", chart); frame.setVisible(true); frame.setSize(1250, 700); frame.setResizable(false); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }
From source file:library.ChartGUI.java
private void btLine1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLine1ActionPerformed try {/*from ww w. java 2 s. c om*/ // TODO add your handling code here: JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql0); JFreeChart chart = ChartFactory.createLineChart3D("Sum Brought Books", "Month", "Count", dataset, PlotOrientation.VERTICAL, false, true, true); BarRenderer renderer = null; CategoryPlot plot = null; renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Sum Brought Books Chart", chart); frame.setVisible(true); frame.setSize(1250, 700); frame.setResizable(false); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }
From source file:library.ChartGUI.java
private void btArea1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btArea1ActionPerformed try {// ww w. j av a 2 s.c o m // TODO add your handling code here: JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql0); JFreeChart chart = ChartFactory.createAreaChart("Sum Brought Books", "Month", "Count", dataset, PlotOrientation.VERTICAL, false, true, true); BarRenderer renderer = null; CategoryPlot plot = null; renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Sum Brought Books Chart", chart); frame.setVisible(true); frame.setSize(1250, 700); frame.setResizable(false); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }
From source file:library.ChartGUI.java
private void btBar1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBar1ActionPerformed try {/* w ww.j a v a 2 s .c o m*/ // TODO add your handling code here: JDBCCategoryDataset dataset = new JDBCCategoryDataset(da.getConnection(), sql0); JFreeChart chart = ChartFactory.createBarChart3D("Sum Brought Books", "Month", "Count", dataset, PlotOrientation.VERTICAL, false, true, true); BarRenderer renderer = null; CategoryPlot plot = null; renderer = new BarRenderer(); ChartFrame frame = new ChartFrame("Sum Brought Books Chart", chart); frame.setVisible(true); frame.setSize(1250, 700); frame.setResizable(false); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }