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.*;
import java.awt.*;
import java.awt.event.*;
/**Graphical view for planner of student */
public class ShukanStudent extends JPanel{
public static final long serialVersionUID = 2L;
/**Height of object */
private int height;
/** Font metrics features */
private FontMetrics fontMetrics;
/** Height of the font characters */
private int fontHeight = 10;
/** Background color */
private Color BACK_COLOR = Color.WHITE;
/** Standard week column width */
private final static int STD_WEEK_WIDTH = 30;
/** Standard activity symbol width */
private final static int STD_ACTIV_WIDTH = 6;
/** Standard number of modules */
private final static int STD_MODULES_NUMBER = 14;
/** Standard number of weeks */
private final static int STD_WEEKS_NUMBER = 20;
/** Standard height of a text line */
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;
private final int TEXT_MIN_HEIGHT = 10;
/** Number of modules to display */
private int nbModules = STD_MODULES_NUMBER;
/** Height of a text line */
private int textHeight = STD_TEXT_HEIGHT;
private final static int STD_APPLI_WIDTH = STD_WEEK_WIDTH * (STD_WEEKS_NUMBER + 2);
private int STD_APPLI_HEIGHT = STD_TEXT_HEIGHT * 3 * (STD_MODULES_NUMBER + 1);
/** Application actual width */
private int appliWidth = STD_APPLI_WIDTH;
/** Application actual height */
private int appliHeight = STD_APPLI_HEIGHT;
/** Number of weeks to display */
private int nbWeeks = STD_WEEKS_NUMBER;
/** Standard activity symbol actual width */
private int activWidth = STD_ACTIV_WIDTH;
/** Week column actual width */
private int weekWidth = STD_WEEK_WIDTH;
/** Frame borders color */
......@@ -39,16 +51,15 @@ public class ShukanStudent extends JPanel{
private final Color REACTIVE_COLOR = new Color (0.7f, 0.9f, 0.5f);
/** 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);
/** Inactive parts of weeks color */
private final Color INACTIVE_COLOR = new Color (0.5f, 0.5f, 0.5f);
/** Text color */
private Color TEXT_COLOR = Color.BLACK;
/**The vertical line with his height */
private int verticalLineHeight = 60;
private boolean isButtonClicked = false;
/** File manager */
/** File manager */
private ShukanIO myIO = null;
/** Displayed data */
private ShukanData data = null;
......@@ -59,10 +70,10 @@ public class ShukanStudent extends JPanel{
this.myIO = myIO;
this.height = height;
setBackground(Color.WHITE);
setPreferredSize(new Dimension(STD_APPLI_WIDTH, height));
}
/** Draws Shukan view.*/
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
......@@ -82,6 +93,7 @@ public class ShukanStudent extends JPanel{
displayCalendar(g2);
}
/** Updates the application size.*/
private void adaptSize(int width, int height) {
if (data != null)
{
......@@ -102,6 +114,7 @@ public class ShukanStudent extends JPanel{
}
}
/** Displays the calendar grid background.*/
private void displayCalendar (Graphics2D g2) {
if (isButtonClicked == false){
g2.setColor(GRID_COLOR);
......@@ -152,6 +165,7 @@ public class ShukanStudent extends JPanel{
}
/**Create a new height */
public void changeStudentHeight(int newHeight) {
setPreferredSize(new Dimension(getWidth(), newHeight));
revalidate();
......@@ -167,7 +181,8 @@ public class ShukanStudent extends JPanel{
/** Draws a centered text in the given area.*/
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));
}
......@@ -196,4 +211,16 @@ public class ShukanStudent extends JPanel{
{
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.
Please register or to comment