Search in sources :

Example 46 with Point2D

use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.

the class CanvasDefinitionTooltip method configure.

public CanvasDefinitionTooltip configure(final AbstractCanvasHandler canvasHandler) {
    setTransform(canvasHandler.getCanvas().getLayer().getTransform());
    setCanvasLocation(new Point2D(canvasHandler.getAbstractCanvas().getView().getAbsoluteX(), canvasHandler.getAbstractCanvas().getView().getAbsoluteY()));
    return this;
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D)

Example 47 with Point2D

use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.

the class PasteSelectionSessionCommand method calculateNewLocation.

private Point2D calculateNewLocation(final Node<? extends View<?>, Edge> node, String newParentUUID) {
    Point2D position = GraphUtils.getPosition(node.getContent());
    // new parent different from the source node
    if (hasParentChanged(node, newParentUUID)) {
        return new Point2D(DEFAULT_PADDING, DEFAULT_PADDING);
    }
    // node is still on canvas (not deleted)
    if (existsOnCanvas(node)) {
        double x = position.getX();
        double max = getYPositionStatistics().getMax();
        double min = getYPositionStatistics().getMin();
        double y = max + (position.getY() - min) + DEFAULT_PADDING;
        return new Point2D(x, y);
    }
    // default or node was deleted
    return position;
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D)

Example 48 with Point2D

use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.

the class NodeShapeImpl method applyPosition.

@Override
public void applyPosition(final Node<View<W>, Edge> element, final MutationContext mutationContext) {
    final Point2D location = GraphUtils.getPosition(element.getContent());
    getShapeView().setShapeLocation(location);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D)

Example 49 with Point2D

use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.

the class TransformImplTest method testTransform.

@Test
public void testTransform() {
    final Point2D t = tested.transform(1, 1);
    assertEquals(12, t.getX(), 0);
    assertEquals(25, t.getY(), 0);
    final Point2D t1 = tested.transform(2, 2);
    assertEquals(14, t1.getX(), 0);
    assertEquals(30, t1.getY(), 0);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Test(org.junit.Test)

Example 50 with Point2D

use of org.kie.workbench.common.stunner.core.graph.content.view.Point2D in project kie-wb-common by kiegroup.

the class TransformImplTest method testGetScale.

@Test
public void testGetScale() {
    final Point2D s = tested.getScale();
    assertEquals(scale, s);
}
Also used : Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Test(org.junit.Test)

Aggregations

Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)55 Test (org.junit.Test)25 Edge (org.kie.workbench.common.stunner.core.graph.Edge)18 View (org.kie.workbench.common.stunner.core.graph.content.view.View)17 Node (org.kie.workbench.common.stunner.core.graph.Node)15 Command (org.kie.workbench.common.stunner.core.command.Command)10 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)10 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)10 Before (org.junit.Before)9 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)7 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)6 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)6 TestingGraphMockHandler (org.kie.workbench.common.stunner.core.TestingGraphMockHandler)5 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)5 Ignore (org.junit.Ignore)4 Element (org.kie.workbench.common.stunner.core.graph.Element)4 AbstractCanvas (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas)3 CanvasCommand (org.kie.workbench.common.stunner.core.client.command.CanvasCommand)3 ShapeView (org.kie.workbench.common.stunner.core.client.shape.view.ShapeView)3 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)3