@Override public BoundingBox getBoundingBox() { double width = 0; final String text = textSupplier.get(); if ((text == null) || text.isEmpty()) { return new BoundingBox(); } final String[] lines = text.split("\\r?\\n"); for (final String line : lines) { final double w = getBoundingBoxForString(line).getWidth(); width = Math.max(width, w); } double height = getBoundingBoxForString(text).getHeight(); height = height * lines.length; return new BoundingBox().addX(0).addX(width).addY(0).addY(height); }
@Override public BoundingBox getBoundingBox() { double width = 0; final String text = textSupplier.get(); if ((text == null) || text.isEmpty()) { return new BoundingBox(); } final String[] lines = text.split("\\r?\\n"); for (final String line : lines) { final double w = getBoundingBoxForString(line).getWidth(); width = Math.max(width, w); } double height = getBoundingBoxForString(text).getHeight(); height = height * lines.length; return new BoundingBox().addX(0).addX(width).addY(0).addY(height); }
@Override public BoundingBox getBoundingBox() { final String[] words = textSupplier.get().split("\\s"); if (words.length < 1) { return wrapBoundaries; } int numOfLines = 1; final double width = wrapBoundaries.getWidth(); final StringBuilder nextLine = new StringBuilder(words[0]); for (int i = 1; i < words.length; i++) { if (getBoundingBoxForString(nextLine + " " + words[i]).getWidth() <= wrapBoundaries.getWidth()) { nextLine.append(" ").append(words[i]); } else { nextLine.setLength(words[i].length()); nextLine.replace(0, words[i].length(), words[i]); numOfLines++; } } double height = getBoundingBoxForString(textSupplier.get()).getHeight(); height = height * numOfLines; return new BoundingBox().addX(0).addX(width).addY(0).addY(height); }
@Override public BoundingBox getBoundingBox() { double width = 0; final String text = textSupplier.get(); if ((text == null) || text.isEmpty()) { return new BoundingBox(); } final String[] lines = text.split("\\r?\\n"); for (final String line : lines) { final double w = getBoundingBoxForString(line).getWidth(); width = Math.max(width, w); } double height = getBoundingBoxForString(text).getHeight(); height = height * lines.length; return new BoundingBox().addX(0).addX(width).addY(0).addY(height); }
@Override public BoundingBox getBoundingBox() { final String[] words = textSupplier.get().split("\\s"); if (words.length < 1) { return wrapBoundaries; } int numOfLines = 1; final double width = wrapBoundaries.getWidth(); final StringBuilder nextLine = new StringBuilder(words[0]); for (int i = 1; i < words.length; i++) { if (getBoundingBoxForString(nextLine + " " + words[i]).getWidth() <= wrapBoundaries.getWidth()) { nextLine.append(" ").append(words[i]); } else { nextLine.setLength(words[i].length()); nextLine.replace(0, words[i].length(), words[i]); numOfLines++; } } double height = getBoundingBoxForString(textSupplier.get()).getHeight(); height = height * numOfLines; return new BoundingBox().addX(0).addX(width).addY(0).addY(height); }
@Override public BoundingBox getBoundingBox() { final String[] words = textSupplier.get().split("\\s"); if (words.length < 1) { return wrapBoundaries; } int numOfLines = 1; final double width = wrapBoundaries.getWidth(); final StringBuilder nextLine = new StringBuilder(words[0]); for (int i = 1; i < words.length; i++) { if (getBoundingBoxForString(nextLine + " " + words[i]).getWidth() <= wrapBoundaries.getWidth()) { nextLine.append(" ").append(words[i]); } else { nextLine.setLength(words[i].length()); nextLine.replace(0, words[i].length(), words[i]); numOfLines++; } } double height = getBoundingBoxForString(textSupplier.get()).getHeight(); height = height * numOfLines; return new BoundingBox().addX(0).addX(width).addY(0).addY(height); }