// This sample demonstrates how to constrain a node // to allow moving and resizing it only horizontally // Create a new node ShapeNode node = diagram.getFactory().createShapeNode(10, 10, 40, 20); // Enable only move and left/right resize handles node.setEnabledHandles(AdjustmentHandles.Move | AdjustmentHandles.ResizeMiddleLeft | AdjustmentHandles.ResizeMiddleRight); // Allow moving the node only horizontally node.getConstraints().setMoveDirection(DirectionConstraint.Horizontal); // Hide the disabled handles diagram.setShowDisabledHandles(false); |