/** * @param right number of digits to the right of the decimal point */ static public String[] nfc(float nums[], int right) { String formatted[] = new String[nums.length]; for (int i = 0; i < formatted.length; i++) { formatted[i] = nfc(nums[i], right); } return formatted; }
static public String[] nfc(int num[]) { String formatted[] = new String[num.length]; for (int i = 0; i < formatted.length; i++) { formatted[i] = nfc(num[i]); } return formatted; }
static public String[] nfc(float num[], int right) { String formatted[] = new String[num.length]; for (int i = 0; i < formatted.length; i++) { formatted[i] = nfc(num[i], right); } return formatted; }
/** * ( begin auto-generated from nfc.xml ) * * Utility function for formatting numbers into strings and placing * appropriate commas to mark units of 1000. There are two versions, one * for formatting ints and one for formatting an array of ints. The value * for the <b>digits</b> parameter should always be a positive integer. * <br/><br/> * For a non-US locale, this will insert periods instead of commas, or * whatever is apprioriate for that region. * * ( end auto-generated ) * @webref data:string_functions * @param nums the numbers to format * @see PApplet#nf(float, int, int) * @see PApplet#nfp(float, int, int) * @see PApplet#nfs(float, int, int) */ static public String[] nfc(int nums[]) { String formatted[] = new String[nums.length]; for (int i = 0; i < formatted.length; i++) { formatted[i] = nfc(nums[i]); } return formatted; }
public void setRowCount(int newCount) { if (newCount != rowCount) { if (newCount > 1000000) { System.out.print("Note: setting maximum row count to " + PApplet.nfc(newCount)); } long t = System.currentTimeMillis(); for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { case INT: columns[col] = PApplet.expand((int[]) columns[col], newCount); break; case LONG: columns[col] = PApplet.expand((long[]) columns[col], newCount); break; case FLOAT: columns[col] = PApplet.expand((float[]) columns[col], newCount); break; case DOUBLE: columns[col] = PApplet.expand((double[]) columns[col], newCount); break; case STRING: columns[col] = PApplet.expand((String[]) columns[col], newCount); break; case CATEGORY: columns[col] = PApplet.expand((int[]) columns[col], newCount); break; } if (newCount > 1000000) { try { Thread.sleep(10); // gc time! } catch (InterruptedException e) { e.printStackTrace(); } } } if (newCount > 1000000) { int ms = (int) (System.currentTimeMillis() - t); System.out.println(" (resize took " + PApplet.nfc(ms) + " ms)"); } } rowCount = newCount; }
public void setRowCount(int newCount) { if (newCount != rowCount) { if (newCount > 1000000) { System.out.print("Note: setting maximum row count to " + PApplet.nfc(newCount)); } long t = System.currentTimeMillis(); for (int col = 0; col < columns.length; col++) { switch (columnTypes[col]) { case INT: columns[col] = PApplet.expand((int[]) columns[col], newCount); break; case LONG: columns[col] = PApplet.expand((long[]) columns[col], newCount); break; case FLOAT: columns[col] = PApplet.expand((float[]) columns[col], newCount); break; case DOUBLE: columns[col] = PApplet.expand((double[]) columns[col], newCount); break; case STRING: columns[col] = PApplet.expand((String[]) columns[col], newCount); break; case CATEGORY: columns[col] = PApplet.expand((int[]) columns[col], newCount); break; } if (newCount > 1000000) { try { Thread.sleep(10); // gc time! } catch (InterruptedException e) { e.printStackTrace(); } } } if (newCount > 1000000) { int ms = (int) (System.currentTimeMillis() - t); System.out.println(" (resize took " + PApplet.nfc(ms) + " ms)"); } } rowCount = newCount; }
protected BoxplotSelection getPercentileSelection(float x0, float x1, float v0, float v1, float p, double valx, double valy, int counts, boolean shift) { float y0 = 1 - v1; float dy = v1 - v0; float y1 = y0 + dy; if (x0 <= valx && valx <= x1 && y0 <= valy && valy <= y1) { BoxplotSelection sel = new BoxplotSelection(x0, y0, x1 - x0, dy); sel.setColor(mixColors(WHITE, COLOR, 0.5f)); if (shift) { sel.setLabel(PApplet.round(p * counts) + "/" + counts); } else { sel.setLabel(PApplet.nfc(100 * p, 2) + "%"); } return sel; } return null; }
public Selection getSelection(double valx, double valy, boolean shift) { if (canDraw()) { float binw = 1.0f / binCount; for (int bx = 0; bx < binCount; bx++) { float p = density[bx]; float h = PApplet.map(p, 0, maxProb, 0, 0.5f); float x0 = binw * bx; float x1 = binw * bx + binw; if (x0 < valx && valx < x1) { Selection sel = new Selection(x0, (1 - h), binw, h); if (shift) { sel.setLabel(PApplet.round(sampleSize * p) + "/" + sampleSize); } else { sel.setLabel(PApplet.nfc(100 * p, 2) + "%"); } return sel; } } } else { return getUnavailableSelection(); } return null; }
public Selection getSelection(double valx, double valy, boolean shift) { if (canDraw()) { float binw = 1.0f / binCountX; float binh = 1.0f / binCountY; for (int bx = 0; bx < binCountX; bx++) { for (int by = 0; by < binCountY; by++) { float x0 = binw * bx; float y0 = 1 - binh * by - binh; float x1 = x0 + binw; float y1 = y0 + binh; if (x0 <= valx && valx <= x1 && y0 <= valy && valy <= y1) { Selection sel = new Selection(x0, y0, binw, binh); float p = density[bx][by]; float np = PApplet.map(p, 0, maxProb, 0, 1); sel.setColor(mixColors(WHITE, COLOR, np)); if (shift) { sel.setLabel(PApplet.round(sampleSize * p) + "/" + sampleSize); } else { sel.setLabel(PApplet.nfc(100 * p, 2) + "%"); } return sel; } } } } else { return getUnavailableSelection(); } return null; }
protected void drawSelection() { float x0 = rightm; float x1 = x0 + width - leftm - rightm; float y0 = topm - 10; float y1 = y0 + height - bottomm - topm; noStroke(); fill(selBarColor); rect(x0, y1, x1 - x0, selW); float selx0 = PApplet.map(selRangeLeft, 0, 1, x0, x1); float selx1 = selRightHandle.x0; //PApplet.map(selRangeRight, 0, 1, x0, x1); fill(selBarColor); rect(selx0, y0, selx1 - selx0, y1 - y0); fill(color(0), 190); rect(selx0, y1, selx1 - selx0, selW); selRightHandle.draw(); if (mira.project.sortMethod == Project.PVALUE) { textFont(pFont); fill(pColor); textAlign(CENTER); text("False Discovery Rate < " + PApplet.nfc(fdr, 2) + "%", selx1, y0 - fdrY); textAlign(LEFT); } }