/** * a Constructor, usually called in the setup() method in your sketch to initialize and start the * library. * * @example Hello * @param theParent */ public PCandide(PApplet _p, String _s) { parent = _p; wfm = parent.loadStrings(_s); parseWfm(); apply = -1; welcome(); }
static public void load(InputStream input, Map table) throws IOException { String[] lines = PApplet.loadStrings(input); // Reads as UTF-8 for (String line : lines) { if ((line.length() == 0) || (line.charAt(0) == '#')) continue; // this won't properly handle = signs being in the text int equals = line.indexOf('='); if (equals != -1) { String key = line.substring(0, equals).trim(); String value = line.substring(equals + 1).trim(); table.put(key, value); } } }
/** Loads data from external sources. */ private void loadExtData() { String[] audioFrameAnalysisTxt = _parApp.loadStrings(_loadFilePathTxt); _audioFrameCnt = audioFrameAnalysisTxt.length; _frameDataCntNbr = audioFrameAnalysisTxt[0].split(DELIMITER_TXT).length; _musicData = new float[_audioFrameCnt][_frameDataCntNbr]; for (int audioFrameIdx = 0; audioFrameIdx < _audioFrameCnt - 1; audioFrameIdx++) { String bufferTxt = audioFrameAnalysisTxt[audioFrameIdx]; String[] bufferVals = bufferTxt.split(DELIMITER_TXT); for (int bufferIdx = 0; bufferIdx < _frameDataCntNbr; bufferIdx++) { _musicData[audioFrameIdx][bufferIdx] = Float.parseFloat(bufferVals[bufferIdx]); } } }
public static void main(String[] argv) { List<String> args = Arrays.asList(argv); if (args.size() % 2 == 1 || args.contains("--help") || args.contains("-h")) { usage(); return; } PApplet processing = new PApplet(); processing.init(); processing.start(); try { WordCram wordCram = new WordCram(processing) .fromTextString(PApplet.loadStrings(System.in)) .withColorer(Colorers.twoHuesRandomSats(processing)) .withAngler(Anglers.mostlyHoriz()) .withWordPadding(4) .withPlacer(Placers.centerClump()); ImageConfiguration imageConfig = parseArgs(args, wordCram); PGraphics image = processing.createGraphics(imageConfig.width, imageConfig.height, JAVA2D); try { wordCram.withCustomCanvas(image); image.beginDraw(); wordCram.drawAll(); image.endDraw(); image.save(imageConfig.fileName); } finally { image.dispose(); } processing.stop(); System.exit(0); } catch (Throwable t) { System.err.println(t.getMessage()); System.exit(1); } }
public FloatHash(PApplet parent, String filename) { String[] lines = parent.loadStrings(filename); keys = new String[lines.length]; values = new float[lines.length]; // boolean csv = (lines[0].indexOf('\t') == -1); for (int i = 0; i < lines.length; i++) { // String[] pieces = csv ? Table.splitLineCSV(lines[i]) : PApplet.split(lines[i], '\t'); String[] pieces = PApplet.split(lines[i], '\t'); if (pieces.length == 2) { keys[count] = pieces[0]; values[count] = PApplet.parseFloat(pieces[1]); count++; } } }