GT::Graphics::Object

A graphical object is a part of a graphic. It can display itself on a picture.


FUNCTIONS TO IMPLEMENT

Each graphic object will have to implement these two functions (methods).

$o->init(...)

This function is called with the trailing arguments (e,g, $args[2] and up) given to the generic new constructor defined here.

$o->display($driver, $picture)

Display the graphic object on the picture using the given driver. It may use $o->{'source'} and $o->{'zone'} (e.g. the graphic objects argument hash $self->{'source'} and $self->{'zone'} to get the data to display and display itself in the correct zone.


GENERIC FUNCTIONS

my $obj = GT::Graphics::Object::<Something>->new($datasource, $zone, ...)

The generic new constructor declared and defined here takes the first 2 arguments (e.g. $datasource and $zone) and assigns them to the objects argument hash $self->{'source'} and $self->{'zone'}, respectively, and passes the remaining arguments, if any, to the init method which must be provided by the GT::Graphics::Object::<Something> package.

in addition, the new constructor sets the objects argument hash keys 'bg_color' and 'fg_color' (e.g. $self->{'bg_color'} and $self->{'fg_color'}) to the gt config key-values corresponding with Graphic::BackgroundColor and Graphic::ForegroundColor respectively.

my $o_z_level = $o->get_z_level()

$o->set_z_level($z)

Those two functions are used to manage the order in which the orders are displayed. An object with a low Z level is drawn first.

my $o_datasource = $o->get_source()

$o->set_source($source)

set/get the datasource associated to this object.

$o->set_zone($zone)

Set the zone in which the object will be displayed.

$o->set_special_scale($scale)

Use a special scale to draw this object.

my $o_scale = $o->get_scale()

Return the associated scale. If it exists, it uses the special scale, otherwise returns the default scale associated to the zone.

$o->set_background_color($color)

Use this color as background color.

$o->set_foreground_color($color)

Use this color as foreground color.

my $o_scale = $o->get_background_color()

return the objects background color.

my $o_fgc = $o->get_foreground_color()

return the objects foreground color.