1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashSet;
import java.util.concurrent.Future;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javafx.concurrent.Task;
public class FractaleCalcul extends JFrame{
private Thread t;
private HashSet data;
private JProgressBar bar;
private int progress;
private int choice;
private int number;
public FractaleCalcul(int choice,int number){
this.choice = choice;
this.number = number;
this.setSize(300, 80);
this.setTitle("*** Calcul des points ***");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
bar = new JProgressBar();
bar.setMaximum(this.number);
bar.setMinimum(0);
bar.setStringPainted(true);
this.getContentPane().add(bar, BorderLayout.CENTER);
t = new Thread(new Traitement(this.choice,this.number));
t.start();
this.setVisible(true);
while(this.progress<this.number){
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
PanelDraw.draw(data);
}
public HashSet getData(){
return this.data;
}
public int getProgress(){
return this.progress;
}
class Traitement implements Runnable{
private int choice;
private int number;
public Traitement(int c,int n){
this.choice = c;
this.number = n;
}
public void run(){
HashSet<Matrix> hs = new HashSet();
float[][]tab = {{(float)0},{(float) 0}};
Matrix matriceU = new Matrix(2,1,tab);
for(int k=0;k<=this.number;k++){
matriceU = DragonCalcul.DragonCalc(matriceU);
hs.add(matriceU);
bar.setValue(k);
progress = k;
}
data = hs;
}
}
} |
Partager