Search in sources :

Example 51 with Group

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

the class SVGShapeViewImplTest method setup.

@Before
public void setup() throws Exception {
    this.parent = new SVGContainer("parent", new Group().setID("parent"), false, null);
    rectangle = new Rectangle(10d, 10d);
    this.childShape = new SVGPrimitiveShape(new Rectangle(10d, 10d));
    this.child = new SVGBasicShapeViewImpl("svgChild1", childShape, 50d, 23d);
    this.shape = new SVGPrimitiveShape(rectangle);
    this.tested = new SVGShapeViewImpl("svg-test1", shape, 100, 340, false);
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) SVGContainer(org.kie.workbench.common.stunner.svg.client.shape.view.SVGContainer) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Rectangle(com.ait.lienzo.client.core.shape.Rectangle) Before(org.junit.Before)

Example 52 with Group

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

the class ConnectorGlyphLienzoRenderer method render.

@Override
public Group render(final ConnectorGlyph glyph, final double width, final double height) {
    final Group group = new Group();
    final Arrow arrow = new Arrow(new Point2D(STROKE_SIZE, height), new Point2D(width, STROKE_SIZE), 5, 10, 45, 45, ArrowType.AT_END).setStrokeWidth(STROKE_SIZE).setFillColor(glyph.getColor()).setStrokeColor(glyph.getColor()).setDraggable(true);
    group.add(arrow);
    scaleTo(group, width - arrow.getStrokeWidth(), height - arrow.getStrokeWidth());
    return group;
}
Also used : Arrow(com.ait.lienzo.client.core.shape.Arrow) Group(com.ait.lienzo.client.core.shape.Group) Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 53 with Group

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

the class ShapeViewUserDataEncoderTest method testSetShapeViewChildrenIds.

@Test
@SuppressWarnings("unchecked")
public void testSetShapeViewChildrenIds() {
    String uuid = "uuid1";
    // Main group.
    Group mainGroup = new Group();
    Rectangle r1 = new Rectangle(50, 50);
    r1.setID("r1");
    Rectangle r2 = new Rectangle(50, 50);
    r2.setUserData("?someUserDataForR2");
    Rectangle r3 = new Rectangle(50, 50);
    mainGroup.add(r1);
    mainGroup.add(r2);
    mainGroup.add(r3);
    // Sub group.
    Group subGroup = new Group();
    Rectangle r11 = new Rectangle(50, 50);
    r11.setID("r11");
    Rectangle r22 = new Rectangle(50, 50);
    r22.setUserData("?someUserDataForR22");
    subGroup.add(r11);
    subGroup.add(r22);
    mainGroup.add(subGroup);
    // Test encoding ids.
    new ShapeViewUserDataEncoder().setShapeViewChildrenIds(uuid, mainGroup);
    // Id's assertions.
    assertEquals(uuid + "_r1", r1.getID());
    assertEquals(uuid + "?someUserDataForR2", r2.getID());
    assertEquals(uuid, r3.getID());
    assertEquals(uuid + "_r11", r11.getID());
    assertEquals(uuid + "?someUserDataForR22", r22.getID());
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Rectangle(com.ait.lienzo.client.core.shape.Rectangle) Test(org.junit.Test)

Example 54 with Group

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

the class LienzoElementGlyphRenderer method newPanel.

private LienzoPanel newPanel(final G glyph, final int width, final int height) {
    final Group glyphGroup = getLienzoGlyphRenderer().render(glyph, width, height);
    final LienzoPanel panel = new LienzoPanel(width, height);
    final Layer layer = new Layer();
    panel.add(layer.setTransformable(true));
    layer.add(glyphGroup);
    return panel;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) LienzoPanel(com.ait.lienzo.client.widget.LienzoPanel) Layer(com.ait.lienzo.client.core.shape.Layer)

Example 55 with Group

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

the class ControlPointControlImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    layer = spy(new Layer());
    edge = new EdgeImpl<>(EDGE_UUID);
    content = new ViewConnectorImpl(mock(Object.class), Bounds.create());
    edge.setContent(content);
    controlPoints = new ControlPoint[] { CONTROL_POINT };
    content.setControlPoints(controlPoints);
    Group connectorGroup = new Group();
    layer.add(connectorGroup);
    when(connector.getGroup()).thenReturn(connectorGroup);
    when(connector.uuid()).thenReturn(EDGE_UUID);
    when(connector.getUUID()).thenReturn(EDGE_UUID);
    when(connector.getPointHandles()).thenReturn(wiresPointHandles);
    when(wiresPointHandles.isEmpty()).thenReturn(false);
    when(wiresPointHandles.size()).thenReturn(3);
    when(wiresPointHandles.getHandle(eq(0))).thenReturn(mock(IControlHandle.class));
    when(wiresPointHandles.getHandle(eq(1))).thenReturn(wiresPointHandle);
    when(wiresPointHandles.getHandle(eq(2))).thenReturn(mock(IControlHandle.class));
    when(wiresPointHandle.getControl()).thenReturn(wiresPointPrimitive);
    when(wiresPointPrimitive.getX()).thenReturn(CONTROL_POINT.getLocation().getX());
    when(wiresPointPrimitive.getY()).thenReturn(CONTROL_POINT.getLocation().getY());
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(canvasHandler.getCanvas()).thenReturn(canvas);
    when(canvasHandler.getAbstractCanvas()).thenReturn(canvas);
    when(canvas.getWiresManager()).thenReturn(wiresManager);
    when(canvas.getShape(EDGE_UUID)).thenReturn(connectorShape);
    when(connectorShape.getShapeView()).thenReturn(connector);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(graph.getContent()).thenReturn(graphContent);
    when(diagram.getGraph()).thenReturn(graph);
    when(commandManager.allow(eq(canvasHandler), any(Command.class))).thenReturn(CanvasCommandResultBuilder.SUCCESS);
    tested = new ControlPointControlImpl(canvasCommandFactory, selectionEvent);
    tested.setCommandManagerProvider(() -> commandManager);
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) CanvasCommand(org.kie.workbench.common.stunner.core.client.command.CanvasCommand) Command(org.kie.workbench.common.stunner.core.command.Command) IControlHandle(com.ait.lienzo.client.core.shape.wires.IControlHandle) Layer(com.ait.lienzo.client.core.shape.Layer) Before(org.junit.Before)

Aggregations

Group (com.ait.lienzo.client.core.shape.Group)66 Test (org.junit.Test)17 Rectangle (com.ait.lienzo.client.core.shape.Rectangle)10 Before (org.junit.Before)10 Text (com.ait.lienzo.client.core.shape.Text)9 GridRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer)8 Layer (com.ait.lienzo.client.core.shape.Layer)7 Point2D (com.ait.lienzo.client.core.types.Point2D)7 Command (org.uberfire.mvp.Command)6 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)4 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)4 Line (com.ait.lienzo.client.core.shape.Line)3 ArrayList (java.util.ArrayList)3 SVGContainer (org.kie.workbench.common.stunner.svg.client.shape.view.SVGContainer)3 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)3 GridRendererTheme (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.themes.GridRendererTheme)3 IPathClipper (com.ait.lienzo.client.core.shape.IPathClipper)2 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)2 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)2 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)2