]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_perl/Maasha/KISS/Draw.pm
KISS browser working, but slow
[biopieces.git] / code_perl / Maasha / KISS / Draw.pm
index 90ed4f66d53a95a6e9d0650a0a1fae74b78b0041..6a8bc52d977eb581b1d44b7e9692604176019b19 100644 (file)
@@ -42,41 +42,13 @@ use vars qw( @ISA @EXPORT );
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-sub track_text
-{
-    # Given a sequence list add this to
-    # a Cairo::Context object.
-
-    my ( $cr,         # Cairo::Context object
-         $text,       # List of hashrefs { txt =>, x => y => }
-         $color,      # Color of features 
-       ) = @_;
-
-    # Returns nothing.
-
-    $cr->set_source_rgb( color_name2rgb( $color ) );
-
-    my ( $txt );
-
-    $cr->set_font_size( 10 );
-
-    foreach $txt ( @{ $text } )
-    {
-        $cr->move_to( $txt->{ 'x' }, $txt->{ 'y' } );
-        $cr->show_text( $txt->{ 'txt' } );
-        $cr->stroke();
-    }
-}
-
-
-sub track_feature
+sub draw_feature
 {
     # Given a list of features add these to
     # a Cairo::Context object.
 
     my ( $cr,         # Cairo::Context object
          $features,   # List of features
-         $color,      # Color of features 
        ) = @_;
 
     # Returns nothing.
@@ -86,15 +58,27 @@ sub track_feature
     foreach $feature ( @{ $features } )
     {
         $cr->set_source_rgb( color_name2rgb( $feature->{ 'color' } ) );
-        $cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
 
         if ( $feature->{ 'type' } eq 'line' )
         {
             $cr->set_line_width( $feature->{ 'line_width' } );
+            $cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
             $cr->line_to( $feature->{ 'x2' }, $feature->{ 'y2' } );
         }
+        elsif ( $feature->{ 'type' } eq 'rect' )
+        {
+            $cr->rectangle(
+                $feature->{ 'x1' },
+                $feature->{ 'y1' },
+                $feature->{ 'x2' } - $feature->{ 'x1' },
+                $feature->{ 'y2' } - $feature->{ 'y1' },
+            );
+
+            $cr->fill;
+        }
         elsif ( $feature->{ 'type' } eq 'text' )
         {
+            $cr->move_to( $feature->{ 'x1' }, $feature->{ 'y1' } );
             $cr->set_font_size( $feature->{ 'font_size' } );
             $cr->show_text( $feature->{ 'txt' } );
         }