// (c) MIT 2003.  All rights reserved.
// $Id: HorizontalWidgetComparator.java,v 1.1 2003/06/03 15:37:14 cadlerun Exp $
// HorizontalWidgetComparator.java -- 
// Author: Aaron Adler <cadlerun@fracas.ai.mit.edu> 
// Copyright:  Copyright (C) 2003 by MIT.  All rights reserved.
// Created: <Wed Apr  9 14:31:28 2003> 

package rec.multi;

import java.util.Comparator;
import java.awt.Rectangle;

import rec.simulate.widgets.WSimObject;

/***
 * This class compares two WSimObjects by their x coordinates
 * of their bounding boxes
 ***/

public class HorizontalWidgetComparator implements Comparator {

  public int compare (Object o1, Object o2) {
    // we will compare the WSimObjects by x coord of the bounding box
    WSimObject wso1 = (WSimObject) o1;
    WSimObject wso2 = (WSimObject) o2;

    Rectangle r1 = wso1.getBounds();
    Rectangle r2 = wso2.getBounds();
    
    Double x1 = new Double (r1.getX());
    Double x2 = new Double (r2.getX());

    return x1.compareTo(x2);
  }
}
