Skip to content

Commit

Permalink
more constants, cleaning, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Mariotti committed Feb 25, 2025
1 parent 117e0a3 commit 80ed91d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MagnetoConstants {
public static final Double CONTENT_FONT_SIZE = 36.0;

// Constantes pour les images
public static final int IMAGE_CONTENT_HEIGHT = 250;
public static final int MAIN_IMAGE_CONTENT_HEIGHT = 400;
public static final int IMAGE_CONTENT_HEIGHT = 480;

}
10 changes: 5 additions & 5 deletions backend/src/main/java/fr/cgi/magneto/helper/SlideHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static XSLFTextBox createContent(XSLFSlide slide) {
return contentBox;
}

public static XSLFPictureShape createImage(XSLFSlide slide, byte[] pictureData, String extension, int contentMarginTop) {
public static XSLFPictureShape createImage(XSLFSlide slide, byte[] pictureData, String extension, int contentMarginTop, int imageContentHeight) {
XMLSlideShow ppt = slide.getSlideShow();

XSLFPictureData pic = ppt.addPicture(pictureData, getPictureTypeFromExtension(extension));
Expand All @@ -69,16 +69,16 @@ public static XSLFPictureShape createImage(XSLFSlide slide, byte[] pictureData,
double imgRatio = (double) imgSize.width / imgSize.height;

int newWidth, newHeight;
if (imgRatio > (double) MagnetoConstants.WIDTH / MagnetoConstants.IMAGE_CONTENT_HEIGHT) {
if (imgRatio > (double) MagnetoConstants.WIDTH / imageContentHeight) {
newWidth = MagnetoConstants.WIDTH;
newHeight = (int) (MagnetoConstants.WIDTH / imgRatio);
} else {
newHeight = MagnetoConstants.IMAGE_CONTENT_HEIGHT;
newWidth = (int) (MagnetoConstants.IMAGE_CONTENT_HEIGHT * imgRatio);
newHeight = imageContentHeight;
newWidth = (int) (imageContentHeight * imgRatio);
}

int x = MagnetoConstants.MARGIN_LEFT + (MagnetoConstants.WIDTH - newWidth) / 2;
int y = contentMarginTop + (MagnetoConstants.IMAGE_CONTENT_HEIGHT - newHeight) / 2;
int y = contentMarginTop + (imageContentHeight - newHeight) / 2;

XSLFPictureShape shape = slide.createPicture(pic);
shape.setAnchor(new Rectangle(x, y, newWidth, newHeight));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public Object createApacheSlide() {
XSLFSlide slide = ppt.createSlide();

SlideHelper.createTitle(slide, title, MagnetoConstants.TITLE_HEIGHT, MagnetoConstants.TITLE_FONT_SIZE, TextParagraph.TextAlign.LEFT);
SlideHelper.createImage(slide, resourceData, fileExtension, MagnetoConstants.CONTENT_MARGIN_TOP);
SlideHelper.createImage(slide, resourceData, fileExtension, MagnetoConstants.CONTENT_MARGIN_TOP, MagnetoConstants.IMAGE_CONTENT_HEIGHT);
SlideHelper.createLegend(slide, caption);

return slide;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private XSLFSlide createTitleSlide(Board board, List<Map<String, Object>> docume
Buffer documentBuffer = (Buffer) documentData.get("buffer");
String fileExtension = (String) documentData.get("extension");
if (documentBuffer != null) {
SlideHelper.createImage(slide, documentBuffer.getBytes(), fileExtension, MagnetoConstants.MAIN_CONTENT_MARGIN_TOP);
SlideHelper.createImage(slide, documentBuffer.getBytes(), fileExtension, MagnetoConstants.MAIN_CONTENT_MARGIN_TOP, MagnetoConstants.MAIN_IMAGE_CONTENT_HEIGHT);
}
}
return slide;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"magneto.dropzone.overlay.action": "J'ai compris",
"magneto.shared.push.notif.body": "a partagé avec vous un nouveau tableau",
"magneto.slideshow.created.by": "Créé par ",
"magneto.slideshow.updated.the": "mis à jour le",
"magneto.slideshow.updated.the": "mis à jour le ",
"magneto.notify.board.push.notif.body": "vous notifie de changements sur un tableau",
"magneto.loading": "Chargement",
"magneto.zoom": "Zoom",
Expand Down

0 comments on commit 80ed91d

Please sign in to comment.