Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.video.animation

Class EM_ANIMATION


Direct ancestors

ARRAY, EM_SHARED_BITMAP_FACTORY, EM_SHARED_ERROR_HANDLER

Creation

Features

Invariants

indexing

description

An EM_ANIMATION is an array of EM_DRAWABLE. To create an EM_ANIMATION you have
to give an animation script file to the creation feature make.

The format of the animation script file:

File ::= [file_name_of_picture [duration]nl]* eof

If no duration is given every frame takes 125ms, which equals 8 frames per second.
The unit of duration is millisecons.

date

$Date: 2005/10/26 07:42:54 $

revision

$Revision: 1.12 $

class

EM_ANIMATION

inherit

ARRAY
RESIZABLE
BOUNDED
FINITE
BOX
CONTAINER
INDEXABLE
TABLE
BAG
COLLECTION
CONTAINER
TO_SPECIAL

create

make_from_file (a_file_name: STRING)

-- Builds an EM_ANIMATION from the information provided by the script file a_file_name.
-- The script file has the following format:
-- File ::= [file_name_of_picture [duration]nl]* eof

require
a_file_name_exist: a_file_name /= void
a_file_name_not_empty: not a_file_name.is_empty
file_must_exist: file_exists (a_file_name)
file_in_correct_format: file_in_correct_format (a_file_name)
make_from_array (a: ARRAY [EM_PAIR [EM_DRAWABLE, INTEGER]])

-- Initialize from the items of a.
-- (Useful in proper descendants of class ARRAY,
-- to initialize an array-like object from a manifest array.)

-- (From ARRAY)

require
array_exists: a /= Void
make (min_index, max_index: INTEGER)

-- Allocate array; set index interval to
-- min_index .. max_index; set all values to default.
-- (Make array empty if min_index = max_index + 1).

-- (From ARRAY)

require
valid_bounds: min_index <= max_index + 1
ensure
lower_set: lower = min_index
upper_set: upper = max_index
items_set: all_default

feature -- Initialization

make (min_index, max_index: INTEGER)

-- Allocate array; set index interval to
-- min_index .. max_index; set all values to default.
-- (Make array empty if min_index = max_index + 1).

-- (From ARRAY)

require
valid_bounds: min_index <= max_index + 1
ensure
lower_set: lower = min_index
upper_set: upper = max_index
items_set: all_default
make_from_array (a: ARRAY [EM_PAIR [EM_DRAWABLE, INTEGER]])

-- Initialize from the items of a.
-- (Useful in proper descendants of class ARRAY,
-- to initialize an array-like object from a manifest array.)

-- (From ARRAY)

require
array_exists: a /= Void
make_from_cil (na: NATIVE_ARRAY [EM_PAIR [EM_DRAWABLE, INTEGER]])

-- Initialize array from na.

-- (From ARRAY)

require
is_dotnet: {PLATFORM}.is_dotnet
na_not_void: na /= Void

feature -- Access

area: SPECIAL [EM_PAIR [EM_DRAWABLE, INTEGER]]

-- Special data zone

-- (From TO_SPECIAL)

frame (i: INTEGER): EM_PAIR [EM_DRAWABLE, INTEGER]

-- Entry at index i, if in index interval

-- (From ARRAY)

require
valid_key: valid_index (i)
has (v: EM_PAIR [EM_DRAWABLE, INTEGER]): BOOLEAN

-- Does v appear in array?
-- (Reference or object equality,
-- based on object_comparison.)

-- (From CONTAINER)

ensure
not_found_in_empty: Result implies not is_empty
infix "@" (i: INTEGER): EM_PAIR [EM_DRAWABLE, INTEGER]

-- Entry at index i, if in index interval

-- (From TABLE)

require
valid_key: valid_key (k)
item (i: INTEGER): EM_PAIR [EM_DRAWABLE, INTEGER]

-- Entry at index i, if in index interval

-- (From TABLE)

require
valid_key: valid_key (k)

feature -- Measurement

growth_percentage: INTEGER

-- Percentage by which structure will grow automatically

-- (From RESIZABLE)

minimal_increase: INTEGER

-- Minimal number of additional items

-- (From RESIZABLE)

additional_space: INTEGER

-- Proposed number of additional items
--| Result is a reasonable value, resulting from a space-time tradeoff.

-- (From RESIZABLE)

ensure
At_least_one: Result >= 1
capacity: INTEGER

-- Number of available indices

-- (From BOUNDED)

ensure then
consistent_with_bounds: Result = upper - lower + 1
index_set: INTEGER_INTERVAL

-- Range of acceptable indexes

-- (From INDEXABLE)

ensure
not_void: Result /= Void
ensure then
same_count: Result.count = count
same_bounds: ((Result.lower = lower) and (Result.upper = upper))
lower: INTEGER

-- Minimum index

-- (From ARRAY)

nr_of_frames: INTEGER

-- Number of available indices

-- (From FINITE)

ensure then
consistent_with_bounds: Result = upper - lower + 1
occurrences (v: EM_PAIR [EM_DRAWABLE, INTEGER]): INTEGER

-- Number of times v appears in structure

-- (From BAG)

ensure
non_negative_occurrences: Result >= 0
upper: INTEGER

-- Maximum index

-- (From ARRAY)

feature -- Comparison

is_equal (other: like Current): BOOLEAN

-- Is array made of the same items as other?

-- (From ANY)

require
other_not_void: other /= Void
ensure
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result

feature -- Status report

all_cleared: BOOLEAN

-- Are all items set to default values?

-- (From ARRAY)

obsolete

Use all_default instead

all_default: BOOLEAN

-- Are all items set to default values?

-- (From ARRAY)

ensure
definition: Result = (count = 0 or else((item (upper) = Void or elseitem (upper) = item (upper).default) andsubarray (lower, upper - 1).all_default))
changeable_comparison_criterion: BOOLEAN

-- May object_comparison be changed?
-- (Answer: yes by default.)

-- (From CONTAINER)

empty: BOOLEAN

-- Is there no element?

-- (From CONTAINER)

obsolete

ELKS 2000: Use is_empty instead

extendible: BOOLEAN

-- May items be added?
-- (Answer: no, although array may be resized.)

-- (From COLLECTION)

file_exists (fn: STRING): BOOLEAN

-- Does file with name fn exist?

require
file_name_exists: fn /= Void
file_name_not_empty: not fn.is_empty
file_name_valid: is_file_name_valid (fn)
file_in_correct_format (a_file_name: STRING): BOOLEAN

-- if file with a_file_name in correct format?
-- The correct format is:
-- File ::= [file_name_of_picture [duration]nl]* eof

require
a_file_name_exist: a_file_name /= void
a_file_name_not_empty: not a_file_name.is_empty
file_exist: file_exists (a_file_name)
full: BOOLEAN

-- Is structure filled to capacity? (Answer: yes)

-- (From BOX)

is_empty: BOOLEAN

-- Is structure empty?

-- (From CONTAINER)

is_file_name_valid (fn: STRING): BOOLEAN

-- Is fn a valid file name?

require
file_name_exists: fn /= Void
file_name_not_empty: not fn.is_empty
is_inserted (v: EM_PAIR [EM_DRAWABLE, INTEGER]): BOOLEAN

-- Has v been inserted by the most recent insertion?
-- (By default, the value returned is equivalent to calling
-- has (v). However, descendants might be able to provide more
-- efficient implementations.)

-- (From COLLECTION)

object_comparison: BOOLEAN

-- Must search operations use equal rather than =
-- for comparing references? (Default: no, use =.)

-- (From CONTAINER)

prunable: BOOLEAN

-- May items be removed? (Answer: no.)

-- (From COLLECTION)

resizable: BOOLEAN

-- May capacity be changed? (Answer: yes.)

-- (From BOUNDED)

same_items (other: like Current): BOOLEAN

-- Do other and Current have same items?

-- (From ARRAY)

require
other_not_void: other /= Void
ensure
definition: Result = ((count = other.count) and then(count = 0 or else (item (upper) = other.item (other.upper)and subarray (lower, upper - 1).same_items(other.subarray (other.lower, other.upper - 1)))))
valid_index (i: INTEGER): BOOLEAN

-- Is i within the bounds of the array?

-- (From TABLE)

ensure then
only_if_in_index_set: Result implies((i >= index_set.lower) and(i <= index_set.upper))
valid_index_set: BOOLEAN

-- (From ARRAY)

feature -- Status setting

compare_objects

-- Ensure that future search operations will use equal
-- rather than = for comparing references.

-- (From CONTAINER)

require
changeable_comparison_criterion: changeable_comparison_criterion
ensure
compare_references

-- Ensure that future search operations will use =
-- rather than equal for comparing references.

-- (From CONTAINER)

require
changeable_comparison_criterion: changeable_comparison_criterion
ensure
reference_comparison: not object_comparison

feature -- Element change

enter (v: like item; i: INTEGER)

-- Replace i-th entry, if in index interval, by v.

-- (From ARRAY)

require
valid_key: valid_index (i)
fill (other: CONTAINER [EM_PAIR [EM_DRAWABLE, INTEGER]])

-- Fill with as many items of other as possible.
-- The representations of other and current structure
-- need not be the same.

-- (From COLLECTION)

require
other_not_void: other /= Void
extendible: extendible
force (v: like item; i: INTEGER)

-- Assign item v to i-th entry.
-- Always applicable: resize the array if i falls out of
-- currently defined bounds; preserve existing items.

-- (From ARRAY)

ensure
inserted: item (i) = v
higher_count: count >= old count
put (v: like item; i: INTEGER)

-- Replace i-th entry, if in index interval, by v.

-- (From TABLE)

require
valid_key: valid_key (k)
ensure then
insertion_done: item (k) = v
subcopy (other: ARRAY [EM_PAIR [EM_DRAWABLE, INTEGER]]start_pos, end_pos, index_pos: INTEGER)

-- Copy items of other within bounds start_pos and end_pos
-- to current array starting at index index_pos.

-- (From ARRAY)

require
other_not_void: other /= Void
valid_start_pos: other.valid_index (start_pos)
valid_end_pos: other.valid_index (end_pos)
valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
valid_index_pos: valid_index (index_pos)
enough_space: (upper - index_pos) >= (end_pos - start_pos)

feature {NONE} -- Element change

set_area (other: like area)

-- Make other the new area

-- (From TO_SPECIAL)

feature -- Removal

clear_all

-- Reset all items to default values.

-- (From ARRAY)

ensure
stable_lower: lower = old lower
stable_upper: upper = old upper
default_items: all_default
discard_items

-- Reset all items to default values with reallocation.

-- (From ARRAY)

ensure
default_items: all_default
prune_all (v: EM_PAIR [EM_DRAWABLE, INTEGER])

-- Remove all occurrences of v.
-- (Reference or object equality,
-- based on object_comparison.)
--|Default implementation, usually inefficient.

-- (From COLLECTION)

require
prunable: prunable
ensure
no_more_occurrences: not has (v)
wipe_out

-- Make array empty.

-- (From COLLECTION)

obsolete

Not applicable since not prunable. Use discard_items instead.

require
prunable: prunable
ensure
wiped_out: is_empty

feature -- Resizing

automatic_grow

-- Change the capacity to accommodate at least
-- Growth_percentage more items.
--| Trades space for time:
--| allocates fairly large chunks of memory but not very often.

-- (From RESIZABLE)

ensure
increased_capacity: capacity >= old capacity + old capacity * Growth_percentage // 100
conservative_resize (min_index, max_index: INTEGER)

-- Rearrange array so that it can accommodate
-- indices down to min_index and up to max_index.
-- Do not lose any previously entered item.

-- (From ARRAY)

require
good_indices: min_index <= max_index
ensure
no_low_lost: lower = min_index or else lower = old lower
no_high_lost: upper = max_index or else upper = old upper
grow (i: INTEGER)

-- Change the capacity to at least i.

-- (From RESIZABLE)

ensure
new_capacity: capacity >= i
resize (min_index, max_index: INTEGER)

-- Rearrange array so that it can accommodate
-- indices down to min_index and up to max_index.
-- Do not lose any previously entered item.

-- (From ARRAY)

obsolete

Use conservative_resize instead as future versions will implement resize as specified in ELKS.

require
good_indices: min_index <= max_index
ensure
no_low_lost: lower = min_index or else lower = old lower
no_high_lost: upper = max_index or else upper = old upper

feature -- Conversion

linear_representation: LINEAR [EM_PAIR [EM_DRAWABLE, INTEGER]]

-- Representation as a linear structure

-- (From CONTAINER)

to_c: ANY

-- Address of actual sequence of values,
-- for passing to external (non-Eiffel) routines.

-- (From ARRAY)

require
not_is_dotnet: not {PLATFORM}.is_dotnet
to_cil: NATIVE_ARRAY [EM_PAIR [EM_DRAWABLE, INTEGER]]

-- Address of actual sequence of values,
-- for passing to external (non-Eiffel) routines.

-- (From ARRAY)

require
is_dotnet: {PLATFORM}.is_dotnet
ensure
to_cil_not_void: Result /= Void

feature -- Duplication

copy (other: like Current)

-- Reinitialize by copying all the items of other.
-- (This is also used by clone.)

-- (From ANY)

require
other_not_void: other /= Void
type_identity: same_type (other)
ensure
is_equal: is_equal (other)
ensure then
equal_areas: area.is_equal (other.area)
subarray (start_pos, end_pos: INTEGER): ARRAY [EM_PAIR [EM_DRAWABLE, INTEGER]]

-- Array made of items of current array within
-- bounds start_pos and end_pos.

-- (From ARRAY)

require
valid_start_pos: valid_index (start_pos)
valid_end_pos: valid_index (end_pos)
valid_bounds: (start_pos <= end_pos) or (start_pos = end_pos + 1)
ensure
lower: Result.lower = start_pos
upper: Result.upper = end_pos

feature -- Iteration

do_all (action: PROCEDURE [ANY, TUPLE [EM_PAIR [EM_DRAWABLE, INTEGER]]])

-- Apply action to every non-void item.
-- Semantics not guaranteed if action changes the structure;
-- in such a case, apply iterator to clone of structure instead.

-- (From ARRAY)

require
action_not_void: action /= Void
do_if (action: PROCEDURE [ANY, TUPLE [EM_PAIR [EM_DRAWABLE, INTEGER]]]test: FUNCTION [ANY, TUPLE [EM_PAIR [EM_DRAWABLE, INTEGER]], BOOLEAN])

-- Apply action to every non-void item that satisfies test.
-- Semantics not guaranteed if action or test changes the structure;
-- in such a case, apply iterator to clone of structure instead.

-- (From ARRAY)

require
action_not_void: action /= Void
test_not_void: test /= Void
for_all (test: FUNCTION [ANY, TUPLE [EM_PAIR [EM_DRAWABLE, INTEGER]], BOOLEAN]): BOOLEAN

-- Is test true for all non-void items?

-- (From ARRAY)

require
test_not_void: test /= Void
there_exists (test: FUNCTION [ANY, TUPLE [EM_PAIR [EM_DRAWABLE, INTEGER]], BOOLEAN]): BOOLEAN

-- Is test true for at least one item?

-- (From ARRAY)

require
test_not_void: test /= Void

invariant

-- From ARRAY
area_exists: area /= Void
consistent_size: capacity = upper - lower + 1
non_negative_count: count >= 0
index_set_has_same_count: valid_index_set

-- From RESIZABLE
increase_by_at_least_one: Minimal_increase >= 1

-- From BOUNDED
valid_count: count <= capacity
full_definition: full = (count = capacity)

-- From FINITE
empty_definition: is_empty = (count = 0)
non_negative_count: count >= 0

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

-- From INDEXABLE
index_set_not_void: index_set /= Void

end