📄 resultmatrix.java
字号:
/** * sets whether the row names or numbers instead are printed * deactivating automatically sets m_EnumerateColNames to TRUE. * @see #setEnumerateRowNames(boolean) */ public void setPrintRowNames(boolean print) { m_PrintRowNames = print; if (!print) setEnumerateRowNames(true); } /** * returns whether row names or numbers instead are printed */ public boolean getPrintRowNames() { return m_PrintRowNames; } /** * sets whether the column names are prefixed with "(x)" where "x" is * the index */ public void setEnumerateColNames(boolean enumerate) { m_EnumerateColNames = enumerate; } /** * returns whether column names or numbers instead are enumerateed */ public boolean getEnumerateColNames() { return m_EnumerateColNames; } /** * sets whether to the row names or numbers instead are enumerateed */ public void setEnumerateRowNames(boolean enumerate) { m_EnumerateRowNames = enumerate; } /** * returns whether row names or numbers instead are enumerateed */ public boolean getEnumerateRowNames() { return m_EnumerateRowNames; } /** * returns the number of columns */ public int getColCount() { return m_ColNames.length; } /** * returns the number of visible columns */ public int getVisibleColCount() { int cols; int i; cols = 0; for (i = 0; i < getColCount(); i++) { if (!getColHidden(i)) cols++; } return cols; } /** * returns the number of rows */ public int getRowCount() { return m_RowNames.length; } /** * returns the number of visible rows */ public int getVisibleRowCount() { int rows; int i; rows= 0; for (i = 0; i < getRowCount(); i++) { if (!getRowHidden(i)) rows++; } return rows; } /** * sets the name of the column (if the index is valid) * @param index the index of the column * @param name the name of the column */ public void setColName(int index, String name) { if ( (index >= 0) && (index < getColCount()) ) m_ColNames[index] = name; } /** * returns the name of the row, if the index is valid, otherwise null. * if getPrintColNames() is FALSE then an empty string is returned or if * getEnumerateColNames() is TRUE then the 1-based index surrounded by * parentheses. * @see #setPrintColNames(boolean) * @see #getPrintColNames() * @see #setEnumerateColNames(boolean) * @see #getEnumerateColNames() */ public String getColName(int index) { String result; result = null; if ( (index >= 0) && (index < getColCount()) ) { if (getPrintColNames()) result = m_ColNames[index]; else result = ""; if (getEnumerateColNames()) { result = LEFT_PARENTHESES + Integer.toString(index + 1) + RIGHT_PARENTHESES + " " + result; result = result.trim(); } } return result; } /** * sets the name of the row (if the index is valid) * @param index the index of the row * @param name the name of the row */ public void setRowName(int index, String name) { if ( (index >= 0) && (index < getRowCount()) ) m_RowNames[index] = name; } /** * returns the name of the row, if the index is valid, otherwise null. * if getPrintRowNames() is FALSE then an empty string is returned or if * getEnumerateRowNames() is TRUE then the 1-based index surrounded by * parentheses. * @see #setPrintRowNames(boolean) * @see #getPrintRowNames() * @see #setEnumerateRowNames(boolean) * @see #getEnumerateRowNames() */ public String getRowName(int index) { String result; result = null; if ( (index >= 0) && (index < getRowCount()) ) { if (getPrintRowNames()) result = m_RowNames[index]; else result = ""; if (getEnumerateRowNames()) { result = LEFT_PARENTHESES + Integer.toString(index + 1) + RIGHT_PARENTHESES + " " + result; result = result.trim(); } } return result; } /** * sets the hidden status of the column (if the index is valid) * @param index the index of the column * @param hidden the hidden status of the column */ public void setColHidden(int index, boolean hidden) { if ( (index >= 0) && (index < getColCount()) ) m_ColHidden[index] = hidden; } /** * returns the hidden status of the column, if the index is valid, otherwise * false */ public boolean getColHidden(int index) { if ( (index >= 0) && (index < getColCount()) ) return m_ColHidden[index]; else return false; } /** * sets the hidden status of the row (if the index is valid) * @param index the index of the row * @param hidden the hidden status of the row */ public void setRowHidden(int index, boolean hidden) { if ( (index >= 0) && (index < getRowCount()) ) m_RowHidden[index] = hidden; } /** * returns the hidden status of the row, if the index is valid, otherwise * false */ public boolean getRowHidden(int index) { if ( (index >= 0) && (index < getRowCount()) ) return m_RowHidden[index]; else return false; } /** * sets the count for the row (if the index is valid) * @param index the index of the row * @param count the count for the row */ public void setCount(int index, double count) { if ( (index >= 0) && (index < getRowCount()) ) m_Counts[index] = count; } /** * returns the count for the row. if the index is invalid then 0. * @param index the index of the row * @return the count for the row */ public double getCount(int index) { if ( (index >= 0) && (index < getRowCount()) ) return m_Counts[index]; else return 0; } /** * sets the mean at the given position (if the position is valid) * @param col the column of the mean * @param row the row of the mean * @param value the value of the mean */ public void setMean(int col, int row, double value) { if ( (col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount()) ) m_Mean[row][col] = value; } /** * returns the mean at the given position, if the position is valid, * otherwise 0 */ public double getMean(int col, int row) { if ( (col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount()) ) return m_Mean[row][col]; else return 0; } /** * returns the average of the mean at the given position, if the position is * valid, otherwise 0 */ public double getAverage(int col) { int i; double avg; int count; if ( (col >= 0) && (col < getColCount()) ) { avg = 0; count = 0; for (i = 0; i < getRowCount(); i++) { if (!Double.isNaN(getMean(col, i))) { avg += getMean(col, i); count++; } } return avg / (double) count; } else { return 0; } } /** * sets the std deviation at the given position (if the position is valid) * @param col the column of the std. deviation * @param row the row of the std deviation * @param value the value of the std deviation */ public void setStdDev(int col, int row, double value) { if ( (col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount()) ) m_StdDev[row][col] = value; } /** * returns the std deviation at the given position, if the position is valid, * otherwise 0 */ public double getStdDev(int col, int row) { if ( (col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount()) ) return m_StdDev[row][col]; else return 0; } /** * sets the significance at the given position (if the position is valid) * @param col the column of the significance * @param row the row of the significance * @param value the value of the significance */ public void setSignificance(int col, int row, int value) { if ( (col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount()) ) m_Significance[row][col] = value; } /** * returns the significance at the given position, if the position is valid, * otherwise SIGNIFICANCE_ATIE */ public int getSignificance(int col, int row) { if ( (col >= 0) && (col < getColCount()) && (row >= 0) && (row < getRowCount()) ) return m_Significance[row][col]; else return SIGNIFICANCE_TIE; } /** * counts the occurrences of the given significance type in the given * column. * @param col the columnn to gather the information from * @param type the significance type, WIN/TIE/LOSS */ public int getSignificanceCount(int col, int type) { int result; int i; result = 0; if ( (col >= 0) && (col < getColCount()) ) { for (i = 0; i < getRowCount(); i++) { if (getRowHidden(i)) continue; // no value? if (Double.isNaN(getMean(col, i))) continue; if (getSignificance(col, i) == type) result++; } } return result; } /** * sets the ordering of the rows, null means default * @param order the new order of the rows */ public void setRowOrder(int[] order) { int i; // default order? if (order == null) { m_RowOrder = null; } else { if (order.length == getRowCount()) { m_RowOrder = new int[order.length]; for (i = 0; i < order.length; i++) m_RowOrder[i] = order[i]; } else { System.err.println("setRowOrder: length does not match (" + order.length + " <> " + getRowCount() + ") - ignored!"); } } } /** * returns the current order of the rows, null means the default order * @return the current order of the rows */ public int[] getRowOrder() { return m_RowOrder; } /** * returns the displayed index of the given row, depending on the order of * rows, returns -1 if index out of bounds * @param index the row to get the displayed index for * @return the real index of the row */ public int getDisplayRow(int index) { if ( (index >= 0) && (index < getRowCount()) ) { if (getRowOrder() == null) return index; else return getRowOrder()[index]; } else { return -1; } } /** * sets the ordering of the columns, null means default * @param order the new order of the columns */ public void setColOrder(int[] order) { int i; // default order? if (order == null) { m_ColOrder = null; } else { if (order.length == getColCount()) { m_ColOrder = new int[order.length]; for (i = 0; i < order.length; i++) m_ColOrder[i] = order[i]; } else { System.err.println("setColOrder: length does not match (" + order.length + " <> " + getColCount() + ") - ignored!"); } } } /** * returns the current order of the columns, null means the default order * @return the current order of the columns */ public int[] getColOrder() { return m_ColOrder; } /** * returns the displayed index of the given col, depending on the order of * columns, returns -1 if index out of bounds * @param index the column to get the displayed index for * @return the real index of the column */ public int getDisplayCol(int index) { if ( (index >= 0) && (index < getColCount()) ) { if (getColOrder() == null) return index; else return getColOrder()[index]; } else { return -1; } } /** * returns the given number as string rounded to the given number of * decimals. additional necessary 0's are added * @param d the number to format * @param prec the number of decimals after the point * @return the formatted number */ protected String doubleToString(double d, int prec) { String result; int currentPrec; int i; result = Utils.doubleToString(d, prec); // decimal point? if (result.indexOf(".") == -1) result += "."; // precision so far? currentPrec = result.length() - result.indexOf(".") - 1; for (i = currentPrec; i < prec; i++) result += "0"; return result; } /** * trims the given string down to the given length if longer, otherwise * leaves it unchanged. a length of "0" leaves the string always * unchanged. * @param s the string to trim (if too long) * @param length the max. length (0 means infinity) * @return the trimmed string */ protected String trimString(String s, int length) { if ( (length > 0) && (s.length() > length) ) return s.substring(0, length); else return s; } /** * pads the given string on the right until it reaches the given length, if * longer cuts it down. if length is 0 then nothing is done. * @param s the string to pad * @param length the max. length of the string * @return the padded string */ protected String padString(String s, int length) { return padString(s, length, false); } /** * pads the given string until it reaches the given length, if longer cuts * it down. if length is 0 then nothing is done. * @param s the string to pad
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -