List of usage examples for java.lang Integer doubleValue
public double doubleValue()
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java
public boolean isEditValid() { final String S_ProcName = "isEditValid"; if (!hasValue()) { setValue(null);/* ww w. j a va 2 s .c o m*/ return (true); } boolean retval = super.isEditValid(); if (retval) { try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = false; } else if (obj instanceof Float) { Float f = (Float) obj; Double v = new Double(f.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else if (obj instanceof Double) { Double v = (Double) obj; if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else if (obj instanceof Short) { Short s = (Short) obj; Double v = new Double(s.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else if (obj instanceof Integer) { Integer i = (Integer) obj; Double v = new Double(i.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else if (obj instanceof Long) { Long l = (Long) obj; Double v = new Double(l.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else if (obj instanceof BigDecimal) { BigDecimal b = (BigDecimal) obj; Double v = new Double(b.toString()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else if (obj instanceof Number) { Number n = (Number) obj; Double v = new Double(n.toString()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { retval = false; } } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, BigDecimal, Float, Double or Number"); } } return (retval); }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java
public Double getDoubleValue() { final String S_ProcName = "getDoubleValue"; Double retval;//from w w w.ja v a2s . c o m String text = getText(); if ((text == null) || (text.length() <= 0)) { retval = null; } else { if (!isEditValid()) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, "Field is not valid"); } try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = null; } else if (obj instanceof Float) { Float f = (Float) obj; Double v = new Double(f.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Double) { Double v = (Double) obj; if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Short) { Short s = (Short) obj; Double v = new Double(s.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Integer) { Integer i = (Integer) obj; Double v = new Double(i.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Long) { Long l = (Long) obj; Double v = new Double(l.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof BigDecimal) { BigDecimal b = (BigDecimal) obj; Double v = new Double(b.toString()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Number) { Number n = (Number) obj; Double v = new Double(n.toString()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, BigDecimal or Number"); } } return (retval); }
From source file:fr.univ_tours.li.mdjedaini.ideb.algo.user.UserModelPageRank.java
/** * /*w ww . jav a2 s .co m*/ */ public void computeWeights() { for (Pair<Query, Query> p_tmp : this.pairToCount.keySet()) { Integer seedCount = this.seedToCount.get(p_tmp.getKey()); Double weight = this.pairToCount.get(p_tmp).doubleValue() / (Double) seedCount.doubleValue(); this.pairToWeight.put(p_tmp, weight); } }
From source file:org.talend.dataquality.record.linkage.ui.composite.chart.BlockingKeyDataChart.java
private Object createDataset() { // MOD scorreia 2011-02-10 code simplified in order to avoid unnecessary aggregation (it is now done in the // histogram dataset automatically) // final double minValue = 0; // lower value of the x-axis of the chart double maxValue = 0; // higher value of the x-axis of the chart List<Double> blockSizeValueList = new ArrayList<Double>(); // add each block size (number of rows of the block) to the list Iterator<String> iterator = prviewData.keySet().iterator(); while (iterator.hasNext()) { String key = iterator.next(); Integer blockSize = prviewData.get(key).size(); assert blockSize != null : "no row found for block " + key; //$NON-NLS-1$ if (blockSize == null) { // should not happen blockSize = 0;//from w w w . j av a2s . c o m } blockSizeValueList.add(blockSize.doubleValue()); // evaluate the maximum number of rows if (maxValue < blockSize) { maxValue = blockSize; } } Double[] valueArray = new Double[blockSizeValueList.size()]; blockSizeValueList.toArray(valueArray); return TOPChartUtil.getInstance().createHistogramDataset(ArrayUtils.toPrimitive(valueArray), maxValue, BINS); }
From source file:org.jutge.joc.porra.controller.base.BetController.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private Bet createBetInstanceByType(final LinkedHashMap map, final List errorMessages, final Locale locale) { final String betType = (String) map.get("tipus"); if (BetType.ROUNDS.name().equals(betType)) { final RoundsBet roundsBet = new RoundsBet(); final String roundsStr = (String) map.get("rondas"); try {// w w w .j a v a 2 s . co m final int rounds = Integer.parseInt(roundsStr); roundsBet.setEnduresRounds(rounds); } catch (final NumberFormatException exception) { final String message = this.messageSource.getMessage("exception.roundsFormat", null, locale); final MessageBox messageBox = new MessageBox("roundsFormat", message, new ArrayList<String>()); errorMessages.add(messageBox); } try { final String kudos = (String) map.get("kudos"); final Integer kudosInt = Integer.parseInt(kudos); if (roundsBet != null) { roundsBet.setKudos(kudosInt.doubleValue()); } } catch (NumberFormatException exception) { final String message = this.messageSource.getMessage("exception.kudosFormat", null, locale); final MessageBox messageBox = new MessageBox("kudosFormat", message, new ArrayList<String>()); errorMessages.add(messageBox); } return roundsBet; } else if (BetType.WINNER.name().equals(betType)) { return new WinnerBet(); } return null; }
From source file:hu.ppke.itk.nlpg.purepos.model.internal.HashSuffixGuesser.java
@Deprecated protected double getTagProbRevHunPOS(String word, T tag) { Double ret = 0.0;//ww w. ja va2s .co m for (int i = 0; i <= word.length(); ++i) { String suff = word.substring(i); MutablePair<HashMap<T, Integer>, Integer> suffixValue = freqTable.get(suff); if (suffixValue != null) { Integer tagSufFreq = suffixValue.getLeft().get(tag); Double relFreq = 0.0; if (tagSufFreq != null) { Double tagSufFreqD = tagSufFreq.doubleValue(); relFreq = tagSufFreqD / suffixValue.getRight(); ret = (ret + (relFreq * theta)) / thetaPlusOne; // logger.debug("accu(" + tag + ") = (prev(" + retP // + ") + relfreq(" + relFreq + ") * theta(" + theta // + "))/thetaPO(" + thetaPlusOne + ") =" + ret); } } } return ret; }
From source file:hu.ppke.itk.nlpg.purepos.model.internal.HashSuffixGuesser.java
protected double getTagProbHunPOS(String word, T tag) { Double ret = 0.0;/* w ww . j a v a 2 s . co m*/ for (int i = word.length(); i >= 0; --i) { String suff = word.substring(i); MutablePair<HashMap<T, Integer>, Integer> suffixValue = freqTable.get(suff); if (suffixValue != null) { Integer tagSufFreq = suffixValue.getLeft().get(tag); Double relFreq = 0.0; if (tagSufFreq != null) { Double tagSufFreqD = tagSufFreq.doubleValue(); relFreq = tagSufFreqD / suffixValue.getRight(); ret = (ret + (relFreq * theta)) / thetaPlusOne; // logger.debug("accu(" + tag + ") = (prev(" + retP // + ") + relfreq(" + relFreq + ") * theta(" + theta // + "))/thetaPO(" + thetaPlusOne + ") =" + ret); } else { break; } } } return ret; }
From source file:hu.ppke.itk.nlpg.purepos.model.internal.HashSuffixGuesser.java
@Deprecated protected double getTagProbBoosted(String word, T tag, Integer offset) { Double ret = 0.0;/*ww w.j a v a 2s .co m*/ for (int i = word.length() - offset; i >= 0; --i) { String suff = word.substring(i); MutablePair<HashMap<T, Integer>, Integer> suffixValue = freqTable.get(suff); if (suffixValue != null) { Integer tagSufFreq = suffixValue.getLeft().get(tag); Double relFreq = 0.0; if (tagSufFreq != null) { Double tagSufFreqD = tagSufFreq.doubleValue(); relFreq = tagSufFreqD / suffixValue.getRight(); ret = (ret + (relFreq * theta)) / thetaPlusOne; // logger.debug("accu(" + tag + ") = (prev(" + retP // + ") + relfreq(" + relFreq + ") * theta(" + theta // + "))/thetaPO(" + thetaPlusOne + ") =" + ret); } else { break; } } } return ret; }
From source file:org.opennms.features.newts.converter.eventd.EventdStresser.java
private static int sendTraps(final SnmpTrapBuilder builder, PoolingConnection pool, long beginMillis, int initialEventCount) throws IllegalStateException, InterruptedException, SQLException { m_sleepMillis = 0;/*www .j a v a 2s . com*/ int totalTrapsSent = 0; System.out.println("Sending " + m_trapCount + " traps in " + m_batchCount + " batches with a batch interval of " + m_batchDelay.toString() + " seconds..."); for (int i = 1; i <= m_batchCount; i++) { Long batchBegin = Calendar.getInstance().getTimeInMillis(); Double currentRate = 0.0; Integer batchTrapsSent = 0; Long batchElapsedMillis = 0L; System.out.println("Sending batch " + i + " of " + Integer.valueOf(m_batchCount) + " batches of " + m_batchSize.intValue() + " traps at the rate of " + m_trapRate.toString() + " traps/sec..."); System.out.println( "Estimated time to send: " + m_batchSize.doubleValue() / m_trapRate.doubleValue() + " seconds"); while (batchTrapsSent.intValue() < m_batchSize.intValue()) { if (currentRate <= m_trapRate || batchElapsedMillis == 0) { batchTrapsSent += sendTrap(builder); } else { Thread.sleep(1); m_sleepMillis++; } batchElapsedMillis = Calendar.getInstance().getTimeInMillis() - batchBegin; currentRate = batchTrapsSent.doubleValue() / batchElapsedMillis.doubleValue() * 1000.0; if (batchElapsedMillis % 1000 == 0) { System.out.print("."); } } System.out.println(); totalTrapsSent += batchTrapsSent; System.out.println(" Actual time to send: " + (batchElapsedMillis / 1000.0 + " seconds")); System.out.println("Elapsed Time (secs): " + ((System.currentTimeMillis() - beginMillis) / 1000L)); System.out.println(" Traps sent: " + Integer.valueOf(totalTrapsSent).toString()); Integer currentEventCount = getEventCount(pool) - initialEventCount; System.out.println("Current Event count: " + currentEventCount.toString()); System.out.println(); Thread.sleep(m_batchDelay.longValue() * 1000L); m_sleepMillis += m_batchDelay.longValue() * 1000L; } int remainingTraps = m_trapCount - totalTrapsSent; System.out.println("Sending batch remainder of " + remainingTraps + " traps..."); Long batchBegin = Calendar.getInstance().getTimeInMillis(); Double currentRate = 0.0; Long batchTrapsSent = 0L; Long elapsedMillis = 0L; while (batchTrapsSent.intValue() < remainingTraps) { if (currentRate <= m_trapRate || elapsedMillis == 0) { batchTrapsSent += sendTrap(builder); } else { Thread.sleep(1); m_sleepMillis++; } elapsedMillis = Calendar.getInstance().getTimeInMillis() - batchBegin; currentRate = batchTrapsSent.doubleValue() / elapsedMillis.doubleValue() * 1000.0; } totalTrapsSent += batchTrapsSent; System.out.println("Elapsed Time (secs): " + ((System.currentTimeMillis() - beginMillis) / 1000L)); System.out.println(" Traps sent: " + Integer.valueOf(totalTrapsSent).toString()); Integer currentEventCount = getEventCount(pool) - initialEventCount; System.out.println("Current Event count: " + currentEventCount.toString()); return totalTrapsSent; }
From source file:org.jahia.utils.maven.plugin.contentgenerator.ContentGeneratorService.java
/** * Calculates the number of pages needed, used to know how much articles we * will need/* w w w . j av a 2s .c om*/ * * @param nbPagesTopLevel * @param nbLevels * @param nbPagesPerLevel * @return number of pages needed */ public Integer getTotalNumberOfPagesNeeded(Integer nbPagesTopLevel, Integer nbLevels, Integer nbPagesPerLevel) { Double nbPages = new Double(0); for (double d = nbLevels; d > 0; d--) { nbPages += Math.pow(nbPagesPerLevel.doubleValue(), d); } nbPages = nbPages * nbPagesTopLevel + nbPagesTopLevel; return new Integer(nbPages.intValue()); }