List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:Logica.Usuario.java
/** * * @param item//from ww w . ja v a 2s .c o m * @return * @throws RemoteException * * Edita la informacin de un tem ya existente. */ @Override public boolean editarItem(ItemInventario item) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); boolean hecho = false; ItemJpaController itm = new ItemJpaController(emf); Item i = itm.findItem(item.getNumero()); i.setCinterno(item.getNumero().trim()); i.setInventario(item.getInventario()); i.setDescripcion(item.getDescripcion()); i.setPresentacion(item.getPresentacion()); i.setCantidad(new Double(Float.toString(item.getCantidad()))); i.setPrecio(new Double(Float.toString(item.getPrecio()))); i.setCcalidad(item.getcCalidad()); i.setCesp(item.getCEsp()); try { itm.edit(i); hecho = true; emf.close(); } catch (Exception ex) { Logger.getLogger(Usuario.class.getName()).log(Level.SEVERE, null, ex); } return hecho; }
From source file:Matrix.java
/** * Convert a matrix into a string. Useful for debuging soya. * @param m the matrix/*from www .ja v a2s. c om*/ * @return the string */ public static final String matrixToString(float[] m) { String s = "matrix 4_4 {\n"; s = s + Float.toString(m[0]) + " " + Float.toString(m[4]) + " " + Float.toString(m[8]) + "\n"; s = s + Float.toString(m[1]) + " " + Float.toString(m[5]) + " " + Float.toString(m[9]) + "\n"; s = s + Float.toString(m[2]) + " " + Float.toString(m[6]) + " " + Float.toString(m[10]) + "\n"; s = s + Float.toString(m[3]) + " " + Float.toString(m[7]) + " " + Float.toString(m[11]) + "\n"; s = s + "X: " + Float.toString(m[12]) + " Y: " + Float.toString(m[13]) + " Z: " + Float.toString(m[14]) + " W: " + Float.toString(m[15]) + "\n"; s = s + "}"; return s; }
From source file:eu.liveGov.gordexola.urbanplanning.activities.MainActivity.java
@SuppressLint("NewApi") @Override/*ww w. j av a 2 s.c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { Process process = Runtime.getRuntime().exec("logcat -c"); } catch (IOException e) { Log.e("MainActivity", "I was unable to clear LogCat"); } _savedInstanceState = savedInstanceState; configureLogbackDirectly(); tracker = EasyTracker.getInstance(this); setContentView(R.layout.activity_main); initialiseTabHost(); initialisePager(); ctx = this; //------ Location Service Start -------------------- Functions.startLocationService(ctx); //------------ Measure kb downloaded ---------------- uid = this.getApplicationInfo().uid; mStartRX = TrafficStats.getUidRxBytes(uid); mStartTX = TrafficStats.getUidTxBytes(uid); //------------ Menu hard or soft key ------------------ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { boolean hasMenuKey = ViewConfiguration.get(ctx).hasPermanentMenuKey(); ActionBar actionBar = getActionBar(); if (!hasMenuKey) { actionBar.show(); } else { actionBar.hide(); } } //------------------ Temperature ----------------------------------- mReceiver_Temperature = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0); if (temperature > 450) { String mes = getString(R.string.tempwarn); int fullstopIndex = mes.indexOf("."); mes = mes.replace("XXXXX", Float.toString((((float) temperature) / 10)) + "\u2103"); String mesA = mes.substring(0, fullstopIndex); Toast.makeText(ctx, mesA, Toast.LENGTH_LONG).show(); String mesB = mes.substring(fullstopIndex + 2); Toast.makeText(ctx, mesB, Toast.LENGTH_LONG).show(); } } }; //--------------- Remove Transparency and Enable ------------------------------- intentFilter = new IntentFilter("android.intent.action.MAIN"); // DataCh mReceiverARFinished = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String ARFINISHED = intent.getStringExtra("ARFINISHED"); Integer ARDATAPLUSVal = intent.getIntExtra("DataPlus", 0); if (ARFINISHED != null) { Log.e("AR Finished", "ok 2"); if (pbarGeneral != null) pbarGeneral.setProgress(90); Message msg = new Message(); msg.arg1 = 2; handlerDialog.sendMessage(msg); } else if (ARDATAPLUSVal != 0) { if (pbarGeneral != null) { if (ARDATAPLUSVal > 90) ARDATAPLUSVal = 90; pbarGeneral.setProgress(ARDATAPLUSVal); } else { if (ARDATAPLUSVal < 15) { Message msg = new Message(); msg.arg1 = 1; handlerDialog.sendMessage(msg); } } } } }; registerReceiver(mReceiverARFinished, intentFilter); //----- Handler for Redrawing Markers from update thread ------------ handlerDialog = new Handler() { public void handleMessage(Message msg) { if (msg.arg1 == 1) { if (progressReceiving == null) { progressReceiving = ProgressDialog.show(ctx, "", "", true); progressReceiving.setContentView(R.layout.dialog_transparent_progress); pbarGeneral = (ProgressBar) progressReceiving.findViewById(R.id.allprogress); } } else { if (progressReceiving != null && progressReceiving.isShowing()) progressReceiving.dismiss(); progressReceiving = null; } super.handleMessage(msg); } }; if (Functions.checkInternetConnection(this) && Functions.hasNetLocationProviderEnabled(this) && Functions.hasGPSLocationProviderEnabled(this)) { // Show progress transparency Message msg = new Message(); msg.arg1 = 1; handlerDialog.sendMessage(msg); } }
From source file:blue.soundObject.pianoRoll.Scale.java
public Element saveAsXML() { Element retVal = new Element("scale"); retVal.addElement("scaleName").setText(scaleName); retVal.addElement("baseFrequency").setText(Float.toString(baseFrequency)); retVal.addElement("octave").setText(Float.toString(octave)); Element ratiosNode = retVal.addElement("ratios"); for (int i = 0; i < ratios.length; i++) { Element node = new Element("ratio").setText(Float.toString(ratios[i])); ratiosNode.addElement(node);/*w ww . ja v a2 s . c o m*/ } return retVal; }
From source file:fr.digitbooks.android.examples.chapitre08.RateDigitbooksActivity.java
private void rateDigitbooks() { final String comment = mEditText.getText().toString(); final float rate = mRatingBar.getRating(); if (!Helpers.isNetworkAvailable(this)) { Toast.makeText(this, getString(R.string.no_network), Toast.LENGTH_LONG).show(); } else {/*from w w w. j a v a2s.c o m*/ new RateTask().execute(comment, Float.toString(rate)); } }
From source file:com.acrutiapps.browser.ui.components.CustomWebView.java
@SuppressLint("SetJavaScriptEnabled") public void loadSettings() { WebSettings settings = getSettings(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); settings.setJavaScriptEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_JAVASCRIPT, true)); settings.setLoadsImagesAutomatically(prefs.getBoolean(Constants.PREFERENCE_ENABLE_IMAGES, true)); settings.setUseWideViewPort(prefs.getBoolean(Constants.PREFERENCE_USE_WIDE_VIEWPORT, true)); settings.setLoadWithOverviewMode(prefs.getBoolean(Constants.PREFERENCE_LOAD_WITH_OVERVIEW, false)); settings.setGeolocationEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_GEOLOCATION, true)); settings.setSaveFormData(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_FORM_DATA, true)); settings.setSavePassword(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_PASSWORDS, true)); settings.setTextZoom(prefs.getInt(Constants.PREFERENCE_TEXT_SCALING, 100)); int minimumFontSize = prefs.getInt(Constants.PREFERENCE_MINIMUM_FONT_SIZE, 1); settings.setMinimumFontSize(minimumFontSize); settings.setMinimumLogicalFontSize(minimumFontSize); boolean useInvertedDisplay = prefs.getBoolean(Constants.PREFERENCE_INVERTED_DISPLAY, false); setWebSettingsProperty(settings, "inverted", useInvertedDisplay ? "true" : "false"); if (useInvertedDisplay) { setWebSettingsProperty(settings, "inverted_contrast", Float.toString(prefs.getInt(Constants.PREFERENCE_INVERTED_DISPLAY_CONTRAST, 100) / 100f)); }//from w w w . j a va 2 s. c om settings.setUserAgentString(prefs.getString(Constants.PREFERENCE_USER_AGENT, Constants.USER_AGENT_ANDROID)); settings.setPluginState(PluginState .valueOf(prefs.getString(Constants.PREFERENCE_PLUGINS, PluginState.ON_DEMAND.toString()))); CookieManager.getInstance().setAcceptCookie(prefs.getBoolean(Constants.PREFERENCE_ACCEPT_COOKIES, true)); settings.setSupportZoom(true); settings.setDisplayZoomControls(false); settings.setBuiltInZoomControls(true); settings.setSupportMultipleWindows(true); settings.setEnableSmoothTransition(true); if (mPrivateBrowsing) { settings.setGeolocationEnabled(false); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setAppCacheEnabled(false); settings.setDatabaseEnabled(false); settings.setDomStorageEnabled(false); } else { // HTML5 API flags settings.setAppCacheEnabled(true); settings.setDatabaseEnabled(true); settings.setDomStorageEnabled(true); // HTML5 configuration settings. settings.setAppCacheMaxSize(3 * 1024 * 1024); settings.setAppCachePath(mContext.getDir("appcache", 0).getPath()); settings.setDatabasePath(mContext.getDir("databases", 0).getPath()); settings.setGeolocationDatabasePath(mContext.getDir("geolocation", 0).getPath()); } setLongClickable(true); setDownloadListener(this); }
From source file:uf.edu.encDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.encdetail_activity); context = this.getApplicationContext(); TextView tv = null;/*from www . j av a 2s . c om*/ SeekBar sb = null; Button b = null; Bundle bundle = this.getIntent().getExtras(); Log.i("TAG", "encDetailActivity:onCreate, Max Trust =" + getString(R.string.TrustSliderMax)); MaxTrust = Integer.parseInt(getString(R.string.TrustSliderMax)) / 2; final AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: //Okay clicked. break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; //builder.setMessage("Are you sure?").setPositiveButton("Okay", dialogClickListener); final EncUser encUser = (EncUser) bundle.getSerializable("userdata"); final ArrayList<String> Address = (ArrayList<String>) bundle.getSerializable("useraddress"); if (encUser == null) { Log.i(TAG, "encDetailsActivity: parameter received was null"); } //Name tv = (TextView) findViewById(R.id.encdetail_name); tv.setText(encUser.Name); //Mac tv = (TextView) findViewById(R.id.encdetail_mac); tv.setText(encUser.Mac); tv.setOnClickListener(new View.OnClickListener() { //event listener to fetch more info abt a user. @Override public void onClick(View v) { iTrust.cd.write("Registration Lookup requested for " + encUser.Mac); Toast.makeText(encDetailActivity.this, "Please wait while we lookup the information", Toast.LENGTH_LONG).show(); String data = getData(encUser.Mac).replace('\n', ' ').trim(); String message = null; if (data.substring(0, 5).compareToIgnoreCase("Error") == 0) { message = "No more info available for this device"; } else { data = data.replace('\'', ' '); //remove single quotes data = data.replace(')', ' ').trim(); //remove closing brackets. StringTokenizer tok = new StringTokenizer(data.substring(1), ","); message = "Name: " + tok.nextToken() + " " + tok.nextToken() + "\n" + "Email: " + tok.nextToken() + "\n" + "Profile: " + tok.nextToken(); } //Toast.makeText(encDetailActivity.this, getData(encUser.Mac), Toast.LENGTH_LONG).show(); builder.setMessage(message); builder.show(); } }); //lasttime tv = (TextView) findViewById(R.id.encdetail_lasttime); tv.setText((new java.util.Date((long) encUser.lastEncounterTime * 1000)).toString()); tv.setOnClickListener(new View.OnClickListener() { //To generate graph @Override public void onClick(View v) { Intent intent = barchartIntent(encUser.timeSeries, encUser.Mac, encUser.Name); startActivity(intent); } }); //tv.setText(Integer.toString(encUser.lastEncounterTime)); //FE tv = (TextView) findViewById(R.id.encdetail_FE); tv.setText(Float.toString(encUser.score[0])); tv = (TextView) findViewById(R.id.encdetail_decayFE); tv.setText(Float.toString(encUser.decayScore[0] * ((float) Math.pow(.5, (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime) / (float) 15552000.0F)))); //DE tv = (TextView) findViewById(R.id.encdetail_DE); tv.setText(Float.toString(encUser.score[1])); tv = (TextView) findViewById(R.id.encdetail_decayDE); tv.setText(Float.toString(encUser.decayScore[1] * ((float) Math.pow(.5, (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime) / (float) 15552000.0F)))); //LV-C tv = (TextView) findViewById(R.id.encdetail_LVC); tv.setText(Float.toString(encUser.score[2])); //LV-D tv = (TextView) findViewById(R.id.encdetail_LVD); tv.setText(Float.toString(encUser.score[3])); //combined //FE tv = (TextView) findViewById(R.id.encdetail_comb); tv.setText(Float.toString(encUser.score[4])); //check the toggle button state sb = (SeekBar) findViewById(R.id.encdetail_trust); //since Seekbar cannot go into -ve values we scale -Max Value to Max Value sb.setProgress(encUser.trusted + MaxTrust); tv = (TextView) findViewById(R.id.CurrentTrustValue); tv.setText(TrustArray[encUser.trusted + MaxTrust]); sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { TextView tvcurrent = (TextView) findViewById(R.id.CurrentTrustValue); @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser == true) { Log.i(TAG, "encDetailsActivity: User changed value for Trust to " + progress); encUser.trusted = progress - MaxTrust; tvcurrent.setText(TrustArray[progress]); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }); b = (Button) findViewById(R.id.encdetail_done); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { iTrust.cd.write("Trust Value changed for this user :" + encUser.Mac + " to:" + encUser.trusted); Bundle bundle = new Bundle(); Intent returnIntent = new Intent(); bundle.putSerializable("Object", encUser); returnIntent.putExtras(bundle); //returnIntent.putExtra("TrustSet",trustResult); encDetailActivity.this.setResult(Activity.RESULT_OK, returnIntent); finish(); } }); //show map tv = (TextView) findViewById(R.id.encdetail_map); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { iTrust.cd.write("Map lookup for encounter user " + encUser.Mac); Bundle bundle = new Bundle(); Intent newIntent = new Intent(context, map.class); bundle.putSerializable("useraddress", Address); newIntent.putExtras(bundle); startActivity(newIntent); } }); }
From source file:com.rabbitmq.examples.PerfTest.java
private static float floatArg(CommandLine cmd, char opt, float def) { return Float.parseFloat(cmd.getOptionValue(opt, Float.toString(def))); }
From source file:alaindc.crowdroid.SensorsIntentService.java
public void stub_onSensorChanged(int typeSensor) { if (typeSensor < 0) return;/*from w ww . j av a 2 s. c o m*/ float value, minf, maxf; switch (typeSensor) { case Sensor.TYPE_AMBIENT_TEMPERATURE: minf = -20; maxf = 42; break; case Sensor.TYPE_PRESSURE: // https://it.wikipedia.org/wiki/Pressione_atmosferica minf = 870; maxf = 1085; break; case Sensor.TYPE_RELATIVE_HUMIDITY: minf = 30; maxf = 100; break; default: minf = 0; maxf = 0; break; } value = random.nextFloat() * (maxf - minf) + minf; int index = Constants.getIndexAlarmForSensor(typeSensor); SharedPreferences sharedPref = getApplicationContext().getSharedPreferences(Constants.PREF_FILE, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putString(Constants.PREF_SENSOR_ + typeSensor, Float.toString(value)); editor.commit(); // Update view Intent senseintent = new Intent(Constants.INTENT_UPDATE_SENSORS); senseintent.putExtra(Constants.INTENT_RECEIVED_DATA_EXTRA_DATA, "Sensor " + Constants.getNameOfSensor(typeSensor) + " value: " + Float.toString(value)); LocalBroadcastManager.getInstance(this).sendBroadcast(senseintent); // Set the alarm random alarmMgr = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); Intent intentAlarm = new Intent(getApplicationContext(), SensorsIntentService.class); intentAlarm.setAction(Constants.INTENT_STUB_SENSOR_CHANGED + typeSensor); intentAlarm.putExtra(Constants.INTENT_STUB_SENSOR_CHANGED_TYPE, typeSensor); alarmIntent = PendingIntent.getService(getApplicationContext(), 0, intentAlarm, 0); // TODO Set timeout time from server indications int seconds = random.nextInt(50) + 10; // 10/60 sec alarmMgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + seconds * 1000, alarmIntent); }
From source file:net.hgw4.testapp.HGWTest.java
public void getDataFromSerial() { testAleLogger.info("------------------ Serial Temp Sensor ------------------------"); curDataTempSerialSens = curHal.pollSensor("0003", "0001"); try {/*from w w w . j a v a 2 s. c o m*/ if (curDataTempSerialSens != null) { testAleLogger.info("sensor:0003"); testAleLogger.info("endpoint:0001"); testAleLogger.info("msgid:" + curDataTempSerialSens.getString("msgid")); testAleLogger.info("timestamp:" + curDataTempSerialSens.getString("timestamp")); String value = curDataTempSerialSens.getString("data"); if (value.equalsIgnoreCase("noData")) { testAleLogger.info("data:" + curDataTempSerialSens.getString("data")); } else { float curTemp = (float) 0.00; int i00 = Integer.valueOf(value, 16).intValue(); curTemp = (float) i00; float curTempValue = (float) 0.00; //curTempValue = (float) ((float) -0.08 * curTemp + 68.0); curTempValue = (float) ((float) -0.08 * curTemp + 66.7); testAleLogger.info("data:" + Float.toString(Math.abs(curTempValue))); } } else { testAleLogger.info("---> no data from real serial temp sens <---"); } } catch (JSONException ex) { testAleLogger.error(ex); } System.out.println(curDataTempSerialSens.toString()); }