static protected int getShaderType(String[] source, int defaultType) { for (int i = 0; i < source.length; i++) { String line = source[i].trim(); if (PApplet.match(line, pointShaderAttrRegexp) != null) return PShader.POINT; else if (PApplet.match(line, lineShaderAttrRegexp) != null) return PShader.LINE; else if (PApplet.match(line, pointShaderDefRegexp) != null) return PShader.POINT; else if (PApplet.match(line, lineShaderDefRegexp) != null) return PShader.LINE; else if (PApplet.match(line, colorShaderDefRegexp) != null) return PShader.COLOR; else if (PApplet.match(line, lightShaderDefRegexp) != null) return PShader.LIGHT; else if (PApplet.match(line, texShaderDefRegexp) != null) return PShader.TEXTURE; else if (PApplet.match(line, texlightShaderDefRegexp) != null) return PShader.TEXLIGHT; else if (PApplet.match(line, polyShaderDefRegexp) != null) return PShader.POLY; else if (PApplet.match(line, triShaderAttrRegexp) != null) return PShader.POLY; else if (PApplet.match(line, quadShaderAttrRegexp) != null) return PShader.POLY; } return defaultType; }
String line = source[i].trim(); if (PApplet.match(line, colorShaderDefRegexp) != null) return PShader.COLOR; else if (PApplet.match(line, lightShaderDefRegexp) != null) return PShader.LIGHT; else if (PApplet.match(line, texShaderDefRegexp) != null) return PShader.TEXTURE; else if (PApplet.match(line, texlightShaderDefRegexp) != null) return PShader.TEXLIGHT; else if (PApplet.match(line, polyShaderDefRegexp) != null) return PShader.POLY; else if (PApplet.match(line, triShaderAttrRegexp) != null) return PShader.POLY; else if (PApplet.match(line, quadShaderAttrRegexp) != null) return PShader.POLY; else if (PApplet.match(line, pointShaderDefRegexp) != null) return PShader.POINT; else if (PApplet.match(line, lineShaderDefRegexp) != null) return PShader.LINE; else if (PApplet.match(line, pointShaderAttrRegexp) != null) return PShader.POINT; else if (PApplet.match(line, pointShaderInRegexp) != null) return PShader.POINT; else if (PApplet.match(line, lineShaderAttrRegexp) != null) return PShader.LINE; else if (PApplet.match(line, lineShaderInRegexp) != null) return PShader.LINE;
/** * Return the row that contains the first String that matches. * @param regexp the String to match * @param column ID number of the column to search */ public int matchRowIndex(String regexp, int column) { checkColumn(column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; for (int row = 0; row < rowCount; row++) { if (stringData[row] != null && PApplet.match(stringData[row], regexp) != null) { return row; } } } else { // less efficient, includes conversion as necessary for (int row = 0; row < rowCount; row++) { String str = getString(row, column); if (str != null && PApplet.match(str, regexp) != null) { return row; } } } return -1; }
/** * Return the row that contains the first String that matches. * @param regexp the String to match * @param column ID number of the column to search */ public int matchRowIndex(String regexp, int column) { checkColumn(column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; for (int row = 0; row < rowCount; row++) { if (stringData[row] != null && PApplet.match(stringData[row], regexp) != null) { return row; } } } else { // less efficient, includes conversion as necessary for (int row = 0; row < rowCount; row++) { String str = getString(row, column); if (str != null && PApplet.match(str, regexp) != null) { return row; } } } return -1; }
/** * Return a list of rows that contain the String passed in. If there are no * matches, a zero length array will be returned (not a null array). * @param regexp the String to match * @param column ID number of the column to search */ public int[] matchRowIndices(String regexp, int column) { int[] outgoing = new int[rowCount]; int count = 0; checkColumn(column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; for (int row = 0; row < rowCount; row++) { if (stringData[row] != null && PApplet.match(stringData[row], regexp) != null) { outgoing[count++] = row; } } } else { // less efficient, includes conversion as necessary for (int row = 0; row < rowCount; row++) { String str = getString(row, column); if (str != null && PApplet.match(str, regexp) != null) { outgoing[count++] = row; } } } return PApplet.subset(outgoing, 0, count); }
static public String[] parseSketchSmooth(String code, boolean fussy, Context context) { String[] matches = PApplet.match(scrubComments(code), SMOOTH_REGEX); if (matches != null) { boolean badSmooth = false; if (PApplet.parseInt(matches[1], -1) == -1) { badSmooth = true; } if (badSmooth && fussy) { // found a reference to smooth, but it didn't seem to contain numbers // final String message = // "The smooth level of this applet could not automatically\n" + // "be determined from your code. Use only a numeric\n" + // "value (not variables) for the smooth() command.\n" + // "See the smooth() reference for an explanation."; // Messages.showWarning("Could not find smooth level", message, null); showWarning(context.getResources().getString(R.string.preproc_no_smooth), context.getResources().getString(R.string.preproc_no_smooth_message)); // new Exception().printStackTrace(System.out); return null; } return matches; } return new String[] { null, null }; // not an error, just empty }
/** * Return a list of rows that contain the String passed in. If there are no * matches, a zero length array will be returned (not a null array). * @param what the String to match * @param column ID number of the column to search */ public int[] matchRowIndices(String regexp, int column) { int[] outgoing = new int[rowCount]; int count = 0; checkColumn(column); if (columnTypes[column] == STRING) { String[] stringData = (String[]) columns[column]; for (int row = 0; row < rowCount; row++) { if (stringData[row] != null && PApplet.match(stringData[row], regexp) != null) { outgoing[count++] = row; } } } else { // less efficient, includes conversion as necessary for (int row = 0; row < rowCount; row++) { String str = getString(row, column); if (str != null && PApplet.match(str, regexp) != null) { outgoing[count++] = row; } } } return PApplet.subset(outgoing, 0, count); }
static protected PMatrix2D parseSingleTransform(String matrixStr) { String[] pieces = PApplet.match(matrixStr, "[,\\s]*(\\w+)\\((.*)\\)"); if (pieces == null) { System.err.println("Could not parse transform " + matrixStr);
static protected PMatrix2D parseSingleTransform(String matrixStr) { String[] pieces = PApplet.match(matrixStr, "[,\\s]*(\\w+)\\((.*)\\)"); if (pieces == null) { System.err.println("Could not parse transform " + matrixStr);
String[] m = PApplet.match(name, "_x([A-Za-z0-9]{2})_"); if (m == null) break; char repair = (char) PApplet.unhex(m[1]);
String[] m = PApplet.match(name, "_x([A-Za-z0-9]{2})_"); if (m == null) break; char repair = (char) PApplet.unhex(m[1]);