jrubyfx 0.9.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/LICENSE +202 -0
  2. data/README.md +97 -0
  3. data/bin/jrubyfx-jarify +90 -0
  4. data/bin/rubyfx-generator +81 -0
  5. data/lib/jrubyfx.rb +27 -0
  6. data/lib/jrubyfx/core_ext/border_pane.rb +29 -0
  7. data/lib/jrubyfx/core_ext/circle.rb +26 -0
  8. data/lib/jrubyfx/core_ext/column_constraints.rb +41 -0
  9. data/lib/jrubyfx/core_ext/duration.rb +28 -0
  10. data/lib/jrubyfx/core_ext/effects.rb +30 -0
  11. data/lib/jrubyfx/core_ext/file_chooser.rb +60 -0
  12. data/lib/jrubyfx/core_ext/labeled.rb +24 -0
  13. data/lib/jrubyfx/core_ext/media_player.rb +23 -0
  14. data/lib/jrubyfx/core_ext/node.rb +24 -0
  15. data/lib/jrubyfx/core_ext/observable_value.rb +36 -0
  16. data/lib/jrubyfx/core_ext/pagination.rb +26 -0
  17. data/lib/jrubyfx/core_ext/parallel_transition.rb +28 -0
  18. data/lib/jrubyfx/core_ext/parent.rb +28 -0
  19. data/lib/jrubyfx/core_ext/path.rb +41 -0
  20. data/lib/jrubyfx/core_ext/progress_indicator.rb +38 -0
  21. data/lib/jrubyfx/core_ext/radial_gradient.rb +37 -0
  22. data/lib/jrubyfx/core_ext/region.rb +39 -0
  23. data/lib/jrubyfx/core_ext/rotate.rb +37 -0
  24. data/lib/jrubyfx/core_ext/scene.rb +29 -0
  25. data/lib/jrubyfx/core_ext/shape.rb +27 -0
  26. data/lib/jrubyfx/core_ext/stage.rb +77 -0
  27. data/lib/jrubyfx/core_ext/stop.rb +29 -0
  28. data/lib/jrubyfx/core_ext/table_view.rb +35 -0
  29. data/lib/jrubyfx/core_ext/timeline.rb +47 -0
  30. data/lib/jrubyfx/core_ext/transition.rb +25 -0
  31. data/lib/jrubyfx/core_ext/xy_chart.rb +53 -0
  32. data/lib/jrubyfx/dsl.rb +217 -0
  33. data/lib/jrubyfx/fxml_application.rb +44 -0
  34. data/lib/jrubyfx/fxml_controller.rb +270 -0
  35. data/lib/jrubyfx/fxml_module.rb +98 -0
  36. data/lib/jrubyfx/java_fx_impl.rb +139 -0
  37. data/lib/jrubyfx/jfx_imports.rb +107 -0
  38. data/lib/jrubyfx/utils.rb +56 -0
  39. data/lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb +24 -0
  40. data/lib/jrubyfx/utils/common_converters.rb +140 -0
  41. data/lib/jrubyfx/utils/common_utils.rb +72 -0
  42. data/lib/jrubyfx/version.rb +4 -0
  43. data/lib/jrubyfx_tasks.rb +110 -0
  44. metadata +116 -0
@@ -0,0 +1,41 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX Paths
18
+ class Java::javafx::scene::shape::Path
19
+ java_import Java::javafx.scene.shape.PathElement
20
+ java_import Java::javafx.scene.transform.Transform
21
+
22
+ include JRubyFX::DSL
23
+
24
+ include_add :elements
25
+
26
+ include_rotate
27
+
28
+ ##
29
+ # This will defer to node to construct proper object, but will
30
+ # optionally add paths primary child automatically if it is a
31
+ # PathElement.
32
+ def method_missing(name, *args, &block)
33
+ super.tap do |obj|
34
+ if obj.kind_of? PathElement
35
+ add(obj)
36
+ elsif obj.kind_of? Transform
37
+ transforms << obj
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX Progress *
18
+ class Java::javafx::scene::control::ProgressIndicator
19
+ extend JRubyFX::Utils::CommonConverters
20
+
21
+ progress_conv = map_converter(indeterminate_progress: INDETERMINATE_PROGRESS,
22
+ indeterminate: INDETERMINATE_PROGRESS)
23
+
24
+ converter_for :progress, [progress_conv]
25
+ converter_for :new, [], [progress_conv]
26
+
27
+ end
28
+ # JRubyFX DSL extensions for JavaFX Progress *
29
+ class Java::javafx::scene::control::ProgressBar
30
+ extend JRubyFX::Utils::CommonConverters
31
+
32
+ progress_conv = map_converter(indeterminate_progress: INDETERMINATE_PROGRESS,
33
+ indeterminate: INDETERMINATE_PROGRESS)
34
+
35
+ converter_for :progress, [progress_conv]
36
+ converter_for :new, [], [progress_conv]
37
+
38
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/utils/common_converters'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Radial Gradients
20
+ class Java::javafx::scene::paint::RadialGradient
21
+ class << self
22
+ java_import Java::javafx.scene.paint.CycleMethod
23
+ extend JRubyFX::Utils::CommonConverters
24
+
25
+ converter_for :new, [:none, :none, :none, :none, :none, :none, enum_converter(CycleMethod), :none]
26
+ end
27
+ end
28
+
29
+ # JRubyFX DSL extensions for JavaFX Linear Gradients
30
+ class Java::javafx::scene::paint::LinearGradient
31
+ class << self
32
+ java_import Java::javafx.scene.paint.CycleMethod
33
+ extend JRubyFX::Utils::CommonConverters
34
+
35
+ converter_for :new, [:none, :none, :none, :none, :none, enum_converter(CycleMethod), :none]
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX color stops
18
+ class Java::javafx::scene::layout::Region
19
+ extend JRubyFX::Utils::CommonConverters
20
+
21
+ use_sizes = map_converter(use_pref_size: USE_PREF_SIZE,
22
+ use_computed_size: USE_COMPUTED_SIZE,
23
+ pref_size: USE_PREF_SIZE,
24
+ computed_size: USE_COMPUTED_SIZE,
25
+ preferred_size: USE_PREF_SIZE,
26
+ compute_size: USE_COMPUTED_SIZE,
27
+ pref: USE_PREF_SIZE,
28
+ computed: USE_COMPUTED_SIZE,
29
+ preferred: USE_PREF_SIZE,
30
+ compute: USE_COMPUTED_SIZE)
31
+
32
+ converter_for :min_width, [use_sizes]
33
+ converter_for :min_height, [use_sizes]
34
+ converter_for :pref_width, [use_sizes]
35
+ converter_for :pref_height, [use_sizes]
36
+ converter_for :max_width, [use_sizes]
37
+ converter_for :max_height, [use_sizes]
38
+
39
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX color stops
18
+ class Java::javafx::scene::transform::Rotate
19
+ extend JRubyFX::Utils::CommonConverters
20
+
21
+ @@axis_conversions = map_converter(x_axis: X_AXIS,
22
+ y_axis: Y_AXIS,
23
+ z_axis: Z_AXIS,
24
+ x: X_AXIS,
25
+ y: Y_AXIS,
26
+ z: Z_AXIS)
27
+
28
+ converter_for :axis, [@@axis_conversions]
29
+
30
+ class << self
31
+ extend JRubyFX::Utils::CommonConverters
32
+
33
+ converter_for :new, [], [:none], [:none, @axis_conversions], [:none, :none, :none],
34
+ [:none, :none, :none, :none], [:none, :none, :none, :none, @axis_conversions]
35
+ end
36
+
37
+ end
@@ -0,0 +1,29 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX Scenes
20
+ class Java::javafx::scene::Scene
21
+ include JRubyFX::DSL
22
+
23
+ class << self
24
+ extend JRubyFX::Utils::CommonConverters
25
+
26
+ converter_for :new, [:none], [:none, :color], [:none, :none, :none],
27
+ [:none, :none, :none, :color]
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX Shapes
18
+ class Java::javafx::scene::shape::Shape
19
+ extend JRubyFX::Utils::CommonConverters
20
+
21
+ converter_for :fill, [:color]
22
+ converter_for :fill=, [:color]
23
+ converter_for :stroke, [:color]
24
+ converter_for :stroke=, [:color]
25
+
26
+ alias :fill :set_fill
27
+ end
@@ -0,0 +1,77 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for the JavaFX Stage
20
+ class Java::javafx::stage::Stage
21
+ include JRubyFX::DSL
22
+
23
+ ##
24
+ # call-seq:
25
+ # [name] => node or nil
26
+ #
27
+ # Returns the item in the scene with the given CSS selector, or nil if not found.
28
+ # === Example
29
+ # stage['#my_button'] #=> Button
30
+ # stage['#doesNotExist'] #=> nil
31
+ #
32
+ def [](name)
33
+ get_scene.lookup(name)
34
+ end
35
+
36
+ ##
37
+ # call-seq:
38
+ # layout_scene() { block } => scene
39
+ # layout_scene(fill) { block } => scene
40
+ # layout_scene(width, height) { block } => scene
41
+ # layout_scene(width, height, fill) { block } => scene
42
+ # layout_scene(width, height, depth_buffer) { block } => scene
43
+ # layout_scene(hash) { block } => scene
44
+ # layout_scene(fill, hash) { block } => scene
45
+ # layout_scene(width, height, hash) { block } => scene
46
+ # layout_scene(width, height, fill, hash) { block } => scene
47
+ # layout_scene(width, height, depth_buffer, hash) { block } => scene
48
+ # layout_scene(fill, hash) => scene
49
+ # layout_scene(width, height, hash) => scene
50
+ # layout_scene(width, height, fill, hash) => scene
51
+ # layout_scene(width, height, depth_buffer, hash) => scene
52
+ # layout_scene(fill) => scene
53
+ # layout_scene(width, height) => scene
54
+ # layout_scene(width, height, fill) => scene
55
+ # layout_scene(width, height, depth_buffer) => scene
56
+ #
57
+ # Creates a new scene with given constructor arguments (fill, width, height),
58
+ # sets all the properties in the hash, and calls the block on the scene.
59
+ # === Examples
60
+ # layout_scene(fill: "white") do
61
+ # label("Hello World!")
62
+ # end
63
+ #
64
+ # layout_scene(:white) do
65
+ # label("Hello World!")
66
+ # end
67
+ #
68
+ # layout_scene do
69
+ # fill = Color::WHITE
70
+ # label("Hello World!")
71
+ # end
72
+ #
73
+ def layout_scene(*args, &code)
74
+ root = code.arity == 1 ? code[node] : instance_eval(&code)
75
+ build(Scene, root, *args).tap { |scene| set_scene scene }
76
+ end
77
+ end
@@ -0,0 +1,29 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX color stops
18
+ class Java::javafx::scene::paint::Stop
19
+ extend JRubyFX::Utils::CommonConverters
20
+
21
+ converter_for :color, [:color]
22
+
23
+ class << self
24
+ extend JRubyFX::Utils::CommonConverters
25
+
26
+ converter_for :new, [:none, :color]
27
+ end
28
+
29
+ end
@@ -0,0 +1,35 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/dsl'
18
+
19
+ # JRubyFX DSL extensions for JavaFX TableViews
20
+ class Java::javafx::scene::control::TableView
21
+ java_import Java::javafx.scene.control.TableColumn
22
+
23
+ include JRubyFX::DSL
24
+ extend JRubyFX::Utils::CommonConverters
25
+
26
+ include_add :get_columns
27
+ include_method_missing TableColumn
28
+
29
+ resize_policy = map_converter(unconstrained_resize_policy: UNCONSTRAINED_RESIZE_POLICY,
30
+ constrained_resize_policy: CONSTRAINED_RESIZE_POLICY,
31
+ unconstrained: UNCONSTRAINED_RESIZE_POLICY,
32
+ constrained: CONSTRAINED_RESIZE_POLICY)
33
+
34
+ converter_for :column_resize_policy, [resize_policy]
35
+ end
@@ -0,0 +1,47 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ # JRubyFX DSL extensions for JavaFX animation Timelines
18
+ class Java::javafx::animation::Timeline
19
+ java_import Java::javafx.animation.KeyFrame
20
+
21
+ include JRubyFX::DSL
22
+ extend JRubyFX::Utils::CommonConverters
23
+
24
+ include_add :key_frames
25
+ include_method_missing KeyFrame
26
+
27
+ def animate(prop, args)
28
+ time = []
29
+ values = []
30
+ # detect our time
31
+ args.each do |key, value|
32
+ if key.is_a? Duration
33
+ time << [key, value]
34
+ time.flatten!
35
+ else #assume values
36
+ values << [key, value]
37
+ values.flatten!
38
+ end
39
+ end
40
+ # add the keyframes
41
+ [time.length, values.length].min.times do |i|
42
+ key_frame(time[i], key_value(prop, values[i]))
43
+ end
44
+ end
45
+
46
+ converter_for :cycle_count, [map_converter(indefinite: Java::javafx::animation::Timeline::INDEFINITE)]
47
+ end