if (port == "80") port = "";
if ("80".equals(port) || "-1".equals(port)) port = "";
	public void init()	{		try {		//-- the image size ---		rawImageSize.width = getIntParameter("IMAGE_W");		rawImageSize.height = getIntParameter("IMAGE_H");		if (rawImageSize.width == 0 || rawImageSize.height == 0)			throw new Exception("Invalid Image Size Parameters");		//-- cropLayout starts out like raw image layout ---		if (rawImageSize.width > rawImageSize.height) cropLayout = LANDSCAPE;		else cropLayout = PORTRAIT; 		//-- crop rectangle. if provided (otherwise, defaults assigned later) ---		cropRect.x = getIntParameter("CROP_X");		cropRect.y = getIntParameter("CROP_Y");		cropRect.width = getIntParameter("CROP_W");		cropRect.height = getIntParameter("CROP_H");		cropToSize = getIntParameter("CROP_TO_SIZE");		//-- the image (prepend full URL) --- 		String imageUrlString = getParameter("IMAGE");		if (imageUrlString == null)			throw new Exception("No Image URL parameter provided.");		String host = this.getDocumentBase().getHost();		String port = "" + this.getDocumentBase().getPort();		if (port == "80") port = "";		else port = ":" + port;		String protocol = this.getDocumentBase().getProtocol();		imageUrlString = protocol + "://" + host + port + imageUrlString;		System.out.println("ImageUrl [" + imageUrlString + "]");		try {			image = getImage(new URL(imageUrlString));		} catch (java.net.MalformedURLException e) {			throw new Exception("Malformed Image URL ["+imageUrlString+"]");		}		//-- start loading the image resource. when it's done, updateImage() 		//-- will notice and finish initialization.		this.prepareImage(image, this);				//-- the cropAspectRatio choices --		aspectRatios = new Vector(); 		aspectRatios.addElement(new AspectRatio("As Image", rawImageSize.width, rawImageSize.height));		aspectRatios.addElement(new AspectRatio("Letterbox", 1, 3));		aspectRatios.addElement(new AspectRatio("HDTV", 9, 16));		aspectRatios.addElement(new AspectRatio("Photo", 3, 5));		aspectRatios.addElement(new AspectRatio("Photo", 4, 6));		aspectRatios.addElement(new AspectRatio("Photo", 5, 7));		aspectRatios.addElement(new AspectRatio("Screen", 3, 4));		aspectRatios.addElement(new AspectRatio("Photo", 8, 10));		aspectRatios.addElement(new AspectRatio("Square", 1, 1));		//aspectRatios.addElement(new AspectRatio(1, 1, "Custom.."));		//-- finally set up the UI ---		setBackground(Color.white);		setLayout(null);		Panel outerBox = new Panel(new BorderLayout());		Panel widgetBox = new Panel(new FlowLayout(FlowLayout.LEFT, 1, 2));		outerBox.setSize(widgetRect.width, widgetRect.height);		outerBox.setLocation(widgetRect.x, widgetRect.y);		widgetBox.setBackground(Color.white);		choice_Ratio = new Choice();		choice_Layout = new Choice();		choice_Layout.add("Landscape");		choice_Layout.add("Portrait");				Panel buttonBox = new Panel(new FlowLayout(FlowLayout.RIGHT, 3, 2));		Button button_Cancel = new Button("Cancel");		button_Cancel.setSize(100, 25);		Button button_OK = new Button("OK");		button_OK.setSize(100, 25);	   		widgetBox.add(new Label("Aspect Ratio:"));		widgetBox.add(choice_Ratio);		widgetBox.add(choice_Layout);		buttonBox.add(button_Cancel);		buttonBox.add(button_OK);		outerBox.add(widgetBox, BorderLayout.WEST);		outerBox.add(buttonBox, BorderLayout.EAST);		add(outerBox);		updateWidgets(true);				//-- add the listeners last ---		WidgetItemListener itemListener = new WidgetItemListener();		choice_Ratio.addItemListener(itemListener);		choice_Layout.addItemListener(itemListener);		MyMouseListener mouseListener = new MyMouseListener();		addMouseListener(mouseListener);		addMouseMotionListener(mouseListener);		MyButtonListener buttonListener = new MyButtonListener();		button_Cancel.addActionListener(buttonListener);		button_OK.addActionListener(buttonListener);		//-- catchall for anything bad in init ---		} catch (Exception e) {			errorOccurred = true;			errorMessage = e.toString();		}			}