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

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

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

origin: ch.sahits.game/OpenPatricianJavaFX

public String calculateEllipsis(Font font, final String text, double maxWidth){
  double ellipsisWidth = sizing.calculate(ELLIPSIS, font).getWidth();
  int guessNbChars = Math.min(sizing.guessNumberOfCharacters(maxWidth - ellipsisWidth, font), text.length());
  String substr;
  double currentCalculatedWidth = sizing.calculate(substr, font).getWidth();
    reducedNbCharacters = true;
    substr = text.substring(0, guessNbChars)+ELLIPSIS;
    currentCalculatedWidth = sizing.calculate(substr, font).getWidth();
        substr = text.substring(0, guessNbChars) + ELLIPSIS;
      currentCalculatedWidth = sizing.calculate(substr, font).getWidth();
origin: ch.sahits.game/OpenPatricianJavaFX

private Dimension2D calculateButtonDimensions(
    final OpenPatricianButton button) {
  Dimension2D dim = new TextSizingUtility().calculate(button.getText(), button.getFont());
  return new Dimension2D(dim.getWidth()*1.2, dim.getHeight()*1.2);
}
origin: ch.sahits.game/OpenPatricianJavaFX

/**
 * Create the labels and add them to the group.
 * @param g group the labels are added to
 * @param centerPoint central point around which the labels are placed.
 */
private void createAndAddLabels(Group g, final Point2D centerPoint) {
  List<String> values = control.valuesProperty();
  angles = new ArrayList<>(values.size());
  double angle = currentRotation.doubleValue() + 180;
  double step = (180.0 - 2 * currentRotation.doubleValue()) / (values.size() - 1);
  int radius = 120;
  for (String value : values) {
    angles.add(angle);
    Point2D basePoint = calculateBasePoint(centerPoint, radius, angle);
    Dimension2D dim = sizeing.calculate(value, control.getFont());
    Label l = new Label(value);
    l.setFont(control.getFont());
    l.getStyleClass().add("openPatricianSlider");
    l.setTranslateX(basePoint.getX() - dim.getWidth() * calculateMoveFactor(angle));
    l.setTranslateY(basePoint.getY() - dim.getHeight());
    g.getChildren().add(l);
    angle += step;
  }
  double initialAngle = Math.max(INITIAL_ROTATION, control.getSelectedIndex() * step);
  currentRotation.setValue(initialAngle);
}
/**
origin: ch.sahits.game/OpenPatricianJavaFX

private void calculateDimensions(OpenPatricianWoodenTextInput input) {
  Dimension2D dim = sizing.calculate(input.getSize(), input.getFont());
  double inputHeigth = textField.getHeight();
  width.set(dim.getWidth());
  height.set(Math.max(dim.getHeight(), inputHeigth));
  textField.setMaxSize(width.doubleValue(), height.doubleValue());
  setImage();
}
origin: ch.sahits.game/OpenPatricianJavaFX

private void calculateNewDimension(Font font) {
  final ObservableList<OpenPatricianSpinnerOptionDataModel> options = spinner.getOptions();
  Dimension2D dim4heigth = sizing.calculate(1, font);
  double maxWidth = spinner.getMaxWidth(); // This must be initialized before appended to the scene
  double destinationHeigth = dim4heigth.getHeight();
    Dimension2D dim4width = sizing.calculate(word, font);
    if (dim4width.getWidth() > dim.getWidth()) {
      double percentage = dim.getWidth() / dim4width.getWidth();
origin: ch.sahits.game/OpenPatricianJavaFX

private void calculateNewDimenstions(OpenPatricianRadioButton radioButton, String text, Image rbBG) {
  InputStream is;
  final int remainWidth = 28; // width that is left from the background
  final int destHight = 27;
  final double xStart = rbBG.getWidth();
  final int yStart = 0;
  Dimension2D dim = sizing.calculate(text, radioButton.getFont());
  double width = dim.getWidth();
  double destWidth = width-remainWidth + 10;
  String fileName = imageFactory.getFileNameExt(destWidth,destHight,remainWidth);
  is = getClass().getResourceAsStream(fileName);
  Image slab = new Image(is, destWidth, destHight, false, true);
  slabView.setImage(slab);
  slabView.translateXProperty().set(xStart);
  slabView.translateYProperty().set(yStart);
  double posX = destWidth/2+(xStart-remainWidth-10);
  label.translateXProperty().set(posX);
}
origin: ch.sahits.game/OpenPatricianJavaFX

  private void calculateDimensions(OpenPatricianDialogInput input) {
    Dimension2D dim = sizing.calculate(input.getSize(), input.getFont());
    width.set(dim.getWidth());
    height.set(dim.getHeight() + 10);
    textField.setMaxSize(width.doubleValue(), height.doubleValue());
  }
}
origin: ch.sahits.game/OpenPatricianJavaFX

public DisplayMessageOverlayLabelSkin(DisplayMessageOverlayLabel control, TextSizingUtility sizing) {
  super(control);
  textLength.set(sizing.calculate(control.getText(), control.getFont()).getWidth());
  control.fontProperty().addListener((observable, oldFont, newFont) ->
      textLength.set(sizing.calculate(control.getText(), newFont).getWidth()));
  control.textProperty().addListener((observable, oldText, newText) ->
      textLength.set(sizing.calculate(newText, control.getFont()).getWidth()));
  InputStream is = getClass().getResourceAsStream("waxButton-middle.png");
  waxBtnMiddle = new Image(is);
origin: ch.sahits.game/OpenPatricianJavaFX

public OpenPatricianWoodenTextInputSkin(OpenPatricianWoodenTextInput input) {
  super(input);
  textField = new TextField(input.getText());
  imgView = new ImageView();
  calculateDimensions(input);
  textField.textProperty().bindBidirectional(input.textProperty());
  textField.getStyleClass().add("openPatricianWoodenTextInput");
  Insets padding = textField.getPadding();
  Insets newPadding = new Insets(0, padding.getRight(), 0, padding.getLeft());
  textField.setPadding(newPadding);
  // Listeners
  input.sizeProperty().addListener((observable, oldValue, newValue) -> calculateDimensions(input));
  textField.heightProperty().addListener((observable, oldValue, newValue) -> {
    Dimension2D dim = sizing.calculate(input.getSize(), input.getFont());
    height.set(Math.max(dim.getHeight(), newValue.doubleValue()));
    setImage();
  });
  
  
  StackPane stack = new StackPane();
  stack.getChildren().addAll(imgView, textField);
  Group group = new Group(stack);
  group.setManaged(false);
  
  getChildren().add(group);
}
origin: ch.sahits.game/OpenPatricianJavaFX

  background.setWidth(newValue.getWidth());
  background.setHeight(newValue.getHeight());
  Dimension2D titleDim = textSize.calculate(control.getTitle(), openPatrician24);
  title.setLayoutX((newValue.getWidth() - titleDim.getWidth())/2 + frame.getInsetBackground().getX());
  titleBackground.setLayoutX((newValue.getWidth() - titleWidth)/2 + frame.getInsetBackground().getX() + 20);
  background.setLayoutX(newValue.getX());
  background.setLayoutY(newValue.getX());
  Dimension2D titleDim = textSize.calculate(control.getTitle(), openPatrician24);
  descBackground.setFitHeight(newValue.getHeight() - 1080 * localScale + 2);
  Dimension2D descDimension = textSize.calculate(control.getDescription(), openPatrician18);
  double wrappingWidth = Math.min(descDimension.getWidth(), newValue.getWidth());
  desc.setWrappingWidth(wrappingWidth);
});
title.textProperty().addListener((observable, oldValue, newValue) -> {
  Dimension2D titleDim = textSize.calculate(control.getTitle(), openPatrician24);
  title.setLayoutX((frame.getBackgroundDimension().getWidth() - titleDim.getWidth())/2 + frame.getInsetBackground().getX());
});
desc.textProperty().addListener((observable, oldValue, newValue) -> {
  Dimension2D descDimension = textSize.calculate(control.getDescription(), openPatrician18);
  double wrappingWidth = Math.min(descDimension.getWidth(), frame.getInnerDimension().getWidth());
  desc.setWrappingWidth(wrappingWidth);
ch.sahits.game.openpatrician.javafx.controlTextSizingUtilitycalculate

Javadoc

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.

Popular methods of TextSizingUtility

  • <init>
  • computeTextHeight
  • computeTextWidth
  • 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
  • Top plugins for WebStorm
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