limelight 0.2.0-java → 0.2.1-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 (51) hide show
  1. data/bin/limelight +2 -3
  2. data/lib/limelight.jar +0 -0
  3. data/lib/limelight/animation.rb +32 -12
  4. data/lib/limelight/build_exception.rb +3 -0
  5. data/lib/limelight/builtin/players/button.rb +17 -2
  6. data/lib/limelight/builtin/players/check_box.rb +21 -2
  7. data/lib/limelight/builtin/players/combo_box.rb +31 -3
  8. data/lib/limelight/builtin/players/combo_box_popup_list.rb +1 -1
  9. data/lib/limelight/builtin/players/combo_box_popup_list_item.rb +1 -1
  10. data/lib/limelight/builtin/players/curtains.rb +1 -1
  11. data/lib/limelight/builtin/players/radio_button.rb +27 -3
  12. data/lib/limelight/builtin/players/text_area.rb +11 -2
  13. data/lib/limelight/builtin/players/text_box.rb +11 -2
  14. data/lib/limelight/button_group_cache.rb +2 -2
  15. data/lib/limelight/casting_director.rb +6 -1
  16. data/lib/limelight/commands.rb +10 -24
  17. data/lib/limelight/file_chooser.rb +16 -3
  18. data/lib/limelight/file_filter.rb +10 -3
  19. data/lib/limelight/java_couplings.rb +11 -10
  20. data/lib/limelight/java_util.rb +36 -3
  21. data/lib/limelight/limelight_exception.rb +3 -1
  22. data/lib/limelight/loaders/file_scene_loader.rb +1 -1
  23. data/lib/limelight/main.rb +108 -0
  24. data/lib/limelight/menu_bar.rb +31 -12
  25. data/lib/limelight/paint_action.rb +4 -2
  26. data/lib/limelight/pen.rb +39 -9
  27. data/lib/limelight/producer.rb +35 -7
  28. data/lib/limelight/production.rb +18 -9
  29. data/lib/limelight/production_builder.rb +22 -5
  30. data/lib/limelight/prop.rb +127 -45
  31. data/lib/limelight/prop_builder.rb +70 -11
  32. data/lib/limelight/scene.rb +25 -21
  33. data/lib/limelight/stage.rb +68 -18
  34. data/lib/limelight/stage_builder.rb +68 -27
  35. data/lib/limelight/styles.rb +327 -30
  36. data/lib/limelight/styles_builder.rb +91 -21
  37. data/lib/limelight/theater.rb +23 -11
  38. data/lib/limelight/util.rb +28 -6
  39. data/lib/limelight/version.rb +1 -1
  40. data/productions/startup/players/browse_button.rb +1 -1
  41. data/spec/builtin/players/check_box_spec.rb +1 -1
  42. data/spec/builtin/players/radio_button_spec.rb +2 -2
  43. data/spec/builtin/players/text_area_spec.rb +1 -1
  44. data/spec/builtin/players/text_box_spec.rb +1 -1
  45. data/spec/commands_spec.rb +4 -3
  46. data/spec/prop_builder_spec.rb +40 -29
  47. data/spec/prop_spec.rb +5 -1
  48. data/spec/stage_spec.rb +15 -15
  49. data/spec/styles_spec.rb +36 -0
  50. data/spec/theater_spec.rb +8 -8
  51. metadata +6 -3
@@ -4,18 +4,31 @@
4
4
  require 'limelight/file_filter'
5
5
 
6
6
  module Limelight
7
-
7
+
8
+ # An object that manages the selection of a file on the file system. When invoked, a file chooser window
9
+ # will pop up and allow the user to select a file.
10
+ #
8
11
  class FileChooser
9
12
 
10
13
  attr_reader :chooser, :chosen_file
11
-
14
+
15
+ # Creates a new FileChooser. Options may include:
16
+ # * :description => a string describing the desired file
17
+ # * :parent => (required) the parent window
18
+ # * :directory => starting directory
19
+ # * :title => title of the window
20
+ # * :directories_only => boolean, true if the user must select a directory
21
+ # * :files_only => boolean, true if the user must select a file
22
+ #
12
23
  def initialize(options = {}, &filter)
13
24
  @options = options
14
25
  @parent = options[:parent]
15
26
  create_chooser
16
27
  @chooser.setFileFilter(FileFilter.new(@options[:description], &filter)) if filter
17
28
  end
18
-
29
+
30
+ # Opens the windows and returns the chosen file.
31
+ #
19
32
  def choose_file
20
33
  returnVal = @chooser.showOpenDialog(@parent);
21
34
 
@@ -2,17 +2,24 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  module Limelight
5
-
5
+
6
+ # A FileFiler is used in conjunction with FileChooser. It is used to help the user select only files of the
7
+ # desired type.
8
+ #
6
9
  class FileFilter < javax.swing.filechooser::FileFilter
7
10
 
8
11
  attr_reader :description, :filter
9
-
12
+
13
+ # The filter parameter is a block that contains the logic to decide whether a given file is selectable or not.
14
+ #
10
15
  def initialize(description, &filter)
11
16
  super()
12
17
  @description = description
13
18
  @filter = filter
14
19
  end
15
-
20
+
21
+ # Called to determine if a file is selectable. Invokes the filter block.
22
+ #
16
23
  def accept(file)
17
24
  return @filter.call(file)
18
25
  end
@@ -1,32 +1,33 @@
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
-
4
- module Limelight
3
+
4
+ module Limelight #:nodoc:
5
5
 
6
6
  Main = Java::limelight.Main
7
7
  SceneLoader = Java::limelight.SceneLoader
8
8
  Context = Java::limelight.Context
9
9
  AnimationTask = Java::limelight.AnimationTask
10
10
 
11
- module Styles
11
+ module Styles #:nodoc:
12
12
  Style = Java::limelight.styles.Style
13
13
  FlatStyle = Java::limelight.styles.FlatStyle
14
14
  RichStyle = Java::limelight.styles.RichStyle
15
15
  ScreenableStyle = Java::limelight.styles.ScreenableStyle
16
16
  end
17
17
 
18
- module Util
18
+ module Util #:nodoc:
19
19
  Colors = Java::limelight.util.Colors
20
20
  end
21
21
 
22
- module UI
22
+ module UI #:nodoc:
23
23
 
24
24
  ButtonGroupCache = Java::limelight.ui.ButtonGroupCache
25
25
 
26
- module Model
26
+ module Model #:nodoc:
27
27
  Frame = Java::limelight.ui.model.Frame
28
28
  Panel = Java::limelight.ui.model.PropPanel
29
- module Inputs
29
+
30
+ module Inputs #:nodoc:
30
31
  ButtonPanel = Java::limelight.ui.model.inputs.ButtonPanel
31
32
  CheckBoxPanel = Java::limelight.ui.model.inputs.CheckBoxPanel
32
33
  ComboBoxPanel = Java::limelight.ui.model.inputs.ComboBoxPanel
@@ -36,20 +37,20 @@ module Limelight
36
37
  end
37
38
  end
38
39
 
39
- module Api
40
+ module Api #:nodoc:
40
41
  Scene = Java::limelight.ui.api.Scene
41
42
  Prop = Java::limelight.ui.api.Prop
42
43
  Stage = Java::limelight.ui.api.Stage
43
44
  Theater = Java::limelight.ui.api.Theater
44
45
  end
45
46
 
46
- module Painting
47
+ module Painting #:nodoc:
47
48
  PaintAction = Java::limelight.ui.painting.PaintAction
48
49
  end
49
50
 
50
51
  end
51
52
 
52
- module Util
53
+ module Util #:nodoc:
53
54
 
54
55
  Packer = Java::limelight.io.Packer
55
56
 
@@ -2,13 +2,41 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  class Class
5
-
5
+
6
+ # Class level method to creates Java style getters.
7
+ #
8
+ # getters :foo, :bar
9
+ #
10
+ # Creates the following methods:
11
+ #
12
+ # def getFoo
13
+ # return @foo
14
+ # end
15
+ #
16
+ # def getBar
17
+ # return @bar
18
+ # end
19
+ #
6
20
  def getters(*symbols)
7
21
  symbols.each do |symbol|
8
22
  self.class_eval "def get#{symbol.to_s.camalized}; return #{symbol}; end"
9
23
  end
10
24
  end
11
-
25
+
26
+ # Class level method to creates Java style setters.
27
+ #
28
+ # setters :foo, :bar
29
+ #
30
+ # Creates the following methods:
31
+ #
32
+ # def setFoo(value)
33
+ # @foo = value
34
+ # end
35
+ #
36
+ # def setBar(value)
37
+ # @bar = value
38
+ # end
39
+ #
12
40
  def setters(*symbols)
13
41
  symbols.each do |symbol|
14
42
  self.class_eval "def set#{symbol.to_s.camalized}(value); self.#{symbol} = value; end"
@@ -18,7 +46,12 @@ class Class
18
46
  end
19
47
 
20
48
  class String
21
-
49
+
50
+ # Converts Ruby style names to Java style camal case.
51
+ #
52
+ # "four_score".camalized # => "FourScore"
53
+ # "and_seven_years".camalized(:lower) # => "andSevenYears"
54
+ #
22
55
  def camalized(starting_case = :upper)
23
56
  value = self.downcase.gsub(/[_| ]([a-z])/) { |match| match[-1..-1].upcase }
24
57
  value = value[0..0].upcase + value[1..-1] if starting_case == :upper
@@ -2,7 +2,9 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  module Limelight
5
-
5
+
6
+ # Most exeception thrown by Limelight Ruby code will be of this type.
7
+ #
6
8
  class LimelightException < Exception
7
9
  end
8
10
 
@@ -4,7 +4,7 @@
4
4
  module Limelight
5
5
  module Loaders
6
6
 
7
- class FileSceneLoader
7
+ class FileSceneLoader #:nodoc:
8
8
 
9
9
  include SceneLoader
10
10
 
@@ -0,0 +1,108 @@
1
+ #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require 'limelight/commands'
5
+
6
+ module Limelight
7
+
8
+ # Used to open and manage Limelight Productions.
9
+ #
10
+ # Productions may have a single scene or multiple scenes.
11
+ #
12
+ # Single-Scene Production Directory Structure:
13
+ #
14
+ # - calculator
15
+ # | - props.rb
16
+ # | - styles.rb
17
+ # | - players
18
+ # | - <player_name>.rb
19
+ # | - *
20
+ # | - stages.rb
21
+ # | - production.rb
22
+ #
23
+ # In a Single-Scene production, the scene name and production name are the same. As seen above, both names are 'calculator'.
24
+ # Inside the scene there are three files and one directory, all of which are options.
25
+ #
26
+ # == props.rb
27
+ # This file defines the props contained in the scene
28
+ # See Limelight::PropBuilder
29
+ #
30
+ # == styles.rb
31
+ # This file defines the styles used in the scene
32
+ # See Limelight::StylesBuilder
33
+ #
34
+ # == players
35
+ # A directory containing all the players used in the scene. Players are modules that are included by Prop objects.
36
+ # If you have a Prop named 'wall', then you may optionaly have a file named 'wall.rb' in the players directory.
37
+ # Inside 'wall.rb' you would define a module named 'Wall'. All behavior defined in the Wall modules will automatically be included
38
+ # in every prop named 'wall'.
39
+ #
40
+ # == stages.rb
41
+ # This file uses a DSL to configure the stages that will be used in the production.
42
+ # See Limelight::StagesBuilder
43
+ #
44
+ # == production.rb
45
+ # This file uses a DSL to configure the current Production.
46
+ # See Limelight::ProductionBuilder
47
+ #
48
+ # Multiple-Scene Production Directory Structure:
49
+ #
50
+ # - sandbox
51
+ # | - stages.rb
52
+ # | - production.rb
53
+ # | - styles.rb
54
+ # | - players
55
+ # | - <player_name>.rb
56
+ # | - fader
57
+ # | - props.rb
58
+ # | - styles.rb
59
+ # | - players
60
+ # | - <player_name>.rb
61
+ # | - floater
62
+ # | - props.rb
63
+ # | - styles.rb
64
+ # | - players
65
+ # | - <player_name>.rb
66
+ #
67
+ # In a Multiple-Scene production, the production acquires that name of the root directory. In this case the production is named 'sandbox'.
68
+ # Each directory inside the root directory is a scene. This production has two scenes named 'fader' and 'floater'. Each scene is structured
69
+ # the same as in a Single-Scene production with the exception of the 'stages.rb' file. This file is specific to the production. The production
70
+ # may contain a 'styles.rb' which contains styles used by multiple scenes. If some players are used in multiple Scenes, then it is useful to
71
+ # to create a players directory in the Production root to hold the common players. Other files may exist in the directory structure and they will not
72
+ # conflict with Limelight.
73
+ #
74
+ # See Limelight::Commands
75
+ #
76
+ class Main
77
+
78
+ class << self
79
+
80
+ # Executes behavior of limelight command.
81
+ #
82
+ def run(args)
83
+ command_name = args.shift
84
+ command = Commands::COMMANDS[command_name]
85
+ if command
86
+ command.new.run(args)
87
+ else
88
+ usage
89
+ end
90
+ end
91
+
92
+ # Prints the usage of the limelight command.
93
+ #
94
+ def usage
95
+ puts "Usage: limelight <command> [options] [params]"
96
+ puts "commands:"
97
+ Commands::COMMANDS.keys.sort.each do |key|
98
+ command = Commands::COMMANDS[key]
99
+ puts "\t#{key}\t\t#{command.description}"
100
+ end
101
+ end
102
+ end
103
+
104
+
105
+ end
106
+
107
+
108
+ end
@@ -2,48 +2,67 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  module Limelight
5
-
6
- class AnonymousActionListener
5
+
6
+ class AnonymousActionListener #:nodoc:
7
7
  include java.awt.event.ActionListener
8
-
8
+
9
9
  def initialize(context, symbol)
10
10
  @context = context
11
11
  @symbol = symbol
12
12
  end
13
-
13
+
14
14
  def actionPerformed(e)
15
15
  method = @context.method(@symbol)
16
16
  method.call
17
17
  end
18
18
  end
19
-
19
+
20
+ # A class used to build menu bars using a DSL.
21
+ #
22
+ # MenuBar.build(self) do
23
+ # menu("File") do
24
+ # item("Open", :open_chosen_scene)
25
+ # item("Refresh", :reload)
26
+ # end
27
+ # end
28
+ #
29
+ # This example created one menu named 'File' with two menu items: 'Open' and 'Refresh'. The seconds parameter of the
30
+ # menu items is the symbol of a method on the context that will be invoked when the menu item is selected.
31
+ #
20
32
  class MenuBar
21
-
33
+
22
34
  def self.build(context, &prop)
23
35
  builder = self.new(context)
24
36
  builder.instance_eval(&prop)
25
37
  return builder.menu_bar
26
38
  end
27
-
39
+
28
40
  attr_reader :menu_bar
29
-
41
+
42
+ # This builder must be provided with a context. All menu item actions will be invoked on the context.
43
+ #
30
44
  def initialize(context)
31
45
  @context = context
32
46
  @menu_bar = javax.swing.JMenuBar.new
33
47
  end
34
-
48
+
49
+ # Creates a new menu with the provided name
50
+ #
35
51
  def menu(name)
36
52
  @menu = javax.swing.JMenu.new(name)
37
53
  @menu_bar.add(@menu)
38
54
  yield
39
55
  end
40
-
56
+
57
+ # Created a new menu item with the provided name. The symbols paramter is the name of a method on the context
58
+ # that will be invoked when the item is selected.
59
+ #
41
60
  def item(name, symbol)
42
61
  menu_item = javax.swing.JMenuItem.new(name)
43
62
  @menu.add(menu_item)
44
63
  menu_item.addActionListener(AnonymousActionListener.new(@context, symbol))
45
64
  end
46
-
65
+
47
66
  end
48
-
67
+
49
68
  end
@@ -4,8 +4,10 @@
4
4
  require 'limelight/pen'
5
5
 
6
6
  module Limelight
7
-
8
- class PaintAction
7
+
8
+ # A PaintAction is created by Prop.after_painting.
9
+ #
10
+ class PaintAction #:nodoc:
9
11
 
10
12
  include UI::Painting::PaintAction
11
13
 
data/lib/limelight/pen.rb CHANGED
@@ -2,48 +2,78 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  module Limelight
5
-
5
+
6
+ # The Pen is acquired from Prop.pen. It is used to draw directly on the screen withing the bounds of the prop
7
+ # from which the Pen was acquired.
8
+ #
9
+ # All points used by the Pen are relative to the bounds of the Prop. The top left corner of the Prop is represented
10
+ # by the point (0, 0). If a Prop has margin, border, or padding, the point (0, 0) may appear to be outside the Prop.
11
+ #
6
12
  class Pen
7
13
 
8
14
  attr_accessor :context
9
-
15
+
16
+ # It is constructed with a context which is essentially a java.awt.Graphic2D object. Defaults are set:
17
+ # * color = "black"
18
+ # * width = 1
19
+ # * smooth = false
20
+ #
10
21
  def initialize(context)
11
22
  @context = context
12
23
  self.color = "black"
13
24
  self.width = 1
14
25
  self.smooth = false
15
26
  end
16
-
27
+
28
+ # Sets the color of the Pen. The passed value should be a string that either names a known color or specifies
29
+ # a hex color value.
30
+ #
17
31
  def color=(value)
18
32
  resolve_color = Util::Colors.resolve(value)
19
33
  @context.setColor(resolve_color)
20
34
  end
21
-
35
+
36
+ # Sets the width, in pixels, of the pen.
37
+ #
22
38
  def width=(value)
23
39
  @context.setStroke(java.awt.BasicStroke.new(value))
24
40
  end
25
-
41
+
42
+ # Specifies whether the pen will use anti-aliasing to draw smooth shapes or not. Shapes will appear pixilated when
43
+ # smooth is set to false.
44
+ #
26
45
  def smooth=(value)
27
46
  hint = value ? java.awt.RenderingHints::VALUE_ANTIALIAS_ON : java.awt.RenderingHints::VALUE_ANTIALIAS_OFF
28
47
  @context.setRenderingHint(java.awt.RenderingHints::KEY_ANTIALIASING, hint)
29
48
  end
30
-
49
+
50
+ # Draws a line from the point (x1, y1) to the point (x2, y2)
51
+ #
31
52
  def draw_line(x1, y1, x2, y2)
32
53
  @context.drawLine(x1, y1, x2, y2)
33
54
  end
34
-
55
+
56
+ # Draws a rectangle with the top left corner at (x, y).
57
+ #
35
58
  def draw_rectangle(x, y, width, height)
36
59
  @context.drawRect(x, y, width, height)
37
60
  end
38
-
61
+
62
+ # Fills a rectangle with the current color of the Pen. The top left corner of the rectangle is (x, y).
63
+ #
39
64
  def fill_rectangle(x, y, width, height)
40
65
  @context.fillRect(x, y, width, height)
41
66
  end
42
-
67
+
68
+ # Draws the largest oval that will fit in the specified rectangle. The top left corner of the bounding
69
+ # rectangle is at (x, y). The center of the oval will be at (x + width/2, y + height/2).
70
+ #
43
71
  def draw_oval(x, y, width, height)
44
72
  @context.drawOval(x, y, width, height)
45
73
  end
46
74
 
75
+ # Fills an oval specified by the bounding rectangle. See draw_oval.
76
+ #
47
77
  def fill_oval(x, y, width, height)
48
78
  @context.fillOval(x, y, width, height)
49
79
  end