limelight 0.2.1-java → 0.3.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,58 @@
1
+ require 'spec'
2
+ require File.expand_path(File.dirname(__FILE__) + "/../../init")
3
+ require 'limelight/scene'
4
+ require 'limelight/producer'
5
+
6
+ $producer = nil
7
+ $with_ui = true
8
+
9
+ module Spec
10
+ module Example
11
+ class ExampleGroup
12
+
13
+ def self.uses_scene(scene_name)
14
+ before(:each) do
15
+ @scene = producer.open_scene(scene_name.to_s, producer.theater["default"])
16
+ end
17
+
18
+ attr_reader :scene
19
+ end
20
+
21
+ after(:suite) do
22
+ $producer.theater.stages.each { |stage| stage.close } unless $producer.nil?
23
+ end
24
+
25
+ def producer
26
+ if $producer.nil?
27
+ if $with_ui
28
+ Limelight::Main.initializeContext
29
+ else
30
+ Limelight::Main.initializeTestContext
31
+ end
32
+ $producer = Limelight::Producer.new($PRODUCTION_PATH)
33
+ $producer.load
34
+ end
35
+ return $producer
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+
42
+ if !$with_ui
43
+ module Limelight
44
+ module UI
45
+ module Model
46
+
47
+ class Frame
48
+
49
+ def open
50
+
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,9 +1,7 @@
1
1
  #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
- require 'limelight/java_util'
5
- require 'limelight/menu_bar'
6
- require 'limelight/loaders/file_scene_loader'
4
+ require 'limelight/dsl/menu_bar'
7
5
  require 'limelight/file_chooser'
8
6
  require 'limelight/util'
9
7
 
@@ -79,6 +77,7 @@ module Limelight
79
77
  # See load_scene
80
78
  #
81
79
  def open(scene)
80
+ scene.illuminate
82
81
  load_scene(scene)
83
82
  @frame.open
84
83
  scene.visible = true
@@ -98,9 +97,9 @@ module Limelight
98
97
  @frame.setJMenuBar(scene.menu_bar)
99
98
  @frame.load(scene.panel)
100
99
  scene.stage = self
101
- scene.panel.snap_to_size
100
+ # scene.panel.snap_to_size # What's this for?
102
101
  if(has_static_size?(scene.style))
103
- @frame.set_size(scene.panel.width + @frame.getHorizontalInsetWidth, scene.panel.height + @frame.getVerticalInsetWidth)
102
+ @frame.set_size(scene.style.compiled_width.value + @frame.getHorizontalInsetWidth, scene.style.compiled_height.value + @frame.getVerticalInsetWidth)
104
103
  end
105
104
  @current_scene = scene
106
105
  end
@@ -124,10 +123,16 @@ module Limelight
124
123
  frame.alert(message)
125
124
  end
126
125
 
126
+ protected #############################################
127
+
128
+ def new_frame
129
+ return UI::Model::Frame.new(self)
130
+ end
131
+
127
132
  private ###############################################
128
133
 
129
134
  def build_frame
130
- @frame = UI::Model::Frame.new(self)
135
+ @frame = new_frame
131
136
  @frame.set_size(800, 800)
132
137
  @frame.set_location(200, 25)
133
138
  @frame.title = title
@@ -0,0 +1,35 @@
1
+ class String
2
+
3
+ # Converts Ruby style names to Java style camal case.
4
+ #
5
+ # "four_score".camalized # => "FourScore"
6
+ # "and_seven_years".camalized(:lower) # => "andSevenYears"
7
+ #
8
+ def camalized(starting_case = :upper)
9
+ value = self.downcase.gsub(/[_| ][a-z]/) { |match| match[-1..-1].upcase }
10
+ value = value[0..0].upcase + value[1..-1] if starting_case == :upper
11
+ return value
12
+ end
13
+
14
+ # Converts Java camel case names to ruby style underscored names.
15
+ #
16
+ # "FourScore".underscored # => "four_score"
17
+ # "andSevenYears".underscored # => "and_seven_years"
18
+ #
19
+ def underscored
20
+ value = self[0..0].downcase + self[1..-1]
21
+ value = value.gsub(/[A-Z]/) { |cap| "_#{cap.downcase}" }
22
+ return value
23
+ end
24
+
25
+
26
+ # Converts ruby style and camalcase strings into title strings where every word is capitalized and separated by a space.
27
+ #
28
+ # "four_score".titleized # => "Four Score"
29
+ #
30
+ def titleized(starting_case = :upper)
31
+ value = self.gsub(/[a-z0-9][A-Z]/) { |match| "#{match[0..0]} #{match[-1..-1]}" }
32
+ value = value.gsub(/[_| ][a-z]/) { |match| " #{match[-1..-1].upcase}" }
33
+ return value[0..0].upcase + value[1..-1]
34
+ end
35
+ end
@@ -0,0 +1,29 @@
1
+ require 'limelight/producer'
2
+
3
+ module Limelight
4
+
5
+ class Studio
6
+
7
+ include Limelight::UI::Api::Studio
8
+
9
+ class << self
10
+
11
+ def install
12
+ Context.instance.studio = instance
13
+ end
14
+
15
+ def instance
16
+ @studio = self.new if @studio.nil?
17
+ return @studio
18
+ end
19
+
20
+ end
21
+
22
+ def open(production)
23
+ producer = Producer.new(production)
24
+ producer.open
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,42 @@
1
+ require 'limelight/templates/templater'
2
+ require 'limelight/string'
3
+
4
+ module Limelight
5
+ module Templates
6
+
7
+ # A Templater that creates all the files and directories for a production. When used with "love_story" as
8
+ # the production_path, the following will be the result.
9
+ #
10
+ # creating directory: ./love_story
11
+ # creating file: ./love_story/production.rb
12
+ # creating file: ./love_story/init.rb
13
+ # creating file: ./love_story/stages.rb
14
+ # creating file: ./love_story/styles.rb
15
+ #
16
+ class ProductionTemplater < Templater
17
+
18
+ attr_reader :tokens
19
+
20
+ # To create a ProductionTemplater, provide a production_path and the name of the default scene.
21
+ #
22
+ def initialize(production_path, default_scene_name)
23
+ super(File.dirname(production_path), Templater.source_dir)
24
+ @production_path = File.basename(production_path)
25
+ @tokens = {}
26
+ @tokens[:DEFAULT_SCENE_NAME] = default_scene_name
27
+ @tokens[:PRODUCTION_NAME] = File.basename(production_path).titleized
28
+ end
29
+
30
+ # Generates the files
31
+ #
32
+ def generate
33
+ file(File.join(@production_path, "production.rb"), "production/production.rb.template", @tokens)
34
+ file(File.join(@production_path, "init.rb"), "production/init.rb.template", @tokens)
35
+ file(File.join(@production_path, "stages.rb"), "production/stages.rb.template", @tokens)
36
+ file(File.join(@production_path, "styles.rb"), "production/styles.rb.template", @tokens)
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ require 'limelight/templates/templater'
2
+ require 'limelight/string'
3
+
4
+ module Limelight
5
+ module Templates
6
+
7
+ # A derivative of Templater that generates all the files for a scene.
8
+ # When created with the path "midnight_romance" the following will result:
9
+ #
10
+ # creating directory: ./midnight_romance
11
+ # creating file: ./midnight_romance/props.rb
12
+ # creating file: ./midnight_romance/styles.rb
13
+ # creating directory: ./midnight_romance/players
14
+ #
15
+ class SceneTemplater < Templater
16
+
17
+ attr_reader :tokens
18
+
19
+ # The scene_path should be path to a desired scene inside a production directory.
20
+ #
21
+ def initialize(scene_path)
22
+ super(File.dirname(scene_path), Templater.source_dir)
23
+ @scene_path = File.basename(scene_path)
24
+ scene_name = File.basename(scene_path)
25
+ @tokens = {}
26
+ @tokens[:SCENE_NAME] = scene_name
27
+ @tokens[:SCENE_TITLE] = scene_name.titleized
28
+ end
29
+
30
+ # Generated the files
31
+ #
32
+ def generate
33
+ file(File.join(@scene_path, "props.rb"), "scene/props.rb.template", @tokens)
34
+ file(File.join(@scene_path, "styles.rb"), "scene/styles.rb.template", @tokens)
35
+ directory(File.join(@scene_path, "players"))
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ # This file was generated by Limelight.
2
+ # It is automtically added to frozen gems. When Limelight loads a production, it will load all 'limelight_init.rb'
3
+ # files, like this one, in each of the frozen gems.
4
+
5
+ Limelight::Gems.install('!-GEM_NAME-!', !-PATHS-!)
@@ -0,0 +1,15 @@
1
+ # This file (init.rb) is the second file loaded (after production.rb) when a production is loaded.
2
+ # Initialization code for the production should go here.
3
+
4
+ # If your production is using external ruby source code that will be required in player modules, you may
5
+ # add the path to $: here.
6
+ #$: << File.expand_path(File.dirname(__FILE__) + "/lib")
7
+
8
+ # Acquires a reference to the production.
9
+ production = Limelight::Production["!-PRODUCTION_NAME-!"]
10
+
11
+ # Require any source code that will be used by the production.
12
+ #require 'seomthing'
13
+
14
+ # This is the ideal place to assign values to production attributes.
15
+ #production.something = MySource::Something.new
@@ -0,0 +1,9 @@
1
+ # This file (production.rb) configures the production. It is the first file loaded when production is opened.
2
+
3
+ # The name of the production. If not present, the production's name will default to the name of the root directory.
4
+ name "!-PRODUCTION_NAME-!"
5
+
6
+ # Attributes. Defining attributes on the production will create getters/setters on the production object.
7
+ # Create attributes for any model objects or resources that need to accessible to props or players within the production
8
+
9
+ #attribute :attribute_name
@@ -0,0 +1,17 @@
1
+ # This file (stages.rb) is used to define the stages within your production.
2
+ #
3
+ # Below is an example statge configuration.
4
+ #
5
+ # stage "center_stage" do
6
+ # default_scene "main"
7
+ # title "Limelight Center Stage"
8
+ # location [0, 0]
9
+ # size [300, 800]
10
+ # end
11
+
12
+ stage "default" do
13
+ default_scene "!-DEFAULT_SCENE_NAME-!"
14
+ title "Limelight"
15
+ location [200, 25]
16
+ size [800, 800]
17
+ end
@@ -0,0 +1,12 @@
1
+ # This file, (styles.rb) in the root directory of the production, should define any styles that are used in multiple
2
+ # scenes. It makes use of the StyleBuilder DSL.
3
+ #
4
+ # For more information see: http://limelightwiki.8thlight.com/index.php/A_Cook%27s_Tour_of_Limelight#Styling_with_styles.rb
5
+ # For a complete listing of style attributes see: http://limelightwiki.8thlight.com/index.php/Style_Attributes
6
+
7
+ # An example style definition
8
+ #foo {
9
+ # width 100
10
+ # height 100
11
+ # background_color :blue
12
+ #}
@@ -0,0 +1,6 @@
1
+ # This file (props.rb) defines all the props that appear in a scene when loaded. It makes use of the
2
+ # PropBuilder DSL.
3
+ #
4
+ # For more information see: http://limelightwiki.8thlight.com/index.php/A_Cook%27s_Tour_of_Limelight#PropBuilder_DSL
5
+
6
+ root :text => "This is the !-SCENE_TITLE-! scene."
@@ -0,0 +1,18 @@
1
+ # This file, (styles.rb) inside a scene, should define any styles specific to the containing scene.
2
+ # It makes use of the StyleBuilder DSL.
3
+ #
4
+ # For more information see: http://limelightwiki.8thlight.com/index.php/A_Cook%27s_Tour_of_Limelight#Styling_with_styles.rb
5
+ # For a complete listing of style attributes see: http://limelightwiki.8thlight.com/index.php/Style_Attributes
6
+
7
+ !-SCENE_NAME-! {
8
+ background_color :black
9
+ horizontal_alignment :center
10
+ vertical_alignment :center
11
+ width "100%"
12
+ height "100%"
13
+ }
14
+
15
+ root {
16
+ text_color :white
17
+ font_size 18
18
+ }
@@ -0,0 +1,128 @@
1
+ require 'limelight/templates/templater_logger'
2
+
3
+ module Limelight
4
+ module Templates
5
+
6
+ # A class to create directories and file templates. An instance of Templater must be provided with
7
+ # a target_root and a source_root. The target_root designates a root directory in which all directories and
8
+ # files will be created. The source_root designated a directory where all the file template can be found.
9
+ #
10
+ # A file template is a plain text file. It may optionally contain token markers in the format !-TOKEN_NAME-!.
11
+ # When a file template is installed by the templater, all the token margers will be replaced by tokens provided
12
+ # in a hash.
13
+ #
14
+ class Templater
15
+
16
+ # Return the default source_root for Limelight related file templates.
17
+ #
18
+ # $LIMELIGHT_LIB$/limelight/templates/sources
19
+ #
20
+ def self.source_dir
21
+ return File.join(File.dirname(__FILE__), "sources")
22
+ end
23
+
24
+ # Carifies a path as relative or absolute. Essentially if makes sure a path begins with a . if it's not
25
+ # an absolute path.
26
+ #
27
+ # Templater.clarity('some/path') -> './some/path'
28
+ # Templater.clarity('/root/path') -> '/root/path'
29
+ #
30
+ def self.clarify(path)
31
+ return path if path[0..0] == '.'
32
+ return path if path == File.expand_path(path)
33
+ return File.join(".", path)
34
+ end
35
+
36
+ attr_reader :target_root, :source_root
37
+
38
+ # See TemplaterLogger
39
+ #
40
+ attr_accessor :logger
41
+
42
+ # New instances Templater require a target_root. The source_root may optionally be provided. source_root
43
+ # defaults to Templater.source_dir
44
+ #
45
+ # The logger is initializes as a TemplaterLogger
46
+ #
47
+ def initialize(target_root, source_root=Templater.source_dir)
48
+ @logger = TemplaterLogger.new
49
+ @target_root = Templater.clarify(target_root)
50
+ @source_root = source_root
51
+ end
52
+
53
+ # Creates a deirectory. If the specified directory's parent directory is missing, it will be created as will its
54
+ # parent directory, and so on.
55
+ #
56
+ # After the following call,
57
+ #
58
+ # templater.directory("dir1/dir2/dir3/dir4")
59
+ #
60
+ # The following directories will exist, inside the target_root, whether they existed prior to the call or not.
61
+ #
62
+ # dir1
63
+ # dir1/dir2
64
+ # dir1/dir2/dir3
65
+ # dir1/dir2/dir3/dir4
66
+ #
67
+ def directory(path)
68
+ full_path = File.join(@target_root, path)
69
+ establish_directory(full_path)
70
+ end
71
+
72
+ # Creates the specified file from the specified file template. The file will be created withint the target_root.
73
+ # All parent diretories will be created if needed. The source paramter should be a path pointing to a
74
+ # file template in the source_root directory.
75
+ #
76
+ # Assume the the file <code>src/default.txt.template</code> exists in the source_root with the following content.
77
+ #
78
+ # !-SCORES-! score and !-YEARS-! years ago, ...
79
+ #
80
+ # When the following command is executed,
81
+ #
82
+ # templater.file('dir/foo.txt', 'src/default.txt.template', :SCORES => "Four", :YEARS => "seven")
83
+ #
84
+ # The file <code>dir/foo.txt</code> will exist in the target_root with the following content.
85
+ #
86
+ # Four score and seven years ago, ...
87
+ #
88
+ def file(target, source, tokens = {})
89
+ target_path = File.join(@target_root, target)
90
+ source_source = File.join(@source_root, source)
91
+
92
+ establish_directory(File.dirname(target_path))
93
+
94
+ if File.exists?(target_path)
95
+ @logger.file_already_exists(target_path)
96
+ else
97
+ @logger.creating_file(target_path)
98
+ content = IO.read(source_source)
99
+ content = replace_tokens(content, tokens)
100
+ File.open(target_path, 'w') { |file| file.write content }
101
+ end
102
+ end
103
+
104
+ private
105
+
106
+ def establish_directory(full_path)
107
+ return if File.exists?(full_path)
108
+ parent_path = File.dirname(full_path)
109
+ while (!File.exists?(parent_path))
110
+ establish_directory(parent_path)
111
+ end
112
+
113
+ @logger.creating_directory(full_path)
114
+ Dir.mkdir(full_path)
115
+ end
116
+
117
+ def replace_tokens(content, tokens)
118
+ return content.gsub(/!-(\w+)-!/) do |value|
119
+ token_name = value[2...-2]
120
+ token = tokens[token_name] || tokens[token_name.to_sym] || "UNKNOWN TOKEN"
121
+ token
122
+ end
123
+ end
124
+
125
+ end
126
+
127
+ end
128
+ end