Search in sources :

Example 1 with Triangle

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

the class PrimitiveTooltip method buildDecorator.

private IPrimitive<?> buildDecorator(final double width, final double height, final Direction direction) {
    final boolean isWest = isWest(direction);
    final boolean isNorth = isNorth(direction);
    final double h2 = height / 2;
    final double w2 = width / 2;
    final double s2 = TRIANGLE_SIZE / 2;
    final Point2D a = isWest ? new Point2D(0, h2) : new Point2D(10, 0);
    final Point2D b = isWest ? new Point2D(TRIANGLE_SIZE, h2 + s2) : new Point2D(10 + s2, TRIANGLE_SIZE);
    final Point2D c = isWest ? new Point2D(TRIANGLE_SIZE, h2 - s2) : new Point2D(10 - s2, TRIANGLE_SIZE);
    final Triangle triangle = new Triangle(a, b, c).setFillColor(BG_COLOR).setFillAlpha(ALPHA).setStrokeWidth(0);
    final Rectangle rectangle = new Rectangle(width + (isWest ? TRIANGLE_SIZE : 0), height + (isNorth ? TRIANGLE_SIZE : 0)).setX(isWest ? TRIANGLE_SIZE : 0).setY(isWest ? 0 : TRIANGLE_SIZE).setCornerRadius(10).setFillColor(BG_COLOR).setFillAlpha(ALPHA).setStrokeAlpha(0).setCornerRadius(5);
    final Group decorator = new Group();
    decorator.add(rectangle);
    decorator.add(triangle);
    return decorator;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Point2D(com.ait.lienzo.client.core.types.Point2D) Triangle(com.ait.lienzo.client.core.shape.Triangle) Rectangle(com.ait.lienzo.client.core.shape.Rectangle)

Aggregations

Group (com.ait.lienzo.client.core.shape.Group)1 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)1 Triangle (com.ait.lienzo.client.core.shape.Triangle)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1