91
92
@tick_label_style = FullTextStyle.new
92
93
@tick_label_style.scale = Types::Dimension.new(:dy, 0.8)
93
95
@axis_label = TextLabel.new(label)
96
98
@ticks = AxisTicks.new
100
@index = @@text_size_index
101
@@text_size_index += 1
99
104
# Draws the axis within the current plot. Boundaries are the
105
110
# where it should be...
106
111
# * non-linear axes (or linear, for that matter, but with
107
112
# a transformation)
114
# _watcher_ is a TextSizeWatcher object.
115
def draw_axis(t, watcher = nil)
109
116
spec = get_axis_specification(t)
111
118
info = t.axis_information(spec)
128
135
spec.update(@ticks_side)
137
# We don't allow Tioga to draw tick labels by itself
139
spec['type'] = case spec['type']
140
when Tioga::FigureConstants::AXIS_WITH_MAJOR_TICKS_AND_NUMERIC_LABELS
141
Tioga::FigureConstants::AXIS_WITH_MAJOR_TICKS_ONLY
142
when Tioga::FigureConstants::AXIS_WITH_TICKS_AND_NUMERIC_LABELS
143
Tioga::FigureConstants::AXIS_WITH_TICKS_ONLY
129
147
t.show_axis(spec)
148
# Now, we draw axis ticks
149
if type == Tioga::FigureConstants::AXIS_WITH_MAJOR_TICKS_AND_NUMERIC_LABELS || type == Tioga::FigureConstants::AXIS_WITH_TICKS_AND_NUMERIC_LABELS
151
fnc = info['vertical'] ? :convert_figure_to_frame_y : :convert_figure_to_frame_x
152
stl = @tick_label_style.dup
155
stl.shift ||= Types::Dimension.new(:dy, info['shift'])
158
# @todo integrate to the
160
@location.base_location == :bottom ||
161
@location.base_location == :at_y_origin ||
162
@location.base_location == :right
164
stl.shift = Types::Dimension.new(:dy, stl.shift.to_dy(t) + shift_def)
167
@location.base_location == :bottom ||
168
@location.base_location == :at_y_origin ||
169
@location.base_location == :right
170
) ? Tioga::FigureConstants::ALIGNED_AT_TOP : Tioga::FigureConstants::ALIGNED_AT_BOTTOM
172
spec['labels'].size.times do |i|
173
pos = spec['major_ticks'][i]
174
label = spec['labels'][i]
175
pos = t.send(fnc, pos)
180
nm = "axis-tick#{@index}-#{i}"
182
stl.draw_text(t, label, spec['location'],
130
190
@axis_label.loc = @location
131
191
default = vertical? ? 'ylabel' : 'xlabel'
132
@axis_label.draw(t, default)
192
nm = "axis-label#{@index}"
194
# stl = @axis_label.dup
195
# # Default to aligning the label where it counts.
197
# @location.base_location == :bottom ||
198
# @location.base_location == :at_y_origin ||
199
# @location.base_location == :right
200
# ) ? Tioga::FigureConstants::ALIGNED_AT_MIDHEIGHT : Tioga::FigureConstants::ALIGNED_AT_BOTTOM
202
@axis_label.draw(t, default, nm)
135
208
# Sets the current boundaries of the _t_ object to the _range_