2498: def [](pdf, info)
2499: @style ||= DEFAULT_STYLE.dup
2500:
2501: case info[:status]
2502: when :start, :start_line
2503:
2504:
2505:
2506: @links ||= {}
2507:
2508: @links[info[:cbid]] = {
2509: :x => info[:x],
2510: :y => info[:y],
2511: :angle => info[:angle],
2512: :descender => info[:descender],
2513: :height => info[:height],
2514: :uri => info[:params]["uri"]
2515: }
2516:
2517: pdf.save_state
2518: pdf.fill_color @style[:text_color] if @style[:text_color]
2519: if @style[:draw_line]
2520: pdf.stroke_color @style[:color] if @style[:color]
2521: sz = info[:height] * @style[:factor]
2522: pdf.stroke_style! StrokeStyle.new(sz, @style[:line_style])
2523: end
2524: when :end, :end_line
2525:
2526:
2527: start = @links[info[:cbid]]
2528:
2529: theta = PDF::Math.deg2rad(start[:angle] - 90.0)
2530: if @style[:draw_line]
2531: drop = start[:height] * @style[:factor] * 1.5
2532: drop_x = Math.cos(theta) * drop
2533: drop_y = -Math.sin(theta) * drop
2534: pdf.move_to(start[:x] - drop_x, start[:y] - drop_y)
2535: pdf.line_to(info[:x] - drop_x, info[:y] - drop_y).stroke
2536: end
2537: pdf.add_link(start[:uri], start[:x], start[:y] +
2538: start[:descender], info[:x], start[:y] +
2539: start[:descender] + start[:height])
2540: pdf.restore_state
2541: end
2542: end