Skip to content

Commit 0d8a75d

Browse files
authored
Merge pull request #1678 from RZ9082/wordcloud
Fix wordcloud
2 parents 76bec04 + 3f4ac35 commit 0d8a75d

9 files changed

Lines changed: 118 additions & 95 deletions

File tree

tools/wordcloud/test-data/mask.png

-4.22 KB
Loading
14.7 KB
Loading
21.6 KB
Loading
31.7 KB
Loading
25.3 KB
Loading
30.7 KB
Loading
-28.6 KB
Binary file not shown.
-152 KB
Binary file not shown.

tools/wordcloud/wordcloud.xml

Lines changed: 118 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<description>with highly customizable appearance</description>
33
<macros>
44
<token name="@TOOL_VERSION@">1.9.4</token>
5-
<token name="@VERSION_SUFFIX@">2</token>
5+
<token name="@VERSION_SUFFIX@">3</token>
66
<token name="@PROFILE@">23.0</token>
77
</macros>
88
<requirements>
@@ -47,29 +47,28 @@
4747
#if str($margin):
4848
--margin $margin
4949
#end if
50-
#if $background
51-
--background '$background'
50+
--mode $background_options.mode
51+
#if str($background_options.mode) == 'RGB'
52+
--background '$background_options.background_color'
53+
#if str($background_options.cloud_shape.cloud_shape_options) == 'mask'
54+
--mask $background_options.cloud_shape.mask
55+
--contour_width $background_options.cloud_shape.contour_width
56+
--contour_color '$background_options.cloud_shape.contour_color'
57+
#end if
58+
#else
59+
--background None
60+
#if str($background_options.cloud_shape.cloud_shape_options) == 'mask'
61+
--mask $background_options.cloud_shape.mask
62+
#end if
5263
#end if
53-
#if $mask
54-
--mask $mask
55-
#end if
56-
#if $color_choice == "color":
57-
--color '$color'
58-
#else if $color_choice == "colormask":
59-
--colormask $colormask
64+
#if $color_choice.color_option == "color":
65+
--color '$color_choice.color'
66+
#else if $color_choice.color_option == "colormask":
67+
--colormask $color_choice.colormask
6068
#end if
6169
#if $colormap
6270
--colormap $colormap
6371
#end if
64-
#if $mode
65-
--mode $mode
66-
#end if
67-
#if $contour_width
68-
--contour_width $contour_width
69-
#end if
70-
#if $contour_color
71-
--contour_color '$contour_color'
72-
#end if
7372
#if str($prefer_horizontal):
7473
--prefer_horizontal $prefer_horizontal
7574
#end if
@@ -120,10 +119,43 @@
120119
<param argument="--width" type="integer" min="1" value="400" optional="true" label="Define output image width"/>
121120
<param argument="--height" type="integer" min="1" value="200" optional="true" label="Define output image height"/>
122121
<param argument="--margin" type="integer" value="2" label="Spacing to leave around words"/>
123-
<param argument="--background" type="color" value="#000000" optional="true" label="Use given color as background color for the image">
124-
<validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
125-
</param>
126-
<param argument="--mask" type="data" format="png" optional="true" label="Mask to use for the image form"/>
122+
<conditional name="background_options">
123+
<param argument="--mode" type="select" label="Use RGB or RGBA for transparent background">
124+
<option value="RGB" selected="true">RGB</option>
125+
<option value="RGBA">RGBA</option>
126+
</param>
127+
<when value="RGB">
128+
<param argument="--background_color" type="color" value="#000000" optional="true" label="Use given color as background color for the image">
129+
<validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
130+
</param>
131+
<conditional name="cloud_shape">
132+
<param name="cloud_shape_options" type="select" label="Choose word cloud shape">
133+
<option value="rectangle" selected="true">Default - Rectangle</option>
134+
<option value="mask">Mask from image input</option>
135+
</param>
136+
<when value="rectangle"/>
137+
<when value="mask">
138+
<param argument="--mask" type="data" format="png" optional="true" label="Mask to use for the image form"/>
139+
<param argument="--contour_width" type="float" min="0" value="0" optional="true" label="Contour width" help="Use given color as mask contour color"/>
140+
<param argument="--contour_color" type="color" value="#000000" optional="true" label="Contour color">
141+
<validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
142+
</param>
143+
</when>
144+
</conditional>
145+
</when>
146+
<when value="RGBA">
147+
<conditional name="cloud_shape">
148+
<param name="cloud_shape_options" type="select" label="Choose word cloud shape">
149+
<option value="rectangle" selected="true">Default - Rectangle</option>
150+
<option value="mask">Mask from image input</option>
151+
</param>
152+
<when value="rectangle"/>
153+
<when value="mask">
154+
<param argument="--mask" type="data" format="png" optional="true" label="Mask to use for the image form"/>
155+
</when>
156+
</conditional>
157+
</when>
158+
</conditional>
127159
<conditional name="color_choice" label="Choose color option">
128160
<param name="color_option" type="select" label="Color option">
129161
<option value="color">Color</option>
@@ -163,14 +195,6 @@
163195
<option value="BuGn">BuGn</option>
164196
<option value="YlGn">YlGn</option>
165197
</param>
166-
<param argument="--mode" type="select" value="RGB" optional="true" label="Use RGB or RGBA for transparent background">
167-
<option value="RGB">RGB</option>
168-
<option value="RGBA">RGBA</option>
169-
</param>
170-
<param argument="--contour_width" type="float" min="0" value="0" optional="true" label="Contour width" help="Use given color as mask contour color"/>
171-
<param argument="--contour_color" type="color" value="#000000" optional="true" label="Contour color">
172-
<validator type="regex" message="Please select a valid RGB color">[#][0-9A-Fa-f]{6}</validator>
173-
</param>
174198
<param argument="--prefer_horizontal" type="float" min="0" max="1" value="0.9" optional="true" label="Ratio of times to try horizontal fitting as opposed to vertical"/>
175199
<param argument="--scale" type="float" value="1.0" optional="True" label="Scaling between computation and drawing"/>
176200
<param argument="--relative_scaling" type="float" min="0.0" max="1.0" value="0.0" optional="true" label="Scaling of words by frequency (0 - 1)"/>
@@ -185,85 +209,84 @@
185209
</outputs>
186210
<tests>
187211
<test expect_num_outputs="1">
188-
<param name="text" value="test.txt" ftype="txt"/>
189-
<conditional name="color_choice">
190-
<param name="color_option" value="color"/>
191-
<param name="color" value="#00ff00"/>
212+
<param name="text" value="test.txt"/>
213+
<param name="font_step" value="2"/>
214+
<param name="min_word_length" value="2"/>
215+
<param name="width" value="200"/>
216+
<param name="height" value="100"/>
217+
<param name="colormap" value="inferno"/>
218+
<param name="scale" value="1.8"/>
219+
<param name="no_collocations" value="false"/>
220+
<conditional name="fonts">
221+
<param name="fonts_selector" value="none"/>
192222
</conditional>
193-
<param name="contour_color" value="#1f4068"/>
194-
<param name="random_state" value="10"/>
195-
<param name="background" value="#000000"/>
196-
<output name="output" file="output_1.png" compare="image_diff" />
223+
<output name="output" file="output0.png" ftype="png"/>
197224
</test>
225+
198226
<test expect_num_outputs="1">
199-
<param name="text" value="test.txt" ftype="txt"/>
227+
<param name="text" value="test.txt"/>
200228
<param name="stopwords" value="stopwords.txt"/>
201229
<conditional name="fonts">
202-
<param name="fonts_selector" value="cached" />
203-
<param name="fonts_select" value="test_font"/>
204-
</conditional>
205-
<param name="min_font_size" value="4"/>
206-
<param name="max_font_size" value="100"/>
207-
<param name="font_step" value="1"/>
208-
<param name="min_word_length" value="0"/>
209-
<param name="max_words" value="200"/>
210-
<param name="width" value="800"/>
211-
<param name="height" value="600"/>
212-
<param name="margin" value="0"/>
213-
<param name="background" value="#ffffff"/>
214-
<param name="mask" value="mask.png"/>
215-
<conditional name="color_choice">
216-
<param name="color_option" value="color"/>
217-
<param name="color" value="#1f4068"/>
230+
<param name="fonts_selector" value="cached"/>
231+
<param name="fonts_select" value="Test Font"/>
218232
</conditional>
219-
<param name="colormap" value="viridis"/>
220-
<param name="mode" value="RGB"/>
221-
<param name="contour_width" value="8"/>
222-
<param name="contour_color" value="#1f4068"/>
223-
<param name="prefer_horizontal" value="0.9"/>
224-
<param name="scale" value="1.0"/>
225-
<param name="relative_scaling" value="0.0"/>
226-
<param name="no_collocations" value="True"/>
227-
<param name="include_numbers" value="False"/>
228-
<param name="no_normalize_plurals" value="True"/>
229-
<param name="repeat" value="True"/>
230-
<param name="random_state" value="10"/>
231-
<output name="output" file="output_2.png" compare="image_diff" />
233+
<output name="output" file="output1.png" ftype="png"/>
232234
</test>
235+
233236
<test expect_num_outputs="1">
234-
<param name="text" value="test.txt" ftype="txt"/>
237+
<param name="text" value="test.txt"/>
235238
<param name="stopwords" value="stopwords.txt"/>
236239
<conditional name="fonts">
237-
<param name="fonts_selector" value="history" />
240+
<param name="fonts_selector" value="history"/>
238241
<param name="fontfile" value="font.ttf"/>
239242
</conditional>
240-
<param name="min_font_size" value="4"/>
241-
<param name="max_font_size" value="100"/>
242-
<param name="font_step" value="1"/>
243-
<param name="min_word_length" value="0"/>
244-
<param name="max_words" value="200"/>
245-
<param name="width" value="800"/>
246-
<param name="height" value="600"/>
247-
<param name="margin" value="0"/>
248-
<param name="background" value="#ffffff"/>
249-
<param name="mask" value="mask.png"/>
243+
<output name="output" file="output1.png" ftype="png"/>
244+
</test>
245+
246+
<test expect_num_outputs="1">
247+
<param name="text" value="test.txt"/>
248+
<param name="stopwords" value="stopwords.txt"/>
249+
<conditional name="background_options">
250+
<param name="mode" value="RGB"/>
251+
<param name="background_color" value="#9141ac"/>
252+
<conditional name="cloud_shape">
253+
<param name="cloud_shape_options" value="mask"/>
254+
<param name="mask" value="mask.png"/>
255+
<param name="contour_width" value="1.8"/>
256+
<param name="contour_color" value="#e01b24"/>
257+
</conditional>
258+
</conditional>
259+
<output name="output" file="output2.png" ftype="png"/>
260+
</test>
261+
262+
<test expect_num_outputs="1">
263+
<param name="text" value="test.txt"/>
264+
<param name="stopwords" value="stopwords.txt"/>
265+
<param name="include_numbers" value="true"/>
266+
<param name="no_normalize_plurals" value="false"/>
267+
<param name="repeat" value="false"/>
268+
<param name="random_state" value="10"/>
250269
<conditional name="color_choice">
251270
<param name="color_option" value="color"/>
252-
<param name="color" value="#1f4068"/>
271+
<param name="color" value="#99c1f1"/>
253272
</conditional>
254-
<param name="colormap" value="viridis"/>
255-
<param name="mode" value="RGB"/>
256-
<param name="contour_width" value="8"/>
257-
<param name="contour_color" value="#1f4068"/>
258-
<param name="prefer_horizontal" value="0.9"/>
259-
<param name="scale" value="1.0"/>
260-
<param name="relative_scaling" value="0.0"/>
261-
<param name="no_collocations" value="True"/>
262-
<param name="include_numbers" value="False"/>
263-
<param name="no_normalize_plurals" value="True"/>
264-
<param name="repeat" value="True"/>
265-
<param name="random_state" value="10"/>
266-
<output name="output" file="output_2.png" compare="image_diff" />
273+
<conditional name="background_options">
274+
<param name="mode" value="RGBA"/>
275+
<conditional name="cloud_shape">
276+
<param name="cloud_shape_options" value="rectangle"/>
277+
</conditional>
278+
</conditional>
279+
<output name="output" file="output3.png" ftype="png"/>
280+
</test>
281+
282+
<test expect_num_outputs="1">
283+
<param name="text" value="test.txt"/>
284+
<param name="stopwords" value="stopwords.txt"/>
285+
<conditional name="color_choice">
286+
<param name="color_option" value="colormask"/>
287+
<param name="colormask" value="mask.png"/>
288+
</conditional>
289+
<output name="output" file="output4.png" ftype="png"/>
267290
</test>
268291
</tests>
269292
<help><![CDATA[

0 commit comments

Comments
 (0)