TP3
This commit is contained in:
parent
fe693705bf
commit
2f94e24111
DEV2.1
@ -1 +1 @@
|
||||
Subproject commit c5462401edb1a4b551292c62563745d06f71de07
|
||||
Subproject commit b9598b5ae3d8c0ac40d70e95e718ecf5396a1e7f
|
Binary file not shown.
@ -21,7 +21,7 @@ public class LectureFichier {
|
||||
for (String info : infosTab) {
|
||||
System.out.println(info);
|
||||
}
|
||||
this.image = new BufferedImage(Integer.parseInt(infosTab[0]), Integer.parseInt(infosTab[1]), BufferedImage.TYPE_3BYTE_BGR);
|
||||
this.image = new BufferedImage(Integer.parseInt(infosTab[1]), Integer.parseInt(infosTab[2]), BufferedImage.TYPE_3BYTE_BGR);
|
||||
|
||||
char[] caracteres = new char[15];
|
||||
Color[] couleurs = new Color[15];
|
||||
@ -46,7 +46,7 @@ public class LectureFichier {
|
||||
String ligne = lecture.readLine().replaceAll("\"", "");
|
||||
ligne = ligne.substring(0, ligne.length()-1);
|
||||
|
||||
for (int j = 0; j != ligne.length(); j++) {
|
||||
for (int j = 0; j != Integer.parseInt(infosTab[0]); j++) {
|
||||
for (int k = 0; k != caracteres.length; k++) {
|
||||
if (caracteres[k] == ligne.charAt(j)) {
|
||||
this.image.setRGB(i, j, couleurs[k].getRGB());
|
||||
|
3
DEV2.1/TP13/03_Questionnaire/LectureFichier.java
Normal file
3
DEV2.1/TP13/03_Questionnaire/LectureFichier.java
Normal file
@ -0,0 +1,3 @@
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
|
5
DEV2.1/TP13/03_Questionnaire/Main.java
Normal file
5
DEV2.1/TP13/03_Questionnaire/Main.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
LectureFichier fichier = new LectureFichier();
|
||||
}
|
||||
}
|
24
DEV2.1/TP13/03_Questionnaire/java.quiz
Normal file
24
DEV2.1/TP13/03_Questionnaire/java.quiz
Normal file
@ -0,0 +1,24 @@
|
||||
Quel mot-clé représente la réalisation d'une interface ?
|
||||
-extends
|
||||
-implements
|
||||
-throws
|
||||
Quel type primitif est stocké sur 16 bits ?
|
||||
-char
|
||||
-byte
|
||||
-float
|
||||
Quel qualificatif représente un membre de classe ?
|
||||
-final
|
||||
-protected
|
||||
-static
|
||||
Vers quel type primitif peut-on convertir implicitement un long ?
|
||||
-float
|
||||
-boolean
|
||||
-int
|
||||
Quel mot-clé qualifie une classe qui ne définit pas complètement ses méthodes ?
|
||||
-private
|
||||
-static
|
||||
-abstract
|
||||
Quelle peut être la classe apparente d'un objet encapsulant la valeur 0.1 ?
|
||||
-Byte
|
||||
-Number
|
||||
-Short
|
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
Loading…
x
Reference in New Issue
Block a user