use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class AbstractGraphCommandTest method mockView.
public static View mockView(final double x, final double y, final double w, final double h) {
View view = mock(View.class);
Bounds bounds = mockBounds(x, y, w, h);
when(view.getBounds()).thenReturn(bounds);
return view;
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class SugiyamaLayoutService method buildLayout.
Layout buildLayout(final HashMap<String, Node> indexByUuid, final List<GraphLayer> layers) {
final Layout layout = new Layout();
for (int i = layers.size() - 1; i >= 0; i--) {
final GraphLayer layer = layers.get(i);
for (final Vertex v : layer.getVertices()) {
final Node n = indexByUuid.get(v.getId());
final int x = v.getX();
final int y = v.getY();
final Bounds currentBounds = ((HasBounds) n.getContent()).getBounds();
final Bound lowerRight = currentBounds.getLowerRight();
final int x2;
if (isCloseToZero(lowerRight.getX())) {
x2 = x + VertexPositioning.DEFAULT_VERTEX_WIDTH;
} else {
x2 = (int) (x + lowerRight.getX());
}
final int y2;
if (isCloseToZero(lowerRight.getY())) {
y2 = y + VertexPositioning.DEFAULT_VERTEX_HEIGHT;
} else {
y2 = (int) (y + lowerRight.getY());
}
final VertexPosition position = new VertexPositionImpl(v.getId(), new Point2D(x, y), new Point2D(x2, y2));
layout.getNodePositions().add(position);
}
}
return layout;
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class NodeFactoryImpl method build.
@Override
@SuppressWarnings("unchecked")
public Node<Definition<Object>, Edge> build(final String uuid, final Object definition) {
final NodeImpl node = new NodeImpl<>(uuid);
final Bounds bounds = definitionUtils.buildBounds(definition, 0d, 0d);
View<Object> content = new ViewImpl<>(definition, bounds);
node.setContent(content);
appendLabels(node.getLabels(), definition);
return node;
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class BasePropertyWriter method absoluteBounds.
public static org.kie.workbench.common.stunner.core.graph.content.Bounds absoluteBounds(final Node<? extends View, ?> node) {
final Point2D point2D = GraphUtils.getComputedPosition(node);
final org.kie.workbench.common.stunner.core.graph.content.Bounds bounds = node.getContent().getBounds();
return org.kie.workbench.common.stunner.core.graph.content.Bounds.create(point2D.getX(), point2D.getY(), point2D.getX() + bounds.getWidth(), point2D.getY() + bounds.getHeight());
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class StunnerLienzoBoundsPanelTest method testLocationConstraints.
@Test
public void testLocationConstraints() {
Bounds bounds = tested.getLocationConstraints();
assertNotNull(bounds);
assertTrue(bounds.hasUpperLeft());
assertEquals(0d, bounds.getUpperLeft().getX(), 0d);
assertEquals(0d, bounds.getUpperLeft().getY(), 0d);
assertFalse(bounds.hasLowerRight());
}
Aggregations