TP3
This commit is contained in:
BIN
DEV2.1/TP14/01_Conversion/Main.class
Normal file
BIN
DEV2.1/TP14/01_Conversion/Main.class
Normal file
Binary file not shown.
58
DEV2.1/TP14/01_Conversion/Main.java
Normal file
58
DEV2.1/TP14/01_Conversion/Main.java
Normal file
@@ -0,0 +1,58 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
String chaine = "";
|
||||
// Lecture
|
||||
try {
|
||||
BufferedReader lecture = new BufferedReader(new FileReader(args[0]));
|
||||
|
||||
try {
|
||||
String texte = lecture.readLine();
|
||||
while (texte != null) {
|
||||
chaine += texte;
|
||||
chaine += "\n";
|
||||
texte = lecture.readLine();
|
||||
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur de lecture.");
|
||||
}
|
||||
|
||||
try {
|
||||
lecture.close();
|
||||
} catch(IOException e3) {
|
||||
System.err.println("Erreur de fermeture.");
|
||||
}
|
||||
} catch(IOException e) {
|
||||
System.err.println("Erreur d'ouverture");
|
||||
}
|
||||
|
||||
//Ecriture
|
||||
|
||||
try {
|
||||
BufferedWriter ecriture = new BufferedWriter(new FileWriter(args[0].split("[.]")[0] + ".html"));
|
||||
|
||||
String html = "<!DOCTYPE html>\n <html>\n <body><p>";
|
||||
String finHtml = "</p>\n </body>\n </html>";
|
||||
try {
|
||||
ecriture.write(html);
|
||||
ecriture.write(chaine);
|
||||
ecriture.write(finHtml);
|
||||
} catch (IOException e2) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
ecriture.close();
|
||||
} catch (IOException e3) {
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
17
DEV2.1/TP14/01_Conversion/texte.html
Normal file
17
DEV2.1/TP14/01_Conversion/texte.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body><p>Mathias
|
||||
Le
|
||||
Goat
|
||||
De
|
||||
L'IUT
|
||||
De
|
||||
Fontainebleau
|
||||
Je
|
||||
Lui
|
||||
Lèche
|
||||
Les
|
||||
Pieds
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
12
DEV2.1/TP14/01_Conversion/texte.txt
Normal file
12
DEV2.1/TP14/01_Conversion/texte.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
Mathias
|
||||
Le
|
||||
Goat
|
||||
De
|
||||
L'IUT
|
||||
De
|
||||
Fontainebleau
|
||||
Je
|
||||
Lui
|
||||
Lèche
|
||||
Les
|
||||
Pieds
|
41
DEV2.1/TP14/02_Couleurs/Composant.java
Normal file
41
DEV2.1/TP14/02_Couleurs/Composant.java
Normal file
@@ -0,0 +1,41 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Composant extends JComponent {
|
||||
|
||||
private Color couleur1;
|
||||
private Color couleur2;
|
||||
private JLabel nomCouleur1;
|
||||
private JLabel nomCouleur2;
|
||||
|
||||
public Composant(Color couleur1, Color couleur2) {
|
||||
this.couleur1 = couleur1;
|
||||
this.couleur2 = couleur2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
|
||||
int[] x1 = {0, 0, this.getWidth()};
|
||||
int[] y1 = {0, this.getHeight(), this.getHeight()};
|
||||
|
||||
int[] x2 = {0, this.getWidth(), this.getWidth()};
|
||||
int[] y2 = {0, 0, this.getHeight()};
|
||||
|
||||
secondPinceau.setColor(this.couleur1);
|
||||
secondPinceau.fillPolygon(x1, y1, 3);
|
||||
secondPinceau.setColor(this.couleur2);
|
||||
secondPinceau.fillPolygon(x2, y2, 3);
|
||||
|
||||
JLabel couleur1Nom = this.nomCouleur1;
|
||||
JLabel couleur2Nom = this.nomCouleur2;
|
||||
|
||||
couleur1Nom.setHorizontalAlignment(JLabel.RIGHT);
|
||||
couleur2Nom.setHorizontalAlignment(JLabel.LEFT);
|
||||
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(couleur1Nom, BorderLayout.NORTH);
|
||||
this.add(couleur2Nom, BorderLayout.SOUTH);
|
||||
}
|
||||
}
|
15
DEV2.1/TP14/02_Couleurs/Fenetre.java
Normal file
15
DEV2.1/TP14/02_Couleurs/Fenetre.java
Normal file
@@ -0,0 +1,15 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
public Fenetre() {
|
||||
this.setSize(200, 200);
|
||||
this.setLocation(100, 100);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLayout(new GridLayout(1, 1));
|
||||
Color couleur1 = // TODO
|
||||
Color couleur2 = // TODO
|
||||
this.add(new Composant(couleur1, couleur2));
|
||||
}
|
||||
}
|
0
DEV2.1/TP14/02_Couleurs/GestionMoletteSouris.java
Normal file
0
DEV2.1/TP14/02_Couleurs/GestionMoletteSouris.java
Normal file
30
DEV2.1/TP14/02_Couleurs/LectureFichier.java
Normal file
30
DEV2.1/TP14/02_Couleurs/LectureFichier.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
||||
public class LectureFichier {
|
||||
|
||||
private Color[] tabCouleurs;
|
||||
private String[] tabNomsCouleurs;
|
||||
|
||||
public LectureFichier() {
|
||||
|
||||
try {
|
||||
BufferedReader lecture = new BufferedReader(new FileReader("rgb.txt"));
|
||||
|
||||
try {
|
||||
String ligne = lecture.readLine();
|
||||
// TODO : Split, trim des lignes + Gestion Molette
|
||||
} catch (IOException e2) {
|
||||
System.err.println("Erreur de lecture.");
|
||||
}
|
||||
try {
|
||||
lecture.close();
|
||||
} catch(IOException e3) {
|
||||
System.err.println("Erreur de fermeture.");
|
||||
}
|
||||
} catch(IOException e) {
|
||||
System.err.println("Erreur d'ouverture");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
6
DEV2.1/TP14/02_Couleurs/Main.java
Normal file
6
DEV2.1/TP14/02_Couleurs/Main.java
Normal file
@@ -0,0 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
738
DEV2.1/TP14/02_Couleurs/rgb.txt
Normal file
738
DEV2.1/TP14/02_Couleurs/rgb.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user