propane 0.9.0-java → 2.0.0.pre-java

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Propane
2
2
  [![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane)
3
3
 
4
- A slim layer to communicate with Processing from JRuby, features a polyglot maven build, this started out as a non serious project by Phillip Cunningam called ribiprocessing. It has now morphed into an experimental project for ruby-processing so we can now "Cook with Gas". We have created a configuration free version of ruby processing, albeit tied to processing-2.2.1, where we get processing core from maven central (and opengl currently testing on linux64/mac). These jars are small enough to include in the gem distribution, and hence we should 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).
4
+ A slim layer to communicate with Processing from JRuby, features a polyglot maven build, this started out as a non serious project by Phillip Cunningam called ribiprocessing. It has now morphed into an experimental project for ruby-processing so we can now "Cook with Gas". We have created a configuration free version of ruby processing, for processing-3.1+, where we get processing core from maven central (and opengl currently testing on linux64/mac). These jars are small enough to include in the gem distribution, and hence we should 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).
5
5
  ## Requirements
6
6
 
7
7
  - jdk8+ since version 0.6.0
@@ -29,47 +29,41 @@ require 'propane'
29
29
 
30
30
  class FlashingLightsSketch < Propane::App
31
31
 
32
- attr_reader :random_background
33
-
34
- def initialize opts={}
35
- @random_background = opts.fetch :random_background, RandomBackground.new(self)
36
- super
32
+ def settings
33
+ size(800, 600)
37
34
  end
38
35
 
39
36
  def setup
40
- size(800, 600)
37
+ sketch_title 'Flashing Light Sketch'
41
38
  end
42
39
 
43
40
  def draw
44
- random_background.generate
45
- end
46
-
47
- end
48
-
49
- class RandomBackground
50
- include Propane::Proxy
51
-
52
- def generate
53
41
  background(rand(255), rand(255), rand(255))
54
42
  end
55
-
56
43
  end
57
44
 
58
- FlashingLightsSketch.new title: "Flashing Lights"
45
+ FlashingLightsSketch.new
59
46
  ```
60
47
 
61
- To install the samples and jruby-complete. The samples get copied to `~/propane_samples`.
48
+ To install the samples. The samples get copied to `~/propane_samples`. Depends on wget.
62
49
  ```bash
63
- propane --install
50
+ propane --install samples
64
51
  ```
65
52
  There is a handy sketch creator tool
66
53
  ```bash
67
54
  propane -c my_sketch 200 200 # for default renderer
68
55
  propane -c my_sketch 200 200 p2d # for opengl 2D renderer
69
56
  propane -c my_sketch 200 200 p3d # for opengl 3D renderer
57
+ ```
58
+
59
+ To run sketches
70
60
 
71
- To run sketches using the installed jruby-complete, you can also use shortform `-r`
72
61
  ```bash
73
- propane --run my_sketch.rb # or
74
62
  jruby -S propane --run my_sketch.rb # belt and braces version
75
63
  ```
64
+ To install the sound and video libraries `~/.propane/libraries`. Depends on wget.
65
+ ```bash
66
+ propane --install sound
67
+ propane --install video
68
+ ```
69
+ Other java libraries can be manually installed to the same folder (no need for processing ide)
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: false
3
2
  require_relative 'lib/propane/version'
4
3
 
@@ -8,7 +7,7 @@ def create_manifest
8
7
  File.open('MANIFEST.MF', 'w') do |f|
9
8
  f.puts(title)
10
9
  f.puts(version)
11
- f.puts('Class-Path: core-2.2.1.jar gluegen-rt-2.1.5-01.jar jog-all-2.1.5-01.jar')
10
+ f.puts('Class-Path: core-3.1.1.jar gluegen-rt-2.3.2.jar jog-all-2.3.2.jar')
12
11
  end
13
12
  end
14
13
 
@@ -48,6 +47,7 @@ end
48
47
  desc 'Test'
49
48
  task :test do
50
49
  sh 'jruby test/respond_to_test.rb'
50
+ sh 'jruby test/create_test.rb'
51
51
  end
52
52
 
53
53
  desc 'clean'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: false
3
2
  unless defined? PROPANE_ROOT
4
3
  $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
@@ -7,6 +6,4 @@ end
7
6
  Dir["#{PROPANE_ROOT}/lib/*.jar"].each do |jar|
8
7
  require jar
9
8
  end
10
- require 'propane/version'
11
- require 'propane/app'
12
- require 'propane/helpers/numeric'
9
+ require_relative 'propane/app'
@@ -19,7 +19,8 @@ module Propane
19
19
  # their own sketch.
20
20
  #
21
21
  # i.e.
22
- #
22
+ # require 'propane'
23
+ #
23
24
  # class MySketch < Propane::App
24
25
  #
25
26
  # def draw
@@ -27,6 +28,8 @@ module Propane
27
28
  # end
28
29
  #
29
30
  # end
31
+ #
32
+ # MySketch.new
30
33
 
31
34
  # Watch the definition of these methods, to make sure
32
35
  # that Processing is able to call them during events.
@@ -49,15 +52,27 @@ module Propane
49
52
  alias stroke_width stroke_weight
50
53
  alias rgb color
51
54
  alias gray color
52
- attr_reader :title, :arguments, :options
55
+ field_reader :surface
56
+
57
+ def sketch_class
58
+ self.class.sketch_class
59
+ end
60
+
61
+ # Keep track of what inherits from the Processing::App, because we're
62
+ # going to want to instantiate one.
63
+ def self.inherited(subclass)
64
+ super(subclass)
65
+ @sketch_class = subclass
66
+ end
67
+
53
68
  # App should be instantiated with an optional list of options
54
69
  # and array of arguments.
55
70
  #
56
- # App.new(width: 500, height: 500, fullscreen: true)
71
+ # App.new
57
72
  #
58
73
  class << self
59
74
  # Handy getters and setters on the class go here:
60
- attr_accessor :sketch_class, :library_loader
75
+ attr_accessor :sketch_class, :library_loader, :title, :arguments, :options
61
76
 
62
77
  def load_libraries(*args)
63
78
  library_loader ||= LibraryLoader.new
@@ -99,7 +114,6 @@ module Propane
99
114
  $app = self
100
115
  @arguments = arguments
101
116
  @options = options
102
- configure_sketch
103
117
  run_sketch
104
118
  end
105
119
 
@@ -111,6 +125,10 @@ module Propane
111
125
  import_opengl if /opengl/ =~ mode
112
126
  super(*args)
113
127
  end
128
+
129
+ def sketch_title(title)
130
+ surface.set_title(title)
131
+ end
114
132
 
115
133
  def data_path(dat)
116
134
  dat_root = File.join(SKETCH_ROOT, 'data')
@@ -118,12 +136,6 @@ module Propane
118
136
  File.join(dat_root, dat)
119
137
  end
120
138
 
121
- # This method runs the processing sketch.
122
- #
123
- def run_sketch
124
- PApplet.run_sketch(arguments, self)
125
- end
126
-
127
139
  private
128
140
 
129
141
  def import_opengl
@@ -135,26 +147,6 @@ module Propane
135
147
  end
136
148
  end
137
149
 
138
- # This method configures the sketch title and and presentation mode.
139
- #
140
- def configure_sketch
141
- set_sketch_title
142
- set_presentation_mode
143
- end
144
-
145
- # This method sets the sketch presentation mode.
146
- #
147
- def set_presentation_mode
148
- arguments.concat ['--present'] if options[:fullscreen]
149
- end
150
-
151
- # This method sets the sketch title.
152
- #
153
- def set_sketch_title
154
- title_string = options.fetch(:title, 'processing sketch')
155
- arguments.concat [title_string]
156
- end
157
-
158
150
  def proxy_java_fields
159
151
  fields = %w(sketchPath key frameRate mousePressed keyPressed)
160
152
  methods = fields.map { |field| java_class.declared_field(field) }
@@ -11,8 +11,9 @@ class SketchParameters
11
11
  name.split('_').collect(&:capitalize).join
12
12
  end
13
13
 
14
- def title
15
- name.split('_').collect(&:capitalize).join(' ')
14
+ def sketch_title
15
+ human = name.split('_').collect(&:capitalize).join(' ')
16
+ format("sketch_title '%s'", human)
16
17
  end
17
18
 
18
19
  def sketch_size
@@ -47,14 +48,15 @@ class ClassSketch
47
48
  ''
48
49
  ]
49
50
  lines << format('class %s < Propane::App', param.class_name)
50
- lines.concat method_lines('setup', param.sketch_size)
51
+ lines.concat method_lines('settings', param.sketch_size)
52
+ lines.concat method_lines('setup', param.sketch_title)
51
53
  lines.concat method_lines('draw', '')
52
54
  lines << 'end'
53
55
  lines.concat new(param)
54
56
  end
55
-
57
+
56
58
  private
57
-
59
+
58
60
  def method_lines(name, content)
59
61
  one = format('%sdef %s', INDENT, name)
60
62
  two = content.empty? ? '' : format(' %s%s', INDENT, content)
@@ -64,7 +66,6 @@ class ClassSketch
64
66
  end
65
67
 
66
68
  def new(param)
67
- ['', format("%s.new title: '%s'", param.class_name, param.title)]
69
+ ['', format('%s.new', param.class_name)]
68
70
  end
69
71
  end
70
-
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: false
2
2
  # processing module wrapper
3
- require_relative '../propane'
4
-
3
+ require_relative 'helpers/numeric'
5
4
  module Propane
6
5
  # Provides some convenience methods
7
6
  module HelperMethods
@@ -100,7 +100,8 @@ module Propane
100
100
  [
101
101
  "#{PROPANE_ROOT}/library/#{library_name}",
102
102
  "#{PROPANE_ROOT}/library/#{library_name}/library",
103
- "#{PROPANE_ROOT}/library/#{library_name}"
103
+ "#{PROPANE_ROOT}/library/#{library_name}",
104
+ "#{ENV['HOME']}/.propane/libraries/#{library_name}/library"
104
105
  ].each do |jpath|
105
106
  if File.exist?(jpath) && !Dir.glob(format('%s/*.%s', jpath, ext)).empty?
106
107
  return jpath
@@ -1,13 +1,9 @@
1
1
  # frozen_string_literal: false
2
- require "#{PROPANE_ROOT}/lib/propane"
3
- require "#{PROPANE_ROOT}/lib/propane/app"
4
2
  require 'optparse'
3
+ require_relative 'version'
5
4
 
6
5
  module Propane
7
- java_import 'monkstone.WatchSketchDir'
8
- java_import 'java.nio.file.StandardWatchEventKinds'
9
- # Utility class to handle the different commands that the 'rp5' command
10
- # offers. Able to run, watch, live, create, app, and unpack
6
+ # Utility class to handle the different commands that the 'propane' offers
11
7
  class Runner
12
8
  attr_reader :options, :argc, :filename
13
9
 
@@ -15,7 +11,7 @@ module Propane
15
11
  @options = {}
16
12
  end
17
13
 
18
- # Start running a propane sketch from the passed-in arguments
14
+ # Start running a propane command from the passed-in arguments
19
15
  def self.execute
20
16
  runner = new
21
17
  runner.parse_options(ARGV)
@@ -26,8 +22,6 @@ module Propane
26
22
  def execute!
27
23
  show_help if options.empty?
28
24
  show_version if options[:version]
29
- run_sketch if options[:run]
30
- watch_sketch if options[:watch]
31
25
  create if options[:create]
32
26
  install if options[:install]
33
27
  end
@@ -46,20 +40,11 @@ module Propane
46
40
  end
47
41
 
48
42
  options[:install] = false
49
- opts.on('-i', '--install', 'Installs jruby-complete') do
43
+ message = '<Samples><Video><Sound> Install samples or library'
44
+ opts.on('-i', '--install', message) do
50
45
  options[:install] = true
51
46
  end
52
47
 
53
- options[:watch] = false
54
- opts.on('-w', '--watch', 'Watch the sketch') do
55
- options[:watch] = true
56
- end
57
-
58
- options[:run] = false
59
- opts.on('-r', '--run', 'Run the sketch using jruby-complete') do
60
- options[:run] = true
61
- end
62
-
63
48
  options[:create] = false
64
49
  opts.on('-c', '--create', 'Create new sketch outline') do
65
50
  options[:create] = true
@@ -75,39 +60,6 @@ module Propane
75
60
  @argc = opt_parser.parse(args)
76
61
  @filename = argc.shift
77
62
  end
78
-
79
- def watch_sketch
80
- run_sketch
81
- root = File.absolute_path(File.dirname(filename))
82
- watcher = WatchSketchDir.watch(root)
83
- count = 0 # guard against a duplicate event
84
- watcher.add_listener do |event|
85
- if event.kind == StandardWatchEventKinds::ENTRY_MODIFY
86
- if count == 0
87
- puts 'reloading sketch...'
88
- run_sketch
89
- end
90
- count += 1
91
- count = 0 if count == 2
92
- end
93
- end
94
- end
95
-
96
- def run_sketch
97
- # root = File.absolute_path(File.dirname(filename))
98
- # sketch = File.join(root, filename)
99
- sketch = File.join(SKETCH_ROOT, filename)
100
- warn_format = 'File %s does not not Exist!'
101
- return warn(format(warn_format, sketch)) unless File.exist?(sketch)
102
- command = [
103
- 'java',
104
- '-cp',
105
- "#{PROPANE_ROOT}/lib/ruby/jruby-complete.jar",
106
- 'org.jruby.Main',
107
- sketch.to_s
108
- ].flatten
109
- exec(*command)
110
- end
111
63
 
112
64
  def create
113
65
  require_relative 'creators/sketch_writer'
@@ -121,7 +73,13 @@ module Propane
121
73
  end
122
74
 
123
75
  def install
124
- system "cd #{PROPANE_ROOT}/vendors && rake"
76
+ choice = filename.downcase
77
+ samples = "cd #{PROPANE_ROOT}/vendors && rake"
78
+ sound = "cd #{PROPANE_ROOT}/vendors && rake download_and_copy_sound"
79
+ video = "cd #{PROPANE_ROOT}/vendors && rake download_and_copy_video"
80
+ system samples if /samples/ =~ choice
81
+ system video if /video/ =~ choice
82
+ system sound if /sound/ =~ choice
125
83
  end
126
84
  end # class Runner
127
85
  end # module Propane
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
  module Propane
4
- VERSION = '0.9.0'.freeze
4
+ VERSION = '2.0.0.pre'.freeze
5
5
  end
@@ -0,0 +1,3 @@
1
+ class Propane::App
2
+ include Java::MonkstoneVideoevent::VideoInterface
3
+ end
data/pom.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  project 'rp5extras', 'https://github.com/monkstone/propane' do
3
3
  model_version '4.0.0'
4
- id 'propane:rp5extras', '0.9.0'
4
+ id 'propane:rp5extras', '2.0.0'
5
5
  packaging 'jar'
6
6
  description 'rp5extras for propane'
7
7
  organization 'ruby-processing', 'https://ruby-processing.github.io'
@@ -13,12 +13,12 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
13
13
  end
14
14
  license 'MIT', 'http://www.opensource.org/licenses/mit-license.php'
15
15
  license 'GPL 3', 'http://www.gnu.org/licenses/gpl-3.0-standalone.html'
16
- issue_management 'https://github.com/monkstone/propane/issues', 'Github'
16
+ issue_management 'https://github.com/ruby-processing/propane/issues', 'Github'
17
17
 
18
18
  source_control(
19
- url: 'https://github.com/monkstone/propane',
20
- connection: 'scm:git:git://github.com/monkstone/propane.git',
21
- developer_connection: 'scm:git:git@github.com/monkstone/propane.git'
19
+ url: 'https://github.com/ruby-processing/propane',
20
+ connection: 'scm:git:git://github.com/ruby-processing/propane.git',
21
+ developer_connection: 'scm:git:git@github.com/ruby-processing/propane.git'
22
22
  )
23
23
 
24
24
  properties('source.directory' => 'src',
@@ -30,11 +30,12 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
30
30
  'jruby.api' => 'http://jruby.org/apidocs/',
31
31
  'processing.api' => 'http://processing.github.io/processing-javadocs/core/',
32
32
  'jruby.api' => 'http://jruby.org/apidocs/',
33
- 'jogl.version' => '2.1.5-01'
33
+ 'jogl.version' => '2.3.2'
34
34
  )
35
35
 
36
- pom('org.jruby:jruby:9.1.2.0')
37
- jar('org.processing:core:2.2.1')
36
+ pom 'org.jruby:jruby:9.1.2.0'
37
+ jar 'org.processing:core:3.1.1'
38
+ jar 'org.processing:video:3.0.2'
38
39
  jar('org.jogamp.jogl:jogl-all:${jogl.version}')
39
40
  jar('org.jogamp.gluegen:gluegen-rt-main:${jogl.version}')
40
41
 
@@ -44,7 +45,7 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
44
45
  execute_goals( id: 'default-cli',
45
46
  artifactItems: [ { groupId: 'org.processing',
46
47
  artifactId: 'core',
47
- version: '2.2.1',
48
+ version: '3.1.1',
48
49
  type: 'jar',
49
50
  outputDirectory: '${propane.basedir}/lib'
50
51
  },
data/pom.xml CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>propane</groupId>
13
13
  <artifactId>rp5extras</artifactId>
14
- <version>0.9.0</version>
14
+ <version>2.0.0</version>
15
15
  <name>rp5extras</name>
16
16
  <description>rp5extras for propane</description>
17
17
  <url>https://github.com/monkstone/propane</url>
@@ -46,16 +46,16 @@ DO NOT MODIFIY - GENERATED CODE
46
46
  </developer>
47
47
  </developers>
48
48
  <scm>
49
- <connection>scm:git:git://github.com/monkstone/propane.git</connection>
50
- <developerConnection>scm:git:git@github.com/monkstone/propane.git</developerConnection>
51
- <url>https://github.com/monkstone/propane</url>
49
+ <connection>scm:git:git://github.com/ruby-processing/propane.git</connection>
50
+ <developerConnection>scm:git:git@github.com/ruby-processing/propane.git</developerConnection>
51
+ <url>https://github.com/ruby-processing/propane</url>
52
52
  </scm>
53
53
  <issueManagement>
54
54
  <system>Github</system>
55
- <url>https://github.com/monkstone/propane/issues</url>
55
+ <url>https://github.com/ruby-processing/propane/issues</url>
56
56
  </issueManagement>
57
57
  <properties>
58
- <jogl.version>2.1.5-01</jogl.version>
58
+ <jogl.version>2.3.2</jogl.version>
59
59
  <jruby.api>http://jruby.org/apidocs/</jruby.api>
60
60
  <source.directory>src</source.directory>
61
61
  <maven.compiler.target>1.8</maven.compiler.target>
@@ -75,7 +75,12 @@ DO NOT MODIFIY - GENERATED CODE
75
75
  <dependency>
76
76
  <groupId>org.processing</groupId>
77
77
  <artifactId>core</artifactId>
78
- <version>2.2.1</version>
78
+ <version>3.1.1</version>
79
+ </dependency>
80
+ <dependency>
81
+ <groupId>org.processing</groupId>
82
+ <artifactId>video</artifactId>
83
+ <version>3.0.2</version>
79
84
  </dependency>
80
85
  <dependency>
81
86
  <groupId>org.jogamp.jogl</groupId>
@@ -109,7 +114,7 @@ DO NOT MODIFIY - GENERATED CODE
109
114
  <artifactItem>
110
115
  <groupId>org.processing</groupId>
111
116
  <artifactId>core</artifactId>
112
- <version>2.2.1</version>
117
+ <version>3.1.1</version>
113
118
  <type>jar</type>
114
119
  <outputDirectory>${propane.basedir}/lib</outputDirectory>
115
120
  </artifactItem>