mirror of
https://github.com/LucasVbr/LecteurPdfDoubleAffichage.git
synced 2026-07-09 20:57:44 +00:00
Ajout commentaires PDF, Page et Fenêtre
Modification recharger/charger => charger uniquement Ajout affichage Vertical/Horizontal Methodes de Tests pour Page et Fenêtre
This commit is contained in:
@@ -23,52 +23,49 @@ import java.io.IOException;
|
||||
* @author Noé VILLENEUVE
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class Fenetre extends JFrame {
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
/** Titre de la fenêtre */
|
||||
private final String TITRE = "Lecteur PDF";
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
/** Le menu de la fenêtre */
|
||||
private Menu menu;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
/** Le fichier courant */
|
||||
private File fichier;
|
||||
|
||||
/** Le document PDF courant */
|
||||
public PDF documentPDF;
|
||||
|
||||
/** Défini la disposition d'affichage des pages du document PDF */
|
||||
private boolean affichageVertical;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* Crée une nouvelle fenêtre contenant un Menu
|
||||
*/
|
||||
public Fenetre() {
|
||||
|
||||
/* Change le style de la fenêtre */
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException
|
||||
| InstantiationException
|
||||
| IllegalAccessException
|
||||
| UnsupportedLookAndFeelException e) {
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Création du menu
|
||||
/* Création du menu */
|
||||
menu = new Menu(this);
|
||||
this.setJMenuBar(menu);
|
||||
|
||||
/* Definis l'affichage Vertical comme affichage par défaut */
|
||||
this.affichageVertical = true;
|
||||
|
||||
/* Initialise l'état par défaut de la fenêtre */
|
||||
setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction utilitaire qui permet de définir l'état par défaut de la fenêtre
|
||||
*/
|
||||
public void setup() {
|
||||
setTitle(TITRE);
|
||||
|
||||
@@ -83,11 +80,42 @@ public class Fenetre extends JFrame {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* Charge le document PDF courant si possible
|
||||
*
|
||||
* @param fichier
|
||||
* @throws IOException Si l'on arrive pas a charger le PDF
|
||||
*/
|
||||
public void chargerPDF() throws IOException {
|
||||
if (haveDocument()) chargerPDF(fichier, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge le document PDF courant avec un zoom spécifique si possible
|
||||
*
|
||||
* @param zoom La taille du zoom sur les pages
|
||||
* @throws IOException Si l'on arrive pas a charger le PDF
|
||||
*/
|
||||
public void chargerPDF(float zoom) throws IOException {
|
||||
if (haveDocument()) chargerPDF(fichier, zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge un document PDF
|
||||
*
|
||||
* @param fichier Le fichier PDF à afficher dans la fenêtre
|
||||
* @throws IOException Si l'on arrive pas a charger le PDF
|
||||
*/
|
||||
public void chargerPDF(File fichier) throws IOException {
|
||||
chargerPDF(fichier, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge un document PDF
|
||||
*
|
||||
* @param fichier Le fichier PDF à afficher dans la fenêtre
|
||||
* @param zoom La taille du zoom sur les pages
|
||||
* @throws IOException Si l'on arrive pas a charger le PDF
|
||||
*/
|
||||
public void chargerPDF(File fichier, float zoom) throws IOException {
|
||||
dechargerPDF();
|
||||
|
||||
this.fichier = fichier;
|
||||
@@ -100,50 +128,10 @@ public class Fenetre extends JFrame {
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(16);
|
||||
this.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
documentPDF = new PDF(fichier, affichageVertical);
|
||||
pdfPanel.add(documentPDF);
|
||||
|
||||
/* Charge les pages */
|
||||
documentPDF.loadPages();
|
||||
|
||||
/* Met à jour la page */
|
||||
this.setTitle(TITRE + " | " + fichier.getName());
|
||||
this.validate();
|
||||
this.pack();
|
||||
this.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void rechargerPDF() throws IOException {
|
||||
rechargerPDF(1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param zoom
|
||||
* @throws IOException
|
||||
*/
|
||||
public void rechargerPDF(float zoom) throws IOException {
|
||||
dechargerPDF();
|
||||
|
||||
/* Crée le panel qui contient le document PDF */
|
||||
JPanel pdfPanel = new JPanel();
|
||||
/* Crée l’élément scrollable */
|
||||
JScrollPane scrollPane = new JScrollPane(pdfPanel);
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(16);
|
||||
this.add(scrollPane);
|
||||
|
||||
documentPDF = new PDF(fichier, affichageVertical);
|
||||
documentPDF.setZoom(zoom);
|
||||
pdfPanel.add(documentPDF);
|
||||
|
||||
/* Charge les pages */
|
||||
documentPDF.loadPages();
|
||||
|
||||
/* Met à jour la page */
|
||||
this.setTitle(TITRE + " | " + fichier.getName());
|
||||
this.validate();
|
||||
@@ -152,7 +140,7 @@ public class Fenetre extends JFrame {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Supprime le PDF de la fenêtre
|
||||
*/
|
||||
public void dechargerPDF() {
|
||||
if (this.getContentPane() != null) {
|
||||
@@ -161,24 +149,22 @@ public class Fenetre extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prédicat qui vérifie si un PDF est affiché dans la fenêtre
|
||||
*
|
||||
* @return true si le prédicat est vérifié, false sinon
|
||||
*/
|
||||
public boolean haveDocument() {
|
||||
return documentPDF != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Définis le mode d'affichage du PDF
|
||||
*
|
||||
* @param affichageVertical true pour un affichage Vertical, false pour
|
||||
* un affichage horizontal
|
||||
*/
|
||||
public void setAffichageVertical(boolean affichageVertical) {
|
||||
this.affichageVertical = affichageVertical;
|
||||
}
|
||||
|
||||
public boolean isAffichageVertical() {
|
||||
return affichageVertical;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO comment main
|
||||
*
|
||||
* @param args non utilisé
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
new Fenetre();
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,48 @@
|
||||
/*
|
||||
* gestionFenetre, 22/11/2021
|
||||
* IUT Rodez 2021, INFO2
|
||||
* pas de copyright, aucun droits
|
||||
*/
|
||||
|
||||
package lecteur_pdf.affichage;
|
||||
|
||||
import lecteur_pdf.document.PDF;
|
||||
import lecteur_pdf.menu.Menu;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* classe de gestion des fenêtres
|
||||
*
|
||||
* @author Léo FRANCH
|
||||
* @author Tristan NOGARET
|
||||
* @author Lucàs VABRE
|
||||
* @author Noé VILLENEUVE
|
||||
* @version 1.0
|
||||
*/
|
||||
public class gestionFenetre {
|
||||
|
||||
|
||||
final int NB_MAX_FENETRE = 2 ;
|
||||
private Fenetre[] fenetresOuvertes;
|
||||
File fichier = null ;
|
||||
|
||||
|
||||
public void ouvrirFenetre(){
|
||||
int placeVide;
|
||||
for (placeVide=0; placeVide<2; placeVide++){
|
||||
if (fenetresOuvertes[placeVide]==null){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(placeVide==2) {
|
||||
//todo erreur trop de fenetres
|
||||
}else {
|
||||
Fenetre fenetre = new Fenetre();
|
||||
fenetresOuvertes[placeVide] = fenetre;
|
||||
}
|
||||
}
|
||||
public void fermerFenetre(JFrame fenetre){
|
||||
for (int i = 0; i<2 ; i++){
|
||||
if (fenetre==fenetresOuvertes[i]){
|
||||
fenetre.dispose();
|
||||
fenetresOuvertes[i]= null ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
///*
|
||||
// * gestionFenetre, 22/11/2021
|
||||
// * IUT Rodez 2021, INFO2
|
||||
// * pas de copyright, aucun droits
|
||||
// */
|
||||
//
|
||||
//package lecteur_pdf.affichage;
|
||||
//
|
||||
//import javax.swing.*;
|
||||
//import java.io.File;
|
||||
//
|
||||
///**
|
||||
// * classe de gestion des fenêtres
|
||||
// *
|
||||
// * @author Léo FRANCH
|
||||
// * @author Tristan NOGARET
|
||||
// * @author Lucàs VABRE
|
||||
// * @author Noé VILLENEUVE
|
||||
// * @version 1.0
|
||||
// */
|
||||
//public class gestionFenetre {
|
||||
//
|
||||
// final int NB_MAX_FENETRE = 2 ;
|
||||
// private Fenetre[] fenetresOuvertes;
|
||||
// File fichier = null ;
|
||||
//
|
||||
//
|
||||
// public void ouvrirFenetre(){
|
||||
// int placeVide;
|
||||
// for (placeVide=0; placeVide<2; placeVide++){
|
||||
// if (fenetresOuvertes[placeVide] == null) break;
|
||||
// }
|
||||
// if(placeVide==2) {
|
||||
// //todo erreur trop de fenetres
|
||||
// }else {
|
||||
// Fenetre fenetre = new Fenetre();
|
||||
// fenetresOuvertes[placeVide] = fenetre;
|
||||
// }
|
||||
// }
|
||||
// public void fermerFenetre(JFrame fenetre){
|
||||
// for (int i = 0; i<2 ; i++){
|
||||
// if (fenetre==fenetresOuvertes[i]){
|
||||
// fenetre.dispose();
|
||||
// fenetresOuvertes[i]= null ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user