Skip to content

Commit

Permalink
Lab09
Browse files Browse the repository at this point in the history
  • Loading branch information
JIMMY committed May 4, 2017
0 parents commit 32ee2cd
Show file tree
Hide file tree
Showing 33 changed files with 2,515 additions and 0 deletions.
Binary file added DB/database.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DB/metro-Paris.pdf
Binary file not shown.
2,231 changes: 2,231 additions & 0 deletions DB/metroparis.sql

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Lab09_MetroDeParis/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="lib/jgrapht-core-0.9.0.jar"/>
<classpathentry kind="lib" path="lib/jgrapht-core-0.9.2-javadoc.jar"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.29-bin.jar"/>
<classpathentry kind="lib" path="lib/simplelatlng-1.3.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
23 changes: 23 additions & 0 deletions Lab09_MetroDeParis/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Lab09_MetroDeParis</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Lab09_MetroDeParis/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.BorderPane?>

<BorderPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="it.polito.tdp.metrodeparis.MetroDeParisController">
<!-- TODO Add Nodes -->
</BorderPane>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions Lab09_MetroDeParis/build.fxbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="Lab8_MetroDeParis"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>
Binary file added Lab09_MetroDeParis/lib/jgrapht-core-0.9.0.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Lab09_MetroDeParis/lib/simplelatlng-1.3.0.jar
Binary file not shown.
Binary file added Lab09_MetroDeParis/rsc/RATP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions Lab09_MetroDeParis/src/it/polito/tdp/metrodeparis/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package it.polito.tdp.metrodeparis;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("MetroDeParis.fxml"));
BorderPane root = (BorderPane) loader.load();
MetroDeParisController controller = loader.getController();

// TODO: Set the model

Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();

} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
launch(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.BorderPane?>

<BorderPane xmlns:fx="http://javafx.com/fxml/1" fx:controller="it.polito.tdp.metrodeparis.MetroDeParisController">
<!-- TODO Add Nodes -->
</BorderPane>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package it.polito.tdp.metrodeparis;

public class MetroDeParisController {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package it.polito.tdp.metrodeparis.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnect {

static private final String jdbcUrl = "jdbc:mysql://localhost/metroparis?user=root";
static private DBConnect instance = null;

private DBConnect() {
instance = this;
}

public static DBConnect getInstance() {
if (instance == null)
return new DBConnect();
else {
return instance;
}
}

public Connection getConnection() {
try {

Connection conn = DriverManager.getConnection(jdbcUrl);
return conn;

} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al database");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package it.polito.tdp.metrodeparis.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.javadocmd.simplelatlng.LatLng;

import it.polito.tdp.metrodeparis.model.Fermata;

public class MetroDAO {

public List<Fermata> getAllFermate() {

final String sql = "SELECT id_fermata, nome, coordx, coordy FROM fermata ORDER BY nome ASC";
List<Fermata> fermate = new ArrayList<Fermata>();

try {
Connection conn = DBConnect.getInstance().getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();

while (rs.next()) {
Fermata f = new Fermata(rs.getInt("id_Fermata"), rs.getString("nome"), new LatLng(rs.getDouble("coordx"), rs.getDouble("coordy")));
fermate.add(f);
}

st.close();
conn.close();

} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}

return fermate;
}
}
18 changes: 18 additions & 0 deletions Lab09_MetroDeParis/src/it/polito/tdp/metrodeparis/dao/TestDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package it.polito.tdp.metrodeparis.dao;

import java.util.List;

import it.polito.tdp.metrodeparis.model.Fermata;

public class TestDAO {

public static void main(String[] args) {

MetroDAO metroDAO = new MetroDAO();

System.out.println("Lista fermate");
List<Fermata> fermate = metroDAO.getAllFermate();
System.out.println(fermate);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package it.polito.tdp.metrodeparis.model;

import com.javadocmd.simplelatlng.LatLng;

public class Fermata {

private int idFermata;
private String nome;
private LatLng coords;

public Fermata(int idFermata, String nome, LatLng coords) {
this.idFermata = idFermata;
this.nome = nome;
this.coords = coords;
}

public Fermata(int idFermata) {
this.idFermata = idFermata;
}

public int getIdFermata() {
return idFermata;
}

public void setIdFermata(int idFermata) {
this.idFermata = idFermata;
}

public String getNome() {
return nome;
}

public void setNome(String nome) {
this.nome = nome;
}

public LatLng getCoords() {
return coords;
}

public void setCoords(LatLng coords) {
this.coords = coords;
}

@Override
public int hashCode() {
return ((Integer) idFermata).hashCode();
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Fermata other = (Fermata) obj;
if (idFermata != other.idFermata)
return false;
return true;
}

@Override
public String toString() {
return nome;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package it.polito.tdp.metrodeparis.model;

public class Model {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package it.polito.tdp.metrodeparis.model;

public class TestModel {

public static void main(String[] args) {

Model model = new Model();
System.out.println("TODO: write a Model class and test it!");
}

}
Binary file added ese09.pdf
Binary file not shown.

0 comments on commit 32ee2cd

Please sign in to comment.