// Carnegie Mellon University
//   Information Networking Institute and
//   School of Computer Science
//
// Master Thesis: A Monitoring Tool for Overlay Network
// By: TungFai Chan and Annie Cheng
//
// File: overlay_monitor.java
// Path: monitor/
// Description: The main class for the monitoring tool


import userInterfaces.*;

import java.awt.*;
import javax.swing.UIManager;


public class overlay_monitor {
    boolean packFrame = false;

    //Construct the application
    public overlay_monitor() {

        System.out.print("Loading Swing Components ...");
	MainScreen frame = new MainScreen();
	//Validate frames that have preset sizes
	//Pack frames that have useful preferred size info, e.g. from their layout
        System.out.print("...");
	if (packFrame) {
	    frame.pack();
	}
	else {
	    frame.validate();
	}
        System.out.println("... Done");

	//Center the window
        System.out.print("Setting Frame Coordination ...");
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension frameSize = frame.getSize();
	if (frameSize.height > screenSize.height) {
	    frameSize.height = screenSize.height;
	}
	if (frameSize.width > screenSize.width) {
	    frameSize.width = screenSize.width;
	}
	frame.setLocation((screenSize.width - frameSize.width) / 2,
                          (screenSize.height - frameSize.height) / 2);
        System.out.println(".... Done");

        System.out.print("Loading Visualization ...");
	frame.setVisible(true);
        System.out.println("......... Complete");
        System.out.println();
        System.out.println();
        System.out.println();

    }

    //Main method
    public static void main(String[] args) {
        System.out.println();
        System.out.println("Overlay Network Monitor v2.0       Please wait for loading...");
        System.out.println();
        System.out.print("Loading Look-And-Feel ...");

	try {
	    UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            System.out.println("......... " +
                               UIManager.getCrossPlatformLookAndFeelClassName());
	}
	catch(Exception e) {
	    e.printStackTrace();
	}
	new overlay_monitor();
    }
}
