congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TextSizingUtility.computeTextWidth
Code IndexAdd Tabnine to your IDE (free)

How to use
computeTextWidth
method
in
ch.sahits.game.openpatrician.javafx.control.TextSizingUtility

Best Java code snippets using ch.sahits.game.openpatrician.javafx.control.TextSizingUtility.computeTextWidth (Showing top 4 results out of 315)

origin: ch.sahits.game/OpenPatricianJavaFX

/**
 * Guess the number of characters that can be displayed in <code>destWidth</code>.
 * The number is guessed as an arbitrary width per character for the font is assumed.
 * @param destWidth destination with
 * @param font to used for the text
 * @return number of characters that should match into <code>destWidth</code>
 */
public int guessNumberOfCharacters(double destWidth, Font font) {
  double width = computeTextWidth(font, "n", Double.MAX_VALUE);
  return (int) Math.floor(destWidth/(width*0.8));
}
/**
origin: ch.sahits.game/OpenPatricianJavaFX

/**
 * Calculate the dimensions of a string using the font with the number of characters.
 * The height  and width are the maximum value, the width of a character is an average value.
 * @param size number of carachters for wich to calculate the dimensions
 * @param font to be used
 * @return dimensions of a String containing Tg to calculate the heigth and n for the width calculation.
 */
@Override
public Dimension2D calculate(int size, Font font) {
  double height = computeTextHeight(font, "Tg", Double.MAX_VALUE);
  double width = computeTextWidth(font, "n", Double.MAX_VALUE);
  return new Dimension2D(width*size*.8, height*1.2);
}
origin: ch.sahits.game/OpenPatricianJavaFX

/**
 * Calculate the dimensions of a string using the font with the characters in the string.
 * The height and width are the maximum value. The text will not be wrapped.
 * @param text for which to calculate the dimensions
 * @param font to be used for the calculation
 * @return Bounding box for the text using font.
 */
@Override
public Dimension2D calculate(String text, Font font) {
  double height = computeTextHeight(font, text, Double.MAX_VALUE);
  double width = computeTextWidth(font, text, Double.MAX_VALUE);
  return new Dimension2D(width, height*1.2);
}
origin: ch.sahits.game/OpenPatricianJavaFX

double lineWidth = sizing.computeTextWidth(font, oneLine.toString(), Double.MAX_VALUE);
  lineWidth = sizing.computeTextWidth(font, l.getLine(), Double.MAX_VALUE);
  if (!isLineTooLong(lineWidth)) {
  lineWidth = sizing.computeTextWidth(font, word, Double.MAX_VALUE);
  if (isLineTooLong(lineWidth)) {
    if (!tokenizer.hasMoreTokens()) {
ch.sahits.game.openpatrician.javafx.controlTextSizingUtilitycomputeTextWidth

Popular methods of TextSizingUtility

  • <init>
  • calculate
    Calculate the dimensions of a string using the font with the characters in the string. The height an
  • computeTextHeight
  • guessNumberOfCharacters
    Guess the number of characters that can be displayed in destWidth. The number is guessed as an arbit

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now