use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.
the class UndefinedExpressionColumnRenderer method renderCell.
@Override
public Group renderCell(final GridCell<String> cell, final GridBodyCellRenderContext context) {
if (isToReturnNull(cell)) {
return null;
}
final GridRenderer renderer = context.getRenderer();
final GridRendererTheme theme = renderer.getTheme();
final Text text = theme.getPlaceholderText();
final String value = cell.getValue().getPlaceHolder();
return internalRenderCell(cell, context, text, value);
}
use of com.ait.lienzo.client.core.shape.Text 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;
}
use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.
the class PrimitiveTooltip method show.
public PrimitiveTooltip show(final IPrimitive<?> _glyph, final String text, final Point2D location, final double width, final double height, final Direction direction) {
clearTimers();
final IPrimitive<?> glyph = null != _glyph ? (IPrimitive<?>) _glyph.copy() : null;
final Text descText = new Text(text).setFontSize(TEXT_SIZE).setFontStyle("").setFontFamily(TEXT_FAMILY).setStrokeWidth(TEXT_WIDTH).setStrokeColor(TEXT_COLOR).setStrokeAlpha(1);
final BoundingBox descTextBB = descText.getBoundingBox();
final double descTextBbW = descTextBB.getWidth();
final double descTextBbH = descTextBB.getHeight();
final double dw = (descTextBbW > width ? (descTextBbW + PADDING) : (width + PADDING));
final double dh = height + descTextBbH + PADDING;
final IPrimitive<?> decorator = buildDecorator(dw, dh, direction);
final double w = dw + (isWest(direction) ? TRIANGLE_SIZE * 2 : 0);
final double h = dh + (isNorth(direction) ? TRIANGLE_SIZE * 2 : 0);
;
final Group g = new Group();
g.add(decorator);
if (null != glyph) {
g.add(glyph);
}
g.add(descText);
super.show(g, w, h, location.getX(), location.getY());
double _x = (w / 2) + (isWest(direction) ? PADDING / 2 : 0);
double _y = PADDING / 2 + (isNorth(direction) ? TRIANGLE_SIZE : 0);
if (null != glyph) {
glyph.setX(_x - (width / 2));
glyph.setY(_y);
_x += width;
_y += height;
}
descText.setX(_x - (descTextBbW / 2));
descText.setY(_y + descTextBbH);
// Ensure text is on top.
descText.moveToTop();
canvasLayer.draw();
startTimers();
return this;
}
use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.
the class WiresTextDecoratorTest method testSetTextWrapperStrategy.
private void testSetTextWrapperStrategy(final TextWrapperStrategy wrapperStrategy) {
final Text text = decorator.getView();
final ITextWrapper expectedWrapper = TextWrapperProvider.get(wrapperStrategy, text);
decorator.setTextWrapper(wrapperStrategy);
verify(decorator).setTextBoundaries(any(BoundingBox.class));
assertEquals(expectedWrapper.getClass(), text.getWrapper().getClass());
}
use of com.ait.lienzo.client.core.shape.Text in project kie-wb-common by kiegroup.
the class WiresTextDecoratorTest method assertBoundaries.
private void assertBoundaries(double width, double height) {
final Text text = decorator.getView();
final BoundingBox wrapBoundaries = ((TextBoundsWrap) text.getWrapper()).getWrapBoundaries();
assertEquals(width, wrapBoundaries.getWidth(), 0d);
assertEquals(height, wrapBoundaries.getHeight(), 0d);
assertNotEquals(wrapBoundaries.getWidth(), 0d, 0.d);
assertNotEquals(wrapBoundaries.getHeight(), 0d, 0d);
}
Aggregations