Skip to content
Snippets Groups Projects
Commit 58dbc243 authored by CHEVALIER Noemy's avatar CHEVALIER Noemy
Browse files

Mise à jour et ajout des commentaires

parent 9d9cced3
No related branches found
No related tags found
No related merge requests found
...@@ -4,33 +4,45 @@ import javax.swing.*; ...@@ -4,33 +4,45 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
/**Graphical view for planner of student */
public class ShukanStudent extends JPanel{ public class ShukanStudent extends JPanel{
/**Height of object */
public static final long serialVersionUID = 2L;
private int height; private int height;
/** Font metrics features */
private FontMetrics fontMetrics; private FontMetrics fontMetrics;
/** Height of the font characters */
private int fontHeight = 10; private int fontHeight = 10;
/** Background color */
private Color BACK_COLOR = Color.WHITE; private Color BACK_COLOR = Color.WHITE;
/** Standard week column width */
private final static int STD_WEEK_WIDTH = 30; private final static int STD_WEEK_WIDTH = 30;
/** Standard activity symbol width */
private final static int STD_ACTIV_WIDTH = 6; private final static int STD_ACTIV_WIDTH = 6;
/** Standard number of modules */
private final static int STD_MODULES_NUMBER = 14; private final static int STD_MODULES_NUMBER = 14;
/** Standard number of weeks */
private final static int STD_WEEKS_NUMBER = 20; private final static int STD_WEEKS_NUMBER = 20;
/** Standard height of a text line */
private final int STD_TEXT_HEIGHT = 13; private final int STD_TEXT_HEIGHT = 13;
/** Standard application width */
private final static int STD_APPLI_WIDTH = STD_WEEK_WIDTH * (STD_WEEKS_NUMBER + 2);
/** Standard application height */
private final int STD_APPLI_HEIGHT = STD_TEXT_HEIGHT * 3 * (STD_MODULES_NUMBER + 1);
private final int TEXT_MAX_HEIGHT = 15; /** Number of modules to display */
private final int TEXT_MIN_HEIGHT = 10;
private int nbModules = STD_MODULES_NUMBER; private int nbModules = STD_MODULES_NUMBER;
/** Height of a text line */
private int textHeight = STD_TEXT_HEIGHT; private int textHeight = STD_TEXT_HEIGHT;
private final static int STD_APPLI_WIDTH = STD_WEEK_WIDTH * (STD_WEEKS_NUMBER + 2); /** Application actual width */
private int STD_APPLI_HEIGHT = STD_TEXT_HEIGHT * 3 * (STD_MODULES_NUMBER + 1);
private int appliWidth = STD_APPLI_WIDTH; private int appliWidth = STD_APPLI_WIDTH;
/** Application actual height */
private int appliHeight = STD_APPLI_HEIGHT; private int appliHeight = STD_APPLI_HEIGHT;
/** Number of weeks to display */
private int nbWeeks = STD_WEEKS_NUMBER; private int nbWeeks = STD_WEEKS_NUMBER;
/** Standard activity symbol actual width */
private int activWidth = STD_ACTIV_WIDTH; private int activWidth = STD_ACTIV_WIDTH;
/** Week column actual width */
private int weekWidth = STD_WEEK_WIDTH; private int weekWidth = STD_WEEK_WIDTH;
/** Frame borders color */ /** Frame borders color */
...@@ -39,16 +51,15 @@ public class ShukanStudent extends JPanel{ ...@@ -39,16 +51,15 @@ public class ShukanStudent extends JPanel{
private final Color REACTIVE_COLOR = new Color (0.7f, 0.9f, 0.5f); private final Color REACTIVE_COLOR = new Color (0.7f, 0.9f, 0.5f);
/** Grid color */ /** Grid color */
private final Color GRID_COLOR = Color.BLACK; private final Color GRID_COLOR = Color.BLACK;
/** Free module weeks color */ /** Text color */
private final Color HOLLY_COLOR = new Color (1.f, 0.8f, 0.7f); private Color TEXT_COLOR = Color.BLACK;
/** Inactive parts of weeks color */
private final Color INACTIVE_COLOR = new Color (0.5f, 0.5f, 0.5f);
/**The vertical line with his height */
private int verticalLineHeight = 60; private int verticalLineHeight = 60;
private boolean isButtonClicked = false; private boolean isButtonClicked = false;
/** File manager */ /** File manager */
private ShukanIO myIO = null; private ShukanIO myIO = null;
/** Displayed data */ /** Displayed data */
private ShukanData data = null; private ShukanData data = null;
...@@ -59,10 +70,10 @@ public class ShukanStudent extends JPanel{ ...@@ -59,10 +70,10 @@ public class ShukanStudent extends JPanel{
this.myIO = myIO; this.myIO = myIO;
this.height = height; this.height = height;
setBackground(Color.WHITE);
setPreferredSize(new Dimension(STD_APPLI_WIDTH, height)); setPreferredSize(new Dimension(STD_APPLI_WIDTH, height));
} }
/** Draws Shukan view.*/
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
...@@ -82,6 +93,7 @@ public class ShukanStudent extends JPanel{ ...@@ -82,6 +93,7 @@ public class ShukanStudent extends JPanel{
displayCalendar(g2); displayCalendar(g2);
} }
/** Updates the application size.*/
private void adaptSize(int width, int height) { private void adaptSize(int width, int height) {
if (data != null) if (data != null)
{ {
...@@ -102,6 +114,7 @@ public class ShukanStudent extends JPanel{ ...@@ -102,6 +114,7 @@ public class ShukanStudent extends JPanel{
} }
} }
/** Displays the calendar grid background.*/
private void displayCalendar (Graphics2D g2) { private void displayCalendar (Graphics2D g2) {
if (isButtonClicked == false){ if (isButtonClicked == false){
g2.setColor(GRID_COLOR); g2.setColor(GRID_COLOR);
...@@ -152,6 +165,7 @@ public class ShukanStudent extends JPanel{ ...@@ -152,6 +165,7 @@ public class ShukanStudent extends JPanel{
} }
/**Create a new height */
public void changeStudentHeight(int newHeight) { public void changeStudentHeight(int newHeight) {
setPreferredSize(new Dimension(getWidth(), newHeight)); setPreferredSize(new Dimension(getWidth(), newHeight));
revalidate(); revalidate();
...@@ -167,7 +181,8 @@ public class ShukanStudent extends JPanel{ ...@@ -167,7 +181,8 @@ public class ShukanStudent extends JPanel{
/** Draws a centered text in the given area.*/ /** Draws a centered text in the given area.*/
private void drawText (Graphics2D g2, float posx, float posy, private void drawText (Graphics2D g2, float posx, float posy,
float width, float height, String text) float width, float height, String text)
{ {
g2.setColor(TEXT_COLOR);
g2.drawString (text, (int) (posx + (width - fontMetrics.stringWidth (text)) / 2), g2.drawString (text, (int) (posx + (width - fontMetrics.stringWidth (text)) / 2),
appliHeight - (int) (posy + (height - fontHeight) / 2)); appliHeight - (int) (posy + (height - fontHeight) / 2));
} }
...@@ -196,4 +211,16 @@ public class ShukanStudent extends JPanel{ ...@@ -196,4 +211,16 @@ public class ShukanStudent extends JPanel{
{ {
g2.drawLine (x, appliHeight - y, x + l, appliHeight - y); g2.drawLine (x, appliHeight - y, x + l, appliHeight - y);
} }
/**Change the background color. */
public void setBackgroundColor(Color c){
BACK_COLOR = c;
repaint();
}
/**Change the text color. */
public void setForeground(Color c){
TEXT_COLOR = c;
repaint();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment