List of usage examples for java.lang Double intValue
public int intValue()
From source file:org.sonar.plugins.cxx.xunit.TestSuiteParser.java
private TestCase parseTestCaseTag(SMInputCursor testCaseCursor) throws XMLStreamException { // TODO: get a decent grammar for the junit format and check the // logic inside this method against it. String name = parseTestCaseName(testCaseCursor); Double time = parseTime(testCaseCursor); String status = "ok"; String stack = ""; String msg = ""; SMInputCursor childCursor = testCaseCursor.childElementCursor(); if (childCursor.getNext() != null) { String elementName = childCursor.getLocalName(); if (elementName.equals("skipped")) { status = "skipped"; } else if (elementName.equals("failure")) { status = "failure"; msg = childCursor.getAttrValue("message"); stack = childCursor.collectDescendantText(); } else if (elementName.equals("error")) { status = "error"; msg = childCursor.getAttrValue("message"); stack = childCursor.collectDescendantText(); }// ww w.ja va2s .c om } return new TestCase(name, time.intValue(), status, stack, msg); }
From source file:org.exoplatform.wcm.connector.FileUploadHandler.java
/** * Gets the progress.// ww w. j av a 2 s . c om * * @param uploadId the upload id * * @return the progress * * @throws Exception the exception */ private Document getProgress(String uploadId) throws Exception { UploadResource resource = uploadService.getUploadResource(uploadId); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); Double percent = 0.0; if (resource != null) { if (resource.getStatus() == UploadResource.UPLOADING_STATUS) { percent = (resource.getUploadedSize() * 100) / resource.getEstimatedSize(); } else { percent = 100.0; } } Element rootElement = doc.createElement("UploadProgress"); rootElement.setAttribute("uploadId", uploadId); rootElement.setAttribute("fileName", resource == null ? "" : resource.getFileName()); rootElement.setAttribute("percent", percent.intValue() + ""); rootElement.setAttribute("uploadedSize", resource == null ? "0" : resource.getUploadedSize() + ""); rootElement.setAttribute("totalSize", resource == null ? "0" : resource.getEstimatedSize() + ""); rootElement.setAttribute("fileType", resource == null ? "null" : resource.getMimeType() + ""); doc.appendChild(rootElement); return doc; }
From source file:gob.dp.simco.intervencion.controller.IntervencionController.java
private Integer defineAvance() { double total = intervencionEtapaActuacions.size(); double activos = 0; for (IntervencionEtapaActuacion iea : intervencionEtapaActuacions) { if (StringUtils.equals(iea.getEstado(), "ACT")) { activos++;/*from w w w . j a v a2 s. c o m*/ } } Double porcentajeD = (activos / total) * 100; Integer porcentaje = porcentajeD.intValue(); return porcentaje; }
From source file:gob.dp.simco.intervencion.controller.IntervencionController.java
private Integer defineAvanceReport(List<IntervencionEtapaActuacion> lista) { double total = lista.size(); double activos = 0; for (IntervencionEtapaActuacion iea : lista) { if (StringUtils.equals(iea.getEstado(), "ACT")) { activos++;//from ww w . jav a2s . com } } Double porcentajeD = (activos / total) * 100; Integer porcentaje = porcentajeD.intValue(); return porcentaje; }
From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java
private Integer calculateDistanceFilter(Float speed) { Double newDistanceFilter = (double) distanceFilter; if (speed < 100) { float roundedDistanceFilter = (round(speed / 5) * 5); newDistanceFilter = pow(roundedDistanceFilter, 2) + (double) distanceFilter; }//from w w w . ja v a2s .c o m return (newDistanceFilter.intValue() < 1000) ? newDistanceFilter.intValue() : 1000; }
From source file:org.sonar.server.component.ws.ComponentAppAction.java
@CheckForNull private String formatVariation(@Nullable MeasureDto measure, Integer periodIndex) { if (measure != null) { Double variation = measure.getVariation(periodIndex); if (variation != null) { Metric metric = CoreMetrics.getMetric(measure.getKey().metricKey()); Metric.ValueType metricType = metric.getType(); if (metricType.equals(Metric.ValueType.FLOAT) || metricType.equals(Metric.ValueType.PERCENT)) { return i18n.formatDouble(UserSession.get().locale(), variation); }//from w w w . java2 s. co m if (metricType.equals(Metric.ValueType.INT)) { return i18n.formatInteger(UserSession.get().locale(), variation.intValue()); } if (metricType.equals(Metric.ValueType.WORK_DUR)) { return durations.format(UserSession.get().locale(), durations.create(variation.longValue()), Durations.DurationFormat.SHORT); } } } return null; }
From source file:org.odk.collect.android.activities.GeoTraceOsmMapActivity.java
public void overlayIntentTrace(String str) { String s = str.replace("; ", ";"); String[] sa = s.split(";"); for (int i = 0; i < (sa.length); i++) { String[] sp = sa[i].split(" "); double[] gp = new double[4]; String lat = sp[0].replace(" ", ""); String lng = sp[1].replace(" ", ""); String altStr = sp[2].replace(" ", ""); String acu = sp[3].replace(" ", ""); gp[0] = Double.parseDouble(lat); gp[1] = Double.parseDouble(lng); Double alt = Double.parseDouble(altStr); Marker marker = new Marker(mapView); marker.setSubDescription(acu);//from ww w . j a va 2 s.c o m GeoPoint point = new GeoPoint(gp[0], gp[1]); point.setAltitude(alt.intValue()); marker.setPosition(point); marker.setOnMarkerClickListener(nullMarkerListener); marker.setDraggable(true); marker.setOnMarkerDragListener(dragListener); marker.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_place_black_36dp)); marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); mapMarkers.add(marker); List<GeoPoint> points = polyline.getPoints(); points.add(marker.getPosition()); polyline.setPoints(points); mapView.getOverlays().add(marker); } mapView.invalidate(); }
From source file:org.sonar.plugins.surefire.TestSuiteParser.java
private TestCaseDetails getTestCaseDetails(SMInputCursor testCaseCursor) throws XMLStreamException { TestCaseDetails detail = new TestCaseDetails(); String name = getTestCaseName(testCaseCursor); detail.setName(name);/*w ww.j a va 2 s .c o m*/ String status = TestCaseDetails.STATUS_OK; Double time = getTimeAttributeInMS(testCaseCursor); SMInputCursor childNode = testCaseCursor.descendantElementCursor(); if (childNode.getNext() != null) { String elementName = childNode.getLocalName(); if (elementName.equals("skipped")) { status = TestCaseDetails.STATUS_SKIPPED; // bug with surefire reporting wrong time for skipped tests time = 0d; } else if (elementName.equals("failure")) { status = TestCaseDetails.STATUS_FAILURE; setStackAndMessage(detail, childNode); } else if (elementName.equals("error")) { status = TestCaseDetails.STATUS_ERROR; setStackAndMessage(detail, childNode); } } // make sure we loop till the end of the elements cursor while (childNode.getNext() != null) { } detail.setTimeMS(time.intValue()); detail.setStatus(status); return detail; }
From source file:stats.GaussianFitMeanStdev.java
public void CalculateGlobalMeanStdev(ChrHistogramFactory gchisto, WindowPlan wins) { Long maxvalue = 0l;//from w w w .j a v a 2s . c om int count = 0; for (String chr : wins.getChrList()) { if (!gchisto.hasChrHistogram(chr)) continue; for (Double d : gchisto.getChrHistogram(chr).retrieveRDBins()) { count++; if (d.longValue() > maxvalue) maxvalue = d.longValue(); } } if (count < 3 || maxvalue.intValue() < 3) { log.log(Level.SEVERE, "Error! Could not calculate Global Mean and Stdev! Count: " + count + " maxvalue: " + maxvalue); System.exit(-1); } Double[] bins = new Double[maxvalue.intValue() + 1]; java.util.Arrays.fill(bins, 0.0d); double sum = 0.0d; for (String chr : wins.getChrList()) { if (!gchisto.hasChrHistogram(chr)) continue; for (Double d : gchisto.getChrHistogram(chr).retrieveRDBins()) { sum += d; bins[d.intValue()] += 1; } } WeightedObservedPoints obs = new WeightedObservedPoints(); for (int i = 0; i < bins.length; i++) { obs.add(i, bins[i]); } double testmean = sum / count; double teststdev = 0.0d; for (String chr : wins.getChrList()) { for (Double d : gchisto.getChrHistogram(chr).retrieveRDBins()) { teststdev += (double) Math.pow(d - testmean, 2.0d); } } teststdev /= (double) (count - 1); teststdev = Math.sqrt(teststdev); double[] parameters; try { this.fitter = GaussianCurveFitter.create().withMaxIterations(50) .withStartPoint(new double[] { maxvalue * 0.4 / teststdev, testmean, teststdev * 0.5 }); parameters = fitter.fit(obs.toList()); } catch (TooManyIterationsException ex) { log.log(Level.WARNING, "Too many iterations! Using regular mean and stdev."); this.mean = testmean; this.stdev = teststdev; return; } Double mincut = parameters[1] - 2.0d * parameters[2]; Double maxcut = parameters[1] + 2.0d * parameters[2]; if (maxcut - mincut < 3 || mincut < 0 || maxcut < 0) { log.log(Level.WARNING, "Gaussian fitting calculation had " + mincut + " and " + maxcut + "! Not fitting values"); this.mean = parameters[1]; this.stdev = parameters[2]; return; } List<Double> tempvals = new ArrayList<>(); for (int i = mincut.intValue(); i < maxcut.intValue(); i++) { tempvals.add(bins[i]); } obs = new WeightedObservedPoints(); for (int i = mincut.intValue(); i < maxcut.intValue(); i++) { obs.add(i, bins[i]); } try { this.fitter = GaussianCurveFitter.create().withMaxIterations(50) .withStartPoint(new double[] { maxvalue * 0.4 / teststdev, testmean, teststdev * 0.5 }); } catch (TooManyIterationsException ex) { log.log(Level.WARNING, "Too many iterations! Using previously generated mean and stdev."); return; } double[] par = fitter.fit(obs.toList()); this.mean = par[1]; this.stdev = par[2]; }
From source file:org.apache.zeppelin.rest.NotebookRestApi.java
/** * Insert paragraph REST API/*from ww w . j a va2 s . c o m*/ * * @param message - JSON containing paragraph's information * @return JSON with status.OK * @throws IOException */ @POST @Path("{noteId}/paragraph") @ZeppelinApi public Response insertParagraph(@PathParam("noteId") String noteId, String message) throws IOException { LOG.info("insert paragraph {} {}", noteId, message); Note note = notebook.getNote(noteId); checkIfNoteIsNotNull(note); checkIfUserCanWrite(noteId, "Insufficient privileges you cannot add paragraph to this note"); NewParagraphRequest request = gson.fromJson(message, NewParagraphRequest.class); AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); Paragraph p; Double indexDouble = request.getIndex(); if (indexDouble == null) { p = note.addParagraph(subject); } else { p = note.insertParagraph(indexDouble.intValue(), subject); } p.setTitle(request.getTitle()); p.setText(request.getText()); note.persist(subject); notebookServer.broadcastNote(note); return new JsonResponse<>(Status.OK, "", p.getId()).build(); }