Search in sources :

Example 1 with HasTitle

use of org.kie.workbench.common.stunner.core.client.shape.view.HasTitle in project kie-wb-common by kiegroup.

the class CanvasInPlaceTextEditorControlImpl method setShapeEditMode.

private boolean setShapeEditMode(final boolean editMode) {
    final Shape<?> shape = getShape(this.uuid);
    if (null != shape) {
        final HasTitle hasTitle = (HasTitle) shape.getShapeView();
        final double alpha = editMode ? SHAPE_EDIT_ALPHA : 1d;
        shape.getShapeView().setFillAlpha(alpha);
        hasTitle.setTitleAlpha(alpha);
        getCanvas().draw();
        return true;
    }
    return false;
}
Also used : HasTitle(org.kie.workbench.common.stunner.core.client.shape.view.HasTitle)

Example 2 with HasTitle

use of org.kie.workbench.common.stunner.core.client.shape.view.HasTitle in project kie-wb-common by kiegroup.

the class FontHandler method handle.

@Override
public void handle(final W element, final V view) {
    if (view instanceof HasTitle) {
        final HasTitle hasTitle = (HasTitle) view;
        final Double alpha = alphaProvider.apply(element);
        final String fontFamily = fontFamilyProvider.apply(element);
        final String fontColor = fontColorProvider.apply(element);
        final Double fontSize = fontSizeProvider.apply(element);
        final String strokeColor = strokeColorProvider.apply(element);
        final Double strokeSize = strokeSizeProvider.apply(element);
        final HasTitle.Position position = positionProvider.apply(element);
        final Double rotation = rotationProvider.apply(element);
        if (fontFamily != null && fontFamily.trim().length() > 0) {
            hasTitle.setTitleFontFamily(fontFamily);
        }
        if (fontColor != null && fontColor.trim().length() > 0) {
            hasTitle.setTitleFontColor(fontColor);
        }
        if (strokeColor != null && strokeColor.trim().length() > 0) {
            hasTitle.setTitleStrokeColor(strokeColor);
        }
        if (fontSize != null && fontSize > 0) {
            hasTitle.setTitleFontSize(fontSize);
        }
        if (strokeSize != null && strokeSize > 0) {
            hasTitle.setTitleStrokeWidth(strokeSize);
        }
        if (null != alpha) {
            hasTitle.setTitleAlpha(alpha);
        }
        if (null != position) {
            hasTitle.setTitlePosition(position);
        }
        if (null != rotation) {
            hasTitle.setTitleRotation(rotation);
        }
    }
}
Also used : HasTitle(org.kie.workbench.common.stunner.core.client.shape.view.HasTitle)

Example 3 with HasTitle

use of org.kie.workbench.common.stunner.core.client.shape.view.HasTitle in project kie-wb-common by kiegroup.

the class LienzoShapeGlyphRenderer method render.

@Override
@SuppressWarnings("unchecked")
public Group render(final ShapeGlyph glyph, final double width, final double height) {
    final String definitionId = glyph.getDefinitionId();
    final Supplier<ShapeFactory> factorySupplier = glyph.getFactorySupplier();
    final Shape shape = factorySupplier.get().newShape(factoryManager.newDefinition(definitionId));
    final ShapeView<?> view = shape.getShapeView();
    final BoundingBox bb = boundingBoxProvider.apply(view);
    Group group = groupProvider.apply(view);
    if (null == group) {
        throw new RuntimeException("Shape view [" + view.toString() + "] not supported for " + "this shape glyph builder [" + this.getClass().getName());
    }
    if (view instanceof HasTitle) {
        final HasTitle hasTitle = (HasTitle) view;
        hasTitle.setTitle(null);
    }
    // Create a copy of this view.
    group = group.copy();
    // Scale, if necessary, to the given glyph size.
    final double[] scale = LienzoUtils.getScaleFactor(bb.getWidth(), bb.getHeight(), width, height);
    group.setScale(scale[0], scale[1]);
    return group;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) HasTitle(org.kie.workbench.common.stunner.core.client.shape.view.HasTitle) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)

Aggregations

HasTitle (org.kie.workbench.common.stunner.core.client.shape.view.HasTitle)3 Group (com.ait.lienzo.client.core.shape.Group)1 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)1 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)1 ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)1