mirror of
https://github.com/LucasVbr/LecteurPdfDoubleAffichage.git
synced 2026-05-13 17:11:51 +00:00
Add Pdf.java et Page.java
A compléter + Tests unitaires avec JUnit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Page, 17/11/2021
|
||||
* IUT Rodez 2021, INFO2
|
||||
* pas de copyright, aucun droits
|
||||
*/
|
||||
|
||||
package lecteur_pdf.document;
|
||||
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
*
|
||||
* @author Lucas
|
||||
*/
|
||||
public class Page {
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
*/
|
||||
private int index;
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
*/
|
||||
private JLabel image;
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
*/
|
||||
private int hauteur;
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
*/
|
||||
private int largeur;
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
* @param document
|
||||
* @param index
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page(PDDocument document, int index) throws IllegalArgumentException {
|
||||
if (!isValid(document, index)) throw new IllegalArgumentException();
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
* @param document
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
private boolean isValid(PDDocument document, int index) {
|
||||
return document != null
|
||||
&& 0 <= index && index < document.getNumberOfPages();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
* @param positionX
|
||||
* @param positionY
|
||||
*/
|
||||
public void setPosition(int positionX, int positionY) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO A compléter
|
||||
* @return
|
||||
*/
|
||||
public JLabel getImage() {
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Pdf, 17/11/2021
|
||||
* IUT Rodez 2021, INFO2
|
||||
* pas de copyright, aucun droits
|
||||
*/
|
||||
|
||||
package lecteur_pdf.document;
|
||||
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Définis virtuellement un fichier PDF
|
||||
*
|
||||
* @author Lucas
|
||||
*/
|
||||
public class Pdf {
|
||||
|
||||
/** Espacement entre chaque page */
|
||||
public static final int OFFSET_PAGES = 10; // px
|
||||
|
||||
/** Document PDF chargé */
|
||||
private PDDocument document;
|
||||
|
||||
/** Le nombre de pages du document PDF */
|
||||
private int nbPages;
|
||||
|
||||
/** Les pages du PDF sous forme d’images */
|
||||
private ArrayList<Page> page;
|
||||
|
||||
/**
|
||||
* Crée un document PDF qui est capable d’être affiché dans une fenêtre
|
||||
* @param fichier Le fichier PDF que l’on veut ouvrir
|
||||
* @throws IllegalArgumentException si le fichier n’existe pas
|
||||
*/
|
||||
public Pdf(File fichier) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public int getNbPages() {
|
||||
return nbPages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return un panel scrollable contenant toutes les pages du PDF
|
||||
*/
|
||||
public JScrollPane getRenderView() {
|
||||
// TODO
|
||||
return null; // Bouchon
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package lecteur_pdf.document;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class PageTest {
|
||||
|
||||
@Test
|
||||
void setPosition() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getImage() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package lecteur_pdf.document;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class PdfTest {
|
||||
|
||||
@Test
|
||||
void getNbPages() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRenderView() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user