$cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
$cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
}
+ elsif ( $feature->{ 'type' } eq 'arrow' )
+ {
+ draw_arrow_horizontal(
+ $cr,
+ $feature->{ 'x1' },
+ $feature->{ 'y1' },
+ $feature->{ 'x2' },
+ $feature->{ 'y2' },
+ $feature->{ 'strand' },
+ );
+
+ }
elsif ( $feature->{ 'type' } eq 'rect' )
{
$cr->rectangle(
}
+sub draw_arrow_horizontal
+{
+ # Draws a horizontal arraw that
+ # consists of a shaft and arrow head.
+
+ my ( $cr, # Cairo::Context object
+ $x1,
+ $y1,
+ $x2,
+ $y2,
+ $strand,
+ ) = @_;
+
+ # Returns nothing.
+
+ my ( $x_diff, $y_diff, $mid, $width, $s_width );
+
+ $x_diff = abs( $x2 - $x1 );
+ $y_diff = abs( $y2 - $y1 );
+
+ $mid = $y_diff / 2;
+
+ if ( $x_diff < $mid ) {
+ $width = $x_diff;
+ } else {
+ $width = $mid;
+ }
+
+ # Draw arrow head
+
+ $cr->set_line_width( 1 );
+
+ if ( $strand eq '+' )
+ {
+ $cr->move_to( $x2 - $width, $y1 );
+ $cr->line_to( $x2, $y1 + $mid );
+ $cr->line_to( $x2 - $width, $y2 );
+ }
+ else
+ {
+ $cr->move_to( $x1 + $width, $y1 );
+ $cr->line_to( $x1, $y1 + $mid );
+ $cr->line_to( $x1 + $width, $y2 );
+ }
+
+ $cr->close_path;
+ $cr->fill_preserve;
+ $cr->stroke;
+
+ # Draw arrow shaft
+
+ if ( $x_diff > $mid )
+ {
+ if ( $strand eq '+' ) {
+ $cr->rectangle( $x1, $y1, ( $x2 - $width ) - $x1, $y2 - $y1 );
+ } else {
+ $cr->rectangle( $x1 + $width, $y1, $x2 - ( $x1 + $width ), $y2 - $y1 );
+ }
+
+ $cr->fill_preserve;
+ $cr->stroke;
+ }
+}
+
+
sub palette
{
# Martin A. Hansen, November 2009.
# Returns a list.
- my ( $factor, $entry, $y_step, @ladder, $y_max, $w, $x1, $y1, $x2, $y2, @features );
-
- # @{ $entries } = sort { $a->[ S_BEG ] <=> $b->[ S_BEG ] or $b->[ S_END ] <=> $a->[ S_END ] } @{ $entries };
+ my ( $factor, $entry, $y_step, @ladder, $y_max, $w, $x1, $y1, $x2, $y2, $feature, @features );
$factor = $cookie->{ 'IMG_WIDTH' } / ( $end - $beg + 1 );
$y_step = 0;
$y1 = $cookie->{ 'TRACK_OFFSET' } + ( ( 0.1 + $cookie->{ 'FEAT_WIDTH' } ) * $y_step );
- push @features, {
- type => 'rect',
+ $feature = {
line_width => $cookie->{ 'FEAT_WIDTH' },
color => $cookie->{ 'FEAT_COLOR' },
- title => "Q_ID: $entry->[ Q_ID ] S_BEG: $entry->[ S_BEG ] S_END: $entry->[ S_END ] STRAND: $entry->[ STRAND ]",
+ title => "Q_ID: $entry->[ Q_ID ] S_BEG: $entry->[ S_BEG ] S_END: $entry->[ S_END ]",
q_id => $entry->[ Q_ID ],
s_beg => $entry->[ S_BEG ],
s_end => $entry->[ S_END ],
y2 => $y1 + $cookie->{ 'FEAT_WIDTH' },
};
+ if ( $entry->[ STRAND ] eq '+' or $entry->[ STRAND ] eq '-' ) {
+ $feature->{ 'type' } = 'arrow';
+ } else {
+ $feature->{ 'type' } = 'rect';
+ }
+
+ push @features, $feature;
+
$y_max = Maasha::Calc::max( $y_max, $y_step * ( 0.1 + $cookie->{ 'FEAT_WIDTH' } ) );
push @features, feature_align( $entry, $beg, $y1, $factor, $cookie->{ 'FEAT_WIDTH' } ) if $entry->[ ALIGN ] ne '.';