import java.util.*;

public class ShowData {
    static String version = "28 September 2004";

    public static void main(String args[]) {
	versionInfo();

	if(args.length == 0) usage();

	try {	    
	    ImageTool.image = new ReducedData(args[args.length-1]);
	    
	    for(int i=0; i<args.length-1; i++) option(args[i]);
	    
	    ImageTool.image.init();
	    ImageTool.image.displayUnit = ImageTool.image.janskyPerBeam;
	    ImageTool.image.show();
	}
	catch(Exception e) { e.printStackTrace(); }
    }

    public static boolean option(String optionString) {
	StringTokenizer tokens = new StringTokenizer(optionString, "=,");

	String key = tokens.nextToken();

	if(key.equalsIgnoreCase("-mask")) {
	    ImageTool.image.readMask(tokens.nextToken());
	}
	else if(key.equalsIgnoreCase("-help")) usage();
	else if(ImageTool.option(optionString)) return true;
	else return false;

	return true;
    
    }

    public static void versionInfo() {
	System.out.println("show -- Display & Manipulation Utility for SHARC2 maps.");
	System.out.println("        Author: Attila Kovacs <attila@submm.caltech.edu>");
	System.out.println("        Version: " + version);
	System.out.println();
    }

    public static void usage() {
	System.out.println("usage: show [options] <filename>");
	System.out.println();
	System.out.println("options to show:");
	System.out.println();
	System.out.println("    -help      Provides this help screen.");
	System.out.println("    -mask=     Specify a region mask file.");
	System.out.println();
	System.out.println("options to show via imagetool:");
	System.out.println();

	ImageTool.optionsSummary();
	
	System.out.println();
	System.exit(0);
    }
}
		
	
