skatolo 0.7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/skatolo.rb +141 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87d2881b5488da17684459af3248602ee7f94173
|
4
|
+
data.tar.gz: 50640b5f31b4a1d72a617cce2732a7909ba7060b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf2c72906650729814e28238cdd0b8caaadc29c01d6a1f2d3a6b8cc835a257185db86bef256126ecf0c367a3f5cfd5456449dc8ec5011c6027c1d112db068c6d
|
7
|
+
data.tar.gz: bbdd68d909d080bb9ee6d342e1666751d182a96ef29de363bb35b11e53b8e6471680ea5da6c8d1dbf557ec57b9465659f51dfcc670ee3508377064b131045c10
|
data/lib/skatolo.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'jruby/core_ext'
|
2
|
+
|
3
|
+
Processing::App.load_library :skatolo
|
4
|
+
|
5
|
+
# module skatolo
|
6
|
+
# include_package 'fr.inria.papart.skatolo'
|
7
|
+
# end
|
8
|
+
|
9
|
+
class EventHandler
|
10
|
+
|
11
|
+
def initialize skatolo
|
12
|
+
@skatolo = skatolo
|
13
|
+
end
|
14
|
+
|
15
|
+
java_signature 'void controlEvent(fr.inria.skatolo.events.ControlEvent)'
|
16
|
+
def controlEvent(controlEvent)
|
17
|
+
@skatolo.send_event_to_sketch controlEvent
|
18
|
+
end
|
19
|
+
|
20
|
+
EventHandler.become_java!
|
21
|
+
end
|
22
|
+
|
23
|
+
class Skatolo < Java::FrInriaSkatolo::Skatolo
|
24
|
+
|
25
|
+
def initialize (applet, events_object = nil)
|
26
|
+
@event_handler = EventHandler.new self
|
27
|
+
@events_object = events_object if events_object != nil
|
28
|
+
@events_object = applet if events_object == nil
|
29
|
+
|
30
|
+
super(applet, @event_handler)
|
31
|
+
# @applet = applet
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
getAll.to_a.each do |controller|
|
36
|
+
name = controller.name
|
37
|
+
## There is a method with this name...
|
38
|
+
|
39
|
+
if not (@events_object.respond_to? name + "_value")
|
40
|
+
# puts "please declare a method for " + name
|
41
|
+
create_getter_for name
|
42
|
+
create_setter_for name
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Event function...
|
48
|
+
def send_event_to_sketch(controlEvent)
|
49
|
+
controller = get(controlEvent.getName)
|
50
|
+
name = controlEvent.getName
|
51
|
+
value = controlEvent.getValue
|
52
|
+
string_value = controlEvent.getStringValue
|
53
|
+
|
54
|
+
# puts controller.object_id.to_s
|
55
|
+
|
56
|
+
## There is a method with this name...
|
57
|
+
if @events_object.respond_to? name
|
58
|
+
|
59
|
+
## Buttons usually, not arguments.
|
60
|
+
if is_event_class controller.class
|
61
|
+
@events_object.send(name)
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
## Sliders, check arity
|
66
|
+
if is_value_class controller.class
|
67
|
+
|
68
|
+
## try to send the value
|
69
|
+
@events_object.send(name, value)
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
## Text
|
74
|
+
## Sliders, check arity
|
75
|
+
if is_string_value_class controller.class
|
76
|
+
## try to send the value
|
77
|
+
@events_object.send(name, string_value)
|
78
|
+
return
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def create_getter_for name
|
85
|
+
controller = get(name)
|
86
|
+
return if is_event_class controller.class
|
87
|
+
|
88
|
+
value = get_controller_value(controller)
|
89
|
+
|
90
|
+
@events_object.create_method(name + "_value") do
|
91
|
+
controller = @skatolo.get(name)
|
92
|
+
@skatolo.get_controller_value controller
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
def create_setter_for name
|
98
|
+
|
99
|
+
controller = get(name)
|
100
|
+
return if is_event_class controller.class
|
101
|
+
|
102
|
+
value = get_controller_value controller
|
103
|
+
# puts "Creating a setter for " + name
|
104
|
+
|
105
|
+
@events_object.create_method(name + "_value=") do |value|
|
106
|
+
controller = @skatolo.get(name)
|
107
|
+
@skatolo.set_controller_value controller, value
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def get_controller_value controller
|
114
|
+
return 1 if is_event_class controller.class
|
115
|
+
return controller.getValue if is_value_class controller.class
|
116
|
+
return controller.getStringValue if is_string_value_class controller.class
|
117
|
+
end
|
118
|
+
|
119
|
+
def set_controller_value controller, value
|
120
|
+
return if is_event_class controller.class
|
121
|
+
return controller.setValue value if is_value_class controller.class
|
122
|
+
return controller.setStringValue value if is_string_value_class controller.class
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def is_event_class object_class
|
127
|
+
object_class == Java::FrInriaSkatoloGuiControllers::Button or
|
128
|
+
object_class == Java::FrInriaSkatoloGuiControllers::Bang
|
129
|
+
end
|
130
|
+
|
131
|
+
def is_value_class object_class
|
132
|
+
object_class == Java::FrInriaSkatoloGuiControllers::Slider or
|
133
|
+
object_class == Java::FrInriaSkatoloGuiControllers::Numberbox
|
134
|
+
end
|
135
|
+
|
136
|
+
def is_string_value_class object_class
|
137
|
+
object_class == Java::FrInriaSkatoloGuiControllers::Textfield
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skatolo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeremy Laviole
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.2'
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.2.4
|
22
|
+
name: jruby_art
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.4
|
33
|
+
description: 'Based on ControlP5 for new purposes and JRubyArt. Only works with JrubyArt
|
34
|
+
and require Skatolo library to be installed in Processing. '
|
35
|
+
email: poqudrof@gmail.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- lib/skatolo.rb
|
41
|
+
homepage: https://github.com/poqudrof/skatolo
|
42
|
+
licenses:
|
43
|
+
- LGPL
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.6.4
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: Skatolo - Gui library for jruby_art
|
65
|
+
test_files: []
|