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

em.video.figure

Class EM_CIRCLE


Direct ancestors

EM_CLOSED_FIGURE, DOUBLE_MATH

Creation

Features

Invariants

indexing

description

A circle (approximated by a polygon).

date

$Date: 2005/10/23 10:57:04 $

revision

$Revision: 1.6 $

class

EM_CIRCLE

inherit

EM_CLOSED_FIGURE

create

make (a_center: EM_VECTOR_2D; a_radius: DOUBLE)

-- Make circle with a_center and a_radius.

require
a_center_not_void: a_center /= Void
a_radius_is_positiive: a_radius > 0
make_inside_box (a_box: EM_ORTHOGONAL_RECTANGLE)

-- Make largest circle fitting into a_box
-- with center at center of a_box.

make_through_three_points (a_vector, b_vector, c_vector: EM_VECTOR_2D)

-- creates a circle, that goes through the 3 given points
-- if the 3 points are all aligned no such circle can be found and the unit circle is created
-- in that case the variable not_created will be set, to inform the client

require
a_vector_not_void: a_vector /= Void
b_vector_not_void: b_vector /= Void
c_vector_not_void: c_vector /= Void

feature -- Initialization

default_create

-- Initialize Current as filled figure
-- in white colors with line width of 0.0.

-- (From ANY)

make (a_center: EM_VECTOR_2D; a_radius: DOUBLE)

-- Make circle with a_center and a_radius.

require
a_center_not_void: a_center /= Void
a_radius_is_positiive: a_radius > 0
make_inside_box (a_box: EM_ORTHOGONAL_RECTANGLE)

-- Make largest circle fitting into a_box
-- with center at center of a_box.

make_through_three_points (a_vector, b_vector, c_vector: EM_VECTOR_2D)

-- creates a circle, that goes through the 3 given points
-- if the 3 points are all aligned no such circle can be found and the unit circle is created
-- in that case the variable not_created will be set, to inform the client

require
a_vector_not_void: a_vector /= Void
b_vector_not_void: b_vector /= Void
c_vector_not_void: c_vector /= Void

feature -- Status report

center: EM_VECTOR_2D

-- Center of Current circle.

fill_color: EM_COLOR

-- The color with which the interrior of the figure is drawed,
-- if is_filled is True

-- (From EM_CLOSED_FIGURE)

height: INTEGER

-- Height of Current.

-- (From EM_DRAWABLE)

ensure
result_not_negative: Result >= 0
is_approximated_adaptively: BOOLEAN

-- Is Current drawed with an adaptively choosen number of polygon points
-- depending on display_resolution of surface it is drawed onto?

is_filled: BOOLEAN

-- Is Current drawed filled with fill_color?
-- (otherwise only the border will be drawed)

-- (From EM_CLOSED_FIGURE)

is_size_fixed: BOOLEAN

-- Should Current not scale when drawed?
-- True means that the object will be drawed unscaled
-- but its position (reference_point) will still be transformed correctly
-- if drawed on a transformed scaled coordinate system
-- (This is handled accordingly by draw_object of EM_SURFACE)

-- (From EM_DRAWABLE)

line_color: EM_COLOR

-- Line color used to draw Current

-- (From EM_FIGURE)

line_width: DOUBLE

-- Line width used to draw Current

-- (From EM_FIGURE)

max_number_of_polygon_points: INTEGER

-- Maximum number of polygon points used to approximate Current circle
-- when is_approximated_adaptively.

min_number_of_polygon_points: INTEGER

-- Minimum number of points used to approximate a circle.

not_created: BOOLEAN

-- will be set to true, if the circle could not be created correctly (in case of 3 aligned points in make_through_three_points)

number_of_polygon_points: INTEGER

-- Number of polygon points used to approximate Current circle
-- when not is_approximated_adaptively.

radius: DOUBLE

-- Radius of Current circle.

width: INTEGER

-- Width of Current.

-- (From EM_DRAWABLE)

ensure
result_not_negative: Result >= 0
x: INTEGER

-- Horizontal position, distance in pixels from left

-- (From EM_DRAWABLE)

y: INTEGER

-- Vertical position, distance in pixels from top

-- (From EM_DRAWABLE)

feature -- Status setting

disable_adaptive_approximation

-- Disable drawing Current with an adaptively choosen number of polygon points,
-- depending on radius and surface's display_resolution.

enable_adaptive_approximation

-- Enable drawing Current with an adaptively choosen number of polygon points,
-- depending on radius and surface's display_resolution.

set_center (a_center: EM_VECTOR_2D)

-- Set center to a_center.

set_fill_color (a_color: EM_COLOR)

-- Set fill_color to a_color.

-- (From EM_CLOSED_FIGURE)

require
a_color_not_void: a_color /= Void
ensure
fill_color_assigned: fill_color = a_color
set_filled (a_bool: BOOLEAN)

-- Set is_filled to a_bool.

-- (From EM_CLOSED_FIGURE)

ensure
is_filled_set: is_filled = a_bool
set_line_color (a_color: EM_COLOR)

-- Set line_color to a_color.

-- (From EM_FIGURE)

require
a_color_not_void: a_color /= Void
ensure
line_color_assigned: line_color = a_color
set_line_width (a_width: DOUBLE)

-- Set line_width to a_width.

-- (From EM_FIGURE)

require
a_width_not_negative: a_width >= 0
ensure
line_width_set: line_width = a_width
set_max_number_of_polygon_points (a_count: INTEGER)

-- Set max_number_of_polygon_points to a_count.

require
a_count_big_enough: a_count >= min_number_of_polygon_points
ensure
max_number_of_polygon_points_set: max_number_of_polygon_points = a_count
set_number_of_polygon_points (a_count: INTEGER)

-- Set number_of_polygon_points to a_count.

require
a_count_big_enough: a_count >= min_number_of_polygon_points
ensure
number_of_polygon_points_set: number_of_polygon_points = a_count
set_radius (a_radius: DOUBLE)

-- Set radius to a_radius.

set_size_fixed (a_boolean: BOOLEAN)

-- Set is_size_fixed to a_boolean.

-- (From EM_DRAWABLE)

ensure
size_fixed_set: is_size_fixed = a_boolean
set_x (x_position: INTEGER)

-- Set x to x_position.

-- (From EM_DRAWABLE)

ensure
x_set: x = x_position
set_x_y (x_position: INTEGER; y_position: INTEGER)

-- Set x and y to x_position and y_position.

-- (From EM_DRAWABLE)

ensure
x_set: x = an_x
y_set: y = a_y
set_y (y_position: INTEGER)

-- Set y to y_position.

-- (From EM_DRAWABLE)

ensure
y_set: y = y_position
update_bounding_box

-- Recalculate bounding_box (x, y, width, height)
-- to surround Current.

-- (From EM_FIGURE)

feature -- Drawing

draw (drawing_interface: EM_SURFACE)

-- Draw Current using drawing_interface.

-- (From EM_DRAWABLE)

require
a_surface_not_void: a_surface /= Void
draw_part (a_rect: EM_RECT; a_surface: EM_SURFACE)

-- Draw rectangular part of Current defined by a_rect to a_surface.
-- (Subclasses could redefine this feature for providing an implementation
-- with better performance, otherwise its just done per default by
-- transforming and clipping coordinates on a_surface before calling draw).

-- (From EM_DRAWABLE)

require
a_surface_not_void: a_surface /= Void
a_rect_not_void: a_rect /= Void

feature -- Mouse Events

publish_mouse_event (a_mouse_event: EM_MOUSE_EVENT)

-- Publish mouse event when a_mouse_event occured on Current.
-- Only publish mouse event, if proportional_point lies inside circle.

-- (From EM_DRAWABLE)

require
a_mouse_event_not_void: a_mouse_event /= Void

feature -- Mouse events

events_initialized: BOOLEAN

-- Have events been initialized?

-- (From EM_DRAWABLE)

initialize_events

-- Event initialization.
-- Needs to be called before subscribing for events.

-- (From EM_DRAWABLE)

require
not_yet_initialized: not events_initialized
ensure
events_initialized: events_initialized
mouse_button_down_event_initialized: mouse_button_down_event /= Void
mouse_button_up_event_initialized: mouse_button_up_event /= Void
mouse_motion_event_initialized: mouse_motion_event /= Void
mouse_button_down_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button down event,
-- gets published when the mouse button is pressed over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

-- (From EM_DRAWABLE)

mouse_button_up_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

-- (From EM_DRAWABLE)

mouse_motion_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEMOTION_EVENT is passed as argument

-- (From EM_DRAWABLE)

feature -- Queries

bounding_box: EM_ORTHOGONAL_RECTANGLE

-- Orthogonal rectangle surrounding Current; (i.e. usefull
-- for visibility testing if it intersects with
-- coordinate_area of EM_SURFACE) TODO: We create a new
-- one on each call. Maybe there is a more efficient way to
-- do that?

-- (From EM_DRAWABLE)

ensure
result_not_void: Result /= Void
reference_point: EM_VECTOR_2D

-- Reference point of Current relative to which it should be positioned.
-- (i.e. important when drawn on a scaled coordinate system and is_size_fixed is True)

-- (From EM_DRAWABLE)

ensure
result_not_void: Result /= Void

invariant

fill_color_not_void: fill_color /= Void

-- From EM_FIGURE
line_color_not_void: line_color /= Void
line_width_not_negative: line_width >= 0.0
points_not_void: points /= Void

-- From EM_DRAWABLE
mouse_button_down_event_initialized: events_initialized implies mouse_button_down_event /= Void
mouse_button_up_event_initialized: events_initialized implies mouse_button_up_event /= Void
mouse_motion_event_initialized: events_initialized implies mouse_motion_event /= Void

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

end