Solved

how do i justify text with math

Posted on 2008-10-21
2
626 Views
Last Modified: 2012-05-05
I need to write an algorithm that will full jusity a number of text links along a line in action script.  i can read any programming language so information in any language is appreciated.

The idea is this:

if therer are 5 links of various sizes that are situated on a menu that can be 600 pixels wide, i need  to center then and adjust the spaces between each item such that the fill the available horizontal area.  Dont worry about what happens if they over fill the available space.
0
Comment
Question by:Edanisko
2 Comments
 
LVL 9

Accepted Solution

by:
jhshukla earned 500 total points
ID: 22772524
>> text links along a line in action script
AFAIK, action script has something to do with flash. So why in C??

that aside, here are the things you will need:
(1) some sort of graphics object or class that can give you dimensions of a given text string.
(2) the fonts (+ size, bold/italics decoration)
(3) the actual text you want to display

use the above three to get the sizes of links and add them to get total size : call it total_size
(600 - total_size)/(num_items - 1) = spacing you need between two links

We will need more info on what environment you are developing in to write pseudo code.
0
 
LVL 2

Author Comment

by:Edanisko
ID: 22772620
Yes.

there here it is in AS3
for(var i:int=0; i<=_NavItems.length-1;i++){
	if (i==0){
		_NavItems[i].x = 0;
	} else {
		_NavItems[i].x =amountOfSpaceBetweenLinks + _NavItems[i-1].x + _NavItems[i-1].width;
	}
	_NavItems[i].visible=true;
	
}

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 46
Unhandled exception type Exception 18 43
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 58
hashmap order 17 37
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question