Skip to content

Commit

Permalink
Merge pull request #8 from mikisvaz/master
Browse files Browse the repository at this point in the history
Allow arbitrary params in SVG objects
  • Loading branch information
danmaclean committed Jul 9, 2013
2 parents 1adba75 + 61a5ebb commit 2bbfe84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/bio/graphics/mini_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Graphics
#A Bio::Graphics::MiniFeature object represents a single genomic feature (e.g. a gene, transcript, exon, start codon, etc), it is a lightweight object that
#holds the minimum information needed to do the render.
class MiniFeature
attr_accessor :start, :end, :strand, :exons, :utrs, :block_gaps, :segment_height, :id
attr_accessor :start, :end, :strand, :exons, :utrs, :block_gaps, :segment_height, :id, :params
#Creates a new MiniFeature
#
#== args
Expand Down Expand Up @@ -41,8 +41,9 @@ def initialize(args)
@block_gaps = []
@id = args[:id]
@segment_height = args[:segment_height]
@params = args[:params]
end
end

end
end
end
5 changes: 3 additions & 2 deletions lib/bio/graphics/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ def draw_features(track)
:exons => f.exons,
:utrs => f.utrs,
:block_gaps => f.block_gaps,
:height => track.feature_height
:height => track.feature_height,
:params => f.params
}.merge!(track.args))

if f.id
Expand Down Expand Up @@ -398,4 +399,4 @@ def write(file)
end
end
end
end
end
7 changes: 5 additions & 2 deletions lib/bio/graphics/svgee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def text_tag(a = {})
end

def common_attributes(a={})
%{stroke="#{a[:stroke]}" stroke-width="#{a[:stroke_width]}" style="#{a[:style]}"}
param_str = ""
a[:params].each{|k,v| param_str << %{ #{k}="#{v}"}} if a[:params]

%{stroke="#{a[:stroke]}" stroke-width="#{a[:stroke_width]}" style="#{a[:style]}"} + param_str
end

def method_missing(primitive, args={}) #only used to dynamically select the primitive type..
Expand Down Expand Up @@ -142,4 +145,4 @@ def draw
s.add_primitive(prim) #add one of the returned, updated Primitive objects
s.draw
=end
=end

0 comments on commit 2bbfe84

Please sign in to comment.