mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 14:19:19 +01:00
table debugging for iterator constructor and HTML export
This commit is contained in:
@@ -168,6 +168,8 @@ public class Table {
|
||||
// Do this after setting types, otherwise it'll attempt to parse the
|
||||
// allocated but empty rows, and drive CATEGORY columns nutso.
|
||||
setRowCount(alloc);
|
||||
// sometimes more columns than titles (and types?)
|
||||
setColumnCount(incoming.getColumnCount());
|
||||
|
||||
} else if (row == alloc) {
|
||||
// Far more efficient than re-allocating all columns and doing a copy
|
||||
@@ -176,7 +178,14 @@ public class Table {
|
||||
}
|
||||
|
||||
//addRow(row);
|
||||
// try {
|
||||
setRow(row++, incoming);
|
||||
// } catch (ArrayIndexOutOfBoundsException aioobe) {
|
||||
// for (int i = 0; i < incoming.getColumnCount(); i++) {
|
||||
// System.out.format("[%d] %s%n", i, incoming.getString(i));
|
||||
// }
|
||||
// throw aioobe;
|
||||
// }
|
||||
}
|
||||
// Shrink the table to only the rows that were used
|
||||
if (row != alloc) {
|
||||
@@ -1034,12 +1043,18 @@ public class Table {
|
||||
|
||||
protected void writeCSV(PrintWriter writer) {
|
||||
if (columnTitles != null) {
|
||||
for (int col = 0; col < columns.length; col++) {
|
||||
for (int col = 0; col < getColumnCount(); col++) {
|
||||
if (col != 0) {
|
||||
writer.print(',');
|
||||
}
|
||||
if (columnTitles[col] != null) {
|
||||
writeEntryCSV(writer, columnTitles[col]);
|
||||
try {
|
||||
if (columnTitles[col] != null) { // col < columnTitles.length &&
|
||||
writeEntryCSV(writer, columnTitles[col]);
|
||||
}
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
PApplet.printArray(columnTitles);
|
||||
PApplet.printArray(columns);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
writer.println();
|
||||
@@ -1110,13 +1125,24 @@ public class Table {
|
||||
|
||||
writer.println("<body>");
|
||||
writer.println(" <table>");
|
||||
|
||||
if (hasColumnTitles()) {
|
||||
writer.println(" <tr>");
|
||||
for (String entry : getColumnTitles()) {
|
||||
writer.print(" <th>");
|
||||
writeEntryHTML(writer, entry);
|
||||
writer.println("</th>");
|
||||
}
|
||||
writer.println(" </tr>");
|
||||
}
|
||||
|
||||
for (int row = 0; row < getRowCount(); row++) {
|
||||
writer.println(" <tr>");
|
||||
for (int col = 0; col < getColumnCount(); col++) {
|
||||
String entry = getString(row, col);
|
||||
writer.print(" <td>");
|
||||
writeEntryHTML(writer, entry);
|
||||
writer.println(" </td>");
|
||||
writer.println("</td>");
|
||||
}
|
||||
writer.println(" </tr>");
|
||||
}
|
||||
@@ -1652,6 +1678,7 @@ public class Table {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @webref table:method
|
||||
* @brief Gets the number of columns in a table
|
||||
@@ -2078,7 +2105,7 @@ public class Table {
|
||||
// Make sure there are enough columns to add this data
|
||||
ensureBounds(row, source.getColumnCount() - 1);
|
||||
|
||||
for (int col = 0; col < columns.length; col++) {
|
||||
for (int col = 0; col < Math.min(source.getColumnCount(), columns.length); col++) {
|
||||
switch (columnTypes[col]) {
|
||||
case INT:
|
||||
setInt(row, col, source.getInt(col));
|
||||
|
||||
Reference in New Issue
Block a user