List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:com.acc.storefront.controllers.pages.StoreLocatorPageController.java
@RequestMapping(method = RequestMethod.GET, params = "q") public String findStores(@RequestParam(value = "page", defaultValue = "0") final int page, @RequestParam(value = "show", defaultValue = "Page") final AbstractSearchPageController.ShowMode showMode, @RequestParam(value = "sort", required = false) final String sortCode, @RequestParam(value = "q") final String locationQuery, @RequestParam(value = "latitude", required = false) final Double latitude, @RequestParam(value = "longitude", required = false) final Double longitude, final StoreFinderForm storeFinderForm, final Model model, final BindingResult bindingResult) throws GeoLocatorException, MapServiceException, CMSItemNotFoundException { final String sanitizedSearchQuery = XSSFilterUtil.filter(locationQuery); if (latitude != null && longitude != null) { final GeoPoint geoPoint = new GeoPoint(); geoPoint.setLatitude(latitude.doubleValue()); geoPoint.setLongitude(longitude.doubleValue()); setUpSearchResultsForPosition(geoPoint, createPageableData(page, getStoreLocatorPageSize(), sortCode, showMode), model); } else if (StringUtils.isNotBlank(sanitizedSearchQuery)) { setUpSearchResultsForLocationQuery(sanitizedSearchQuery, createPageableData(page, getStoreLocatorPageSize(), sortCode, showMode), model); setUpMetaData(sanitizedSearchQuery, model); setUpPageForms(model);/*www .j a v a2 s. co m*/ setUpPageTitle(sanitizedSearchQuery, model); } else { GlobalMessages.addErrorMessage(model, "storelocator.error.no.results.subtitle"); model.addAttribute(WebConstants.BREADCRUMBS_KEY, storefinderBreadcrumbBuilder.getBreadcrumbsForLocationSearch(sanitizedSearchQuery)); } storeCmsPageInModel(model, getStoreFinderPage()); return ControllerConstants.Views.Pages.StoreFinder.StoreFinderSearchPage; }
From source file:org.energy_home.jemma.ah.ebrain.MeteringCore.java
public void notifyDeviceAdded(DeviceInfo info) { String applianceId = info.getPersistentId(); ApplianceInfo appliance = appliances.get(applianceId); if (appliance == null) { if (info.getConfiguration().getCategory() == DeviceCategory.Meter) { smartInfoExchange = new SmartMeterInfo(info); appliance = smartInfoExchange; } else if (info.getConfiguration().getCategory() == DeviceCategory.ProductionMeter) { smartInfoProduction = new SmartMeterInfo(info); appliance = smartInfoProduction; } else {/* ww w . j a v a 2s. c o m*/ appliance = new ApplianceInfo(info); } appliances.put(applianceId, appliance); } if (appliance.getAccumulatedEnergyTime() == 0) { ContentInstance ci = cloudProxy.retrieveDeliveredEnergySummation(applianceId); if (ci != null) { Long timestamp = ci.getId(); Double energySummation = (Double) ci.getContent(); appliance.updateEnergyCost(timestamp.longValue(), energySummation.doubleValue()); } } if (appliance == smartInfoExchange) { smartInfoExchange.setNextTotalEnergyValidValues(0); smartInfoExchange.setNextProducedEnergyValidValues(0); } else if (appliance == smartInfoProduction) { smartInfoProduction.setNextTotalEnergyValidValues(0); smartInfoProduction.setNextProducedEnergyValidValues(0); } }
From source file:com.verisign.epp.codec.gen.EPPUtil.java
/** * Decode <code>BigDecimal</code>, by XML namespace and tag name, from an * XML Element. The children elements of <code>aElement</code> will be * searched for the specified <code>aNS</code> namespace URI and the * specified <code>aTagName</code>. The first XML element found will be * decoded and returned. If no element is found, <code>null</code> is * returned.//from www. j av a 2 s .com * * @param aElement * XML Element to scan. For example, the element could be * <domain:create> * @param aNS * XML namespace of the elements. For example, for domain element * this is "urn:iana:xmlns:domain". * @param aTagName * Tag name of the element including an optional namespace * prefix. For example, the tag name for the domain name is * "domain:name". * @return <code>BigDecimal</code> value if found; <code>null</code> * otherwise. * @exception EPPDecodeException * Error decoding <code>aElement</code>. */ public static BigDecimal decodeBigDecimal(Element aElement, String aNS, String aTagName) throws EPPDecodeException { Element theElm = EPPUtil.getElementByTagNameNS(aElement, aNS, aTagName); BigDecimal retBigDecimal = null; if (theElm != null) { Node textNode = theElm.getFirstChild(); // Element does have a text node? if (textNode != null) { String doubleValStr = textNode.getNodeValue(); try { Double tempDouble = Double.valueOf(doubleValStr); retBigDecimal = new BigDecimal(tempDouble.doubleValue()); retBigDecimal = retBigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); } catch (NumberFormatException e) { throw new EPPDecodeException("Can't convert value to Double: " + doubleValStr + e); } } else { throw new EPPDecodeException("Can't decode numeric value from non-existant text node"); } } return retBigDecimal; }
From source file:org.pentaho.reporting.engine.classic.core.layout.output.AbstractOutputProcessorMetaData.java
public double getNumericFeatureValue(final OutputProcessorFeature.NumericOutputProcessorFeature feature) { if (feature == null) { throw new NullPointerException(); }//from www. j av a2 s . c o m if (OutputProcessorFeature.DEFAULT_FONT_SIZE == feature) { return this.defaultFontSize; } else if (OutputProcessorFeature.FONT_SMOOTH_THRESHOLD == feature) { return fontSmoothThreshold; } else if (OutputProcessorFeature.DEVICE_RESOLUTION == feature) { return this.deviceResolution; } final Double d = numericFeatures.get(feature); if (d == null) { return 0; } return d.doubleValue(); }
From source file:org.opencms.i18n.tools.CmsContainerPageCopier.java
/** * Starts the page copying process.<p> * * @param source the source (can be either a container page, or a folder whose default file is a container page) * @param target the target folder// w ww.jav a 2 s .c om * @param targetName the name to give the new folder * * @throws CmsException if soemthing goes wrong * @throws NoCustomReplacementException if a custom replacement element was not found */ public void run(CmsResource source, CmsResource target, String targetName) throws CmsException, NoCustomReplacementException { LOG.info("Starting page copy process: page='" + source.getRootPath() + "', targetFolder='" + target.getRootPath() + "'"); CmsObject rootCms = OpenCms.initCmsObject(m_cms); rootCms.getRequestContext().setSiteRoot(""); if (m_copyMode == CopyMode.automatic) { Locale sourceLocale = OpenCms.getLocaleManager().getDefaultLocale(rootCms, source); Locale targetLocale = OpenCms.getLocaleManager().getDefaultLocale(rootCms, target); // if same locale, copy elements, otherwise use configured setting LOG.debug("copy mode automatic: source=" + sourceLocale + " target=" + targetLocale + " reuseConfig=" + OpenCms.getLocaleManager().shouldReuseElements() + ""); if (sourceLocale.equals(targetLocale)) { m_copyMode = CopyMode.smartCopyAndChangeLocale; } else { if (OpenCms.getLocaleManager().shouldReuseElements()) { m_copyMode = CopyMode.reuse; } else { m_copyMode = CopyMode.smartCopyAndChangeLocale; } } } if (source.isFolder()) { if (source.equals(target)) { throw new CmsException(Messages.get().container(Messages.ERR_PAGECOPY_SOURCE_IS_TARGET_0)); } CmsResource page = m_cms.readDefaultFile(source, CmsResourceFilter.IGNORE_EXPIRATION); if ((page == null) || !CmsResourceTypeXmlContainerPage.isContainerPage(page)) { throw new CmsException(Messages.get().container(Messages.ERR_PAGECOPY_INVALID_PAGE_0)); } List<CmsProperty> properties = Lists.newArrayList(m_cms.readPropertyObjects(source, false)); Iterator<CmsProperty> iterator = properties.iterator(); while (iterator.hasNext()) { CmsProperty prop = iterator.next(); // copied folder may be root of a locale subtree, but since we may want to copy to a different locale, // we don't want the locale property in the copy if (prop.getName().equals(CmsPropertyDefinition.PROPERTY_LOCALE) || prop.getName().equals(CmsPropertyDefinition.PROPERTY_ELEMENT_REPLACEMENTS)) { iterator.remove(); } } I_CmsFileNameGenerator nameGen = OpenCms.getResourceManager().getNameGenerator(); String copyPath; if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(targetName)) { copyPath = CmsStringUtil.joinPaths(target.getRootPath(), targetName); if (rootCms.existsResource(copyPath)) { copyPath = nameGen.getNewFileName(rootCms, copyPath + "%(number)", 4, true); } } else { copyPath = CmsFileUtil .removeTrailingSeparator(CmsStringUtil.joinPaths(target.getRootPath(), source.getName())); copyPath = nameGen.getNewFileName(rootCms, copyPath + "%(number)", 4, true); } Double maxNavPosObj = readMaxNavPos(target); double maxNavpos = maxNavPosObj == null ? 0 : maxNavPosObj.doubleValue(); boolean hasNavpos = maxNavPosObj != null; CmsResource copiedFolder = rootCms.createResource(copyPath, OpenCms.getResourceManager().getResourceType(CmsResourceTypeFolder.RESOURCE_TYPE_NAME), null, properties); m_createdResources.add(copiedFolder); if (hasNavpos) { String newNavPosStr = "" + (maxNavpos + 10); rootCms.writePropertyObject(copiedFolder.getRootPath(), new CmsProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, newNavPosStr, null)); } String pageCopyPath = CmsStringUtil.joinPaths(copiedFolder.getRootPath(), page.getName()); m_originalPage = page; m_targetFolder = target; m_copiedFolderOrPage = copiedFolder; rootCms.copyResource(page.getRootPath(), pageCopyPath); CmsResource copiedPage = rootCms.readResource(pageCopyPath, CmsResourceFilter.IGNORE_EXPIRATION); m_createdResources.add(copiedPage); replaceElements(copiedPage); CmsLocaleGroupService localeGroupService = rootCms.getLocaleGroupService(); if (Status.linkable == localeGroupService.checkLinkable(m_originalPage, copiedPage)) { try { localeGroupService.attachLocaleGroupIndirect(m_originalPage, copiedPage); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } } tryUnlock(copiedFolder); } else { CmsResource page = source; if (!CmsResourceTypeXmlContainerPage.isContainerPage(page)) { throw new CmsException(Messages.get().container(Messages.ERR_PAGECOPY_INVALID_PAGE_0)); } I_CmsFileNameGenerator nameGen = OpenCms.getResourceManager().getNameGenerator(); String copyPath = CmsFileUtil .removeTrailingSeparator(CmsStringUtil.joinPaths(target.getRootPath(), source.getName())); int lastDot = copyPath.lastIndexOf("."); int lastSlash = copyPath.lastIndexOf("/"); if (lastDot > lastSlash) { // path has an extension String macroPath = copyPath.substring(0, lastDot) + "%(number)" + copyPath.substring(lastDot); copyPath = nameGen.getNewFileName(rootCms, macroPath, 4, true); } else { copyPath = nameGen.getNewFileName(rootCms, copyPath + "%(number)", 4, true); } Double maxNavPosObj = readMaxNavPos(target); double maxNavpos = maxNavPosObj == null ? 0 : maxNavPosObj.doubleValue(); boolean hasNavpos = maxNavPosObj != null; rootCms.copyResource(page.getRootPath(), copyPath); if (hasNavpos) { String newNavPosStr = "" + (maxNavpos + 10); rootCms.writePropertyObject(copyPath, new CmsProperty(CmsPropertyDefinition.PROPERTY_NAVPOS, newNavPosStr, null)); } CmsResource copiedPage = rootCms.readResource(copyPath); m_createdResources.add(copiedPage); m_originalPage = page; m_targetFolder = target; m_copiedFolderOrPage = copiedPage; replaceElements(copiedPage); CmsLocaleGroupService localeGroupService = rootCms.getLocaleGroupService(); if (Status.linkable == localeGroupService.checkLinkable(m_originalPage, copiedPage)) { try { localeGroupService.attachLocaleGroupIndirect(m_originalPage, copiedPage); } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } } tryUnlock(copiedPage); } }
From source file:oculus.aperture.graph.aggregation.impl.LouvainAggregator.java
private double q(int node, Community community) { if (structure == null) { return 0.0; }//w w w .j a va2s . c o m Double edgesToDouble = structure.nodeConnectionsWeight[node].get(community); double edgesTo = 0; if (edgesToDouble != null) { edgesTo = edgesToDouble.doubleValue(); } double weightSum = community.weightSum; double nodeWeight = structure.weights[node]; double qValue; if ((structure.nodeCommunities[node] == community) && (structure.nodeCommunities[node].size() > 1)) { qValue = resolution * edgesTo - (nodeWeight * (weightSum - nodeWeight)) / (2.0 * structure.graphWeightSum); } else if ((structure.nodeCommunities[node] == community) && (structure.nodeCommunities[node].size() == 1)) { qValue = 0.0; } else { qValue = resolution * edgesTo - (nodeWeight * weightSum) / (2.0 * structure.graphWeightSum); } return qValue; }
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.excelimport.EntityDataImporter.java
private Object readPropertyValue(Cell nonEmptyCell, PropertyExpression<?> nonReleasenameProperty) { if (nonReleasenameProperty instanceof EnumerationPropertyExpression) { return getEnumPropertyValue(nonEmptyCell, nonReleasenameProperty); } else if (nonReleasenameProperty.getType().equals(BuiltinPrimitiveType.INTEGER)) { Double doubleValue = getCellValueOfType(nonEmptyCell, Double.class); return doubleValue == null ? null : BigInteger.valueOf(doubleValue.longValue()); } else if (nonReleasenameProperty.getType().equals(BuiltinPrimitiveType.DECIMAL)) { Double doubleValue = getCellValueOfType(nonEmptyCell, Double.class); return doubleValue == null ? null : BigDecimal.valueOf(doubleValue.doubleValue()); } else if (nonReleasenameProperty.getType().equals(BuiltinPrimitiveType.DATE)) { return getCellValueOfType(nonEmptyCell, Date.class); } else if (nonReleasenameProperty.getType().equals(BuiltinPrimitiveType.BOOLEAN)) { String stringValue = getCellValueOfType(nonEmptyCell, String.class); return Boolean.valueOf(Boolean.parseBoolean(stringValue)); } else if (nonReleasenameProperty.getType().equals(BuiltinPrimitiveType.STRING)) { return getStringPropertyValue(nonEmptyCell, nonReleasenameProperty); } else {/*from w w w . j a va2 s .c o m*/ LOGGER.info("Property type for Java enum: {0}", nonReleasenameProperty.getClass().getName()); return resolveJavaEnum(nonReleasenameProperty.getType().getName(), ExcelUtils.getCellValue(nonEmptyCell, false)); } }
From source file:BayesianAnalyzer.java
/** * Returns a SortedSet of TokenProbabilityStrength built from the * Corpus and the tokens passed in the "tokens" Set. * The ordering is from the highest strength to the lowest strength. * * @param tokens/*from w w w . j a v a 2s.c om*/ * @param workCorpus * @return SortedSet of TokenProbabilityStrength objects. */ private SortedSet getTokenProbabilityStrengths(Set tokens, Map workCorpus) { //Convert to a SortedSet of token probability strengths. SortedSet tokenProbabilityStrengths = new TreeSet(); Iterator i = tokens.iterator(); while (i.hasNext()) { TokenProbabilityStrength tps = new TokenProbabilityStrength(); tps.token = (String) i.next(); if (workCorpus.containsKey(tps.token)) { tps.strength = Math.abs(0.5 - ((Double) workCorpus.get(tps.token)).doubleValue()); } else { //This token has never been seen before, //we'll give it initially the default probability. Double corpusProbability = new Double(DEFAULT_TOKEN_PROBABILITY); tps.strength = Math.abs(0.5 - DEFAULT_TOKEN_PROBABILITY); boolean isTokenDegeneratedFound = false; Collection degeneratedTokens = buildDegenerated(tps.token); Iterator iDegenerated = degeneratedTokens.iterator(); String tokenDegenerated = null; double strengthDegenerated; while (iDegenerated.hasNext()) { tokenDegenerated = (String) iDegenerated.next(); if (workCorpus.containsKey(tokenDegenerated)) { Double probabilityTemp = (Double) workCorpus.get(tokenDegenerated); strengthDegenerated = Math.abs(0.5 - probabilityTemp.doubleValue()); if (strengthDegenerated > tps.strength) { isTokenDegeneratedFound = true; tps.strength = strengthDegenerated; corpusProbability = probabilityTemp; } } } // to reduce memory usage, put in the corpus only if the probability is different from (stronger than) the default if (isTokenDegeneratedFound) { synchronized (workCorpus) { workCorpus.put(tps.token, corpusProbability); } } } tokenProbabilityStrengths.add(tps); } return tokenProbabilityStrengths; }
From source file:rb.app.QNTransientSCMSystem.java
/** * Override eval_theta_q_a in order to account for the affine terms * related to basis functions// w w w. ja va2 s. c om */ @Override public double eval_theta_q_a(int q) { if (q < get_n_basis_functions()) { double theta_c_value = eval_theta_c(); return current_RB_coeffs.getEntry(q) * theta_c_value; } else { Method meth; try { Class partypes[] = new Class[2]; partypes[0] = Integer.TYPE; partypes[1] = double[].class; meth = mAffineFnsClass.getMethod("evaluateA", partypes); } catch (NoSuchMethodException nsme) { throw new RuntimeException("getMethod for evaluateA failed", nsme); } Double theta_val; try { Object arglist[] = new Object[2]; arglist[0] = new Integer(q - get_n_basis_functions()); arglist[1] = current_parameters.getArray(); Object theta_obj = meth.invoke(mTheta, arglist); theta_val = (Double) theta_obj; } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite.getCause()); } return theta_val.doubleValue(); } }
From source file:org.n52.ifgicopter.spf.input.GpxInputPlugin.java
/** * @return//from www . j av a 2 s.co m * */ private JPanel makeControlPanel() { if (this.controlPanel == null) { this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); JButton startButton = new JButton("Start"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { start(); } }); } }); this.controlPanel.add(startButton); JButton stopButton = new JButton("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { EventQueue.invokeLater(new Runnable() { @Override public void run() { stop(); } }); } }); this.controlPanel.add(stopButton); JButton selectFileButton = new JButton("Select GPX File"); selectFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectGpxFileAction(); } }); this.controlPanel.add(selectFileButton); JLabel sleepTimeLabel = new JLabel("Time between points in seconds:"); this.controlPanel.add(sleepTimeLabel); double spinnerMin = 0.5d; double spinnerMax = 10000.0d; SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d); JSpinner sleepTimeSpinner = new JSpinner(model); sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of " + spinnerMin + " to " + spinnerMax + "."); sleepTimeSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source instanceof JSpinner) { final JSpinner spinner = (JSpinner) source; EventQueue.invokeLater(new Runnable() { @Override public void run() { Double value = (Double) spinner.getValue(); value = Double.valueOf(value.doubleValue() * SECONDS_TO_MILLISECONDS); setSleepTimeMillis(value.longValue()); } }); } else getLog().warn("Unsupported ChangeEvent, need JSpinner as source: " + e); } }); // catch text change events without loosing the focus // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor(); // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text // field the keystroke was etc. --> too complicated. this.controlPanel.add(sleepTimeSpinner); } return this.controlPanel; }