當前位置: 首頁>>代碼示例>>Java>>正文


Java Utils.padLeft方法代碼示例

本文整理匯總了Java中weka.core.Utils.padLeft方法的典型用法代碼示例。如果您正苦於以下問題:Java Utils.padLeft方法的具體用法?Java Utils.padLeft怎麽用?Java Utils.padLeft使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在weka.core.Utils的用法示例。


在下文中一共展示了Utils.padLeft方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toStringRanking

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * returns the ranking in a string representation.
 * 
 * @return the ranking
 */
@Override
public String toStringRanking() {
  int biggest;
  int width;
  String result;
  int[] ranking;
  int i;
  int curr;

  if (m_RankingWins == null) {
    return "-ranking data not set-";
  }

  biggest = Math.max(m_RankingWins[Utils.maxIndex(m_RankingWins)],
    m_RankingLosses[Utils.maxIndex(m_RankingLosses)]);
  width = Math.max(2 + (int) (Math.log(biggest) / Math.log(10)),
    ">-<".length());
  result = Utils.padLeft(">-<", width) + ' ' + Utils.padLeft(">", width)
    + ' ' + Utils.padLeft("<", width) + " Resultset\n";

  ranking = Utils.sort(m_RankingDiff);

  for (i = getColCount() - 1; i >= 0; i--) {
    curr = ranking[i];

    if (getColHidden(curr)) {
      continue;
    }

    result += Utils.padLeft("" + m_RankingDiff[curr], width) + ' '
      + Utils.padLeft("" + m_RankingWins[curr], width) + ' '
      + Utils.padLeft("" + m_RankingLosses[curr], width) + ' '
      + removeFilterName(m_ColNames[curr]) + '\n';
  }

  return result;
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:43,代碼來源:ResultMatrixPlainText.java

示例2: toStringRanking

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * returns the ranking in a string representation.
 * 
 * @return 		the ranking
 */
public String toStringRanking() {
  int           biggest;
  int           width;
  String        result;
  int[]         ranking;
  int           i;
  int           curr;

  if (m_RankingWins == null)
    return "-ranking data not set-";

  biggest = Math.max(m_RankingWins[Utils.maxIndex(m_RankingWins)],
                     m_RankingLosses[Utils.maxIndex(m_RankingLosses)]);
  width = Math.max(2 + (int)(Math.log(biggest) / Math.log(10)),
	 ">-<".length());
  result = "\\begin{table}[thb]\n\\caption{\\label{labelname}Table Caption"
    + "}\n\\footnotesize\n{\\centering \\begin{tabular}{rlll}\\\\\n\\hline\n";
  result +=   "Resultset & Wins$-$ & Wins & Losses \\\\\n& Losses & & "
            + "\\\\\n\\hline\n";

  ranking = Utils.sort(m_RankingDiff);
  for (i = getColCount() - 1; i >= 0; i--) {
    curr = ranking[i];
    
    if (getColHidden(curr))
      continue;

    result +=   "(" + (curr + 1) + ") & " 
              + Utils.padLeft("" + m_RankingDiff[curr], width) 
              + " & " + Utils.padLeft("" + m_RankingWins[curr], width)
              + " & " + Utils.padLeft("" + m_RankingLosses[curr], width)
              + "\\\\\n";
  }

  result += "\\hline\n\\end{tabular} \\footnotesize \\par}\n\\end{table}";

  return result;
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:44,代碼來源:ResultMatrixLatex.java

示例3: colorToString

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * returns a string representation (#RGB) of the given color
 */
protected String colorToString(Color c) {
  String result;

  result = "#" + Utils.padLeft(Integer.toHexString(c.getRed()), 2)
    + Utils.padLeft(Integer.toHexString(c.getGreen()), 2)
    + Utils.padLeft(Integer.toHexString(c.getBlue()), 2);

  result = result.replaceAll("\\ ", "0").toUpperCase();

  return result;
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:15,代碼來源:LogWindow.java

示例4: toString

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * Converts a matrix to a string. (FracPete: taken from old weka.core.Matrix
 * class)
 * 
 * @return the converted string
 */
@Override
public String toString() {
  // Determine the width required for the maximum element,
  // and check for fractional display requirement.
  double maxval = 0;
  boolean fractional = false;
  Object element = null;
  int widthNumber = 0;
  int widthExpression = 0;
  for (int i = 0; i < size(); i++) {
    for (int j = 0; j < size(); j++) {
      element = getCell(i, j);
      if (element instanceof Double) {
        double current = ((Double) element).doubleValue();

        if (current < 0)
          current *= -11;
        if (current > maxval)
          maxval = current;
        double fract = Math.abs(current - Math.rint(current));
        if (!fractional && ((Math.log(fract) / Math.log(10)) >= -2)) {
          fractional = true;
        }
      } else {
        if (element.toString().length() > widthExpression) {
          widthExpression = element.toString().length();
        }
      }
    }
  }
  if (maxval > 0) {
    widthNumber =
      (int) (Math.log(maxval) / Math.log(10) + (fractional ? 4 : 1));
  }

  int width = (widthNumber > widthExpression) ? widthNumber : widthExpression;

  StringBuffer text = new StringBuffer();
  for (int i = 0; i < size(); i++) {
    for (int j = 0; j < size(); j++) {
      element = getCell(i, j);
      if (element instanceof Double) {
        text.append(" ").append(
          Utils.doubleToString(((Double) element).doubleValue(), width,
            (fractional ? 2 : 0)));
      } else {
        int diff = width - element.toString().length();
        if (diff > 0) {
          int left = diff % 2;
          left += diff / 2;
          String temp =
            Utils.padLeft(element.toString(), element.toString().length()
              + left);
          temp = Utils.padRight(temp, width);
          text.append(" ").append(temp);
        } else {
          text.append(" ").append(element.toString());
        }
      }
    }
    text.append("\n");
  }

  return text.toString();
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:72,代碼來源:CostMatrix.java

示例5: toStringSummary

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * returns the summary as string.
 * 
 * @return the summary
 */
@Override
public String toStringSummary() {
  String result;
  String titles;
  int resultsetLength;
  int i;
  int j;

  if (m_NonSigWins == null) {
    return "-summary data not set-";
  }

  result = "";
  titles = "";
  resultsetLength = 1 + Math.max(
    (int) (Math.log(getColCount()) / Math.log(10)),
    (int) (Math.log(getRowCount()) / Math.log(10)));

  for (i = 0; i < getColCount(); i++) {
    if (getColHidden(i)) {
      continue;
    }
    titles += " "
      + Utils.padLeft("" + getSummaryTitle(i), resultsetLength * 2 + 3);
  }
  result += titles + "  (No. of datasets where [col] >> [row])\n";

  for (i = 0; i < getColCount(); i++) {
    if (getColHidden(i)) {
      continue;
    }

    for (j = 0; j < getColCount(); j++) {
      if (getColHidden(j)) {
        continue;
      }

      result += " ";
      if (j == i) {
        result += Utils.padLeft("-", resultsetLength * 2 + 3);
      } else {
        result += Utils.padLeft("" + m_NonSigWins[i][j] + " (" + m_Wins[i][j]
          + ")", resultsetLength * 2 + 3);
      }
    }

    result += " | " + getSummaryTitle(i) + " = " + getColName(i) + '\n';
  }

  return result;
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:57,代碼來源:ResultMatrixPlainText.java

示例6: toStringSummary

import weka.core.Utils; //導入方法依賴的package包/類
/**
  * returns the summary as string.
  * 
  * @return		the summary
  */
 public String toStringSummary() {
   int           resultsetLength;
   String        result;
   String        titles;
   int           i;
   int           j;

   if (m_NonSigWins == null)
     return "-summary data not set-";
   
   resultsetLength = 1 + Math.max((int)(Math.log(getColCount())/Math.log(10)),
                                  (int)(Math.log(getRowCount())/Math.log(10)));
   result = "";
   titles = "";

   result += "{\\centering\n";
   result += "\\begin{table}[thb]\n\\caption{\\label{labelname}"
               +"Table Caption}\n";
   result += "\\footnotesize\n";
   result += "\\begin{tabular}{l";

   for (i = 0; i < getColCount(); i++) {
     if (getColHidden(i))
       continue;

     titles += " &";
     result += "c";
     titles += ' ' + Utils.padLeft("" + getSummaryTitle(i),
			    resultsetLength * 2 + 3);
   }
   result += "}\\\\\n\\hline\n";
   result += titles + " \\\\\n\\hline\n";
   
   for (i = 0; i < getColCount(); i++) {
     if (getColHidden(i))
       continue;

     for (j = 0; j < getColCount(); j++) {
       if (getColHidden(j))
         continue;

if (j == 0)
  result +=  (char)((int)'a' + i % 26);

if (j == i)
  result += " & - ";
else
  result += "& " + m_NonSigWins[i][j] + " (" + m_Wins[i][j] + ") ";
     }
     result += "\\\\\n";
   }

   result += "\\hline\n\\end{tabular} \\footnotesize \\par\n\\end{table}}";

   return result;
 }
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:62,代碼來源:ResultMatrixLatex.java

示例7: toStringSummary

import weka.core.Utils; //導入方法依賴的package包/類
/**
  * returns the summary as string.
  * 
  * @return		the summary
  */
 public String toStringSummary() {
   String      result;
   String      titles;
   int         resultsetLength;
   int         i;
   int         j;
   String      content;

   if (m_NonSigWins == null)
     return "-summary data not set-";
   
   result = "<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\">\n";
   titles = "   <tr>";
   resultsetLength = 1 + Math.max((int)(Math.log(getColCount())/Math.log(10)),
                                  (int)(Math.log(getRowCount())/Math.log(10)));

   for (i = 0; i < getColCount(); i++) {
     if (getColHidden(i))
       continue;
     titles += "<td align=\"center\"><b>" + getSummaryTitle(i) + "</b></td>";
   }
   result +=   titles 
             + "<td><b>(No. of datasets where [col] &gt;&gt; [row])</b></td></tr>\n";

   for (i = 0; i < getColCount(); i++) {
     if (getColHidden(i))
       continue;

     result += "   <tr>";

     for (j = 0; j < getColCount(); j++) {
       if (getColHidden(j))
         continue;

if (j == i)
  content = Utils.padLeft("-", resultsetLength * 2 + 3);
else
  content = Utils.padLeft("" + m_NonSigWins[i][j] 
                                 + " (" + m_Wins[i][j] + ")",
			  resultsetLength * 2 + 3);
       result += "<td>" + content.replaceAll(" ", "&nbsp;") + "</td>";
     }

     result += "<td><b>" + getSummaryTitle(i) + "</b> = " + removeFilterName(m_ColNames[i]) + "</td></tr>\n";
   }

   result += "</table>\n";

   return result;
 }
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:56,代碼來源:ResultMatrixHTML.java


注:本文中的weka.core.Utils.padLeft方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。