Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:01:57+00:00 2026-06-17T23:01:57+00:00

I’m working on word cloud generation. My words should appear in a rectangle of

  • 0

I’m working on word cloud generation.

My words should appear in a rectangle of (0, 0, w, h), where w is the max width and h is the max height.

I already have an algorithm for generating the word cloud, but sometimes the words go outside the bounds of the rectangle or there is too much unused space. The real bounds of a word cloud are of (0, 0, maxX, maxY).

My idea of scaling looks like this:

if (maxX > w) then
    if (maxY > h) then
        if (maxX / w) > (maxY / h) then
            scale(w / maxX)
        else
            scale(h / maxY)
        end if
    else
        scale(w / maxX)
    end if
else if (maxY > h) then
    scale(h / maxY)
else if ((maxX < w) and (maxY < h)) then
    if (maxX / w) > (maxY / h) then
        scale(w / maxX)
    else
        scale(h / maxY)
    end if
end if

Let’s suppose I have a word in the rectangle of (x1, y1, x2, y2). If I call scale(1.5), then the new position of the rectangle will be (1.5 * x1, 1.5 * y1, 1.5 * x2, 1.5 * y2). This is very nice and simple, but I have a problem with this:

A word previously had a size of S1 and was situated on coordinates (x1, y1, x2, y2). If I want to scale it by r, then the new coordinates will be of (r * x1, r * y1, r * x2, r * y2). Question: If I know that the word will be r * bigger/smaller, then what is the value of S2 size which would be the new size of the word after scaling with a rate of r?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:01:58+00:00Added an answer on June 17, 2026 at 11:01 pm

    OK, I have figured out this one. This function calculates the scale:

    public static void scale(double rate)
    {
        for (int keyIndex = 0; keyIndex < keys.length; keyIndex++)
        {
            hashMap.get(keys[keyIndex]).setSize((int)(Math.sqrt(Math.pow(hashMap.get(keys[keyIndex]).getSize(), 2) * (rate * rate))));
        }
    }
    

    And of course, the positions of the words have to be updated accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.