use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class GraphBoundsIndexerImpl method getNodeAbsoluteCoordinates.
private double[] getNodeAbsoluteCoordinates(final Node node, final double parentX, final double parentY) {
final View content = (View) node.getContent();
final Bounds bounds = content.getBounds();
final Bound ulBound = bounds.getUpperLeft();
final Bound lrBound = bounds.getLowerRight();
final double ulX = ulBound.getX() + parentX;
final double ulY = ulBound.getY() + parentY;
final double lrX = lrBound.getX() + parentX;
final double lrY = lrBound.getY() + parentY;
return new double[] { ulX, ulY, lrX, lrY };
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class ClientBPMNDocumentationServiceTest method createNode.
private Node createNode(Object content) {
NodeImpl node = new NodeImpl(UUID.uuid());
node.setContent(new ViewImpl<>(content, new Bounds(new Bound(0d, 0d), new Bound(1d, 1d))));
return node;
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class ElementParser method initialize.
@Override
@SuppressWarnings("unchecked")
public void initialize(final Context context) {
this.context = context;
Object definition = element.getContent().getDefinition();
// Resource id field.
super.addParser(new StringFieldParser("resourceId", element.getUUID()));
// Properties array.
Object def = element.getContent().getDefinition();
Set<?> properties = context.getDefinitionManager().adapters().forDefinition().getProperties(def);
ObjectParser propertiesParser = new ObjectParser("properties");
super.addParser(propertiesParser);
if (null != properties && !properties.isEmpty()) {
for (Object property : properties) {
PropertyAdapter propertyAdapter = context.getDefinitionManager().adapters().registry().getPropertyAdapter(property.getClass());
PropertyType propertyType = propertyAdapter.getType(property);
String oryxPropId = context.getOryxManager().getMappingsManager().getOryxPropertyId(def.getClass(), property.getClass());
Object value = propertyAdapter.getValue(property);
String valueStr = value != null ? context.getOryxManager().getPropertyManager().serialize(property, propertyType, value) : "";
propertiesParser.addParser(new StringFieldParser(oryxPropId, valueStr));
}
}
// Custom extended prpoerties, if any.
parseExtendedProperties(propertiesParser);
// Stencil id field.
String defId = context.getOryxManager().getMappingsManager().getOryxDefinitionId(definition);
super.addParser(new ObjectParser("stencil").addParser(new StringFieldParser("id", defId)));
// Bounds.
Bounds.Bound ul = element.getContent().getBounds().getUpperLeft();
Bounds.Bound lr = element.getContent().getBounds().getLowerRight();
parseBounds(ul, lr);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class GraphBuilder method translate.
/**
* Move node into a new coordinate system with origin in newOrigin.
* <p>
* E.g., assume origin is currently (0,0), and consider node at (10,11).
* If we move node into a new coordinate system where the origin is in (3, 4)
* then the new coordinates for node are: (10-3, 11-4) = (7,7)
*/
private void translate(Node<? extends View, ?> node, Bounds.Bound newOrigin) {
logger.debug("Translating {} into constraints {}", node.getContent().getBounds(), newOrigin);
Bounds childBounds = node.getContent().getBounds();
double constrainedX = childBounds.getUpperLeft().getX() - newOrigin.getX();
double constrainedY = childBounds.getUpperLeft().getY() - newOrigin.getY();
Point2D coords = Point2D.create(constrainedX, constrainedY);
updatePosition(node, coords);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bounds in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallEvaluation.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEvaluation() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVALUATION);
assertDiagram(diagram, 8);
assertEquals("Evaluation", diagram.getMetadata().getTitle());
Node<? extends View, ?> task1 = diagram.getGraph().getNode("_88233779-B395-4B8C-A086-9EF43698426C");
Node<? extends View, ?> task2 = diagram.getGraph().getNode("_AE5BF0DC-B720-4FDE-9499-5ED89D41FB1A");
Node<? extends View, ?> task3 = diagram.getGraph().getNode("_6063D302-9D81-4C86-920B-E808A45377C2");
assertTrue(task1.getContent().getDefinition() instanceof UserTask);
assertTrue(task2.getContent().getDefinition() instanceof UserTask);
assertTrue(task3.getContent().getDefinition() instanceof UserTask);
// Assert bounds.
Bounds task1Bounds = task1.getContent().getBounds();
Bounds.Bound task1ULBound = task1Bounds.getUpperLeft();
Bounds.Bound task1LRBound = task1Bounds.getLowerRight();
assertEquals(648d, task1ULBound.getX(), 0);
assertEquals(149d, task1ULBound.getY(), 0);
assertEquals(784d, task1LRBound.getX(), 0);
assertEquals(197d, task1LRBound.getY(), 0);
}
Aggregations