Module: Bioroebe::GUI::CalculateCellNumbersOfBacteriaModule

Includes:
Bioroebe::GUI
Included in:
Gtk::CalculateCellNumbersOfBacteria, LibUI::CalculateCellNumbersOfBacteria
Defined in:
lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb

Overview

Bioroebe::GUI::CalculateCellNumbersOfBacteriaModule

Constant Summary collapse

TITLE =
#

TITLE

#
'Calculate cell numbers of bacteria'
WIDTH =
#

WIDTH

#
'25% or minimum 300px'
HEIGHT =
#

HEIGHT

#
'20%'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_20

Constants included from Bioroebe::GUI

ARRAY_ALL_GTK_WIDGETS, FONT_SIZE, OLD_VERBOSE_VALUE, USE_THIS_FONT_FAMILY_FOR_GUI_APPLICATIONS

Instance Method Summary collapse

Methods included from Bioroebe::GUI

#disable_warnings, #enable_warnings, #log_dir?

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)

60
61
62
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 60

def border_size?
  4
end

#create_skeletonObject

#

create_skeleton (create tag)

#

202
203
204
205
206
207
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 202

def create_skeleton
  create_the_entries
  create_the_button_to_calculate_how_many_bacteria_will_exist
  create_the_boxes # Must come after the entries.
  create_the_hspacer
end

#create_the_boxesObject

#

create_the_boxes

#

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 166

def create_the_boxes
  # ======================================================================= #
  # === @hbox1
  # ======================================================================= #
  @hbox1 = create_hbox(
    bold_text('n bacteria (start)'),
    @entry_point_start_with_n_bacteria
  )

  # ======================================================================= #
  # === @hbox2
  # ======================================================================= #
  @hbox2 = create_hbox(
    bold_text('n doubling times'),
    @entry_point_use_n_divisions
  )

  # ======================================================================= #
  # === @hbox3
  # ======================================================================= #
  @hbox3 = create_hbox(
    bold_text('n bacteria (end)'),
    @entry_point_n_cells
  )
end

#create_the_button_to_calculate_how_many_bacteria_will_existObject

#

create_the_button_to_calculate_how_many_bacteria_will_exist (button tag)

#

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 80

def create_the_button_to_calculate_how_many_bacteria_will_exist
  # ======================================================================= #
  # === @button_to_calculate_how_many_bacteria_will_exist
  # ======================================================================= #
  @button_to_calculate_how_many_bacteria_will_exist = bold_button(
    'Calculate how many bacteria will exist after n rounds'
  )
  @button_to_calculate_how_many_bacteria_will_exist.clear_background
  @button_to_calculate_how_many_bacteria_will_exist.bblack2
  @button_to_calculate_how_many_bacteria_will_exist.on_clicked {
    do_the_calculation
  }
  @button_to_calculate_how_many_bacteria_will_exist.hint =
    "Click on this button in order to do the calculation\n"\
    "e. g. <b>how many bacteria we will have</b> "\
    "based on the above parameters."
  @button_to_calculate_how_many_bacteria_will_exist.on_hover(:powderblue)
  # @button_to_calculate_how_many_bacteria_will_exist.bg_colour(
  #   :lightsteelblue
  # )
end

#create_the_entriesObject

#

create_the_entries

#

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 105

def create_the_entries
  # ======================================================================= #
  # === @entry_point_start_with_n_bacteria
  # ======================================================================= #
  @entry_point_start_with_n_bacteria = entry
  @entry_point_start_with_n_bacteria.default = 10
  @entry_point_start_with_n_bacteria.bblack1
  @entry_point_start_with_n_bacteria.on_click_select_all
  @entry_point_start_with_n_bacteria.do_center
  @entry_point_start_with_n_bacteria.on_key_press_event { |widget, event|
    if use_gtk3?
      do_the_calculation if Gdk::Keyval.to_name(event.keyval) == 'Return'
    else
      do_the_calculation
    end
  }
  @entry_point_start_with_n_bacteria.hint =
    'Input a <b>number</b> here, denoting how many bacteria '\
    'exist at the start.'

  # ======================================================================= #
  # === @entry_point_use_n_divisions
  # ======================================================================= #
  @entry_point_use_n_divisions = entry
  @entry_point_use_n_divisions.default = 10
  @entry_point_use_n_divisions.bblack1
  @entry_point_use_n_divisions.on_click_select_all
  @entry_point_use_n_divisions.do_center
  @entry_point_use_n_divisions.on_key_press_event { |widget, event|
    if use_gtk3?
      do_the_calculation if Gdk::Keyval.to_name(event.keyval) == 'Return'
    else
      do_the_calculation
    end
  }
  @entry_point_use_n_divisions.hint =
    'Input a <b>number</b> here, denoting how many cell '\
    'divisions the bacteria will undergo.'

  # ======================================================================= #
  # === @entry_point_n_cells
  # ======================================================================= #
  @entry_point_n_cells = entry
  @entry_point_n_cells.default = 0
  @entry_point_n_cells.bblack1
  @entry_point_n_cells.do_center
  @entry_point_n_cells.on_key_press_event { |widget, event|
    if use_gtk3?
      do_the_calculation if Gdk::Keyval.to_name(event.keyval) == 'Return'
    else
      do_the_calculation
    end
  }
  @entry_point_n_cells.hint =
    'The number here will be <b>the amount of bacteria '\
    'after n cell divisions</b>.'
end

#create_the_hspacerObject

#

create_the_hspacer

#

195
196
197
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 195

def create_the_hspacer
  @a_hspacer = hspacer
end

#do_the_calculationObject

#

do_the_calculation

This method will do the actual calculation part.

#

69
70
71
72
73
74
75
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 69

def do_the_calculation
  result = ::Bioroebe.calculate_exponential_growth(
    number_of_cells     = @entry_point_start_with_n_bacteria.text?,
    number_of_divisions = @entry_point_use_n_divisions.text?
  )
  @entry_point_n_cells.set_text(result.to_s)
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)

53
54
55
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 53

def padding?
  12
end

#reset_shared_moduleObject

#

reset_shared_module

#

46
47
48
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 46

def reset_shared_module
  title_width_height(TITLE, WIDTH, HEIGHT)
end

#runObject

#

run (run tag)

#

212
213
214
# File 'lib/bioroebe/gui/shared_code/calculate_cell_numbers_of_bacteria/calculate_cell_numbers_of_bacteria_module.rb', line 212

def run
  create_skeleton_then_connect_skeleton
end