Module: Kernel

Defined in:
lib/jrubyfx/controller.rb

Overview

Special methods for fxml loading

Constant Summary collapse

@@jrubyfx_res_dir =
{}

Instance Method Summary collapse

Instance Method Details

#fxml_root(value = nil, jar_value = nil) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/jrubyfx/controller.rb', line 29

def fxml_root(value=nil, jar_value=nil)
  if value or jar_value
    @@jrubyfx_fxml_dir = JRubyFX::Application.in_jar? ? jar_value : File.expand_path(value)
  else
    @@jrubyfx_fxml_dir
  end
end

#resource_root(res_name, value = nil, jar_value = nil) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/jrubyfx/controller.rb', line 36

def resource_root(res_name, value=nil, jar_value=nil)
  if value or jar_value
    @@jrubyfx_res_dir[res_name.to_sym] = JRubyFX::Application.in_jar? ? jar_value : File.expand_path(value)
  else
    @@jrubyfx_res_dir[res_name.to_sym]
  end
end

#resource_url(type, relative_path) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/jrubyfx/controller.rb', line 43

def resource_url(type, relative_path)
  if JRubyFX::Application.in_jar?
    JRuby.runtime.jruby_class_loader.get_resource("#{resource_root(type)}/#{relative_path}");
  else
    java.net.URL.new("file:" + File.join(resource_root(type), relative_path))
  end
end