List of usage examples for java.lang Float doubleValue
public double doubleValue()
From source file:org.apache.fop.svg.AbstractFOPTextPainter.java
private void updateLocationFromACI(AttributedCharacterIterator aci, Point2D loc) { //Adjust position of span Float xpos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.X); Float ypos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.Y); Float dxpos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.DX); Float dypos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.DY); if (xpos != null) { loc.setLocation(xpos.doubleValue(), loc.getY()); }// w ww . java 2 s . co m if (ypos != null) { loc.setLocation(loc.getX(), ypos.doubleValue()); } if (dxpos != null) { loc.setLocation(loc.getX() + dxpos.doubleValue(), loc.getY()); } if (dypos != null) { loc.setLocation(loc.getX(), loc.getY() + dypos.doubleValue()); } }
From source file:di.uniba.it.wsd.RevisedLesk.java
private double simBag(Map<String, Float> bag1, Map<String, Float> bag2) { double n1 = 0; double n2 = 0; double ip = 0; Iterator<String> it1 = bag1.keySet().iterator(); while (it1.hasNext()) { String t1 = it1.next();/* www . j av a2 s. c o m*/ Float v1 = bag1.get(t1); if (bag2.containsKey(t1)) { ip += v1.doubleValue() * bag2.get(t1).doubleValue(); } n1 += Math.pow(v1.doubleValue(), 2); } Iterator<Float> it2 = bag2.values().iterator(); while (it2.hasNext()) { n2 += Math.pow(it2.next().doubleValue(), 2); } if (n1 == 0 || n2 == 0) { return 0; } else { return ip / (n1 * n2); } }
From source file:app.common.upload.shapeways.oauth.ModelUploadOauthRunner.java
public String uploadModel(byte[] bytes, String fileName, Integer modelId, Float scale, String title, String description, Integer isPublic, Integer isForSale, Map<Integer, Object> materialsMap) throws Exception { String reason = null;/* w w w.ja v a2 s .c om*/ Gson gson = new Gson(); String encodedFile = null; encodedFile = encodeModel(bytes); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("file", encodedFile); parameters.put("fileName", fileName); parameters.put("ownOrAuthorizedModel", 1); parameters.put("acceptTermsAndConditions", 1); parameters.put("hasRightsToModel", 1); if (scale != null) { parameters.put("uploadScale", scale.doubleValue()); } if (modelId != null) { parameters.put("modelId", modelId.intValue()); } if (title != null) { parameters.put("title", title); } if (description != null) { parameters.put("description", description); } if (isPublic != null) { parameters.put("isPublic", isPublic.intValue()); } if (isForSale != null) { parameters.put("isForSale", isForSale.intValue()); } if (materialsMap != null) { parameters.put("materials", materialsMap); } OAuthRequest request = new OAuthRequest(Verb.POST, UPLOAD_URL); String encodedParams = gson.toJson(parameters); //System.out.println("json params: " + encodedParams); request.addPayload(encodedParams); service.signRequest(accessToken, request); Response response = request.send(); if (!response.isSuccessful()) { reason = "Upload failed: " + UPLOAD_URL + ", response code: " + response.getCode(); System.out.println(reason); throw new Exception(reason); } String responseBody = response.getBody(); System.out.println(responseBody); return responseBody; }
From source file:oscar.oscarRx.util.RxUtil.java
public static String FloatToString(float value) { Float f = new Float(value); java.text.NumberFormat fmt = java.text.NumberFormat.getNumberInstance(); String s = fmt.format(f.doubleValue()); return s;/* www . jav a 2 s . c o m*/ }
From source file:org.rhq.plugins.cassandra.StorageServiceComponent.java
@Override protected void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests, EmsBean bean) { super.getValues(report, requests, bean); EmsAttribute loadAttribute = bean.getAttribute(LOAD_NAME); Object loadValue = loadAttribute.refresh(); EmsAttribute dataFileLocationAttribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME); Object dataFileLocationValue = dataFileLocationAttribute.refresh(); double load = 0; if (loadValue != null && dataFileLocationValue != null && dataFileLocationValue instanceof String[]) { //Please visit for details: https://issues.apache.org/jira/browse/CASSANDRA-2749 //The average usage of all partitions with the data will be reported. //Cassandra selects the partition with most free space for SStable flush and compaction. load = Double.parseDouble(loadValue.toString()); load = load / 1024d; //transform in MB }/*from w w w .jav a 2 s. c o m*/ for (MeasurementScheduleRequest request : requests) { if (OWNERSHIP_METRIC_NAME.equals(request.getName()) && host != null) { EmsAttribute attribute = bean.getAttribute(OWNERSHIP_METRIC_NAME); Object valueObject = attribute.refresh(); if (valueObject instanceof Map<?, ?>) { @SuppressWarnings("unchecked") Map<InetAddress, Float> ownership = (Map<InetAddress, Float>) valueObject; Float value = ownership.get(host); if (value == null) { // the inet address wasn't probably resolved, scan the map for (Map.Entry<InetAddress, Float> entry : ownership.entrySet()) { if (entry.getKey().getHostAddress().equals(host.getHostAddress())) { value = entry.getValue(); break; } } } if (value > 1) { value = 1f; } report.addData(new MeasurementDataNumeric(request, value.doubleValue())); } break; } else if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName()) || TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName()) || FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(request.getName())) { double metricValue = getDiskUsageMetric(request, load, (String[]) dataFileLocationValue); report.addData(new MeasurementDataNumeric(request, metricValue)); } } }
From source file:uk.ac.diamond.scisoft.ncd.rcp.views.NcdDetectorParameters.java
private void restoreState() { if (memento != null) { Boolean val; Integer idx;//www .j a v a2 s . c o m IMemento[] waxsMemento = memento.getChildren(NcdPreferences.NCD_WAXS_DETECTOR); if (waxsMemento != null) { detListWaxs.removeAll(); for (IMemento det : waxsMemento) { NcdDetectorSettings ncdDetector = new NcdDetectorSettings(det.getID(), DetectorTypes.WAXS_DETECTOR, 1); Float px = det.getFloat(NcdPreferences.NCD_PIXEL); if (px != null) ncdDetector.setPxSize(Amount.valueOf(px.doubleValue(), SI.MILLIMETRE)); Integer dim = det.getInteger(NcdPreferences.NCD_DIM); if (dim != null) ncdDetector.setDimension(dim.intValue()); ncdDetectorSourceProvider.addNcdDetector(ncdDetector); } } ncdDetectorSourceProvider.updateNcdDetectors(); idx = memento.getInteger(NcdPreferences.NCD_WAXS_INDEX); if (idx != null) { detListWaxs.select(idx); detListWaxs.notifyListeners(SWT.Selection, null); } IMemento[] saxsMemento = memento.getChildren(NcdPreferences.NCD_SAXS_DETECTOR); if (saxsMemento != null) { detListSaxs.removeAll(); for (IMemento det : saxsMemento) { NcdDetectorSettings ncdDetector = new NcdDetectorSettings(det.getID(), DetectorTypes.SAXS_DETECTOR, 2); Float px = det.getFloat(NcdPreferences.NCD_PIXEL); if (px != null) ncdDetector.setPxSize(Amount.valueOf(px.doubleValue(), SI.MILLIMETRE)); Integer dim = det.getInteger(NcdPreferences.NCD_DIM); if (dim != null) ncdDetector.setDimension(dim.intValue()); ncdDetectorSourceProvider.addNcdDetector(ncdDetector); } } ncdDetectorSourceProvider.updateNcdDetectors(); idx = memento.getInteger(NcdPreferences.NCD_SAXS_INDEX); if (idx != null) { detListSaxs.select(idx); detListSaxs.notifyListeners(SWT.Selection, null); } val = memento.getBoolean(NcdPreferences.NCD_WAXS); if (val != null) { detTypeWaxs.setSelection(val); if (val.booleanValue()) detTypeWaxs.notifyListeners(SWT.Selection, null); } val = memento.getBoolean(NcdPreferences.NCD_SAXS); if (val != null) { detTypeSaxs.setSelection(val); if (val.booleanValue()) detTypeSaxs.notifyListeners(SWT.Selection, null); } IMemento[] normMemento = memento.getChildren(NcdPreferences.NCD_NORM_DETECTOR); if (normMemento != null) { calList.removeAll(); for (IMemento det : normMemento) { NcdDetectorSettings ncdDetector = new NcdDetectorSettings(det.getID(), DetectorTypes.CALIBRATION_DETECTOR, 1); ncdDetector.setMaxChannel(det.getInteger(NcdPreferences.NCD_MAXCHANNEL)); ncdDetector.setNormChannel(det.getInteger(NcdPreferences.NCD_MAXCHANNEL_INDEX)); ncdDetectorSourceProvider.addNcdDetector(ncdDetector); } } ncdDetectorSourceProvider.updateNcdDetectors(); idx = memento.getInteger(NcdPreferences.NCD_NORM_INDEX); if (idx != null) { calList.select(idx); calList.notifyListeners(SWT.Selection, null); } } }
From source file:eu.uqasar.model.tree.Project.java
/** * @param formulaToEval the formulaToEval to set */// w ww.ja va 2 s . co m @JsonIgnore public void setFormulaToEval(final String formulaToEval) { this.formulaToEval = formulaToEval; if (formulaToEval != null && !formulaToEval.isEmpty()) { Double val = null; Float evaluatedVal = Formula.evalFormula(formulaToEval); if (evaluatedVal != null) { val = evaluatedVal.doubleValue(); this.setValue(val); } } }
From source file:org.wso2.carbon.appmgt.migration.client.MigrationClientImpl.java
private void migrateMobileAppRatings(Map<String, Float> appRating, String tenantDomain) throws APPMMigrationException { Connection connection = null; PreparedStatement statement = null; try {//w w w .ja va2 s . co m if (log.isDebugEnabled()) { log.debug("Executing: " + Constants.INSERT_SOCIAL_CACHE); } connection = getConnection(Constants.SOCIAL_DB_NAME); statement = connection.prepareStatement(Constants.INSERT_SOCIAL_CACHE); for (String contextId : appRating.keySet()) { statement.setString(1, contextId); Float rating = appRating.get(contextId); statement.setInt(2, rating.intValue()); statement.setInt(3, 1); statement.setDouble(4, rating.doubleValue()); statement.setString(5, tenantDomain); statement.addBatch(); } statement.executeBatch(); } catch (SQLException e) { handleException("Error occurred while migrating mobile application ratings for tenant " + tenantDomain, e); } catch (DataSourceException e) { handleException("Error occurred while obtaining datasource connection for " + Constants.SOCIAL_DB_NAME + " during mobile application ratings migration for tenant " + tenantDomain, e); } finally { closeConnection(connection); if (statement != null) { try { statement.close(); } catch (SQLException e) { handleException( "Error occurred while closing prepared statement for Mobile app Social Cache update " + "for tenant " + tenantDomain, e); } } } }
From source file:pandroid.agent.PandroidAgentListener.java
private String buildXML() { String buffer = ""; String gpsData = ""; buffer += "<?xml version='1.0' encoding='UTF-8'?>\n"; String latitude = getSharedData("PANDROID_DATA", "latitude", "181", "float"); String longitude = getSharedData("PANDROID_DATA", "longitude", "181", "float"); if (!latitude.equals("181.0") && !longitude.equals("181.0")) { gpsData = " latitude='" + latitude + "' longitude='" + longitude + "'"; }//from w w w.j av a 2 s . c o m String interval = getSharedData("PANDROID_DATA", "interval", Integer.toString(Core.defaultInterval), "integer"); String agentName = getSharedData("PANDROID_DATA", "agentName", Core.defaultAgentName, "string"); buffer += "<agent_data " + "description='' group='' os_name='android' os_version='" + Build.VERSION.RELEASE + "' " + "interval='" + interval + "' version='4.0(Build 111012)' " + "timestamp='" + getHumanDateTime(-1) + "' agent_name='" + agentName + "' " + "timezone_offset='0'" + gpsData + ">\n"; // // // MODULES // // // // String orientation = getSharedData("PANDROID_DATA", "orientation", "361", "float"); // String proximity = getSharedData("PANDROID_DATA", "proximity", "-1.0", "float"); String batteryLevel = getSharedData("PANDROID_DATA", "batteryLevel", "-1", "integer"); String taskStatus = getSharedData("PANDROID_DATA", "taskStatus", "disabled", "string"); String taskRun = getSharedData("PANDROID_DATA", "taskRun", "false", "string"); String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", "", "string"); taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName); String task = getSharedData("PANDROID_DATA", "task", "", "string"); String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", Core.defaultMemoryStatus, "string"); String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0", "long"); String totalRamKb = getSharedData("PANDROID_DATA", "totalRamKb", "0", "long"); String upTime = getSharedData("PANDROID_DATA", "upTime", "" + Core.defaultUpTime, "long"); String helloSignal = getSharedData("PANDROID_DATA", "helloSignal", "" + Core.defaultHelloSignal, "integer"); String SimID = getSharedData("PANDROID_DATA", "simID", Core.defaultSimID, "string"); String networkOperator = getSharedData("PANDROID_DATA", "networkOperator", Core.defaultNetworkOperator, "string"); String networkType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string"); String phoneType = getSharedData("PANDROID_DATA", "networkType", Core.defaultNetworkType, "string"); String signalStrength = getSharedData("PANDROID_DATA", "signalStrength", "" + Core.defaultSignalStrength, "integer"); String SMSReceived = getSharedData("PANDROID_DATA", "SMSReceived", "" + Core.defaultSMSReceived, "integer"); String SMSSent = getSharedData("PANDROID_DATA", "SMSSent", "" + Core.defaultSMSSent, "integer"); String incomingCalls = getSharedData("PANDROID_DATA", "incomingCalls", "" + Core.defaultIncomingCalls, "integer"); String missedCalls = getSharedData("PANDROID_DATA", "missedCalls", "" + Core.defaultMissedCalls, "integer"); String outgoingCalls = getSharedData("PANDROID_DATA", "outgoingCalls", "" + Core.defaultOutgoingCalls, "integer"); String receiveBytes = getSharedData("PANDROID_DATA", "receiveBytes", "" + Core.defaultReceiveBytes, "long"); String transmitBytes = getSharedData("PANDROID_DATA", "transmitBytes", "" + Core.defaultTransmitBytes, "long"); String roaming = getSharedData("PANDROID_DATA", "roaming", "" + Core.defaultRoaming, "integer"); String simIDReport = getSharedData("PANDROID_DATA", "simIDReport", Core.defaultSimIDReport, "string"); String DeviceUpTimeReport = getSharedData("PANDROID_DATA", "DeviceUpTimeReport", Core.defaultDeviceUpTimeReport, "string"); String NetworkOperatorReport = getSharedData("PANDROID_DATA", "NetworkOperatorReport", Core.defaultNetworkOperatorReport, "string"); String NetworkTypeReport = getSharedData("PANDROID_DATA", "NetworkTypeReport", Core.defaultNetworkTypeReport, "string"); String PhoneTypeReport = getSharedData("PANDROID_DATA", "PhoneTypeReport", Core.defaultPhoneTypeReport, "string"); String SignalStrengthReport = getSharedData("PANDROID_DATA", "SignalStrengthReport", Core.defaultSignalStrengthReport, "string"); String ReceivedSMSReport = getSharedData("PANDROID_DATA", "ReceivedSMSReport", Core.defaultReceivedSMSReport, "string"); String SentSMSReport = getSharedData("PANDROID_DATA", "SentSMSReport", Core.defaultSentSMSReport, "string"); String IncomingCallsReport = getSharedData("PANDROID_DATA", "IncomingCallsReport", Core.defaultIncomingCallsReport, "string"); String MissedCallsReport = getSharedData("PANDROID_DATA", "MissedCallsReport", Core.defaultMissedCallsReport, "string"); String OutgoingCallsReport = getSharedData("PANDROID_DATA", "OutgoingCallsReport", Core.defaultOutgoingCallsReport, "string"); String BytesReceivedReport = getSharedData("PANDROID_DATA", "BytesReceivedReport", Core.defaultBytesReceivedReport, "string"); String BytesSentReport = getSharedData("PANDROID_DATA", "BytesSentReport", Core.defaultBytesSentReport, "string"); String HelloSignalReport = getSharedData("PANDROID_DATA", "HelloSignalReport", Core.defaultHelloSignalReport, "string"); String BatteryLevelReport = getSharedData("PANDROID_DATA", "BatteryLevelReport", Core.defaultBatteryLevelReport, "string"); String RoamingReport = getSharedData("PANDROID_DATA", "RoamingReport", Core.defaultRoamingReport, "string"); String InventoryReport = getSharedData("PANDROID_DATA", "InventoryReport", Core.defaultInventoryReport, "string"); if (InventoryReport.equals("enabled")) { buffer += buildInventoryXML(); } if (BatteryLevelReport.equals("enabled")) buffer += buildmoduleXML("battery_level", "The current Battery level", "generic_data", batteryLevel); // if(!orientation.equals("361.0")) { // buffer += buildmoduleXML("orientation", "The actually device orientation (in degrees)", "generic_data", orientation); // } // // if(!proximity.equals("-1.0")) { // buffer += buildmoduleXML("proximity", "The actually device proximity detector (0/1)", "generic_data", proximity); // } if (taskStatus.equals("enabled")) { buffer += buildmoduleXML("taskHumanName", "The task's human name.", "async_string", taskHumanName); buffer += buildmoduleXML("task", "The task's package name.", "async_string", task); if (taskRun.equals("true")) { buffer += buildmoduleXML("taskRun", "The task is running.", "async_proc", "1"); } else { buffer += buildmoduleXML("taskRun", "The task is running.", "async_proc", "0"); } } if (memoryStatus.equals("enabled")) { Float freeMemory = new Float((Float.valueOf(availableRamKb) / Float.valueOf(totalRamKb)) * 100.0); DecimalFormat formatPercent = new DecimalFormat("#.##"); buffer += buildmoduleXML("freeRamMemory", "The percentage of available ram.", "generic_data", formatPercent.format(freeMemory.doubleValue())); } //buffer += buildmoduleXML("last_gps_contact", "Datetime of the last geo-location contact", "generic_data", lastGpsContactDateTime); if (DeviceUpTimeReport.equals("enabled")) buffer += buildmoduleXML("upTime", "Total device uptime in seconds.", "generic_data", upTime); if (HelloSignalReport.equals("enabled")) buffer += buildmoduleXML("helloSignal", "Hello Signal", "generic_data", helloSignal); if (Core.hasSim) { if (simIDReport.equals("enabled")) buffer += buildmoduleXML("simID", "The Sim ID.", "generic_data_string", SimID); if (NetworkOperatorReport.equals("enabled")) buffer += buildmoduleXML("networkOperator", "Currently registered network operator", "generic_data_string", networkOperator); if (NetworkTypeReport.equals("enabled")) buffer += buildmoduleXML("networkType", "Current network type", "generic_data_string", networkType); if (PhoneTypeReport.equals("enabled")) buffer += buildmoduleXML("phoneType", "Phone type", "generic_data_string", phoneType); if (SignalStrengthReport.equals("enabled")) buffer += buildmoduleXML("signalStrength", "Signal strength (dB)", "generic_data_string", signalStrength); if (ReceivedSMSReport.equals("enabled")) buffer += buildmoduleXML("SMSReceived", "Number of SMS received", "generic_data", SMSReceived); if (SentSMSReport.equals("enabled")) buffer += buildmoduleXML("SMSSent", "Number of SMS sent", "generic_data", SMSSent); if (IncomingCallsReport.equals("enabled")) buffer += buildmoduleXML("incomingCalls", "Incoming calls", "generic_data", incomingCalls); if (MissedCallsReport.equals("enabled")) buffer += buildmoduleXML("missedCalls", "Missed calls", "generic_data", missedCalls); if (OutgoingCallsReport.equals("enabled")) buffer += buildmoduleXML("outgoingCalls", "Outgoing calls", "generic_data", outgoingCalls); if (BytesReceivedReport.equals("enabled")) buffer += buildmoduleXML("receiveBytes", "Bytes received(mobile)", "generic_data", receiveBytes); if (BytesSentReport.equals("enabled")) buffer += buildmoduleXML("transmitBytes", "Bytes transmitted(mobile)", "generic_data", transmitBytes); if (RoamingReport.equals("enabled")) buffer += buildmoduleXML("roaming", "Device is roaming", "generic_data", roaming); } // end if sim card buffer += "</agent_data>"; return buffer; }
From source file:org.etudes.jforum.view.admin.CategoryAction.java
/** * send grades to gradebook//from w w w. j ava 2s . c om * @param grade grade * @param gradebookUid gradebookuid * @param jForumGBService jforum gradebook service * @throws Exception */ protected void sendGradesToGradebook(Grade grade, String gradebookUid, JForumGBService jForumGBService) throws Exception { if (grade.isAddToGradeBook()) { // send grades to gradebook List<Evaluation> evaluations = null; EvaluationDAO.EvaluationsSort evalSort = EvaluationDAO.EvaluationsSort.last_name_a; evaluations = DataAccessDriver.getInstance().newEvaluationDAO() .selectCategoryEvaluations(grade.getCategoryId(), evalSort); Map<String, Double> scores = new HashMap<String, Double>(); for (Evaluation eval : evaluations) { if (eval.isReleased()) { String key = eval.getSakaiUserId(); Float userScore = eval.getScore(); scores.put(key, (userScore == null) ? null : Double.valueOf(userScore.doubleValue())); } } jForumGBService.updateExternalAssessmentScores(gradebookUid, "discussions-" + String.valueOf(grade.getId()), scores); } }