Skip to content
Snippets Groups Projects
Commit 300b0e71 authored by Terje Haugum's avatar Terje Haugum
Browse files

Prøve på å lage barchart med connection til database. Laget i kommentar foreløpig

parent 58db7ea2
No related branches found
No related tags found
No related merge requests found
package GUI;
import database.Connecting;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.jdbc.JDBCCategoryDataset;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.SQLException;
import javax.swing.JLabel;
import database.Executor;
public class CostGraph extends JFrame{
private JPanel contentPane;
......@@ -10,6 +21,7 @@ public class CostGraph extends JFrame{
private static Font boldFont = new Font("Avenir", Font.BOLD, 50);
private JPanel mal;
private JPanel mal2;
// Executor ex = new Executor();
public CostGraph() {
setTitle("Trondheim city graph");
......@@ -50,6 +62,27 @@ public class CostGraph extends JFrame{
del.setFont(plainFont);
contentPane.add(del);
//Barchart button
// JButton barChart = new JButton("Barchart");
// barChart.setBounds(700, 150, 150, 25);
// barChart.setFont(plainFont);
// contentPane.add(barChart);
//
// barChart.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// try {
//// JDBCCategoryDataset dataset = new JDBCCategoryDataset((Connection) ex.getAllBikes(),query);
// JFreeChart chart = ChartFactory.createBarChart("Cost of bikes","Biketypes","Price of bikes", dataset, PlotOrientation.HORIZONTAL,false,true,false);
//
// } catch (Exception e1 ) {
// JOptionPane.showMessageDialog(null,e1);
// }
// }
// });
//
//Back to main page---------------------------------------------------------------------
JButton back = new JButton("Back to Graph");
back.setBounds(50, 150, 250, 50);
......
......@@ -439,6 +439,33 @@ public class Executor {
return types;
}
}
// Get sum of bike-prices
// public ArrayList<Bike> getSumPrices() {
// ArrayList<Bike> prices = new ArrayList<>();
// Connecting con = dbp.take();
// try {
// stm = con.getConn().createStatement();
// String statement1 = "";
// stm.executeQuery(statement1);
// ResultSet rs = stm.executeQuery(statement1);
// while (rs.next()) {
// Bike bikePrice = new Bike(rs.getDate("date_registered"), rs.getInt("price"),
// rs.getInt("type_id"), rs.getDate("produced"));
// bikePrice.setPrice(rs.getInt("price"));
// bikePrice.setCharge(rs.getInt("charge"));
// bikePrice.setAnt_rep(rs.getInt("all_repairs"));
// bikePrice.setTot_trips(rs.getInt("total_trips"));
// bikePrice.setTot_km(rs.getInt("total_km"));
// prices.add(bikePrice);
// }
// } catch (Exception e) {
// System.out.println(e);
// }
// finally {
// dbp.give(con);
// return prices;
// }
// }
// --------------------------------------------------------------------------------------------Get all rented
public ArrayList<Bike> getRented() {
ArrayList<Bike> rentedBikes = new ArrayList<Bike>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment