Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Electrical-bike-Project
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathias Braathen
Electrical-bike-Project
Commits
300b0e71
Commit
300b0e71
authored
6 years ago
by
Terje Haugum
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/GUI/CostGraph.java
+33
-0
33 additions, 0 deletions
src/GUI/CostGraph.java
src/database/Executor.java
+27
-0
27 additions, 0 deletions
src/database/Executor.java
with
60 additions
and
0 deletions
src/GUI/CostGraph.java
+
33
−
0
View file @
300b0e71
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
);
...
...
This diff is collapsed.
Click to expand it.
src/database/Executor.java
+
27
−
0
View file @
300b0e71
...
...
@@ -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
>();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment