2525: def [](pdf, info)
2526: @style ||= DEFAULT_STYLE.dup
2527:
2528: case info[:status]
2529: when :start, :start_line
2530:
2531:
2532:
2533: @links ||= {}
2534:
2535: @links[info[:cbid]] = {
2536: :x => info[:x],
2537: :y => info[:y],
2538: :angle => info[:angle],
2539: :descender => info[:descender],
2540: :height => info[:height],
2541: :uri => info[:params]["uri"]
2542: }
2543:
2544: pdf.save_state
2545: pdf.fill_color @style[:text_color] if @style[:text_color]
2546: if @style[:draw_line]
2547: pdf.stroke_color @style[:color] if @style[:color]
2548: sz = info[:height] * @style[:factor]
2549: pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style])
2550: end
2551: when :end, :end_line
2552:
2553:
2554: start = @links[info[:cbid]]
2555:
2556: theta = PDF::Math.deg2rad(start[:angle] - 90.0)
2557: if @style[:draw_line]
2558: drop = start[:height] * @style[:factor] * 1.5
2559: drop_x = Math.cos(theta) * drop
2560: drop_y = -Math.sin(theta) * drop
2561: pdf.move_to(start[:x] - drop_x, start[:y] - drop_y)
2562: pdf.line_to(info[:x] - drop_x, info[:y] - drop_y).stroke
2563: end
2564: pdf.add_link(start[:uri], start[:x], start[:y] +
2565: start[:descender], info[:x], start[:y] +
2566: start[:descender] + start[:height])
2567: pdf.restore_state
2568: end
2569: end