Permalink
Browse files

new method

  • Loading branch information...
1 parent a4f0fe4 commit f31899cf16cf4e5149e17aaf62c990d71a0ad652 @rdp committed Apr 13, 2012
Showing with 17 additions and 8 deletions.
  1. +17 −8 lib/create_icon_from_numbers.rb
@@ -6,15 +6,20 @@ module CreateIconFromNumbers
include_package 'java.awt.font'; [TextLayout]
include_package 'javax.swing'; [JFrame, JLabel]
- def self.get_letters_as_icon letters, size=64
+ def self.assign_icons_to_jframe jframe, title_bar_text, group_icon_and_alt_tab_icon_text
+ jframe.icon_images = [get_letters_as_icon(title_bar_text, 20), get_letters_as_icon(group_icon_and_alt_tab_icon_text, 40)]
+ end
+
+ def self.get_letters_as_icon letters, size
letters = letters.to_s
- image = BufferedImage.new(size, size, BufferedImage::TYPE_INT_ARGB);
- graphics = g = image.createGraphics()
-# g.setColor(Color::WHITE )
-# g.fillRect(0,0,SIZE,SIZE)
-
+ image = BufferedImage.new(size, size, BufferedImage::TYPE_INT_ARGB);
+ graphics = g = image.createGraphics
+
=begin needed?
+ # g.setColor(Color::WHITE )
+ # g.fillRect(0,0,SIZE,SIZE)
+
for (int col = 0; col < ICON_DIMENSION; col++) {
for (int row = 0; row < ICON_DIMENSION; row++) {
image.setRGB(col, row, 0x0);
@@ -48,8 +53,12 @@ def self.get_letters_as_icon letters, size=64
class J < javax.swing.JFrame
def initialize
super
- self.icon_images = (1..128).map {|n| CreateIconFromNumbers.get_letters_as_icon(n, n.to_i)}
+ icon_numbers = (1..128).map{|n| n}.reverse
+ self.icon_images = icon_numbers.map {|n| CreateIconFromNumbers.get_letters_as_icon(n, n.to_i)}
end
end
- J.new.show
+ a = J.new
+ a.show
+ CreateIconFromNumbers.assign_icons_to_jframe a, 'title_bar_text', 'group_icon_and_alt_tab_icon_text'
+
end

0 comments on commit f31899c

Please sign in to comment.