Update of /cvsroot/gmod/cmap/lib/Bio/GMOD/CMap/Drawer
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6407/lib/Bio/GMOD/CMap/Drawer
Modified Files:
Map.pm
Log Message:
Made major speed increases by implementing a system where if there are too many labels to fit on a map, only the labels that correspond to drawn features (as opposed to collapesed features) will even be considered.
Moved the area box creation code for labels to where it will only be implemented when a label is actually being drawn (thus not executing it for labels that won't be drawn).
Index: Map.pm
===================================================================
RCS file: /cvsroot/gmod/cmap/lib/Bio/GMOD/CMap/Drawer/Map.pm,v
retrieving revision 1.175
retrieving revision 1.176
diff -C2 -d -r1.175 -r1.176
*** Map.pm 19 Aug 2005 17:14:52 -0000 1.175
--- Map.pm 15 Sep 2005 20:27:00 -0000 1.176
***************
*** 1070,1075 ****
$_->{'drawing_lane'},
$_->{'drawing_priority'},
! defined $_->{'feature_start'} ? $_->{'feature_start'} : 0,
! defined $_->{'feature_stop'} ? $_->{'feature_stop'} : 0,
]
} values %{ $map->{'features'} }
--- 1070,1075 ----
$_->{'drawing_lane'},
$_->{'drawing_priority'},
! ( $_->{'feature_start'} || 0 ),
! ( $_->{'feature_stop'} || 0 ),
]
} values %{ $map->{'features'} }
***************
*** 1438,1441 ****
--- 1438,1455 ----
: $map_base_x;
}
+
+ # If the labels aren't going to fit, don't deal with the ones
+ # that are on collapsed features.
+ my $label_collapsed_features = 1;
+ my $magic_label_height_ratio = 3;
+ if (
+ $drawer->label_features eq 'none'
+ or
+ ( ( $pixel_height * $magic_label_height_ratio ) / $font_height )
+ < ( scalar(@$lane_features) )
+ )
+ {
+ $label_collapsed_features = 0;
+ }
my %drawn_glyphs;
for my $feature (@$lane_features) {
***************
*** 1444,1450 ****
my $color;
my $label_y;
! ( $leftmostf, $rightmostf, $coords, $color, $label_y ) =
! $self->add_feature_to_map(
base_x => $map_base_x,
map_base_y => $map_placement_data{$map_id}{'map_coords'}[1],
--- 1458,1468 ----
my $color;
my $label_y;
+ my $glyph_drawn = 0;
! (
! $leftmostf, $rightmostf, $coords,
! $color, $label_y, $glyph_drawn
! )
! = $self->add_feature_to_map(
base_x => $map_base_x,
map_base_y => $map_placement_data{$map_id}{'map_coords'}[1],
***************
*** 1466,1485 ****
map_width => $map_width,
);
! $self->collect_labels_to_display(
! even_labels => \%even_labels,
! map_id => $map_id,
! slot_no => $slot_no,
! is_flipped => $is_flipped,
! show_labels => $show_labels,
! drawer => $drawer,
! feature => $feature,
! coords => $coords,
! color => $color,
! midpoint => $midpoint,
! label_y => $label_y,
! feature_type_accs => \%feature_type_accs,
! features_with_corr => \%features_with_corr,
! map_base_y => $map_placement_data{$map_id}{'map_coords'}[1],
! );
########################################
}
--- 1484,1506 ----
map_width => $map_width,
);
! if ( $label_collapsed_features or $glyph_drawn ) {
! $self->collect_labels_to_display(
! even_labels => \%even_labels,
! map_id => $map_id,
! slot_no => $slot_no,
! is_flipped => $is_flipped,
! show_labels => $show_labels,
! drawer => $drawer,
! feature => $feature,
! coords => $coords,
! color => $color,
! midpoint => $midpoint,
! label_y => $label_y,
! feature_type_accs => \%feature_type_accs,
! features_with_corr => \%features_with_corr,
! map_base_y =>
! $map_placement_data{$map_id}{'map_coords'}[1],
! );
! }
########################################
}
***************
*** 2915,2920 ****
$draw_this = 0;
}
- if ($draw_this) {
my $omit_area_boxes = $drawer->omit_area_boxes;
my $reg_font = $drawer->regular_font
--- 2936,2943 ----
$draw_this = 0;
}
+ # save this value for export
+ my $glyph_drawn = $draw_this;
+ if ($draw_this) {
my $omit_area_boxes = $drawer->omit_area_boxes;
my $reg_font = $drawer->regular_font
***************
*** 3053,3057 ****
$label_y = $drawn_glyphs->{$glyph_key}->[1];
}
! return ( $leftmostf, $rightmostf, \@coords, $color, $label_y );
}
--- 3076,3081 ----
$label_y = $drawn_glyphs->{$glyph_key}->[1];
}
! return ( $leftmostf, $rightmostf, \@coords, $color, $label_y,
! $glyph_drawn );
}
***************
*** 3081,3085 ****
my $label = $feature->{'feature_name'};
my $has_corr = $drawer->has_correspondence( $feature->{'feature_id'} );
- my $feature_details_url = DEFAULT->{'feature_details_url'};
my $is_highlighted = $drawer->highlight_feature(
--- 3105,3108 ----
***************
*** 3114,3125 ****
{
- my $code = '';
- my $url = $feature_details_url . $feature->{'feature_acc'};
- my $alt =
- 'Feature Details: '
- . $feature->{'feature_name'} . ' ['
- . $feature->{'feature_acc'} . ']';
- eval $self->feature_type_data( $feature->{'feature_type_acc'},
- 'area_code' );
my $even_label_key =
$is_highlighted ? 'highlights'
--- 3137,3140 ----
***************
*** 3128,3132 ****
push @{ $even_labels->{$even_label_key} },
{
! priority => $feature->{'drawing_priority'},
text => $label,
target => $label_y,
--- 3143,3147 ----
push @{ $even_labels->{$even_label_key} },
{
! feature => $feature,
text => $label,
target => $label_y,
***************
*** 3135,3148 ****
is_highlighted => $is_highlighted,
feature_coords => $coords,
- feature_mid_y => $feature->{'mid_y'},
- feature_type => $feature->{'feature_type'},
has_corr => $has_corr,
- feature_id => $feature->{'feature_id'},
- feature_start => $feature->{'feature_start'},
- shape => $feature->{'shape'},
- column => $feature->{'column'},
- url => $url,
- alt => $alt,
- code => $code,
};
}
--- 3150,3154 ----
***************
*** 3188,3191 ****
--- 3194,3198 ----
my $feature_highlight_bg_color =
$drawer->config_data('feature_highlight_bg_color');
+ my $feature_details_url = DEFAULT->{'feature_details_url'};
#my @accepted_labels; # the labels we keep
***************
*** 3208,3211 ****
--- 3215,3219 ----
for my $label (@$accepted_labels) {
my $text = $label->{'text'};
+ my $feature = $label->{'feature'};
my $label_y = $label->{'y'};
my $label_len = $font_width * length($text);
***************
*** 3242,3251 ****
}
push @$map_area_data,
{
coords => \@label_bounds,
! url => $label->{'url'},
! alt => $label->{'alt'},
! code => $label->{'code'},
}
unless ($omit_area_boxes);
--- 3250,3267 ----
}
+ my $code = '';
+ my $url = $feature_details_url . $feature->{'feature_acc'};
+ my $alt =
+ 'Feature Details: '
+ . $feature->{'feature_name'} . ' ['
+ . $feature->{'feature_acc'} . ']';
+ eval $self->feature_type_data( $feature->{'feature_type_acc'},
+ 'area_code' );
push @$map_area_data,
{
coords => \@label_bounds,
! url => $url,
! alt => $alt,
! code => $code,
}
unless ($omit_area_boxes);
***************
*** 3268,3272 ****
my $label_connect_y1 =
$label_side eq RIGHT
! ? $label->{'feature_mid_y'}
: $label_y + $font_height / 2;
--- 3284,3288 ----
my $label_connect_y1 =
$label_side eq RIGHT
! ? $feature->{'mid_y'}
: $label_y + $font_height / 2;
***************
*** 3279,3288 ****
$label_side eq RIGHT
? $label_y + $font_height / 2
! : $label->{'feature_mid_y'};
#
# Back the connection off.
#
! if ( $label->{'shape'} eq LINE ) {
if ( $label_side eq RIGHT ) {
$label_connect_x1 += $buffer;
--- 3295,3304 ----
$label_side eq RIGHT
? $label_y + $font_height / 2
! : $feature->{'mid_y'};
#
# Back the connection off.
#
! if ( $feature->{'shape'} eq LINE ) {
if ( $label_side eq RIGHT ) {
$label_connect_x1 += $buffer;
***************
*** 3304,3310 ****
# corresponding features.
#
! if ( defined $features_with_corr->{ $label->{'feature_id'} } ) {
if ( $label_side eq RIGHT ) {
! $features_with_corr->{ $label->{'feature_id'} }{'right'} = [
$label_bounds[2],
(
--- 3320,3326 ----
# corresponding features.
#
! if ( defined $features_with_corr->{ $feature->{'feature_id'} } ) {
if ( $label_side eq RIGHT ) {
! $features_with_corr->{ $feature->{'feature_id'} }{'right'} = [
$label_bounds[2],
(
***************
*** 3315,3319 ****
}
else {
! $features_with_corr->{ $label->{'feature_id'} }{'left'} = [
$label_bounds[0],
(
--- 3331,3335 ----
}
else {
! $features_with_corr->{ $feature->{'feature_id'} }{'left'} = [
$label_bounds[0],
(
|