Search in sources :

Example 66 with BoundingBox

use of com.ait.lienzo.client.core.types.BoundingBox in project lienzo-core by ahome-it.

the class AbstractMultiPathPartShape method validSizeConstraints.

private boolean validSizeConstraints() {
    final BoundingBox shapeBB = getBoundingBox();
    final BoundingBox constraintsBB = getSizeConstraints();
    if (constraintsBB == null) {
        return true;
    }
    final double minWidth = constraintsBB.getMinX();
    final double minHeight = constraintsBB.getMinY();
    final double maxWidth = constraintsBB.getMaxX();
    final double maxHeight = constraintsBB.getMaxY();
    final double width = shapeBB.getWidth();
    final double height = shapeBB.getHeight();
    if (minWidth > width) {
        return false;
    }
    if (minHeight > height) {
        return false;
    }
    if (maxWidth < width) {
        return false;
    }
    if (maxHeight < height) {
        return false;
    }
    return true;
}
Also used : BoundingBox(com.ait.lienzo.client.core.types.BoundingBox)

Example 67 with BoundingBox

use of com.ait.lienzo.client.core.types.BoundingBox in project lienzo-core by ahome-it.

the class ContainerNode method drawWithoutTransforms.

/**
 * Used internally. Draws the node in the current Context2D
 * without applying the transformation-related attributes
 * (e.g. X, Y, ROTATION, SCALE, SHEAR, OFFSET and TRANSFORM.)
 * <p>
 * Groups should draw their children in the current context.
 */
@Override
protected void drawWithoutTransforms(final Context2D context, double alpha, final BoundingBox bounds) {
    if ((context.isSelection()) && (false == isListening())) {
        return;
    }
    alpha = alpha * getAttributes().getAlpha();
    if (alpha <= 0) {
        return;
    }
    BoundingBox bbox = getStorageBounds();
    if (null == bbox) {
        bbox = bounds;
    }
    final NFastArrayList<M> list = getChildNodes(bbox);
    final int size = list.size();
    final IPathClipper clip = getPathClipper();
    if ((null != clip) && (clip.isActive())) {
        context.save();
        clip.clip(context);
        for (int i = 0; i < size; i++) {
            list.get(i).drawWithTransforms(context, alpha, bbox);
        }
        context.restore();
    } else {
        for (int i = 0; i < size; i++) {
            list.get(i).drawWithTransforms(context, alpha, bbox);
        }
    }
}
Also used : BoundingBox(com.ait.lienzo.client.core.types.BoundingBox)

Example 68 with BoundingBox

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

the class LogBoundingBoxDevCommand method execute.

@Override
protected void execute(final Node<? extends View<?>, Edge> node) {
    String id = node.getUUID();
    final Shape shape = this.getCanvasHandler().getCanvas().getShape(id);
    final WiresShapeView shapeView = (WiresShapeView) shape.getShapeView();
    final BoundingBox boundingBox = shapeView.getGroup().getBoundingBox();
    logTask(() -> StunnerClientLogger.log(boundingBox.toString()));
}
Also used : Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox)

Example 69 with BoundingBox

use of com.ait.lienzo.client.core.types.BoundingBox 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 70 with BoundingBox

use of com.ait.lienzo.client.core.types.BoundingBox 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);
}
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

BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)79 Point2D (com.ait.lienzo.client.core.types.Point2D)24 Test (org.junit.Test)16 ScratchPad (com.ait.lienzo.client.core.util.ScratchPad)8 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)7 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)7 Context2D (com.ait.lienzo.client.core.Context2D)6 ArrayList (java.util.ArrayList)6 Direction (com.ait.lienzo.shared.core.types.Direction)5 Group (com.ait.lienzo.client.core.shape.Group)4 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)4 Text (com.ait.lienzo.client.core.shape.Text)3 Transform (com.ait.lienzo.client.core.types.Transform)3 NFastDoubleArrayJSO (com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO)3 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)3 MultiPathDecorator (com.ait.lienzo.client.core.shape.MultiPathDecorator)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)2 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)2 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)2 BoundingPoints (com.ait.lienzo.client.core.types.BoundingPoints)2