limelight 0.2.1-java → 0.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/bin/ll.bat +1 -1
  2. data/lib/i4jruntime.jar +0 -0
  3. data/lib/junit-4.4.jar +0 -0
  4. data/lib/limelight.jar +0 -0
  5. data/lib/limelight/animation.rb +3 -3
  6. data/lib/limelight/builtin/players.rb +2 -1
  7. data/lib/limelight/builtin/players/combo_box.rb +8 -2
  8. data/lib/limelight/builtin/players/image.rb +47 -0
  9. data/lib/limelight/builtin/styles.rb +1 -1
  10. data/lib/limelight/casting_director.rb +70 -39
  11. data/lib/limelight/commands/command.rb +150 -0
  12. data/lib/limelight/commands/create_command.rb +79 -0
  13. data/lib/limelight/commands/freeze_command.rb +113 -0
  14. data/lib/limelight/commands/open_command.rb +49 -0
  15. data/lib/limelight/commands/pack_command.rb +45 -0
  16. data/lib/limelight/dsl/build_exception.rb +51 -0
  17. data/lib/limelight/dsl/menu_bar.rb +71 -0
  18. data/lib/limelight/dsl/production_builder.rb +71 -0
  19. data/lib/limelight/dsl/prop_builder.rb +155 -0
  20. data/lib/limelight/dsl/stage_builder.rb +105 -0
  21. data/lib/limelight/dsl/styles_builder.rb +134 -0
  22. data/lib/limelight/file_loader.rb +46 -0
  23. data/lib/limelight/gems.rb +45 -0
  24. data/lib/limelight/java_couplings.rb +7 -2
  25. data/lib/limelight/java_util.rb +2 -15
  26. data/lib/limelight/main.rb +7 -5
  27. data/lib/limelight/producer.rb +87 -66
  28. data/lib/limelight/production.rb +42 -4
  29. data/lib/limelight/prop.rb +84 -70
  30. data/lib/limelight/scene.rb +75 -20
  31. data/lib/limelight/specs/spec_helper.rb +58 -0
  32. data/lib/limelight/stage.rb +11 -6
  33. data/lib/limelight/string.rb +35 -0
  34. data/lib/limelight/studio.rb +29 -0
  35. data/lib/limelight/templates/production_templater.rb +42 -0
  36. data/lib/limelight/templates/scene_templater.rb +41 -0
  37. data/lib/limelight/templates/sources/freezing/limelight_init.rb.template +5 -0
  38. data/lib/limelight/templates/sources/production/init.rb.template +15 -0
  39. data/lib/limelight/templates/sources/production/production.rb.template +9 -0
  40. data/lib/limelight/templates/sources/production/stages.rb.template +17 -0
  41. data/lib/limelight/templates/sources/production/styles.rb.template +12 -0
  42. data/lib/limelight/templates/sources/scene/props.rb.template +6 -0
  43. data/lib/limelight/templates/sources/scene/styles.rb.template +18 -0
  44. data/lib/limelight/templates/templater.rb +128 -0
  45. data/lib/limelight/templates/templater_logger.rb +36 -0
  46. data/lib/limelight/theater.rb +21 -7
  47. data/lib/limelight/util.rb +22 -6
  48. data/lib/limelight/version.rb +2 -2
  49. data/productions/examples/8thlight.com/styles.rb +1 -1
  50. data/productions/examples/langstons_ant/html_javascript/ant.html +1 -1
  51. data/productions/examples/langstons_ant/init.rb +1 -0
  52. data/productions/examples/langstons_ant/players/log.rb +2 -2
  53. data/productions/examples/langstons_ant/players/world.rb +0 -26
  54. data/productions/examples/sandbox.llp +0 -0
  55. data/productions/examples/sandbox/click_me/players/chromaton.rb +10 -4
  56. data/productions/examples/sandbox/floaters/players/floater.rb +4 -2
  57. data/productions/examples/sandbox/gradients/players/spinner.rb +5 -1
  58. data/productions/examples/sandbox/gradients/players/teaser.rb +2 -2
  59. data/productions/examples/sandbox/gradients/players/wave.rb +2 -2
  60. data/productions/examples/sandbox/gradients/players/waves.rb +2 -2
  61. data/productions/examples/sandbox/header.rb +1 -0
  62. data/productions/examples/sandbox/images/logo.png +0 -0
  63. data/productions/examples/sandbox/images_scene/props.rb +25 -0
  64. data/productions/examples/sandbox/images_scene/styles.rb +30 -0
  65. data/productions/examples/sandbox/inputs/styles.rb +1 -1
  66. data/productions/examples/sandbox/scrolling/props.rb +12 -12
  67. data/productions/examples/sandbox/teaser/players/fader.rb +2 -8
  68. data/productions/stage_composer/inspector/styles.rb +2 -2
  69. data/productions/startup/styles.rb +2 -2
  70. data/spec/builtin/players/button_spec.rb +0 -1
  71. data/spec/builtin/players/image_spec.rb +41 -0
  72. data/spec/casting_director_spec.rb +114 -44
  73. data/spec/commands/command_spec.rb +18 -0
  74. data/spec/commands/create_command_spec.rb +74 -0
  75. data/spec/commands/freeze_command_spec.rb +59 -0
  76. data/spec/commands/open_command_spec.rb +30 -0
  77. data/spec/commands/pack_command_spec.rb +23 -0
  78. data/spec/dsl/production_builder_spec.rb +46 -0
  79. data/spec/{prop_builder_spec.rb → dsl/prop_builder_spec.rb} +80 -24
  80. data/spec/{stage_builder_spec.rb → dsl/stage_builder_spec.rb} +4 -4
  81. data/spec/{styles_builder_spec.rb → dsl/styles_builder_spec.rb} +6 -6
  82. data/spec/{loaders/file_loader_spec.rb → file_loader_spec.rb} +4 -4
  83. data/spec/gems_spec.rb +83 -0
  84. data/spec/java_util_spec.rb +1 -17
  85. data/spec/main_spec.rb +17 -0
  86. data/spec/producer_spec.rb +89 -79
  87. data/spec/production_spec.rb +28 -3
  88. data/spec/prop_spec.rb +82 -16
  89. data/spec/scene_spec.rb +73 -3
  90. data/spec/spec_helper.rb +37 -1
  91. data/spec/stage_spec.rb +10 -1
  92. data/spec/string_spec.rb +35 -0
  93. data/spec/studio_spec.rb +14 -0
  94. data/spec/styles_spec.rb +14 -0
  95. data/spec/templates/production_templater_spec.rb +44 -0
  96. data/spec/templates/scene_templater_spec.rb +25 -0
  97. data/spec/templates/templater_logger_spec.rb +38 -0
  98. data/spec/templates/templater_spec.rb +104 -0
  99. data/spec/theater_spec.rb +12 -21
  100. metadata +75 -23
  101. data/bin/icons/splash.png +0 -0
  102. data/lib/limelight/build_exception.rb +0 -48
  103. data/lib/limelight/commands.rb +0 -52
  104. data/lib/limelight/loaders/file_scene_loader.rb +0 -49
  105. data/lib/limelight/menu_bar.rb +0 -68
  106. data/lib/limelight/production_builder.rb +0 -66
  107. data/lib/limelight/prop_builder.rb +0 -119
  108. data/lib/limelight/stage_builder.rb +0 -103
  109. data/lib/limelight/styles_builder.rb +0 -131
  110. data/spec/commands_spec.rb +0 -34
  111. data/spec/production_builder_spec.rb +0 -48
data/bin/ll.bat CHANGED
@@ -1,4 +1,4 @@
1
- set LIMELIGHT_HOME=Y:\Projects\limelight
1
+ set LIMELIGHT_HOME=Z:\Projects\limelight
2
2
 
3
3
  java -cp lib\limelight.jar;jruby\lib\jruby.jar %JAVA_OPTS% -Dlimelight.home=%LIMELIGHT_HOME% limelight.Main %1 %2 %3 %4 %5
4
4
 
Binary file
data/lib/junit-4.4.jar ADDED
Binary file
data/lib/limelight.jar CHANGED
Binary file
@@ -9,7 +9,7 @@ module Limelight
9
9
  # Although, this object does not update the screen, it provides a means to perform sequential updates in evenly
10
10
  # spaced time frames.
11
11
  #
12
- class Animation < Limelight::AnimationTask
12
+ class Animation < Limelight::Background::Animation
13
13
 
14
14
  # A Prop and block are required to construct an Animation. Options may include :name (string), :updates_per_second
15
15
  # (int defaults to 60)
@@ -23,10 +23,10 @@ module Limelight
23
23
  @block = block
24
24
  name = options[:name] || "#{prop.to_s} animation"
25
25
  updates_per_second = options[:updates_per_second] || 60
26
- super(name, updates_per_second, prop.panel)
26
+ super(updates_per_second)
27
27
  end
28
28
 
29
- def doPerform #:nodoc:
29
+ def doUpdate #:nodoc:
30
30
  @block.call
31
31
  end
32
32
 
@@ -9,4 +9,5 @@ require 'limelight/builtin/players/text_area'
9
9
  require 'limelight/builtin/players/text_box'
10
10
  require 'limelight/builtin/players/combo_box_popup_list_item'
11
11
  require 'limelight/builtin/players/combo_box_popup_list'
12
- require 'limelight/builtin/players/curtains'
12
+ require 'limelight/builtin/players/curtains'
13
+ require 'limelight/builtin/players/image'
@@ -29,10 +29,16 @@ module Limelight
29
29
  combo_box = Limelight::UI::Model::Inputs::ComboBoxPanel.new
30
30
  prop.panel.add(combo_box)
31
31
  prop.combo_box = combo_box.combo_box
32
+ prop.clear
32
33
  end
33
34
  end
34
35
 
35
36
  attr_accessor :combo_box #:nodoc:
37
+ attr_reader :choices
38
+
39
+ def clear #:nodoc:
40
+ @choices = []
41
+ end
36
42
 
37
43
  # Sets the choices listed in the combo_box. The value parameter should an Array or a String that
38
44
  # can be evalulated into an Array. All choices in a combo_box are strings.
@@ -43,7 +49,7 @@ module Limelight
43
49
  def choices=(value)
44
50
  value = eval(value) if value.is_a? String
45
51
  raise "Invalid choices type: #{value.class}. Choices have to be an array." if !value.is_a?(Array)
46
- @values = value
52
+ @choices = value
47
53
  combo_box.remove_all_items
48
54
  value.each { |choice| combo_box.add_item(choice) }
49
55
  end
@@ -69,7 +75,7 @@ module Limelight
69
75
  popup_style.y = panel.absolute_location.y.to_s
70
76
  popup_style.width = panel.width.to_s
71
77
 
72
- @values.each do |value|
78
+ @choices.each do |value|
73
79
  popup_list.add(Limelight::Prop.new(:name => "limelight_builtin_players_combo_box_popup_list_item", :text => value, :players => "combo_box_popup_list_item", :combo_box => self))
74
80
  end
75
81
 
@@ -0,0 +1,47 @@
1
+ module Limelight
2
+ module Builtin
3
+ module Players
4
+
5
+ module Image
6
+
7
+ class << self
8
+
9
+ def extended(prop) #:nodoc:
10
+ image_panel = Limelight::UI::Model::ImagePanel.new
11
+ prop.panel.add(image_panel)
12
+ prop.image_panel = image_panel
13
+ end
14
+
15
+ end
16
+
17
+ attr_accessor :image_panel #:nodoc:
18
+
19
+ def image=(path)
20
+ image_panel.image_file = path
21
+ end
22
+
23
+ def image
24
+ return image_panel.image_file
25
+ end
26
+
27
+ def rotation=(value)
28
+ image_panel.rotation = value.to_f
29
+ end
30
+
31
+ def rotation
32
+ return image_panel.rotation
33
+ end
34
+
35
+ def scaled=(value)
36
+ image_panel.scaled = value
37
+ end
38
+
39
+ def scaled?
40
+ return image_panel.scaled
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -16,7 +16,7 @@ limelight_builtin_players_combo_box_popup_list {
16
16
  rounded_corner_radius 5
17
17
  border_width 1
18
18
  border_color "#dcdcdc"
19
- vertical_scroll_bar :on
19
+ vertical_scrollbar :on
20
20
  min_height 50
21
21
  max_height 200
22
22
  }
@@ -11,70 +11,101 @@ module Limelight
11
11
  # Users of Limelight need not be concerned with this class.
12
12
  #
13
13
  class CastingDirector
14
-
14
+
15
15
  def initialize(loader)
16
16
  @loader = loader
17
17
  @known_players = {}
18
18
  end
19
-
19
+
20
20
  def fill_cast(prop)
21
+ raise LimelightException.new("Cannot cast a Prop without a Scene.") if prop.scene.nil?
21
22
  cast_default_player(prop)
22
23
  cast_additional_players(prop)
23
24
  end
24
-
25
+
25
26
  private ###############################################
26
-
27
+
27
28
  def cast_default_player(prop)
28
29
  return if prop.name.nil? || prop.name.empty?
29
- prop.include_player(@known_players[prop.name]) if player_exists?(prop, prop.name)
30
+ cast_player(prop, prop.name)
30
31
  end
31
-
32
+
32
33
  def cast_additional_players(prop)
33
34
  return if prop.players.nil? || prop.players.empty?
34
35
  player_names = prop.players.split(/[ ,]/)
35
36
  player_names.each do |player_name|
36
- apply_player(prop, player_name)
37
+ cast_player(prop, player_name)
37
38
  end
38
39
  end
39
-
40
- def apply_player(prop, player_name)
41
- prop.include_player(@known_players[player_name]) if player_exists?(prop, player_name)
40
+
41
+ def cast_player(prop, player_name)
42
+ recruiter = Recruiter.new(prop, player_name, @loader)
43
+ prop.include_player(recruiter.player) if recruiter.player_exists?
44
+ end
45
+ end
46
+
47
+ class Recruiter
48
+
49
+ def initialize(prop, player_name, loader)
50
+ @prop = prop
51
+ @cast = prop.scene.cast
52
+ @player_name = player_name
53
+ @module_name = player_name.camalized
54
+ @loader = loader
55
+ end
56
+
57
+ def player
58
+ return @cast.const_get(@module_name)
59
+ end
60
+
61
+ def player_already_exists?
62
+ return @cast.const_defined?(@module_name)
42
63
  end
43
-
44
- def player_exists?(prop, player_name)
45
- load_player_by_name(prop, player_name) if !@known_players.has_key?(player_name)
46
- return @known_players[player_name] != :does_not_exist
64
+
65
+ def player_exists?
66
+ recruit_player if !player_already_exists?
67
+ return @cast.const_get(@module_name) != :does_not_exist
47
68
  end
48
-
49
- def load_player_by_name(prop, player_name)
50
- load_custom_player(prop, player_name)
51
- load_builtin_player(player_name) if !@known_players.has_key?(player_name)
52
- @known_players[player_name] = :does_not_exist if !@known_players.has_key?(player_name)
69
+
70
+ def recruit_player
71
+ recruit_custom_player
72
+ recruit_builtin_player if !player_already_exists?
73
+ @cast.const_set(@module_name, :does_not_exist) if !player_already_exists?
53
74
  end
54
-
55
- def load_custom_player(prop, player_name)
56
- player_filename = File.join([prop.scene.path.to_s, "players", "#{player_name}.rb"])
57
- return if !@loader.exists?(player_filename)
58
-
59
- Kernel.load @loader.path_to(player_filename)
60
-
61
- module_name = player_name.camalized
62
- return if !Object.const_defined?(module_name)
63
-
64
- mod = Object.const_get(module_name)
65
- @known_players[player_name] = mod
75
+
76
+ def recruit_custom_player
77
+ player_filename = locate_player
78
+ load_player(player_filename) if player_filename
66
79
  end
67
-
68
- def load_builtin_player(player_name)
80
+
81
+ def recruit_builtin_player
69
82
  begin
70
- module_name = player_name.camalized
71
- return if !Limelight::Builtin::Players.const_defined?(module_name)
72
- mod = Limelight::Builtin::Players.const_get(module_name)
73
- @known_players[player_name] = mod
83
+ return if !Limelight::Builtin::Players.const_defined?(@module_name)
84
+ @cast.const_set(@module_name, Limelight::Builtin::Players.const_get(@module_name))
74
85
  rescue NameError
75
86
  end
76
87
  end
77
-
88
+
89
+ private ###############################################
90
+
91
+ def locate_player
92
+ player_filename = File.join(@prop.scene.path.to_s, "players", "#{@player_name}.rb")
93
+ if !@loader.exists?(player_filename)
94
+ if @prop.scene.production && @prop.scene.path != @prop.scene.production.path
95
+ player_filename = File.join(@prop.scene.production.path.to_s, "players", "#{@player_name}.rb")
96
+ return nil if !@loader.exists?(player_filename)
97
+ else
98
+ return nil
99
+ end
100
+ end
101
+ return player_filename
102
+ end
103
+
104
+ def load_player(player_filename)
105
+ src = IO.read(@loader.path_to(player_filename))
106
+ @cast.module_eval(src, player_filename)
107
+ end
108
+
78
109
  end
79
-
110
+
80
111
  end
@@ -0,0 +1,150 @@
1
+ require 'optparse'
2
+
3
+ module Limelight
4
+ module Commands
5
+
6
+ LISTING = {}
7
+
8
+ class << self
9
+
10
+ def [](name)
11
+ load_listing if !@listing_loaded
12
+ return LISTING[name]
13
+ end
14
+
15
+ def load_listing
16
+ Dir.entries(File.dirname(__FILE__)).each do |file|
17
+ if file != "." && file != ".."
18
+ require "limelight/commands/#{file.gsub('.rb', '')}"
19
+ end
20
+ end
21
+ @listing_loaded = true
22
+ end
23
+
24
+ end
25
+
26
+ # The base class for all limelight commands. The following is a list of them all.
27
+ #
28
+ # Usage: limelight <command> [options] [params]
29
+ # commands:
30
+ # create Creates the directories and files for a production and/or scene.
31
+ # freeze freeze a gem into a production.
32
+ # open Open a limelight production.
33
+ # pack Pack a limelight production into a .llp file.
34
+ #
35
+ class Command
36
+
37
+ class << self
38
+
39
+ attr_accessor :alias
40
+
41
+ # Sets the alias for the derivative command and installs it in the command listing. All derivative much
42
+ # call this method exactly once.
43
+ #
44
+ def install_as(name)
45
+ raise "Command already installed: #{name}." if LISTING[name]
46
+ self.alias = name
47
+ LISTING[name] = self
48
+ end
49
+
50
+ # Abstract class level methof that returns a string description of the command. Derivatives should
51
+ # override this class level method.
52
+ #
53
+ def description
54
+ return "Default Command description"
55
+ end
56
+
57
+ end
58
+
59
+ # Flag. The backtrace on parse errors will be printed if true.
60
+ #
61
+ attr_accessor :print_backtrace
62
+
63
+ # Runs the command. This is TemplateMethod. It will first parse the arguments, then require files, and finally
64
+ # process the command. Derivative should not override this method.
65
+ #
66
+ def run(args)
67
+ parse(args)
68
+ do_requires
69
+ begin
70
+ process if !@has_parse_error
71
+ rescue SystemExit
72
+ #okay
73
+ end
74
+ end
75
+
76
+ # Parse the arguments. All options will be parsed first, then parse_remainder will be called on
77
+ # remaining args. Derivative should not override this method.
78
+ #
79
+ def parse(args)
80
+ begin
81
+ remainder = options_spec.parse(args)
82
+ parse_remainder(remainder)
83
+ rescue SystemExit => e
84
+ raise e
85
+ rescue Exception => e
86
+ @has_parse_error = true
87
+ parse_error e
88
+ end
89
+ end
90
+
91
+ protected ###########################################
92
+
93
+ # Prints an exception that occurs while parsing the arguments. The usages summary will follow.
94
+ #
95
+ def parse_error(exception = nil)
96
+ if exception
97
+ puts ""
98
+ puts "!!! #{exception}"
99
+ puts exception.backtrace if @print_backtrace
100
+ end
101
+ usage
102
+ exit -1
103
+ end
104
+
105
+ # Prints the usage summary for a command.
106
+ #
107
+ def usage
108
+ puts ""
109
+ puts "Usage: limelight #{self.class.alias} #{parameter_description}"
110
+ puts " #{self.class.description}"
111
+ puts " options:"
112
+ puts options_spec.summarize
113
+ end
114
+
115
+ # Retreives the OptionParser instance for this command. It will create it if it doesn't exist.
116
+ #
117
+ def options_spec
118
+ if @options_spec.nil?
119
+ @options_spec = OptionParser.new
120
+ @options_spec.on("-h", "--help", "Prints this usage summary.") { usage; exit 0 }
121
+ build_options(@options_spec)
122
+ end
123
+ return @options_spec
124
+ end
125
+
126
+ # Abstract method to require any files needed for processing the command. Derivative should override this
127
+ # method if they need to require any files.
128
+ #
129
+ def do_requires
130
+ #override me
131
+ end
132
+
133
+ # Abstract method to define the command line options in the OptionParser. Derivative should override
134
+ # this method if they offer command line options
135
+ #
136
+ def build_options(spec)
137
+ #override me
138
+ end
139
+
140
+ # Abstract method to parse command line paramters. Parameter are those command line arguments listed after
141
+ # the options. Derivatives should override this method they take command line paramters.
142
+ #
143
+ def parse_remainder(args)
144
+ #override me
145
+ end
146
+
147
+ end
148
+
149
+ end
150
+ end
@@ -0,0 +1,79 @@
1
+ require 'limelight/commands/command'
2
+
3
+ module Limelight
4
+ module Commands
5
+
6
+ # See the following usages summary
7
+ #
8
+ # Usage: limelight create [options] <production|scene> <path>
9
+ # Creates the directories and files for a production and/or scene.
10
+ # options:
11
+ # -h, --help Prints this usage summary.
12
+ # -s, --scene=<name> Name of scene when creating a production. Defaults to 'default_scene'.
13
+ #
14
+ # Assume you wanted to create a new production named "love_story" containing two scenes, "midnight_romance" and
15
+ # "happily_ever_after". The following commands would created all the needed files.
16
+ #
17
+ # $ jruby -S limelight create -s midnight_romance production love_story
18
+ # $ jruby -S limelight create scene love_story/happily_ever_after
19
+ #
20
+ class CreateCommand < Command
21
+
22
+ install_as "create"
23
+
24
+ def self.description #:nodoc:
25
+ return "Creates the directories and files for a production and/or scene."
26
+ end
27
+
28
+ protected ###########################################
29
+
30
+ attr_reader :template_type, :path, :default_scene_name #:nodoc:
31
+
32
+ def initialize #:nodoc:
33
+ @default_scene_name = "default_scene"
34
+ @actions = {}
35
+ @actions["production"] = :create_production
36
+ @actions["scene"] = :create_scene
37
+ end
38
+
39
+ def process #:nodoc:
40
+ action = @actions[@template_type]
41
+ self.send action
42
+ end
43
+
44
+ def parameter_description #:nodoc:
45
+ return "[options] <production|scene> <path>"
46
+ end
47
+
48
+ def parse_remainder(args) #:nodoc:
49
+ @template_type = args.shift
50
+ raise "Missing template type" if @template_type.nil?
51
+ raise "Unknown template type: #{@template_type}" if @actions[@template_type].nil?
52
+ @path = args.shift
53
+ raise "Missing path parameter" if @path.nil?
54
+ end
55
+
56
+ def do_requires #:nodoc:
57
+ require 'limelight/templates/production_templater'
58
+ require 'limelight/templates/scene_templater'
59
+ end
60
+
61
+ def build_options(spec) #:nodoc:
62
+ spec.on("-s <name>", "--scene=<name>", "Name of scene when creating a production. Defaults to 'default_scene'.") { |value| @default_scene_name = value}
63
+ end
64
+
65
+ private #############################################
66
+
67
+ def create_production
68
+ Templates::ProductionTemplater.new(@path, @default_scene_name).generate
69
+ Templates::SceneTemplater.new("#{@path}/#{@default_scene_name}").generate
70
+ end
71
+
72
+ def create_scene
73
+ Templates::SceneTemplater.new(@path).generate
74
+ end
75
+
76
+ end
77
+
78
+ end
79
+ end