Search in sources :

Example 1 with Node

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

the class WiresConnectorViewTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    Node lineNode = line;
    Node headPathNode = headPath;
    Node tailPathNode = tailPath;
    point2DArray = new Point2DArray(new Point2D(0, 10), new Point2D(10, 10), new Point2D(20, 20), new Point2D(30, 30), new Point2D(40, 40));
    when(line.getPoint2DArray()).thenReturn(point2DArray);
    when(line.asShape()).thenReturn(lineShape);
    when(line.asNode()).thenReturn(lineNode);
    when(lineShape.setFillColor(anyString())).thenReturn(lineShape);
    when(lineShape.setFillColor(any(IColor.class))).thenReturn(lineShape);
    when(lineShape.setFillAlpha(anyDouble())).thenReturn(lineShape);
    when(lineShape.setStrokeColor(anyString())).thenReturn(lineShape);
    when(lineShape.setStrokeColor(any(IColor.class))).thenReturn(lineShape);
    when(lineShape.setStrokeAlpha(anyDouble())).thenReturn(lineShape);
    when(lineShape.setStrokeWidth(anyDouble())).thenReturn(lineShape);
    when(line.isControlPointShape()).thenReturn(true);
    when(headDecorator.getPath()).thenReturn(headPath);
    when(tailDecorator.getPath()).thenReturn(tailPath);
    when(headPath.asNode()).thenReturn(headPathNode);
    when(tailPath.asNode()).thenReturn(tailPathNode);
    when(headPath.getBoundingBox()).thenReturn(new BoundingBox(0, 0, 10, 10));
    this.tested = new WiresConnectorView(line, headDecorator, tailDecorator);
    this.tested.setControl(wiresConnectorControl);
    tested = spy(tested);
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Point2D(com.ait.lienzo.client.core.types.Point2D) Node(com.ait.lienzo.client.core.shape.Node) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) IColor(com.ait.lienzo.shared.core.types.IColor) Before(org.junit.Before)

Example 2 with Node

use of com.ait.lienzo.client.core.shape.Node in project lienzo-core by ahome-it.

the class JSONDeserializer method deserializeChildren.

/**
 * Creates the child nodes for a {@link IJSONSerializable} that implements
 * {@link IContainer} from a JSONObject node.
 * <p>
 * You should only call this when you're writing your own {@link IContainer} class
 * and you're building a custom {@link IFactory}.
 *
 * @param container IContainer
 * @param node parent JSONObject
 * @param factory IContainerFactory
 * @param ctx ValidationContext
 * @throws ValidationException
 */
public final void deserializeChildren(final IContainer<?, ?> container, final JSONObject node, final IContainerFactory factory, final ValidationContext ctx) throws ValidationException {
    JSONValue jsonvalu = node.get("children");
    if (null == jsonvalu) {
        // OK - 'children' is optional
        return;
    }
    ctx.push("children");
    final JSONArray array = jsonvalu.isArray();
    if (null == array) {
        ctx.addBadTypeError("Array");
    } else {
        final int size = array.size();
        for (int i = 0; i < size; i++) {
            ctx.pushIndex(i);
            jsonvalu = array.get(i);
            final JSONObject object = jsonvalu.isObject();
            if (null == object) {
                ctx.addBadTypeError("Object");
            } else {
                final IJSONSerializable<?> serial = fromJSON(object, ctx);
                if (null != serial) {
                    if (serial instanceof Node) {
                        if (false == factory.addNodeForContainer(container, (Node<?>) serial, ctx)) {
                            ;
                        }
                    } else {
                        ctx.addBadTypeError("Node");
                    }
                }
            }
            // index
            ctx.pop();
        }
    }
    // children
    ctx.pop();
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) Node(com.ait.lienzo.client.core.shape.Node) JSONArray(com.google.gwt.json.client.JSONArray)

Aggregations

Node (com.ait.lienzo.client.core.shape.Node)2 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)1 IColor (com.ait.lienzo.shared.core.types.IColor)1 JSONArray (com.google.gwt.json.client.JSONArray)1 JSONObject (com.google.gwt.json.client.JSONObject)1 JSONValue (com.google.gwt.json.client.JSONValue)1 Before (org.junit.Before)1