package org.lucci.madhoc.simulation.projection;

import org.lucci.madhoc.network.Station;

/*
 * Created on May 3, 2005
 */

/**
 * @author luc.hogie
 */
public class SquareWindowProjection extends WindowProjection
{
    /* (non-Javadoc)
     * @see org.lucci.madhoc.simulation.DeviceRelevancy#deviceIsRelevant(org.lucci.madhoc.network.hardware.Device)
     */
    public boolean acceptComputer(Station computer)
    {
        Station device = computer;
        double edgeLenght = device.getNetwork().getNetworkEnvironment().getGrid().getEdgeLenght();
        double x1 = edgeLenght / 2 - edgeLenght * getRadiusRatio() / 2;
        double y1 = x1;
        double x2 = edgeLenght / 2 + edgeLenght * getRadiusRatio() / 2;
        double y2 = x2;

        return x1 <= device.getLocation().getX() && device.getLocation().getX() <= x2
                && y1 <= device.getLocation().getY() && device.getLocation().getY() <= y2;
    }

    /* (non-Javadoc)
     * @see org.lucci.madhoc.simulation.projection.Projection#getName()
     */
    public String getName()
    {
        return "Square window";
    }
}