From 982db8e89dc4513b99699563c7868421193df124 Mon Sep 17 00:00:00 2001 From: benfry Date: Sun, 9 Dec 2012 21:02:53 +0000 Subject: [PATCH] closing up Table work, moving functions a bit, hide unapproved --- core/src/processing/data/Table.java | 94 ++++++++++++++--------------- core/todo.txt | 54 +++++++++-------- 2 files changed, 76 insertions(+), 72 deletions(-) diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 61b2fbd0a..973f01ee0 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -2223,53 +2223,6 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - /** - * Remove any of the specified characters from the entire table. - */ - public void removeTokens(String tokens) { - for (int col = 0; col < getColumnCount(); col++) { - removeTokens(tokens, col); - } - } - - - /** - * Removed any of the specified characters from a column. For instance, - * the following code removes dollar signs and commas from column 2: - *
-   * table.removeTokens(",$", 2);
-   * 
- */ - public void removeTokens(String tokens, int column) { - for (int row = 0; row < rowCount; row++) { - String s = getString(row, column); - if (s != null) { - char[] c = s.toCharArray(); - int index = 0; - for (int j = 0; j < c.length; j++) { - if (tokens.indexOf(c[j]) == -1) { - if (index != j) { - c[index] = c[j]; - } - index++; - } - } - if (index != c.length) { - setString(row, column, new String(c, 0, index)); - } - } - } - } - - - public void removeTokens(String tokens, String columnName) { - removeTokens(tokens, getColumnIndex(columnName)); - } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - /** * Return the row that contains the first String that matches. * @param value the String to match @@ -2574,6 +2527,53 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + /** + * Remove any of the specified characters from the entire table. + */ + public void removeTokens(String tokens) { + for (int col = 0; col < getColumnCount(); col++) { + removeTokens(tokens, col); + } + } + + + /** + * Removed any of the specified characters from a column. For instance, + * the following code removes dollar signs and commas from column 2: + *
+   * table.removeTokens(",$", 2);
+   * 
+ */ + public void removeTokens(String tokens, int column) { + for (int row = 0; row < rowCount; row++) { + String s = getString(row, column); + if (s != null) { + char[] c = s.toCharArray(); + int index = 0; + for (int j = 0; j < c.length; j++) { + if (tokens.indexOf(c[j]) == -1) { + if (index != j) { + c[index] = c[j]; + } + index++; + } + } + if (index != c.length) { + setString(row, column, new String(c, 0, index)); + } + } + } + } + + + public void removeTokens(String tokens, String columnName) { + removeTokens(tokens, getColumnIndex(columnName)); + } + + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + public void trim() { for (int col = 0; col < getColumnCount(); col++) { trim(col); diff --git a/core/todo.txt b/core/todo.txt index 5e68e154a..4a9b762d4 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -6,33 +6,37 @@ X heading2D()? weird.. changed to heading() X http://toxiclibs.org/docs/core/toxi/geom/Vec3D.html X http://code.google.com/p/processing/issues/detail?id=987 -X lots of improvements/cleanups to Table class -X added lastRowIndex() -X rows() instead of getRows() (doesn't perform like our other get() functions) -X it's more like keys() and values() in HashMap -X addRow() returns TableRow object to be modified -X lastRowIndex() (to avoid getRowCount() - 1) -X not lastRow() because Row functions return TableRow object/intf +table +X added lastRowIndex() +X rows() instead of getRows() (doesn't perform like our other get() functions) +X it's more like keys() and values() in HashMap +X addRow() returns TableRow object to be modified +X lastRowIndex() (to avoid getRowCount() - 1) +X not lastRow() because Row functions return TableRow object/intf +X makeNullEmpty() -> replace(null, ""); +X makeEmptyNull() -> replace("", null); +X saveTable("filename.tsv") or saveTable("filename.txt", "tsv") +X createTable() method in PApplet +X removed getUniqueXxxx() and some others, pending names -X makeNullEmpty() -> replace(null, ""); -X makeEmptyNull() -> replace("", null); +more table +_ naming for these (or whether to include hash) +_ Table createSubset() -> leave out? +_ String[] getUnique(col) +_ HashMap getUniqueCount(col) +_ possible features +_ create table from TableRow iterator...allows for subset and find +_ downside is types are not included +_ getMaxFloat() (whole table) or getMaxFloat(col) +_ that's max(getFloatColumn(n)) +_ also important b/c can leave out missing values +_ include SQL, HTML, ODS, binary? +_ naming HTMLTable, TableHTML (ala PShapeSVG) +_ or should it be HTMLTable / HtmlTable... then SVGShape / SvgShape +_ dictionary support +_ join tables together (static is kinda gross) -createTable() -need option to save table - -_ create table from TableRow iterator...allows for subset and find - -naming for these (or whether to include hash) -Table createSubset() -> leave out? -String[] getUnique(col) -HashMap getUniqueCount(col) - -features? -getMaxFloat() (whole table) or getMaxFloat(col) (that's max(getFloatColumn(n)) - also important b/c can leave out missing values -include SQL, HTML, ODS, binary? - -join tables together (static is kinda gross) +. . . PShape s = createShape(); s.beginShape(QUADS);