shoeset

Check-in [2e3ea62bd5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Changed formatting only
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2e3ea62bd5001cb0bd88fd8d5bf75f900b79a80dc4006d212b6b4b8b93710346
User & Date: i5ivem@gmail.com 2010-03-16 15:27:23
Original User & Date: i5ivem@gmail.com 2010-03-16 15:27:24
Context
2010-03-16
15:27
First release candidate of App * API Key and Shared secret in external file * Separated app into different methods * This allows redrawing. If new set is selected redraws progress bar and tag cloud * Added logout method to clear token * Other GUI refinements: - Click on username to show/hide token - logout button - progress bar nudged slightly to right check-in: 73a783ca97 user: i5ivem@gmail.com tags: trunk, v0.0.1
15:27
Changed formatting only check-in: 2e3ea62bd5 user: i5ivem@gmail.com tags: trunk
15:27
Progress bar and sleep interval added check-in: c532927408 user: i5ivem@gmail.com tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to cloud.rb.

1
2
3
4

5
6
7
8

9
10
11
12
13
14
15
..
17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
42

43


44
45
46
# Taken from http://snippets.dzone.com/posts/show/6027
# Tweaked to return values suitable for Shoes (lines 38-40, etc)
class TagCloud
    

  def initialize(words)
    @wordcount = count_words(words)
  end
  

  def count_words(words)
    wordcount = {}
    words.split(/\s/).each do |word| 
      word.downcase!
      if word.strip.size > 0
        unless wordcount.key?(word.strip)
          wordcount[word.strip] = 0
................................................................................
          wordcount[word.strip] = wordcount[word.strip] + 1
        end
      end
    end
    wordcount
  end
  

  def font_ratio(wordcount={})
    min, max = 1000000, -1000000
    wordcount.each_key do |word|
      max = wordcount[word] if wordcount[word] > max
      min = wordcount[word] if wordcount[word] < min
    end
    18.0 / (max - min)
  end
  

  def build
    cloud = String.new
    ratio = font_ratio(@wordcount)
	color = ["steelblue", "deeppink"]
    @wordcount.each_key do |word|
      font_size = (10 + (@wordcount[word] * ratio)).round #must round for shoes since pixels
	  cloud << %Q{para "#{word}", :size => #{font_size}, :stroke => #{color[0]}; }
	  color.reverse! #alternate between colours
    end
    cloud

  end


end






>




>







 







>









>










>

>
>



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
..
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Taken from http://snippets.dzone.com/posts/show/6027
# Tweaked to return values suitable for Shoes (lines 38-40, etc)
class TagCloud
    

  def initialize(words)
    @wordcount = count_words(words)
  end
  

  def count_words(words)
    wordcount = {}
    words.split(/\s/).each do |word| 
      word.downcase!
      if word.strip.size > 0
        unless wordcount.key?(word.strip)
          wordcount[word.strip] = 0
................................................................................
          wordcount[word.strip] = wordcount[word.strip] + 1
        end
      end
    end
    wordcount
  end
  

  def font_ratio(wordcount={})
    min, max = 1000000, -1000000
    wordcount.each_key do |word|
      max = wordcount[word] if wordcount[word] > max
      min = wordcount[word] if wordcount[word] < min
    end
    18.0 / (max - min)
  end
  

  def build
    cloud = String.new
    ratio = font_ratio(@wordcount)
	color = ["steelblue", "deeppink"]
    @wordcount.each_key do |word|
      font_size = (10 + (@wordcount[word] * ratio)).round #must round for shoes since pixels
	  cloud << %Q{para "#{word}", :size => #{font_size}, :stroke => #{color[0]}; }
	  color.reverse! #alternate between colours
    end
    cloud
	#debug cloud
  end


end