Class: Java::javafx::animation::Timeline

Inherits:
Object
  • Object
show all
Extended by:
JRubyFX::Utils::CommonConverters
Includes:
JRubyFX::DSL
Defined in:
lib/jrubyfx/core_ext/timeline.rb

Overview

JRubyFX DSL extensions for JavaFX animation Timelines

Constant Summary

Constants included from JRubyFX::Utils::CommonConverters

JRubyFX::Utils::CommonConverters::ARG_CONVERTER_SUFFIX, JRubyFX::Utils::CommonConverters::CONVERTERS, JRubyFX::Utils::CommonConverters::NAME_TO_COLORS

Constants included from JRubyFX::DSL

JRubyFX::DSL::ENUM_OVERRIDES, JRubyFX::DSL::NAME_TO_CLASSES

Constants included from JRubyFX

JRubyFX::VERSION

Constants included from JRubyFX::FXImports

JRubyFX::FXImports::JFX_CLASS_HIERARCHY

Instance Method Summary collapse

Methods included from JRubyFX::Utils::CommonConverters

animation_converter_for, converter_for, enum_converter, map_converter, map_enums, set_overrides_for

Methods included from JRubyFX::DSL

included, inject_enum_method_converter, inject_symbol_converter, load_dsl, load_enum_converter, #method_missing

Methods included from JRubyFX

#build, #run_later, #with

Methods included from JRubyFX::Utils::CommonUtils

#attempt_conversion, #populate_properties, #split_args_from_properties

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JRubyFX::DSL

Instance Method Details

#animate(prop, args) ⇒ Object

call-seq:

animate myProperty, from_duration => to_duration, start_value => next_value
animate myProperty, from_duration => [with_duration, ..., to_duration], start_value => [next_value, ...]

Animates a given JavaFX property over the given duration, using the given values as keyFrames

Examples

animate translateXProperty, 0.sec => [100.ms, 1.sec], 0 => [500, 200]
animate translateYProperty, 0.sec => 1.sec, 0 => 200


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jrubyfx/core_ext/timeline.rb', line 40

def animate(prop, args)
  time = []
  values = []
  # detect our time
  args.each do |key, value|
    if key.is_a? Duration
      time << [key, value]
      time.flatten!
    else #assume values
      values << [key, value]
      values.flatten!
    end
  end
  # add the keyframes
  [time.length, values.length].min.times do |i|
    key_frame(time[i], key_value(prop, values[i]))
  end
end