Search in sources :

Example 6 with Group

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

the class EditableHeaderUtilities method getUiHeaderRowIndex.

/**
 * Gets the header row index corresponding to the provided Canvas y-coordinate relative to the grid. Grid-relative coordinates
 * can be obtained from {@link INodeXYEvent} using {@link CoordinateUtilities#convertDOMToGridCoordinate(GridWidget, Point2D)}
 * @param gridWidget GridWidget to check.
 * @param column Column on which the even has occurred
 * @param cy y-coordinate relative to the GridWidget.
 * @return The header row index or null if the coordinate did not map to a header row.
 */
public static Integer getUiHeaderRowIndex(final GridWidget gridWidget, final GridColumn<?> column, final double cy) {
    final Group header = gridWidget.getHeader();
    final GridRenderer renderer = gridWidget.getRenderer();
    final BaseGridRendererHelper.RenderingInformation ri = gridWidget.getRendererHelper().getRenderingInformation();
    final double headerRowsYOffset = ri.getHeaderRowsYOffset();
    final double headerMinY = (header == null ? headerRowsYOffset : header.getY() + headerRowsYOffset);
    final double headerMaxY = (header == null ? renderer.getHeaderHeight() : renderer.getHeaderHeight() + header.getY());
    if (cy < headerMinY || cy > headerMaxY) {
        return null;
    }
    // Get header row index
    int uiHeaderRowIndex = 0;
    double offsetY = cy - headerMinY;
    final double headerRowsHeight = renderer.getHeaderRowHeight();
    final double headerRowHeight = headerRowsHeight / column.getHeaderMetaData().size();
    while (headerRowHeight < offsetY) {
        offsetY = offsetY - headerRowHeight;
        uiHeaderRowIndex++;
    }
    if (uiHeaderRowIndex < 0 || uiHeaderRowIndex > column.getHeaderMetaData().size() - 1) {
        return null;
    }
    return uiHeaderRowIndex;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 7 with Group

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

the class EditableHeaderUtilities method makeRenderContext.

public static GridBodyCellEditContext makeRenderContext(final GridWidget gridWidget, final BaseGridRendererHelper.RenderingInformation ri, final BaseGridRendererHelper.ColumnInformation ci, final Point2D rp, final int uiHeaderRowIndex) {
    final GridColumn<?> column = ci.getColumn();
    final GridRenderer renderer = gridWidget.getRenderer();
    final Group header = gridWidget.getHeader();
    final double headerRowsYOffset = ri.getHeaderRowsYOffset();
    final double headerMinY = (header == null ? headerRowsYOffset : header.getY() + headerRowsYOffset);
    final double headerRowHeight = renderer.getHeaderRowHeight() / column.getHeaderMetaData().size();
    final double cellX = gridWidget.getAbsoluteX() + ci.getOffsetX();
    final double cellY = gridWidget.getAbsoluteY() + headerMinY + (headerRowHeight * uiHeaderRowIndex);
    final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = ri.getFloatingBlockInformation();
    final double floatingX = floatingBlockInformation.getX();
    final double floatingWidth = floatingBlockInformation.getWidth();
    final double clipMinX = gridWidget.getAbsoluteX() + floatingX + floatingWidth;
    final double clipMinY = gridWidget.getAbsoluteY();
    // Check and adjust for blocks of columns sharing equal HeaderMetaData
    double blockCellX = cellX;
    double blockCellWidth = column.getWidth();
    final List<GridColumn<?>> gridColumns = ri.getAllColumns();
    final GridColumn.HeaderMetaData clicked = column.getHeaderMetaData().get(uiHeaderRowIndex);
    // Walk backwards to block start
    if (ci.getUiColumnIndex() > 0) {
        int uiLeadColumnIndex = ci.getUiColumnIndex() - 1;
        GridColumn<?> lead = gridColumns.get(uiLeadColumnIndex);
        while (uiLeadColumnIndex >= 0 && isSameHeaderMetaData(clicked, lead.getHeaderMetaData(), uiHeaderRowIndex)) {
            blockCellX = blockCellX - lead.getWidth();
            blockCellWidth = blockCellWidth + lead.getWidth();
            if (--uiLeadColumnIndex >= 0) {
                lead = gridColumns.get(uiLeadColumnIndex);
            }
        }
    }
    // Walk forwards to block end
    if (ci.getUiColumnIndex() < gridColumns.size() - 1) {
        int uiTailColumnIndex = ci.getUiColumnIndex() + 1;
        GridColumn<?> tail = gridColumns.get(uiTailColumnIndex);
        while (uiTailColumnIndex < gridColumns.size() && isSameHeaderMetaData(clicked, tail.getHeaderMetaData(), uiHeaderRowIndex)) {
            blockCellWidth = blockCellWidth + tail.getWidth();
            tail = gridColumns.get(uiTailColumnIndex);
            if (++uiTailColumnIndex < gridColumns.size()) {
                tail = gridColumns.get(uiTailColumnIndex);
            }
        }
    }
    return new GridBodyCellEditContext(blockCellX, cellY, blockCellWidth, headerRowHeight, clipMinY, clipMinX, uiHeaderRowIndex, ci.getUiColumnIndex(), floatingBlockInformation.getColumns().contains(column), gridWidget.getViewport().getTransform(), renderer, Optional.of(rp));
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridBodyCellEditContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 8 with Group

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

the class ExpressionEditorColumnRenderer method renderCell.

@Override
public Group renderCell(final GridCell<Optional<BaseExpressionGrid>> cell, final GridBodyCellRenderContext context) {
    if (cell == null || cell.getValue() == null) {
        return null;
    }
    final Group g = GWT.create(Group.class);
    if (cell.getValue() != null && cell.getValue() instanceof ExpressionCellValue) {
        final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue();
        ecv.getValue().ifPresent(editor -> {
            g.add(editor.setX(editor.getPadding()).setY(editor.getPadding()));
            registry.register(editor);
        });
    }
    return g;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group)

Example 9 with Group

use of com.ait.lienzo.client.core.shape.Group in project lienzo-core by ahome-it.

the class WiresManager method setWiresShapeHandler.

public static void setWiresShapeHandler(final WiresShape shape, final HandlerRegistrationManager registrationManager, final WiresShapeHandler handler) {
    final Group group = shape.getGroup();
    registrationManager.register(group.addNodeMouseClickHandler(handler));
    registrationManager.register(group.addNodeMouseDownHandler(handler));
    registrationManager.register(group.addNodeMouseUpHandler(handler));
    registrationManager.register(group.addNodeDragEndHandler(handler));
    group.setDragConstraints(handler);
    shape.setWiresShapeControl(handler.getControl());
}
Also used : Group(com.ait.lienzo.client.core.shape.Group)

Example 10 with Group

use of com.ait.lienzo.client.core.shape.Group in project lienzo-core by ahome-it.

the class WiresShapeControlHandleList method updateParentLocation.

protected void updateParentLocation() {
    if ((null == m_parent) && (null != getGroup().getLayer())) {
        m_parent = new Group();
        getGroup().getLayer().add(m_parent);
    }
    if (null == m_parent) {
        return;
    }
    final Point2D p = getGroup().getComputedLocation();
    m_parent.setX(p.getX());
    m_parent.setY(p.getY());
    m_parent.moveToTop();
    for (final WiresShape child : m_wires_shape.getChildShapes()) {
        final WiresShapeControlHandleList list = child.getControls();
        if (null != list) {
            list.updateParentLocation();
        }
    }
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Point2D(com.ait.lienzo.client.core.types.Point2D)

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