List of usage examples for java.lang Float floatValue
@HotSpotIntrinsicCandidate public float floatValue()
From source file:org.tinymediamanager.scraper.SubtitleSearchResult.java
/** * Set the score of this result (nullsafe) * * @param score//from w ww .ja v a2s . c o m * the result */ public void setScore(Float score) { if (score != null) { setScore(score.floatValue()); } }
From source file:com.joliciel.csvLearner.features.RealValueFeatureNormaliser.java
/** * Peform the normalisation./*from w w w .j a va 2s.c o m*/ */ public void normalise() { for (GenericEvent event : this.events) { if (LOG.isTraceEnabled()) LOG.trace("Normalising " + event.getIdentifier()); List<Float> newWeights = new ArrayList<Float>(); for (int j = 0; j < event.getFeatures().size(); j++) { String featureName = event.getFeatures().get(j); boolean nominalFeature = featureName.contains(CSVLearner.NOMINAL_MARKER); float weight = event.getWeights().get(j); if (nominalFeature) { newWeights.add(weight); } else if (normaliseToPreviousMaxValues) { Float maxValueObj = this.featureToMaxMap.get(featureName); float maxValue = maxValueObj == null ? 0 : maxValueObj.floatValue(); float newWeight = maxValue == 0 ? weight : (weight / maxValue) * this.normalisedMax; newWeights.add(newWeight); } else if (this.normaliseMethod.equals(NormaliseMethod.NORMALISE_BY_MAX)) { float maxValue = this.eventListReader.getMax(featureName); float newWeight = (weight / maxValue) * this.normalisedMax; newWeights.add(newWeight); if (!featureToMaxMap.containsKey(featureName)) featureToMaxMap.put(featureName, maxValue); } else { float meanValue = this.eventListReader.getMean(featureName); float newWeight = (weight / meanValue) * (this.normalisedMax / 2); newWeights.add(newWeight); if (!featureToMaxMap.containsKey(featureName)) featureToMaxMap.put(featureName, meanValue * 2.0f); } } event.getWeights().clear(); event.getWeights().addAll(newWeights); } }
From source file:org.etudes.mneme.tool.SectionScoreDelegate.java
/** * {@inheritDoc}//from w w w . j a v a 2s .c o m */ public String format(Context context, Object value) { if (value == null) return null; if (!(value instanceof Part)) return value.toString(); Part part = (Part) value; Object o = context.get("submission"); if (!(o instanceof Submission)) return value.toString(); Submission submission = (Submission) o; Assessment assessment = submission.getAssessment(); if (assessment == null) return value.toString(); // use the {}/{} format if doing feedback, or just {} if not. StringBuffer rv = new StringBuffer(); Boolean review = (Boolean) context.get("review"); String selector = "worth-points"; // if we are doing review and the submission has been graded if ((review != null) && review && submission.getIsReleased()) { // add the sum of scores for any answered question in this section float score = 0; // find the section's answers to AssessmentQuestions that are in this section. boolean partial = false; for (Answer answer : submission.getAnswers()) { if (answer.getQuestion().getPart().equals(part)) { Float answerScore = answer.getTotalScore(); if (answerScore != null) { score += answerScore.floatValue(); } else { partial = true; } } } rv.append("<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url") + "/icons/grade.png\" alt=\"" + context.getMessages().getString("score") + "\" />"); rv.append(context.getMessages().getString("score") + ": " + FormatScoreDelegate.formatScore(score) + " "); selector = "of-points"; if (partial) { selector += "-partial"; } } // add the total possible points for the section Float score = part.getTotalPoints(); if (score.equals(Float.valueOf((1)))) { selector += "-singular"; } Object[] args = new Object[1]; args[0] = FormatScoreDelegate.formatScore(score); rv.append(context.getMessages().getFormattedMessage(selector, args)); return rv.toString(); }
From source file:z.tool.util.ToStringBuilder.java
public ToStringBuilder add(String key, Float value) { if (null != key && null != value) { getOrTryInitBuff().append(key).append(":").append(value.floatValue()).append(SEP); }//from www .j a v a 2s .c om return this; }
From source file:org.muse.mneme.tool.SectionScoreDelegate.java
/** * {@inheritDoc}//from w w w . j a va 2 s . co m */ public String format(Context context, Object value) { if (value == null) return null; if (!(value instanceof Part)) return value.toString(); Part part = (Part) value; Object o = context.get("submission"); if (!(o instanceof Submission)) return value.toString(); Submission submission = (Submission) o; Assessment assessment = submission.getAssessment(); if (assessment == null) return value.toString(); // use the {}/{} format if doing feedback, or just {} if not. StringBuffer rv = new StringBuffer(); Boolean review = (Boolean) context.get("review"); String selector = "worth-points"; // if we are doing review and the submission has been graded if ((review != null) && review && submission.getIsReleased()) { // add the sum of scores for any answered question in this section float score = 0; // find the section's answers to AssessmentQuestions that are in this section. boolean partial = false; for (Answer answer : submission.getAnswers()) { if (answer.getQuestion().getPart().equals(part)) { Float answerScore = answer.getTotalScore(); if (answerScore != null) { score += answerScore.floatValue(); } else { partial = true; } } } rv.append("<img src=\"" + context.get("sakai.return.url") + "/icons/grade.png\" alt=\"" + context.getMessages().getString("score") + "\" />"); rv.append(context.getMessages().getString("score") + ": " + formatScore(score) + " "); selector = "of-points"; if (partial) { selector += "-partial"; } } // add the total possible points for the section Float score = part.getTotalPoints(); if (score.equals(Float.valueOf((1)))) { selector += "-singular"; } Object[] args = new Object[1]; args[0] = formatScore(score); rv.append(context.getMessages().getFormattedMessage(selector, args)); return rv.toString(); }
From source file:org.stathissideris.ascii2image.core.ConversionOptions.java
public ConversionOptions(CommandLine cmdLine) throws UnsupportedEncodingException { processingOptions.setVerbose(cmdLine.hasOption("verbose")); renderingOptions.setDropShadows(!cmdLine.hasOption("no-shadows")); this.setDebug(cmdLine.hasOption("debug")); processingOptions.setOverwriteFiles(cmdLine.hasOption("overwrite")); if (cmdLine.hasOption("scale")) { Float scale = Float.parseFloat(cmdLine.getOptionValue("scale")); renderingOptions.setScale(scale.floatValue()); }/*from ww w. j a v a 2 s . c o m*/ processingOptions.setAllCornersAreRound(cmdLine.hasOption("round-corners")); processingOptions.setPerformSeparationOfCommonEdges(!cmdLine.hasOption("no-separation")); renderingOptions.setAntialias(!cmdLine.hasOption("no-antialias")); renderingOptions.setFixedSlope(cmdLine.hasOption("fixed-slope")); if (cmdLine.hasOption("background")) { String b = cmdLine.getOptionValue("background"); Color background = parseColor(b); renderingOptions.setBackgroundColor(background); } if (cmdLine.hasOption("transparent")) { renderingOptions.setBackgroundColor(new Color(0, 0, 0, 0)); } if (cmdLine.hasOption("tabs")) { Integer tabSize = Integer.parseInt(cmdLine.getOptionValue("tabs")); int tabSizeValue = tabSize.intValue(); if (tabSizeValue < 0) tabSizeValue = 0; processingOptions.setTabSize(tabSizeValue); } String encoding = (String) cmdLine.getOptionValue("encoding"); if (encoding != null) { new String(new byte[2], encoding); processingOptions.setCharacterEncoding(encoding); } ConfigurationParser configParser = new ConfigurationParser(); try { for (Option curOption : cmdLine.getOptions()) { if (curOption.getLongOpt().equals("config")) { String configFilename = curOption.getValue(); System.out.println("Parsing configuration file " + configFilename); File file = new File(configFilename); if (file.exists()) { configParser.parseFile(file); HashMap<String, CustomShapeDefinition> shapes = configParser.getShapeDefinitionsHash(); processingOptions.putAllInCustomShapes(shapes); } else { System.err.println("File " + file + " does not exist, skipping"); } } } } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:ome.util.ModelMapper.java
public float nullSafeFloat(Float f) { if (f == null) { return 0.0F; }//from www .ja v a 2 s . c o m return f.floatValue(); }
From source file:org.astrojournal.generator.statistics.BasicStatistics.java
/** * Return the averages for seeing (0), transparency (1) and darkness (2). * // w ww .j a v a 2 s . c o m * @param type * the target type * @param index * the index of the reader. Seeing (0), transparency (1) and * darkness (2). * @return the reading average */ public float getLocationWeatherAvgs(String type, int index) { if (locationWeatherCount.containsKey(type) && index >= 0 && index <= 2) { ArrayList<Float> reading = locationWeatherCount.get(type).get(index); float sum = 0; for (Float f : reading) { sum = sum + f.floatValue(); } return sum / reading.size(); } return 0; }
From source file:org.tap4j.plugin.model.TapTestResultResult.java
public float getDuration() { Map<String, Object> diagnostic = this.tapTestResult.getDiagnostic(); // FIXME: code duplication. Refactor it and TapResult if (diagnostic != null && !diagnostic.isEmpty()) { Object duration = diagnostic.get(DURATION_KEY); if (duration != null) { Float durationMS = Float.parseFloat(duration.toString()); return durationMS.floatValue(); }//from w ww. j av a 2 s .co m } return super.getDuration(); }
From source file:org.apache.pdfbox.pdmodel.font.PDCIDFont.java
/** * This will get the font width for a character. * * @param c The character code to get the width for. * @param offset The offset into the array. * @param length The length of the data. * * @return The width is in 1000 unit of text space, ie 333 or 777 * * @throws IOException If an error occurs while parsing. */// ww w. j a va2 s . com public float getFontWidth(byte[] c, int offset, int length) throws IOException { float retval = getDefaultWidth(); int code = getCodeFromArray(c, offset, length); Float widthFloat = widthCache.get(code); if (widthFloat != null) { retval = widthFloat.floatValue(); } return retval; }