static _paintGateTooltip_matrix(painter, gate, matrix, pad, dispSize, w, pushRect, nextY) {
        if (matrix === undefined) {
            return;
        }

        pushRect(new Rect(0, nextY(), 1, 0), pad*2);
        pushRect(painter.printParagraph('As matrix:', new Rect(pad, nextY(), w, 18), new Point(0, 0), 'black', 12), 0);
        let matrixRect = new Rect(pad, nextY(), dispSize, dispSize);
        let matrixDescRect = new Rect(0, matrixRect.y, w - pad, dispSize).skipLeft(matrixRect.right() + pad);
        MathPainter.paintMatrix(
            painter,
            matrix,
            matrixRect,
            Config.OPERATION_FORE_COLOR,
            'black',
            undefined,
            Config.OPERATION_BACK_COLOR,
            undefined,
            'transparent');
        pushRect(matrixRect);
        let n = matrix.height();
        if (n <= 4) {
            let format = gate.stableDuration() < 0.2 ? Format.CONSISTENT : Format.SIMPLIFIED;
            let matDescs = WidgetPainter.describeGateTransformations(matrix, format);
            let rowHeight = matrixDescRect.h / n;
            for (let r = 0; r < n; r++) {
                pushRect(painter.printParagraph(
                    matDescs[r],
                    matrixDescRect.skipTop(r * rowHeight).takeTop(rowHeight),
                    new Point(0, 0.5),
                    'black',
                    12));
            }
        }
    }
@param {!Painter} painter
@param {!Gate} gate
@param {undefined|!Matrix} matrix
@param {!number} pad
@param {!number} dispSize
@param {!number} w
@param {!function(!Rect, pad:!number=):void} pushRect
@param {!function():!number} nextY
@private