Search in sources :

Example 46 with Group

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

the class RendererUtils method getEditableHeaderPlaceHolderText.

public static Group getEditableHeaderPlaceHolderText(final EditableHeaderMetaData headerMetaData, final GridHeaderColumnRenderContext context, final double blockWidth, final double blockHeight) {
    final Group headerGroup = GWT.create(Group.class);
    headerMetaData.getPlaceHolder().ifPresent(placeHolder -> {
        final GridRenderer renderer = context.getRenderer();
        final GridRendererTheme theme = renderer.getTheme();
        final Text text = theme.getPlaceholderText();
        text.setX(blockWidth / 2);
        text.setY(blockHeight / 2);
        text.setText(placeHolder);
        text.setListening(false);
        headerGroup.add(text);
    });
    return headerGroup;
}
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 47 with Group

use of com.ait.lienzo.client.core.shape.Group 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 48 with Group

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

the class EditableHeaderUtilities method getEditableHeaderContent.

public static Group getEditableHeaderContent(final Supplier<Group> defaultHeaderContentSupplier, final List<GridColumn.HeaderMetaData> headerMetaData, final GridHeaderColumnRenderContext context, final int headerRowIndex, final double blockWidth, final double rowHeight) {
    final Group headerGroup = GWT.create(Group.class);
    if (headerRowIndex >= headerMetaData.size()) {
        return headerGroup;
    }
    final GridColumn.HeaderMetaData headerRowMetaData = headerMetaData.get(headerRowIndex);
    if (headerRowMetaData instanceof EditableHeaderMetaData) {
        final EditableHeaderMetaData editableHeaderMetaData = (EditableHeaderMetaData) headerRowMetaData;
        if (EditableHeaderUtilities.isPlaceHolderToBeShown(editableHeaderMetaData)) {
            return editableHeaderMetaData.renderPlaceHolder(context, blockWidth, rowHeight);
        }
        return ((EditableHeaderMetaData) headerRowMetaData).render(context, blockWidth, rowHeight);
    }
    return defaultHeaderContentSupplier.get();
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Example 49 with Group

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

the class WiresShapeViewTest method testMove.

@Test
public void testMove() {
    final LayoutContainer container = mock(LayoutContainer.class);
    final Group group = mock(Group.class);
    when(container.getGroup()).thenReturn(group);
    when(container.refresh()).thenReturn(container);
    when(container.execute()).thenReturn(container);
    when(container.setOffset(any(Point2D.class))).thenReturn(container);
    when(container.setSize(anyDouble(), anyDouble())).thenReturn(container);
    this.tested = new WiresShapeView(PATH, container);
    tested.moveToTop();
    tested.moveToBottom();
    tested.moveUp();
    tested.moveDown();
    verify(group, times(1)).moveToTop();
    verify(group, times(1)).moveToBottom();
    verify(group, times(1)).moveUp();
    verify(group, times(1)).moveDown();
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) LayoutContainer(com.ait.lienzo.client.core.shape.wires.LayoutContainer) Point2D(com.ait.lienzo.client.core.types.Point2D) Test(org.junit.Test)

Example 50 with Group

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

the class LienzoShapeGlyphRendererTest method testRender.

@Test
@SuppressWarnings("unchecked")
public void testRender() {
    final Group group = tested.render(glyph, 150d, 351d);
    assertEquals(this.group, group);
    verify(this.group, times(1)).setScale(eq(1d), eq(1d));
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Test(org.junit.Test)

Aggregations

Group (com.ait.lienzo.client.core.shape.Group)66 Test (org.junit.Test)17 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)10 Before (org.junit.Before)10 Text (com.ait.lienzo.client.core.shape.Text)9 GridRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)8 Layer (com.ait.lienzo.client.core.shape.Layer)7 Point2D (com.ait.lienzo.client.core.types.Point2D)7 Command (org.uberfire.mvp.Command)6 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)4 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)4 Line (com.ait.lienzo.client.core.shape.Line)3 ArrayList (java.util.ArrayList)3 SVGContainer (org.kie.workbench.common.stunner.svg.client.shape.view.SVGContainer)3 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)3 GridRendererTheme (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme)3 IPathClipper (com.ait.lienzo.client.core.shape.IPathClipper)2 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)2 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)2 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)2