Class: JavaColor

Inherits:
BaseColor show all
Defined in:
lib/libisi/color/java.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseColor

#adjust, #blue, #blue=, #brightness, #green, #green=, #hue, #object, #red, #red=, #rgb, #rgb=, #saturation

Constructor Details

#initialize(options = {}) ⇒ JavaColor

Returns a new instance of JavaColor.



29
30
31
32
33
34
35
36
37
38
# File 'lib/libisi/color/java.rb', line 29

def initialize(options = {})
  # create javacolor out of color-tools
  options = Color.create("colortools",options) if
    options.class == String or options.class == Symbol

  raise "Cannot create color out of #{options}" unless
    options.respond_to?(:rgb)
  rgb = options.rgb
  @java_object = JavaBridge.import("java.awt.Color").new(*rgb)    
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



23
24
25
# File 'lib/libisi/color/java.rb', line 23

def method_missing(m, *args)
  @obj.send(m, *args)
end

Instance Attribute Details

#java_objectObject

Returns the value of attribute java_object.



27
28
29
# File 'lib/libisi/color/java.rb', line 27

def java_object
  @java_object
end

Instance Method Details

#htmlObject



40
41
42
# File 'lib/libisi/color/java.rb', line 40

def html
  "#" + [@java_object.getRed.to_s(16),@java_object.getGreen.to_s(16),@java_object.getBlue.to_s(16)].map {|v| v.ljust(2,"0")}.join
end