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