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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
|
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Scrollbar;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class AffineFrame extends JFrame implements AdjustmentListener {
private Vector listeEvaluations;
private Scrollbar sbA;
private Scrollbar sbB;
private JTextField valeurA;
private JTextField valeurB;
private JTextField a, b, coeffATxt, coeffBTxt;
private JLabel resultat;
private JLabel resultatEssais;
private JLabel conjecture;
private JButton evaluer;
private Graphe graphe;
private Graphe graphe2;
private Signe signe;
private Variation variation;
private double coeffA, coeffB;
private Equation eq;
private Equation equationEleve;
private int nbEssais;
private int nbGraph;
/**
* Constructeur d'une fenêtre permettant d'afficher des droites affines
*/
public AffineFrame() {
super("Droites");
WindowListener w1 = new WindowAdapter(){
public void windowClosing ( WindowEvent we){
if (nbGraph != 0 ){
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
final JFrame question= new JFrame("Fermeture de la session.");
Container content = question.getContentPane();
question.setSize(400,100);
JPanel p = new JPanel();
JLabel jl = new JLabel("Voulez-vous sauvegarder le travail de l'élève.");
jl.setFont(new Font("Arial", Font.PLAIN, 14));
p.add(jl);
content.add(p,BorderLayout.CENTER);
JPanel buttons =new JPanel();
JButton oui = new JButton ("Oui");
JButton non = new JButton ("Non");
JButton annuler = new JButton ("Annuler");
buttons.add(oui);
buttons.add(non);
buttons.add(annuler);
content.add(buttons, BorderLayout.SOUTH);
oui.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
question.setVisible(false);
Outils.PasswordFrame pf = new Outils.PasswordFrame(
"Saisissez le mot de passe pour sauvegarder");
//System.out.println(pf.getValue());
String pwd = pf.getValue();
if (pwd != null && pwd.equals("prof")) {
new EvaluationFrame(listeEvaluations);
dispose();
nbGraph = 0;
}else{
question.setVisible(true);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
}
});
non.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
question.dispose();
}
});
annuler.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
question.dispose();
}
});
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
question.pack();
/* la fenêtre prend sa taille... */
question.setLocation(
(screenSize.width-question.getWidth())/2,
(screenSize.height-question.getHeight())/2
);
question.show();
}
}
};
addWindowListener(w1);
//panel principal
Container mainPanel = getContentPane();
mainPanel.setLayout(new BorderLayout());
//panel titre
JPanel panelTitre = new JPanel();
JLabel cours = new JLabel("Cours :");
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
Insets in = new Insets(20, 20, 0, 0);
c.insets = in;
gbl.setConstraints(cours, c);
panelTitre.add(cours);
JPanel blanc = new JPanel();
c.weightx = 1.0;
c.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(blanc, c);
panelTitre.add(blanc);
JTextArea titre =
new JTextArea(
"Toute droite non-verticale a pour équation réduite : \n\t\t\t Y = m × X + p \n\n Rmq : Toute droite verticale a pour équation ( X = k ), mais elle ne représente pas une fonction.",
4,
100);
titre.setFont(new Font("Arial", Font.PLAIN, 12));
titre.setLineWrap(true);
titre.setWrapStyleWord(true);
titre.setEditable(false);
JScrollPane jspanTitre = new JScrollPane(titre);
in = new Insets(10, 40, 20, 40);
c.insets = in;
c.fill = GridBagConstraints.BOTH;
c.weighty = 1.0;
gbl.setConstraints(jspanTitre, c);
panelTitre.add(jspanTitre);
panelTitre.setLayout(gbl);
mainPanel.add(panelTitre, BorderLayout.NORTH);
//Panel centre
JPanel panelCentre = new JPanel();
panelCentre.setLayout(new GridLayout(1, 2));
//valeurs
JPanel gauche = new JPanel();
GridBagLayout gbl2 = new GridBagLayout();
gauche.setLayout(gbl2);
in = new Insets(0, 20, 0, 0);
c = new GridBagConstraints();
c.insets = in;
c.weighty = 0;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
JLabel role = new JLabel("Rôle des paramètres :");
gbl2.setConstraints(role, c);
gauche.add(role);
JLabel reduite = new JLabel("Equation réduite :");
in = new Insets(10, 40, 0, 0);
c.insets = in;
gbl2.setConstraints(reduite, c);
gauche.add(reduite);
c.gridwidth = 1;
JLabel coeff = new JLabel("Coefficient directeur : m");
in.top = 10;
in.left = 60;
c.insets = in;
gbl2.setConstraints(coeff, c);
gauche.add(coeff);
valeurA = new JTextField("0.0", 4);
valeurA.setFont(new Font("Arial", Font.PLAIN, 14));
valeurA.setHorizontalAlignment(JTextField.CENTER);
valeurA.setForeground(Color.red);
valeurA.setEditable(false);
in.left = 20;
c.insets = in;
gbl2.setConstraints(valeurA, c);
gauche.add(valeurA);
c.weightx = 1.0;
c.gridwidth = GridBagConstraints.REMAINDER;
sbA = new Scrollbar(Scrollbar.HORIZONTAL, 0, 2, -1000, 1002);
sbA.addAdjustmentListener(this);
in.left = 20;
in.right = 20;
c.insets = in;
gbl2.setConstraints(sbA, c);
gauche.add(sbA);
coeff = new JLabel("Ordonnée à l'origine : p");
in.right = 10;
in.left = 60;
c.insets = in;
c.gridwidth = 1;
c.weightx = 0.0;
gbl2.setConstraints(coeff, c);
gauche.add(coeff);
valeurB = new JTextField("0.0", 4);
valeurB.setFont(new Font("Arial", Font.PLAIN, 14));
valeurB.setHorizontalAlignment(JTextField.CENTER);
valeurB.setForeground(Color.blue);
valeurB.setEditable(false);
in.left = 20;
in.right = 0;
c.insets = in;
gbl2.setConstraints(valeurB, c);
gauche.add(valeurB);
c.weightx = 1.0;
c.gridwidth = GridBagConstraints.REMAINDER;
sbB = new Scrollbar(Scrollbar.HORIZONTAL, 0, 2, -1000, 1002);
sbB.addAdjustmentListener(this);
in.right = 20;
c.insets = in;
gbl2.setConstraints(sbB, c);
gauche.add(sbB);
c.weightx = 0;
c.gridwidth = 1;
JPanel equationReduite = new JPanel();
GridBagLayout gbl3 = new GridBagLayout();
JLabel y = new JLabel("Y = ");
in.top = 5;
in.right = 0;
in.left = 60;
c.insets = in;
gbl3.setConstraints(y, c);
equationReduite.add(y);
a = new JTextField("m", 4);
a.setForeground(Color.red);
a.setHorizontalAlignment(JTextField.CENTER);
a.setEditable(false);
in.left = 0;
c.insets = in;
gbl3.setConstraints(a, c);
equationReduite.add(a);
JLabel x_plus = new JLabel(" × X + ");
gbl3.setConstraints(x_plus, c);
equationReduite.add(x_plus);
b = new JTextField("p", 4);
b.setForeground(Color.blue);
b.setHorizontalAlignment(JTextField.CENTER);
b.setEditable(false);
gbl3.setConstraints(b, c);
equationReduite.add(b);
blanc = new JPanel();
c.weightx = 1.0;
gbl3.setConstraints(blanc, c);
equationReduite.add(blanc);
equationReduite.setLayout(gbl3);
c.gridwidth = GridBagConstraints.REMAINDER;
gbl2.setConstraints(equationReduite, c);
gauche.add(equationReduite);
gbl.setConstraints(gauche, c);
panelCentre.add(gauche);
//variations
JPanel droite = new JPanel();
gbl = new GridBagLayout();
droite.setLayout(gbl);
eq = new EquationAffine(sbA.getValue() / 100.0, sbB.getValue() / 100.0);
graphe = new Graphe(-10, 10, 4000, eq);
//[tmin, tmax, nbPoints, equationParabole)
c = new GridBagConstraints();
in = new Insets(10, 10, 10, 40);
c.insets = in;
c.weightx = 1.0;
c.weighty = 1.0;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(graphe, c);
droite.add(graphe);
gbl.setConstraints(droite, c);
panelCentre.add(droite);
//Panel bas
JPanel panelBas = new JPanel();
panelBas.setLayout(new GridLayout(1, 2));
//graphe
gauche = new JPanel();
gbl = new GridBagLayout();
gauche.setLayout(gbl);
JLabel application = new JLabel("Application :");
c = new GridBagConstraints();
in = new Insets(30, 20, 0, 0);
c.insets = in;
gbl.setConstraints(application, c);
gauche.add(application);
c.gridwidth = GridBagConstraints.REMAINDER;
blanc = new JPanel();
gbl.setConstraints(blanc, c);
gauche.add(blanc);
graphe2 =
new Graphe(
-10,
10,
4000,
new EquationAffine(
sbA.getValue() / 100.0,
sbB.getValue() / 100.0));
//[tmin, tmax, nbPoints, equationParabole)
c = new GridBagConstraints();
in = new Insets(10, 40, 10, 20);
c.insets = in;
c.weightx = 1.0;
c.weighty = 1.0;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(graphe2, c);
gauche.add(graphe2);
panelBas.add(gauche);
//texte
droite = new JPanel();
gbl2 = new GridBagLayout();
droite.setLayout(gbl2);
in = new Insets(10, 15, 10, 15);
c = new GridBagConstraints();
c.insets = in;
c.weighty = 0;
c.fill = GridBagConstraints.BOTH;
c.weightx = 0;
c.gridwidth = 1;
final JButton valider = new JButton("Valider !");
final JButton generer = new JButton("Générer une Courbe");
generer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
nbGraph++;
nbEssais = 0;
conjecture.setText("Courbe nº "+nbGraph+" Tentative nº "+nbEssais);
resultat.setText(" ");
resultatEssais.setText(" ");
graphe.setAffichageAutorise(false);
//bloquer les curseur
sbA.setEnabled(false);
sbB.setEnabled(false);
//Permettre ecriture de A et B
coeffATxt.setEditable(true);
coeffBTxt.setEditable(true);
Equation eqGeneree = graphe2.getEquation();
EquationAffine ea = (EquationAffine) eqGeneree;
coeffA =
((double) ((int) (10 * (Math.random() * 20 - 10)))) / 10;
coeffATxt.setText("");
coeffB =
((double) ((int) (10 * (Math.random() * 20 - 10)))) / 10;
coeffBTxt.setText("");
ea.setA(coeffA);
ea.setB(coeffB);
ea.notifier();
generer.setEnabled(false);
valider.setEnabled(true);
}
});
gbl2.setConstraints(generer, c);
droite.add(generer);
blanc = new JPanel();
c.gridwidth = GridBagConstraints.RELATIVE;
c.weightx = 1.0;
gbl2.setConstraints(blanc, c);
droite.add(blanc);
evaluer = new JButton("Evaluation");
evaluer.setVisible(false);
evaluer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Outils.PasswordFrame pf =
new Outils.PasswordFrame(
"Saisissez le mot de passe pour évaluer");
// System.out.println(pf.getValue());
String pwd = pf.getValue();
if (pwd != null && pwd.equals("prof")) {
new EvaluationFrame(listeEvaluations);
nbGraph = 0;
}
}
});
c.weightx = 0;
in.right = 40;
c.insets = in;
gbl2.setConstraints(evaluer, c);
droite.add(evaluer);
evaluer.setVisible(false);
blanc = new JPanel();
c.gridwidth = GridBagConstraints.REMAINDER;
gbl2.setConstraints(blanc, c);
c.weightx = 1.0;
droite.add(blanc);
equationReduite = new JPanel();
gbl3 = new GridBagLayout();
y = new JLabel("Y = ");
in.top = 5;
in.right = 0;
in.left = 60;
c.insets = in;
c.weightx = 0;
c.gridwidth = 1;
gbl3.setConstraints(y, c);
equationReduite.add(y);
coeffATxt = new JTextField("m", 3);
coeffATxt.setHorizontalAlignment(JTextField.CENTER);
coeffATxt.setEditable(false);
in.left = 0;
c.insets = in;
gbl3.setConstraints(coeffATxt, c);
equationReduite.add(coeffATxt);
x_plus = new JLabel(" × X + ");
gbl3.setConstraints(x_plus, c);
equationReduite.add(x_plus);
coeffBTxt = new JTextField("p", 3);
coeffBTxt.setHorizontalAlignment(JTextField.CENTER);
coeffBTxt.setEditable(false);
gbl3.setConstraints(coeffBTxt, c);
equationReduite.add(coeffBTxt);
blanc = new JPanel();
c.weightx = 1.0;
gbl3.setConstraints(blanc, c);
equationReduite.add(blanc);
//Validité de la réponse
valider.setEnabled(false);
valider.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
graphe.setAffichageAutorise(false);
sbA.setEnabled(false);
sbB.setEnabled(false);
double a = 0.0;
try {
a = Double.parseDouble(coeffATxt.getText());
} catch (NumberFormatException nfe) {
coeffATxt.setText("0");
throw new RuntimeException("Veuillez saisir un nombre pour le coefficient directeur \"a\"");
}
double b = 0.0;
try {
b = Double.parseDouble(coeffBTxt.getText());
} catch (NumberFormatException nfe) {
coeffBTxt.setText("0");
throw new RuntimeException("Veuillez saisir un nombre pour l'ordonnée à l'origine \"b\"");
}
double diffA = Math.abs(coeffA - a);
double diffB = Math.abs(coeffB - b);
nbEssais++;
if (nbEssais == 1) {
//On sauve les coeffs de la première équation donnée par l'élève
equationEleve = new EquationAffine(a, b);
}
String A="";
if (a >= 0)
A = coeffATxt.getText();
else
A = "(" + coeffATxt.getText() + ")";
String B = "";
if (b >= 0)
B = coeffBTxt.getText();
else
B = "(" + coeffBTxt.getText() + ")";
conjecture.setText("Courbe nº "+nbGraph+" Tentative nº"+nbEssais+" : Y = "
+ A
+ " × X + "
+ B);
String coeffA3 = "";
if (coeffA >= 0)
coeffA3 = Double.toString(coeffA);
else
coeffA3 = "(" + Double.toString(coeffA) + ")";
String coeffB3 = "";
if (coeffB >= 0)
coeffB3 = Double.toString(coeffB);
else
coeffB3 = "(" + Double.toString(coeffB) + ")";
String coeffC3 = "";
//Test des resultats proposes par les etudiants
if (nbEssais >= 5 && (diffA > 0.5 || diffB > 0.2)) {
sbA.setEnabled(true);
sbB.setEnabled(true);
nbEssais=-1;
graphe.setAffichageAutorise(true);
coeffATxt.setEditable(false);
coeffBTxt.setEditable(false);
//resultatEssais.setText("Vous avez dépassé les 5 tentatives autorisées, veuillez revoir votre cours");
resultatEssais.setText(
"Vous avez effectué les 5 tentatives autorisées, veuillez revoir votre cours.");
resultat.setText(
" La bonne équation était : Y = "
+ coeffA3
+ " × X + "
+ coeffB3);
valider.setEnabled(false);
generer.setEnabled(true);
//Sauvegarde de l'évaluation
Vector coeffsEquationGeneree = new Vector();
coeffsEquationGeneree.add(new Double(coeffA));
coeffsEquationGeneree.add(new Double(coeffB));
//Sauvegarde de l'évaluation
Equation equationGeneree =
new EquationAffine(coeffA, coeffB);
listeEvaluations.add(
new Evaluation(
equationGeneree,
equationEleve,
nbEssais,
listeEvaluations));
//Fin de sauvegarde
//Bouton evaluer visible
if (nbGraph > 4) {
evaluer.setVisible(true);
}
} else {
if ((coeffA < 0 && a > 0)
|| (coeffA > 0 && a < 0)
|| (coeffB < 0 && b > 0)
|| (coeffB > 0 && b < 0)) {
resultat.setText(
"A l'aide des curseurs, observez dans le cours, l'influence du signe des paramètres.");
sbA.setEnabled(true);
sbB.setEnabled(true);
graphe.setAffichageAutorise(true);
} else if (diffA < 0.5) {
if (diffB < 0.2) {
sbA.setEnabled(true);
sbB.setEnabled(true);
graphe.setAffichageAutorise(true);
coeffATxt.setEditable(false);
coeffBTxt.setEditable(false);
String reponse = "";
switch (nbEssais) {
case 1 :
reponse =
"Excellent : vous avez trouvé en 1 tentative.";
break;
case 2 :
reponse =
"Trés bien : vous avez trouvé en 2 tentatives.";
break;
case 3 :
reponse =
"Bien : vous avez trouvé en 3 tentatives.";
break;
default :
reponse =
"Vous avez trouvé, mais si vous avez des difficultés appelez le professeur.";
}
resultat.setText(reponse);
resultatEssais.setText(
" La bonne équation est : Y = "
+ coeffA3
+ " × X + "
+ coeffB3);
valider.setEnabled(false);
generer.setEnabled(true);
// Sauvegarde de l'évaluation
Vector coeffsEquationGeneree = new Vector();
coeffsEquationGeneree.add(new Double(coeffA));
coeffsEquationGeneree.add(new Double(coeffB));
//Sauvegarde de l'évaluation
Equation equationGeneree =
new EquationAffine(coeffA, coeffB);
listeEvaluations.add(
new Evaluation(
equationGeneree,
equationEleve,
nbEssais,
listeEvaluations));
//Fin de sauvegarde
//Bouton evaluer visible
if (nbGraph > 4) {
evaluer.setVisible(true);
}
} else {
resultat.setText(" Vous devez recalculer B");
}
} else {
if (diffB < 0.2) {
resultat.setText(" Vous devez recalculer A");
} else {
resultat.setText(
"A l'aide des curseurs, appliquez vos valeurs dans le cours et corrigez vos choix");
graphe.setAffichageAutorise(true);
sbA.setEnabled(true);
sbB.setEnabled(true);
}
}
} //Fin du test des resultats proposes par les etudiants
} catch (Exception ex) {
//Affichage du message :)
resultat.setText(ex.getMessage());
}
}
});
//Fin de validité
in.right = 20;
c.insets = in;
gbl3.setConstraints(valider, c);
equationReduite.add(valider);
equationReduite.setLayout(gbl3);
c.gridwidth = GridBagConstraints.REMAINDER;
gbl2.setConstraints(equationReduite, c);
droite.add(equationReduite);
c.weightx = 0.0;
in.left = 20;
c.insets = in;
conjecture = new JLabel(" ");
gbl2.setConstraints(conjecture, c);
droite.add(conjecture);
c.weightx = 1.0;
gbl.setConstraints(droite, c);
panelBas.add(droite);
resultat = new JLabel(" ");
gbl2.setConstraints(resultat, c);
droite.add(resultat);
c.weightx = 1.0;
gbl.setConstraints(droite, c);
panelBas.add(droite);
resultatEssais = new JLabel(" ");
gbl2.setConstraints(resultatEssais, c);
droite.add(resultatEssais);
c.weightx = 1.0;
gbl.setConstraints(droite, c);
panelBas.add(droite);
JPanel principal = new JPanel();
gbl = new GridBagLayout();
principal.setLayout(gbl);
c = new GridBagConstraints();
c.weightx = 1.0;
c.weighty = 1.0;
c.fill = GridBagConstraints.BOTH;
c.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(panelCentre, c);
principal.add(panelCentre);
c.gridwidth = 1;
c.weighty = 1.0;
gbl.setConstraints(panelBas, c);
principal.add(panelBas);
mainPanel.add(principal, BorderLayout.CENTER);
//Dimensionnement minimal de la fenêtre
addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(ComponentEvent e) {
JFrame tmp = (JFrame) e.getSource();
int width = tmp.getWidth();
int height = tmp.getHeight();
if (width < 710 || height < 650) {
tmp.setSize(Math.max(width, 710), Math.max(height, 650));
}
}
});
listeEvaluations = new Vector();
pack();
show();
/*Cest ici la partie pour le plein ecran*/
/*****************************************************/
GraphicsDevice myDevice = GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice();
Window myWindow = new Window();
if( myDevice.isFullScreenSupported() ) {
try {
myDevice.setFullScreenWindow(myWindow);
/** ... */
} finally {
myDevice.setFullScreenWindow(null);
}
} else {
System.err.println("Plein écran non supporté");
}
}
/*Jusqu ici********************************************/
/**
* Factorisation du code
*/
public void adjustmentValueChanged(AdjustmentEvent event) {
//ScrollBar A et affichage de sa valeur
double valueA = sbA.getValue() / 100.0;
String chaineA = Double.toString(valueA);
valeurA.setText(chaineA);
if (valueA >= 0)
a.setText(chaineA);
else
a.setText("(" + chaineA + ")");
//ScrollBar B et affichage de sa valeur
double valueB = sbB.getValue() / 100.0;
String chaineB = Double.toString(valueB);
valeurB.setText(chaineB);
if (valueB >= 0)
b.setText(chaineB);
else
b.setText("(" + chaineB + ")");
//Mise à jour de l'équation et rafraîchissement du graphe
((EquationAffine) eq).setA(valueA);
((EquationAffine) eq).setB(valueB);
eq.notifier();
}
/**
* Appelée par le système pour redimensionner la fenêtre
* Fournit une taille minimale à cette fenêtre
*/
public Dimension getPreferredSize() {
return new Dimension(950, 700);
}
/**
* Appelée par le système pour repeindre la fenêtre
* Rafraîchit simplement la fenêtre et le bouton d'accès à l'évaluation
*/
public void paint(Graphics g){
super.paint(g);
evaluer.setVisible(listeEvaluations.size()> 4);
}
// /**
// * Main pour test unitaire :)
// */
// public static void main(String[] args) {
// new AffineFrame();
// }
} |
Partager