From 82d4491332a0cbee656294fd8c8a402e535db150 Mon Sep 17 00:00:00 2001 From: CHEVALIER Noemy <noemy.chevalier7@etu.univ-lorraine.fr> Date: Mon, 29 May 2023 17:33:43 +0000 Subject: [PATCH] Ajout fonctions convertions couleurs --- shukan/ShukanView.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/shukan/ShukanView.java b/shukan/ShukanView.java index 7ab1bf5..65e901e 100644 --- a/shukan/ShukanView.java +++ b/shukan/ShukanView.java @@ -70,13 +70,14 @@ public class ShukanView extends JPanel /** Background color */ private Color BACK_COLOR = new ColorUIResource(226, 226, 226); + /** Background color */ private Color BACK_COLOR2 = Color.LIGHT_GRAY; /** Grid color */ private final Color GRID_COLOR = Color.BLACK; /** Free module weeks color */ - private final Color HOLLY_COLOR = new Color (1.f, 0.8f, 0.7f); + private Color HOLLY_COLOR = new Color (1.f, 0.8f, 0.7f); /** Inactive parts of weeks color */ - private final Color INACTIVE_COLOR = new Color (0.5f, 0.5f, 0.5f); + private Color INACTIVE_COLOR = new Color (0.5f, 0.5f, 0.5f); /** Frame borders color */ private final Color ACTIVE_COLOR = new Color (0.6f, 0.6f, 0.9f); /** Selected activity color */ @@ -84,7 +85,7 @@ public class ShukanView extends JPanel /** Frame borders color */ private final Color FRAME_COLOR = Color.BLACK; /** Text color */ - private final Color TEXT_COLOR = Color.BLACK; + private Color TEXT_COLOR = Color.BLACK; /** Selected text color */ private final Color SELECTED_TEXT_COLOR = Color.WHITE; /** Unselectable text color */ @@ -377,6 +378,7 @@ public class ShukanView extends JPanel private void drawText (Graphics2D g2, float posx, float posy, float width, float height, String text) { + g2.setColor(TEXT_COLOR); g2.drawString (text, (int) (posx + (width - fontMetrics.stringWidth (text)) / 2), appliHeight - (int) (posy + (height - fontHeight) / 2)); @@ -446,9 +448,18 @@ public class ShukanView extends JPanel } } - /** change the background color */ - public void setBackgroundColor(Color c){ + /** Change the background color */ + public void setBackgroundColor(Color c, Color c1){ BACK_COLOR = c; + BACK_COLOR2 = c1; + repaint(); + } + + /** Change the text and the hollydays colors*/ + public void setForeground(Color c, Color c1, Color c2){ + TEXT_COLOR = c; + HOLLY_COLOR = c1; + INACTIVE_COLOR = c2; repaint(); } -- GitLab