List of usage examples for org.jfree.chart ChartFrame setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:br.com.utfpr.pb.view.GraficoProdutosMaisVendidosView.java
public GraficoProdutosMaisVendidosView() { try {//from w w w. j av a 2 s .c om // cria o grfico JFreeChart grafico = ChartFactory.createBarChart("Produtos mais Vendidos vs Comprados", "Produto", "Total venda", graficoDao.produtosMaisVendidos(), PlotOrientation.VERTICAL, true, true, false); //exibe o grfico ChartFrame frame = new ChartFrame("Grfico", grafico); frame.pack(); frame.setVisible(true); frame.setLocationRelativeTo(null); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.com.utfpr.pb.view.GraficoTotalVendasView.java
public GraficoTotalVendasView() { try {//from ww w.j a v a 2 s . c om // cria o grfico JFreeChart grafico = ChartFactory.createBarChart("Total de Vendas vs Compras por Data", "Data", "Valor Total", graficoDao.totalVendasPorData(), PlotOrientation.VERTICAL, true, true, false); //exibe o grfico ChartFrame frame = new ChartFrame("Grfico", grafico); frame.pack(); frame.setVisible(true); frame.setLocationRelativeTo(null); } catch (Exception e) { e.printStackTrace(); } }
From source file:br.com.utfpr.pb.view.GraficoQuantidadeVendasView.java
public GraficoQuantidadeVendasView() { try {// w w w . j av a 2 s . c o m // cria o grfico JFreeChart grafico = ChartFactory.createBarChart("Nmero de Vendas vs Compras por Data", "Data", "Quantidade", graficoDao.quantidadeVendasPorData(), PlotOrientation.VERTICAL, true, true, false); //exibe o grfico ChartFrame frame = new ChartFrame("Grfico", grafico); frame.pack(); frame.setVisible(true); frame.setLocationRelativeTo(null); } catch (Exception e) { e.printStackTrace(); } }
From source file:classes.SharedClass.java
public void getStatistics() { result = db.select("member", new String[] { " count(id) id" }, new String[] { "id" }, new String[] { "99999" }, "!=", "and"); try {//w w w . j a v a 2 s . c o m if (result.next()) { memberId = result.getInt("id"); } } catch (SQLException ex) { Logger.getLogger(SharedClass.class.getName()).log(Level.SEVERE, null, ex); ex.printStackTrace(); } //book result = db.select("book", new String[] { "count(id)" }, new String[] { "id" }, new String[] { "99999" }, "!=", "and"); try { if (result.next()) { bookId = result.getInt(1); } } catch (SQLException ex) { Logger.getLogger(SharedClass.class.getName()).log(Level.SEVERE, null, ex); } //operations result = db.select("operations", new String[] { "count(id)" }, new String[] { "type" }, new String[] { "borrowed" }, "=", "and"); try { if (result.next()) { operationsId = result.getInt(1); } } catch (SQLException ex) { Logger.getLogger(SharedClass.class.getName()).log(Level.SEVERE, null, ex); } DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); dataSet.setValue(memberId, "Percent", "Members"); dataSet.setValue(bookId, "Percent", "Books"); dataSet.setValue(operationsId, "Percent", "Borrowe books"); JFreeChart chart = ChartFactory.createBarChart3D("Statistics", "Fields", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.yellow); chart.getTitle().setPaint(Color.red); CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.blue); ChartFrame frame = new ChartFrame("Statistics", chart); frame.setLocationRelativeTo(null); frame.setSize(500, 550); frame.setVisible(true); }
From source file:mes2.Chart.java
public void createwykres() { XYSeriesCollection xySeriesCollection = new XYSeriesCollection(dataSet); // Dodanie kolejnych serii do kolekcji: xySeriesCollection.addSeries(dataSet2); // tworzenie XYDataSet XYDataset xyDataset = xySeriesCollection; // tworzenie wykresu JFreeChart lineGraph = ChartFactory.createXYLineChart("Wykres nagrzewania wsadu", // Title "Czas", // X-Axis label "Temperatura", // Y-Axis label xyDataset, // Dataset PlotOrientation.VERTICAL, //Plot orientation true, //show legend true, // Show tooltips false //url show );//from w w w. ja v a 2s . c om ChartFrame frame1 = new ChartFrame("Szybkie wyswietlanie wykresu - klasa ChartFrame", lineGraph); frame1.pack(); frame1.setVisible(true); frame1.setLocationRelativeTo(null); //frame1.setDefaultCloseOperation(DISPOSE_ON_CLOSE); ChartPanel chartPanel = new ChartPanel(lineGraph); //frame.getContentPane().add(chartPanel); // frame.getContentPane().add(new JLabel("<<< wykres dodany jako ChartPanel")); }
From source file:pidev.presentation.Statistiques.java
private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed String requete = "select Count(id_Agence) from Agence "; System.out.println(requete);/*from w w w . jav a 2 s. c om*/ try { Statement statement = MyConnection.getInstance().createStatement(); ResultSet resultat = statement.executeQuery(requete); while (resultat.next()) { nombredagence = resultat.getInt(1); } } catch (SQLException ex) { //Logger.getLogger(PersonneDao.class.getName()).log(Level.SEVERE, null, ex); System.out.println("erreur lors du chargement des annonces " + ex.getMessage()); } String requete2 = "select Count(id_Client) from Client "; System.out.println(requete2); try { Statement statement = MyConnection.getInstance().createStatement(); ResultSet resultat = statement.executeQuery(requete2); while (resultat.next()) { nombreclient = resultat.getInt(1); } } catch (SQLException ex) { //Logger.getLogger(PersonneDao.class.getName()).log(Level.SEVERE, null, ex); System.out.println("erreur lors du chargement des annonces " + ex.getMessage()); } DefaultPieDataset result = new DefaultPieDataset(); result.setValue("Agences", nombredagence); result.setValue("Clients", nombreclient); JFreeChart chart = ChartFactory.createPieChart3D("nombre d'agences + nombre de clients", result, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); ChartFrame ch = new ChartFrame("Statistiques", chart); // ChartPanel ch = new ChartPanel(chart); ch.setSize(300, 300); ch.setLocationRelativeTo(null); ch.pack(); ch.setVisible(true); }
From source file:pidev.presentation.Statistiques.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: String requete = "select Count(id_Annonce),destination from helpers.Annonce group by (destination) "; System.out.println(requete);/*from www . j av a 2 s. c om*/ try { Statement statement = MyConnection.getInstance().createStatement(); ResultSet resultat = statement.executeQuery(requete); while (resultat.next()) { map.put(resultat.getString(2), resultat.getInt(1)); } } catch (SQLException ex) { //Logger.getLogger(PersonneDao.class.getName()).log(Level.SEVERE, null, ex); System.out.println("erreur lors du chargement des annonces " + ex.getMessage()); } DefaultPieDataset result = new DefaultPieDataset(); for (Map.Entry<String, Integer> entry : map.entrySet()) { String string = entry.getKey(); Integer integer = entry.getValue(); result.setValue(string, integer); } JFreeChart chart = ChartFactory.createPieChart3D("nombres d'annonces par ville", result, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); ChartFrame ch = new ChartFrame("Statistiques", chart); // ChartPanel ch = new ChartPanel(chart); ch.setSize(400, 400); ch.setLocationRelativeTo(null); ch.pack(); ch.setVisible(true); // JFrame frame = new JFrame(); //map2.addCursor("red", ".",3.876772f,43.613087f); //frame.add(map2); //frame.setSize(400, 420); //frame.setLocation(200, 200); //map2.setVisible(true); //frame.setVisible(true); // new GMaps(3.876772f,43.613087f).setVisible(true); //jButton2.setVisible(true); // this.setContentPane(ch); }
From source file:teambootje.A5.java
/** * Creates new form A5/* w w w . j a v a 2s. com*/ */ public A5() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 5"); ImageIcon icon = new ImageIcon("img/bootje.jpg"); setIconImage(icon.getImage()); // back BTN JButton back = new JButton("Back"); add(back, BorderLayout.NORTH); back.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // panel en Label JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String sql = "SELECT Leeftijd, COUNT(*) AS Aantal FROM persoon GROUP BY Leeftijd"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String age = rs.getString("Leeftijd"); int aantal = rs.getInt("Aantal"); String[] row = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row[i - 1] = rs.getString(i); } list.add(row); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String leeftijd = age; int a1 = aantal; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Niet vrijgegeven", a1); JFreeChart chart = ChartFactory.createPieChart3D("Aantal mensen per leeftijd", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal mensen per leeftijd", chart); pie.setVisible(true); pie.setSize(500, 500); pie.setLocationRelativeTo(null); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Leeftijd", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); }
From source file:teambootje.A3.java
/** * Creates new form A3/* ww w . ja v a 2 s . co m*/ */ public A3() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 3"); ImageIcon icon = new ImageIcon("img/bootje.jpg"); setIconImage(icon.getImage()); // back BTN JButton back = new JButton("Back"); add(back, BorderLayout.NORTH); back.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // panel en Label JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String sql = "SELECT locatie.land, locatie.stad, COUNT(posts.PID) AS Aantal FROM persoon, locatie, posts WHERE persoon.LID = locatie.LID AND persoon.AID = posts.AID GROUP BY locatie.land ORDER BY count(posts.PID)"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String land = rs.getString("locatie.land"); String stad = rs.getString("locatie.stad"); int aantal = rs.getInt("Aantal"); String[] row = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row[i - 1] = rs.getString(i); } list.add(row); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String l1 = land; String s1 = stad; int a1 = aantal; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(s1, a1); JFreeChart chart = ChartFactory.createPieChart3D("Aantal Posts per locatie", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal Posts per locatie", chart); pie.setVisible(true); pie.setSize(500, 500); pie.setLocationRelativeTo(null); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Land", "Stad", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); }
From source file:teambootje.A6.java
/** * Creates new form A6//ww w . jav a 2 s . c o m */ public A6() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 6"); ImageIcon icon = new ImageIcon("img/bootje.jpg"); setIconImage(icon.getImage()); // back BTN JButton back = new JButton("Back"); add(back, BorderLayout.NORTH); back.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // panel en Label JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String sql = "SELECT Locatie.land, locatie.stad, count(persoon.LID) as Aantal FROM persoon, Locatie WHERE persoon.LID = locatie.LID GROUP BY stad"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String city = rs.getString("locatie.stad"); int amount = rs.getInt("Aantal"); String[] row = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row[i - 1] = rs.getString(i); } list.add(row); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String c1 = city; int a1 = amount; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(c1, a1); pieDataset.setValue("Rotterdam", new Integer(1)); pieDataset.setValue("Bergen op zoom", new Integer(1)); JFreeChart chart = ChartFactory.createPieChart3D("Waar komen bezoekers vandaan", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Waar komen bezoekers vandaan", chart); pie.setVisible(true); pie.setSize(500, 500); pie.setLocationRelativeTo(null); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Land", "stad", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); }