src/main/java/org/fit/layout/model/Rectangular.java
public Rectangular vsplit(Rectangular other)
    {
        if (this.intersects(other))
        {
            Rectangular a = new Rectangular(this);
            Rectangular b = new Rectangular(this);
            if (a.y2 > other.y1 - 1) a.y2 = other.y1 - 1;
            if (b.y1 < other.y2 + 1) b.y1 = other.y2 + 1;
            if (a.isEmpty())
            {
                y1 = b.y1;
                return null;
            }
            else
            {
                y2 = a.y2;
                if (b.isEmpty())
                    return null;
                else
                    return b;
            }
        }
        else
            return null;
    }
public Rectangular vsplit(Rectangular other)
    {
        if (this.intersects(other))
        {
            Rectangular a = new Rectangular(this);
            Rectangular b = new Rectangular(this);
            if (a.y2 > other.y1 - 1) a.y2 = other.y1 - 1;
            if (b.y1 < other.y2 + 1) b.y1 = other.y2 + 1;
            if (a.isEmpty())
            {
                y1 = b.y1;
                return null;
            }
            else
            {
                y2 = a.y2;
                if (b.isEmpty())
                    return null;
                else
                    return b;
            }
        }
        else
            return null;
    }
public Rectangular vsplit ( Rectangular other ) { if ( this . intersects ( other ) ) { Rectangular a = new Rectangular ( this ) ; Rectangular b = new Rectangular ( this ) ; if ( a . y2 > other . y1 - 1 ) a . y2 = other . y1 - 1 ; if ( b . y1 < other . y2 + 1 ) b . y1 = other . y2 + 1 ; if ( a . isEmpty ( ) ) { y1 = b . y1 ; return null ; } else { y2 = a . y2 ; 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.
If this rectangle intersets with the other one splits this rectangle horizontally so that it does not intersect with the other one anymore .