KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > comment > ITextMeasurement


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.text.comment;
12
13 /**
14  * The measurements can be used to compute how many times a first string has to
15  * be concatenated to reach the same width as a second string. This is usually
16  * with respect to a given font.
17  * <p>
18  * E.g., given a <code>firstString</code> and a <code>secondString</code>,
19  * with the following code:
20  * </p>
21  *
22  * <pre>
23  * int numberOfConcat= computeWidth(secondString) / computeWidth(firstString);
24  * String thirdString= &quot;&quot;;
25  * for (int i= 0; i &lt; numberOfConcat; i++)
26  * thirdString += firstString;
27  * </pre>
28  *
29  * <p>
30  * <code>computeWidth(thirdString) == computeWidth(secondString)</code> will
31  * be <code>true</code> (disregarding rounding errors due to integer
32  * arithmetic).
33  * </p>
34  *
35  * @since 3.0
36  */

37 public interface ITextMeasurement {
38
39     /**
40      * Width of the given string.
41      *
42      * @param string The considered string
43      * @return The measured width
44      */

45     public int computeWidth(String JavaDoc string);
46 }
47
Popular Tags