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,36 @@
1
+ module Limelight
2
+ module Templates
3
+
4
+ # Templaters uses this class to log activity.
5
+ #
6
+ class TemplaterLogger
7
+
8
+ # An accessor to the output IO. Defaults to STDOUT
9
+ #
10
+ attr_accessor :output
11
+
12
+ def initialize
13
+ @output = STDOUT
14
+ end
15
+
16
+ def creating_directory(name)
17
+ @output.puts "\tcreating directory: #{name}"
18
+ end
19
+
20
+ def creating_file(name)
21
+ @output.puts "\tcreating file: #{name}"
22
+ end
23
+
24
+ def file_already_exists(name)
25
+ @output.puts "\tfile already exists: #{name}"
26
+ end
27
+
28
+ def log(message, name)
29
+ spaces = 21 - message.length - 1
30
+ @output.puts "\t#{message}:#{' '*spaces}#{name}"
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
@@ -14,26 +14,34 @@ module Limelight
14
14
  attr_reader :active_stage
15
15
 
16
16
  def initialize
17
- @__stages__ = {}
17
+ @stages = {}
18
18
  end
19
19
 
20
20
  # Returns an Array of Stages that belong to this Theater.
21
21
  #
22
22
  def stages
23
- return @__stages__.values
23
+ return @stages.values
24
+ end
25
+
26
+ # Returns true if the theater has at least one stage
27
+ #
28
+ def has_stages?
29
+ return stages.length > 0
24
30
  end
25
31
 
26
32
  # Returns the Stage with the spcified name, nil if none exist with the specified name.
27
33
  #
28
34
  def [](stage_name)
29
- return @__stages__[stage_name]
35
+ return @stages[stage_name]
30
36
  end
31
37
 
32
38
  # Adds a Stage to the Theater. Raises an exception is the name of the Stage is duplicated.
33
39
  #
34
- def add_stage(stage)
35
- raise LimelightException.new("Duplicate stage name: '#{stage.name}'") if @__stages__[stage.name]
36
- @__stages__[stage.name] = stage
40
+ def add_stage(name)
41
+ raise LimelightException.new("Duplicate stage name: '#{name}'") if @stages[name]
42
+ stage = build_stage(name)
43
+ @stages[name] = stage
44
+ return stage
37
45
  end
38
46
 
39
47
  # Lets the Theater know which stage has the limelight (currently active).
@@ -45,9 +53,15 @@ module Limelight
45
53
  # If no Stages are added, the Theater will provide a default Stage named "Limelight".
46
54
  #
47
55
  def default_stage
48
- add_stage(Stage.new(self, "Limelight")) if self["Limelight"].nil?
56
+ add_stage("Limelight") if self["Limelight"].nil?
49
57
  return self["Limelight"]
50
58
  end
59
+
60
+ protected #############################################
61
+
62
+ def build_stage(name)
63
+ return Limelight::Stage.new(self, name)
64
+ end
51
65
 
52
66
  end
53
67
 
@@ -9,19 +9,18 @@ module Limelight
9
9
 
10
10
  # Returns true if the specified file is a directory and has the structure of a Scene.
11
11
  #
12
- def self.is_limelight_scene?(file)
13
- return is_directory_containing_file?(file, "props.rb")
12
+ def self.is_limelight_scene?(dir)
13
+ return directory_contains_file(dir, "props.rb")
14
14
  end
15
15
 
16
16
  # Returns true if the specified file is a directory and has the structure of a Production.
17
- #
18
- def self.is_limelight_production?(file)
19
- return is_directory_containing_file?(file, "stages.rb")
17
+ def self.is_limelight_production?(dir)
18
+ return directory_contains_file(dir, "stages.rb")
20
19
  end
21
20
 
22
21
  # Returns true of the file is a directory containing an entry named file_name.
23
22
  #
24
- def self.is_directory_containing_file?(file, file_name)
23
+ def self.directory_contains_file(file, file_name)
25
24
  if file.is_a? String
26
25
  return File.directory?(file) && File.exists?(File.join(file, file_name))
27
26
  else
@@ -45,4 +44,21 @@ module Limelight
45
44
 
46
45
  end
47
46
 
47
+ end
48
+
49
+ class Module
50
+
51
+ def prop_reader(*symbols)
52
+ symbols.each do |sym|
53
+ define_method(sym) do
54
+ value = instance_variable_get("@#{sym}")
55
+ if value.nil?
56
+ value = scene.find(sym.to_s)
57
+ instance_variable_set("@#{sym}", value) unless value.nil?
58
+ end
59
+ return value
60
+ end
61
+ end
62
+ end
63
+
48
64
  end
@@ -5,8 +5,8 @@ module Limelight
5
5
  module VERSION #:nodoc:
6
6
  unless defined? MAJOR
7
7
  MAJOR = 0
8
- MINOR = 2
9
- TINY = 1
8
+ MINOR = 3
9
+ TINY = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
  TAG = "REL_" + [MAJOR, MINOR, TINY].join('_')
@@ -6,7 +6,7 @@ page {
6
6
  height "100%"
7
7
  horizontal_alignment "center"
8
8
  background_image "images/bg.jpg"
9
- vertical_scroll_bar :on
9
+ vertical_scrollbar :on
10
10
  }
11
11
 
12
12
  main_column {
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Langston's Ant</title>
4
4
  <link rel=StyleSheet href="ant.css" type="text/css" media="screen, print"/>
5
- <script language="JavaScript" src="ant.js"/>
5
+ <script language="JavaScript" src="ant.js"></script>
6
6
  </head>
7
7
  <body onload="load()">
8
8
  <div id="title">
@@ -0,0 +1 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/players/ant")
@@ -17,12 +17,12 @@ module Log
17
17
  end
18
18
 
19
19
  def count
20
- @count = self.find("count") if not @count
20
+ @count = scene.find("count") if not @count
21
21
  return @count
22
22
  end
23
23
 
24
24
  def location
25
- @location = self.find("location") if not @location
25
+ @location = scene.find("location") if not @location
26
26
  return @location
27
27
  end
28
28
 
@@ -1,33 +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
- load File.expand_path(File.dirname(__FILE__) + "/ant.rb")
5
-
6
4
  module World
7
-
8
- # def self.extended(prop)
9
- # create_time = 0
10
- # add_time = 0
11
- #
12
- # prop.cell_index = {}
13
- # 50.times do |y|
14
- # 50.times do |x|
15
- # id = "#{x},#{y}"
16
- # start = Time.now
17
- # cell = Limelight::Prop.new(:name => "cell", :id => id)
18
- # create_time += Time.now - start
19
- # start = Time.now
20
- # prop.add(cell)
21
- # add_time += Time.now - start
22
- # prop.cell_index[id] = cell
23
- # end
24
- # end
25
- # puts "create_time: #{create_time}"
26
- # puts "add_time: #{add_time}"
27
- # # create_time: 3.2059999999998325
28
- # # add_time: 0.5010000000000002
29
- #
30
- # end
31
5
 
32
6
  def self.extended(prop)
33
7
  prop.cells = {}
Binary file
@@ -12,13 +12,12 @@ module Chromaton
12
12
  extended_block.clicks = 0
13
13
  extended_block.text = "Click Me!"
14
14
  end
15
-
16
- def mouse_clicked(e)
15
+
16
+ def mouse_clicked(e)
17
17
  @clicks += 1
18
18
  new_random_color
19
19
  new_random_size
20
20
  update_text
21
- parent.update
22
21
  end
23
22
 
24
23
  private
@@ -27,12 +26,19 @@ module Chromaton
27
26
  r = rand(255)
28
27
  g = rand(255)
29
28
  b = rand(255)
30
- @new_color = sprintf("#%x%x%x", r, g, b)
29
+ @new_color = "##{as_2_digit_hex(r)}#{as_2_digit_hex(g)}#{as_2_digit_hex(b)}"
31
30
  style.background_color = @new_color
32
31
  end
32
+
33
+ def as_2_digit_hex(number)
34
+ value = sprintf("%x", number)
35
+ value << "0" if value.length == 1
36
+ return value;
37
+ end
33
38
 
34
39
  def new_random_size
35
40
  @size = rand(500) + 50
41
+ puts "@size: #{@size}"
36
42
  style.width = @size.to_s
37
43
  style.height = @size.to_s
38
44
  end
@@ -62,8 +62,9 @@ module Floater
62
62
  def calculate_vector(sx, sy)
63
63
  dx = (x - sx)
64
64
  dy = (y - sy)
65
- @x_coefficient = dx / (dx.abs + dy.abs)
66
- @y_coefficient = dy / (dx.abs + dy.abs)
65
+ abs_delta = (dx.abs + dy.abs).to_f
66
+ @x_coefficient = dx / abs_delta
67
+ @y_coefficient = dy / abs_delta
67
68
  @velocity = 20
68
69
  find_bounds if @max_x.nil?
69
70
  end
@@ -79,6 +80,7 @@ module Floater
79
80
  @velocity -= @velocity * FRICTION
80
81
  else
81
82
  @sliding = false
83
+
82
84
  @animation.stop
83
85
  end
84
86
  end
@@ -5,7 +5,11 @@ module Spinner
5
5
 
6
6
  def mouse_entered(e)
7
7
  @animation = animate(:updates_per_second => 30) do
8
- style.gradient_angle = (style.gradient_angle.to_i + 1).to_s
8
+ if style.gradient_angle == "359"
9
+ style.gradient_angle = "0"
10
+ else
11
+ style.gradient_angle = (style.gradient_angle.to_i + 1).to_s
12
+ end
9
13
  end
10
14
  end
11
15
 
@@ -6,8 +6,8 @@ module Teaser
6
6
  def mouse_entered(e)
7
7
  @step = -1
8
8
  @animation = animate(:updates_per_second => 30) do
9
- @step = -1 if style.gradient_penetration == "100"
10
- @step = 1 if style.gradient_penetration == "1"
9
+ @step = -1 if style.gradient_penetration == "100%"
10
+ @step = 1 if style.gradient_penetration == "1%"
11
11
  style.gradient_penetration = (style.gradient_penetration.to_i + @step).to_s
12
12
  end
13
13
  end
@@ -6,8 +6,8 @@ module Wave
6
6
  def mouse_entered(e)
7
7
  @step = -1
8
8
  @animation = animate(:updates_per_second => 30) do
9
- @step = -1 if style.gradient_penetration == "100"
10
- @step = 1 if style.gradient_penetration == "1"
9
+ @step = -1 if style.gradient_penetration == "100%"
10
+ @step = 1 if style.gradient_penetration == "1%"
11
11
  style.gradient_penetration = (style.gradient_penetration.to_i + @step).to_s
12
12
  end
13
13
  end
@@ -6,8 +6,8 @@ module Waves
6
6
  def mouse_entered(e)
7
7
  @step = -1
8
8
  @animation = animate(:updates_per_second => 30) do
9
- @step = -1 if style.gradient_penetration == "100"
10
- @step = 1 if style.gradient_penetration == "1"
9
+ @step = -1 if style.gradient_penetration == "100%"
10
+ @step = 1 if style.gradient_penetration == "1%"
11
11
  style.gradient_penetration = (style.gradient_penetration.to_i + @step).to_s
12
12
  end
13
13
  end
@@ -12,5 +12,6 @@ header do
12
12
  example_link :text => "Floaters", :on_mouse_clicked => "scene.load('floaters')"
13
13
  example_link :text => "Sketching", :on_mouse_clicked => "scene.load('sketching')"
14
14
  example_link :text => "Sound", :on_mouse_clicked => "scene.load('sounds')"
15
+ example_link :text => "Images", :on_mouse_clicked => "scene.load('images_scene')"
15
16
  end
16
17
 
@@ -0,0 +1,25 @@
1
+ __ :name => "sandbox"
2
+ __install "header.rb"
3
+ arena :vertical_alignment => :center do
4
+ control_panel do
5
+ setting do
6
+ label :text => "Width:"
7
+ input :players => "text_box", :text => "auto", :on_focus_lost => "scene.find('logo').style.width = text"
8
+ end
9
+ setting do
10
+ label :text => "Height:"
11
+ input :players => "text_box", :text => "auto", :on_focus_lost => "scene.find('logo').style.height = text"
12
+ end
13
+ setting do
14
+ label :text => "Scaled:", :width => "100%"
15
+ input :players => "check_box", :checked => true, :on_button_pressed => "scene.find('logo').scaled = checked?"
16
+ end
17
+ setting do
18
+ label :text => "Rotation:"
19
+ input :players => "text_box", :text => "0", :on_focus_lost => "scene.find('logo').rotation = text.to_f"
20
+ end
21
+ end
22
+ image_area do
23
+ logo :id => "logo", :players => "image", :image => "images/logo.png"
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ control_panel {
2
+ width "100%"
3
+ background_color :gray
4
+ secondary_background_color :dark_green
5
+ gradient_angle 270
6
+ gradient :on
7
+ horizontal_alignment :center
8
+ padding 10
9
+ }
10
+
11
+ setting {
12
+ width 120
13
+ }
14
+
15
+ label {
16
+ text_color :white
17
+ font_style "bold"
18
+ }
19
+
20
+ image_area {
21
+ width "100%"
22
+ height "90%"
23
+ horizontal_alignment :center
24
+ vertical_alignment :center
25
+ background_color :light_gray
26
+ }
27
+
28
+ logo {
29
+ border_width 1
30
+ }
@@ -22,7 +22,7 @@ input_log {
22
22
  width "100%"
23
23
  background_color "#999"
24
24
  text_color "black"
25
- # vertical_scroll_bar :on
25
+ # vertical_scrollbar :on
26
26
  }
27
27
 
28
28
  input_results {
@@ -4,35 +4,35 @@
4
4
  __ :name => "sandbox"
5
5
  __install "header.rb"
6
6
  arena do
7
- table :scroll_bars => "on", :id => "one_table" do
7
+ table :scrollbars => "on", :id => "one_table" do
8
8
  10.times do |y|
9
- row :id => y.to_s do
9
+ row :id => "a_#{y}" do
10
10
  10.times do |x|
11
- id = "#{x},#{y}"
11
+ id = "a_#{x},#{y}"
12
12
  bg_color = ( (x + y) % 2 == 0 ) ? "blue" : "#DDDDDD"
13
- cell :id => id, :text => id, :background_color => bg_color
13
+ cell :id => id, :text => "#{x},#{y}", :background_color => bg_color
14
14
  end
15
15
  end
16
16
  end
17
17
  end
18
- table :vertical_scroll_bar => "off", :horizontal_scroll_bar => "on", :id => "two_table" do
18
+ table :vertical_scrollbar => "off", :horizontal_scrollbar => "on", :id => "two_table" do
19
19
  2.times do |y|
20
- row :id => y.to_s do
20
+ row :id => "b_#{y}" do
21
21
  10.times do |x|
22
- id = "#{x},#{y}"
22
+ id = "b_#{x},#{y}"
23
23
  bg_color = ( (x + y) % 2 == 0 ) ? "blue" : "#DDDDDD"
24
- cell :id => id, :text => id, :background_color => bg_color
24
+ cell :id => id, :text => "#{x},#{y}", :background_color => bg_color
25
25
  end
26
26
  end
27
27
  end
28
28
  end
29
- table :vertical_scroll_bar => "on", :horizontal_scroll_bar => "off", :id => "three_table" do
29
+ table :vertical_scrollbar => "on", :horizontal_scrollbar => "off", :id => "three_table" do
30
30
  10.times do |y|
31
- row :id => y.to_s do
31
+ row :id => "c_#{y}" do
32
32
  2.times do |x|
33
- id = "#{x},#{y}"
33
+ id = "c_#{x},#{y}"
34
34
  bg_color = ( (x + y) % 2 == 0 ) ? "blue" : "#DDDDDD"
35
- cell :id => id, :text => id, :background_color => bg_color
35
+ cell :id => id, :text => "#{x},#{y}", :background_color => bg_color
36
36
  end
37
37
  end
38
38
  end