@@ -38,12 +38,6 @@ class Axes < Base
3838 attr_reader :figure
3939 # Array of plots contained in this Axes.
4040 attr_reader :plots
41- # Position of this Axes object in the subplots.
42- attr_reader :position
43- # Width in pixels of the graph
44- attr_reader :width
45- # Height in pixels of the graph
46- attr_reader :height
4741 # data variables for something
4842 attr_reader :raw_rows
4943 attr_reader :backend
@@ -54,19 +48,12 @@ class Axes < Base
5448
5549 attr_reader :label_stagger_height
5650 # FIXME: possibly disposable attrs
57- attr_reader :graph_height , :title_caps_height , :graph_bottom
58- # left margin of the actual plot
59- attr_reader :graph_left
60- # top margin of the actual plot to leave space for the title
61- attr_reader :graph_top
62- # total width of the actual graph
63- attr_reader :graph_width
51+ attr_reader :title_caps_height
52+ attr_reader :top_spacing
6453
6554 # @param figure [Rubyplot::Figure] Figure object to which this Axes belongs.
66- # @param position [Integer] Position among the rest of the Axes in the Figure.
67- def initialize figure , width , height , position
55+ def initialize figure
6856 @figure = figure
69- @position = position
7057
7158 @x_title = ''
7259 @y_title = ''
@@ -86,8 +73,6 @@ def initialize figure, width, height, position
8673 @y_axis_padding = :default
8774 @x_ticks = { }
8875 @plots = [ ]
89- @width = width
90- @height = height
9176
9277 @raw_rows = @width * ( @height /@width )
9378
@@ -162,6 +147,25 @@ def stacked_bar! *args, &block
162147 def write file_name
163148 @plots [ 0 ] . write file_name
164149 end
150+
151+ # Absolute X co-ordinate of the Axes. Top left corner.
152+ def abs_x
153+ @figure . top_spacing * @figure . abs_height + @figure . abs_x
154+ end
155+
156+ # Absolute Y co-ordinate of the Axes. Top left corner.
157+ def abs_y
158+ @figure . top_spacing * @figure . abs_height + @figure . abs_y
159+ end
160+ # Absolute width of the Axes in pixels.
161+ def abs_width
162+ ( @figure . left_spacing + @figure . right_spacing ) * @figure . abs_width
163+ end
164+
165+ # Absolute height of the Axes in pixels.
166+ def abs_height
167+ ( @figure . top_spacing + @figure . bottom_spacing ) * @figure . abs_height
168+ end
165169
166170 private
167171
@@ -241,7 +245,7 @@ def setup_default_theme
241245 # * X/Y offsets
242246 def setup_drawing
243247 calculate_spread
244- normalize
248+ normalize # FIXME: maybe doesnt need to go here.
245249 setup_graph_measurements
246250 end
247251
@@ -267,6 +271,11 @@ def normalize
267271 # It calcuates the measurments in pixels to figure out the positioning
268272 # gap pixels of Legends, Labels and Titles from the picture edge.
269273 def setup_graph_measurements
274+ calculate_font_spaces
275+ calculate_top_spacing
276+ calculate_left_spacing
277+ calculate_bottom_spacing
278+ calculate_right_spacing
270279 @marker_caps_height = @backend . caps_height @font , @marker_font_size
271280 @title_caps_height = @geometry . hide_title || @title . nil? ? 0 :
272281 @backend . caps_height ( @font , @title_font_size ) * @title . lines . to_a . size
@@ -328,6 +337,12 @@ def setup_graph_measurements
328337 @graph_height = @graph_bottom - @graph_top
329338 end
330339
340+ # Consider the various fonts that in use in this graph and calculate the
341+ # ratio of the space that they will occupy w.r.t the Axes.
342+ def calculate_font_spaces
343+
344+ end
345+
331346 # Return a formatted string representing a number value that should be
332347 # printed as a label.
333348 def label_string ( value , increment )
0 commit comments