package shukan; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; /** parameters of Shukan */ class ShukanParameters extends JFrame { /** panels of the graphic interface */ private JPanel pPrincipal,p, p1, p2; /** buttons of the graphic interface */ private JButton changerdetheme, theme1, theme2, theme3, retour, para; /** view of the app */ private ShukanView canvas; /** Color background, text, hollydays*/ private Color BACK_COLOR, BACK_COLOR2, TEXT_COLOR, HOLLY_COLOR, INACTIVE_COLOR; /** Number of modules to display */ private int nbModules = STD_MODULES_NUMBER; /** Standard number of modules */ private final static int STD_MODULES_NUMBER = 14; /**Labels for the shortcuts */ private JLabel Labq, Labl, Labm, LabLO, LabMP, Lableft, Labright, LabE, LabX; /** built a parameter window */ public ShukanParameters(String titre, ShukanView canvas) { super(titre); this.canvas = canvas; p = new JPanel(new GridBagLayout()); GridBagConstraints gbcprinc = new GridBagConstraints(); p1 = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); changerdetheme = new JButton("Changer de thème"); changerdetheme.setPreferredSize(new Dimension(190, 25)); changerdetheme.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { remove(pPrincipal); validate(); repaint(); gbc.insets = new Insets(10, 10, 10, 10); theme1 = new JButton("Thème sombre"); theme1.setPreferredSize(new Dimension(150, 25)); theme1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for(int i = 0; i <= 6; i++){ BACK_COLOR = new Color(51,51,51); BACK_COLOR2 = new Color(102,102,102); TEXT_COLOR = Color.WHITE; HOLLY_COLOR = new Color(153, 0, 0); INACTIVE_COLOR = new Color (204,204,204); canvas.setBackgroundColor(BACK_COLOR, BACK_COLOR2); canvas.setForeground(TEXT_COLOR, HOLLY_COLOR, INACTIVE_COLOR); } canvas.repaint(); } }); theme2 = new JButton("Thème modéré"); theme2.setPreferredSize(new Dimension(150, 25)); theme2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for(int i = 0; i <= nbModules; i++){ BACK_COLOR = new Color(102,102,102); BACK_COLOR2 = new Color(153,153,153); TEXT_COLOR = Color.BLACK; HOLLY_COLOR = new Color(255,102,102); INACTIVE_COLOR = new Color(51,51,51); canvas.setBackgroundColor(BACK_COLOR, BACK_COLOR2); canvas.setForeground(TEXT_COLOR, HOLLY_COLOR, INACTIVE_COLOR); } canvas.repaint(); } }); theme3 = new JButton("Thème clair"); theme3.setPreferredSize(new Dimension(150, 25)); theme3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for(int i = 0; i <= nbModules; i++){ BACK_COLOR = new Color(226,226,226); BACK_COLOR2 = Color.LIGHT_GRAY; TEXT_COLOR = Color.BLACK; HOLLY_COLOR = new Color (1.f, 0.8f, 0.7f); INACTIVE_COLOR = new Color (0.5f, 0.5f, 0.5f); canvas.setBackgroundColor(BACK_COLOR, BACK_COLOR2); canvas.setForeground(TEXT_COLOR, HOLLY_COLOR, INACTIVE_COLOR); } canvas.repaint(); } }); retour = new JButton("Retour"); retour.setPreferredSize(new Dimension(150, 25)); retour.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { remove(pPrincipal); validate(); repaint(); p.removeAll(); gbcprinc.insets = new Insets(10, 10, 10, 10); gbcprinc.gridx = 0; gbcprinc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; p.add(changerdetheme, gbcprinc); gbcprinc.gridx = 0; gbcprinc.gridy = 1; p.add(para, gbcprinc); pPrincipal = p; add(pPrincipal); validate(); repaint(); } }); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; p1.add(theme1, gbc); gbc.gridx = 0; gbc.gridy = 1; p1.add(theme2, gbc); gbc.gridx = 0; gbc.gridy = 2; p1.add(theme3, gbc); gbc.gridx = 0; gbc.gridy = 3; p1.add(retour, gbc); add(p1); pPrincipal = p1; validate(); repaint(); } }); para = new JButton("Raccourcis"); para.setPreferredSize(new Dimension(190, 25)); para.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ remove (pPrincipal); validate(); repaint(); p2 = new JPanel(new GridBagLayout()); GridBagConstraints gbcpara = new GridBagConstraints(); setSize(new Dimension(500, 400)); Labq = new JLabel("q : Quitter en sauvegardant"); Labl = new JLabel("l : Déplace extremité gauche vers gauche"); Labm = new JLabel("m : Déplace extremité droite vers droite"); LabLO = new JLabel("L, O : Déplace extremité gauche vers gauche sans bouger selection"); LabMP = new JLabel("M , P : Déplace extremité droite vers droite sans bouger selection"); Lableft = new JLabel("← : Professeur précédent"); Labright = new JLabel("→ : Professeur suivant"); LabE = new JLabel("E : Exporter en format .tex"); LabX = new JLabel("CTRL + X : Echanger les extrémités d'une séléction"); retour = new JButton("Retour"); retour.setPreferredSize(new Dimension(150, 25)); retour.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { remove(pPrincipal); validate(); repaint(); p2.removeAll(); gbcprinc.insets = new Insets(10, 10, 10, 10); setSize(new Dimension(300, 300)); gbcprinc.gridx = 0; gbcprinc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; p.add(changerdetheme, gbcprinc); gbcprinc.gridx = 0; gbcprinc.gridy = 1; p.add(para, gbcprinc); pPrincipal = p; add(pPrincipal); validate(); repaint(); } }); gbcpara.insets = new Insets(10, 10, 10, 10); gbcpara.anchor = GridBagConstraints.WEST; gbcpara.gridx = 0; gbcpara.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; p2.add(Labq, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 1; p2.add(Labl, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 2; p2.add(Labm, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 3; p2.add(LabLO, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 4; p2.add(LabMP, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 5; p2.add(Lableft, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 6; p2.add(Labright, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 7; p2.add(LabE, gbcpara); gbcpara.gridx = 0; gbcpara.gridy = 8; p2.add(LabX, gbcpara); gbcprinc.gridx = 0; gbcprinc.gridy = 9; p2.add(retour, gbcprinc); add(p2); pPrincipal = p2; validate(); repaint(); } }); gbcprinc.insets = new Insets(10, 10, 10, 10); gbcprinc.gridx = 0; gbcprinc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; p.add(changerdetheme, gbcprinc); gbcprinc.gridx = 0; gbcprinc.gridy = 1; p.add(para, gbcprinc); pPrincipal = p; add(pPrincipal); } }