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;
}
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));
}
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;
}
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());
}
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();
}
}
}
Aggregations