indexing
	description: "Positions relative to other positions.Takes another relative point as origin and then defines ahor. & vert. scaling factor, x, y and angle.You can then access absolute scale_x, scale_y, x, y and anglewhich are recomputed only if invalidate_absolute_position hasbeen called.You may also choose to specify a positioner. This is an agentthat gets called everytime a recomputation is requested.When a positioner is installed, the other attributes are ignored.The x and y are transformed by the angle and scaling of the origin.This implies that the scale_x, scale_y and angle features of thisobject are only for propagation to referring points."
	status: "See notice at end of class"
	keywords: "point, position, location, origin"
	date: "$Date$"
	revision: "$Revision$"

class interface
	EV_RELATIVE_POINT

create 

	default_create
			-- Base origin.

	make_with_origin (an_origin: EV_RELATIVE_POINT)
			-- Create with an_origin on position (0, 0).

	make_with_origin_and_position (an_origin: EV_RELATIVE_POINT; new_x, new_y: INTEGER)
			-- Create with an_origin on position (new_x, new_y).

	make_with_position (new_x, new_y: INTEGER)
			-- Create on position (new_x, new_y).

	make_with_positioner (pos_agent: like positioner)
			-- Create with pos_agent.

feature -- Access

	absolute_coordinates: EV_COORDINATE
			-- Coordinates relative to (0, 0). Updates if necessary.

	angle: DOUBLE
			-- Angle in radians relative to origin.

	angle_abs: DOUBLE
			-- Angle relative to 0. Updates if necessary.
		ensure
			result_assigned: Result = last_angle_abs

	frozen id_object (an_id: INTEGER): IDENTIFIED
			-- Object associated with an_id (void if no such object)
			-- (from IDENTIFIED)
		ensure -- from IDENTIFIED
			consistent: Result = void or else Result.object_id = an_id

	frozen object_id: INTEGER
			-- Unique for current object in any given session
			-- (from IDENTIFIED)
		ensure -- from IDENTIFIED
			valid_id: id_object (Result) = Current

	origin: EV_RELATIVE_POINT
			-- Origin the position is relative to.
			-- If this is Void, x and y are relative to (0, 0).

	positioner: PROCEDURE [ANY, TUPLE [like Current]]
			-- Take special absolute positioning action.
			-- A positioner is expected to use the routines:
			-- set_x_abs, set_y_abs.
			-- set_angle_abs, set_scale_x_abs, set_scale_y_abs can be used too
			-- to propagate angle and scaling factor to referring points.

	scale_x: DOUBLE
			-- Relative horizontal scaling factor.

	scale_x_abs: DOUBLE
			-- Final horizontal scaling factor. Updates if necessary.
		ensure
			result_assigned: Result = last_scale_x_abs

	scale_y: DOUBLE
			-- Relative vertical scaling factor.

	scale_y_abs: DOUBLE
			-- Final vertical scaling factor. Updates if necessary.
		ensure
			result_assigned: Result = last_scale_y_abs

	x: INTEGER
			-- X-coordinate relative to origin.

	x_abs: INTEGER
			-- X relative to (0, 0). Updates if necessary.
		ensure
			result_assigned: Result = last_x_abs

	y: INTEGER
			-- Y-coordinate relative to origin.

	y_abs: INTEGER
			-- Y relative to (0, 0). Updates if necessary.
		ensure
			result_assigned: Result = last_y_abs
	
feature -- Status report

	being_positioned: BOOLEAN
			-- Used for cycle detection of positioning agents.

	has_positioner: BOOLEAN
			-- Is this point controlled by an agent?
		ensure
			result_assigned: Result = (positioner /= void)

	relative_to (org: EV_RELATIVE_POINT): BOOLEAN
			-- Does this point have org as origin somehow?
			-- This is not the case when it is being positioned.
	
feature -- Element change

	change_origin (new_origin: EV_RELATIVE_POINT)
			-- Set point this point is relative to.
			-- Do not change absolute coordinates if
			-- scaling factors and angle do not change.
		require
			new_origin_not_void: new_origin /= void
			no_dependance_circle: not new_origin.relative_to (Current)

	set_angle (new_angle: DOUBLE)
			-- Set angle of this point (in radians).

	set_angle_abs (new_angle_abs: DOUBLE)
			-- Change absolute angle.
		ensure
			last_angle_abs_assigned: last_angle_abs = new_angle_abs

	set_origin (new_origin: EV_RELATIVE_POINT)
			-- Set point this point is relative to.
		require
			new_origin_not_void: new_origin /= void
			no_dependance_circle: not new_origin.relative_to (Current) and new_origin /= Current

	set_position (new_x, new_y: INTEGER)
			-- Set both x and y.

	set_positioner (pos_agent: like positioner)
			-- Set a customized positioning routine.
		ensure
			positioner_assigned: positioner = pos_agent

	set_scale (new_scale: DOUBLE)
			-- Set relative scaling factor.

	set_scale_x (new_scale_x: DOUBLE)
			-- Set relative horizontal scaling factor.

	set_scale_x_abs (new_scale_x_abs: DOUBLE)
			-- Change absolute horizontal scaling factor.
		ensure
			last_scale_x_abs_assigned: last_scale_x_abs = new_scale_x_abs

	set_scale_y (new_scale_y: DOUBLE)
			-- Set relative vertical scaling factor.

	set_scale_y_abs (new_scale_y_abs: DOUBLE)
			-- Change absolute vertical scaling factor.
		ensure
			last_scale_y_abs_assigned: last_scale_y_abs = new_scale_y_abs

	set_x (new_x: INTEGER)
			-- Change relative horizontal position.

	set_x_abs (new_x_abs: INTEGER)
			-- Change absolute position.
		ensure
			last_x_abs_assigned: last_x_abs = new_x_abs

	set_y (new_y: INTEGER)
			-- Change relative vertical position.

	set_y_abs (new_y_abs: INTEGER)
			-- Change absolute position.
		ensure
			last_y_abs_assigned: last_y_abs = new_y_abs
	
feature -- Representation

	out_abs: STRING
			-- A string with absolute coordinates.

	out_rel: STRING
			-- A string with all relative coordinates of origins.
	
invariant

	notify_list_exists: notify_list_ids /= void
	has_origin_implies_origin_notifies: origin /= void implies origin.notify_list_ids.has (object_id)
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class EV_RELATIVE_POINT