mirror of
https://github.com/LucasVbr/LecteurPdfDoubleAffichage.git
synced 2026-05-13 17:11:51 +00:00
Edit interface Raccourcis claviers + refactor de code
This commit is contained in:
@@ -85,7 +85,7 @@ public class GestionPdf {
|
||||
GestionMode.setModeSepare();
|
||||
newIhmPdf();
|
||||
|
||||
System.out.println(RaccourcisClavier.raccourcis);
|
||||
System.out.println(RaccourcisClavier.gestionnaireRaccourcis);
|
||||
// System.out.println(RaccourcisClavier.raccourcis);
|
||||
// System.out.println(RaccourcisClavier.gestionnaireRaccourcis);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,7 @@ import javax.swing.*;
|
||||
* @author Tristan Nogaret
|
||||
*/
|
||||
public class MenuBar extends JMenuBar {
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
|
||||
public MenuBar(IhmPdf parent) {
|
||||
add(new MenuFichier(parent));
|
||||
add(new MenuAffichage(parent));
|
||||
|
||||
@@ -46,8 +46,6 @@ public class MenuAffichage extends JMenu {
|
||||
add(new ZoomPlus(parent));
|
||||
addSeparator();
|
||||
|
||||
|
||||
|
||||
add(new PageEntiere(parent));
|
||||
add(new PleineLargeur(parent));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,5 @@ public class MenuFichier extends JMenu {
|
||||
add(new OuvrirFichier(parent));
|
||||
add(new FermerFichier(parent));
|
||||
add(new Quitter(parent));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,5 @@ public class MenuMode extends JMenu {
|
||||
addSeparator();
|
||||
add(modeSepare);
|
||||
add(modeSynchronise);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import lecteur_pdf.IhmPdf;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -31,29 +32,28 @@ public class FermerFichier extends MenuItem {
|
||||
public FermerFichier(IhmPdf parent) {
|
||||
super(parent, "Fermer");
|
||||
|
||||
/* Action du bouton */
|
||||
addActionListener(e -> {
|
||||
JDialog jd = new JDialog();
|
||||
jd.setLayout(new FlowLayout());
|
||||
jd.setBounds(500,300,400,100);
|
||||
JLabel jlabel = new JLabel("etes vous sûr de vouloir fermer ? ");
|
||||
JButton oui = new JButton("oui");
|
||||
oui.addActionListener(m -> {
|
||||
parent.getPdfPanel().dechargerPdf();
|
||||
parent.setTitle(GestionPdf.TITRE_APPLICATION);
|
||||
parent.pack();
|
||||
jd.setVisible(false);
|
||||
});
|
||||
JButton non = new JButton("non");
|
||||
non.addActionListener(n -> jd.setVisible(false));
|
||||
jd.add(jlabel);
|
||||
jd.add(oui);
|
||||
jd.add(non);
|
||||
jd.setVisible(true);
|
||||
|
||||
});
|
||||
|
||||
/* TODO Définition du raccourcis clavier a modifier */
|
||||
setRaccourcis(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK);
|
||||
// setRaccourcis(KeyEvent.VK_X, KeyEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
JDialog jd = new JDialog();
|
||||
jd.setLayout(new FlowLayout());
|
||||
jd.setBounds(500,300,400,100);
|
||||
JLabel jlabel = new JLabel("etes vous sûr de vouloir fermer ? ");
|
||||
JButton oui = new JButton("oui");
|
||||
oui.addActionListener(m -> {
|
||||
parent.getPdfPanel().dechargerPdf();
|
||||
parent.setTitle(GestionPdf.TITRE_APPLICATION);
|
||||
parent.pack();
|
||||
jd.setVisible(false);
|
||||
});
|
||||
JButton non = new JButton("non");
|
||||
non.addActionListener(n -> jd.setVisible(false));
|
||||
jd.add(jlabel);
|
||||
jd.add(oui);
|
||||
jd.add(non);
|
||||
jd.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import lecteur_pdf.IhmPdf;
|
||||
import lecteur_pdf.raccourcisClavier.RaccourcisClavier;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* TODO commentaires
|
||||
@@ -19,7 +20,7 @@ import javax.swing.*;
|
||||
* @author Noé Villeneuve
|
||||
* @author Tristan Nogaret
|
||||
*/
|
||||
public class MenuItem extends JMenuItem {
|
||||
public abstract class MenuItem extends JMenuItem {
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -30,40 +31,33 @@ public class MenuItem extends JMenuItem {
|
||||
* TODO
|
||||
*
|
||||
* @param parent Référence de la fenêtre qui possède l'instance de ce MenuItem
|
||||
* @param name
|
||||
* @param name Nom de l'action
|
||||
*/
|
||||
public MenuItem(IhmPdf parent, String name) {
|
||||
super(name);
|
||||
this.parent = parent;
|
||||
|
||||
addActionListener(this::action);
|
||||
RaccourcisClavier.listeItem.put(name, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public void setRaccourcis(int key) {
|
||||
KeyStroke raccourcis = KeyStroke.getKeyStroke((char) key);
|
||||
setAccelerator(raccourcis);
|
||||
protected abstract void action(ActionEvent evt);
|
||||
|
||||
RaccourcisClavier.raccourcis.put(this.getText(), raccourcis);
|
||||
RaccourcisClavier.gestionnaireRaccourcis.put(this, this.getText());
|
||||
}
|
||||
// public void setRaccourcis(int key) {
|
||||
// KeyStroke raccourcis = KeyStroke.getKeyStroke((char) key);
|
||||
// setAccelerator(raccourcis);
|
||||
//
|
||||
// RaccourcisClavier.raccourcis.put(this.getText(), raccourcis);
|
||||
// RaccourcisClavier.gestionnaireRaccourcis.put(this, this.getText());
|
||||
// }
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @param key
|
||||
* @param mask
|
||||
*/
|
||||
public void setRaccourcis(int key, int mask) {
|
||||
KeyStroke raccourcis = KeyStroke.getKeyStroke(key, mask);
|
||||
setAccelerator(raccourcis);
|
||||
// public void setRaccourcis(int key, int mask) {
|
||||
// KeyStroke raccourcis = KeyStroke.getKeyStroke(key, mask);
|
||||
// setAccelerator(raccourcis);
|
||||
//
|
||||
// RaccourcisClavier.raccourcis.put(this.getText(), raccourcis);
|
||||
// RaccourcisClavier.gestionnaireRaccourcis.put(this, this.getText());
|
||||
// }
|
||||
|
||||
RaccourcisClavier.raccourcis.put(this.getText(), raccourcis);
|
||||
RaccourcisClavier.gestionnaireRaccourcis.put(this, this.getText());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,18 +21,12 @@ import javax.swing.*;
|
||||
*/
|
||||
public class ModeSynchronise extends JRadioButtonMenuItem {
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
IhmPdf parent;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param parent Référence de la fenêtre qui possède l'instance de ce MenuItem
|
||||
*/
|
||||
public ModeSynchronise(IhmPdf parent) {
|
||||
super("Mode Synchronisé");
|
||||
this.parent = parent;
|
||||
|
||||
addActionListener(e -> {
|
||||
GestionMode.setModeSynchronise();
|
||||
|
||||
@@ -9,6 +9,8 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
import lecteur_pdf.IhmPdf;
|
||||
import lecteur_pdf.raccourcisClavier.RaccourcisClavier;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* TODO commentaires
|
||||
*
|
||||
@@ -25,10 +27,10 @@ public class ModifierTouches extends MenuItem {
|
||||
*/
|
||||
public ModifierTouches(IhmPdf parent) {
|
||||
super(parent, "Modifier Touches");
|
||||
}
|
||||
|
||||
addActionListener(e -> {
|
||||
new RaccourcisClavier();
|
||||
});
|
||||
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
new RaccourcisClavier();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import lecteur_pdf.GestionMode;
|
||||
import lecteur_pdf.GestionPdf;
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* TODO commentaires
|
||||
@@ -28,14 +28,14 @@ public class NouvelleFenetre extends MenuItem {
|
||||
*/
|
||||
public NouvelleFenetre(IhmPdf parent) {
|
||||
super(parent, "Nouvelle Fenêtre");
|
||||
}
|
||||
|
||||
addActionListener(e -> {
|
||||
/* Essaye de créer une nouvelle fenêtre */
|
||||
GestionPdf.newIhmPdf();
|
||||
|
||||
/* Désactive le bouton si on a atteint la limite des affichages */
|
||||
if (GestionPdf.ihmPdfList.size() == GestionPdf.maxPdf) GestionMode.desactiverFenetre();
|
||||
});
|
||||
@Override
|
||||
public void action(ActionEvent evt) {
|
||||
/* Essaye de créer une nouvelle fenêtre */
|
||||
GestionPdf.newIhmPdf();
|
||||
|
||||
/* Désactive le bouton si on a atteint la limite des affichages */
|
||||
if (GestionPdf.ihmPdfList.size() == GestionPdf.maxPdf) GestionMode.desactiverFenetre();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import lecteur_pdf.GestionPdf;
|
||||
import lecteur_pdf.IhmPdf;
|
||||
import lecteur_pdf.SelectionnerFichier;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
|
||||
@@ -26,32 +27,32 @@ public class OuvrirFichier extends MenuItem {
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public OuvrirFichier(IhmPdf parent) {
|
||||
super(parent, "Ouvrir");
|
||||
|
||||
addActionListener(e -> {
|
||||
/* On charge le fichier si c'est possible */
|
||||
File fichier = SelectionnerFichier.ouvrirFichier();
|
||||
// setRaccourcis(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
if (fichier == null) {
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
/* On charge le fichier si c'est possible */
|
||||
File fichier = SelectionnerFichier.ouvrirFichier();
|
||||
|
||||
/* Si il y a deja un fichier d'ouvert, on le ferme */
|
||||
parent.getPdfPanel().dechargerPdf();
|
||||
parent.setTitle(GestionPdf.TITRE_APPLICATION);
|
||||
if (fichier == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Si il y a deja un fichier d'ouvert, on le ferme */
|
||||
parent.getPdfPanel().dechargerPdf();
|
||||
parent.setTitle(GestionPdf.TITRE_APPLICATION);
|
||||
parent.pack();
|
||||
|
||||
if (parent.getPdfPanel().chargerPdf(fichier)) {
|
||||
parent.setTitle(GestionPdf.TITRE_APPLICATION + " - " + fichier.getName());
|
||||
parent.pack();
|
||||
|
||||
if (parent.getPdfPanel().chargerPdf(fichier)) {
|
||||
parent.setTitle(GestionPdf.TITRE_APPLICATION + " - " + fichier.getName());
|
||||
parent.pack();
|
||||
} else {
|
||||
// TODO Erreur fichier n'as pas pu etre chargé
|
||||
}
|
||||
});
|
||||
|
||||
setRaccourcis(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK);
|
||||
} else {
|
||||
// TODO Erreur fichier n'as pas pu etre chargé
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class PageEntiere extends MenuItem {
|
||||
/**
|
||||
* TODO
|
||||
@@ -9,9 +11,10 @@ public class PageEntiere extends MenuItem {
|
||||
*/
|
||||
public PageEntiere(IhmPdf parent) {
|
||||
super(parent, "Page Entière");
|
||||
}
|
||||
|
||||
addActionListener(e -> {
|
||||
parent.getPdfPanel().setPleineLargeur(false);
|
||||
});
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
parent.getPdfPanel().setPleineLargeur(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import lecteur_pdf.GestionMode;
|
||||
import lecteur_pdf.GestionPdf;
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -29,14 +30,12 @@ public class PagePrecedente extends MenuItem {
|
||||
public PagePrecedente(IhmPdf parent) {
|
||||
super(parent, "Page précédente");
|
||||
|
||||
addActionListener(e -> {
|
||||
if (GestionMode.isModeSepare()) {
|
||||
parent.getPdfPanel().previousPage();
|
||||
} else {
|
||||
GestionPdf.previousPages();
|
||||
}
|
||||
});
|
||||
// setRaccourcis(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
setRaccourcis(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK);
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
if (GestionMode.isModeSepare()) parent.getPdfPanel().previousPage();
|
||||
else GestionPdf.previousPages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import lecteur_pdf.GestionMode;
|
||||
import lecteur_pdf.GestionPdf;
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -29,14 +30,12 @@ public class PageSuivante extends MenuItem {
|
||||
public PageSuivante(IhmPdf parent) {
|
||||
super(parent, "Page suivante");
|
||||
|
||||
addActionListener(e -> {
|
||||
if (GestionMode.isModeSepare()) {
|
||||
parent.getPdfPanel().nextPage();
|
||||
} else {
|
||||
GestionPdf.nextPages();
|
||||
}
|
||||
});
|
||||
// setRaccourcis(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
setRaccourcis(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK);
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
if (GestionMode.isModeSepare()) parent.getPdfPanel().nextPage();
|
||||
else GestionPdf.nextPages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -27,10 +28,11 @@ public class PleinEcran extends MenuItem {
|
||||
public PleinEcran(IhmPdf parent) {
|
||||
super(parent, "Mode Plein Ecran");
|
||||
|
||||
addActionListener(e -> {
|
||||
parent.pleinEcran();
|
||||
});
|
||||
// setRaccourcis(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
setRaccourcis(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK);
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
parent.pleinEcran();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class PleineLargeur extends MenuItem{
|
||||
|
||||
|
||||
@@ -11,9 +13,10 @@ public class PleineLargeur extends MenuItem{
|
||||
*/
|
||||
public PleineLargeur(IhmPdf parent) {
|
||||
super(parent, "Pleine Largeur");
|
||||
}
|
||||
|
||||
addActionListener(e -> {
|
||||
parent.getPdfPanel().setPleineLargeur(true);
|
||||
});
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
parent.getPdfPanel().setPleineLargeur(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import lecteur_pdf.IhmPdf;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -29,26 +30,25 @@ public class Quitter extends MenuItem {
|
||||
public Quitter(IhmPdf parent) {
|
||||
super(parent, "Quitter");
|
||||
|
||||
addActionListener(e -> {
|
||||
JDialog jd = new JDialog();
|
||||
jd.setLayout(new FlowLayout());
|
||||
jd.setBounds(500,300,400,100);
|
||||
JLabel jlabel = new JLabel("etes vous sûr de vouloir quitter ? ");
|
||||
JButton oui = new JButton("oui");
|
||||
oui.addActionListener(m -> {
|
||||
parent.quitter();
|
||||
jd.setVisible(false);
|
||||
});
|
||||
JButton non = new JButton("non");
|
||||
non.addActionListener(n -> jd.setVisible(false));
|
||||
jd.add(jlabel);
|
||||
jd.add(oui);
|
||||
jd.add(non);
|
||||
jd.setVisible(true);
|
||||
|
||||
});
|
||||
|
||||
setRaccourcis(KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK);
|
||||
// setRaccourcis(KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
JDialog jd = new JDialog();
|
||||
jd.setLayout(new FlowLayout());
|
||||
jd.setBounds(500,300,400,100);
|
||||
JLabel jlabel = new JLabel("etes vous sûr de vouloir quitter ? ");
|
||||
JButton oui = new JButton("oui");
|
||||
oui.addActionListener(m -> {
|
||||
parent.quitter();
|
||||
jd.setVisible(false);
|
||||
});
|
||||
JButton non = new JButton("non");
|
||||
non.addActionListener(n -> jd.setVisible(false));
|
||||
jd.add(jlabel);
|
||||
jd.add(oui);
|
||||
jd.add(non);
|
||||
jd.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -27,13 +28,13 @@ public class ZoomDefaut extends MenuItem {
|
||||
public ZoomDefaut(IhmPdf parent) {
|
||||
super(parent, "Zoom 100%");
|
||||
|
||||
addActionListener(e -> {
|
||||
parent.getPdfPanel().updateScaleZoom(1.0f);
|
||||
parent.validate();
|
||||
});
|
||||
|
||||
setRaccourcis(KeyEvent.VK_G, KeyEvent.CTRL_DOWN_MASK);
|
||||
// setRaccourcis(KeyEvent.VK_G, KeyEvent.CTRL_DOWN_MASK);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
parent.getPdfPanel().updateScaleZoom(1.0f);
|
||||
parent.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -27,12 +28,13 @@ public class ZoomMoins extends MenuItem {
|
||||
public ZoomMoins(IhmPdf parent) {
|
||||
super(parent, "Zoom 50%");
|
||||
|
||||
addActionListener(e -> {
|
||||
parent.getPdfPanel().updateScaleZoom(0.5f);
|
||||
parent.validate();
|
||||
});
|
||||
|
||||
setRaccourcis(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK);
|
||||
// setRaccourcis(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
parent.getPdfPanel().updateScaleZoom(0.5f);
|
||||
parent.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package lecteur_pdf.menuBar.menuItems;
|
||||
|
||||
import lecteur_pdf.IhmPdf;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
@@ -27,12 +28,13 @@ public class ZoomPlus extends MenuItem {
|
||||
public ZoomPlus(IhmPdf parent) {
|
||||
super(parent, "Zoom 150%");
|
||||
|
||||
addActionListener(e -> {
|
||||
parent.getPdfPanel().updateScaleZoom(1.5f);
|
||||
parent.validate();
|
||||
});
|
||||
|
||||
setRaccourcis(KeyEvent.VK_H, KeyEvent.CTRL_DOWN_MASK);
|
||||
// setRaccourcis(KeyEvent.VK_H, KeyEvent.CTRL_DOWN_MASK);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void action(ActionEvent evt) {
|
||||
parent.getPdfPanel().updateScaleZoom(1.5f);
|
||||
parent.validate();
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,6 @@ public class OutilsImage {
|
||||
int h = img.getHeight();
|
||||
|
||||
int ratio = newH / (1+h);
|
||||
// System.out.println(ratio);
|
||||
|
||||
int newW = w * ratio;
|
||||
|
||||
|
||||
@@ -110,8 +110,7 @@ public class PdfLoader {
|
||||
document.close();
|
||||
minWidth = -1;
|
||||
minHeight = -1;
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,10 +11,7 @@ import lecteur_pdf.GestionPdf;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -28,24 +25,26 @@ import java.io.IOException;
|
||||
*/
|
||||
public class PdfPanel extends JPanel {
|
||||
|
||||
/* Données */
|
||||
private int currentPage;
|
||||
|
||||
private float scaleSizing;
|
||||
private float scaleZoom;
|
||||
|
||||
private boolean pleineLargeur;
|
||||
private boolean processing;
|
||||
|
||||
/* Chargeur de Pdf */
|
||||
private PdfLoader pdfLoader;
|
||||
|
||||
/* Interface */
|
||||
private final JTextField indexPageInput;
|
||||
private final JLabel maxPageLabel;
|
||||
|
||||
private final JScrollPane scrollPane;
|
||||
private final JViewport viewport;
|
||||
private final JLabel page;
|
||||
|
||||
private boolean processing;
|
||||
|
||||
/**
|
||||
* Crée une nouvelle interface de PDF vide
|
||||
*/
|
||||
public PdfPanel() {
|
||||
super(new BorderLayout());
|
||||
|
||||
@@ -55,17 +54,10 @@ public class PdfPanel extends JPanel {
|
||||
processing = false;
|
||||
pleineLargeur = false;
|
||||
|
||||
/* Controls */
|
||||
/* Controleurs */
|
||||
JPanel controls = new JPanel();
|
||||
/* Contenu de Controls */
|
||||
JButton btnPrecedent = new JButton("Précédent");
|
||||
// indexPageInput = new JSpinner();
|
||||
// JComponent field = ((JSpinner.DefaultEditor) indexPageInput.getEditor());
|
||||
// Dimension prefSize = field.getPreferredSize();
|
||||
// prefSize = new Dimension(50, prefSize.height);
|
||||
// field.setPreferredSize(prefSize);
|
||||
|
||||
indexPageInput = new JTextField(5);
|
||||
indexPageInput = new JTextField(7);
|
||||
indexPageInput.setText("-");
|
||||
maxPageLabel = new JLabel("/ -");
|
||||
JButton btnSuivant = new JButton("Suivant");
|
||||
@@ -90,15 +82,8 @@ public class PdfPanel extends JPanel {
|
||||
add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
/* Actions */
|
||||
btnSuivant.addActionListener(e -> {
|
||||
if (GestionMode.isModeSepare()) nextPage();
|
||||
else GestionPdf.nextPages();
|
||||
});
|
||||
|
||||
btnPrecedent.addActionListener(e -> {
|
||||
if (GestionMode.isModeSepare()) previousPage();
|
||||
else GestionPdf.previousPages();
|
||||
});
|
||||
btnSuivant.addActionListener(this::btnSuivantAction);
|
||||
btnPrecedent.addActionListener(this::btnPrecedentAction);
|
||||
|
||||
/* Saisie uniquement de caractère numérique */
|
||||
indexPageInput.addKeyListener(new KeyAdapter() {
|
||||
@@ -133,6 +118,22 @@ public class PdfPanel extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param evt Ecouteur d'évèvement
|
||||
*/
|
||||
private void btnSuivantAction(ActionEvent evt) {
|
||||
if (GestionMode.isModeSepare()) nextPage();
|
||||
else GestionPdf.nextPages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param evt Ecouteur d'évèvement
|
||||
*/
|
||||
private void btnPrecedentAction(ActionEvent evt) {
|
||||
if (GestionMode.isModeSepare()) previousPage();
|
||||
else GestionPdf.previousPages();
|
||||
}
|
||||
|
||||
public void resize() {
|
||||
if (pdfLoader != null && !processing) {
|
||||
scaleSizing = pleineLargeur
|
||||
@@ -196,7 +197,6 @@ public class PdfPanel extends JPanel {
|
||||
currentPage = 0;
|
||||
|
||||
/* Interface Vide */
|
||||
// indexPageInput.setValue(0);
|
||||
indexPageInput.setText("");
|
||||
maxPageLabel.setText("/ -");
|
||||
|
||||
@@ -253,7 +253,6 @@ public class PdfPanel extends JPanel {
|
||||
try {
|
||||
page.setIcon(new ImageIcon(pdfLoader.renderPage(index, scaleZoom + scaleSizing)));
|
||||
currentPage = index;
|
||||
// indexPageInput.setValue(currentPage +1);
|
||||
indexPageInput.setText(Integer.toString(currentPage + 1));
|
||||
maxPageLabel.setText(String.format("/%d", pdfLoader.getNbPages()));
|
||||
} catch (IOException ignored) {}
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
|
||||
package lecteur_pdf.raccourcisClavier;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
import lecteur_pdf.menuBar.menuItems.MenuItem;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.io.Serializable;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,23 +24,66 @@ import java.util.Map;
|
||||
*/
|
||||
public class RaccourcisClavier extends JFrame {
|
||||
|
||||
public static Map<String, KeyStroke> raccourcis = new HashMap<>();
|
||||
public static Map<String, JMenuItem> listeItem = new HashMap<>();
|
||||
|
||||
public static Map<JMenuItem, String> gestionnaireRaccourcis
|
||||
= new HashMap<>();
|
||||
public final String[][] RACCOURCIS = {
|
||||
{"Ouvrir", "o",},
|
||||
{"Fermer", "f",},
|
||||
{"Quitter", "x",},
|
||||
{"Mode Plein Ecran", "p",},
|
||||
{"Page Prédédente", "m",},
|
||||
{"Page Suivante", "l",},
|
||||
{"Zoom 50%", "&",},
|
||||
{"Zoom 100%", "é",},
|
||||
{"Zoom 150%", "\"",},
|
||||
{"Page Entière", "a",},
|
||||
{"Pleine Largeur", "z",},
|
||||
{"Nouvelle Fenêtre", "n",},
|
||||
// { "Mode Séparé",},
|
||||
// { "Mode Synchronisé",},
|
||||
{"Modifier Touches", "!",}
|
||||
};
|
||||
|
||||
public RaccourcisClavier() {
|
||||
super("Modification des raccourcis claviers");
|
||||
JPanel panel = new JPanel();
|
||||
for (String nomOptions : raccourcis.keySet()) {
|
||||
panel.add(new ligneRaccourci(nomOptions,
|
||||
(char) raccourcis.get(nomOptions)
|
||||
.getKeyCode()));
|
||||
JPanel panel = new JPanel(new GridLayout(RACCOURCIS.length, 1, 10, 5));
|
||||
|
||||
System.out.println(listeItem);
|
||||
|
||||
for (int i = 0; i < listeItem.size(); i++) {
|
||||
RaccourcisElement raccourcisElement = new RaccourcisElement(RACCOURCIS[i][0], listeItem.get(RACCOURCIS[i][0]));
|
||||
|
||||
// Si l'actions n'as pas de raccourcis, mettre celui par défaut
|
||||
// try {
|
||||
// listeItem.get(RACCOURCIS[i][0]).getAccelerator();
|
||||
// } catch (NullPointerException e) {
|
||||
// listeItem.get(RACCOURCIS[i][0]).setAccelerator(KeyStroke.getKeyStroke(RACCOURCIS[i][1].charAt(0), KeyEvent.CTRL_DOWN_MASK));
|
||||
// }
|
||||
|
||||
panel.add(raccourcisElement);
|
||||
}
|
||||
add(panel);
|
||||
|
||||
add(new JScrollPane(panel));
|
||||
|
||||
// JPanel panel = new JPanel();
|
||||
// for (String nomOptions : raccourcis.keySet()) {
|
||||
// panel.add(new ligneRaccourci(nomOptions,
|
||||
// (char) raccourcis.get(nomOptions)
|
||||
// .getKeyCode()));
|
||||
// }
|
||||
// add(panel);
|
||||
pack();
|
||||
setSize(200, 400);
|
||||
setResizable(false);
|
||||
setMinimumSize(new Dimension(400, 200));
|
||||
// setSize(200, 400);
|
||||
// setResizable(false);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void chargerRaccourcisDefaut() {
|
||||
|
||||
}
|
||||
|
||||
private void chargerRaccourcis() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package lecteur_pdf.raccourcisClavier;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
public class RaccourcisElement extends JPanel {
|
||||
|
||||
JLabel nomElement;
|
||||
JButton btnRaccourcis;
|
||||
KeyEvent raccourcis;
|
||||
JMenuItem menuItem;
|
||||
|
||||
public RaccourcisElement(String nom, JMenuItem menuItem) {
|
||||
super(new GridLayout(1, 2));
|
||||
|
||||
nomElement = new JLabel(nom);
|
||||
this.menuItem = menuItem;
|
||||
btnRaccourcis = new JButton();
|
||||
|
||||
add(nomElement);
|
||||
add(btnRaccourcis);
|
||||
|
||||
btnRaccourcis.addActionListener(this::action);
|
||||
|
||||
// this.setVisible(false);
|
||||
}
|
||||
|
||||
public void action(ActionEvent evt) {
|
||||
// TODO ecoute la frappe de clavier et change le raccourcis
|
||||
// KeyListener kl = new KeyListener() {
|
||||
// @Override
|
||||
// public void keyTyped(KeyEvent e) {}
|
||||
//
|
||||
// @Override
|
||||
// public void keyPressed(KeyEvent e) {
|
||||
// setCaractereRaccourcis(e.getKeyChar());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void keyReleased(KeyEvent e) {}
|
||||
// };
|
||||
// addKeyListener(kl);
|
||||
// removeKeyListener(kl);
|
||||
// btnRaccourcis.setText(String.valueOf(caractereRaccourcis));
|
||||
// }
|
||||
//
|
||||
// public void setMenuItem(JMenuItem menuItem) {
|
||||
// this.menuItem = menuItem;
|
||||
// this.setVisible(true);
|
||||
// }
|
||||
//
|
||||
// public void setCaractereRaccourcis(char caractereRaccourcis) {
|
||||
// this.caractereRaccourcis = caractereRaccourcis;
|
||||
// menuItem.setAccelerator(KeyStroke.getKeyStroke(caractereRaccourcis, KeyEvent.CTRL_DOWN_MASK));
|
||||
}
|
||||
}
|
||||
@@ -12,34 +12,34 @@ import java.awt.event.ActionListener;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* TODO class comment
|
||||
*/
|
||||
public class ligneRaccourci extends JPanel implements ActionListener {
|
||||
private JLabel raccourciLabel;
|
||||
private JPanel optionsRaccourcis;
|
||||
private JButton inputButton;
|
||||
|
||||
Scanner entree = new Scanner(System.in);
|
||||
|
||||
public ligneRaccourci(String labelName, char raccourcis) {
|
||||
raccourciLabel.setText(labelName);
|
||||
inputButton.setText(String.valueOf(raccourcis));
|
||||
add(optionsRaccourcis);
|
||||
inputButton.addActionListener(this);
|
||||
}
|
||||
|
||||
public JLabel getRaccourciLabel() {
|
||||
return raccourciLabel;
|
||||
}
|
||||
|
||||
public JButton getInputButton() {
|
||||
return inputButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
inputButton.setText(
|
||||
String.valueOf(entree.next().charAt(0)).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
///**
|
||||
// * TODO class comment
|
||||
// */
|
||||
//public class ligneRaccourci extends JPanel implements ActionListener {
|
||||
// private JLabel raccourciLabel;
|
||||
// private JPanel optionsRaccourcis;
|
||||
// private JButton inputButton;
|
||||
//
|
||||
// Scanner entree = new Scanner(System.in);
|
||||
//
|
||||
// public ligneRaccourci(String labelName, char raccourcis) {
|
||||
// raccourciLabel.setText(labelName);
|
||||
// inputButton.setText(String.valueOf(raccourcis));
|
||||
// add(optionsRaccourcis);
|
||||
// inputButton.addActionListener(this);
|
||||
// }
|
||||
//
|
||||
// public JLabel getRaccourciLabel() {
|
||||
// return raccourciLabel;
|
||||
// }
|
||||
//
|
||||
// public JButton getInputButton() {
|
||||
// return inputButton;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// inputButton.setText(
|
||||
// String.valueOf(entree.next().charAt(0)).toUpperCase(Locale.ROOT));
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user