Class: SimpleController

Inherits:
Object
  • Object
show all
Defined in:
lib/app/simple_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modelObject

Returns the value of attribute model.



60
61
62
# File 'lib/app/simple_controller.rb', line 60

def model
  @model
end

#viewObject

Returns the value of attribute view.



60
61
62
# File 'lib/app/simple_controller.rb', line 60

def view
  @view
end

Instance Method Details

#add_edgeObject



79
80
81
# File 'lib/app/simple_controller.rb', line 79

def add_edge
  @view.add_mouse_listener(AddEdgeMouseListener.new(self))
end

#add_nodeObject



71
72
73
# File 'lib/app/simple_controller.rb', line 71

def add_node
  @view.add_mouse_listener(AddNodeMouseListener.new(self))
end

#center_xObject



238
239
240
# File 'lib/app/simple_controller.rb', line 238

def center_x
  @model.center_x
end

#center_yObject



242
243
244
# File 'lib/app/simple_controller.rb', line 242

def center_y
  @model.center_y
end

#choose_generatorObject



98
99
100
101
# File 'lib/app/simple_controller.rb', line 98

def choose_generator
  @view.add_info_panel("Generate Graph. Enter Generation Mode [Random <s>, Linear <s>, Ring <s>, Mesh <r>, Connected <s>]")
  @view.add_text_field(GenerateGraphActionListener.new(self))
end

#choose_graph_typeObject



103
104
105
106
# File 'lib/app/simple_controller.rb', line 103

def choose_graph_type
  @view.add_info_panel("Choose graph type: [directed, undirected]")
  @view.add_text_field(GraphTypeActionListener.new(self))
end

#choose_layoutObject



93
94
95
96
# File 'lib/app/simple_controller.rb', line 93

def choose_layout
  @view.add_info_panel("Select Layout. Enter Type [Random, Circle, FR, ISOM]")
  @view.add_text_field(LayoutActionListener.new(self))
end

#count_nodesObject



205
206
207
# File 'lib/app/simple_controller.rb', line 205

def count_nodes
  @model.count_nodes
end

#del_edgeObject



83
84
85
# File 'lib/app/simple_controller.rb', line 83

def del_edge
  @view.add_mouse_listener(DelEdgeMouseListener.new(self))
end

#del_nodeObject



75
76
77
# File 'lib/app/simple_controller.rb', line 75

def del_node
  @view.add_mouse_listener(DelNodeMouseListener.new(self))
end

#do_layoutObject



108
109
110
# File 'lib/app/simple_controller.rb', line 108

def do_layout
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#generate_graphObject



120
121
# File 'lib/app/simple_controller.rb', line 120

def generate_graph
end

#move_layout_downObject



234
235
236
# File 'lib/app/simple_controller.rb', line 234

def move_layout_down
  @model.move_layout(0, 5)
end

#move_layout_leftObject



222
223
224
# File 'lib/app/simple_controller.rb', line 222

def move_layout_left
  @model.move_layout(-5, 0)
end

#move_layout_rightObject



226
227
228
# File 'lib/app/simple_controller.rb', line 226

def move_layout_right
  @model.move_layout(5, 0)
end

#move_layout_upObject



230
231
232
# File 'lib/app/simple_controller.rb', line 230

def move_layout_up
  @model.move_layout(0, -5)
end

#move_nodeObject



87
88
89
90
91
# File 'lib/app/simple_controller.rb', line 87

def move_node
  listener = MoveNodeMouseListener.new(self)
  @view.add_mouse_motion_listener(listener)
  @view.add_mouse_listener(listener)
end

#new_graphObject



112
113
114
115
# File 'lib/app/simple_controller.rb', line 112

def new_graph
  @model.new_empty_graph
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#new_layoutObject



117
118
# File 'lib/app/simple_controller.rb', line 117

def new_layout
end


192
193
194
195
# File 'lib/app/simple_controller.rb', line 192

def print_info
  puts @controller.model.layout
  puts @controller.model.graph
end

#rotate_layout_leftObject



218
219
220
# File 'lib/app/simple_controller.rb', line 218

def rotate_layout_left
  @model.rotate_layout(-2)
end

#rotate_layout_rightObject



214
215
216
# File 'lib/app/simple_controller.rb', line 214

def rotate_layout_right
  @model.rotate_layout(2)
end

#select_nodeObject



123
124
125
# File 'lib/app/simple_controller.rb', line 123

def select_node

end

#set_bintree(size) ⇒ Object



172
173
174
175
# File 'lib/app/simple_controller.rb', line 172

def set_bintree(size)
  @model.new_binary_tree(size)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_circle_layoutObject



132
133
134
135
# File 'lib/app/simple_controller.rb', line 132

def set_circle_layout
  @model.set_circle_layout
  @model.layout.layout
end

#set_collapse_layoutObject



157
158
159
160
# File 'lib/app/simple_controller.rb', line 157

def set_collapse_layout
  @model.set_collapse_layout
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_connected(size) ⇒ Object



177
178
179
180
# File 'lib/app/simple_controller.rb', line 177

def set_connected(size)
  @model.new_connected_graph(size)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_fr_layoutObject



137
138
139
140
# File 'lib/app/simple_controller.rb', line 137

def set_fr_layout
  @model.set_fr_layout
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_isom_layoutObject



142
143
144
145
# File 'lib/app/simple_controller.rb', line 142

def set_isom_layout
  @model.set_isom_layout
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_kk_layoutObject



147
148
149
150
# File 'lib/app/simple_controller.rb', line 147

def set_kk_layout
  @model.set_kk_layout
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_linear(size) ⇒ Object



182
183
184
185
# File 'lib/app/simple_controller.rb', line 182

def set_linear(size)
  @model.new_linear_graph(size)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_mesh(rows) ⇒ Object



187
188
189
190
# File 'lib/app/simple_controller.rb', line 187

def set_mesh(rows)
  @model.new_mesh_graph(rows)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_morph_layout(target_layout_class) ⇒ Object



152
153
154
155
# File 'lib/app/simple_controller.rb', line 152

def set_morph_layout(target_layout_class)
  @model.set_morph_layout(target_layout_class)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_random(size) ⇒ Object



162
163
164
165
# File 'lib/app/simple_controller.rb', line 162

def set_random(size)
  @model.new_random_graph(size)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#set_random_layoutObject



127
128
129
130
# File 'lib/app/simple_controller.rb', line 127

def set_random_layout
  @model.set_random_layout
  @model.layout.layout
end

#set_ring(size) ⇒ Object



167
168
169
170
# File 'lib/app/simple_controller.rb', line 167

def set_ring(size)
  @model.new_ring_graph(size)
  java.lang.Thread.new(java.lang.Runnable.impl { @model.layout.layout }).start
end

#shortest_pathObject



197
198
199
# File 'lib/app/simple_controller.rb', line 197

def shortest_path
  @view.add_mouse_listener(ShortestPathMouseListener.new(self))
end

#shortest_treeObject



201
202
203
# File 'lib/app/simple_controller.rb', line 201

def shortest_tree
  @view.add_mouse_listener(ShortestTreeMouseListener.new(self))
end

#toggle_paint_iterationsObject



209
210
211
212
# File 'lib/app/simple_controller.rb', line 209

def toggle_paint_iterations
  @view.toggle_paint_iterations
  $LOG.info "PluggableRenderer: paint_iterations? #{@view.canvas.paint_iterations?}"
end