image_paradise 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of image_paradise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/LICENSE.md +38 -0
- data/README.md +179 -0
- data/USAGE.md +10 -0
- data/bin/black_white +10 -0
- data/bin/display_text_from_this_image +7 -0
- data/bin/image_paradise +7 -0
- data/bin/image_paradise_shell +7 -0
- data/bin/image_to_ascii +54 -0
- data/bin/image_to_pdf +7 -0
- data/bin/make_this_image_transparent +7 -0
- data/bin/rotate_left +7 -0
- data/bin/rotate_right +7 -0
- data/doc/README.gen +162 -0
- data/doc/TODO_FOR_THE_GTK_GUI.md +1 -0
- data/image_paradise.gemspec +50 -0
- data/lib/image_paradise.rb +5 -0
- data/lib/image_paradise/base/base.rb +91 -0
- data/lib/image_paradise/black_white.rb +89 -0
- data/lib/image_paradise/confree_generator/class.rb +614 -0
- data/lib/image_paradise/confree_generator/constants.rb +61 -0
- data/lib/image_paradise/confree_generator/gui/gtk_confree_generator.rb +752 -0
- data/lib/image_paradise/confree_generator/gui/insert_button.rb +78 -0
- data/lib/image_paradise/confree_generator/reset.rb +61 -0
- data/lib/image_paradise/confree_generator/shared/shared.rb +100 -0
- data/lib/image_paradise/constants.rb +43 -0
- data/lib/image_paradise/constants/image_file_types.rb +21 -0
- data/lib/image_paradise/create_animated_gif.rb +47 -0
- data/lib/image_paradise/crop/crop.rb +302 -0
- data/lib/image_paradise/gm_support.rb +34 -0
- data/lib/image_paradise/graphs.rb +36 -0
- data/lib/image_paradise/graphs/accumulator_bar.rb +29 -0
- data/lib/image_paradise/graphs/area.rb +64 -0
- data/lib/image_paradise/graphs/bar.rb +117 -0
- data/lib/image_paradise/graphs/bar_conversion.rb +53 -0
- data/lib/image_paradise/graphs/base.rb +1392 -0
- data/lib/image_paradise/graphs/bezier.rb +45 -0
- data/lib/image_paradise/graphs/bullet.rb +115 -0
- data/lib/image_paradise/graphs/deprecated.rb +42 -0
- data/lib/image_paradise/graphs/dot.rb +129 -0
- data/lib/image_paradise/graphs/line.rb +328 -0
- data/lib/image_paradise/graphs/mini/bar.rb +42 -0
- data/lib/image_paradise/graphs/mini/legend.rb +109 -0
- data/lib/image_paradise/graphs/mini/pie.rb +42 -0
- data/lib/image_paradise/graphs/mini/side_bar.rb +41 -0
- data/lib/image_paradise/graphs/net.rb +133 -0
- data/lib/image_paradise/graphs/photo_bar.rb +106 -0
- data/lib/image_paradise/graphs/pie.rb +139 -0
- data/lib/image_paradise/graphs/scatter.rb +264 -0
- data/lib/image_paradise/graphs/scene.rb +216 -0
- data/lib/image_paradise/graphs/side_bar.rb +144 -0
- data/lib/image_paradise/graphs/side_stacked_bar.rb +116 -0
- data/lib/image_paradise/graphs/spider.rb +163 -0
- data/lib/image_paradise/graphs/stacked_area.rb +73 -0
- data/lib/image_paradise/graphs/stacked_bar.rb +68 -0
- data/lib/image_paradise/graphs/stacked_mixin.rb +30 -0
- data/lib/image_paradise/graphs/themes.rb +117 -0
- data/lib/image_paradise/graphviz/README.md +2 -0
- data/lib/image_paradise/graphviz/generate_graphviz_image.rb +274 -0
- data/lib/image_paradise/gui/gtk/control_panel.rb +126 -0
- data/lib/image_paradise/identify.rb +145 -0
- data/lib/image_paradise/image_border.rb +231 -0
- data/lib/image_paradise/image_manipulations.rb +320 -0
- data/lib/image_paradise/image_paradise.rb +150 -0
- data/lib/image_paradise/image_to_ascii/image_to_ascii.rb +187 -0
- data/lib/image_paradise/image_to_pdf/image_to_pdf.rb +99 -0
- data/lib/image_paradise/label/README.md +2 -0
- data/lib/image_paradise/label/simple_label.rb +206 -0
- data/lib/image_paradise/optimizer.rb +483 -0
- data/lib/image_paradise/project/project.rb +29 -0
- data/lib/image_paradise/random_text_to_image.rb +363 -0
- data/lib/image_paradise/requires/common_base_requires.rb +17 -0
- data/lib/image_paradise/requires/require_colours.rb +9 -0
- data/lib/image_paradise/requires/require_gtk_components.rb +8 -0
- data/lib/image_paradise/requires/require_image_to_ascii.rb +7 -0
- data/lib/image_paradise/requires/require_the_image_paradise_project.rb +24 -0
- data/lib/image_paradise/requires/require_toplevel_methods.rb +21 -0
- data/lib/image_paradise/rotate/README.md +2 -0
- data/lib/image_paradise/rotate/rotate.rb +98 -0
- data/lib/image_paradise/shell/interactive.rb +156 -0
- data/lib/image_paradise/svg/README.md +5 -0
- data/lib/image_paradise/svg/circle.rb +106 -0
- data/lib/image_paradise/svg/feature.rb +48 -0
- data/lib/image_paradise/svg/rectangle.rb +154 -0
- data/lib/image_paradise/svg/svg.rb +102 -0
- data/lib/image_paradise/to_gif.rb +91 -0
- data/lib/image_paradise/to_jpg.rb +90 -0
- data/lib/image_paradise/toplevel_methods/add_black_border_to_this_image.rb +56 -0
- data/lib/image_paradise/toplevel_methods/crop.rb +28 -0
- data/lib/image_paradise/toplevel_methods/e.rb +16 -0
- data/lib/image_paradise/toplevel_methods/esystem.rb +19 -0
- data/lib/image_paradise/toplevel_methods/extract_text_from_this_image.rb +56 -0
- data/lib/image_paradise/toplevel_methods/file_related_code.rb +25 -0
- data/lib/image_paradise/toplevel_methods/flip_image_left_right.rb +32 -0
- data/lib/image_paradise/toplevel_methods/greyscale_this_image.rb +59 -0
- data/lib/image_paradise/toplevel_methods/help.rb +30 -0
- data/lib/image_paradise/toplevel_methods/make_this_image_transparent.rb +30 -0
- data/lib/image_paradise/toplevel_methods/menu.rb +92 -0
- data/lib/image_paradise/toplevel_methods/merge_these_images.rb +49 -0
- data/lib/image_paradise/toplevel_methods/mirror_image.rb +28 -0
- data/lib/image_paradise/toplevel_methods/misc.rb +31 -0
- data/lib/image_paradise/toplevel_methods/png_to_svg.rb +34 -0
- data/lib/image_paradise/toplevel_methods/roebe.rb +17 -0
- data/lib/image_paradise/toplevel_methods/to_png.rb +105 -0
- data/lib/image_paradise/toplevel_methods/wallpaper.rb +37 -0
- data/lib/image_paradise/toplevel_methods/write_this_text.rb +76 -0
- data/lib/image_paradise/version/version.rb +19 -0
- data/test/16x16_red_square_image_for_testing.png +0 -0
- data/test/testing_confree_generator.rb +8 -0
- data/test/testing_crop.rb +19 -0
- data/test/testing_image_magick_commands.rb +39 -0
- data/test/testing_image_paradise.rb +49 -0
- data/test/testing_the_svg_component.html +261 -0
- data/test/testing_the_svg_component.rb +106 -0
- metadata +217 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
require 'image_paradise/graphs/base.rb'
|
6
|
+
require 'image_paradise/graphs/stacked_mixin.rb'
|
7
|
+
|
8
|
+
module ImageParadise
|
9
|
+
|
10
|
+
class Gruff::StackedBar < Gruff::Base
|
11
|
+
|
12
|
+
include StackedMixin
|
13
|
+
|
14
|
+
# Spacing factor applied between bars
|
15
|
+
attr_accessor :bar_spacing
|
16
|
+
|
17
|
+
# Number of pixels between bar segments
|
18
|
+
attr_accessor :segment_spacing
|
19
|
+
|
20
|
+
# === draw
|
21
|
+
#
|
22
|
+
# Draws a bar graph, but multiple sets are stacked on top of each other.
|
23
|
+
def draw
|
24
|
+
get_maximum_by_stack
|
25
|
+
super
|
26
|
+
return unless @has_data
|
27
|
+
# Setup spacing.
|
28
|
+
#
|
29
|
+
# Columns sit stacked.
|
30
|
+
@bar_spacing ||= 0.9
|
31
|
+
@segment_spacing ||= 1
|
32
|
+
@bar_width = @graph_width / @column_count.to_f
|
33
|
+
padding = (@bar_width * (1 - @bar_spacing)) / 2
|
34
|
+
|
35
|
+
@d = @d.stroke_opacity 0.0
|
36
|
+
|
37
|
+
height = Array.new(@column_count, 0)
|
38
|
+
|
39
|
+
@norm_data.each_with_index do |data_row, row_index|
|
40
|
+
data_row[DATA_VALUES_INDEX].each_with_index do |data_point, point_index|
|
41
|
+
@d = @d.fill data_row[DATA_COLOR_INDEX]
|
42
|
+
|
43
|
+
# Calculate center based on bar_width and current row
|
44
|
+
label_center = @graph_left + (@bar_width * point_index) + (@bar_width * @bar_spacing / 2.0)
|
45
|
+
draw_label(label_center, point_index)
|
46
|
+
|
47
|
+
next if (data_point == 0)
|
48
|
+
# Use incremented x and scaled y
|
49
|
+
left_x = @graph_left + (@bar_width * point_index) + padding
|
50
|
+
left_y = @graph_top + (@graph_height -
|
51
|
+
data_point * @graph_height -
|
52
|
+
height[point_index]) + @segment_spacing
|
53
|
+
right_x = left_x + @bar_width * @bar_spacing
|
54
|
+
right_y = @graph_top + @graph_height - height[point_index] - @segment_spacing
|
55
|
+
|
56
|
+
# update the total height of the current stacked bar
|
57
|
+
height[point_index] += (data_point * @graph_height )
|
58
|
+
|
59
|
+
@d = @d.rectangle(left_x, left_y, right_x, right_y)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
@d.draw(@base_image)
|
66
|
+
end
|
67
|
+
|
68
|
+
end; end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module ImageParadise
|
6
|
+
|
7
|
+
module Gruff::Base::StackedMixin
|
8
|
+
# Used by StackedBar and child classes.
|
9
|
+
#
|
10
|
+
# tsal: moved from Base 03 FEB 2007
|
11
|
+
DATA_VALUES_INDEX = Gruff::Base::DATA_VALUES_INDEX
|
12
|
+
# === get_maximum_by_stack
|
13
|
+
def get_maximum_by_stack
|
14
|
+
# Get sum of each stack
|
15
|
+
max_hash = {}
|
16
|
+
@data.each { |data_set|
|
17
|
+
data_set[DATA_VALUES_INDEX].each_with_index do |data_point, i|
|
18
|
+
max_hash[i] = 0.0 unless max_hash[i]
|
19
|
+
max_hash[i] += data_point.to_f
|
20
|
+
end
|
21
|
+
}
|
22
|
+
|
23
|
+
# @maximum_value = 0
|
24
|
+
max_hash.keys.each { |key|
|
25
|
+
@maximum_value = max_hash[key] if max_hash[key] > @maximum_value
|
26
|
+
}
|
27
|
+
@minimum_value = 0
|
28
|
+
end
|
29
|
+
|
30
|
+
end; end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
module ImageParadise
|
6
|
+
|
7
|
+
module Gruff
|
8
|
+
|
9
|
+
module Themes
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === THIRTYSEVEN_SIGNALS
|
13
|
+
#
|
14
|
+
# A color scheme plucked from the colors on the popular usability blog.
|
15
|
+
# ========================================================================= #
|
16
|
+
THIRTYSEVEN_SIGNALS = {
|
17
|
+
:colors => [
|
18
|
+
'#FFF804', # yellow
|
19
|
+
'#336699', # blue
|
20
|
+
'#339933', # green
|
21
|
+
'#ff0000', # red
|
22
|
+
'#cc99cc', # purple
|
23
|
+
'#cf5910', # orange
|
24
|
+
'black'
|
25
|
+
],
|
26
|
+
:marker_color => 'black',
|
27
|
+
:font_color => 'black',
|
28
|
+
:background_colors => %w(#d1edf5 white)
|
29
|
+
}
|
30
|
+
|
31
|
+
# ========================================================================= #
|
32
|
+
# === KEYNOTE
|
33
|
+
#
|
34
|
+
# A color scheme similar to the popular presentation software.
|
35
|
+
# ========================================================================= #
|
36
|
+
KEYNOTE = {
|
37
|
+
:colors => [
|
38
|
+
'#FDD84E', # yellow
|
39
|
+
'#6886B4', # blue
|
40
|
+
'#72AE6E', # green
|
41
|
+
'#D1695E', # red
|
42
|
+
'#8A6EAF', # purple
|
43
|
+
'#EFAA43', # orange
|
44
|
+
'white'
|
45
|
+
],
|
46
|
+
:marker_color => 'white',
|
47
|
+
:font_color => 'white',
|
48
|
+
:background_colors => %w(black #4a465a)
|
49
|
+
}
|
50
|
+
|
51
|
+
# A color scheme from the colors used on the 2005 Rails keynote
|
52
|
+
# presentation at RubyConf.
|
53
|
+
RAILS_KEYNOTE = {
|
54
|
+
:colors => [
|
55
|
+
'#00ff00', # green
|
56
|
+
'#333333', # grey
|
57
|
+
'#ff5d00', # orange
|
58
|
+
'#f61100', # red
|
59
|
+
'white',
|
60
|
+
'#999999', # light grey
|
61
|
+
'black'
|
62
|
+
],
|
63
|
+
:marker_color => 'white',
|
64
|
+
:font_color => 'white',
|
65
|
+
:background_colors => %w(#0083a3 #0083a3)
|
66
|
+
}
|
67
|
+
|
68
|
+
# A color scheme similar to that used on the popular podcast site.
|
69
|
+
ODEO = {
|
70
|
+
:colors => [
|
71
|
+
'#202020', # grey
|
72
|
+
'white',
|
73
|
+
'#3a5b87', # dark blue
|
74
|
+
'#a21764', # dark pink
|
75
|
+
'#8ab438', # green
|
76
|
+
'#999999', # light grey
|
77
|
+
'black'
|
78
|
+
],
|
79
|
+
:marker_color => 'white',
|
80
|
+
:font_color => 'white',
|
81
|
+
:background_colors => %w(#ff47a4 #ff1f81)
|
82
|
+
}
|
83
|
+
|
84
|
+
# A pastel theme
|
85
|
+
PASTEL = {
|
86
|
+
:colors => [
|
87
|
+
'#a9dada', # blue
|
88
|
+
'#aedaa9', # green
|
89
|
+
'#daaea9', # peach
|
90
|
+
'#dadaa9', # yellow
|
91
|
+
'#a9a9da', # dk purple
|
92
|
+
'#daaeda', # purple
|
93
|
+
'#dadada' # grey
|
94
|
+
],
|
95
|
+
:marker_color => '#aea9a9', # Grey
|
96
|
+
:font_color => 'black',
|
97
|
+
:background_colors => 'white'
|
98
|
+
}
|
99
|
+
|
100
|
+
# === GREYSCALE
|
101
|
+
#
|
102
|
+
# A greyscale theme
|
103
|
+
GREYSCALE = {
|
104
|
+
:colors => [
|
105
|
+
'#282828', #
|
106
|
+
'#383838', #
|
107
|
+
'#686868', #
|
108
|
+
'#989898', #
|
109
|
+
'#c8c8c8', #
|
110
|
+
'#e8e8e8', #
|
111
|
+
],
|
112
|
+
:marker_color => '#aea9a9', # Grey
|
113
|
+
:font_color => 'black',
|
114
|
+
:background_colors => 'white'
|
115
|
+
}
|
116
|
+
|
117
|
+
end; end; end
|
@@ -0,0 +1,274 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === ImageParadise::GenerateGraphvizImage
|
6
|
+
#
|
7
|
+
# This class can generate a graphviz-image.
|
8
|
+
#
|
9
|
+
# Note that it currently is catered to the Studium project's primary
|
10
|
+
# use case, so don't expect it to have too many features.
|
11
|
+
#
|
12
|
+
# The first argument to this class can be a Hash. If so then this
|
13
|
+
# class will batch-process that Hash.
|
14
|
+
#
|
15
|
+
# The generated String, into the dotfile, should be like this:
|
16
|
+
#
|
17
|
+
# "Module M4" -> "Module M10";
|
18
|
+
# "Module M8" -> "Module M10";
|
19
|
+
#
|
20
|
+
# Usage example:
|
21
|
+
#
|
22
|
+
# ImageParadise::GenerateGraphvizImage.new(ARGV)
|
23
|
+
#
|
24
|
+
# =========================================================================== #
|
25
|
+
# require 'image_paradise/graphviz/generate_graphviz_image.rb'
|
26
|
+
# ImageParadise::GenerateGraphvizImage.new(ARGV)
|
27
|
+
# =========================================================================== #
|
28
|
+
require 'image_paradise/base/base.rb'
|
29
|
+
|
30
|
+
module ImageParadise
|
31
|
+
|
32
|
+
class GenerateGraphvizImage < Base # === ImageParadise::GenerateGraphvizImage
|
33
|
+
|
34
|
+
require 'fileutils'
|
35
|
+
|
36
|
+
# ========================================================================= #
|
37
|
+
# === TRY_TO_REDUCE_THE_FILESIZE_FOR_GENERATED_PNG_FILES
|
38
|
+
# ========================================================================= #
|
39
|
+
TRY_TO_REDUCE_THE_FILESIZE_FOR_GENERATED_PNG_FILES = true
|
40
|
+
|
41
|
+
# ========================================================================= #
|
42
|
+
# === initialize
|
43
|
+
# ========================================================================= #
|
44
|
+
def initialize(
|
45
|
+
commandline_arguments = nil,
|
46
|
+
run_already = true
|
47
|
+
)
|
48
|
+
reset
|
49
|
+
set_commandline_arguments(
|
50
|
+
commandline_arguments
|
51
|
+
)
|
52
|
+
# ======================================================================= #
|
53
|
+
# === Handle blocks
|
54
|
+
# ======================================================================= #
|
55
|
+
if block_given?
|
56
|
+
yielded = yield
|
57
|
+
case yielded
|
58
|
+
# ===================================================================== #
|
59
|
+
# === :use_bold_font
|
60
|
+
# ===================================================================== #
|
61
|
+
when :use_bold_font
|
62
|
+
use_bold_font
|
63
|
+
# ===================================================================== #
|
64
|
+
# === :use_bold_font_and_german
|
65
|
+
# ===================================================================== #
|
66
|
+
when :use_bold_font_and_german
|
67
|
+
use_bold_font
|
68
|
+
use_german
|
69
|
+
end
|
70
|
+
end
|
71
|
+
run if run_already
|
72
|
+
end
|
73
|
+
|
74
|
+
# ========================================================================= #
|
75
|
+
# === reset (reset tag)
|
76
|
+
# ========================================================================= #
|
77
|
+
def reset
|
78
|
+
super()
|
79
|
+
# ======================================================================= #
|
80
|
+
# === @append_this_string_to_each_node
|
81
|
+
#
|
82
|
+
# This string here will be appended to each node-line.
|
83
|
+
# ======================================================================= #
|
84
|
+
@append_this_string_to_each_node = ''.dup
|
85
|
+
# ======================================================================= #
|
86
|
+
# === @use_this_fontname
|
87
|
+
# ======================================================================= #
|
88
|
+
@use_this_fontname = 'Courier'
|
89
|
+
# ======================================================================= #
|
90
|
+
# === @penwidth
|
91
|
+
# ======================================================================= #
|
92
|
+
@penwidth = 2
|
93
|
+
# ======================================================================= #
|
94
|
+
# === @use_english_or_german_for_this_class
|
95
|
+
# ======================================================================= #
|
96
|
+
@use_english_or_german_for_this_class = :english
|
97
|
+
end
|
98
|
+
|
99
|
+
# ========================================================================= #
|
100
|
+
# === to_german
|
101
|
+
# ========================================================================= #
|
102
|
+
def to_german
|
103
|
+
@use_english_or_german_for_this_class = :german
|
104
|
+
end; alias use_german to_german # === use_german
|
105
|
+
|
106
|
+
# ========================================================================= #
|
107
|
+
# === return_english_or_german_name_for_a_module
|
108
|
+
# ========================================================================= #
|
109
|
+
def return_english_or_german_name_for_a_module
|
110
|
+
case @use_english_or_german_for_this_class
|
111
|
+
when :english
|
112
|
+
'Module'
|
113
|
+
when :german
|
114
|
+
'Modul'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# ========================================================================= #
|
119
|
+
# === use_bold_font
|
120
|
+
#
|
121
|
+
# This will use a hardcoded font by default. The user is expected to
|
122
|
+
# supply another font if he/she seeks to change the font.
|
123
|
+
# ========================================================================= #
|
124
|
+
def use_bold_font(
|
125
|
+
i = 'Cascadia Mono PL Bold'
|
126
|
+
)
|
127
|
+
@use_this_fontname = i
|
128
|
+
end
|
129
|
+
|
130
|
+
# ========================================================================= #
|
131
|
+
# === set_commandline_arguments
|
132
|
+
# ========================================================================= #
|
133
|
+
def set_commandline_arguments(i = '')
|
134
|
+
i = [i].flatten.compact
|
135
|
+
@commandline_arguments = i
|
136
|
+
end
|
137
|
+
|
138
|
+
# ========================================================================= #
|
139
|
+
# === commandline_arguments?
|
140
|
+
# ========================================================================= #
|
141
|
+
def commandline_arguments?
|
142
|
+
@commandline_arguments
|
143
|
+
end
|
144
|
+
|
145
|
+
# ========================================================================= #
|
146
|
+
# === first_argument?
|
147
|
+
# ========================================================================= #
|
148
|
+
def first_argument?
|
149
|
+
@commandline_arguments.first
|
150
|
+
end; alias dataset? first_argument? # === dataset?
|
151
|
+
|
152
|
+
# ========================================================================= #
|
153
|
+
# === check_whether_the_first_argument_is_a_hash
|
154
|
+
# ========================================================================= #
|
155
|
+
def check_whether_the_first_argument_is_a_hash
|
156
|
+
into = 'module_dependencies.dot'
|
157
|
+
_ = ''.dup
|
158
|
+
_ << "# dot -Tpng #{into} -o outfile.png\n"
|
159
|
+
_ << 'digraph graphname {
|
160
|
+
|
161
|
+
node [color=Red,fontname="'+@use_this_fontname+'",shape=box, fontsize=28] // All nodes will this shape and colour
|
162
|
+
edge [color=Blue, style=dashed] // All the lines look like this
|
163
|
+
'
|
164
|
+
first_argument = first_argument?
|
165
|
+
if first_argument.is_a? Hash
|
166
|
+
if @penwidth
|
167
|
+
@append_this_string_to_each_node << " [penwidth=#{@penwidth}]"
|
168
|
+
end
|
169
|
+
sorted = first_argument.sort_by {|key, value|
|
170
|
+
key.delete('M').to_i
|
171
|
+
}
|
172
|
+
sorted.each {|module_number, module_dependencies|
|
173
|
+
# Iterate over the module dependencies next.
|
174
|
+
module_dependencies.each {|this_module|
|
175
|
+
this_module.delete!('"')
|
176
|
+
unless this_module.include?('None')
|
177
|
+
source_module = '"'+return_english_or_german_name_for_a_module+' '+module_number+'"'
|
178
|
+
target_module = '"'+return_english_or_german_name_for_a_module+' '+this_module+'"'
|
179
|
+
unless source_module == target_module
|
180
|
+
_ << "#{target_module} -> #{source_module}"
|
181
|
+
unless @append_this_string_to_each_node.empty?
|
182
|
+
_ << @append_this_string_to_each_node
|
183
|
+
end
|
184
|
+
_ << ';'
|
185
|
+
_ << N
|
186
|
+
end
|
187
|
+
end
|
188
|
+
}
|
189
|
+
_ << "\n"
|
190
|
+
}
|
191
|
+
_ << '}'
|
192
|
+
# ===================================================================== #
|
193
|
+
# Remove the old file if it exists.
|
194
|
+
# ===================================================================== #
|
195
|
+
puts "Saving into the file #{into} next."
|
196
|
+
if File.exist? into
|
197
|
+
File.delete(into)
|
198
|
+
end
|
199
|
+
write_what_into(_, into)
|
200
|
+
if File.exist? into
|
201
|
+
run_dot_command_to_create_the_image(into)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# ========================================================================= #
|
207
|
+
# === run_dot_command_to_create_the_image
|
208
|
+
# ========================================================================= #
|
209
|
+
def run_dot_command_to_create_the_image(i)
|
210
|
+
output_file = 'outfile.png'
|
211
|
+
if File.exist? output_file
|
212
|
+
File.delete(output_file)
|
213
|
+
end
|
214
|
+
cmd_to_run = "dot -Tpng #{i} -o #{output_file}"
|
215
|
+
e
|
216
|
+
e " #{cmd_to_run}"
|
217
|
+
e
|
218
|
+
result = `#{cmd_to_run} 2>&1`
|
219
|
+
if result.include? 'Error: '
|
220
|
+
# ===================================================================== #
|
221
|
+
# Handle situations such as this one here:
|
222
|
+
# Error: module_dependencies.dot: syntax error in line 4 near ','
|
223
|
+
# ===================================================================== #
|
224
|
+
e 'Some error happened. The error will be shown next:'
|
225
|
+
e
|
226
|
+
e Colours.crimson(" #{result.strip}")
|
227
|
+
e
|
228
|
+
else
|
229
|
+
# ===================================================================== #
|
230
|
+
# Try to optimize the .png file at hand.
|
231
|
+
# ===================================================================== #
|
232
|
+
if TRY_TO_REDUCE_THE_FILESIZE_FOR_GENERATED_PNG_FILES and
|
233
|
+
output_file.end_with?('.png') and
|
234
|
+
File.exist?(output_file)
|
235
|
+
new_file = 'OUT_'+output_file
|
236
|
+
e
|
237
|
+
e 'Running pngquant next:'
|
238
|
+
e
|
239
|
+
esystem "pngquant #{output_file} --output #{new_file}"
|
240
|
+
e
|
241
|
+
if File.exist?(new_file) and File.exist?(output_file)
|
242
|
+
FileUtils.mv(new_file, output_file)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
# ===================================================================== #
|
246
|
+
# Open the existing file in the browser next, if present.
|
247
|
+
# ===================================================================== #
|
248
|
+
if File.exist?(output_file) and is_on_roebe?
|
249
|
+
require 'roebe/toplevel_methods/open_in_browser.rb'
|
250
|
+
e "Now opening #{sfile(output_file)} in the browser."
|
251
|
+
OpenInBrowser[output_file]
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# ========================================================================= #
|
257
|
+
# === run (run tag)
|
258
|
+
# ========================================================================= #
|
259
|
+
def run
|
260
|
+
check_whether_the_first_argument_is_a_hash
|
261
|
+
end
|
262
|
+
|
263
|
+
# ========================================================================= #
|
264
|
+
# === ImageParadise::GenerateGraphvizImage[]
|
265
|
+
# ========================================================================= #
|
266
|
+
def self.[](i = '')
|
267
|
+
new(i)
|
268
|
+
end
|
269
|
+
|
270
|
+
end; end
|
271
|
+
|
272
|
+
if __FILE__ == $PROGRAM_NAME
|
273
|
+
ImageParadise::GenerateGraphvizImage.new(ARGV)
|
274
|
+
end # generate_graphviz_image
|