List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:net.solarnetwork.node.power.impl.XantrexGtViewPowerDatumDataSource.java
@SuppressWarnings("deprecation") private PowerDatum getPowerDatumInstance(String data) { if (log.isDebugEnabled()) { log.debug("Raw last sample data in file: " + data); }/*w ww . j a v a 2 s.co m*/ String[] tokens = data.split("\t"); // only use this if DC watts is non-zero. Some junk is // left over from previous day in other fields Double d = getFrameDouble(tokens, FRAME_IDX_PV_WATTS); if (d == null || d.doubleValue() == 0.0) { return null; } PowerDatum datum = new PowerDatum(); // Field 0: Date: unused // Field 1: Time: unused // Field 2: DC Volts d = getFrameDouble(tokens, FRAME_IDX_PV_VOLTS); if (d != null) { datum.setPvVolts(d.floatValue()); if (log.isDebugEnabled()) { log.debug("DC Volts: " + d); } } // Field 3: DC Amps d = getFrameDouble(tokens, FRAME_IDX_PV_AMPS); if (d != null) { datum.setPvAmps(d.floatValue()); if (log.isDebugEnabled()) { log.debug("DC Amps: " + d); } } // Field 4: MPPT: unused // Field 5: DC Watts: already parsed above // Field 7: Efficiency: unused // Field 8: AC Volts: unused d = getFrameDouble(tokens, FRAME_IDX_AC_VOLTS); if (d != null) { datum.setAcOutputVolts(d.floatValue()); if (log.isDebugEnabled()) { log.debug("AC Volts: " + d); } } // Field 6: AC Watts: used to set AC amps d = getFrameDouble(tokens, FRAME_IDX_AC_WATTS); if (d != null) { if (datum.getAcOutputVolts() > 0) { datum.setAcOutputAmps(d.floatValue() / datum.getAcOutputVolts()); } if (log.isDebugEnabled()) { log.debug("AC Amps: " + d); } } // Field 9: Cumulative AC Watts d = getFrameDouble(tokens, FRAME_IDX_WH); if (d != null) { // store Wh as kWh datum.setKWattHoursToday(d.doubleValue() / 1000); if (log.isDebugEnabled()) { log.debug("WH: " + d); } } return datum; }
From source file:ExpenseReport.java
public void calcTotal() { double total = 0; for (int k = 0; k < m_data.getRowCount(); k++) { Double amount = (Double) m_data.getValueAt(k, ExpenseReportData.COL_AMOUNT); total += amount.doubleValue(); }/*from ww w . j a va 2 s . c om*/ m_title.setText("Total: $" + total); }
From source file:StocksTable4.java
public ColorData(Double data) { m_color = data.doubleValue() >= 0 ? GREEN : RED; m_data = data; }
From source file:com.joliciel.csvLearner.maxent.MaxentBestFeatureObserver.java
@Override public void onTerminate() { bestFeaturesPerOutcome = new TreeMap<String, List<NameValuePair>>(); totalPerOutcome = new TreeMap<String, Double>(); bestFeatureTotalPerOutcome = new TreeMap<String, Double>(); filePercentagePerOutcome = new TreeMap<String, Map<String, Double>>(); fileNames = new TreeSet<String>(); for (Entry<String, Map<String, Double>> entry : featureMap.entrySet()) { String outcome = entry.getKey(); LOG.debug("outcome: " + outcome); Map<String, Double> featureTotals = entry.getValue(); Map<String, Double> fileTotals = new TreeMap<String, Double>(); PriorityQueue<NameValuePair> heap = new PriorityQueue<NameValuePair>(featureTotals.size(), new NameValueDescendingComparator()); double grandTotal = 0.0; for (Entry<String, Double> featureTotal : featureTotals.entrySet()) { NameValuePair pair = new NameValuePair(featureTotal.getKey(), featureTotal.getValue()); heap.add(pair);//from w w w .j a v a 2 s . c o m grandTotal += featureTotal.getValue(); String featureKey = featureTotal.getKey(); if (featureKey.contains(CSVLearner.NOMINAL_MARKER)) featureKey = featureKey.substring(0, featureKey.indexOf(CSVLearner.NOMINAL_MARKER)); String fileName = this.featureToFileMap.get(featureKey); Double fileTotalObj = fileTotals.get(fileName); double fileTotal = fileTotalObj == null ? 0 : fileTotalObj.doubleValue(); fileTotals.put(fileName, fileTotal + featureTotal.getValue()); } List<NameValuePair> bestFeatures = new ArrayList<NameValuePair>(); double bestFeatureTotal = 0.0; for (int i = 0; i < n; i++) { NameValuePair pair = heap.poll(); if (pair == null) break; LOG.debug("Feature: " + pair.getName() + ", Total: " + pair.getValue()); bestFeatures.add(pair); bestFeatureTotal += pair.getValue(); } bestFeaturesPerOutcome.put(outcome, bestFeatures); totalPerOutcome.put(outcome, grandTotal); bestFeatureTotalPerOutcome.put(outcome, bestFeatureTotal); // convert the file totals to percentages for (Entry<String, Double> fileTotal : fileTotals.entrySet()) { double filePercentage = fileTotal.getValue() / grandTotal; fileTotal.setValue(filePercentage); fileNames.add(fileTotal.getKey()); } filePercentagePerOutcome.put(outcome, fileTotals); featureTotals.clear(); } featureMap.clear(); featureMap = null; }
From source file:org.mifos.application.collectionsheet.struts.action.CollectionSheetEntryViewPostPreviewValidator.java
private ActionErrors validatePopulatedData(final CollectionSheetEntryView parent, final ActionErrors errors, final Locale locale) { List<CollectionSheetEntryView> children = parent.getCollectionSheetEntryChildren(); ResourceBundle resources = ResourceBundle.getBundle(FilePaths.BULKENTRY_RESOURCE, locale); String acCollections = resources.getString(CollectionSheetEntryConstants.AC_COLLECTION); if (null != children) { for (CollectionSheetEntryView collectionSheetEntryView : children) { validatePopulatedData(collectionSheetEntryView, errors, locale); }/* w w w. j a v a2s . co m*/ } for (LoanAccountsProductView accountView : parent.getLoanAccountDetails()) { if (accountView.isDisburseLoanAccountPresent() || accountView.getLoanAccountViews().size() > 1) { Double enteredAmount = 0.0; if (null != accountView.getEnteredAmount() && accountView.isValidAmountEntered()) { enteredAmount = getDoubleValue(accountView.getEnteredAmount()); } Double enteredDisbursalAmount = 0.0; if (null != accountView.getDisBursementAmountEntered() && accountView.isValidDisbursementAmount()) { enteredDisbursalAmount = getDoubleValue(accountView.getDisBursementAmountEntered()); } Double totalDueAmount = accountView.getTotalAmountDue(); Double totalDisburtialAmount = accountView.getTotalDisburseAmount(); if (totalDueAmount.doubleValue() <= 0.0 && totalDisburtialAmount > 0.0) { if (!accountView.isValidDisbursementAmount() || !enteredDisbursalAmount.equals(totalDisburtialAmount) && !enteredDisbursalAmount.equals(0.0)) { errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName())); } } if (totalDisburtialAmount <= 0.0 && totalDueAmount > 0.0) { if (!accountView.isValidAmountEntered() || !enteredAmount.equals(totalDueAmount) && !enteredAmount.equals(0.0)) { errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName())); } } if (totalDueAmount.doubleValue() > 0.0 && totalDisburtialAmount > 0.0) { if (!accountView.isValidAmountEntered() || !accountView.isValidDisbursementAmount() || accountView.getEnteredAmount() == null || accountView.getDisBursementAmountEntered() == null || enteredAmount.equals(0.0) && !enteredDisbursalAmount.equals(0.0) || enteredDisbursalAmount.equals(0.0) && !enteredAmount.equals(0.0) || enteredDisbursalAmount.equals(totalDisburtialAmount) && !enteredAmount.equals(totalDueAmount) || enteredAmount.equals(totalDueAmount) && !enteredDisbursalAmount.equals(totalDisburtialAmount) || !enteredAmount.equals(totalDueAmount) && !enteredDisbursalAmount.equals(totalDisburtialAmount) && !enteredDisbursalAmount.equals(0.0) && !enteredAmount.equals(0.0)) { errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName())); } } if (totalDisburtialAmount <= 0.0 && totalDueAmount <= 0.0) { if (!accountView.isValidAmountEntered() || !accountView.isValidDisbursementAmount() || !enteredDisbursalAmount.equals(0.0) || !enteredAmount.equals(0.0)) { errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, accountView.getPrdOfferingShortName(), parent.getCustomerDetail().getDisplayName())); } } } } for (SavingsAccountView savingsAccountView : parent.getSavingsAccountDetails()) { if (!savingsAccountView.isValidDepositAmountEntered() || !savingsAccountView.isValidWithDrawalAmountEntered()) { errors.add(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.ERRORINVALIDAMOUNT, savingsAccountView.getSavingsOfferingShortName(), parent.getCustomerDetail().getDisplayName())); } } CustomerAccountView customerAccountView = parent.getCustomerAccountDetails(); Double customerAccountAmountEntered = 0.0; if (null != customerAccountView.getCustomerAccountAmountEntered() && customerAccountView.isValidCustomerAccountAmountEntered()) { customerAccountAmountEntered = getDoubleValue(customerAccountView.getCustomerAccountAmountEntered()); } if (!customerAccountView.isValidCustomerAccountAmountEntered() || !customerAccountAmountEntered .equals(customerAccountView.getTotalAmountDue().getAmountDoubleValue()) && !customerAccountAmountEntered.equals(0.0)) { errors.add(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, new ActionMessage(CollectionSheetEntryConstants.BULKENTRYINVALIDAMOUNT, acCollections, parent.getCustomerDetail().getDisplayName())); } return errors; }
From source file:org.kalypso.ui.rrm.internal.calccase.CatchmentModelHelper.java
private static IStatus compareTimeseries(final ZmlLink link, final ZmlLink tmpLink, final String statusLabel) { /* No links? */ if (link == null && tmpLink == null) return new Status(IStatus.OK, KalypsoUIRRMPlugin.getID(), statusLabel); /* The status collector. */ final StatusCollector collector = new StatusCollector(KalypsoUIRRMPlugin.getID()); try {/*from w ww . j a v a2 s. c o m*/ /* If there is no link in the new model, no status. */ if (!(tmpLink.isLinkSet() && tmpLink.isLinkExisting())) return null; /* If there is no link in the old model, create a warning. */ if (!(link.isLinkSet() && link.isLinkExisting())) return new Status(IStatus.WARNING, KalypsoUIRRMPlugin.getID(), Messages.getString("CatchmentModelHelper.1")); //$NON-NLS-1$ /* Load the timeseries. */ /* The time zone may be different to that of the newly generated timeseries. */ final IObservation observation = link.loadObservation(); /* Load the temporary timeseries. */ /* The time zone may be different to that of the original timeseries. */ final IObservation tmpObservation = tmpLink.loadObservation(); /* Get the values of both timeseries. */ final ITupleModel values = observation.getValues(null); final ITupleModel tmpValues = tmpObservation.getValues(null); /* Build a hash date->value for the old timeseries. */ final Map<Long, Double> hash = buildHash(values); /* Build a hash date->value for the new timeseries. */ final Map<Long, Double> tmpHash = buildHash(tmpValues); /* Loop through the new hash. */ int differences = 0; for (final Entry<Long, Double> tmpEntry : tmpHash.entrySet()) { /* Get the key and the value of the new timeseries. */ final Long tmpKey = tmpEntry.getKey(); final Double tmpValue = tmpEntry.getValue(); /* Get the value of the old timeseries. */ final Double value = hash.get(tmpKey); /* Compare the values of the new timeseries with the ones in the old timeseries. */ // TODO 0.01 different with other datatypes? if (value == null || Math.abs(tmpValue.doubleValue() - value.doubleValue()) > 0.01) differences++; } /* Calculate the procentual difference. */ if (differences > 0) { final int percent = (differences * 100) / tmpHash.size(); collector.add(IStatus.WARNING, Messages.getString("CatchmentModelHelper_18"), null, percent, //$NON-NLS-1$ differences); } return collector.asMultiStatusOrOK(statusLabel, statusLabel); } catch (final Exception ex) { collector.add(IStatus.WARNING, Messages.getString("CatchmentModelHelper_19"), null, //$NON-NLS-1$ ex.getLocalizedMessage()); return collector.asMultiStatus(statusLabel); } }
From source file:com.epam.cme.facades.converters.populator.SearchProductTelcoPopulator.java
@Override public void populate(final SOURCE source, final TARGET target) { final ProductData telcoProduct = target; final String billingTimeAsString = this.getValue(source, "billingTime"); final BillingTimeData billingTime = new BillingTimeData(); billingTime.setName(billingTimeAsString); if (telcoProduct.getSubscriptionTerm() == null) { telcoProduct.setSubscriptionTerm(new SubscriptionTermData()); telcoProduct.getSubscriptionTerm().setBillingPlan(new BillingPlanData()); }//from w ww. jav a 2 s. c o m if (telcoProduct.getSubscriptionTerm().getBillingPlan() == null) { telcoProduct.getSubscriptionTerm().setBillingPlan(new BillingPlanData()); } telcoProduct.getSubscriptionTerm().getBillingPlan().setBillingTime(billingTime); final Boolean soldIndividually = this.getValue(source, ProductModel.SOLDINDIVIDUALLY); telcoProduct.setSoldIndividually(soldIndividually == null ? true : soldIndividually.booleanValue()); final String termOfServiceFrequencyAsString = this.getValue(source, "termLimit"); final TermOfServiceFrequencyData termOfServiceFrequencyData = new TermOfServiceFrequencyData(); termOfServiceFrequencyData.setName(termOfServiceFrequencyAsString); telcoProduct.getSubscriptionTerm().setTermOfServiceFrequency(termOfServiceFrequencyData); final Double lowestBundlePriceValue = this.getValue(source, "lowestBundlePriceValue"); telcoProduct.setLowestBundlePrice(lowestBundlePriceValue == null ? null : getPriceDataFactory().create(PriceDataType.BUY, BigDecimal.valueOf(lowestBundlePriceValue.doubleValue()), getCommonI18NService().getCurrentCurrency().getIsocode())); }
From source file:org.polymap.wbv.ui.reports.Report102.java
@Override public JasperReportBuilder build() throws DRException, JRException, IOException { // datasource JsonBuilder jsonBuilder = new JsonBuilder(revierFlurstuecke()) { @Override/*from ww w . ja v a 2 s. c om*/ protected Object buildJson(Object value) { Object result = super.buildJson(value); // if (value instanceof Flurstueck) { JSONObject resultObj = (JSONObject) result; Flurstueck flurstueck = (Flurstueck) value; Waldbesitzer wb = flurstueck.waldbesitzer(); resultObj.put("name", besitzerName(wb)); if (flurstueck.gemarkung.get() != null) { String gemeinde = flurstueck.gemarkung.get().gemeinde.get(); resultObj.put("gemeinde", gemeinde); String gemarkung = flurstueck.gemarkung.get().gemarkung.get(); resultObj.put("gemarkung", gemarkung); } String flstNr = flurstueck.zaehlerNenner.get(); resultObj.put("flst_nr", flstNr); Double gesamtFlaeche = flurstueck.flaeche.get(); Double waldFlaeche = flurstueck.flaecheWald.get(); resultObj.put("gesamtFlaeche", gesamtFlaeche != null ? gesamtFlaeche.doubleValue() : 0d); resultObj.put("flaecheWaldAnteilig", waldFlaeche != null ? waldFlaeche.doubleValue() : 0d); } return result; } }; // report TextColumnBuilder<String> gemeindeColumn = col.column("Gemeinde", "gemeinde", type.stringType()) .setStyle(stl.style().bold()); TextColumnBuilder<String> gemarkungColumn = col.column("Gemarkung", "gemarkung", type.stringType()) .setStyle(stl.style().bold()); TextColumnBuilder<String> flstnrColumn = col.column("Flst-Nr", "flst_nr", type.stringType()) .setStyle(stl.style().bold()); TextColumnBuilder<Double> gesamtFlaecheColumn = col .column("Gesamtflche", "gesamtFlaeche", type.doubleType()).setValueFormatter(nf); TextColumnBuilder<Double> waldFlaecheColumn = col .column("davon Wald", "flaecheWaldAnteilig", type.doubleType()).setValueFormatter(nf); TextColumnBuilder<String> nameColumn = col.column("Waldbesitzer", "name", type.stringType()); ColumnTitleGroupBuilder titleGroup1 = grid.titleGroup("Gemeinde \n Gemarkung", gemeindeColumn, gemarkungColumn); ColumnGroupBuilder gemeindeGroupBuilder = Groups.group(gemeindeColumn).setPadding(5).footer(cmp.line()); ColumnGroupBuilder gemarkungGroupBuilder = Groups.group(gemarkungColumn).setPadding(5).footer(cmp.line()); ReportTemplateBuilder templateBuilder = template(); templateBuilder.setGroupShowColumnHeaderAndFooter(false); templateBuilder.setGroupHeaderLayout(GroupHeaderLayout.VALUE); templateBuilder.setSubtotalLabelPosition(Position.BOTTOM); templateBuilder.setSubtotalStyle(stl.style(stl.style().bold())); templateBuilder .setGroupStyle(stl.style(stl.style().bold()).setHorizontalAlignment(HorizontalAlignment.LEFT)); templateBuilder .setGroupTitleStyle(stl.style(stl.style().bold()).setHorizontalAlignment(HorizontalAlignment.LEFT)); return report().setTemplate(templateBuilder).setDataSource(new JsonDataSource(jsonBuilder.run())) .setPageFormat(PageType.A4, PageOrientation.PORTRAIT) .title(cmp.text("Flurstcksweise Anzeige mit Waldbesitzer").setStyle(titleStyle), cmp.text(df.format(new Date())).setStyle(headerStyle), cmp.text("").setStyle(headerStyle)) .pageFooter(cmp.pageXofY().setStyle(footerStyle)) // number of page .setDetailOddRowStyle(highlightRowStyle).setColumnTitleStyle(columnTitleStyle) .addGroup(gemeindeGroupBuilder).addGroup(gemarkungGroupBuilder) .columns(flstnrColumn, gesamtFlaecheColumn, waldFlaecheColumn, nameColumn) .columnGrid(titleGroup1, flstnrColumn, gesamtFlaecheColumn, waldFlaecheColumn, nameColumn) .subtotalsAtGroupFooter(gemarkungGroupBuilder, sbt.sum(gesamtFlaecheColumn).setValueFormatter(nf), sbt.sum(waldFlaecheColumn).setValueFormatter(nf)) .sortBy(asc(gemeindeColumn), asc(gemarkungColumn)); }
From source file:com.joliciel.csvLearner.maxent.MaxentBestFeatureObserver.java
@Override public void onAnalyse(GenericEvent event, Collection<NameValuePair> outcomes) { Map<String, Double> featureTotals = featureMap.get(event.getOutcome()); if (featureTotals == null) { featureTotals = new TreeMap<String, Double>(); featureMap.put(event.getOutcome(), featureTotals); }// w w w . j ava 2 s . c o m for (int i = 0; i < event.getFeatures().size(); i++) { String feature = event.getFeatures().get(i); double value = event.getWeights().get(i); double currentTotal = 0.0; Double currentTotalObj = featureTotals.get(feature); if (currentTotalObj != null) currentTotal = currentTotalObj.doubleValue(); int predicateIndex = predicateTable.get(feature); if (predicateIndex >= 0) { Context context = modelParameters[predicateIndex]; int[] outcomeIndexes = context.getOutcomes(); double[] parameters = context.getParameters(); int outcomeIndex = -1; for (int j = 0; j < outcomeNames.length; j++) { if (outcomeNames[j].equals(event.getOutcome())) { outcomeIndex = j; break; } } int paramIndex = -1; for (int k = 0; k < outcomeIndexes.length; k++) { if (outcomeIndexes[k] == outcomeIndex) { paramIndex = k; break; } } double weight = 0.0; if (paramIndex >= 0) weight = parameters[paramIndex]; double total = Math.exp(value * weight); currentTotal += total; } featureTotals.put(feature, currentTotal); } }
From source file:jasima.core.util.converter.DblDistributionFactory.java
@Override public DblStream stringToStream(ArgListTokenizer tk) { TypeToStringConverter doubleConv = TypeToStringConverter.lookupConverter(Double.class); assert doubleConv != null; String prefix = tk.currTokenText(); tk.assureTokenTypes(tk.nextTokenNoWhitespace(), TokenType.PARENS_OPEN); ArrayList<Double> values = new ArrayList<Double>(); // there has to be at least one value Double v1 = doubleConv.fromString(tk, Double.class, prefix, this.getClass().getClassLoader(), Util.DEF_CLASS_SEARCH_PATH); values.add(v1);/* w w w. j a va 2s . c o m*/ tk.assureTokenTypes(tk.nextTokenNoWhitespace(), TokenType.PARENS_CLOSE); return new DblDistribution(new ExponentialDistribution(v1.doubleValue())); }