package tmcsim.client;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

/**
 * The CADClientView class is the view component to the CAD Client application.
 *
 * @author jdalbey
 */
@SuppressWarnings("serial")
public class ClockView extends JFrame
{
    /**
     * Error Logger.
     */
    private static Logger cadLogger = Logger.getLogger("tmcsim.client");
    private JPanel mainPane;
    private JLabel currentTime;
    private final static Dimension SCREEN_SIZE = new Dimension(1100, 255);

    /**
     * Constructor. Build panes, add key listeners, and set up observer
     * relationship between the footer and main panes. TODO: Consider having
     * screen size and font size in properties file.
     */
    public ClockView()
    {
        super("Simulation Clock");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        currentTime = new JLabel("00:00:00");
        currentTime.setAlignmentX(Box.CENTER_ALIGNMENT);
        currentTime.setFont(new Font("Geneva", Font.BOLD, 200));
        mainPane = new JPanel();
        setSize(SCREEN_SIZE);
        setMaximumSize(SCREEN_SIZE);
        setMinimumSize(SCREEN_SIZE);
        mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
        mainPane.setBorder(BorderFactory.createLineBorder(Color.black));
        mainPane.setBackground(new Color(230, 230, 230));  // #E6E6E6
        mainPane.add(currentTime);
        add(mainPane);
        pack();
    }

    public void updateTime(String msg)
    {
        currentTime.setText(msg);
    }
}
