Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9f686d0
Update README.md
monkstone May 5, 2017
f800bb2
bump versions
monkstone Jun 4, 2017
21f7d9d
bump versions
monkstone Jun 4, 2017
4fb0140
update processing
monkstone Jun 11, 2017
278f566
bump jruby version
monkstone Jun 15, 2017
5865b40
Update README.md
monkstone Jun 16, 2017
98925e7
rake is a development dependency
monkstone Jun 16, 2017
3913b70
include gemspec
monkstone Jun 16, 2017
d655ef3
include minitest in gemspec
monkstone Jun 16, 2017
0d35c02
Update respond_to_test.rb
monkstone Jun 16, 2017
07f917b
Update Rakefile
monkstone Jun 16, 2017
6577b2b
skip doesn't work because setup fails
monkstone Jun 16, 2017
bbdf8ac
control panel fixes
monkstone Jul 16, 2017
eabc98c
control_panel
monkstone Jul 17, 2017
70a4248
bump version
monkstone Jul 19, 2017
9a5c933
oops had not been updating propane samples
monkstone Jul 19, 2017
4dc7891
Update README.md
monkstone Jul 19, 2017
7ef012f
Update README.md
monkstone Jul 19, 2017
0995d15
Update README.md
monkstone Jul 19, 2017
f510305
get ready for release
monkstone Jul 19, 2017
a58d650
tidy up creator
monkstone Jul 20, 2017
1592fe4
specify trusty
monkstone Jul 27, 2017
e26f731
custom keyEvent
monkstone Aug 2, 2017
8777bb3
create ruby library
monkstone Aug 2, 2017
6fe9373
add example
monkstone Aug 2, 2017
c8a5d69
draw and mouseEvent as no_op
monkstone Aug 4, 2017
1d50293
Extend LibraryProxy
monkstone Aug 6, 2017
ad8f68f
CHANGELOG.md
monkstone Aug 6, 2017
5343ddc
changelog
monkstone Aug 6, 2017
f5777bb
Merge pull request #10 from ruby-processing/custom
monkstone Aug 7, 2017
36c6551
Adjust test/sketches for merge
monkstone Aug 7, 2017
994143b
update samples
monkstone Aug 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: ruby
sudo: false
dist: trusty

rvm:
- jruby-9.1.6.0
rvm:
- jruby-9.1.12.0
jdk:
- oraclejdk8
os:
- linux

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
**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?

**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

**v2.3.0** Update to core processing-3.3 `grid` method now implemented in java, bump examples to include WOVNS
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
source 'https://rubygems.org'

gemspec
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# 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].
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 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
```
adjust above for your OS/distro setup.

## 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.5 (_build only_)

## Building and testing

Expand All @@ -21,7 +28,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.4-java.gem # for local install
```

## Usage
Expand Down Expand Up @@ -70,4 +77,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/
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.jar gluegen-rt-2.3.2.jar jog-all-2.3.2.jar')
end
end

Expand Down Expand Up @@ -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'
Expand Down
32 changes: 15 additions & 17 deletions lib/propane/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 6 additions & 4 deletions lib/propane/creators/sketch_class.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#frozen_string_literal: false
# frozen_string_literal: false

# the sketch class
class SketchClass
attr_reader :name, :width, :height, :mode
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/propane/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Propane
VERSION = '2.3.2'.freeze
VERSION = '2.4.0'.freeze
end
20 changes: 12 additions & 8 deletions library/control_panel/control_panel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -151,10 +155,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

Expand All @@ -169,4 +173,4 @@ def control_panel
end
end

Propane::App.send :include, ControlPanel::InstanceMethods
Propane::App.include(ControlPanel::InstanceMethods)
4 changes: 2 additions & 2 deletions library/library_proxy/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 11 additions & 9 deletions library/library_proxy/library_proxy.rb
Original file line number Diff line number Diff line change
@@ -1,12 +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...
# def keyPressed...
# def mousePressed...
# 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
8 changes: 4 additions & 4 deletions pom.rb
Original file line number Diff line number Diff line change
@@ -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.4.0'
packaging 'jar'
description 'rp5extras for propane'
organization 'ruby-processing', 'https://ruby-processing.github.io'
Expand Down Expand Up @@ -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.12.0'
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}')
Expand All @@ -44,7 +44,7 @@
execute_goals( id: 'default-cli',
artifactItems: [ { groupId: 'org.processing',
artifactId: 'core',
version: '3.3.2',
version: '3.3.5',
type: 'jar',
outputDirectory: '${propane.basedir}/lib'
},
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
<modelVersion>4.0.0</modelVersion>
<groupId>propane</groupId>
<artifactId>propane</artifactId>
<version>2.3.2</version>
<version>2.4.0</version>
<name>rp5extras</name>
<description>rp5extras for propane</description>
<url>https://github.com/monkstone/propane</url>
Expand Down Expand Up @@ -58,13 +58,13 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby</artifactId>
<version>9.1.8.0</version>
<version>9.1.12.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.processing</groupId>
<artifactId>core</artifactId>
<version>3.3.2</version>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.processing</groupId>
Expand Down Expand Up @@ -103,7 +103,7 @@ DO NOT MODIFIY - GENERATED CODE
<artifactItem>
<groupId>org.processing</groupId>
<artifactId>core</artifactId>
<version>3.3.2</version>
<version>3.3.5</version>
<type>jar</type>
<outputDirectory>${propane.basedir}/lib</outputDirectory>
</artifactItem>
Expand Down
8 changes: 5 additions & 3 deletions propane.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.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.2.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'
Expand All @@ -23,7 +23,9 @@ 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_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'
end
Loading