示例#1
0
 /**
  * Produce values for a list of scales that can be used in a pulldown menu
  *
  * @param scales a list of {@link EvalScale}
  * @return an array of values for the passed in scales
  */
 public static String[] getScaleValues(List<EvalScale> scales) {
   List<String> scaleValues = new ArrayList<>();
   for (EvalScale scale : scales) {
     // ensure only real scales are included
     if (scale.getId() != null) {
       scaleValues.add(scale.getId().toString());
     }
   }
   return (String[]) scaleValues.toArray(new String[] {});
 }
示例#2
0
 /**
  * Produce scale labels for a list of scales that can be used in a pulldown menu
  *
  * @param scales a list of {@link EvalScale}
  * @return an array of labels for the passed in scales
  */
 public static String[] getScaleLabels(List<EvalScale> scales) {
   List<String> scaleLabels = new ArrayList<>();
   for (EvalScale scale : scales) {
     // ensure only real scales are included
     if (scale.getId() != null) {
       scaleLabels.add(makeScaleText(scale, 90));
     }
   }
   return (String[]) scaleLabels.toArray(new String[scaleLabels.size()]);
 }
示例#3
0
 public static int idealIndex(EvalScale scale) {
   int index = -1;
   for (int i = 0; i < idealKeys.length; ++i) {
     if (StringUtil.equals(scale.getIdeal(), idealKeys[i])) {
       index = i;
       break;
     }
   }
   if (index == -1) {
     // Fix for http://www.caret.cam.ac.uk/jira/browse/CTL-562 - added to ensure this will not
     // cause a failure
     LOG.info(
         "Could not find index for scale ("
             + scale.getId()
             + ") for ideal setting: "
             + scale.getIdeal()
             + ", setting to default of 0 (no ideal)");
     index = 0;
   }
   return index;
 }
示例#4
0
 /**
  * Turns a scale in user displayable text, works for any scale (not just for scaled mode)
  *
  * @param scale any persisted scale
  * @param maxLength the maximum length of this text
  * @return a string suitable for display to the user
  */
 public static String makeScaleText(EvalScale scale, int maxLength) {
   StringBuilder scaleText = new StringBuilder();
   if (EvalConstants.SCALE_MODE_SCALE.equals(scale.getMode())) {
     scaleText.append(scale.getOptions().length);
     scaleText.append(" pt - "); // I18n?
     scaleText.append(scale.getTitle());
     scaleText.append(" (");
   } else {
     scaleText.append("Options: "); // I18n?
   }
   for (int j = 0; j < scale.getOptions().length; j++) {
     scaleText.append((j == 0 ? "" : ","));
     scaleText.append(scale.getOptions()[j]);
   }
   if (EvalConstants.SCALE_MODE_SCALE.equals(scale.getMode())) {
     scaleText.append(")");
   }
   return EvalUtils.makeMaxLengthString(scaleText.toString(), maxLength);
 }