indexing
	description: "Rectangular areas."
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	EV_RECTANGLE

create 

	make (a_x, a_y, a_width, a_height: INTEGER)
			-- Initialize with a_x, a_y, a_width, a_height.
			-- Was declared in EV_RECTANGLE as synonym of set.
		require
			a_width_positive: a_width >= 0
			a_height_positive: a_height >= 0

	set (a_x, a_y, a_width, a_height: INTEGER)
			-- Initialize with a_x, a_y, a_width, a_height.
			-- Was declared in EV_RECTANGLE as synonym of make.
		require
			a_width_positive: a_width >= 0
			a_height_positive: a_height >= 0

feature -- Access

	bottom: INTEGER
			-- Vertical position of bottom.

	height: INTEGER
			-- Height of Current.

	left: INTEGER
			-- Horizontal position of left side

	right: INTEGER
			--  Horizontal position of right side.

	top: INTEGER
			-- Vertical position of top.

	width: INTEGER
			-- Width of Current.

	x: INTEGER
			-- Horizontal position.

	y: INTEGER
			-- Vertical position.
	
feature -- Status report

	has (c: EV_COORDINATE): BOOLEAN
			-- Is c inside Current?
		require
			c_not_void: c /= void

	has_x_y (a_x, a_y: INTEGER): BOOLEAN
			-- Is (a_x, a_y) inside Current?

	intersects (other: like Current): BOOLEAN
			-- Does other at least partially overlap Current?

	lower_left: EV_COORDINATE
			-- Lower-left corner of Current.
		ensure
			result_exists: Result /= void
			result_assigned: Result.x = x and then Result.y = y + height

	lower_right: EV_COORDINATE
			-- Lower-right corner of Current.
		ensure
			result_exists: Result /= void
			result_assigned: Result.x = x + width and then Result.y = y + height

	upper_left: EV_COORDINATE
			-- Upper-left corner of Current.
		ensure
			result_exists: Result /= void
			result_assigned: Result.x = x and then Result.y = y

	upper_right: EV_COORDINATE
			-- Upper-right corner of Current.
		ensure
			result_exists: Result /= void
			result_assigned: Result.x = x + width and then Result.y = y
	
feature -- Element change

	grow_bottom (i: INTEGER)
			-- Increment size by i to south.

	grow_left (i: INTEGER)
			-- Increment size by i to west.
		require
			width + i > 0

	grow_right (i: INTEGER)
			-- Increment size by i to east.

	grow_top (i: INTEGER)
			-- Increment size by i to north.
		require
			height + i > 0

	include (a_x, a_y: INTEGER)
			-- Enlarge so that a_x, a_y is in Current.

	include_point (c: EV_COORDINATE)
			-- Enlarge so that c is in Current.
		require
			c_not_void: c /= void
		ensure
			has_c: has (c)

	merge (other: like Current)
			-- Enlarge Current so that other fits inside.
		require
			other_not_void: other /= void

	move (a_x, a_y: INTEGER)
			-- Move to a_x and a_y.
		ensure
			x_assigned: x = a_x
			y_assigned: y = a_y

	move_and_resize (a_x, a_y, a_width, a_height: INTEGER)
			-- Move to a_x and a_y and resize to a_width and a_height.
		require
			a_width_positive: a_width >= 0
			a_height_positive: a_height >= 0

	resize (a_width, a_height: INTEGER)
			-- Resize to a_width and a_height.
		require
			a_width_positive: a_width >= 0
			a_height_positive: a_height >= 0
		ensure
			width_assigned: width = a_width
			height_assigned: height = a_height

	set_bottom (i: INTEGER)
			-- Assign i to bottom.
		require
			i - y >= 0
		ensure
			assigned: bottom = i

	set_height (new_height: INTEGER)
			-- Assign new_height to height.
		require
			new_height_positive: new_height >= 0
		ensure
			height_assigned: height = new_height

	set_left (i: INTEGER)
			-- Assign i to left.
		require
			i <= right
		ensure
			assigned: left = i
			right_same: right = old right

	set_right (i: INTEGER)
			-- Assign i to right.
		require
			i - x >= 0
		ensure
			assigned: right = i

	set_top (i: INTEGER)
			-- Assign i to top.
		require
			i <= bottom
		ensure
			assigned: top = i
			bottom_same: bottom = old bottom

	set_width (new_width: INTEGER)
			-- Assign new_width to 'width'.
		require
			new_width_positive: new_width >= 0
		ensure
			width_assigned: width = new_width

	set_x (new_x: INTEGER)
			-- Assign new_x to x.
		ensure
			x_set: x = new_x

	set_y (new_y: INTEGER)
			-- Assign new_y to y.
		ensure
			y_set: y = new_y
	
feature -- Output

	out: STRING
			-- Return readable string.
	
invariant

	width_positive: width >= 0
	height_positive: height >= 0
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class EV_RECTANGLE