Sha256: 43d0f8e996adfc43972bd988a216f150e512c8a886a363cd96600ca1a9daf65d

Contents?: true

Size: 825 Bytes

Versions: 6

Compression:

Stored size: 825 Bytes

Contents

module Clevic

class Field
  # Convert a color name understood by java.awt.Color,
  # or a 0xddccee style string to a java.awt.Color
  def string_or_color( s_or_c )
    case s_or_c
    when NilClass
      nil
    when java.awt.Color
      s_or_c
    else
      color_string = s_or_c.to_s
      if java.awt.Color.constants.include?( color_string.upcase )
        eval( "java.awt.Color::#{color_string.upcase}" )
      elsif
        color_string[0..1] == "0x"
        java.awt.Color.decode( color_string )
      else
        nil
      end
    end
  end
  
  def swing_alignment
    case alignment
    when :left; javax.swing.SwingConstants::LEFT
    when :right; javax.swing.SwingConstants::RIGHT
    when :centre, :center; javax.swing.SwingConstants::CENTER
    else javax.swing.SwingConstants::LEADING
    end
  end
end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
clevic-0.13.0.b9 lib/clevic/swing/field.rb
clevic-0.13.0.b6 lib/clevic/swing/field.rb
clevic-0.13.0.b5 lib/clevic/swing/field.rb
clevic-0.13.0.b3 lib/clevic/swing/field.rb
clevic-0.13.0.b2 lib/clevic/swing/field.rb
clevic-0.13.0.b1 lib/clevic/swing/field.rb