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.
 *
 */
@SuppressWarnings("serial")
public class CADClockView extends JFrame
{
    /**
     * Error Logger.
     */
    private static Logger cadLogger = Logger.getLogger("tmcsim.client");
    private JPanel mainPane;
    private JLabel currentTime;

    /**
     * Constructor. Build panes, add key listeners, and set up observer
     * relationship between the footer and main panes.
     *
     * @param position The CAD position for this client terminal.
     */
    public CADClockView()
    {
        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(new Dimension(1100, 255));
        setMaximumSize(new Dimension(1100, 255));
        setMinimumSize(new Dimension(1100, 255));
        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);
    }
}
