note
	description: "[
		Support class for holding coordinates for the definition
		of all widgets for the VITP game.
		Each POINT_LIST represents the definition of an area such
		as a sea area or land mass or the corners of a tile in
		a widget for an attack unit.
		
		The points defining the widgets may be larger than required,
		so we provide scaling factors to be used after the widget
		is built.
		]"
	author: "Jimmy J. Johnson"

class
	ITEM_DEFINITION

inherit

	LINKED_LIST [POINT_LIST]
		redefine
			make
		end

create
	make

feature {NONE} -- Initialization

	make
			-- Initialize Current with a `control_point' at the origin
		do
			Precursor
			create dot_offset
			create lines.make
			factor_x := 1.0
			factor_y := 1.0
		end

	anchor_type: REAL_64
			-- Anchor scales and offsets to this numeric type

feature -- Access

	factor_x: like anchor_type
			-- Amount to scale widget in x direction (after it is built)

	factor_y: like anchor_type
			-- Amount to scale widget in x direction (after it is built)

	offset_x: like anchor_type
			-- Amount to x translate the widget to get it in to its initial
			-- position on the board (after the widget is built)

	offset_y: like anchor_type
			-- Amount to y translate the widget to get it in to its initial
			-- position on the board (after the widget is built)

	dot_offset_x: like anchor_type
			-- Amount to translate the `dot' in the described {VITP_WIDGET}
			-- This offset is relative to the center point of the widget

	dot_offset: EV_COORDINATE
--	dot_offset_y: like anchor_type
			-- Amount to translate the `dot' in the described {VITP_WIDGET}
			-- This offset is relative to the center point of the widget

	line_count: INTEGER
			-- The number of text lines
		do
			Result := lines.count
		end

	line (a_index: INTEGER): STRING
			-- The line at `a_index'
		require
			has_lines: has_lines
			index_large_enough: a_index >= 1
			index_small_enough: a_index <= line_count
		do
			Result := lines [a_index]
		end

feature -- Element change

	set_offset (ax, ay: like anchor_type)
			-- The amount by which the widget defined by Current should be translated
		do
			offset_x := ax
			offset_y := ay
		end

	set_dot_offset (a_offset: like dot_offset)
			-- Change the `dot_offset
		do
			dot_offset := a_offset
		end

	set_offset_x (ax: like anchor_type)
			-- Change the `offset_x'
		do
			offset_x := ax
		end

	set_offset_y (ay: like anchor_type)
			-- Change the `offset_y'
		do
			offset_y := ay
		end

	set_factors (ax, ay: like anchor_type)
			-- Change both x and y scale factors
		require
			x_factor_large_enough: ax > 0.0
			y_factor_large_enough: ay > 0.0
		do
			factor_x := ax
			factor_y := ay
		end

	set_factor_x (ax: like anchor_type)
			-- Change the `factor_x'
		require
			factor_large_enough: ax > 0.0
		do
			factor_x := ax
		end

	set_factor_y (ay: like anchor_type)
			-- Change the `factor_y'
		require
			factor_large_enough: ay > 0.0
		do
			factor_y := ay
		end

	add_line (a_line: STRING)
			-- Add a line of text
		require
			line_exists: a_line /= Void
		do
			lines.extend (a_line)
		end

feature -- Status report

	has_lines: BOOLEAN
			-- Does Current have at least one line?
		do
			Result := not lines.is_empty
		end

feature {NONE} -- Implementation

	lines: LINKED_LIST [STRING]
			-- All the lines of text that belong in the represented area

invariant

	dot_offset_exists: dot_offset /= Void
	lines_exists: lines /= Void

end
