Search in sources :

Example 61 with Group

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

the class ColumnHeaderPopOverImpl method getScreenY.

private int getScreenY(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter) {
    final GridWidget gridWidget = dtPresenter.getView();
    final double gy = gridWidget.getY();
    final GridLayer layer = modellerView.getGridLayerView();
    final int containerY = layer.getDomElementContainer().getAbsoluteTop();
    final double vy = layer.getVisibleBounds().getY();
    final Transform t = layer.getViewport().getTransform();
    final Group header = gridWidget.getHeader();
    final double headerHeight = gridWidget.getRenderer().getHeaderHeight();
    final double headerRowHeight = gridWidget.getRenderer().getHeaderRowHeight();
    final double offsetY = header == null ? 0 : header.getY();
    final int screenY = containerY + (int) ((gy - vy + offsetY + headerHeight - headerRowHeight / 2) * t.getScaleX());
    return screenY;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) Transform(com.ait.lienzo.client.core.types.Transform)

Example 62 with Group

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

the class ScenarioGridColumnRenderer method internalRenderCell.

@Override
protected Group internalRenderCell(final GridCell<String> cell, final GridBodyCellRenderContext context, final Text text, final String value) {
    if (value == null) {
        return null;
    }
    final GridRenderer renderer = context.getRenderer();
    final ScenarioGridRendererTheme theme = (ScenarioGridRendererTheme) renderer.getTheme();
    final Group g = new Group();
    text.setText(value);
    text.setListening(false);
    text.setX(context.getCellWidth() / 2);
    text.setY(context.getCellHeight() / 2);
    applyBackgroundColor((ScenarioGridCell) cell, context, g, theme);
    g.add(text);
    return g;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)

Example 63 with Group

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

the class ScenarioGridColumnRendererTest method renderCell.

@Test
public void renderCell() {
    GridCell<String> cell = null;
    Group retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNull(retrieved);
    verify(scenarioGridColumnRenderer, never()).internalRenderCell(any(), eq(contextMock), any(), anyString());
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    cell = new ScenarioGridCell(null);
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNull(retrieved);
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    verify(scenarioGridColumnRenderer, never()).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(null));
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(null));
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNull(retrieved);
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    verify(scenarioGridColumnRenderer, never()).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(null));
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(MULTIPART_VALUE));
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(MULTIPART_VALUE));
    reset(scenarioGridColumnRenderer);
    ScenarioGridCell scenarioGridCell = new ScenarioGridCell(new ScenarioGridCellValue(MULTIPART_VALUE, PLACEHOLDER));
    retrieved = scenarioGridColumnRenderer.renderCell(scenarioGridCell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(MULTIPART_VALUE));
    reset(scenarioGridColumnRenderer);
    scenarioGridCell = new ScenarioGridCell(new ScenarioGridCellValue(null, PLACEHOLDER));
    retrieved = scenarioGridColumnRenderer.renderCell(scenarioGridCell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(placeholderMock), eq(PLACEHOLDER));
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(LIST_VALUE));
    ((ScenarioGridCell) cell).setListMap(true);
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(LIST_VALUE));
    verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(LIST_VALUE), eq(true));
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(MAP_VALUE));
    ((ScenarioGridCell) cell).setListMap(false);
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(MAP_VALUE));
    verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(MAP_VALUE), eq(false));
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(EXPRESSION_VALUE));
    ((ScenarioGridCell) cell).setListMap(true);
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(EXPRESSION_VALUE));
    verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(EXPRESSION_VALUE), eq(true));
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(EXPRESSION_VALUE));
    ((ScenarioGridCell) cell).setListMap(false);
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(textMock), eq(EXPRESSION_VALUE));
    verify(scenarioGridColumnRenderer, times(1)).getCollectionString(eq(EXPRESSION_VALUE), eq(false));
    reset(scenarioGridColumnRenderer);
    cell = new ScenarioGridCell(new ScenarioGridCellValue(MULTIPART_VALUE));
    ((ScenarioGridCell) cell).setErrorMode(true);
    retrieved = scenarioGridColumnRenderer.renderCell(cell, contextMock);
    assertNotNull(retrieved);
    verify(scenarioGridColumnRenderer, never()).getCollectionString(anyString(), anyBoolean());
    verify(scenarioGridColumnRenderer, times(1)).internalRenderCell(any(), eq(contextMock), eq(errorTextMock), eq(MULTIPART_VALUE));
    reset(scenarioGridColumnRenderer);
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) ScenarioGridCell(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridCell) Matchers.anyString(org.mockito.Matchers.anyString) ScenarioGridCellValue(org.drools.workbench.screens.scenariosimulation.client.values.ScenarioGridCellValue) Test(org.junit.Test)

Example 64 with Group

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

the class ScenarioGridColumnRendererTest method applyBackgroundColor.

@Test
public void applyBackgroundColor() {
    Group group = mock(Group.class);
    when(scenarioGridCell.isErrorMode()).thenReturn(true);
    scenarioGridColumnRenderer.applyBackgroundColor(scenarioGridCell, contextMock, group, themeMock);
    verify(group, times(1)).add(any());
    reset(group);
    when(scenarioGridCell.isErrorMode()).thenReturn(false);
    scenarioGridColumnRenderer.applyBackgroundColor(scenarioGridCell, contextMock, group, themeMock);
    verify(group, never()).add(any());
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Test(org.junit.Test)

Example 65 with Group

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

the class GuidedDecisionTreeWidget method showGettingStartedHint.

private void showGettingStartedHint() {
    if (isGettingStartedHintVisible) {
        return;
    }
    if (hint == null) {
        hint = new Group();
        final Rectangle hintRectangle = new Rectangle(600, 225, 15);
        hintRectangle.setStrokeWidth(2.0);
        hintRectangle.setStrokeColor("#6495ED");
        hintRectangle.setFillColor("#AFEEEE");
        hintRectangle.setAlpha(0.75);
        final Text hintText = new Text(GuidedDecisionTreeConstants.INSTANCE.gettingStartedHint(), ShapeFactoryUtil.FONT_FAMILY_DESCRIPTION, 18);
        hintText.setTextAlign(TextAlign.CENTER);
        hintText.setTextBaseLine(TextBaseLine.MIDDLE);
        hintText.setFillColor("#6495ED");
        hintText.setX(hintRectangle.getWidth() / 2);
        hintText.setY(hintRectangle.getHeight() / 2);
        hint.setX((canvasLayer.getWidth() - hintRectangle.getWidth()) / 2);
        hint.setY((canvasLayer.getHeight() / 3) - (hintRectangle.getHeight() / 2));
        hint.add(hintRectangle);
        hint.add(hintText);
    }
    hint.animate(AnimationTweener.LINEAR, new AnimationProperties(), ANIMATION_DURATION, new IAnimationCallback() {

        @Override
        public void onStart(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) {
            hint.setAlpha(0.0);
            canvasLayer.add(hint);
            isGettingStartedHintVisible = true;
        }

        @Override
        public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) {
            // Lienzo's IAnimation.getPercent() passes values > 1.0
            final double pct = iAnimation.getPercent() > 1.0 ? 1.0 : iAnimation.getPercent();
            hint.setAlpha(pct);
            hint.getLayer().batch();
        }

        @Override
        public void onClose(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) {
        // Nothing to do
        }
    });
}
Also used : IAnimationHandle(com.ait.lienzo.client.core.animation.IAnimationHandle) Group(com.ait.lienzo.client.core.shape.Group) AnimationProperties(com.ait.lienzo.client.core.animation.AnimationProperties) IAnimation(com.ait.lienzo.client.core.animation.IAnimation) Rectangle(com.ait.lienzo.client.core.shape.Rectangle) Text(com.ait.lienzo.client.core.shape.Text) IAnimationCallback(com.ait.lienzo.client.core.animation.IAnimationCallback)

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