use of javafx.scene.control.OverrunStyle in project lttng-scope by lttng.
the class TimeGraphStateLayer method prepareTimeGrahLabelsContents.
private Node prepareTimeGrahLabelsContents(Collection<StateRectangle> stateRectangles, TimeRange windowRange) {
double minX = getWidget().timestampToPaneXPos(windowRange.getStartTime());
final String ellipsisStr = DebugOptions.ELLIPSIS_STRING;
final double ellipsisWidth = getWidget().getDebugOptions().getEllipsisWidth();
final Font textFont = getWidget().getDebugOptions().stateLabelFont.get();
final OverrunStyle overrunStyle = OverrunStyle.ELLIPSIS;
final Color textColor = Color.WHITE;
/* Requires a ~2 pixels adjustment to be centered on the states */
final double yOffset = TimeGraphWidget.ENTRY_HEIGHT / 2.0 + 2.0;
Collection<Node> texts = stateRectangles.stream().filter(stateRect -> stateRect.getWidth() > ellipsisWidth).filter(stateRect -> stateRect.getStateInterval().getLabel() != null).map(stateRect -> {
String labelText = requireNonNull(stateRect.getStateInterval().getLabel());
/* A small offset looks better here */
double textX = Math.max(minX, stateRect.getX()) + 4.0;
double textY = stateRect.getY() + yOffset;
double rectEndX = stateRect.getX() + stateRect.getWidth();
double minWidth = rectEndX - textX;
String ellipsedText = JfxTextUtils.computeClippedText(textFont, labelText, minWidth, overrunStyle, ellipsisStr);
if (ellipsedText.equals(ellipsisStr)) {
return null;
}
Text text = new Text(textX, textY, ellipsedText);
text.setFont(textFont);
text.setFill(textColor);
return text;
}).filter(Objects::nonNull).collect(Collectors.toList());
return new Group(texts);
}
Aggregations