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