wads 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2652d96c92be67ffd117365e2eb1ed93c21fd6f6c83cae037c6761f3f70754d5
4
- data.tar.gz: e1680952ab2bdd333bc518ae7d97bca0a8bfc4033e2b0b9f8bf062e689ee22e9
3
+ metadata.gz: 14aff80a445145535994cd93357eae0a5ed6b3b5ae31c722ab043e92857dc645
4
+ data.tar.gz: 5cbcc5dea862306c0d9e572f8781b78f1da32e77947f130ef49670ff3f9ef8fd
5
5
  SHA512:
6
- metadata.gz: 2e07cd62b59ca7d4e73176a94f3396f37f2981b6d448ebdd9490f9b6d5c0a69e0cd531805fed3e5512435b2d9a669521b1a047e0d022dd9ee0fb1ffb9ddd1941
7
- data.tar.gz: 9189a546fe8c0f74fa0e18abbca8de17eacd70b63b7092e09374b4315f832ed359f62add905a3ce9c82641728b569846fc44f04007b2e14bcdb28e0608f35e3d
6
+ metadata.gz: 1e43b86028c31695ecee423d4cda06a59e09386f55cd08507058443373541f2dd2914dae44d0f6c5d2937688546b37986f0c7cc66f7ae4f24d749d4457e390f3
7
+ data.tar.gz: 954a9e628886be15e7e91cdf3a7522c845480e48b49cd0c01666d91fb695f6885c06775933d1f36ff64ce3db75e508a2f2d37e20b8067fa8dce442dead4aa32d
data/README.md CHANGED
@@ -27,6 +27,9 @@ cd ruby-wads
27
27
  This will run the sample NASDAQ stocks analysis that features the use of the
28
28
  Stats class, and a table Gosu widget used to display the results of the analysis.
29
29
 
30
+ ![alt Screenshot](https://github.com/dbroemme/ruby-wads/blob/main/media/StocksSample.png?raw=true)
31
+
32
+
30
33
  You can also see the graph capabilities by running the Star Wars analysis example.
31
34
  This uses a data set that captures all character interactions within Episode 4.
32
35
 
@@ -38,6 +41,34 @@ There is also a sample Graph display using the following command.
38
41
  ```
39
42
  ./run-sample-app -g
40
43
  ```
44
+ Note that you can construct graphs in one of two ways. The first approach uses Nodes directly.
45
+ ```
46
+ root = Node.new("a")
47
+ b = root.add("b")
48
+ b.add("d")
49
+ b.add("e").add("f")
50
+ root.add("c")
51
+ Graph.new(root)
52
+ ```
53
+ The second approach uses an overarching Graph object.
54
+ ```
55
+ g = Graph.new
56
+ g.add("a")
57
+ g.add("b")
58
+ g.add("c")
59
+ g.add("d")
60
+ g.add("e")
61
+ g.add("f")
62
+ g.connect("a", "b")
63
+ g.connect("a", "c")
64
+ g.connect("b", "d")
65
+ g.connect("b", "e")
66
+ g.connect("e", "f")
67
+ ```
68
+
69
+ Currently, the Graph object is used by the Graph Widget for display. For the code above, this appears by default as follows:
70
+
71
+ ![alt Screenshot](https://github.com/dbroemme/ruby-wads/blob/main/media/SampleGraph.png?raw=true)
41
72
 
42
73
  ## References
43
74
 
data/lib/wads/app.rb CHANGED
@@ -49,7 +49,7 @@ class WadsSampleApp < Gosu::Window
49
49
  process_lottery_data
50
50
 
51
51
  elsif opts[:graph]
52
- graph = create_test_graph
52
+ graph = create_test_graph #_using_nodes
53
53
  if not opts[:text]
54
54
  @display_widget = SampleGraphDisplay.new(@small_font, graph)
55
55
  show
@@ -204,6 +204,15 @@ class WadsSampleApp < Gosu::Window
204
204
  g.connect("e", "f")
205
205
  g
206
206
  end
207
+
208
+ def create_test_graph_using_nodes
209
+ root = Node.new("a")
210
+ b = root.add("b")
211
+ b.add("d")
212
+ b.add("e").add("f")
213
+ root.add("c")
214
+ Graph.new(root)
215
+ end
207
216
  end
208
217
 
209
218
  class SampleStocksDisplay < Widget
@@ -271,6 +271,14 @@ module Wads
271
271
  @visited = false
272
272
  @tags = tags
273
273
  end
274
+
275
+ def add(name, value = nil, tags = {})
276
+ add_output_node(Node.new(name, value, tags))
277
+ end
278
+
279
+ def children
280
+ @outputs
281
+ end
274
282
 
275
283
  def add_child(name, value)
276
284
  add_output(name, value)
@@ -400,9 +408,14 @@ module Wads
400
408
  attr_accessor :node_list
401
409
  attr_accessor :node_map
402
410
 
403
- def initialize
411
+ def initialize(root_node = nil)
404
412
  @node_list = []
405
413
  @node_map = {}
414
+ if root_node
415
+ root_node.visit do |n|
416
+ add_node(n)
417
+ end
418
+ end
406
419
  end
407
420
 
408
421
  def add(name, value = nil, tags = {})
data/lib/wads/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wads
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/wads/widgets.rb CHANGED
@@ -946,6 +946,9 @@ module Wads
946
946
 
947
947
  def is_row_selected(mouse_y)
948
948
  row_number = determine_row_number(mouse_y)
949
+ if row_number.nil?
950
+ return false
951
+ end
949
952
  @selected_rows.include?(@current_row + row_number)
950
953
  end
951
954
 
@@ -995,6 +998,9 @@ module Wads
995
998
  def handle_mouse_down mouse_x, mouse_y
996
999
  if contains_click(mouse_x, mouse_y)
997
1000
  row_number = determine_row_number(mouse_y)
1001
+ if row_number.nil?
1002
+ return WidgetResult.new(false)
1003
+ end
998
1004
  # First check if its the delete button that got this
999
1005
  delete_this_row = false
1000
1006
  @delete_buttons.each do |db|
@@ -1423,6 +1429,7 @@ module Wads
1423
1429
  @rendered_nodes.values.each do |vn|
1424
1430
  vn.draw
1425
1431
  end
1432
+
1426
1433
  # Draw the connections between nodes
1427
1434
  @visible_data_nodes.values.each do |data_node|
1428
1435
  data_node.outputs.each do |connected_data_node|
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dbroemme
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-07 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu
@@ -77,6 +77,8 @@ files:
77
77
  - lib/wads/version.rb
78
78
  - lib/wads/widgets.rb
79
79
  - media/Banner.png
80
+ - media/SampleGraph.png
81
+ - media/StocksSample.png
80
82
  - media/WadsScreenshot.png
81
83
  - run-sample-app
82
84
  - sample_app.rb