This commit is contained in:
2023-10-23 13:07:05 +02:00
parent 4f9ed8483e
commit 667dae6f1a
26 changed files with 469 additions and 45 deletions

View File

@@ -2,23 +2,29 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Polygon;
import java.lang.Math;
public class Q5Main{
public static void main(String[] args) {
int l = 1000;
int m = 40;
int detail = Integer.parseInt(args[0]);
JFrame fenetre = new JFrame("Q1 Galerie");
fenetre.setSize(300, 200);
fenetre.setLocation(700, 300);
fenetre.setSize(l+2*m, l+2*m);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Polygon etoile = new Polygon();
etoile.addPoint(50,50);
etoile.addPoint(300,140);
etoile.addPoint(230,80);
etoile.addPoint(10,330);
fenetre.setVisible(true);
Q5Polygon dessinEtoile = new Q5Polygon(etoile);
Q5Recursivite modele = new Q5Recursivite(etoile, fenetre);
fenetre.add(dessinEtoile);
fenetre.setVisible(true);
Q5Point g = new Q5Point(m+l/2, m);
Q5Point c = new Q5Point(m+l-((int)(l*Math.sqrt(3))/2), m+(3*l)/4);
Q5Point a = new Q5Point(2*m+((int)(l*Math.sqrt(3))/2), m+(3*l)/4);
modele.nextStep(detail, a,c,g);
modele.nextStep(detail, c,g,a);
modele.nextStep(detail, g,a,c);
}
}

Binary file not shown.

View File

@@ -0,0 +1,33 @@
public class Q5Point{
public int x;
public int y;
public Q5Point(int x, int y) {
this.x = x;
this.y = y;
}
public Q5Point() {
this.x = 0;
this.y = 0;
}
public static Q5Point tiers(Q5Point a, Q5Point b){
Q5Point resultat = new Q5Point();
resultat.x = (int) a.x + (b.x - a.x)/3;
resultat.y = (int) a.y + (b.y - a.y)/3;
return resultat;
}
public static Q5Point millieu(Q5Point a, Q5Point b){
Q5Point resultat = new Q5Point();
resultat.x = (int) a.x + (b.x - a.x)/2;
resultat.y = (int) a.y + (b.y - a.y)/2;
return resultat;
}
public static Q5Point pointe(Q5Point a, Q5Point b, Q5Point p){
Q5Point i = Q5Point.millieu(a,b);
Q5Point resultat = new Q5Point();
resultat.x = (int) i.x - (p.x - i.x)/3;
resultat.y = (int) i.y - (p.y - i.y)/3;
return resultat;
}
}

View File

@@ -11,6 +11,6 @@ public class Q5Polygon extends JComponent {
@Override
protected void paintComponent(Graphics pinceau) {
pinceau.setColor(Color.BLUE);
pinceau.fillPolygon(this.etoile);
pinceau.drawPolygon(this.etoile);
}
}

Binary file not shown.

View File

@@ -0,0 +1,32 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Polygon;
public class Q5Recursivite{
public Polygon etoile;
public JFrame fenetre;
public Q5Recursivite(Polygon etoile, JFrame fenetre) {
this.etoile = etoile;
this.fenetre = fenetre;
}
public void nextStep(int i, Q5Point c, Q5Point g, Q5Point a){
if (i<=0){
this.etoile.addPoint(c.x,c.y);
this.fenetre.repaint();
}
else{
Q5Point b = Q5Point.tiers(c,a);
Q5Point d = Q5Point.tiers(c,g);
Q5Point e = Q5Point.pointe(c,g,a);
Q5Point f = Q5Point.tiers(g,c);
Q5Point h = Q5Point.tiers(g,a);
this.nextStep(i-1, c, d, b);
this.nextStep(i-1, d, e, f);
this.nextStep(i-1, e, f, d);
this.nextStep(i-1, f, g, h);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,34 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Action implements MouseListener{
public java.util.List<Parallelogramme> listeParallelogramme;
public Action(java.util.List<Parallelogramme> listeParallelogramme){
this.listeParallelogramme = listeParallelogramme;
}
@Override
public void mouseClicked(MouseEvent e){
for (Parallelogramme parallelogramme : this.listeParallelogramme){
if (parallelogramme.forme.contains(e.getPoint())){
System.out.println("clic");
}
}
}
@Override
public void mouseEntered(MouseEvent e){
}
@Override
public void mouseExited(MouseEvent e){
}
@Override
public void mousePressed(MouseEvent e){
}
@Override
public void mouseReleased(MouseEvent e){
}
}

Binary file not shown.

View File

@@ -0,0 +1,27 @@
import javax.swing.JComponent;
import java.awt.*;
import java.util.*;
public class Dessin extends JComponent {
public java.util.List<Parallelogramme> listeParallelogramme;
public Dessin(java.util.List<Parallelogramme> listeParallelogramme){
this.listeParallelogramme = listeParallelogramme;
}
@Override
protected void paintComponent(Graphics pinceau) {
Graphics secondPinceau = pinceau.create();
if (this.isOpaque()) {
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
for (Parallelogramme parallelogramme : this.listeParallelogramme){
secondPinceau.setColor(parallelogramme.couleur);
secondPinceau.fillPolygon(parallelogramme.forme);
secondPinceau.setColor(Color.BLACK);
secondPinceau.drawPolygon(parallelogramme.forme);
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,28 @@
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Main{
public static void main(String[] args){
JFrame fenetre = new JFrame();
fenetre.setSize(700, 300);
fenetre.setLocation(0, 0);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
java.util.List<Parallelogramme> listeParallelogramme = new ArrayList<>();
int i;
Parallelogramme suivant = new Parallelogramme();
for (i=0; i<10; i++){
listeParallelogramme.add(suivant);
suivant = new Parallelogramme(suivant);
}
Action action = new Action(listeParallelogramme);
fenetre.addMouseListener(action);
Dessin lesDessins = new Dessin(listeParallelogramme);
fenetre.add(lesDessins);
fenetre.setVisible(true);
}
}

Binary file not shown.

View File

@@ -0,0 +1,28 @@
import java.awt.*;
import java.util.*;
public class Parallelogramme{
public static int hauteur=100;
public static int largeur=50;
public static int marge=5;
public static int inclinaison=40;
public static Random aleatoire = new Random();
public Polygon forme;
public Color couleur;
public Parallelogramme(){
this(0,Parallelogramme.marge);
}
public Parallelogramme(Parallelogramme ancien){
this(ancien.forme.xpoints[1],ancien.forme.ypoints[2]);
}
public Parallelogramme(int gauche, int haut){
this.forme = new Polygon();
this.couleur = new Color(Parallelogramme.aleatoire.nextInt(255), Parallelogramme.aleatoire.nextInt(255), Parallelogramme.aleatoire.nextInt(255));
this.forme.addPoint(gauche+Parallelogramme.marge, haut+Parallelogramme.hauteur);
this.forme.addPoint(gauche+Parallelogramme.marge+Parallelogramme.largeur, haut+Parallelogramme.hauteur);
this.forme.addPoint(gauche+Parallelogramme.marge+Parallelogramme.largeur+Parallelogramme.inclinaison, haut);
this.forme.addPoint(gauche+Parallelogramme.marge+Parallelogramme.inclinaison, haut);
}
}

View File

@@ -0,0 +1,16 @@
1.
employee
2.
employee
3.
gerer la bibliotheque (gerer les adherants, gerer les oeuvres)
gerer les contentieux
s'authentifier
lancer des poursuites judiciaires
4.
5.

Binary file not shown.