jrubyfx 0.9.1-java → 0.9.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/README.md +18 -2
  2. data/bin/{rubyfx-generator → jrubyfx-generator} +3 -3
  3. data/bin/jrubyfx-jarify +29 -4
  4. data/lib/jrubyfx/core_ext/border_pane.rb +2 -0
  5. data/lib/jrubyfx/core_ext/column_constraints.rb +2 -0
  6. data/lib/jrubyfx/core_ext/drag_event.rb +32 -0
  7. data/lib/jrubyfx/core_ext/drag_event.rb~ +32 -0
  8. data/lib/jrubyfx/core_ext/duration.rb +2 -0
  9. data/lib/jrubyfx/core_ext/effects.rb +2 -0
  10. data/lib/jrubyfx/core_ext/file_chooser.rb +3 -0
  11. data/lib/jrubyfx/core_ext/image_view.rb +24 -0
  12. data/lib/jrubyfx/core_ext/image_view.rb~ +24 -0
  13. data/lib/jrubyfx/core_ext/media_player.rb +2 -0
  14. data/lib/jrubyfx/core_ext/menu.rb +25 -0
  15. data/lib/jrubyfx/core_ext/menu.rb~ +26 -0
  16. data/lib/jrubyfx/core_ext/menu_bar.rb +25 -0
  17. data/lib/jrubyfx/core_ext/menu_bar.rb~ +24 -0
  18. data/lib/jrubyfx/core_ext/menu_item.rb +22 -0
  19. data/lib/jrubyfx/core_ext/node.rb +2 -0
  20. data/lib/jrubyfx/core_ext/pagination.rb +4 -2
  21. data/lib/jrubyfx/core_ext/path.rb +2 -0
  22. data/lib/jrubyfx/core_ext/progress_indicator.rb +3 -0
  23. data/lib/jrubyfx/core_ext/region.rb +3 -0
  24. data/lib/jrubyfx/core_ext/rotate.rb +2 -0
  25. data/lib/jrubyfx/core_ext/shape.rb +2 -0
  26. data/lib/jrubyfx/core_ext/stop.rb +2 -0
  27. data/lib/jrubyfx/core_ext/timeline.rb +13 -0
  28. data/lib/jrubyfx/core_ext/transition.rb +1 -0
  29. data/lib/jrubyfx/core_ext/tree_item.rb +25 -0
  30. data/lib/jrubyfx/core_ext/tree_item.rb~ +25 -0
  31. data/lib/jrubyfx/core_ext/tree_view.rb +40 -0
  32. data/lib/jrubyfx/core_ext/tree_view.rb~ +33 -0
  33. data/lib/jrubyfx/dsl.rb +46 -7
  34. data/lib/jrubyfx/fxml_controller.rb +85 -30
  35. data/lib/jrubyfx/jfx_imports.rb +25 -23
  36. data/lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb +6 -0
  37. data/lib/jrubyfx/utils/common_converters.rb +50 -2
  38. data/lib/jrubyfx/version.rb +1 -1
  39. data/lib/jrubyfx_tasks.rb +54 -10
  40. metadata +18 -5
@@ -31,8 +31,10 @@ begin
31
31
  jfx_path.gsub(/[\/\\][amdix345678_]+$/, "") # strip i386 or amd64 (including variants). TODO: ARM
32
32
  end
33
33
  end
34
- require 'jfxrt.jar'
35
- rescue LoadError
34
+ # Java 8 and above has JavaFX as part of the normal distib, only require it if we are 7 or below
35
+ require 'jfxrt.jar' if ENV['JFX_DIR'] or ENV_JAVA["java.runtime.version"].match(/^1\.[0-7]{1}\..*/)
36
+ testit = Java.javafx.application.Application
37
+ rescue LoadError, NameError
36
38
  puts "JavaFX runtime not found. Please install Java 7u6 or newer or set environment variable JFX_DIR to the folder that contains jfxrt.jar "
37
39
  puts "If you have Java 7u6 or later, this is a bug. Please report to the issue tracker on github. Include your OS version, 32/64bit, and architecture (x86, ARM, PPC, etc)"
38
40
  exit -1
@@ -42,50 +44,50 @@ module JRubyFX
42
44
  # If you need JavaFX, just include this module. Its sole purpose in life is to
43
45
  # import all JavaFX stuff, plus a few useful Java classes (like Void)
44
46
  module FXImports
45
-
47
+
46
48
  # If something is missing, just java_import it in your code.
47
49
  # And then ask us to put it in this list
48
-
49
- ##
50
+
51
+ ##
50
52
  # This is the list of all classes in JavaFX that most apps should care about.
51
- # It is a hashmaps with the leafs as arrays. Where a leaf also contains more
53
+ # It is a hashmaps with the leafs as arrays. Where a leaf also contains more
52
54
  # packages, the hashmap key is "" (empty string). You can utilize this constant
53
55
  # to save yourself some typing when adding code for most/all of the JavaFX
54
56
  # classes by using either `Hash.flat_tree_inject` from jrubyfx/utils.rb or
55
57
  # writing your own traversal function
56
58
  #
57
59
  JFX_CLASS_HIERARCHY = { :javafx => {
58
- :animation => %w[Animation AnimationTimer FadeTransition FillTransition Interpolator KeyFrame KeyValue ParallelTransition PathTransition
60
+ :animation => %w[Animation AnimationTimer FadeTransition FillTransition Interpolator KeyFrame KeyValue ParallelTransition PathTransition
59
61
  PauseTransition RotateTransition ScaleTransition SequentialTransition StrokeTransition Timeline Transition TranslateTransition],
60
62
  :application => ['Platform'],
61
63
  :beans => {
62
64
  :property => ['SimpleDoubleProperty'],
63
65
  #TODO: import more
64
- :value => ['ChangeListener']
66
+ :value => ['ChangeListener']
65
67
  },
66
68
  :collections => ['FXCollections'],
67
69
  :event => %w[Event ActionEvent EventHandler],
68
70
  :fxml => ['Initializable', 'LoadException'],
69
- :geometry => %w[HorizontalDirection HPos Insets Orientation Pos Side VerticalDirection VPos],
71
+ :geometry => %w[HorizontalDirection HPos Insets Orientation Pos Rectangle2D Side VerticalDirection VPos],
70
72
  :scene => {
71
73
  '' => %w[Group Node Parent Scene],
72
74
  :canvas => ['Canvas'],
73
- :chart => %w[Axis CategoryAxis Chart LineChart NumberAxis XYChart],
74
- # TODO: import more of these
75
- :control => %w[Accordion Button Cell CheckBox CheckBoxTreeItem CheckMenuItem ChoiceBox ColorPicker ComboBox ContextMenu Hyperlink
76
- Label ListCell ListView Menu MenuBar MenuButton MenuItem Pagination PasswordField PopupControl ProgressBar ProgressIndicator RadioButton
77
- RadioMenuItem ScrollBar ScrollPane Separator SeparatorMenuItem Slider SplitMenuButton SplitPane Tab TableView TableColumn TabPane TextArea
78
- TextField TitledPane ToggleButton ToggleGroup ToolBar Tooltip TreeItem TreeView ContentDisplay OverrunStyle SelectionMode],
79
- :effect => %w[Blend BlendMode Bloom BlurType BoxBlur ColorAdjust ColorInput DisplacementMap DropShadow GaussianBlur Glow ImageInput
75
+ :chart => %w[AreaChart Axis BarChart BubbleChart CategoryAxis Chart LineChart NumberAxis
76
+ PieChart ScatterChart StackedAreaChart StackedBarChart ValueAxis XYChart],
77
+ :control => %w[Accordion Button Cell CheckBox CheckBoxTreeItem CheckMenuItem ChoiceBox ColorPicker ComboBox ContextMenu Hyperlink
78
+ Label ListCell ListView Menu MenuBar MenuButton MenuItem Pagination PasswordField PopupControl ProgressBar ProgressIndicator RadioButton
79
+ RadioMenuItem ScrollBar ScrollPane Separator SeparatorMenuItem Slider SplitMenuButton SplitPane Tab TableView TableColumn TabPane TextArea
80
+ TextField TitledPane ToggleButton ToggleGroup ToolBar Tooltip TreeCell TreeItem TreeView ContentDisplay OverrunStyle SelectionMode],
81
+ :effect => %w[Blend BlendMode Bloom BlurType BoxBlur ColorAdjust ColorInput DisplacementMap DropShadow GaussianBlur Glow ImageInput
80
82
  InnerShadow Lighting MotionBlur PerspectiveTransform Reflection SepiaTone Shadow],
81
83
  :image => %w[Image ImageView PixelReader PixelWriter],
82
- :input => %w[Clipboard ContextMenuEvent DragEvent GestureEvent InputEvent InputMethodEvent KeyEvent
83
- Mnemonic MouseDragEvent MouseEvent RotateEvent ScrollEvent SwipeEvent TouchEvent ZoomEvent],
84
+ :input => %w[Clipboard ClipboardContent ContextMenuEvent DragEvent GestureEvent InputEvent InputMethodEvent KeyCode KeyEvent
85
+ Mnemonic MouseDragEvent MouseEvent RotateEvent ScrollEvent SwipeEvent TouchEvent TransferMode ZoomEvent],
84
86
  :layout => %w[AnchorPane BorderPane ColumnConstraints FlowPane GridPane HBox Pane Priority RowConstraints StackPane TilePane VBox],
85
- :media => %w[Media MediaPlayer MediaView],
86
- # TODO: fill this out
87
+ :media => %w[AudioClip AudioEqualizer AudioTrack EqualizerBand Media MediaException
88
+ MediaErrorEvent MediaMarkerEvent MediaPlayer MediaView VideoTrack],
87
89
  :paint => %w[Color CycleMethod ImagePattern LinearGradient Paint RadialGradient Stop],
88
- :shape => %w[Arc ArcTo ArcType Circle ClosePath CubicCurve CubicCurveTo Ellipse FillRule HLineTo Line LineTo MoveTo Path PathElement
90
+ :shape => %w[Arc ArcTo ArcType Circle ClosePath CubicCurve CubicCurveTo Ellipse FillRule HLineTo Line LineTo MoveTo Path PathElement
89
91
  Polygon Polyline QuadCurve QuadCurveTo Rectangle Shape StrokeLineCap StrokeLineJoin StrokeType SVGPath VLineTo],
90
92
  :text => %w[Font FontPosture FontSmoothingType FontWeight Text TextAlignment TextBoundsType],
91
93
  :transform => %w[Affine Rotate Scale Shear Translate],
@@ -95,7 +97,7 @@ module JRubyFX
95
97
  :util => ['Duration']
96
98
  }
97
99
  }
98
-
100
+
99
101
  # Imports all the listed JavaFX classes
100
102
  java_import *(JFX_CLASS_HIERARCHY.flat_tree_inject do |res, name, values|
101
103
  name = "#{name.to_s}."
@@ -104,4 +106,4 @@ module JRubyFX
104
106
  end)
105
107
  java_import 'java.lang.Void'
106
108
  end
107
- end
109
+ end
@@ -11,12 +11,18 @@ module Java #:nodoc: all
11
11
  end
12
12
  module control
13
13
  end
14
+ module effect
15
+ end
14
16
  module layout
15
17
  end
18
+ module media
19
+ end
16
20
  module paint
17
21
  end
18
22
  module shape
19
23
  end
24
+ module transform
25
+ end
20
26
  end
21
27
  module stage
22
28
  end
@@ -14,11 +14,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  =end
17
+ false # Do NOT delete this or it will make RDOC associate the copyright header with JRubyFX module
18
+
17
19
  module JRubyFX
18
20
  module Utils
19
21
  # Contains conversion utilities to ease Ruby => JavaFX coding
20
22
  module CommonConverters
21
23
  java_import 'javafx.scene.paint.Color'
24
+ java_import 'javafx.geometry.Insets'
25
+ java_import 'javafx.geometry.Rectangle2D'
22
26
 
23
27
  # argument converter method name suffix
24
28
  ARG_CONVERTER_SUFFIX = '_arg_converter'
@@ -48,7 +52,20 @@ module JRubyFX
48
52
  (JRubyFX::Utils::CommonConverters.map_enums(enum_class)[value.to_s] || value)
49
53
  end
50
54
  end
51
-
55
+
56
+ ##
57
+ # call-seq:
58
+ # animation_converter_for :property_name, ...
59
+ #
60
+ # Generates an animation adapter for the given properties so you can specify
61
+ # transformations, etc with a hashmap of from, to values
62
+ # === Examples
63
+ # animation_converter_for :value
64
+ #
65
+ # ...
66
+ #
67
+ # _my_type_(value: {0 => 360})
68
+ #
52
69
  def animation_converter_for(*prop_names)
53
70
  prop_names.each do |prop_name|
54
71
  self.__send__(:define_method, prop_name.to_s + "=") do |hash|
@@ -72,9 +89,18 @@ module JRubyFX
72
89
  # *new_arg_converter* which will perform no argument coercion on
73
90
  # the first argument and a color coercion on the second argument.
74
91
  #
75
- def converter_for(method_name, *converters)
92
+ # e = enum_converter(Java::javafx::scene::input::TransferMode)
93
+ # converter_for :accept_transfer_modes &e
94
+ #
95
+ # This method will allow a catch-all converter to be used for all
96
+ # arities not specified. In this case since no arities are given
97
+ # all arities will pass through this enum_converter. This form
98
+ # is useful for single var_args signatures.
99
+ #
100
+ def converter_for(method_name, *converters, &default)
76
101
  sheep = lambda do |direct, this, *values|
77
102
  converter = converters.find { |e| e.length == values.length }
103
+ converter = Array.new(values.length, default) unless converter
78
104
 
79
105
  # FIXME: Better error reporting on many things which can fail
80
106
  i = 0
@@ -115,6 +141,28 @@ module JRubyFX
115
141
  new_value = NAME_TO_COLORS[value.to_s.gsub(/_/, "")]
116
142
  new_value ? new_value : value
117
143
  },
144
+ :rectangle2d => lambda { |value|
145
+ if value == :empty
146
+ Rectangle2D::EMPTY
147
+ elsif value.is_a? Array
148
+ Rectangle2D.new(*value)
149
+ else
150
+ value
151
+ end
152
+ },
153
+ :insets => lambda { |value|
154
+ if value == :empty
155
+ Insets::EMPTY
156
+ elsif value.is_a? Numeric
157
+ Insets.new(value)
158
+ elsif value.is_a? Array
159
+ # top/bottom, left/right
160
+ value = [value[0], value[1], value[0], value[1]] if value.size == 2
161
+ Insets.new(*value)
162
+ else
163
+ value
164
+ end
165
+ },
118
166
  }
119
167
 
120
168
  # Store enum mapping overrides
@@ -1,4 +1,4 @@
1
1
  module JRubyFX
2
2
  # Current gem version. Used in rake task.
3
- VERSION='0.9.1'
3
+ VERSION='0.9.2'
4
4
  end
@@ -19,6 +19,8 @@ limitations under the License.
19
19
  require 'open-uri'
20
20
  require 'rake'
21
21
  require 'tmpdir'
22
+ require "ant"
23
+ require "pathname"
22
24
 
23
25
  module JRubyFX
24
26
  # This module contains utilities to jarify an app, and can be used in a rakefile or a running app.
@@ -28,8 +30,8 @@ module JRubyFX
28
30
  BASE_URL='http://repository.codehaus.org/org/jruby/jruby-complete'
29
31
 
30
32
  ##
31
- # Downloads the jruby-complete jar file for `jruby_version` and save in
32
- # ~/.jruby-jar/jruby-complete.jar unless it already exits. If the jar is
33
+ # Downloads the jruby-complete jar file for `jruby_version` and save in
34
+ # ~/.jruby-jar/jruby-complete.jar unless it already exits. If the jar is
33
35
  # corrupt or an older version, set force to true to delete and re-download
34
36
  def download_jruby(jruby_version, force=false)
35
37
  dist = "#{ENV['HOME']}/.jruby-jar"
@@ -37,19 +39,19 @@ module JRubyFX
37
39
  mkdir_p dist
38
40
  base_dir = Dir.pwd
39
41
  cd dist
40
- puts "JRuby complete jar not found. Downloading... (May take awhile)"
42
+ $stderr.puts "JRuby complete jar not found. Downloading... (May take awhile)"
41
43
  download(jruby_version)
42
44
  cd base_dir
43
45
  end
44
46
  end
45
47
 
46
- ##
48
+ ##
47
49
  # Creates a full jar from the given source pattern (must be a pattern to match
48
50
  # files), with the given main script as the script to launch when the jarfile
49
51
  # is run. The output jar is saved in the `target` dir, which also doubles as a
50
52
  # temporary work dir. `jar` is the executable that makes jars. If `target` is
51
53
  # nill then a random temporary directory is created, and output_jar is the
52
- # full path to the jar file to save
54
+ # full path to the jar file to save
53
55
  def jarify_jrubyfx(src="src/*" ,main_script=nil, target="target", output_jar="jrubyfx-app.jar", opts = {})
54
56
  if target_was_nil = target == nil
55
57
  target = Dir.mktmpdir("jrubyfx")
@@ -71,11 +73,11 @@ module JRubyFX
71
73
  cp main_script, "#{target}/jar-bootstrap.rb" unless main_script == nil
72
74
 
73
75
  unless File.exists? "#{target}/jar-bootstrap.rb"
74
- puts "@"*79
75
- puts "@#{"!!!WARNING!!!".center(79-2)}@"
76
- puts "@#{"jar-bootstrap.rb NOT FOUND!".center(79-2)}@"
77
- puts "@#{"Did you set main_src= or have jar-bootstrap in src= ?".center(79-2)}@"
78
- puts "@"*79
76
+ $stderr.puts "@"*79
77
+ $stderr.puts "@#{"!!!WARNING!!!".center(79-2)}@"
78
+ $stderr.puts "@#{"jar-bootstrap.rb NOT FOUND!".center(79-2)}@"
79
+ $stderr.puts "@#{"Did you set main_src= or have jar-bootstrap in src= ?".center(79-2)}@"
80
+ $stderr.puts "@"*79
79
81
  end
80
82
 
81
83
  #copy our libs in
@@ -96,6 +98,47 @@ module JRubyFX
96
98
  end
97
99
  end
98
100
 
101
+ # Uses Java 8 Ant task to create a native bundle (exe, deb, rpm, etc) of the
102
+ # specified jar-ified ruby script
103
+ def native_bundles(base_dir=Dir.pwd, output_jar, verbosity, app_name)
104
+ # Currently only JDK8 will package up JRuby apps. In the near
105
+ # future the necessary tools will be in maven central and
106
+ # we can download them as needed, so this can be changed then.
107
+ # this is in format "1.7.0_11-b21", check for all jdk's less than 8
108
+ if ENV_JAVA["java.runtime.version"].match(/^1\.[0-7]{1}\..*/)
109
+ raise "You must install JDK 8 to use the native-bundle packaging tools. You can still create an executable jar, though."
110
+ end
111
+
112
+ output_jar = Pathname.new(output_jar)
113
+ dist_dir = output_jar.parent
114
+ jar_name = File.basename(output_jar)
115
+ out_name = File.basename(output_jar, '.*')
116
+
117
+ # Can't access the "fx" xml namespace directly, so we get it via __send__.
118
+ ant do
119
+ taskdef(resource: "com/sun/javafx/tools/ant/antlib.xml",
120
+ uri: "javafx:com.sun.javafx.tools.ant",
121
+ classpath: ".:${java.home}/../lib/ant-javafx.jar")
122
+ __send__("javafx:com.sun.javafx.tools.ant:deploy", nativeBundles: "all",
123
+ width: "100", height: "100", outdir: "#{base_dir}/build/",
124
+ outfile: out_name, verbose: verbosity) do
125
+ application(mainClass: "org.jruby.JarBootstrapMain", name: app_name)
126
+ resources do
127
+ fileset(dir: dist_dir) do
128
+ include name: jar_name
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ # These webstart files don't work, and the packager doesn't have an option to
135
+ # disable them, so remove them so the user isn't confused.
136
+ # FIXME: jnlp webstart
137
+ full_build_dir = "#{base_dir}/build/"
138
+ rm FileList["#{full_build_dir}*.html","#{full_build_dir}*.jnlp"]
139
+ end
140
+
141
+
99
142
  private
100
143
  def download(version_string) #:nodoc:
101
144
  File.open("jruby-complete.jar","wb") do |f|
@@ -105,6 +148,7 @@ module JRubyFX
105
148
 
106
149
  module_function :jarify_jrubyfx
107
150
  module_function :download_jruby
151
+ module_function :native_bundles
108
152
  module_function :download
109
153
  end
110
154
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrubyfx
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.9.2
4
5
  prerelease:
5
- version: 0.9.1
6
6
  platform: java
7
7
  authors:
8
8
  - Patrick Plenefisch
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-01-24 00:00:00.000000000 Z
15
+ date: 2013-02-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -39,7 +39,7 @@ email:
39
39
  - nahi@ruby-lang.org
40
40
  - asari.ruby@gmail.com
41
41
  executables:
42
- - rubyfx-generator
42
+ - jrubyfx-generator
43
43
  - jrubyfx-jarify
44
44
  extensions: []
45
45
  extra_rdoc_files: []
@@ -57,11 +57,20 @@ files:
57
57
  - lib/jrubyfx/core_ext/border_pane.rb
58
58
  - lib/jrubyfx/core_ext/circle.rb
59
59
  - lib/jrubyfx/core_ext/column_constraints.rb
60
+ - lib/jrubyfx/core_ext/drag_event.rb
61
+ - lib/jrubyfx/core_ext/drag_event.rb~
60
62
  - lib/jrubyfx/core_ext/duration.rb
61
63
  - lib/jrubyfx/core_ext/effects.rb
62
64
  - lib/jrubyfx/core_ext/file_chooser.rb
65
+ - lib/jrubyfx/core_ext/image_view.rb
66
+ - lib/jrubyfx/core_ext/image_view.rb~
63
67
  - lib/jrubyfx/core_ext/labeled.rb
64
68
  - lib/jrubyfx/core_ext/media_player.rb
69
+ - lib/jrubyfx/core_ext/menu.rb
70
+ - lib/jrubyfx/core_ext/menu.rb~
71
+ - lib/jrubyfx/core_ext/menu_bar.rb
72
+ - lib/jrubyfx/core_ext/menu_bar.rb~
73
+ - lib/jrubyfx/core_ext/menu_item.rb
65
74
  - lib/jrubyfx/core_ext/node.rb
66
75
  - lib/jrubyfx/core_ext/observable_value.rb
67
76
  - lib/jrubyfx/core_ext/pagination.rb
@@ -79,15 +88,19 @@ files:
79
88
  - lib/jrubyfx/core_ext/table_view.rb
80
89
  - lib/jrubyfx/core_ext/timeline.rb
81
90
  - lib/jrubyfx/core_ext/transition.rb
91
+ - lib/jrubyfx/core_ext/tree_item.rb
92
+ - lib/jrubyfx/core_ext/tree_item.rb~
93
+ - lib/jrubyfx/core_ext/tree_view.rb
94
+ - lib/jrubyfx/core_ext/tree_view.rb~
82
95
  - lib/jrubyfx/core_ext/xy_chart.rb
83
96
  - lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb
84
97
  - lib/jrubyfx/utils/common_converters.rb
85
98
  - lib/jrubyfx/utils/common_utils.rb
86
99
  - LICENSE
87
100
  - README.md
88
- - bin/rubyfx-generator
101
+ - bin/jrubyfx-generator
89
102
  - bin/jrubyfx-jarify
90
- homepage: https://github.com/byteit101/JRubyFX
103
+ homepage: https://github.com/jruby/jrubyfx
91
104
  licenses: []
92
105
  post_install_message:
93
106
  rdoc_options: []