/** * Returns a string representation of the given matrix. * * @param matrix * the matrix to convert. */ protected String toString(AbstractMatrix2D matrix) { String[][] strings = this.format(matrix); align(strings); StringBuffer total = new StringBuffer(toString(strings)); if (printShape) total.insert(0, shape(matrix) + "\n"); return total.toString(); } }
/** * Returns a String with the given character repeated <tt>length</tt> times. */ protected String repeat(char character, int length) { if (character == ' ') return blanks(length); if (length < 0) length = 0; StringBuffer buf = new StringBuffer(length); for (int k = 0; k < length; k++) { buf.append(character); } return buf.toString(); }
/** * Returns the number of characters before the decimal point. */ protected int lead(String s) { if (alignment.equals(DECIMAL)) return indexOfDecimalPoint(s); return super.lead(s); }
/** * Returns a string representation of the receiver's shape. */ public String toStringShort() { return AbstractFormatter.shape(this); }
/** * Returns a string representation of the given matrix. * * @param matrix * the matrix to convert. */ public String toString(ObjectMatrix2D matrix) { return super.toString(matrix); }
/** * Modifies the strings the string matrix to be aligned * (left,centered,right,decimal). */ protected void alignRow(String[] row, int[] maxColWidth, int[] maxColLead) { StringBuffer s = new StringBuffer(); int columns = row.length; for (int column = 0; column < columns; column++) { s.setLength(0); String c = row[column]; if (alignment.equals(RIGHT)) { s.append(blanks(maxColWidth[column] - s.length())); s.append(c); } else if (alignment.equals(DECIMAL)) { s.append(blanks(maxColLead[column] - lead(c))); s.append(c); s.append(blanks(maxColWidth[column] - s.length())); } else if (alignment.equals(CENTER)) { s.append(blanks((maxColWidth[column] - c.length()) / 2)); s.append(c); s.append(blanks(maxColWidth[column] - s.length())); } else if (alignment.equals(LEFT)) { s.append(c); s.append(blanks(maxColWidth[column] - s.length())); } else throw new InternalError(); row[column] = s.toString(); } }
/** * Returns a string representations of all cells; no alignment considered. */ protected String[] formatRow(AbstractMatrix1D vector) { Former formatter = null; formatter = factory.create(format); int s = (int) vector.size(); String[] strings = new String[s]; for (int i = 0; i < s; i++) { strings[i] = form(vector, i, formatter); } return strings; }
/** * Returns a string representation of the receiver's shape. */ public String toStringShort() { return AbstractFormatter.shape(this); }
/** * Returns a string representation of the given matrix. * * @param matrix * the matrix to convert. */ public String toString(LongMatrix2D matrix) { return super.toString(matrix); }
/** * Modifies the strings the string matrix to be aligned * (left,centered,right,decimal). */ protected void alignRow(String[] row, int[] maxColWidth, int[] maxColLead) { StringBuffer s = new StringBuffer(); int columns = row.length; for (int column = 0; column < columns; column++) { s.setLength(0); String c = row[column]; if (alignment.equals(RIGHT)) { s.append(blanks(maxColWidth[column] - s.length())); s.append(c); } else if (alignment.equals(DECIMAL)) { s.append(blanks(maxColLead[column] - lead(c))); s.append(c); s.append(blanks(maxColWidth[column] - s.length())); } else if (alignment.equals(CENTER)) { s.append(blanks((maxColWidth[column] - c.length()) / 2)); s.append(c); s.append(blanks(maxColWidth[column] - s.length())); } else if (alignment.equals(LEFT)) { s.append(c); s.append(blanks(maxColWidth[column] - s.length())); } else throw new InternalError(); row[column] = s.toString(); } }
/** * Returns a string representations of all cells; no alignment considered. */ protected String[] formatRow(AbstractMatrix1D vector) { Former formatter = null; formatter = factory.create(format); int s = (int) vector.size(); String[] strings = new String[s]; for (int i = 0; i < s; i++) { strings[i] = form(vector, i, formatter); } return strings; }
/** * Returns a string representation of the receiver's shape. */ public String toStringShort() { return AbstractFormatter.shape(this); }
/** * Returns a string representation of the given matrix. * * @param matrix * the matrix to convert. */ protected String toString(AbstractMatrix2D matrix) { String[][] strings = this.format(matrix); align(strings); StringBuffer total = new StringBuffer(toString(strings)); if (printShape) total.insert(0, shape(matrix) + "\n"); return total.toString(); } }
/** * Returns a string representation of the given matrix. * * @param matrix * the matrix to convert. */ public String toString(DoubleMatrix2D matrix) { return super.toString(matrix); }
/** * Returns the number of characters before the decimal point. */ protected int lead(String s) { if (alignment.equals(DECIMAL)) return indexOfDecimalPoint(s); return super.lead(s); }
/** * Returns a String with the given character repeated <tt>length</tt> times. */ protected String repeat(char character, int length) { if (character == ' ') return blanks(length); if (length < 0) length = 0; StringBuffer buf = new StringBuffer(length); for (int k = 0; k < length; k++) { buf.append(character); } return buf.toString(); }
/** * Returns a string representation of the receiver's shape. */ public String toStringShort() { return AbstractFormatter.shape(this); }
/** * Returns a string representation of the given matrix. * * @param matrix * the matrix to convert. */ public String toString(LongMatrix2D matrix) { return super.toString(matrix); }