1 package Maasha::KISS::Track;
3 # Copyright (C) 2009 Martin A. Hansen.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
22 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
25 # Routines for creating KISS tracks.
28 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
35 use vars qw( @ISA @EXPORT );
37 @ISA = qw( Exporter );
40 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
45 my ( $entries, # list of KISS entries
50 @{ $entries } = sort { $a->{ 'S_BEG' } <=> $b->{ 'S_BEG' } or
51 $a->{ 'S_END' } <=> $b->{ 'S_END' } } @{ $entries };
57 my ( $width, # draw window width
58 $y_offset, # y axis draw offset
59 $beg, # base window beg
60 $end, # base window end
61 $entries, # list of sorted KISS entries
66 my ( $factor, $entry, $y_step, @ladder, $i, $x, $y, $w, @features );
68 $factor = $width / ( $end - $beg );
71 foreach $entry ( @{ $entries } )
73 $w = sprintf( "%.0f", ( $entry->{ 'S_END' } - $entry->{ 'S_BEG' } + 1 ) * $factor );
77 $x = sprintf( "%.0f", $entry->{ 'S_BEG' } * $factor );
79 for ( $y_step = 0; $y_step < @ladder; $y_step++ )
81 last if $x >= $ladder[ $y_step ] + 1;
84 $y = $y_offset + ( 5 * $y_step );
87 id => $entry->{ 'Q_ID' },
94 $ladder[ $y_step ] = $x + $w;
98 return wantarray ? @features : \@features;
102 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<