def draw(context, rect, border, plots=Array.new, axes_top = true, grid_top = false)
border.top, border.bottom = border.bottom, border.top
context.windowspace = rect.cut(border)
border.top, border.bottom = border.bottom, border.top
grid_figures = Array.new
plot_figures = Array.new
axes_figures = Array.new
top_figures = Array.new
@figures.each do |figure|
case figure.layer
when :grid
grid_figures << figure
when :plots
plot_figures << figure
when :axes
axes_figures << figure
when :figure
top_figures << figure
end
end
if !grid_top
grid_figures.each{ |figure| figure.draw(context, @space)}
@grid.draw(context, @space) if @grid
end
if !axes_top
axes_figures.each{ |figure| figure.draw(context, @space)}
@axes.draw(context, @space) if @axes
end
plot_figures.each{ |figure| figure.draw(context, @space)}
context.clip = true
draw_naked(context)
plots.each { |plot| plot.draw_naked(context) }
context.clip = false
if grid_top
grid_figures.each{ |figure| figure.draw(context, @space)}
@grid.draw(context, @space) if @grid
end
if axes_top
axes_figures.each{ |figure| figure.draw(context, @space)}
@axes.draw(context, @space) if @axes
end
top_figures.each{ |figure| figure.draw(context, @space)}
if @history
all_plots = Array.new
all_plots << self
all_plots.insert(1, *plots)
@history.plots = all_plots
@history.draw(context, @space)
end
if @title
neworigin = context.inverse_transform(Point.new(rect.x,rect.y))
@title.rect = Rect.new(neworigin.x,neworigin.y-border.top, rect.width, border.top)
@title.draw(context, @space)
end
if @description
neworigin = context.inverse_transform(Point.new(rect.x,rect.y+rect.height))
@description.rect = Rect.new(neworigin.x,neworigin.y, rect.width, border.bottom)
@description.draw(context, @space)
end
end