Exemplo n.º 1
0
static void printRawMatrix(SEXP sx, int offset, int r_pr, int r, int c,
                           SEXP rl, SEXP cl, const char *rn, const char *cn)
{
    _PRINT_INIT_rl_rn;
    Rbyte *x = RAW(sx) + offset;

    for (j = 0; j < c; j++) {
        formatRaw(&x[j * r], (R_xlen_t) r, &w[j]);
        _PRINT_SET_clabw;
        if (w[j] < clabw)
            w[j] = clabw;
        w[j] += R_print.gap;
    }
    _PRINT_DEAL_c_eq_0;
    while (jmin < c) {
        width = rlabw;
        do {
            width += w[jmax];
            jmax++;
        }
        while (jmax < c && width + w[jmax] < R_print.width);

        _PRINT_ROW_LAB;

        for (j = jmin; j < jmax ; j++)
            MatrixColumnLabel(cl, j, w[j]);
        for (i = 0; i < r_pr; i++) {
            MatrixRowLabel(rl, i, rlabw, lbloff);
            for (j = jmin; j < jmax; j++)
                Rprintf("%*s%s", w[j]-2, "", EncodeRaw(x[i + j * r], ""));
        }
        Rprintf("\n");
        jmin = jmax;
    }
}
Exemplo n.º 2
0
static int
setFormat(JNIEnv *env, jobject jxil, InstanceState *inst)
{
    jboolean isInstance;
    jobject jStream;

    /*    Debug Message */
    PRINT("XILCapture in setFormat \n");

    jStream = GetObjectField(env, jxil, "stream",
				"Ljavax/media/protocol/SourceStream;");
    if (!jStream) {
	/*    Debug Message */
	PRINT("XILCapture setFormat failed to obtain stream \n");
	return 0;
    }
    isInstance = IsInstanceOf(env, jStream, 
			"com/sun/media/protocol/sunvideo/SunVideoSourceStream");
    if (!isInstance) {
	/*    Debug Message */
	PRINT("XILCapture setFormat stream not valid instance \n");
	return 0;
    }
    if (inst->do_cis == RAW) {
	return formatRaw(env, jxil, inst, jStream);
    } else if (inst->do_cis == JPEG) {
	return formatJpeg(env, jxil, inst, jStream);
    } else {
	return formatMpeg(env, jxil, inst, jStream);
    }
}
Exemplo n.º 3
0
void printRawVector(Rbyte *x, int n, int indx)
{
    int i, w, labwidth=0, width;

    DO_first_lab;
    formatRaw(x, n, &w);
    w += R_print.gap;

    for (i = 0; i < n; i++) {
	if (i > 0 && width + w > R_print.width) {
	    DO_newline;
	}
	Rprintf("%*s%s", R_print.gap, "", EncodeRaw(x[i]));
	width += w;
    }
    Rprintf("\n");
}
Exemplo n.º 4
0
SEXP attribute_hidden do_formatinfo(SEXP call, SEXP op, SEXP args, SEXP env)
{
    SEXP x;
    int digits, nsmall, no = 1, w, d, e, wi, di, ei;

    checkArity(op, args);
    x = CAR(args);
    R_xlen_t n = XLENGTH(x);
    PrintDefaults();

    digits = asInteger(CADR(args));
    if (!isNull(CADR(args))) {
	digits = asInteger(CADR(args));
	if (digits == NA_INTEGER || digits < R_MIN_DIGITS_OPT
	    || digits > R_MAX_DIGITS_OPT)
	    error(_("invalid '%s' argument"), "digits");
	R_print.digits = digits;
    }
    nsmall = asInteger(CADDR(args));
    if (nsmall == NA_INTEGER || nsmall < 0 || nsmall > 20)
	error(_("invalid '%s' argument"), "nsmall");

    w = 0;
    d = 0;
    e = 0;
    switch (TYPEOF(x)) {

    case RAWSXP:
	formatRaw(RAW(x), n, &w);
	break;

    case LGLSXP:
	formatLogical(LOGICAL(x), n, &w);
	break;

    case INTSXP:
	formatInteger(INTEGER(x), n, &w);
	break;

    case REALSXP:
	no = 3;
	formatReal(REAL(x), n, &w, &d, &e, nsmall);
	break;

    case CPLXSXP:
	no = 6;
	wi = di = ei = 0;
	formatComplex(COMPLEX(x), n, &w, &d, &e, &wi, &di, &ei, nsmall);
	break;

    case STRSXP:
	for (R_xlen_t i = 0; i < n; i++)
	    if (STRING_ELT(x, i) != NA_STRING) {
		int il = Rstrlen(STRING_ELT(x, i), 0);
		if (il > w) w = il;
	    }
	break;

    default:
	error(_("atomic vector arguments only"));
    }
    x = allocVector(INTSXP, no);
    INTEGER(x)[0] = w;
    if(no > 1) {
	INTEGER(x)[1] = d;
	INTEGER(x)[2] = e;
    }
    if(no > 3) {
	INTEGER(x)[3] = wi;
	INTEGER(x)[4] = di;
	INTEGER(x)[5] = ei;
    }
    return x;
}