src/main/java/org/fit/layout/model/Rectangular.java
public Rectangular hsplit(Rectangular other)
    {
        if (this.intersects(other))
        {
            Rectangular a = new Rectangular(this);
            Rectangular b = new Rectangular(this);
            if (a.x2 > other.x1 - 1) a.x2 = other.x1 - 1;
            if (b.x1 < other.x2 + 1) b.x1 = other.x2 + 1;
            if (a.isEmpty())
            {
                x1 = b.x1;
                return null;
            }
            else
            {
                x2 = a.x2;
                if (b.isEmpty())
                    return null;
                else
                    return b;
            }
        }
        else
            return null;
    }
public Rectangular hsplit(Rectangular other)
    {
        if (this.intersects(other))
        {
            Rectangular a = new Rectangular(this);
            Rectangular b = new Rectangular(this);
            if (a.x2 > other.x1 - 1) a.x2 = other.x1 - 1;
            if (b.x1 < other.x2 + 1) b.x1 = other.x2 + 1;
            if (a.isEmpty())
            {
                x1 = b.x1;
                return null;
            }
            else
            {
                x2 = a.x2;
                if (b.isEmpty())
                    return null;
                else
                    return b;
            }
        }
        else
            return null;
    }
If this rectangle intersets with the other one, splits this rectangle horizontally so that it does not intersect with the other one anymore.
@param other the rectangle used to split this one
@return if this rectangle had to be split in two parts, the second one is returned. Otherwise, null is returned.