prep 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/examples/generate_sample7.rb +40 -0
- data/examples/sample.yml +28 -0
- data/examples/sample7.yml +130 -0
- data/lib/core/arc_rectangle.rb +168 -0
- data/lib/core/group.rb +10 -0
- data/lib/core/loop.rb +40 -4
- data/lib/core/page.rb +2 -0
- data/lib/core/prep.rb +2 -0
- data/lib/core/rectangle.rb +9 -2
- metadata +26 -29
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "prep")
|
2
|
+
|
3
|
+
prep = PREP::Core::Prep.new("sample7.yml")
|
4
|
+
values = {
|
5
|
+
:content => {
|
6
|
+
:out_table => {
|
7
|
+
:header => { :header_title => "hoge" },
|
8
|
+
:values => [
|
9
|
+
{
|
10
|
+
:inner_table => {
|
11
|
+
:header => { :inner_table_header_title => "First" },
|
12
|
+
:values => [
|
13
|
+
{ :inner_table_content_column01_label => "1-1" },
|
14
|
+
{ :inner_table_content_column01_label => "1-2" },
|
15
|
+
],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
{
|
19
|
+
:inner_table => {
|
20
|
+
:header => { :inner_table_header_title => "Second" },
|
21
|
+
:values => [
|
22
|
+
{ :inner_table_content_column01_label => "2-1" },
|
23
|
+
{ :inner_table_content_column01_label => "2-2" },
|
24
|
+
],
|
25
|
+
},
|
26
|
+
},
|
27
|
+
{
|
28
|
+
:inner_table => {
|
29
|
+
:header => { :inner_table_header_title => "Third" },
|
30
|
+
:values => [
|
31
|
+
{ :inner_table_content_column01_label => "3-1" },
|
32
|
+
{ :inner_table_content_column01_label => "3-2" },
|
33
|
+
],
|
34
|
+
},
|
35
|
+
},
|
36
|
+
],
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
prep.generate("#{$0}.pdf", values)
|
data/examples/sample.yml
CHANGED
@@ -88,3 +88,31 @@ content:
|
|
88
88
|
y: 10
|
89
89
|
width: 10
|
90
90
|
height: 10
|
91
|
+
# arc_rect_rect:
|
92
|
+
# type: rectangle
|
93
|
+
# region:
|
94
|
+
# x: 50
|
95
|
+
# y: 200
|
96
|
+
# width: 100
|
97
|
+
# height: 30
|
98
|
+
# line_color:
|
99
|
+
# red: 0
|
100
|
+
# green: 0
|
101
|
+
# blue: 1
|
102
|
+
arc_rect:
|
103
|
+
type: arc_rectangle
|
104
|
+
line_width: 10
|
105
|
+
region:
|
106
|
+
x: 50
|
107
|
+
y: 200
|
108
|
+
width: 100
|
109
|
+
height: 30
|
110
|
+
line_color:
|
111
|
+
red: 1
|
112
|
+
green: 0
|
113
|
+
blue: 1
|
114
|
+
fill_color:
|
115
|
+
red: 0
|
116
|
+
green: 1
|
117
|
+
blue: 1
|
118
|
+
round_arc: 5
|
@@ -0,0 +1,130 @@
|
|
1
|
+
page:
|
2
|
+
size: a4
|
3
|
+
orientation: portrait
|
4
|
+
margin:
|
5
|
+
top: 10
|
6
|
+
left: 10
|
7
|
+
bottom: 10
|
8
|
+
right: 10
|
9
|
+
content:
|
10
|
+
type: group
|
11
|
+
out_table:
|
12
|
+
type: loop
|
13
|
+
x: 0
|
14
|
+
y: 0
|
15
|
+
direction: vertical
|
16
|
+
fixed_times: 2
|
17
|
+
page_break: false
|
18
|
+
gap: 0
|
19
|
+
header: out_table_header
|
20
|
+
iterator: out_table_content
|
21
|
+
footer: out_table_footer
|
22
|
+
|
23
|
+
# 外側のテーブル定義
|
24
|
+
out_table_content:
|
25
|
+
type: group
|
26
|
+
inner_table:
|
27
|
+
type: loop
|
28
|
+
x: 0
|
29
|
+
y: 0
|
30
|
+
direction: horizontal
|
31
|
+
fixed_times: 4
|
32
|
+
at_least_one: true
|
33
|
+
page_break: false
|
34
|
+
gap: 0
|
35
|
+
header: inner_table_header
|
36
|
+
iterator: inner_table_content
|
37
|
+
footer: inner_table_footer
|
38
|
+
out_table_header:
|
39
|
+
type: group
|
40
|
+
out_table_header_label:
|
41
|
+
type: label
|
42
|
+
label: 外側のテーブルヘッダ
|
43
|
+
align: center
|
44
|
+
expand: true
|
45
|
+
region:
|
46
|
+
x: 0
|
47
|
+
y: 0
|
48
|
+
width: 30
|
49
|
+
height: 10
|
50
|
+
out_table_header_rect:
|
51
|
+
type: rectangle
|
52
|
+
expand: true
|
53
|
+
region:
|
54
|
+
x: 0
|
55
|
+
y: 0
|
56
|
+
width: 30
|
57
|
+
height: 10
|
58
|
+
out_table_footer:
|
59
|
+
type: group
|
60
|
+
out_table_footer_label:
|
61
|
+
type: label
|
62
|
+
label: 外側のテーブルフッタ
|
63
|
+
align: center
|
64
|
+
expand: true
|
65
|
+
region:
|
66
|
+
x: 0
|
67
|
+
y: 0
|
68
|
+
width: 30
|
69
|
+
height: 10
|
70
|
+
out_table_header_rect:
|
71
|
+
type: rectangle
|
72
|
+
expand: true
|
73
|
+
region:
|
74
|
+
x: 0
|
75
|
+
y: 0
|
76
|
+
width: 30
|
77
|
+
height: 10
|
78
|
+
|
79
|
+
# 内側のテーブル定義
|
80
|
+
inner_table_content:
|
81
|
+
type: group
|
82
|
+
inner_table_content_column01_label:
|
83
|
+
type: label
|
84
|
+
label: 値1
|
85
|
+
region:
|
86
|
+
x: 0
|
87
|
+
y: 0
|
88
|
+
width: 30
|
89
|
+
height: 10
|
90
|
+
inner_table_content_column01_rect:
|
91
|
+
type: rectangle
|
92
|
+
region:
|
93
|
+
x: 0
|
94
|
+
y: 0
|
95
|
+
width: 30
|
96
|
+
height: 10
|
97
|
+
inner_table_header:
|
98
|
+
type: group
|
99
|
+
inner_table_header_title:
|
100
|
+
type: label
|
101
|
+
label: 内側のテーブルヘッダ
|
102
|
+
region:
|
103
|
+
x: 0
|
104
|
+
y: 0
|
105
|
+
width: 30
|
106
|
+
height: 10
|
107
|
+
inner_table_header_column01_rect:
|
108
|
+
type: rectangle
|
109
|
+
region:
|
110
|
+
x: 0
|
111
|
+
y: 0
|
112
|
+
width: 30
|
113
|
+
height: 10
|
114
|
+
inner_table_footer:
|
115
|
+
type: group
|
116
|
+
inner_table_footer_column01_label:
|
117
|
+
type: label
|
118
|
+
label: 内側のテーブルフッタ
|
119
|
+
region:
|
120
|
+
x: 0
|
121
|
+
y: 0
|
122
|
+
width: 30
|
123
|
+
height: 10
|
124
|
+
inner_table_footer_column01_rect:
|
125
|
+
type: rectangle
|
126
|
+
region:
|
127
|
+
x: 0
|
128
|
+
y: 0
|
129
|
+
width: 30
|
130
|
+
height: 10
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# ArcRectangle クラスのソースファイル
|
3
|
+
# Author:: maki-tetsu
|
4
|
+
# Date:: 2011/10/10
|
5
|
+
# Copyright:: Copyright (c) 2011 maki-tetsu
|
6
|
+
|
7
|
+
require File.join(File.dirname(__FILE__), "drawable")
|
8
|
+
require File.join(File.dirname(__FILE__), "color")
|
9
|
+
require File.join(File.dirname(__FILE__), "region")
|
10
|
+
require File.join(File.dirname(__FILE__), "rectangle")
|
11
|
+
require File.join(File.dirname(__FILE__), "..", "mm2pixcel")
|
12
|
+
|
13
|
+
module PREP # nodoc
|
14
|
+
module Core # nodoc
|
15
|
+
# 角丸矩形描画構成要素クラス
|
16
|
+
class ArcRectangle < Rectangle
|
17
|
+
@@default_values[:round_arc] = nil
|
18
|
+
|
19
|
+
attr_reader :round_arc
|
20
|
+
|
21
|
+
def initialize(identifier, values = { })
|
22
|
+
values = @@default_values.merge(key_string_to_symbol(values))
|
23
|
+
@round_arc = values.delete(:round_arc)
|
24
|
+
|
25
|
+
if @round_arc.nil?
|
26
|
+
raise "round_arc must be specified for arc_rectangle."
|
27
|
+
else
|
28
|
+
@round_arc = @round_arc.mm2pixcel
|
29
|
+
end
|
30
|
+
|
31
|
+
super(identifier, values)
|
32
|
+
end
|
33
|
+
|
34
|
+
# 角丸矩形の描画
|
35
|
+
def draw(prep, region, values, stop_on_drawable = nil)
|
36
|
+
if self === stop_on_drawable
|
37
|
+
raise ReRenderJump.new(region)
|
38
|
+
end
|
39
|
+
STDERR.puts("Draw on #{self.class} #{self.identifier}") if ENV['DEBUG']
|
40
|
+
# 領域判定
|
41
|
+
calculate_region(prep, region, values)
|
42
|
+
# 円弧描画時は 5% 太さを上げる
|
43
|
+
prep.current_page.set_line_width(@line_width.to_f * 1.05)
|
44
|
+
unless @line_color.white?
|
45
|
+
prep.current_page.set_rgb_stroke(@line_color.red.to_f,
|
46
|
+
@line_color.green.to_f,
|
47
|
+
@line_color.blue.to_f)
|
48
|
+
end
|
49
|
+
unless @fill_color.white?
|
50
|
+
prep.current_page.set_rgb_fill(@fill_color.red.to_f,
|
51
|
+
@fill_color.green.to_f,
|
52
|
+
@fill_color.blue.to_f)
|
53
|
+
end
|
54
|
+
region_backup = @region.dup
|
55
|
+
if @expand_region
|
56
|
+
@region = @expand_region.dup
|
57
|
+
@expand_region = nil
|
58
|
+
end
|
59
|
+
pos_x, pos_y = calculate_pos(prep.current_page, region, @region.x, @region.y)
|
60
|
+
|
61
|
+
### 塗り潰し描画
|
62
|
+
unless @fill_color.white?
|
63
|
+
# 縦方向
|
64
|
+
prep.current_page.rectangle(pos_x + @round_arc, pos_y - @region.height,
|
65
|
+
@region.width - (@round_arc * 2), @region.height)
|
66
|
+
prep.current_page.fill
|
67
|
+
# 横方向
|
68
|
+
prep.current_page.rectangle(pos_x, pos_y - @region.height + @round_arc,
|
69
|
+
@region.width, @region.height - (@round_arc * 2))
|
70
|
+
prep.current_page.fill
|
71
|
+
end
|
72
|
+
|
73
|
+
# ここからが本番
|
74
|
+
### 4角の円弧を描画
|
75
|
+
# 左上
|
76
|
+
unless @fill_color.white?
|
77
|
+
prep.current_page.move_to(pos_x + @round_arc, pos_y - @round_arc)
|
78
|
+
prep.current_page.line_to(pos_x, pos_y - @round_arc)
|
79
|
+
prep.current_page.arc(pos_x + @round_arc,
|
80
|
+
pos_y - @round_arc,
|
81
|
+
@round_arc, 360 * 0.75, 360)
|
82
|
+
prep.current_page.line_to(pos_x + @round_arc, pos_y - @round_arc)
|
83
|
+
prep.current_page.fill
|
84
|
+
end
|
85
|
+
unless @line_color.white?
|
86
|
+
prep.current_page.arc(pos_x + @round_arc,
|
87
|
+
pos_y - @round_arc,
|
88
|
+
@round_arc, 360 * 0.75, 360)
|
89
|
+
prep.current_page.stroke
|
90
|
+
end
|
91
|
+
# 右上
|
92
|
+
unless @fill_color.white?
|
93
|
+
prep.current_page.move_to(pos_x + @region.width - @round_arc, pos_y - @round_arc)
|
94
|
+
prep.current_page.line_to(pos_x + @region.width - @round_arc, pos_y)
|
95
|
+
prep.current_page.arc(pos_x + @region.width - @round_arc,
|
96
|
+
pos_y - @round_arc,
|
97
|
+
@round_arc, 0, 360 * 0.25)
|
98
|
+
prep.current_page.line_to(pos_x + @region.width - @round_arc, pos_y - @round_arc)
|
99
|
+
prep.current_page.fill
|
100
|
+
end
|
101
|
+
unless @line_color.white?
|
102
|
+
prep.current_page.arc(pos_x + @region.width - @round_arc,
|
103
|
+
pos_y - @round_arc,
|
104
|
+
@round_arc, 0, 360 * 0.25)
|
105
|
+
prep.current_page.stroke
|
106
|
+
end
|
107
|
+
# 左下
|
108
|
+
unless @fill_color.white?
|
109
|
+
prep.current_page.move_to(pos_x + @round_arc, pos_y - @region.height + @round_arc)
|
110
|
+
prep.current_page.line_to(pos_x + @round_arc, pos_y - @region.height)
|
111
|
+
prep.current_page.arc(pos_x + @round_arc,
|
112
|
+
pos_y - @region.height + @round_arc,
|
113
|
+
@round_arc, 360 * 0.5, 360 * 0.75)
|
114
|
+
prep.current_page.line_to(pos_x + @round_arc, pos_y - @region.height + @round_arc)
|
115
|
+
prep.current_page.fill
|
116
|
+
end
|
117
|
+
unless @line_color.white?
|
118
|
+
prep.current_page.arc(pos_x + @round_arc,
|
119
|
+
pos_y - @region.height + @round_arc,
|
120
|
+
@round_arc, 360 * 0.5, 360 * 0.75)
|
121
|
+
prep.current_page.stroke
|
122
|
+
end
|
123
|
+
# 右下
|
124
|
+
unless @fill_color.white?
|
125
|
+
prep.current_page.move_to(pos_x + @region.width - @round_arc, pos_y - @region.height + @round_arc)
|
126
|
+
prep.current_page.line_to(pos_x + @region.width, pos_y - @region.height + @round_arc)
|
127
|
+
prep.current_page.arc(pos_x + @region.width - @round_arc,
|
128
|
+
pos_y - @region.height + @round_arc,
|
129
|
+
@round_arc, 360 * 0.25, 360 * 0.5)
|
130
|
+
prep.current_page.line_to(pos_x + @region.width - @round_arc, pos_y - @region.height + @round_arc)
|
131
|
+
prep.current_page.fill
|
132
|
+
end
|
133
|
+
unless @line_color.white?
|
134
|
+
prep.current_page.arc(pos_x + @region.width - @round_arc,
|
135
|
+
pos_y - @region.height + @round_arc,
|
136
|
+
@round_arc, 360 * 0.25, 360 * 0.5)
|
137
|
+
prep.current_page.stroke
|
138
|
+
end
|
139
|
+
|
140
|
+
# 元の太さへ
|
141
|
+
prep.current_page.set_line_width(@line_width.to_f)
|
142
|
+
|
143
|
+
# ### 4辺描画
|
144
|
+
unless @line_color.white?
|
145
|
+
# 上
|
146
|
+
prep.current_page.move_to(pos_x + @round_arc, pos_y)
|
147
|
+
prep.current_page.line_to(pos_x + @region.width - @round_arc, pos_y)
|
148
|
+
prep.current_page.stroke
|
149
|
+
# 下
|
150
|
+
prep.current_page.move_to(pos_x + @round_arc, pos_y - @region.height)
|
151
|
+
prep.current_page.line_to(pos_x + @region.width - @round_arc, pos_y - @region.height)
|
152
|
+
prep.current_page.stroke
|
153
|
+
# 左
|
154
|
+
prep.current_page.move_to(pos_x, pos_y - @region.height + @round_arc)
|
155
|
+
prep.current_page.line_to(pos_x, pos_y - @round_arc)
|
156
|
+
prep.current_page.stroke
|
157
|
+
# 右
|
158
|
+
prep.current_page.move_to(pos_x + @region.width, pos_y - @region.height + @round_arc)
|
159
|
+
prep.current_page.line_to(pos_x + @region.width, pos_y - @round_arc)
|
160
|
+
prep.current_page.stroke
|
161
|
+
end
|
162
|
+
|
163
|
+
@region = region_backup
|
164
|
+
prep.current_page.drawed = true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/lib/core/group.rb
CHANGED
@@ -8,6 +8,7 @@ require File.join(File.dirname(__FILE__), "drawable")
|
|
8
8
|
require File.join(File.dirname(__FILE__), "label")
|
9
9
|
require File.join(File.dirname(__FILE__), "line")
|
10
10
|
require File.join(File.dirname(__FILE__), "rectangle")
|
11
|
+
require File.join(File.dirname(__FILE__), "arc_rectangle")
|
11
12
|
require File.join(File.dirname(__FILE__), "image")
|
12
13
|
require File.join(File.dirname(__FILE__), "loop")
|
13
14
|
|
@@ -91,6 +92,15 @@ module PREP # nodoc
|
|
91
92
|
end
|
92
93
|
end
|
93
94
|
end
|
95
|
+
when "arc_rectangle"
|
96
|
+
klass = ArcRectangle
|
97
|
+
unless @@allow_all
|
98
|
+
@drawables.values.each do |drawable|
|
99
|
+
if Loop === drawable
|
100
|
+
raise "Group already has Loop!!"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
94
104
|
when "image"
|
95
105
|
klass = Image
|
96
106
|
unless @@allow_all
|
data/lib/core/loop.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# Loop クラスのソースファイル
|
2
3
|
# Author:: maki-tetsu
|
3
4
|
# Date:: 2011/03/11
|
@@ -21,9 +22,11 @@ module PREP # nodoc
|
|
21
22
|
:page_break => false,
|
22
23
|
:layer => 4,
|
23
24
|
:allow_header_split => true,
|
25
|
+
:fixed_times => nil,
|
26
|
+
:at_least_one => false,
|
24
27
|
}
|
25
28
|
|
26
|
-
attr_reader :direction, :gap, :header_group, :iterator_group, :footer_group, :point, :page_break, :width, :height, :allow_header_split
|
29
|
+
attr_reader :direction, :gap, :header_group, :iterator_group, :footer_group, :point, :page_break, :width, :height, :allow_header_split, :fixed_times, :at_least_one
|
27
30
|
|
28
31
|
def initialize(identifier, values = { })
|
29
32
|
values = @@default_values.merge(key_string_to_symbol(values))
|
@@ -38,6 +41,8 @@ module PREP # nodoc
|
|
38
41
|
@point = Point.new(values[:x].mm2pixcel, values[:y].mm2pixcel)
|
39
42
|
@page_break = values[:page_break]
|
40
43
|
@allow_header_split = values[:allow_header_split]
|
44
|
+
@fixed_times = values[:fixed_times]
|
45
|
+
@at_least_one = !!values[:at_least_one]
|
41
46
|
end
|
42
47
|
|
43
48
|
def direction=(d)
|
@@ -57,7 +62,12 @@ module PREP # nodoc
|
|
57
62
|
dataset[:header] = header.generate_sample_dataset(prep)
|
58
63
|
end
|
59
64
|
iterator = prep.group(@iterator_group)
|
60
|
-
dataset[:values] =
|
65
|
+
dataset[:values] =
|
66
|
+
[
|
67
|
+
iterator.generate_sample_dataset(prep),
|
68
|
+
iterator.generate_sample_dataset(prep),
|
69
|
+
iterator.generate_sample_dataset(prep),
|
70
|
+
]
|
61
71
|
unless @footer_group.nil?
|
62
72
|
footer = prep.group(@footer_group)
|
63
73
|
dataset[:footer] = footer.generate_sample_dataset(prep)
|
@@ -288,7 +298,20 @@ module PREP # nodoc
|
|
288
298
|
# 繰返し構成要素を描画するためのメソッド
|
289
299
|
def draw_iterator(prep, region, values, stop_on_drawable = nil)
|
290
300
|
iterator = prep.group(@iterator_group)
|
291
|
-
|
301
|
+
# 固定繰り返し時のエラー回避用
|
302
|
+
if @at_least_one
|
303
|
+
values[:values] ||= [nil]
|
304
|
+
else
|
305
|
+
values[:values] ||= []
|
306
|
+
end
|
307
|
+
if !@fixed_times.nil? && !(values[:values].size % @fixed_times).zero?
|
308
|
+
iterator_times = ((values[:values].size / @fixed_times) + 1) * @fixed_times
|
309
|
+
else
|
310
|
+
iterator_times = values[:values].size
|
311
|
+
end
|
312
|
+
iterator_times.times do |index|
|
313
|
+
iterator_values = values[:values][index]
|
314
|
+
iterator_values ||= { }
|
292
315
|
begin
|
293
316
|
w, h = rewind_current_page(prep) do
|
294
317
|
iterator.calculate_region(prep, region, iterator_values, stop_on_drawable)
|
@@ -372,7 +395,20 @@ module PREP # nodoc
|
|
372
395
|
# 繰返し構成要素の描画領域を計算するためのメソッド
|
373
396
|
def calculate_iterator_region(prep, region, values, stop_on_drawable = nil)
|
374
397
|
iterator = prep.group(@iterator_group)
|
375
|
-
|
398
|
+
# 固定繰り返し時のエラー回避用
|
399
|
+
if @at_least_one
|
400
|
+
values[:values] ||= [nil]
|
401
|
+
else
|
402
|
+
values[:values] ||= []
|
403
|
+
end
|
404
|
+
if !@fixed_times.nil? && !(values[:values].size % @fixed_times).zero?
|
405
|
+
iterator_times = ((values[:values].size / @fixed_times) + 1) * @fixed_times
|
406
|
+
else
|
407
|
+
iterator_times = values[:values].size
|
408
|
+
end
|
409
|
+
iterator_times.times do |index|
|
410
|
+
iterator_values = values[:values][index]
|
411
|
+
iterator_values ||= { }
|
376
412
|
begin
|
377
413
|
w, h = iterator.calculate_region(prep, region, iterator_values, stop_on_drawable)
|
378
414
|
# 描画したので、方向に応じてリージョン補正
|
data/lib/core/page.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# Page クラスのソースファイル
|
2
3
|
# Author:: maki-tetsu
|
3
4
|
# Date:: 2011/03/11
|
@@ -13,6 +14,7 @@ module PREP # nodoc
|
|
13
14
|
class Page
|
14
15
|
# ページサイズの設定種別
|
15
16
|
SIZES = {
|
17
|
+
:a5 => HPDFDoc::HPDF_PAGE_SIZE_A5, # A5
|
16
18
|
:a4 => HPDFDoc::HPDF_PAGE_SIZE_A4, # A4
|
17
19
|
:a3 => HPDFDoc::HPDF_PAGE_SIZE_A3, # A3
|
18
20
|
}
|
data/lib/core/prep.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# Prep クラスのソースファイル
|
2
3
|
# Author:: maki-tetsu
|
3
4
|
# Date:: 2011/03/11
|
@@ -11,6 +12,7 @@ require "hpdf"
|
|
11
12
|
require File.join(File.dirname(__FILE__), "label")
|
12
13
|
require File.join(File.dirname(__FILE__), "line")
|
13
14
|
require File.join(File.dirname(__FILE__), "rectangle")
|
15
|
+
require File.join(File.dirname(__FILE__), "arc_rectangle")
|
14
16
|
require File.join(File.dirname(__FILE__), "group")
|
15
17
|
require File.join(File.dirname(__FILE__), "region")
|
16
18
|
require File.join(File.dirname(__FILE__), "page")
|
data/lib/core/rectangle.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# Rectangle クラスのソースファイル
|
2
3
|
# Author:: maki-tetsu
|
3
4
|
# Date:: 2011/03/11
|
@@ -120,6 +121,13 @@ module PREP # nodoc
|
|
120
121
|
pos_x, pos_y = calculate_pos(prep.current_page, region, @region.x, @region.y)
|
121
122
|
prep.current_page.rectangle(pos_x, pos_y - @region.height, @region.width, @region.height)
|
122
123
|
|
124
|
+
fill_and_or_stroke(prep)
|
125
|
+
|
126
|
+
@region = region_backup
|
127
|
+
prep.current_page.drawed = true
|
128
|
+
end
|
129
|
+
|
130
|
+
def fill_and_or_stroke(prep)
|
123
131
|
if @fill_color.white?
|
124
132
|
unless @line_color.white?
|
125
133
|
prep.current_page.stroke
|
@@ -129,9 +137,8 @@ module PREP # nodoc
|
|
129
137
|
else
|
130
138
|
prep.current_page.fill_stroke
|
131
139
|
end
|
132
|
-
@region = region_backup
|
133
|
-
prep.current_page.drawed = true
|
134
140
|
end
|
141
|
+
private :fill_and_or_stroke
|
135
142
|
end
|
136
143
|
end
|
137
144
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 19
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
|
8
|
+
- 1
|
9
|
+
segments_generated: true
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tetsuhisa MAKINO
|
@@ -15,87 +15,82 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-10-10 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
prerelease: false
|
23
|
-
name: hpdf
|
24
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 31
|
30
26
|
segments:
|
31
27
|
- 2
|
32
28
|
- 0
|
33
29
|
- 8
|
30
|
+
segments_generated: true
|
34
31
|
version: 2.0.8
|
35
32
|
requirement: *id001
|
33
|
+
prerelease: false
|
36
34
|
type: :runtime
|
35
|
+
name: hpdf
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
|
-
prerelease: false
|
39
|
-
name: rspec
|
40
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ~>
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
41
|
segments:
|
47
42
|
- 2
|
48
43
|
- 3
|
49
44
|
- 0
|
45
|
+
segments_generated: true
|
50
46
|
version: 2.3.0
|
51
47
|
requirement: *id002
|
48
|
+
prerelease: false
|
52
49
|
type: :development
|
50
|
+
name: rspec
|
53
51
|
- !ruby/object:Gem::Dependency
|
54
|
-
prerelease: false
|
55
|
-
name: bundler
|
56
52
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
53
|
requirements:
|
59
54
|
- - ~>
|
60
55
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 23
|
62
56
|
segments:
|
63
57
|
- 1
|
64
58
|
- 0
|
65
59
|
- 0
|
60
|
+
segments_generated: true
|
66
61
|
version: 1.0.0
|
67
62
|
requirement: *id003
|
63
|
+
prerelease: false
|
68
64
|
type: :development
|
65
|
+
name: bundler
|
69
66
|
- !ruby/object:Gem::Dependency
|
70
|
-
prerelease: false
|
71
|
-
name: jeweler
|
72
67
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
68
|
requirements:
|
75
69
|
- - ~>
|
76
70
|
- !ruby/object:Gem::Version
|
77
|
-
hash: 7
|
78
71
|
segments:
|
79
72
|
- 1
|
80
73
|
- 5
|
81
74
|
- 2
|
75
|
+
segments_generated: true
|
82
76
|
version: 1.5.2
|
83
77
|
requirement: *id004
|
78
|
+
prerelease: false
|
84
79
|
type: :development
|
80
|
+
name: jeweler
|
85
81
|
- !ruby/object:Gem::Dependency
|
86
|
-
prerelease: false
|
87
|
-
name: rcov
|
88
82
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
83
|
requirements:
|
91
84
|
- - ">="
|
92
85
|
- !ruby/object:Gem::Version
|
93
|
-
hash: 3
|
94
86
|
segments:
|
95
87
|
- 0
|
88
|
+
segments_generated: true
|
96
89
|
version: "0"
|
97
90
|
requirement: *id005
|
91
|
+
prerelease: false
|
98
92
|
type: :development
|
93
|
+
name: rcov
|
99
94
|
description: PREP is PDF Report generator depends on HPDF.
|
100
95
|
email: tim.makino@gmail.com
|
101
96
|
executables:
|
@@ -125,6 +120,7 @@ files:
|
|
125
120
|
- examples/generate_sample4.rb
|
126
121
|
- examples/generate_sample5.rb
|
127
122
|
- examples/generate_sample6.rb
|
123
|
+
- examples/generate_sample7.rb
|
128
124
|
- examples/generate_sample_dataset.rb
|
129
125
|
- examples/group_sample.yml
|
130
126
|
- examples/image_sample.yml
|
@@ -134,6 +130,8 @@ files:
|
|
134
130
|
- examples/sample3.yml
|
135
131
|
- examples/sample5.yml
|
136
132
|
- examples/sample6.yml
|
133
|
+
- examples/sample7.yml
|
134
|
+
- lib/core/arc_rectangle.rb
|
137
135
|
- lib/core/color.rb
|
138
136
|
- lib/core/drawable.rb
|
139
137
|
- lib/core/group.rb
|
@@ -163,27 +161,25 @@ rdoc_options: []
|
|
163
161
|
require_paths:
|
164
162
|
- lib
|
165
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
-
none: false
|
167
164
|
requirements:
|
168
165
|
- - ">="
|
169
166
|
- !ruby/object:Gem::Version
|
170
|
-
hash: 3
|
171
167
|
segments:
|
172
168
|
- 0
|
169
|
+
segments_generated: true
|
173
170
|
version: "0"
|
174
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
172
|
requirements:
|
177
173
|
- - ">="
|
178
174
|
- !ruby/object:Gem::Version
|
179
|
-
hash: 3
|
180
175
|
segments:
|
181
176
|
- 0
|
177
|
+
segments_generated: true
|
182
178
|
version: "0"
|
183
179
|
requirements: []
|
184
180
|
|
185
181
|
rubyforge_project:
|
186
|
-
rubygems_version: 1.3.
|
182
|
+
rubygems_version: 1.3.6
|
187
183
|
signing_key:
|
188
184
|
specification_version: 3
|
189
185
|
summary: PREP is PDF Report generator depends on HPDF.
|
@@ -196,6 +192,7 @@ test_files:
|
|
196
192
|
- examples/generate_sample4.rb
|
197
193
|
- examples/generate_sample5.rb
|
198
194
|
- examples/generate_sample6.rb
|
195
|
+
- examples/generate_sample7.rb
|
199
196
|
- examples/generate_sample_dataset.rb
|
200
197
|
- spec/component_spec.rb
|
201
198
|
- spec/prep_spec.rb
|