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
|
public class Outils extends JToolBar {
public Outils() {
setFloatable(false);
final ScalingControl scaler = new CrossoverScalingControl();
setBorder(new LineBorder(Color.DARK_GRAY));
// Nouveau
Icon icone = new ImageIcon("images/stock_new.png");
JButton bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
this.add(bouton);
// Save
icone = new ImageIcon("images/stock_save.png");
bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveEtat();
}
});
this.add(bouton);
this.addSeparator();
// Zoom +
icone = new ImageIcon("images/stock_zoom-in.png");
bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(Tableau.getInstance().getVisualization(), 1.1f, Tableau.getInstance().getVisualization().getCenter());
}
});
this.add(bouton);
// Zoom -
icone = new ImageIcon("images/stock_zoom-out.png");
bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
scaler.scale(Tableau.getInstance().getVisualization(), 1/1.1f, Tableau.getInstance().getVisualization().getCenter());
}
});
this.add(bouton);
this.addSeparator();
// PICKING
icone = new ImageIcon("images/stock_pick.png");
bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Tableau.getInstance().getGraphMouse().setMode(ModalGraphMouse.Mode.PICKING);
}
});
this.add(bouton);
// EDITING
icone = new ImageIcon("images/stock_edit.png");
bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Tableau.getInstance().getGraphMouse().setMode(ModalGraphMouse.Mode.EDITING);
}
});
this.add(bouton);
// TRANSFORMING
icone = new ImageIcon("images/stock_transform.png");
bouton = new JButton(icone);
bouton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Tableau.getInstance().getGraphMouse().setMode(ModalGraphMouse.Mode.TRANSFORMING);
}
});
this.add(bouton);
}
private void saveEtat() {
for (Object o : Tableau.getInstance().getGraph().getVertices()) {
Materiel m = (Materiel)o;
HibernateRequetes.saveComposant(m.getComposant());
}
Tableau.getInstance().ajoutInfo("Your panel has been correctly saved to the database.");
}
} |