Search in sources :

Example 1 with OverrunStyle

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);
}
Also used : TimeRange(com.efficios.jabberwocky.common.TimeRange) IntStream(java.util.stream.IntStream) JfxTextUtils(org.lttng.scope.common.jfx.JfxTextUtils) StateRectangle(org.lttng.scope.views.timeline.widgets.timegraph.StateRectangle) TimeGraphTreeElement(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement) OverrunStyle(javafx.scene.control.OverrunStyle) FutureTask(java.util.concurrent.FutureTask) Function(java.util.function.Function) TimeGraphModelStateProvider(com.efficios.jabberwocky.views.timegraph.model.provider.states.TimeGraphModelStateProvider) Objects.requireNonNull(java.util.Objects.requireNonNull) TimeGraphTreeRender(com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender) TimeGraphWidget(org.lttng.scope.views.timeline.widgets.timegraph.TimeGraphWidget) Color(javafx.scene.paint.Color) VerticalPosition(org.lttng.scope.views.timeline.widgets.timegraph.VerticalPosition) Node(javafx.scene.Node) Collection(java.util.Collection) Font(javafx.scene.text.Font) Group(javafx.scene.Group) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) Text(javafx.scene.text.Text) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Stream(java.util.stream.Stream) JfxUtils(org.lttng.scope.common.jfx.JfxUtils) TimeGraphStateRender(com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender) Collections(java.util.Collections) DebugOptions(org.lttng.scope.views.timeline.DebugOptions) OverrunStyle(javafx.scene.control.OverrunStyle) Group(javafx.scene.Group) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Text(javafx.scene.text.Text) Font(javafx.scene.text.Font)

Aggregations

TimeRange (com.efficios.jabberwocky.common.TimeRange)1 TimeGraphModelStateProvider (com.efficios.jabberwocky.views.timegraph.model.provider.states.TimeGraphModelStateProvider)1 TimeGraphStateRender (com.efficios.jabberwocky.views.timegraph.model.render.states.TimeGraphStateRender)1 TimeGraphTreeElement (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeElement)1 TimeGraphTreeRender (com.efficios.jabberwocky.views.timegraph.model.render.tree.TimeGraphTreeRender)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 FutureTask (java.util.concurrent.FutureTask)1 Function (java.util.function.Function)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 Platform (javafx.application.Platform)1 Group (javafx.scene.Group)1 Node (javafx.scene.Node)1 OverrunStyle (javafx.scene.control.OverrunStyle)1