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
| package fr.julien.graphique.lancement;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import fr.julien.graphique.lancement.ObservablePoint;
import fr.julien.graphique.lancement.ObservateurPoint;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import fr.ihm.projet.te.FenetreIHM;
import fr.ihm.projet.te.FenetrePoint;
import fr.julien.graphique.Graphique;
import fr.julien.graphique.ZoneGraphique;
import fr.julien.graphique.axes.AxeX;
import fr.julien.graphique.axes.AxeY;
import fr.julien.graphique.axes.OptionAxe;
import fr.julien.graphique.element.forme.Cercle;
import fr.julien.graphique.element.forme.OptionForme;
import fr.julien.graphique.element.forme.Polygone;
import fr.julien.graphique.element.point.Point;
import fr.julien.graphique.element.quadrillage.Quadrillage;
public class Test {
private Rendu rendu = new Rendu();
public Test() {
JButton ok1;
/********************************** FENETRE IHM *************************************************/
JFrame fenetreihm = new JFrame();
JPanel panelihm = new JPanel();
fenetreihm.setTitle("Tableau de Bord");
Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit()
.getScreenSize();
int hauteur = (int) tailleEcran.getHeight() - 40;
int largeur = ((int) tailleEcran.getWidth() - 2) / 2;
fenetreihm.setSize(largeur, hauteur);
fenetreihm.setLocation(0, 0);
fenetreihm.setVisible(true);
JButton point = new JButton(".");
point.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
FenetrePoint fenP = new FenetrePoint();
}
});
JButton rectangle = new JButton("[]");
JButton triangle = new JButton("Tri");
JButton cercle = new JButton("O");
JButton custom = new JButton("Pers.");
point.setBounds(20, 175, 70, 70);
fenetreihm.add(point);
rectangle.setBounds(20, 275, 70, 70);
fenetreihm.add(rectangle);
triangle.setBounds(20, 375, 70, 70);
fenetreihm.add(triangle);
cercle.setBounds(20, 475, 70, 70);
fenetreihm.add(cercle);
custom.setBounds(20, 575, 70, 70);
fenetreihm.add(custom);
fenetreihm.setLayout(null);
/**************************************************************************************************/
/******************************************** RENDU ******************************************************/
class Rendu extends JFrame {
public Rendu() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
OptionAxe optionsAxes = new OptionAxe(Color.BLACK, true, -1, 1,
true, true);
Graphique.getInstance().initGraphique(
new AxeX(-1, 10, optionsAxes),
new AxeY(-1, 10, optionsAxes));
Graphique.getInstance().ajouterElement(new Quadrillage(1, 1));
this.add(new ZoneGraphique());
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void dessinePoint(int a, int b) {
Graphique.getInstance().ajouterElement(new Point('A',a, b));
this.add(new ZoneGraphique());
this.pack();
this.repaint();
}
}
/**************************************************************************************************/
/************************************** CLASS INTERNE ************************************************************/
class FenetrePoint extends Test {
JTextField xlog = new JTextField();
JTextField ylog = new JTextField();
JFrame fenPoint = new JFrame();
public FenetrePoint() {
fenPoint.setTitle("Nouveau Point");
fenPoint.setSize(450, 300);
fenPoint.setLocationRelativeTo(null);
fenPoint.setVisible(true);
Dimension size = new Dimension(10, 10);
JPanel p = new JPanel();
fenPoint.add(p);
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
p.add(p1);
p.add(p2);
p.add(p3);
p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
p3.setLayout(new BoxLayout(p3, BoxLayout.X_AXIS));
/*************************** COORDONNEE X ******************************/
JLabel x = new JLabel("X: ");
xlog.setMaximumSize(new Dimension(175, 22));
p1.add(x);
p1.add(Box.createRigidArea(new Dimension(27, 10)));
p1.add(xlog);
/*************************** COORDONNEE Y ******************************/
JLabel y = new JLabel("Y: ");
ylog.setMaximumSize(new Dimension(175, 22));
p2.add(y);
p2.add(Box.createRigidArea(new Dimension(27, 10)));
p2.add(ylog);
/*************************** COMMANDE ******************************/
JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
/*int xp = Integer.valueOf(xlog.getText()).intValue();
int yp = Integer.valueOf(ylog.getText()).intValue();
Rendu lol;
lol = new Rendu();
lol.dessinePoint(2, 2);*/
System.exit(0);
}
});
JButton annuler = new JButton("Annuler");
p3.add(ok);
p3.add(Box.createRigidArea(size));
p3.add(annuler);
}
}
/**************************************************************************************************/
}
public Rendu getRendu() {
return this.rendu;
}
} |
Partager