Search in sources :

Example 1 with Text

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

the class GuidedDecisionTableViewImpl method makeHeaderCaption.

private Group makeHeaderCaption() {
    final Group g = GWT.create(Group.class);
    final double captionWidth = getHeaderCaptionWidth();
    final GuidedDecisionTableTheme theme = (GuidedDecisionTableTheme) renderer.getTheme();
    final Rectangle r = theme.getBaseRectangle(GuidedDecisionTableTheme.ModelColumnType.CAPTION);
    r.setWidth(captionWidth);
    r.setHeight(HEADER_CAPTION_HEIGHT);
    final MultiPath border = theme.getBodyGridLine();
    border.M(0.5, HEADER_CAPTION_HEIGHT + 0.5);
    border.L(0.5, 0.5);
    border.L(captionWidth + 0.5, 0.5);
    border.L(captionWidth + 0.5, HEADER_CAPTION_HEIGHT + 0.5);
    border.L(0.5, HEADER_CAPTION_HEIGHT + 0.5);
    final Text caption = theme.getHeaderText();
    caption.setText(model.getTableName());
    caption.setX(captionWidth / 2);
    caption.setY(HEADER_CAPTION_HEIGHT / 2);
    // Clip Caption Group
    final BoundingBox bb = new BoundingBox(0, 0, captionWidth + border.getStrokeWidth(), HEADER_CAPTION_HEIGHT + 0.5);
    final IPathClipper clipper = getPathClipper(bb);
    g.setPathClipper(clipper);
    clipper.setActive(true);
    g.add(r);
    g.add(caption);
    g.add(border);
    return g;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) MultiPath(com.ait.lienzo.client.core.shape.MultiPath) IPathClipper(com.ait.lienzo.client.core.shape.IPathClipper) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Rectangle(com.ait.lienzo.client.core.shape.Rectangle) GuidedDecisionTableTheme(org.drools.workbench.screens.guided.dtable.client.widget.table.themes.GuidedDecisionTableTheme) Text(com.ait.lienzo.client.core.shape.Text)

Example 2 with Text

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

the class BaseGuidedDecisionTreeNodeFactory method getDragProxy.

@Override
public ShapeDragProxy getDragProxy(final FactoryHelper helper, final ShapeDragProxyPreviewCallback dragPreviewCallback, final ShapeDragProxyCompleteCallback dragEndCallBack) {
    final T shape = makeShape();
    final Group group = new Group();
    group.add(shape);
    // Add a label to the drag proxy if needed
    double dragProxyWidth = getWidth();
    double dragProxyHeight = getHeight();
    final String description = getNodeLabel(helper);
    if (description != null) {
        final Text nodeLabel = new Text(description, ShapeFactoryUtil.FONT_FAMILY_DESCRIPTION, ShapeFactoryUtil.FONT_SIZE_DESCRIPTION);
        nodeLabel.setTextAlign(TextAlign.CENTER);
        nodeLabel.setTextBaseLine(TextBaseLine.MIDDLE);
        nodeLabel.setFillColor(Color.rgbToBrowserHexColor(0, 0, 0));
        dragProxyWidth = getDragProxyWidth(nodeLabel);
        dragProxyHeight = getDragProxyHeight(nodeLabel);
        group.add(nodeLabel);
    }
    final double _dragProxyWidth = dragProxyWidth;
    final double _dragProxyHeight = dragProxyHeight;
    return new ShapeDragProxy() {

        @Override
        public Group getDragGroup() {
            return group;
        }

        @Override
        public void onDragPreview(final double x, final double y) {
            dragPreviewCallback.callback(x, y);
        }

        @Override
        public void onDragComplete(final double x, final double y) {
            dragEndCallBack.callback(x, y);
        }

        @Override
        public double getWidth() {
            return _dragProxyWidth;
        }

        @Override
        public double getHeight() {
            return _dragProxyHeight;
        }
    };
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) ShapeDragProxy(org.uberfire.ext.wires.core.api.factories.ShapeDragProxy) Text(com.ait.lienzo.client.core.shape.Text)

Example 3 with Text

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

the class GuidedDecisionTreeStencilPaletteBuilder method build.

public PaletteShape build(final LienzoPanel dragProxyParentPanel, final FactoryHelper helper, final ShapeFactory factory, final boolean isReadOnly) {
    // If the Editor is not Read Only delegate to super class
    if (!isReadOnly) {
        return super.build(dragProxyParentPanel, helper, factory);
    }
    // Otherwise make a Read Only Stencil
    final PaletteShape paletteShape = new PaletteShape();
    final ShapeGlyph glyph = drawGlyph(factory, helper);
    final Text description = drawDescription(factory, helper);
    final Rectangle bounding = drawBoundingBox(factory, helper);
    // Build Palette Shape
    paletteShape.setBounding(bounding);
    paletteShape.setGroup(scaleGlyph(glyph));
    paletteShape.setDescription(description);
    return paletteShape;
}
Also used : ShapeGlyph(org.uberfire.ext.wires.core.api.factories.ShapeGlyph) Rectangle(com.ait.lienzo.client.core.shape.Rectangle) Text(com.ait.lienzo.client.core.shape.Text) PaletteShape(org.uberfire.ext.wires.core.client.palette.PaletteShape)

Example 4 with Text

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;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Text(com.ait.lienzo.client.core.shape.Text)

Example 5 with Text

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

the class WiresTextDecorator method initialize.

private void initialize() {
    this.text = new Text("").setAlpha(TEXT_ALPHA).setFontFamily(TEXT_FONT_FAMILY).setFontSize(TEXT_FONT_SIZE).setFillColor(TEXT_FILL_COLOR).setStrokeColor(TEXT_STROKE_COLOR).setStrokeWidth(TEXT_STROKE_WIDTH).setTextAlign(TEXT_ALIGN).setDraggable(false);
    this.textWrapper = new TextBoundsWrap(text, new BoundingBox(0, 0, 1, 1));
    this.text.setWrapper(textWrapper);
    this.currentTextLayout = TEXT_LAYOUT_ALIGN;
    textContainer.add(text);
    // Ensure path bounds are available on the selection context.
    text.setFillBoundsForSelection(true);
    initializeHandlers();
}
Also used : BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) Text(com.ait.lienzo.client.core.shape.Text) TextBoundsWrap(com.ait.lienzo.client.core.shape.TextBoundsWrap)

Aggregations

Text (com.ait.lienzo.client.core.shape.Text)9 Group (com.ait.lienzo.client.core.shape.Group)6 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)3 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)3 GridRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)2 GridRendererTheme (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme)2 AnimationProperties (com.ait.lienzo.client.core.animation.AnimationProperties)1 IAnimation (com.ait.lienzo.client.core.animation.IAnimation)1 IAnimationCallback (com.ait.lienzo.client.core.animation.IAnimationCallback)1 IAnimationHandle (com.ait.lienzo.client.core.animation.IAnimationHandle)1 IPathClipper (com.ait.lienzo.client.core.shape.IPathClipper)1 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 TextBoundsWrap (com.ait.lienzo.client.core.shape.TextBoundsWrap)1 TextLineBreakWrap (com.ait.lienzo.client.core.shape.TextLineBreakWrap)1 GuidedDecisionTableTheme (org.drools.workbench.screens.guided.dtable.client.widget.table.themes.GuidedDecisionTableTheme)1 ConstraintFactoryHelper (org.drools.workbench.screens.guided.dtree.client.widget.factories.ConstraintFactoryHelper)1 TypeFactoryHelper (org.drools.workbench.screens.guided.dtree.client.widget.factories.TypeFactoryHelper)1 ShapeDragProxy (org.uberfire.ext.wires.core.api.factories.ShapeDragProxy)1 ShapeGlyph (org.uberfire.ext.wires.core.api.factories.ShapeGlyph)1 PaletteShape (org.uberfire.ext.wires.core.client.palette.PaletteShape)1