jrubyfx 0.9.2-java → 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -17
- data/bin/jrubyfx-generator +28 -11
- data/lib/jrubyfx.rb +8 -4
- data/lib/jrubyfx/{fxml_application.rb → application.rb} +0 -2
- data/lib/jrubyfx/controller.rb +307 -0
- data/lib/jrubyfx/core_ext/border_pane.rb +0 -1
- data/lib/jrubyfx/core_ext/duration.rb +1 -1
- data/lib/jrubyfx/core_ext/exts.yml +53 -0
- data/lib/jrubyfx/core_ext/image_view.rb +1 -0
- data/lib/jrubyfx/core_ext/observable_value.rb +69 -2
- data/lib/jrubyfx/core_ext/path.rb +0 -6
- data/lib/jrubyfx/core_ext/precompiled.rb +501 -0
- data/lib/jrubyfx/core_ext/stage.rb +12 -0
- data/lib/jrubyfx/core_ext/table_view.rb +0 -4
- data/lib/jrubyfx/core_ext/timeline.rb +3 -7
- data/lib/jrubyfx/dsl.rb +168 -150
- data/lib/jrubyfx/dsl_map.rb +267 -0
- data/lib/jrubyfx/imports.rb +64 -0
- data/lib/jrubyfx/java_fx_impl.rb +0 -1
- data/lib/jrubyfx/module.rb +172 -0
- data/lib/jrubyfx/{jfx_imports.rb → part_imports.rb} +17 -9
- data/lib/jrubyfx/utils.rb +13 -4
- data/lib/jrubyfx/utils/common_converters.rb +45 -13
- data/lib/jrubyfx/utils/common_utils.rb +1 -1
- data/lib/jrubyfx/version.rb +1 -1
- data/lib/jrubyfx_tasks.rb +9 -1
- metadata +69 -55
- data/lib/jrubyfx/core_ext/circle.rb +0 -26
- data/lib/jrubyfx/core_ext/drag_event.rb~ +0 -32
- data/lib/jrubyfx/core_ext/image_view.rb~ +0 -24
- data/lib/jrubyfx/core_ext/labeled.rb +0 -24
- data/lib/jrubyfx/core_ext/menu.rb +0 -25
- data/lib/jrubyfx/core_ext/menu.rb~ +0 -26
- data/lib/jrubyfx/core_ext/menu_bar.rb +0 -25
- data/lib/jrubyfx/core_ext/menu_bar.rb~ +0 -24
- data/lib/jrubyfx/core_ext/menu_item.rb +0 -22
- data/lib/jrubyfx/core_ext/node.rb +0 -26
- data/lib/jrubyfx/core_ext/parallel_transition.rb +0 -28
- data/lib/jrubyfx/core_ext/parent.rb +0 -28
- data/lib/jrubyfx/core_ext/scene.rb +0 -29
- data/lib/jrubyfx/core_ext/shape.rb +0 -29
- data/lib/jrubyfx/core_ext/stop.rb +0 -31
- data/lib/jrubyfx/core_ext/tree_item.rb +0 -25
- data/lib/jrubyfx/core_ext/tree_item.rb~ +0 -25
- data/lib/jrubyfx/core_ext/tree_view.rb~ +0 -33
- data/lib/jrubyfx/fxml_controller.rb +0 -325
- data/lib/jrubyfx/fxml_module.rb +0 -98
@@ -0,0 +1,267 @@
|
|
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
|
+
|
18
|
+
# DO NOT MODIFY THIS FILE!
|
19
|
+
# This file is generated by the `rake reflect` task.
|
20
|
+
|
21
|
+
module JRubyFX
|
22
|
+
module DSL
|
23
|
+
NAME_TO_CLASSES = {
|
24
|
+
# Manual overrides
|
25
|
+
'observable_array_list' => proc { |*args| FXCollections.observable_array_list(*args) },
|
26
|
+
'double_property' => SimpleDoubleProperty,
|
27
|
+
'xy_chart_series' => Java::javafx.scene.chart.XYChart::Series,
|
28
|
+
'xy_chart_data' => Java::javafx.scene.chart.XYChart::Data,
|
29
|
+
# Automatically generated
|
30
|
+
'animation' => Animation,
|
31
|
+
'animation_timer' => AnimationTimer,
|
32
|
+
'fade_transition' => FadeTransition,
|
33
|
+
'fill_transition' => FillTransition,
|
34
|
+
'interpolator' => Interpolator,
|
35
|
+
'key_frame' => KeyFrame,
|
36
|
+
'key_value' => KeyValue,
|
37
|
+
'parallel_transition' => ParallelTransition,
|
38
|
+
'path_transition' => PathTransition,
|
39
|
+
'pause_transition' => PauseTransition,
|
40
|
+
'rotate_transition' => RotateTransition,
|
41
|
+
'scale_transition' => ScaleTransition,
|
42
|
+
'sequential_transition' => SequentialTransition,
|
43
|
+
'stroke_transition' => StrokeTransition,
|
44
|
+
'timeline' => Timeline,
|
45
|
+
'transition' => Transition,
|
46
|
+
'translate_transition' => TranslateTransition,
|
47
|
+
'platform' => Platform,
|
48
|
+
'simple_boolean_property' => SimpleBooleanProperty,
|
49
|
+
'simple_double_property' => SimpleDoubleProperty,
|
50
|
+
'simple_float_property' => SimpleFloatProperty,
|
51
|
+
'simple_integer_property' => SimpleIntegerProperty,
|
52
|
+
'simple_list_property' => SimpleListProperty,
|
53
|
+
'simple_long_property' => SimpleLongProperty,
|
54
|
+
'simple_map_property' => SimpleMapProperty,
|
55
|
+
'simple_object_property' => SimpleObjectProperty,
|
56
|
+
'simple_set_property' => SimpleSetProperty,
|
57
|
+
'simple_string_property' => SimpleStringProperty,
|
58
|
+
'change_listener' => ChangeListener,
|
59
|
+
'fx_collections' => FXCollections,
|
60
|
+
'event' => Event,
|
61
|
+
'action_event' => ActionEvent,
|
62
|
+
'event_handler' => EventHandler,
|
63
|
+
'initializable' => Initializable,
|
64
|
+
'load_exception' => LoadException,
|
65
|
+
'horizontal_direction' => HorizontalDirection,
|
66
|
+
'h_pos' => HPos,
|
67
|
+
'insets' => Insets,
|
68
|
+
'orientation' => Orientation,
|
69
|
+
'pos' => Pos,
|
70
|
+
'rectangle2_d' => Rectangle2D,
|
71
|
+
'side' => Side,
|
72
|
+
'vertical_direction' => VerticalDirection,
|
73
|
+
'v_pos' => VPos,
|
74
|
+
'group' => Group,
|
75
|
+
'node' => Node,
|
76
|
+
'parent' => Parent,
|
77
|
+
'scene' => Scene,
|
78
|
+
'canvas' => Canvas,
|
79
|
+
'area_chart' => AreaChart,
|
80
|
+
'axis' => Axis,
|
81
|
+
'bar_chart' => BarChart,
|
82
|
+
'bubble_chart' => BubbleChart,
|
83
|
+
'category_axis' => CategoryAxis,
|
84
|
+
'chart' => Chart,
|
85
|
+
'line_chart' => LineChart,
|
86
|
+
'number_axis' => NumberAxis,
|
87
|
+
'pie_chart' => PieChart,
|
88
|
+
'scatter_chart' => ScatterChart,
|
89
|
+
'stacked_area_chart' => StackedAreaChart,
|
90
|
+
'stacked_bar_chart' => StackedBarChart,
|
91
|
+
'value_axis' => ValueAxis,
|
92
|
+
'xy_chart' => XYChart,
|
93
|
+
'accordion' => Accordion,
|
94
|
+
'button' => Button,
|
95
|
+
'cell' => Cell,
|
96
|
+
'check_box' => CheckBox,
|
97
|
+
'check_box_tree_item' => CheckBoxTreeItem,
|
98
|
+
'check_menu_item' => CheckMenuItem,
|
99
|
+
'choice_box' => ChoiceBox,
|
100
|
+
'color_picker' => ColorPicker,
|
101
|
+
'combo_box' => ComboBox,
|
102
|
+
'context_menu' => ContextMenu,
|
103
|
+
'hyperlink' => Hyperlink,
|
104
|
+
'label' => Label,
|
105
|
+
'list_cell' => ListCell,
|
106
|
+
'list_view' => ListView,
|
107
|
+
'menu' => Menu,
|
108
|
+
'menu_bar' => MenuBar,
|
109
|
+
'menu_button' => MenuButton,
|
110
|
+
'menu_item' => MenuItem,
|
111
|
+
'pagination' => Pagination,
|
112
|
+
'password_field' => PasswordField,
|
113
|
+
'popup_control' => PopupControl,
|
114
|
+
'progress_bar' => ProgressBar,
|
115
|
+
'progress_indicator' => ProgressIndicator,
|
116
|
+
'radio_button' => RadioButton,
|
117
|
+
'radio_menu_item' => RadioMenuItem,
|
118
|
+
'scroll_bar' => ScrollBar,
|
119
|
+
'scroll_pane' => ScrollPane,
|
120
|
+
'separator' => Separator,
|
121
|
+
'separator_menu_item' => SeparatorMenuItem,
|
122
|
+
'slider' => Slider,
|
123
|
+
'split_menu_button' => SplitMenuButton,
|
124
|
+
'split_pane' => SplitPane,
|
125
|
+
'tab' => Tab,
|
126
|
+
'table_view' => TableView,
|
127
|
+
'table_cell' => TableCell,
|
128
|
+
'table_column' => TableColumn,
|
129
|
+
'tab_pane' => TabPane,
|
130
|
+
'text_area' => TextArea,
|
131
|
+
'text_field' => TextField,
|
132
|
+
'titled_pane' => TitledPane,
|
133
|
+
'toggle_button' => ToggleButton,
|
134
|
+
'toggle_group' => ToggleGroup,
|
135
|
+
'tool_bar' => ToolBar,
|
136
|
+
'tooltip' => Tooltip,
|
137
|
+
'tree_cell' => TreeCell,
|
138
|
+
'tree_item' => TreeItem,
|
139
|
+
'tree_view' => TreeView,
|
140
|
+
'content_display' => ContentDisplay,
|
141
|
+
'overrun_style' => OverrunStyle,
|
142
|
+
'selection_mode' => SelectionMode,
|
143
|
+
'blend' => Blend,
|
144
|
+
'blend_mode' => BlendMode,
|
145
|
+
'bloom' => Bloom,
|
146
|
+
'blur_type' => BlurType,
|
147
|
+
'box_blur' => BoxBlur,
|
148
|
+
'color_adjust' => ColorAdjust,
|
149
|
+
'color_input' => ColorInput,
|
150
|
+
'displacement_map' => DisplacementMap,
|
151
|
+
'drop_shadow' => DropShadow,
|
152
|
+
'gaussian_blur' => GaussianBlur,
|
153
|
+
'glow' => Glow,
|
154
|
+
'image_input' => ImageInput,
|
155
|
+
'inner_shadow' => InnerShadow,
|
156
|
+
'lighting' => Lighting,
|
157
|
+
'motion_blur' => MotionBlur,
|
158
|
+
'perspective_transform' => PerspectiveTransform,
|
159
|
+
'reflection' => Reflection,
|
160
|
+
'sepia_tone' => SepiaTone,
|
161
|
+
'shadow' => Shadow,
|
162
|
+
'image' => Image,
|
163
|
+
'image_view' => ImageView,
|
164
|
+
'pixel_reader' => PixelReader,
|
165
|
+
'pixel_writer' => PixelWriter,
|
166
|
+
'clipboard' => Clipboard,
|
167
|
+
'clipboard_content' => ClipboardContent,
|
168
|
+
'context_menu_event' => ContextMenuEvent,
|
169
|
+
'drag_event' => DragEvent,
|
170
|
+
'gesture_event' => GestureEvent,
|
171
|
+
'input_event' => InputEvent,
|
172
|
+
'input_method_event' => InputMethodEvent,
|
173
|
+
'key_code' => KeyCode,
|
174
|
+
'key_event' => KeyEvent,
|
175
|
+
'mnemonic' => Mnemonic,
|
176
|
+
'mouse_drag_event' => MouseDragEvent,
|
177
|
+
'mouse_event' => MouseEvent,
|
178
|
+
'rotate_event' => RotateEvent,
|
179
|
+
'scroll_event' => ScrollEvent,
|
180
|
+
'swipe_event' => SwipeEvent,
|
181
|
+
'touch_event' => TouchEvent,
|
182
|
+
'transfer_mode' => TransferMode,
|
183
|
+
'zoom_event' => ZoomEvent,
|
184
|
+
'anchor_pane' => AnchorPane,
|
185
|
+
'border_pane' => BorderPane,
|
186
|
+
'column_constraints' => ColumnConstraints,
|
187
|
+
'flow_pane' => FlowPane,
|
188
|
+
'grid_pane' => GridPane,
|
189
|
+
'hbox' => HBox,
|
190
|
+
'pane' => Pane,
|
191
|
+
'priority' => Priority,
|
192
|
+
'row_constraints' => RowConstraints,
|
193
|
+
'stack_pane' => StackPane,
|
194
|
+
'tile_pane' => TilePane,
|
195
|
+
'vbox' => VBox,
|
196
|
+
'audio_clip' => AudioClip,
|
197
|
+
'audio_equalizer' => AudioEqualizer,
|
198
|
+
'audio_track' => AudioTrack,
|
199
|
+
'equalizer_band' => EqualizerBand,
|
200
|
+
'media' => Media,
|
201
|
+
'media_exception' => MediaException,
|
202
|
+
'media_error_event' => MediaErrorEvent,
|
203
|
+
'media_marker_event' => MediaMarkerEvent,
|
204
|
+
'media_player' => MediaPlayer,
|
205
|
+
'media_view' => MediaView,
|
206
|
+
'video_track' => VideoTrack,
|
207
|
+
'color' => Color,
|
208
|
+
'cycle_method' => CycleMethod,
|
209
|
+
'image_pattern' => ImagePattern,
|
210
|
+
'linear_gradient' => LinearGradient,
|
211
|
+
'paint' => Paint,
|
212
|
+
'radial_gradient' => RadialGradient,
|
213
|
+
'stop' => Stop,
|
214
|
+
'arc' => Arc,
|
215
|
+
'arc_to' => ArcTo,
|
216
|
+
'arc_type' => ArcType,
|
217
|
+
'circle' => Circle,
|
218
|
+
'close_path' => ClosePath,
|
219
|
+
'cubic_curve' => CubicCurve,
|
220
|
+
'cubic_curve_to' => CubicCurveTo,
|
221
|
+
'ellipse' => Ellipse,
|
222
|
+
'fill_rule' => FillRule,
|
223
|
+
'hline_to' => HLineTo,
|
224
|
+
'line' => Line,
|
225
|
+
'line_to' => LineTo,
|
226
|
+
'move_to' => MoveTo,
|
227
|
+
'path' => Path,
|
228
|
+
'path_element' => PathElement,
|
229
|
+
'polygon' => Polygon,
|
230
|
+
'polyline' => Polyline,
|
231
|
+
'quad_curve' => QuadCurve,
|
232
|
+
'quad_curve_to' => QuadCurveTo,
|
233
|
+
'rectangle' => Rectangle,
|
234
|
+
'shape' => Shape,
|
235
|
+
'stroke_line_cap' => StrokeLineCap,
|
236
|
+
'stroke_line_join' => StrokeLineJoin,
|
237
|
+
'stroke_type' => StrokeType,
|
238
|
+
'svg_path' => SVGPath,
|
239
|
+
'vline_to' => VLineTo,
|
240
|
+
'font' => Font,
|
241
|
+
'font_posture' => FontPosture,
|
242
|
+
'font_smoothing_type' => FontSmoothingType,
|
243
|
+
'font_weight' => FontWeight,
|
244
|
+
'text' => Text,
|
245
|
+
'text_alignment' => TextAlignment,
|
246
|
+
'text_bounds_type' => TextBoundsType,
|
247
|
+
'affine' => Affine,
|
248
|
+
'rotate' => Rotate,
|
249
|
+
'scale' => Scale,
|
250
|
+
'shear' => Shear,
|
251
|
+
'translate' => Translate,
|
252
|
+
'web_view' => WebView,
|
253
|
+
'html_editor' => HTMLEditor,
|
254
|
+
'directory_chooser' => DirectoryChooser,
|
255
|
+
'file_chooser' => FileChooser,
|
256
|
+
'modality' => Modality,
|
257
|
+
'popup' => Popup,
|
258
|
+
'popup_window' => PopupWindow,
|
259
|
+
'screen' => Screen,
|
260
|
+
'stage' => Stage,
|
261
|
+
'stage_style' => StageStyle,
|
262
|
+
'window' => Window,
|
263
|
+
'window_event' => WindowEvent,
|
264
|
+
'duration' => Duration,
|
265
|
+
}
|
266
|
+
end
|
267
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
|
18
|
+
require_relative 'utils'
|
19
|
+
|
20
|
+
# Update load path to include the JavaFX runtime and fail nicely if we can't find it
|
21
|
+
begin
|
22
|
+
if ENV['JFX_DIR']
|
23
|
+
$LOAD_PATH << ENV['JFX_DIR']
|
24
|
+
else #should we check for 1.7 vs 1.8? oh well, adding extra paths won't hurt anybody (maybe performance loading)
|
25
|
+
jfx_path = ENV_JAVA["sun.boot.library.path"]
|
26
|
+
$LOAD_PATH << if jfx_path.include? ":\\" and !jfx_path.include? "/" # can be tricked, but should work fine
|
27
|
+
#windows
|
28
|
+
jfx_path.gsub(/\\bin[\\]*$/i, "\\lib")
|
29
|
+
else
|
30
|
+
# *nix
|
31
|
+
jfx_path.gsub(/[\/\\][amdix345678_]+$/, "") # strip i386 or amd64 (including variants). TODO: ARM
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Java 8 (after ea-b75) and above has JavaFX as part of the normal distib, only require it if we are 7 or below
|
36
|
+
jre = ENV_JAVA["java.runtime.version"].match %r{^(?<version>(?<major>\d+)\.(?<minor>\d+))\.(?<patch>\d+)(_\d+)?-?(?<release>ea|u\d)?(-?b(?<build>\d+))?}
|
37
|
+
require 'jfxrt.jar' if ENV['JFX_DIR'] or
|
38
|
+
jre[:version].to_f < 1.8 or
|
39
|
+
(jre[:version].to_f == 1.8 and jre[:release] == 'ea' and jre[:build].to_i < 75)
|
40
|
+
|
41
|
+
# Attempt to load a javafx class
|
42
|
+
Java.javafx.application.Application
|
43
|
+
rescue LoadError, NameError
|
44
|
+
puts "JavaFX runtime not found. Please install Java 7u6 or newer or set environment variable JFX_DIR to the folder that contains jfxrt.jar "
|
45
|
+
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)"
|
46
|
+
exit -1
|
47
|
+
end
|
48
|
+
|
49
|
+
module JRubyFX
|
50
|
+
# If you need JavaFX, just include this module. Its sole purpose in life is to
|
51
|
+
# import all JavaFX stuff, plus a few useful Java classes (like Void)
|
52
|
+
module FXImports
|
53
|
+
|
54
|
+
# If something is missing, just java_import it in your code.
|
55
|
+
# And then ask us to put it in this list
|
56
|
+
#
|
57
|
+
|
58
|
+
# The below lines are generated by `rake reflect`. Do not edit.
|
59
|
+
|
60
|
+
java_import 'javafx.animation.Animation','javafx.animation.AnimationTimer','javafx.animation.FadeTransition','javafx.animation.FillTransition','javafx.animation.Interpolator','javafx.animation.KeyFrame','javafx.animation.KeyValue','javafx.animation.ParallelTransition','javafx.animation.PathTransition','javafx.animation.PauseTransition','javafx.animation.RotateTransition','javafx.animation.ScaleTransition','javafx.animation.SequentialTransition','javafx.animation.StrokeTransition','javafx.animation.Timeline','javafx.animation.Transition','javafx.animation.TranslateTransition','javafx.application.Platform','javafx.beans.property.SimpleBooleanProperty','javafx.beans.property.SimpleDoubleProperty','javafx.beans.property.SimpleFloatProperty','javafx.beans.property.SimpleIntegerProperty','javafx.beans.property.SimpleListProperty','javafx.beans.property.SimpleLongProperty','javafx.beans.property.SimpleMapProperty','javafx.beans.property.SimpleObjectProperty','javafx.beans.property.SimpleSetProperty','javafx.beans.property.SimpleStringProperty','javafx.beans.value.ChangeListener','javafx.collections.FXCollections','javafx.event.Event','javafx.event.ActionEvent','javafx.event.EventHandler','javafx.fxml.Initializable','javafx.fxml.LoadException','javafx.geometry.HorizontalDirection','javafx.geometry.HPos','javafx.geometry.Insets','javafx.geometry.Orientation','javafx.geometry.Pos','javafx.geometry.Rectangle2D','javafx.geometry.Side','javafx.geometry.VerticalDirection','javafx.geometry.VPos','javafx.scene.Group','javafx.scene.Node','javafx.scene.Parent','javafx.scene.Scene','javafx.scene.canvas.Canvas','javafx.scene.chart.AreaChart','javafx.scene.chart.Axis','javafx.scene.chart.BarChart','javafx.scene.chart.BubbleChart','javafx.scene.chart.CategoryAxis','javafx.scene.chart.Chart','javafx.scene.chart.LineChart','javafx.scene.chart.NumberAxis','javafx.scene.chart.PieChart','javafx.scene.chart.ScatterChart','javafx.scene.chart.StackedAreaChart','javafx.scene.chart.StackedBarChart','javafx.scene.chart.ValueAxis','javafx.scene.chart.XYChart','javafx.scene.control.Accordion','javafx.scene.control.Button','javafx.scene.control.Cell','javafx.scene.control.CheckBox','javafx.scene.control.CheckBoxTreeItem','javafx.scene.control.CheckMenuItem','javafx.scene.control.ChoiceBox','javafx.scene.control.ColorPicker','javafx.scene.control.ComboBox','javafx.scene.control.ContextMenu','javafx.scene.control.Hyperlink','javafx.scene.control.Label','javafx.scene.control.ListCell','javafx.scene.control.ListView','javafx.scene.control.Menu','javafx.scene.control.MenuBar','javafx.scene.control.MenuButton','javafx.scene.control.MenuItem','javafx.scene.control.Pagination','javafx.scene.control.PasswordField','javafx.scene.control.PopupControl','javafx.scene.control.ProgressBar','javafx.scene.control.ProgressIndicator','javafx.scene.control.RadioButton','javafx.scene.control.RadioMenuItem','javafx.scene.control.ScrollBar','javafx.scene.control.ScrollPane','javafx.scene.control.Separator','javafx.scene.control.SeparatorMenuItem','javafx.scene.control.Slider','javafx.scene.control.SplitMenuButton','javafx.scene.control.SplitPane','javafx.scene.control.Tab','javafx.scene.control.TableView','javafx.scene.control.TableCell','javafx.scene.control.TableColumn','javafx.scene.control.TabPane','javafx.scene.control.TextArea','javafx.scene.control.TextField','javafx.scene.control.TitledPane','javafx.scene.control.ToggleButton','javafx.scene.control.ToggleGroup','javafx.scene.control.ToolBar','javafx.scene.control.Tooltip','javafx.scene.control.TreeCell','javafx.scene.control.TreeItem','javafx.scene.control.TreeView','javafx.scene.control.ContentDisplay','javafx.scene.control.OverrunStyle','javafx.scene.control.SelectionMode','javafx.scene.effect.Blend','javafx.scene.effect.BlendMode','javafx.scene.effect.Bloom','javafx.scene.effect.BlurType','javafx.scene.effect.BoxBlur','javafx.scene.effect.ColorAdjust','javafx.scene.effect.ColorInput','javafx.scene.effect.DisplacementMap','javafx.scene.effect.DropShadow','javafx.scene.effect.GaussianBlur','javafx.scene.effect.Glow','javafx.scene.effect.ImageInput','javafx.scene.effect.InnerShadow','javafx.scene.effect.Lighting','javafx.scene.effect.MotionBlur','javafx.scene.effect.PerspectiveTransform','javafx.scene.effect.Reflection','javafx.scene.effect.SepiaTone','javafx.scene.effect.Shadow','javafx.scene.image.Image','javafx.scene.image.ImageView','javafx.scene.image.PixelReader','javafx.scene.image.PixelWriter','javafx.scene.input.Clipboard','javafx.scene.input.ClipboardContent','javafx.scene.input.ContextMenuEvent','javafx.scene.input.DragEvent','javafx.scene.input.GestureEvent','javafx.scene.input.InputEvent','javafx.scene.input.InputMethodEvent','javafx.scene.input.KeyCode','javafx.scene.input.KeyEvent','javafx.scene.input.Mnemonic','javafx.scene.input.MouseDragEvent','javafx.scene.input.MouseEvent','javafx.scene.input.RotateEvent','javafx.scene.input.ScrollEvent','javafx.scene.input.SwipeEvent','javafx.scene.input.TouchEvent','javafx.scene.input.TransferMode','javafx.scene.input.ZoomEvent','javafx.scene.layout.AnchorPane','javafx.scene.layout.BorderPane','javafx.scene.layout.ColumnConstraints','javafx.scene.layout.FlowPane','javafx.scene.layout.GridPane','javafx.scene.layout.HBox','javafx.scene.layout.Pane','javafx.scene.layout.Priority','javafx.scene.layout.RowConstraints','javafx.scene.layout.StackPane','javafx.scene.layout.TilePane','javafx.scene.layout.VBox','javafx.scene.media.AudioClip','javafx.scene.media.AudioEqualizer','javafx.scene.media.AudioTrack','javafx.scene.media.EqualizerBand','javafx.scene.media.Media','javafx.scene.media.MediaException','javafx.scene.media.MediaErrorEvent','javafx.scene.media.MediaMarkerEvent','javafx.scene.media.MediaPlayer','javafx.scene.media.MediaView','javafx.scene.media.VideoTrack','javafx.scene.paint.Color','javafx.scene.paint.CycleMethod','javafx.scene.paint.ImagePattern','javafx.scene.paint.LinearGradient','javafx.scene.paint.Paint','javafx.scene.paint.RadialGradient','javafx.scene.paint.Stop','javafx.scene.shape.Arc','javafx.scene.shape.ArcTo','javafx.scene.shape.ArcType','javafx.scene.shape.Circle','javafx.scene.shape.ClosePath','javafx.scene.shape.CubicCurve','javafx.scene.shape.CubicCurveTo','javafx.scene.shape.Ellipse','javafx.scene.shape.FillRule','javafx.scene.shape.HLineTo','javafx.scene.shape.Line','javafx.scene.shape.LineTo','javafx.scene.shape.MoveTo','javafx.scene.shape.Path','javafx.scene.shape.PathElement','javafx.scene.shape.Polygon','javafx.scene.shape.Polyline','javafx.scene.shape.QuadCurve','javafx.scene.shape.QuadCurveTo','javafx.scene.shape.Rectangle','javafx.scene.shape.Shape','javafx.scene.shape.StrokeLineCap','javafx.scene.shape.StrokeLineJoin','javafx.scene.shape.StrokeType','javafx.scene.shape.SVGPath','javafx.scene.shape.VLineTo','javafx.scene.text.Font','javafx.scene.text.FontPosture','javafx.scene.text.FontSmoothingType','javafx.scene.text.FontWeight','javafx.scene.text.Text','javafx.scene.text.TextAlignment','javafx.scene.text.TextBoundsType','javafx.scene.transform.Affine','javafx.scene.transform.Rotate','javafx.scene.transform.Scale','javafx.scene.transform.Shear','javafx.scene.transform.Translate','javafx.scene.web.WebView','javafx.scene.web.HTMLEditor','javafx.stage.DirectoryChooser','javafx.stage.FileChooser','javafx.stage.Modality','javafx.stage.Popup','javafx.stage.PopupWindow','javafx.stage.Screen','javafx.stage.Stage','javafx.stage.StageStyle','javafx.stage.Window','javafx.stage.WindowEvent','javafx.util.Duration'
|
61
|
+
java_import 'java.lang.Void'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
data/lib/jrubyfx/java_fx_impl.rb
CHANGED
@@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
|
|
15
15
|
limitations under the License.
|
16
16
|
=end
|
17
17
|
#:nodoc: all
|
18
|
-
require 'jrubyfx'
|
19
18
|
|
20
19
|
# Due to certain bugs in JRuby 1.7 (namely some newInstance mapping bugs), we
|
21
20
|
# are forced to re-create the Launcher if we want a pure ruby wrapper
|
@@ -0,0 +1,172 @@
|
|
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
|
+
|
18
|
+
require_relative 'utils/common_utils'
|
19
|
+
|
20
|
+
# This module contains useful methods for defining JavaFX code. Include it in your
|
21
|
+
# class to use it, and the JRubyFX::FXImports. JRubyFX::Application and JRubyFX::Controller already include it.
|
22
|
+
module JRubyFX
|
23
|
+
include JRubyFX::FXImports
|
24
|
+
include JRubyFX::Utils::CommonUtils
|
25
|
+
|
26
|
+
##
|
27
|
+
# call-seq:
|
28
|
+
# with(obj, hash) => obj
|
29
|
+
# with(obj) { block } => obj
|
30
|
+
# with(obj, hash) { block }=> obj
|
31
|
+
#
|
32
|
+
# Set properties (e.g. setters) on the passed in object plus also invoke
|
33
|
+
# any block passed against this object.
|
34
|
+
# === Examples
|
35
|
+
#
|
36
|
+
# with(grid, vgap: 2, hgap: 2) do
|
37
|
+
# set_pref_size(500, 400)
|
38
|
+
# children << location << go << view
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
def with(obj, properties = {}, &block)
|
42
|
+
populate_properties(obj, properties)
|
43
|
+
|
44
|
+
if block_given?
|
45
|
+
# cache the proxy - http://wiki.jruby.org/Persistence
|
46
|
+
obj.class.__persistent__ = true if obj.class.ancestors.include? JavaProxy
|
47
|
+
obj.extend(JRubyFX)
|
48
|
+
obj.instance_eval(&block)
|
49
|
+
end
|
50
|
+
|
51
|
+
obj
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# call-seq:
|
56
|
+
# run_later { block }
|
57
|
+
#
|
58
|
+
# Convenience method so anything can safely schedule to run on JavaFX
|
59
|
+
# main thread.
|
60
|
+
def run_later(&block)
|
61
|
+
Platform.run_later &block
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# call-seq:
|
66
|
+
# build(class) => obj
|
67
|
+
# build(class, hash) => obj
|
68
|
+
# build(class) { block } => obj
|
69
|
+
# build(class, hash) { block } => obj
|
70
|
+
#
|
71
|
+
# Create "build" a new JavaFX instance with the provided class and
|
72
|
+
# set properties (e.g. setters) on that new instance plus also invoke
|
73
|
+
# any block passed against this new instance. This also can build a proc
|
74
|
+
# or lambda form in which case the return value of the block will be what
|
75
|
+
# is used to set the additional properties on.
|
76
|
+
# === Examples
|
77
|
+
#
|
78
|
+
# grid = build(GridPane, vgap: 2, hgap: 2) do
|
79
|
+
# set_pref_size(500, 400)
|
80
|
+
# children << location << go << view
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# build(proc { Foo.new }, vgap: 2, hgap: 2)
|
84
|
+
#
|
85
|
+
def build(klass, *args, &block)
|
86
|
+
args, properties = split_args_from_properties(*args)
|
87
|
+
|
88
|
+
obj = if klass.kind_of? Proc
|
89
|
+
klass.call(*args)
|
90
|
+
else
|
91
|
+
klass.new(*attempt_conversion(klass, :new, *args))
|
92
|
+
end
|
93
|
+
|
94
|
+
with(obj, properties, &block)
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.included(mod)
|
98
|
+
mod.extend(JRubyFX::FXMLClassUtils)
|
99
|
+
end
|
100
|
+
|
101
|
+
module FXMLClassUtils
|
102
|
+
def fxml_raw_accessor(symbol_name, type=java::lang::String)
|
103
|
+
# TODO: RDoc
|
104
|
+
# TODO: somebody clean this up
|
105
|
+
# TODO: _reader and _writer
|
106
|
+
send(:define_method, symbol_name.id2name.snake_case + "=") do |val|
|
107
|
+
instance_variable_set("@#{symbol_name}", val)
|
108
|
+
end
|
109
|
+
send(:define_method, symbol_name.id2name.snake_case) do
|
110
|
+
instance_variable_get("@#{symbol_name}")
|
111
|
+
end
|
112
|
+
send(:define_method, symbol_name.id2name.snake_case + "GetType") do
|
113
|
+
return type.java_class
|
114
|
+
end
|
115
|
+
camel = symbol_name.id2name
|
116
|
+
camel = camel[0].upcase + camel[1..-1]
|
117
|
+
send(:define_method, "set" + camel) do |val|
|
118
|
+
instance_variable_set("@#{symbol_name}", val)
|
119
|
+
end
|
120
|
+
send(:define_method, "get" + camel) do
|
121
|
+
instance_variable_get("@#{symbol_name}")
|
122
|
+
end
|
123
|
+
send(:define_method, symbol_name.id2name + "GetType") do
|
124
|
+
return type.java_class
|
125
|
+
end
|
126
|
+
end
|
127
|
+
def fxml_accessor(symbol_name,ptype=Java::javafx.beans.property.SimpleStringProperty, type=nil)
|
128
|
+
# TODO: RDoc
|
129
|
+
# TODO: somebody clean this up
|
130
|
+
# TODO: _reader and _writer ? maybe? not?
|
131
|
+
pname = symbol_name.id2name + "Property"
|
132
|
+
unless type
|
133
|
+
type = ptype.java_class.java_instance_methods.find_all{|x|x.name == "getValue"}.map{|x|x.return_type}.find_all{|x|x != java.lang.Object.java_class}
|
134
|
+
if type.length != 1
|
135
|
+
raise "Unknown property type. Please manually supply a type or report this as a bug"
|
136
|
+
end
|
137
|
+
type = type[0]
|
138
|
+
else
|
139
|
+
type = type.java_class
|
140
|
+
end
|
141
|
+
send(:define_method, symbol_name.id2name.snake_case + "=") do |val|
|
142
|
+
send(pname).setValue val
|
143
|
+
end
|
144
|
+
send(:define_method, symbol_name.id2name.snake_case) do
|
145
|
+
send(pname).getValue
|
146
|
+
end
|
147
|
+
send(:define_method, symbol_name.id2name.snake_case + "GetType") do
|
148
|
+
return type
|
149
|
+
end
|
150
|
+
camel = symbol_name.id2name
|
151
|
+
camel = camel[0].upcase + camel[1..-1]
|
152
|
+
send(:define_method, "set" + camel) do |val|
|
153
|
+
send(pname).setValue val
|
154
|
+
end
|
155
|
+
send(:define_method, "get" + camel) do
|
156
|
+
send(pname).getValue
|
157
|
+
end
|
158
|
+
send(:define_method, symbol_name.id2name + "GetType") do
|
159
|
+
return type
|
160
|
+
end
|
161
|
+
send(:define_method, pname) do
|
162
|
+
unless instance_variable_get("@#{symbol_name}")
|
163
|
+
instance_variable_set("@#{symbol_name}", ptype.new(self, symbol_name.to_s))
|
164
|
+
end
|
165
|
+
return instance_variable_get("@#{symbol_name}")
|
166
|
+
end
|
167
|
+
add_method_signature pname, [ptype]
|
168
|
+
add_method_signature "set" + camel, [java.lang.Void, type]
|
169
|
+
add_method_signature "get" + camel, [type]
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|