import java.awt.*;
import java.io.*;

/**
 * An application that can be used to paste advertisements
 * on virtual billboards
 *
 * @version 1.0
 */
public class Markit
{
    /**
     * The entry-point of the application
     *
     * @param args  The command line arguments (file, position, style)
     */
    public static void main(String[] args)
    {
       BillboardMarker bbMarker;
       Camera          camera;       
       Color[][]       adImage, fieldImage, markedImage;
       String          name;       
       String[]        ad;
       
       
       // Create the Camera
       camera = new Camera();

       // Create the BillboardMarker
       bbMarker = new BillboardMarker(camera);       

       // Process the command line arguments
       ad       = new String[args.length-1];
       name     = args[0];
       for (int i=1; i<args.length; i++) ad[i-1] = args[i];       
       
       // Load the image
       fieldImage = ImageStorage.loadImage(name);

       // Copy the image
       markedImage = ImageManipulator.copyImage(fieldImage);

       // Load the ads and paste them
       for (int i=0; i<ad.length; i++)
       {
          adImage = ImageStorage.loadImage(ad[i]);

          try
          {
             markedImage   = bbMarker.paste(markedImage, adImage, i);
          }
          catch (SizeMismatchException sme)
          {
             sme.printStackTrace();          
          }
       }
       
       
       // Save the marked image
       try
       {
          ImageStorage.saveImage(markedImage, "marked-"+name);          
       }
       catch (IOException io)
       {
          System.out.println("Couldn't save!");
          
       }
    }
}
