From 9f686d05e61a3342a5f7dc4a3109747e066ab93f Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Fri, 5 May 2017 07:05:38 +0100 Subject: [PATCH 01/31] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 852c54d..84771b0 100644 --- a/README.md +++ b/README.md @@ -70,4 +70,7 @@ propane --install video ``` Other java libraries can be manually installed to the same folder (no need for processing ide) +See [gh-pages][gh-pages] for more detailed instructions and much more. + [building]:http://ruby-processing.github.io/building/building/ +[gh-pages]:https://ruby-processing.github.io/propane/ From f800bb27ba032a230ee801e6194fdcb5e6da31e8 Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 4 Jun 2017 08:46:05 +0100 Subject: [PATCH 02/31] bump versions --- CHANGELOG.md | 2 ++ pom.rb | 6 +++--- pom.xml | 6 +++--- propane.gemspec | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 074de86..38899f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +**v2.3.2** Update to processing-3.3.4, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade jruby-9.1.10.0 last in 9.1 series? + **v2.3.1** Update to processing-3.3.1, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade to final jruby-9.1.x.x **v2.3.0** Update to core processing-3.3 `grid` method now implemented in java, bump examples to include WOVNS diff --git a/pom.rb b/pom.rb index 08d18cb..f9d2049 100644 --- a/pom.rb +++ b/pom.rb @@ -32,8 +32,8 @@ 'jogl.version' => '2.3.2' ) - pom 'org.jruby:jruby:9.1.8.0' - jar 'org.processing:core:3.3.2' + pom 'org.jruby:jruby:9.1.10.0' + jar 'org.processing:core:3.3.4' jar 'org.processing:video:3.0.2' jar('org.jogamp.jogl:jogl-all:${jogl.version}') jar('org.jogamp.gluegen:gluegen-rt-main:${jogl.version}') @@ -44,7 +44,7 @@ execute_goals( id: 'default-cli', artifactItems: [ { groupId: 'org.processing', artifactId: 'core', - version: '3.3.2', + version: '3.3.4', type: 'jar', outputDirectory: '${propane.basedir}/lib' }, diff --git a/pom.xml b/pom.xml index d33010e..0f0eb4e 100644 --- a/pom.xml +++ b/pom.xml @@ -58,13 +58,13 @@ DO NOT MODIFIY - GENERATED CODE org.jruby jruby - 9.1.8.0 + 9.1.10.0 pom org.processing core - 3.3.2 + 3.3.4 org.processing @@ -103,7 +103,7 @@ DO NOT MODIFIY - GENERATED CODE org.processing core - 3.3.2 + 3.3.4 jar ${propane.basedir}/lib diff --git a/propane.gemspec b/propane.gemspec index ab758dd..4c5e606 100644 --- a/propane.gemspec +++ b/propane.gemspec @@ -10,11 +10,11 @@ Gem::Specification.new do |gem| gem.email = ['mamba2928@yahoo.co.uk'] gem.licenses = %w(GPL-3.0 LGPL-2.0) gem.description = %q{A batteries included version of processing in ruby, MacOS and linux64} - gem.summary = %q{ruby wrapper for processing-3.3.1 on MacOS and linux64 bit only for opengl} + gem.summary = %q{ruby wrapper for processing-3.3.4 on MacOS and linux64 bit only for opengl} gem.homepage = 'https://ruby-processing.github.io/propane/' gem.files = `git ls-files`.split($/) gem.files << 'lib/propane.jar' - gem.files << 'lib/core-3.3.2.jar' + gem.files << 'lib/core-3.3.4.jar' gem.files << 'lib/gluegen-rt-2.3.2.jar' gem.files << 'lib/jogl-all-2.3.2.jar' gem.files << 'lib/gluegen-rt-2.3.2-natives-linux-amd64.jar' @@ -23,7 +23,7 @@ Gem::Specification.new do |gem| gem.files << 'lib/jogl-all-2.3.2-natives-macosx-universal.jar' gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.0' + gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.0' gem.require_paths = ['lib'] gem.platform = 'java' end From 21f7d9da65ec2264874766ba0b59c8ff23e88896 Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 4 Jun 2017 08:47:05 +0100 Subject: [PATCH 03/31] bump versions --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 92a1ac2..5b70c6e 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ def create_manifest File.open('MANIFEST.MF', 'w') do |f| f.puts(title) f.puts(version) - f.puts('Class-Path: core-3.3.1.jar gluegen-rt-2.3.2.jar jog-all-2.3.2.jar') + f.puts('Class-Path: core-3.3.4.jar gluegen-rt-2.3.2.jar jog-all-2.3.2.jar') end end From 4fb0140fd52f7e580275ef63a7c784929ad92192 Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 11 Jun 2017 16:18:20 +0100 Subject: [PATCH 04/31] update processing --- CHANGELOG.md | 2 +- lib/propane/version.rb | 2 +- pom.rb | 2 +- pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38899f2..9908a3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -**v2.3.2** Update to processing-3.3.4, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade jruby-9.1.10.0 last in 9.1 series? +**v2.3.3** Update to processing-3.3.4, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade jruby-9.1.10.0 last in 9.1 series? **v2.3.1** Update to processing-3.3.1, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade to final jruby-9.1.x.x diff --git a/lib/propane/version.rb b/lib/propane/version.rb index 6e3d413..af93562 100644 --- a/lib/propane/version.rb +++ b/lib/propane/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Propane - VERSION = '2.3.2'.freeze + VERSION = '2.3.3'.freeze end diff --git a/pom.rb b/pom.rb index f9d2049..81dedcd 100644 --- a/pom.rb +++ b/pom.rb @@ -1,7 +1,7 @@ require 'fileutils' project 'rp5extras', 'https://github.com/monkstone/propane' do model_version '4.0.0' - id 'propane:propane', '2.3.2' + id 'propane:propane', '2.3.3' packaging 'jar' description 'rp5extras for propane' organization 'ruby-processing', 'https://ruby-processing.github.io' diff --git a/pom.xml b/pom.xml index 0f0eb4e..c36257f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE 4.0.0 propane propane - 2.3.2 + 2.3.3 rp5extras rp5extras for propane https://github.com/monkstone/propane From 278f5667f16e7eb427c8685c55f4a12c116130f1 Mon Sep 17 00:00:00 2001 From: monkstone Date: Thu, 15 Jun 2017 19:16:58 +0100 Subject: [PATCH 05/31] bump jruby version --- .travis.yml | 5 ++--- CHANGELOG.md | 4 +++- README.md | 8 ++++---- pom.rb | 2 +- pom.xml | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index f49d9aa..19d7175 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ language: ruby sudo: false -rvm: - - jruby-9.1.6.0 +rvm: + - jruby-9.1.12.0 jdk: - oraclejdk8 os: - linux - diff --git a/CHANGELOG.md b/CHANGELOG.md index 9908a3c..3c280ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ -**v2.3.3** Update to processing-3.3.4, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade jruby-9.1.10.0 last in 9.1 series? +**v2.3.3** Update to processing-3.3.4, and upgrade jruby-9.1.12.0 last in 9.1 series? + +**v2.3.3** Update to processing-3.3.2 **v2.3.1** Update to processing-3.3.1, Update samples which now include `#!/usr/bin/env jruby` to assist running sketches from atom, add Rakefile for automatic sketch running for many samples, expected upgrade to final jruby-9.1.x.x diff --git a/README.md b/README.md index 84771b0..00dec82 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ A slim layer to communicate with Processing from JRuby, features a polyglot mave ## Requirements - jdk8+ -- jruby-9.1.8.0+ -- mvn-3.3.1+ (development only) -- core.jar processing-3.3.1 (development only until processing.org is available at maven central) +- jruby-9.1.12.0 +- mvn-3.5.0+ +- core.jar processing-3.3.4 ## Building and testing @@ -21,7 +21,7 @@ rake javadoc ## Installation ```bash jgem install propane # from rubygems -jgem install propane-2.3.1-java.gem # for local install +jgem install propane-2.3.3-java.gem # for local install ``` ## Usage diff --git a/pom.rb b/pom.rb index 81dedcd..bb1c9c2 100644 --- a/pom.rb +++ b/pom.rb @@ -32,7 +32,7 @@ 'jogl.version' => '2.3.2' ) - pom 'org.jruby:jruby:9.1.10.0' + pom 'org.jruby:jruby:9.1.12.0' jar 'org.processing:core:3.3.4' jar 'org.processing:video:3.0.2' jar('org.jogamp.jogl:jogl-all:${jogl.version}') diff --git a/pom.xml b/pom.xml index c36257f..8b14c8b 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ DO NOT MODIFIY - GENERATED CODE org.jruby jruby - 9.1.10.0 + 9.1.12.0 pom From 5865b40b42082ebc5932841992185e5734e2bcc9 Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Fri, 16 Jun 2017 08:34:27 +0100 Subject: [PATCH 06/31] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00dec82..08ae1a1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Propane -[![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane) +[![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane) [![Travis CI](https://travis-ci.org/ruby-processing/propane.svg)](https://travis-ci.org/ruby-processing/propane) A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.3.1, where we include processing core (from a local maven repository and opengl etc from maven central). These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby, but you could use jruby-complete if you used the propane script (avoids need to give the absolute data path for the data folder, but would also be needed for a watch mode). See guide to [building ruby-processing projects][building]. From 98925e7f6dac6e325c9d8c7aa5f32849c802e871 Mon Sep 17 00:00:00 2001 From: monkstone Date: Fri, 16 Jun 2017 08:52:23 +0100 Subject: [PATCH 07/31] rake is a development dependency --- propane.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/propane.gemspec b/propane.gemspec index 4c5e606..b5d2a9d 100644 --- a/propane.gemspec +++ b/propane.gemspec @@ -23,6 +23,7 @@ Gem::Specification.new do |gem| gem.files << 'lib/jogl-all-2.3.2-natives-macosx-universal.jar' gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.add_development_dependency 'rake', '~> 12' gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.0' gem.require_paths = ['lib'] gem.platform = 'java' From 3913b70f3312bf0c7796ab8cbcf61243dbba4479 Mon Sep 17 00:00:00 2001 From: monkstone Date: Fri, 16 Jun 2017 09:02:29 +0100 Subject: [PATCH 08/31] include gemspec --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index c9721cb..fa75df1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,3 @@ source 'https://rubygems.org' +gemspec From d655ef3686d3dd690a189c168980578e063fe127 Mon Sep 17 00:00:00 2001 From: monkstone Date: Fri, 16 Jun 2017 09:14:46 +0100 Subject: [PATCH 09/31] include minitest in gemspec --- propane.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/propane.gemspec b/propane.gemspec index b5d2a9d..bc5eb44 100644 --- a/propane.gemspec +++ b/propane.gemspec @@ -24,6 +24,7 @@ Gem::Specification.new do |gem| gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.add_development_dependency 'rake', '~> 12' + gem.add_development_dependency 'minitest', '~> 5.10' gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.0' gem.require_paths = ['lib'] gem.platform = 'java' From 0d35c026272ad53b39da846c2e48817a28bb78ac Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Fri, 16 Jun 2017 15:11:03 +0100 Subject: [PATCH 10/31] Update respond_to_test.rb Skip test to avoid Travis Fail --- test/respond_to_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/respond_to_test.rb b/test/respond_to_test.rb index 8bf9879..699b1a9 100644 --- a/test/respond_to_test.rb +++ b/test/respond_to_test.rb @@ -204,6 +204,7 @@ def setup end def test_respond + skip(msg = "Headless fail on Travis") METHODS.each do |method_string| assert_respond_to @propane_sketch, method_string end From 07f917b327bd786d5b9659d06e26ae1abc7fd011 Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Fri, 16 Jun 2017 15:23:05 +0100 Subject: [PATCH 11/31] Update Rakefile --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 5b70c6e..242d874 100644 --- a/Rakefile +++ b/Rakefile @@ -47,7 +47,7 @@ end desc 'Test' task :test do sh 'jruby test/helper_methods_test.rb' - sh 'jruby test/respond_to_test.rb' + # sh 'jruby test/respond_to_test.rb' Skip test on Travis to avoid Headless fail sh 'jruby test/create_test.rb' sh 'jruby test/math_tool_test.rb' sh 'jruby test/deglut_spec_test.rb' From 6577b2b50a9309bcf5d7176fb471f14243e56c25 Mon Sep 17 00:00:00 2001 From: monkstone Date: Fri, 16 Jun 2017 16:03:45 +0100 Subject: [PATCH 12/31] skip doesn't work because setup fails --- test/respond_to_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/respond_to_test.rb b/test/respond_to_test.rb index 699b1a9..8bf9879 100644 --- a/test/respond_to_test.rb +++ b/test/respond_to_test.rb @@ -204,7 +204,6 @@ def setup end def test_respond - skip(msg = "Headless fail on Travis") METHODS.each do |method_string| assert_respond_to @propane_sketch, method_string end From bbdf8ac7b605e83477095b720b5fb1762844243b Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 16 Jul 2017 14:02:09 +0100 Subject: [PATCH 13/31] control panel fixes --- lib/propane/app.rb | 32 ++++++++++++-------------- library/control_panel/control_panel.rb | 8 +++---- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/propane/app.rb b/lib/propane/app.rb index 4980a1c..73959ff 100644 --- a/lib/propane/app.rb +++ b/lib/propane/app.rb @@ -139,15 +139,15 @@ def data_path(dat) def import_opengl # Include processing opengl classes that we'd like to use: - %w(FontTexture FrameBuffer LinePath LineStroker PGL + %w[FontTexture FrameBuffer LinePath LineStroker PGL PGraphics2D PGraphics3D PGraphicsOpenGL PShader - PShapeOpenGL Texture).each do |klass| + PShapeOpenGL Texture].each do |klass| java_import "processing.opengl.#{klass}" end end def proxy_java_fields - fields = %w(sketchPath key frameRate mousePressed keyPressed) + fields = %w[sketchPath key frameRate mousePressed keyPressed] methods = fields.map { |field| java_class.declared_field(field) } @declared_fields = Hash[fields.zip(methods)] end @@ -160,22 +160,20 @@ def method_added(method_name) #:nodoc: end end - # Importing PConstants to access processing constants, we also need to - # 'include PConstants' to avoid requiring the `PConstants::` prefix - # `include Math etc because we expect to use them` - # Using :method_missing to mimic inner class methods - # @HACK you should consider using 'forwardable' to avoid this - # egregious hack... + # @HACK purists may prefer 'forwardable' to the use of Proxy + # Importing PConstants here to access the processing constants module Proxy - java_import 'processing.core.PConstants' - include Math, MathTool, HelperMethods, PConstants - def respond_to_missing?(name, include_private = false) - $app.respond_to?(name) || super + include Math + include HelperMethods + include Java::ProcessingCore::PConstants + + def respond_to_missing?(symbol, include_priv = false) + $app.respond_to?(symbol, include_priv) || super end - def method_missing(name, *args) - return $app.send(name, *args) if $app && $app.respond_to?(name) + def method_missing(name, *args, &block) + return $app.send(name, *args) if $app.respond_to? name super end - end -end + end # Processing::Proxy +end # Propane diff --git a/library/control_panel/control_panel.rb b/library/control_panel/control_panel.rb index 5ffa743..14d0281 100644 --- a/library/control_panel/control_panel.rb +++ b/library/control_panel/control_panel.rb @@ -151,10 +151,10 @@ def look_feel(lf) def set_feel(lf = 'metal') lafinfo = javax.swing.UIManager.getInstalledLookAndFeels - laf = lafinfo.select do |info| - info.getName.eql? lf.capitalize + laf = lafinfo.to_ary.select do |info| + info.name =~ Regexp.new(Regexp.escape(lf), Regexp::IGNORECASE) end - javax.swing.UIManager.setLookAndFeel(laf[0].getClassName) + javax.swing.UIManager.setLookAndFeel(laf[0].class_name) end end @@ -169,4 +169,4 @@ def control_panel end end -Propane::App.send :include, ControlPanel::InstanceMethods +Propane::App.include(ControlPanel::InstanceMethods) From eabc98c53cf2180a04afc92ee6d03322e6bfd806 Mon Sep 17 00:00:00 2001 From: monkstone Date: Mon, 17 Jul 2017 15:17:16 +0100 Subject: [PATCH 14/31] control_panel --- library/control_panel/control_panel.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/control_panel/control_panel.rb b/library/control_panel/control_panel.rb index 14d0281..34e2d4f 100644 --- a/library/control_panel/control_panel.rb +++ b/library/control_panel/control_panel.rb @@ -66,11 +66,11 @@ def initialize(control_panel, name, proc = nil) set_horizontal_alignment javax.swing.SwingConstants::CENTER control_panel.add_element(self, name, false) add_action_listener do - $app.instance_variable_set("@#{name}", value) unless value.nil? + $app.instance_variable_set("@#{name}", value) proc.call(value) if proc end end - + # define value as checkbox state def value is_selected end @@ -83,7 +83,7 @@ def initialize(control_panel, name, proc = nil) set_preferred_size(java.awt.Dimension.new(170, 64)) control_panel.add_element(self, name, false, true) add_action_listener do - $app.send(name.to_s) + $app.send(name) proc.call(value) if proc end end @@ -126,6 +126,10 @@ def remove dispose end + def title(name) + set_title(name) + end + def slider(name, range = 0..100, initial_value = nil, &block) Slider.new(self, name, range, initial_value, block || nil) end @@ -134,7 +138,7 @@ def menu(name, elements, initial_value = nil, &block) Menu.new(self, name, elements, initial_value, block || nil) end - def checkbox(name, initial_value = nil, &block) + def checkbox(name, initial_value = false, &block) checkbox = Checkbox.new(self, name, block || nil) checkbox.do_click if initial_value == true end From 70a4248c998a3d96254caae8a7601945428a23dd Mon Sep 17 00:00:00 2001 From: monkstone Date: Wed, 19 Jul 2017 06:22:30 +0100 Subject: [PATCH 15/31] bump version --- CHANGELOG.md | 2 ++ README.md | 6 +++--- lib/propane/version.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c280ac..485727f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +**v2.3.4** Simplify control_panel library (replacing `c.title = 'PaneTitle'` with `c.title('PaneTitle')`) also enable use of `block` with `button's`. + **v2.3.3** Update to processing-3.3.4, and upgrade jruby-9.1.12.0 last in 9.1 series? **v2.3.3** Update to processing-3.3.2 diff --git a/README.md b/README.md index 08ae1a1..270bd60 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Propane [![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane) [![Travis CI](https://travis-ci.org/ruby-processing/propane.svg)](https://travis-ci.org/ruby-processing/propane) -A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.3.1, where we include processing core (from a local maven repository and opengl etc from maven central). These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby, but you could use jruby-complete if you used the propane script (avoids need to give the absolute data path for the data folder, but would also be needed for a watch mode). See guide to [building ruby-processing projects][building]. +A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.3.5, where we include processing core (from a local maven repository and opengl etc from maven central). These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby, but you could use jruby-complete if you used the propane script (avoids need to give the absolute data path for the data folder, but would also be needed for a watch mode). See guide to [building ruby-processing projects][building]. ## Requirements - jdk8+ - jruby-9.1.12.0 - mvn-3.5.0+ -- core.jar processing-3.3.4 +- core.jar processing-3.3.5 (_build only_) ## Building and testing @@ -21,7 +21,7 @@ rake javadoc ## Installation ```bash jgem install propane # from rubygems -jgem install propane-2.3.3-java.gem # for local install +jgem install propane-2.3.4-java.gem # for local install ``` ## Usage diff --git a/lib/propane/version.rb b/lib/propane/version.rb index af93562..5f11f7a 100644 --- a/lib/propane/version.rb +++ b/lib/propane/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Propane - VERSION = '2.3.3'.freeze + VERSION = '2.3.4'.freeze end From 9a5c93360c16b182d938e81858cf546dcd1ccd5b Mon Sep 17 00:00:00 2001 From: monkstone Date: Wed, 19 Jul 2017 07:07:05 +0100 Subject: [PATCH 16/31] oops had not been updating propane samples --- Rakefile | 2 +- vendors/Rakefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 242d874..b06df1f 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ def create_manifest File.open('MANIFEST.MF', 'w') do |f| f.puts(title) f.puts(version) - f.puts('Class-Path: core-3.3.4.jar gluegen-rt-2.3.2.jar jog-all-2.3.2.jar') + f.puts('Class-Path: core-3.3.5.jar gluegen-rt-2.3.2.jar jog-all-2.3.2.jar') end end diff --git a/vendors/Rakefile b/vendors/Rakefile index 24f239e..d80f974 100644 --- a/vendors/Rakefile +++ b/vendors/Rakefile @@ -9,7 +9,7 @@ SOUND = 'sound.zip'.freeze SOUND_VERSION = 'v1.3.2' # version 1.3.2 VIDEO = 'video-2.zip' VIDEO_VERSION = '2' # version 1.0.1 -EXAMPLES = '1.0'.freeze +EXAMPLES = '1.3'.freeze HOME_DIR = ENV['HOME'] MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os'] From 4dc7891a645d86cba3dcc481031c0c76784ea1de Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Wed, 19 Jul 2017 10:47:23 +0100 Subject: [PATCH 17/31] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 270bd60..eb73be6 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,13 @@ A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.3.5, where we include processing core (from a local maven repository and opengl etc from maven central). These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby, but you could use jruby-complete if you used the propane script (avoids need to give the absolute data path for the data folder, but would also be needed for a watch mode). See guide to [building ruby-processing projects][building]. +NB: The main reason for build failing is when the `core.jar` is bot available form maven central, to install a local jar:- +```bash + +mvn install:install-file /home/tux/processing-3.3.5/core/library/core.jar -DgroupId=org.processing -DartifactId=core -Dversion=3.3.5 +``` +adjust for your OS/distro. + ## Requirements - jdk8+ From 7ef012f7d36c46a851e6a4aaf1094c087fc5615a Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Wed, 19 Jul 2017 10:48:12 +0100 Subject: [PATCH 18/31] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb73be6..4c42233 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A slim layer to communicate with Processing from JRuby, features a polyglot maven build. We have created a configuration free version of ruby processing, for processing-3.3.5, where we include processing core (from a local maven repository and opengl etc from maven central). These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby, but you could use jruby-complete if you used the propane script (avoids need to give the absolute data path for the data folder, but would also be needed for a watch mode). See guide to [building ruby-processing projects][building]. -NB: The main reason for build failing is when the `core.jar` is bot available form maven central, to install a local jar:- +NB: The main reason for build failing is when the `core.jar` is not available from maven central, to install a local jar:- ```bash mvn install:install-file /home/tux/processing-3.3.5/core/library/core.jar -DgroupId=org.processing -DartifactId=core -Dversion=3.3.5 From 0995d15ab8b405b15355c4f820def4575454fc6d Mon Sep 17 00:00:00 2001 From: Martin Prout Date: Wed, 19 Jul 2017 10:48:59 +0100 Subject: [PATCH 19/31] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c42233..08275e5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ NB: The main reason for build failing is when the `core.jar` is not available fr mvn install:install-file /home/tux/processing-3.3.5/core/library/core.jar -DgroupId=org.processing -DartifactId=core -Dversion=3.3.5 ``` -adjust for your OS/distro. +adjust above for your OS/distro setup. ## Requirements From f510305e42b7431a07c6aeea21202a294032bf57 Mon Sep 17 00:00:00 2001 From: monkstone Date: Wed, 19 Jul 2017 10:50:34 +0100 Subject: [PATCH 20/31] get ready for release --- pom.rb | 6 +++--- pom.xml | 6 +++--- propane.gemspec | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.rb b/pom.rb index bb1c9c2..e19de26 100644 --- a/pom.rb +++ b/pom.rb @@ -1,7 +1,7 @@ require 'fileutils' project 'rp5extras', 'https://github.com/monkstone/propane' do model_version '4.0.0' - id 'propane:propane', '2.3.3' + id 'propane:propane', '2.3.4' packaging 'jar' description 'rp5extras for propane' organization 'ruby-processing', 'https://ruby-processing.github.io' @@ -33,7 +33,7 @@ ) pom 'org.jruby:jruby:9.1.12.0' - jar 'org.processing:core:3.3.4' + jar 'org.processing:core:3.3.5' jar 'org.processing:video:3.0.2' jar('org.jogamp.jogl:jogl-all:${jogl.version}') jar('org.jogamp.gluegen:gluegen-rt-main:${jogl.version}') @@ -44,7 +44,7 @@ execute_goals( id: 'default-cli', artifactItems: [ { groupId: 'org.processing', artifactId: 'core', - version: '3.3.4', + version: '3.3.5', type: 'jar', outputDirectory: '${propane.basedir}/lib' }, diff --git a/pom.xml b/pom.xml index 8b14c8b..f7f4163 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE 4.0.0 propane propane - 2.3.3 + 2.3.4 rp5extras rp5extras for propane https://github.com/monkstone/propane @@ -64,7 +64,7 @@ DO NOT MODIFIY - GENERATED CODE org.processing core - 3.3.4 + 3.3.5 org.processing @@ -103,7 +103,7 @@ DO NOT MODIFIY - GENERATED CODE org.processing core - 3.3.4 + 3.3.5 jar ${propane.basedir}/lib diff --git a/propane.gemspec b/propane.gemspec index bc5eb44..8f59e21 100644 --- a/propane.gemspec +++ b/propane.gemspec @@ -10,11 +10,11 @@ Gem::Specification.new do |gem| gem.email = ['mamba2928@yahoo.co.uk'] gem.licenses = %w(GPL-3.0 LGPL-2.0) gem.description = %q{A batteries included version of processing in ruby, MacOS and linux64} - gem.summary = %q{ruby wrapper for processing-3.3.4 on MacOS and linux64 bit only for opengl} + gem.summary = %q{ruby wrapper for processing-3.3.5 on MacOS and linux64 bit only for opengl} gem.homepage = 'https://ruby-processing.github.io/propane/' gem.files = `git ls-files`.split($/) gem.files << 'lib/propane.jar' - gem.files << 'lib/core-3.3.4.jar' + gem.files << 'lib/core-3.3.5.jar' gem.files << 'lib/gluegen-rt-2.3.2.jar' gem.files << 'lib/jogl-all-2.3.2.jar' gem.files << 'lib/gluegen-rt-2.3.2-natives-linux-amd64.jar' From a58d650f7fae60a921f6ef5141cec7d3f5ff50be Mon Sep 17 00:00:00 2001 From: monkstone Date: Thu, 20 Jul 2017 14:55:35 +0100 Subject: [PATCH 21/31] tidy up creator --- lib/propane/creators/sketch_class.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/propane/creators/sketch_class.rb b/lib/propane/creators/sketch_class.rb index c2769e1..c1842f4 100644 --- a/lib/propane/creators/sketch_class.rb +++ b/lib/propane/creators/sketch_class.rb @@ -1,4 +1,5 @@ -#frozen_string_literal: false +# frozen_string_literal: false + # the sketch class class SketchClass attr_reader :name, :width, :height, :mode @@ -24,7 +25,7 @@ def indent(line) end def size - return format(' size %d, %d', width.to_i, height.to_i) if mode.nil? + return format(' size %d, %d', width.to_i, height.to_i) unless mode format(' size %d, %d, %s', width.to_i, height.to_i, mode.upcase) end @@ -33,8 +34,8 @@ def sketch_title format(" sketch_title '%s'", human) end - def method_lines(name, content = '') - return [format(' def %s', name), content, ' end'] if content.empty? + def method_lines(name, content = nil) + return [format(' def %s', name), '', ' end'] unless content [format(' def %s', name), content, ' end', ''] end @@ -50,6 +51,7 @@ def lines lines.concat method_lines('setup', sketch_title) lines.concat method_lines('draw') lines << 'end' + lines << '' lines << sketch_new end end From 1592fe4b299df1a6fde23ff4fdf57a261a817616 Mon Sep 17 00:00:00 2001 From: monkstone Date: Thu, 27 Jul 2017 10:11:10 +0100 Subject: [PATCH 22/31] specify trusty --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 19d7175..6b645a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: ruby sudo: false +dist: trusty rvm: - jruby-9.1.12.0 From e26f731598127927d09c24a1fad44210258d4b57 Mon Sep 17 00:00:00 2001 From: monkstone Date: Wed, 2 Aug 2017 06:58:11 +0100 Subject: [PATCH 23/31] custom keyEvent --- lib/propane/version.rb | 2 +- pom.rb | 2 +- src/monkstone/core/CustomProxy.java | 102 ++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/monkstone/core/CustomProxy.java diff --git a/lib/propane/version.rb b/lib/propane/version.rb index 5f11f7a..1ac71ee 100644 --- a/lib/propane/version.rb +++ b/lib/propane/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Propane - VERSION = '2.3.4'.freeze + VERSION = '2.4.0.pre'.freeze end diff --git a/pom.rb b/pom.rb index e19de26..843c348 100644 --- a/pom.rb +++ b/pom.rb @@ -1,7 +1,7 @@ require 'fileutils' project 'rp5extras', 'https://github.com/monkstone/propane' do model_version '4.0.0' - id 'propane:propane', '2.3.4' + id 'propane:propane', '2.4.0.pre' packaging 'jar' description 'rp5extras for propane' organization 'ruby-processing', 'https://ruby-processing.github.io' diff --git a/src/monkstone/core/CustomProxy.java b/src/monkstone/core/CustomProxy.java new file mode 100644 index 0000000..ae382ba --- /dev/null +++ b/src/monkstone/core/CustomProxy.java @@ -0,0 +1,102 @@ +package monkstone.core; + +import processing.core.PApplet; +import static processing.core.PConstants.*; + +/** + * The purpose of this class is to enable + * access to processing keyEvent and draw? in propane + * as a regular java library class. + * Also included background, fill and stroke methods. + * PConstants should also be available from static import + * @author Martin Prout + */ +public abstract class CustomProxy { +private final PApplet app; + + /** + * Useful accessors + */ + public int width, height; + + /** + * + * @param app PApplet + */ + public CustomProxy(PApplet app) { + this.app = app; + this.width = app.width; + this.height = app.height; + setActive(true); + } + + + /** + * Register or unregister reflection methods + * @param active + */ + final void setActive(boolean active) { + if (active) { + this.app.registerMethod("dispose", this); + this.app.registerMethod("keyEvent", this); + this.app.registerMethod("draw", this); + } else { + this.app.unregisterMethod("draw", this); + this.app.unregisterMethod("keyEvent", this); + } + } + + /** + * Simple signature for background hides need to call app + * @param col int + */ + public void background(int col) { + this.app.background(col); + } + + /** + * Simple signature for fill hides need to call app + * @param col int + */ + public void fill(int col) { + this.app.fill(col); + } + + /** + * Simple signature for stroke hides need to call app + * @param col int + */ + public void stroke(int col) { + this.app.stroke(col); + } + + /** + * Access applet if we must + * @return applet PApplet + */ + public PApplet app() { + return this.app; + } + + /** + * Extending classes must implement this gives access to processing PApplet + * draw loop + */ + public abstract void draw(); + + + /** + * Extending classes must implement this gives access to processing PApplet + * keyEvent (more general than required for keyPressed) + * + * @param e KeyEvent + */ + public abstract void keyEvent(processing.event.KeyEvent e); + + /** + * required for processing + */ + public void dispose() { + setActive(false); + } +} From 8777bb3a999186861f9ababe0161e08a4a560f40 Mon Sep 17 00:00:00 2001 From: monkstone Date: Wed, 2 Aug 2017 11:17:28 +0100 Subject: [PATCH 24/31] create ruby library --- library/custom_proxy/custom_proxy.rb | 10 ++++++++++ library/library_proxy/library_proxy.rb | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 library/custom_proxy/custom_proxy.rb diff --git a/library/custom_proxy/custom_proxy.rb b/library/custom_proxy/custom_proxy.rb new file mode 100644 index 0000000..395a446 --- /dev/null +++ b/library/custom_proxy/custom_proxy.rb @@ -0,0 +1,10 @@ +java_import Java::MonkstoneCore::CustomProxy + + +# classes that inherit from Library are expected to implement +# the abstract methods of monkstone.core.LibraryProxy +# def draw... +# def post... +# def keyEvent... +# NOOP is fine... +# `app` can be called to get PApplet instance diff --git a/library/library_proxy/library_proxy.rb b/library/library_proxy/library_proxy.rb index fbf6789..adf5baa 100644 --- a/library/library_proxy/library_proxy.rb +++ b/library/library_proxy/library_proxy.rb @@ -6,7 +6,5 @@ # def pre... # def draw... # def post... -# def keyPressed... -# def mousePressed... # NOOP is fine... # `app` can be called to get PApplet instance From 6fe9373e6d5be79c058b07bb7a47bb963d66e383 Mon Sep 17 00:00:00 2001 From: monkstone Date: Wed, 2 Aug 2017 13:15:43 +0100 Subject: [PATCH 25/31] add example --- pom.xml | 2 +- src/monkstone/core/CustomProxy.java | 3 ++- test/sketches/key_event.rb | 27 +++++++++++++++++++ .../sketches/library/my_library/my_library.rb | 22 +++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 test/sketches/key_event.rb create mode 100644 test/sketches/library/my_library/my_library.rb diff --git a/pom.xml b/pom.xml index f7f4163..5f659ba 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE 4.0.0 propane propane - 2.3.4 + 2.4.0.pre rp5extras rp5extras for propane https://github.com/monkstone/propane diff --git a/src/monkstone/core/CustomProxy.java b/src/monkstone/core/CustomProxy.java index ae382ba..8c23331 100644 --- a/src/monkstone/core/CustomProxy.java +++ b/src/monkstone/core/CustomProxy.java @@ -1,6 +1,7 @@ package monkstone.core; import processing.core.PApplet; +import processing.event.KeyEvent; import static processing.core.PConstants.*; /** @@ -91,7 +92,7 @@ public PApplet app() { * * @param e KeyEvent */ - public abstract void keyEvent(processing.event.KeyEvent e); + public abstract void keyEvent(KeyEvent e); /** * required for processing diff --git a/test/sketches/key_event.rb b/test/sketches/key_event.rb new file mode 100644 index 0000000..229c8ec --- /dev/null +++ b/test/sketches/key_event.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env jruby +require 'propane' + + +class CustomProxySketch < Propane::App + + # A simple demonstration of vanilla processing 'reflection' methods using + # propane :library_proxy. See my_library.rb code for the guts. + load_libraries :custom_proxy, :my_library + + def settings + size 300, 200 + end + + def setup + sketch_title 'Reflection Voodoo Proxy' + MyLibrary.new self + no_loop + end + + def draw + fill(0, 0, 200) + ellipse(170, 115, 70, 100) + end +end + +CustomProxySketch.new diff --git a/test/sketches/library/my_library/my_library.rb b/test/sketches/library/my_library/my_library.rb new file mode 100644 index 0000000..d919928 --- /dev/null +++ b/test/sketches/library/my_library/my_library.rb @@ -0,0 +1,22 @@ +# This class demonstrates how by inheriting from the abstract class CustomProxy +# we can access 'keyEvent' and 'draw' (Note we need a draw method even +# though can be empty) +class MyLibrary < CustomProxy + java_import 'processing.event.KeyEvent' + + attr_reader :app + + def initialize(parent) + @app = parent + end + + def draw # required but empty method is fine + app.fill(200, 100) + app.ellipse(150, 100, 200, 60) + end + + def keyEvent(e) # keep camel case for reflection to work + return unless e.get_action == KeyEvent::PRESS + puts e.key_code + end +end From c8a5d692e0be84e346de62b922e0741905dd3d9c Mon Sep 17 00:00:00 2001 From: monkstone Date: Fri, 4 Aug 2017 08:56:40 +0100 Subject: [PATCH 26/31] draw and mouseEvent as no_op --- src/monkstone/core/CustomProxy.java | 13 +++++++++++- test/sketches/key_event.rb | 16 ++++++++++++--- .../sketches/library/my_library/my_library.rb | 20 ++++++++++++++----- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/monkstone/core/CustomProxy.java b/src/monkstone/core/CustomProxy.java index 8c23331..af1e37d 100644 --- a/src/monkstone/core/CustomProxy.java +++ b/src/monkstone/core/CustomProxy.java @@ -2,6 +2,7 @@ import processing.core.PApplet; import processing.event.KeyEvent; +import processing.event.MouseEvent; import static processing.core.PConstants.*; /** @@ -40,10 +41,12 @@ final void setActive(boolean active) { if (active) { this.app.registerMethod("dispose", this); this.app.registerMethod("keyEvent", this); + this.app.registerMethod("mouseEvent", this); this.app.registerMethod("draw", this); } else { this.app.unregisterMethod("draw", this); this.app.unregisterMethod("keyEvent", this); + this.app.unregisterMethod("mouseEvent", this); } } @@ -83,7 +86,15 @@ public PApplet app() { * Extending classes must implement this gives access to processing PApplet * draw loop */ - public abstract void draw(); + public void draw(){} + + /** + * Extending classes must implement this gives access to processing PApplet + * mouseEvent (more general than required for mousePressed) + * + * @param e mouseEvent + */ + public void mouseEvent(MouseEvent e){} /** diff --git a/test/sketches/key_event.rb b/test/sketches/key_event.rb index 229c8ec..718053e 100644 --- a/test/sketches/key_event.rb +++ b/test/sketches/key_event.rb @@ -8,19 +8,29 @@ class CustomProxySketch < Propane::App # propane :library_proxy. See my_library.rb code for the guts. load_libraries :custom_proxy, :my_library + attr_reader :visible + def settings size 300, 200 + @visible = false end def setup sketch_title 'Reflection Voodoo Proxy' MyLibrary.new self - no_loop + end + + def hide(val) + @visible = !val end def draw - fill(0, 0, 200) - ellipse(170, 115, 70, 100) + if visible + fill(0, 0, 200) + ellipse(170, 115, 70, 100) + else + background 0 + end end end diff --git a/test/sketches/library/my_library/my_library.rb b/test/sketches/library/my_library/my_library.rb index d919928..d27d859 100644 --- a/test/sketches/library/my_library/my_library.rb +++ b/test/sketches/library/my_library/my_library.rb @@ -10,13 +10,23 @@ def initialize(parent) @app = parent end - def draw # required but empty method is fine - app.fill(200, 100) - app.ellipse(150, 100, 200, 60) + def draw # optional + fill app.color(200, 0, 0, 100) + app.rect 100, 100, 60, 90 end - def keyEvent(e) # keep camel case for reflection to work + # favor guard clause no_op unless key pressed + # and no_op unless ascii key + def keyEvent(e) # NB: need camel case for reflection to work return unless e.get_action == KeyEvent::PRESS - puts e.key_code + return if e.get_key > 122 # else we can't use :chr + case e.get_key.chr.upcase + when 'S' + app.send :hide, false + when 'H' + app.send :hide, true + else + puts e.get_key.chr + end end end From 1d5029366cbd90b5537dbfbb00ea454055732281 Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 6 Aug 2017 21:24:17 +0100 Subject: [PATCH 27/31] Extend LibraryProxy --- lib/propane/version.rb | 2 +- library/custom_proxy/custom_proxy.rb | 10 -- library/library_proxy/README.md | 4 +- library/library_proxy/library_proxy.rb | 18 ++- pom.rb | 2 +- src/monkstone/core/CustomProxy.java | 114 -------------- src/monkstone/core/LibraryProxy.java | 200 ++++++++++++++----------- 7 files changed, 124 insertions(+), 226 deletions(-) delete mode 100644 library/custom_proxy/custom_proxy.rb delete mode 100644 src/monkstone/core/CustomProxy.java diff --git a/lib/propane/version.rb b/lib/propane/version.rb index 1ac71ee..18b0e84 100644 --- a/lib/propane/version.rb +++ b/lib/propane/version.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Propane - VERSION = '2.4.0.pre'.freeze + VERSION = '2.4.0'.freeze end diff --git a/library/custom_proxy/custom_proxy.rb b/library/custom_proxy/custom_proxy.rb deleted file mode 100644 index 395a446..0000000 --- a/library/custom_proxy/custom_proxy.rb +++ /dev/null @@ -1,10 +0,0 @@ -java_import Java::MonkstoneCore::CustomProxy - - -# classes that inherit from Library are expected to implement -# the abstract methods of monkstone.core.LibraryProxy -# def draw... -# def post... -# def keyEvent... -# NOOP is fine... -# `app` can be called to get PApplet instance diff --git a/library/library_proxy/README.md b/library/library_proxy/README.md index d9ab57c..f0f1bf1 100644 --- a/library/library_proxy/README.md +++ b/library/library_proxy/README.md @@ -1,8 +1,8 @@ ### Using the LibraryProxy in your sketches LibraryProxy is a [abstract java class](https://github.com/ruby-processing/JRubyArt/blob/master/src/monkstone/core/LibraryProxy.java) so that you can acccess vanilla processing library reflection methods in your sketches using ruby. -In the sketch you should `load_library :library_proxy` and your library class should inherit -from LibraryProxy and implement pre(), draw() and post() methods (can be empty method if not +In the sketch you should `load_library :library_proxy` and your library class should inherit +from LibraryProxy and implement the draw() method (can be empty method if not required). For simplicity initialize your `processing library` in the sketch `setup`. ### Example library diff --git a/library/library_proxy/library_proxy.rb b/library/library_proxy/library_proxy.rb index adf5baa..a639865 100644 --- a/library/library_proxy/library_proxy.rb +++ b/library/library_proxy/library_proxy.rb @@ -1,10 +1,14 @@ java_import Java::MonkstoneCore::LibraryProxy +java_import Java::ProcessingEvent::KeyEvent +java_import Java::ProcessingEvent::MouseEvent - -# classes that inherit from Library are expected to implement -# the abstract methods of monkstone.core.LibraryProxy -# def pre... -# def draw... -# def post... -# NOOP is fine... +# classes that inherit from LibraryProxy are expected to implement +# the abstract draw method of monkstone.core.LibraryProxy the other methods are +# registered with PApplet instance in constructor ImplementingClass.new(app) +# +# def pre... NOOP can be overridden +# def draw... Abstract Method should be implemented NOOP is OK +# def post... NOOP can be overridden +# def keyEvent(e)... NOOP can be overridden +# def mouseEvent(e)... NOOP can be overridden # `app` can be called to get PApplet instance diff --git a/pom.rb b/pom.rb index 843c348..24fa22f 100644 --- a/pom.rb +++ b/pom.rb @@ -1,7 +1,7 @@ require 'fileutils' project 'rp5extras', 'https://github.com/monkstone/propane' do model_version '4.0.0' - id 'propane:propane', '2.4.0.pre' + id 'propane:propane', '2.4.0' packaging 'jar' description 'rp5extras for propane' organization 'ruby-processing', 'https://ruby-processing.github.io' diff --git a/src/monkstone/core/CustomProxy.java b/src/monkstone/core/CustomProxy.java deleted file mode 100644 index af1e37d..0000000 --- a/src/monkstone/core/CustomProxy.java +++ /dev/null @@ -1,114 +0,0 @@ -package monkstone.core; - -import processing.core.PApplet; -import processing.event.KeyEvent; -import processing.event.MouseEvent; -import static processing.core.PConstants.*; - -/** - * The purpose of this class is to enable - * access to processing keyEvent and draw? in propane - * as a regular java library class. - * Also included background, fill and stroke methods. - * PConstants should also be available from static import - * @author Martin Prout - */ -public abstract class CustomProxy { -private final PApplet app; - - /** - * Useful accessors - */ - public int width, height; - - /** - * - * @param app PApplet - */ - public CustomProxy(PApplet app) { - this.app = app; - this.width = app.width; - this.height = app.height; - setActive(true); - } - - - /** - * Register or unregister reflection methods - * @param active - */ - final void setActive(boolean active) { - if (active) { - this.app.registerMethod("dispose", this); - this.app.registerMethod("keyEvent", this); - this.app.registerMethod("mouseEvent", this); - this.app.registerMethod("draw", this); - } else { - this.app.unregisterMethod("draw", this); - this.app.unregisterMethod("keyEvent", this); - this.app.unregisterMethod("mouseEvent", this); - } - } - - /** - * Simple signature for background hides need to call app - * @param col int - */ - public void background(int col) { - this.app.background(col); - } - - /** - * Simple signature for fill hides need to call app - * @param col int - */ - public void fill(int col) { - this.app.fill(col); - } - - /** - * Simple signature for stroke hides need to call app - * @param col int - */ - public void stroke(int col) { - this.app.stroke(col); - } - - /** - * Access applet if we must - * @return applet PApplet - */ - public PApplet app() { - return this.app; - } - - /** - * Extending classes must implement this gives access to processing PApplet - * draw loop - */ - public void draw(){} - - /** - * Extending classes must implement this gives access to processing PApplet - * mouseEvent (more general than required for mousePressed) - * - * @param e mouseEvent - */ - public void mouseEvent(MouseEvent e){} - - - /** - * Extending classes must implement this gives access to processing PApplet - * keyEvent (more general than required for keyPressed) - * - * @param e KeyEvent - */ - public abstract void keyEvent(KeyEvent e); - - /** - * required for processing - */ - public void dispose() { - setActive(false); - } -} diff --git a/src/monkstone/core/LibraryProxy.java b/src/monkstone/core/LibraryProxy.java index 8b3d728..3d7e561 100644 --- a/src/monkstone/core/LibraryProxy.java +++ b/src/monkstone/core/LibraryProxy.java @@ -2,106 +2,124 @@ import processing.core.PApplet; import static processing.core.PConstants.*; +import processing.event.MouseEvent; +import processing.event.KeyEvent; /** - * The purpose of this class is to enable - * access to processing pre, draw and post loops in - * ruby-processing as a regular java library class. - * Also included background, fill and stroke methods. - * PConstants should also be available from static import - * @author Martin Prout - */ +* The purpose of this class is to enable +* access to processing pre, draw and post loops in +* ruby-processing as a regular java library class. +* Also included background, fill and stroke methods. +* PConstants should also be available from static import +* @author Martin Prout +*/ public abstract class LibraryProxy { - private final PApplet app; - - /** - * Useful accessors - */ - public int width, height; - - /** - * - * @param app PApplet - */ - public LibraryProxy(PApplet app) { - this.app = app; - this.width = app.width; - this.height = app.height; - setActive(true); - } + private final PApplet app; - /** - * Extending classes must implement this gives access to, by reflection, - * processing PApplet pre loop (called before draw) - */ - public abstract void pre(); - - /** - * Extending classes must implement this gives access to processing PApplet - * draw loop - */ - public abstract void draw(); - - /** - * Extending classes must implement this gives access to, by reflection, - * processing PApplet post loop (called after draw) - */ - public abstract void post(); - - /** - * Register or unregister reflection methods - * @param active - */ - final void setActive(boolean active) { - if (active) { - this.app.registerMethod("pre", this); - this.app.registerMethod("draw", this); - this.app.registerMethod("post", this); - this.app.registerMethod("dispose", this); - } else { - this.app.unregisterMethod("pre", this); - this.app.unregisterMethod("draw", this); - this.app.unregisterMethod("post", this); - } - } + /** + * Useful accessors + */ + public int width, height; - /** - * Simple signature for background hides need to call app - * @param col int - */ - public void background(int col) { - this.app.background(col); - } + /** + * + * @param app PApplet + */ + public LibraryProxy(PApplet app) { + this.app = app; + this.width = app.width; + this.height = app.height; + setActive(true); + } - /** - * Simple signature for fill hides need to call app - * @param col int - */ - public void fill(int col) { - this.app.fill(col); - } + /** + * Extending classes can override this, gives access to, by reflection, + * processing PApplet pre loop (called before draw) + */ + public void pre(){} - /** - * Simple signature for stroke hides need to call app - * @param col int - */ - public void stroke(int col) { - this.app.stroke(col); - } + /** + * Extending classes must implement this gives access to processing PApplet + * draw loop + */ + public abstract void draw(); - /** - * Access applet if we must - * @return applet PApplet - */ - public PApplet app() { - return this.app; - } + /** + * Extending classes can override this, gives access to, by reflection, + * processing PApplet post loop (called after draw) + */ + public void post(){} + + /** + * Extending classes can override this, gives access to, by reflection, + * processing PApplet post loop (called after draw) + */ + public void keyEvent(KeyEvent e){} - /** - * required for processing - */ - public void dispose() { - setActive(false); + /** + * Extending classes can override this, gives access to, by reflection, + * processing PApplet post loop (called after draw) + */ + public void mouseEvent(MouseEvent e){} + + /** + * Register or unregister reflection methods + * @param active + */ + final void setActive(boolean active) { + if (active) { + this.app.registerMethod("pre", this); + this.app.registerMethod("draw", this); + this.app.registerMethod("post", this); + this.app.registerMethod("mouseEvent", this); + this.app.registerMethod("keyEvent", this); + this.app.registerMethod("dispose", this); + } else { + this.app.unregisterMethod("pre", this); + this.app.unregisterMethod("draw", this); + this.app.unregisterMethod("post", this); + this.app.unregisterMethod("mouseEvent", this); + this.app.unregisterMethod("keyEvent", this); } + } + + /** + * Simple signature for background hides need to call app + * @param col int + */ + public void background(int col) { + this.app.background(col); + } + + /** + * Simple signature for fill hides need to call app + * @param col int + */ + public void fill(int col) { + this.app.fill(col); + } + + /** + * Simple signature for stroke hides need to call app + * @param col int + */ + public void stroke(int col) { + this.app.stroke(col); + } + + /** + * Access applet if we must + * @return applet PApplet + */ + public PApplet app() { + return this.app; + } + + /** + * required for processing + */ + public void dispose() { + setActive(false); + } } From ad8f68f0010f8a6a4e5440cacb4baecec0eccd66 Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 6 Aug 2017 21:29:47 +0100 Subject: [PATCH 28/31] CHANGELOG.md --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5f659ba..a8c6bfa 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE 4.0.0 propane propane - 2.4.0.pre + 2.4.0 rp5extras rp5extras for propane https://github.com/monkstone/propane From 5343ddc3799c1460eb9323e8a61b9962314e4e13 Mon Sep 17 00:00:00 2001 From: monkstone Date: Sun, 6 Aug 2017 21:30:54 +0100 Subject: [PATCH 29/31] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 485727f..acdf8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +**v2.4.0** Extend LibraryProxy to include mouseEvent and keyEvent. + **v2.3.4** Simplify control_panel library (replacing `c.title = 'PaneTitle'` with `c.title('PaneTitle')`) also enable use of `block` with `button's`. **v2.3.3** Update to processing-3.3.4, and upgrade jruby-9.1.12.0 last in 9.1 series? From 36c655140f4d800283166dedeba380736dfd103f Mon Sep 17 00:00:00 2001 From: monkstone Date: Mon, 7 Aug 2017 06:52:30 +0100 Subject: [PATCH 30/31] Adjust test/sketches for merge --- test/sketches/key_event.rb | 2 +- test/sketches/library/my_library/my_library.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sketches/key_event.rb b/test/sketches/key_event.rb index 718053e..8365b1e 100644 --- a/test/sketches/key_event.rb +++ b/test/sketches/key_event.rb @@ -6,7 +6,7 @@ class CustomProxySketch < Propane::App # A simple demonstration of vanilla processing 'reflection' methods using # propane :library_proxy. See my_library.rb code for the guts. - load_libraries :custom_proxy, :my_library + load_libraries :library_proxy, :my_library attr_reader :visible diff --git a/test/sketches/library/my_library/my_library.rb b/test/sketches/library/my_library/my_library.rb index d27d859..f6a2a50 100644 --- a/test/sketches/library/my_library/my_library.rb +++ b/test/sketches/library/my_library/my_library.rb @@ -1,7 +1,7 @@ -# This class demonstrates how by inheriting from the abstract class CustomProxy +# This class demonstrates how by inheriting from the abstract class LibraryProxy # we can access 'keyEvent' and 'draw' (Note we need a draw method even # though can be empty) -class MyLibrary < CustomProxy +class MyLibrary < LibraryProxy java_import 'processing.event.KeyEvent' attr_reader :app From 994143b11460b9f6dd1f391177e9aacbca4aa23f Mon Sep 17 00:00:00 2001 From: monkstone Date: Mon, 7 Aug 2017 16:23:17 +0100 Subject: [PATCH 31/31] update samples --- vendors/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendors/Rakefile b/vendors/Rakefile index d80f974..8a1234d 100644 --- a/vendors/Rakefile +++ b/vendors/Rakefile @@ -9,7 +9,7 @@ SOUND = 'sound.zip'.freeze SOUND_VERSION = 'v1.3.2' # version 1.3.2 VIDEO = 'video-2.zip' VIDEO_VERSION = '2' # version 1.0.1 -EXAMPLES = '1.3'.freeze +EXAMPLES = '1.4'.freeze HOME_DIR = ENV['HOME'] MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']