    indexing
    	description: "Positions relative to other positions.%NTakes another relative point as origin and then defines a%Nhor. & vert. scaling factor, x, y and angle.%NYou can then access absolute scale_x, scale_y, x, y and angle%Nwhich are recomputed only if invalidate_absolute_position has%Nbeen called.%NYou may also choose to specify a positioner. This is an agent%Nthat gets called everytime a recomputation is requested.%NWhen a positioner is installed, the other attributes are ignored.%NThe x and y are transformed by the angle and scaling of the origin.%NThis implies that the scale_x, scale_y and angle features of this%Nobject are only for propagation to referring points."
    	legal: "See notice at end of class."
    	status: "See notice at end of class."
    	keywords: "point, position, location, origin"
    	date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
    	revision: "$Revision: 56675 $"

    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_32)
    			-- Create with `an_origin' on position (`new_x', `new_y').

    	make_with_position (new_x, new_y: INTEGER_32)
    			-- 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: REAL_64
    			-- Angle in radians relative to origin.

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

    	generating_type: STRING_8
    			-- Name of current object's generating type
    			-- (type of which it is a direct instance)
    			-- (from ANY)

    	generator: STRING_8
    			-- Name of current object's generating class
    			-- (base class of the type of which it is a direct instance)
    			-- (from ANY)

    	frozen id_object (an_id: INTEGER_32): 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_32
    			-- 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: REAL_64
    			-- Relative horizontal scaling factor.

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

    	scale_y: REAL_64
    			-- Relative vertical scaling factor.

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

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

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

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

    	y_abs: INTEGER_32
    			-- Y relative to (0, 0). Updates if necessary.
    		ensure
    			result_assigned: Result = last_y_abs

    feature -- Comparison

    	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void
    			-- or attached to isomorphic object structures?
    			-- (from ANY)
    		ensure -- from ANY
    			shallow_implies_deep: standard_equal (some, other) implies Result
    			both_or_none_void: (some = Void) implies (Result = (other = Void))
    			same_type: (Result and (some /= Void)) implies some.same_type (other)
    			symmetric: Result implies deep_equal (other, some)

    	frozen equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached
    			-- to objects considered equal?
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

    	is_equal (other: like Current): BOOLEAN
    			-- Is `other' attached to an object considered
    			-- equal to current object?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			symmetric: Result implies other.is_equal (Current)
    			consistent: standard_is_equal (other) implies Result

    	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached to
    			-- field-by-field identical objects of the same type?
    			-- Always uses default object comparison criterion.
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

    	frozen standard_is_equal (other: like Current): BOOLEAN
    			-- Is `other' attached to an object of the same type
    			-- as current object, and field-by-field identical to it?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			same_type: Result implies same_type (other)
    			symmetric: Result implies other.standard_is_equal (Current)

    feature -- Status report

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

    	conforms_to (other: ANY): BOOLEAN
    			-- Does type of current object conform to type
    			-- of `other' (as per Eiffel: The Language, chapter 13)?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void

    	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.

    	same_type (other: ANY): BOOLEAN
    			-- Is type of current object identical to type of `other'?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			definition: Result = (conforms_to (other) and other.conforms_to (Current))

    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: REAL_64)
    			-- Set angle of this point (in radians).

    	set_angle_abs (new_angle_abs: REAL_64)
    			-- 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_32)
    			-- 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: REAL_64)
    			-- Set relative scaling factor.

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

    	set_scale_x_abs (new_scale_x_abs: REAL_64)
    			-- 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: REAL_64)
    			-- Set relative vertical scaling factor.

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

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

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

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

    	set_y_abs (new_y_abs: INTEGER_32)
    			-- Change absolute position.
    		ensure
    			last_y_abs_assigned: last_y_abs = new_y_abs

    feature -- Duplication

    	copy (other: like Current)
    			-- Update current object using fields of object attached
    			-- to `other', so as to yield equal objects.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_equal: is_equal (other)

    	frozen deep_copy (other: like Current)
    			-- Effect equivalent to that of:
    			--		copy (`other' . deep_twin)
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, other)

    	frozen deep_twin: like Current
    			-- New object structure recursively duplicated from Current.
    			-- (from ANY)
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, Result)

    	frozen standard_copy (other: like Current)
    			-- Copy every field of `other' onto corresponding field
    			-- of current object.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_standard_equal: standard_is_equal (other)

    	frozen standard_twin: like Current
    			-- New object field-by-field identical to `other'.
    			-- Always uses default copying semantics.
    			-- (from ANY)
    		ensure -- from ANY
    			standard_twin_not_void: Result /= Void
    			equal: standard_equal (Result, Current)

    	frozen twin: like Current
    			-- New object equal to `Current'
    			-- twin calls copy; to change copying/twining semantics, redefine copy.
    			-- (from ANY)
    		ensure -- from ANY
    			twin_not_void: Result /= Void
    			is_equal: Result.is_equal (Current)

    feature -- Basic operations

    	frozen default: like Current
    			-- Default value of object's type
    			-- (from ANY)

    	frozen default_pointer: POINTER
    			-- Default value of type `POINTER'
    			-- (Avoid the need to write `p'.default for
    			-- some `p' of type `POINTER'.)
    			-- (from ANY)

    	default_rescue
    			-- Process exception for routines with no Rescue clause.
    			-- (Default: do nothing.)
    			-- (from ANY)

    	frozen do_nothing
    			-- Execute a null action.
    			-- (from ANY)

    feature -- Output

    	io: STD_FILES
    			-- Handle to standard file setup
    			-- (from ANY)

    	out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of tagged_out.
    			-- (from ANY)

    	print (some: ANY)
    			-- Write terse external representation of `some'
    			-- on standard output.
    			-- (from ANY)

    	frozen tagged_out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of out.
    			-- (from ANY)

    feature -- Platform

    	operating_environment: OPERATING_ENVIRONMENT
    			-- Objects available from the operating system
    			-- (from ANY)

    feature -- Representation

    	out_abs: STRING_8
    			-- A string with absolute coordinates.

    	out_rel: STRING_8
    			-- 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)

    indexing
    	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
    	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
    	source: "[
    		Eiffel Software
    		356 Storke Road, Goleta, CA 93117 USA
    		Telephone 805-685-1006, Fax 805-685-6869
    		Website http://www.eiffel.com
    		Customer support http://support.eiffel.com
    	]"

    end -- class EV_RELATIVE_POINT