Search in sources :

Example 16 with Text

use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.

the class UndefinedExpressionColumnRenderer method renderCell.

@Override
public Group renderCell(final GridCell<String> cell, final GridBodyCellRenderContext context) {
    if (isToReturnNull(cell)) {
        return null;
    }
    final GridRenderer renderer = context.getRenderer();
    final GridRendererTheme theme = renderer.getTheme();
    final Text text = theme.getPlaceholderText();
    final String value = cell.getValue().getPlaceHolder();
    return internalRenderCell(cell, context, text, value);
}
Also used : GridRendererTheme(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme) Text(com.ait.lienzo.client.core.shape.Text) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)

Example 17 with Text

use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.

the class RendererUtils method getCenteredCellText.

public static Group getCenteredCellText(final GridBodyCellRenderContext context, final GridCell<String> gridCell) {
    final GridRenderer gridRenderer = context.getRenderer();
    final GridRendererTheme theme = gridRenderer.getTheme();
    final Group g = GWT.create(Group.class);
    String value = gridCell.getValue().getValue();
    final Text t;
    if (!StringUtils.isEmpty(value)) {
        t = theme.getBodyText();
    } else {
        value = gridCell.getValue().getPlaceHolder();
        t = theme.getPlaceholderText();
    }
    t.setText(value);
    t.setListening(false);
    t.setX(context.getCellWidth() / 2);
    t.setY(context.getCellHeight() / 2);
    g.add(t);
    return g;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridRendererTheme(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme) Text(com.ait.lienzo.client.core.shape.Text) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)

Example 18 with Text

use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.

the class PrimitiveTooltip method show.

public PrimitiveTooltip show(final IPrimitive<?> _glyph, final String text, final Point2D location, final double width, final double height, final Direction direction) {
    clearTimers();
    final IPrimitive<?> glyph = null != _glyph ? (IPrimitive<?>) _glyph.copy() : null;
    final Text descText = new Text(text).setFontSize(TEXT_SIZE).setFontStyle("").setFontFamily(TEXT_FAMILY).setStrokeWidth(TEXT_WIDTH).setStrokeColor(TEXT_COLOR).setStrokeAlpha(1);
    final BoundingBox descTextBB = descText.getBoundingBox();
    final double descTextBbW = descTextBB.getWidth();
    final double descTextBbH = descTextBB.getHeight();
    final double dw = (descTextBbW > width ? (descTextBbW + PADDING) : (width + PADDING));
    final double dh = height + descTextBbH + PADDING;
    final IPrimitive<?> decorator = buildDecorator(dw, dh, direction);
    final double w = dw + (isWest(direction) ? TRIANGLE_SIZE * 2 : 0);
    final double h = dh + (isNorth(direction) ? TRIANGLE_SIZE * 2 : 0);
    ;
    final Group g = new Group();
    g.add(decorator);
    if (null != glyph) {
        g.add(glyph);
    }
    g.add(descText);
    super.show(g, w, h, location.getX(), location.getY());
    double _x = (w / 2) + (isWest(direction) ? PADDING / 2 : 0);
    double _y = PADDING / 2 + (isNorth(direction) ? TRIANGLE_SIZE : 0);
    if (null != glyph) {
        glyph.setX(_x - (width / 2));
        glyph.setY(_y);
        _x += width;
        _y += height;
    }
    descText.setX(_x - (descTextBbW / 2));
    descText.setY(_y + descTextBbH);
    // Ensure text is on top.
    descText.moveToTop();
    canvasLayer.draw();
    startTimers();
    return this;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Text(com.ait.lienzo.client.core.shape.Text)

Example 19 with Text

use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.

the class WiresTextDecoratorTest method testSetTextWrapperStrategy.

private void testSetTextWrapperStrategy(final TextWrapperStrategy wrapperStrategy) {
    final Text text = decorator.getView();
    final ITextWrapper expectedWrapper = TextWrapperProvider.get(wrapperStrategy, text);
    decorator.setTextWrapper(wrapperStrategy);
    verify(decorator).setTextBoundaries(any(BoundingBox.class));
    assertEquals(expectedWrapper.getClass(), text.getWrapper().getClass());
}
Also used : ITextWrapper(com.ait.lienzo.client.core.shape.ITextWrapper) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Text(com.ait.lienzo.client.core.shape.Text)

Example 20 with Text

use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.

the class WiresTextDecoratorTest method assertBoundaries.

private void assertBoundaries(double width, double height) {
    final Text text = decorator.getView();
    final BoundingBox wrapBoundaries = ((TextBoundsWrap) text.getWrapper()).getWrapBoundaries();
    assertEquals(width, wrapBoundaries.getWidth(), 0d);
    assertEquals(height, wrapBoundaries.getHeight(), 0d);
    assertNotEquals(wrapBoundaries.getWidth(), 0d, 0.d);
    assertNotEquals(wrapBoundaries.getHeight(), 0d, 0d);
}
Also used : BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Text(com.ait.lienzo.client.core.shape.Text) TextBoundsWrap(com.ait.lienzo.client.core.shape.TextBoundsWrap)

Aggregations

Text (com.ait.lienzo.client.core.shape.Text)26 Group (com.ait.lienzo.client.core.shape.Group)10 GridRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)6 GridRendererTheme (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme)6 Test (org.junit.Test)5 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)4 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)3 TextBoundsWrap (com.ait.lienzo.client.core.shape.TextBoundsWrap)2 Field (java.lang.reflect.Field)2 GridBodyCellRenderContext (org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext)2 AnimationProperties (com.ait.lienzo.client.core.animation.AnimationProperties)1 IAnimation (com.ait.lienzo.client.core.animation.IAnimation)1 IAnimationCallback (com.ait.lienzo.client.core.animation.IAnimationCallback)1 IAnimationHandle (com.ait.lienzo.client.core.animation.IAnimationHandle)1 IPathClipper (com.ait.lienzo.client.core.shape.IPathClipper)1 ITextWrapper (com.ait.lienzo.client.core.shape.ITextWrapper)1 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 Node (com.ait.lienzo.client.core.shape.Node)1 TextLineBreakWrap (com.ait.lienzo.client.core.shape.TextLineBreakWrap)1 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)1