List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:com.wormsim.tracking.TrackedDouble.java
@Override public String toRecentBetweenVarianceString() { return Double.toString(this.getRecentBetweenVariance()); }
From source file:de.topobyte.livecg.core.painting.backend.svg.SvgPainter.java
@Override public void fillRect(double x, double y, double width, double height) { Element rectangle = doc.createElementNS(svgNS, "rect"); rectangle.setAttributeNS(null, "x", Double.toString(x)); rectangle.setAttributeNS(null, "y", Double.toString(y)); rectangle.setAttributeNS(null, "width", Double.toString(width)); rectangle.setAttributeNS(null, "height", Double.toString(height)); rectangle.setAttributeNS(null, "fill", getCurrentColor()); append(rectangle);//from ww w .j a v a2 s.co m }
From source file:net.sf.jasperreports.engine.data.JRAbstractTextDataSource.java
protected Object convertNumber(Number number, Class<?> valueClass) throws JRException { Number value = null;/* www. ja v a 2 s. c o m*/ if (valueClass.equals(Byte.class)) { value = number.byteValue(); } else if (valueClass.equals(Short.class)) { value = number.shortValue(); } else if (valueClass.equals(Integer.class)) { value = number.intValue(); } else if (valueClass.equals(Long.class)) { value = number.longValue(); } else if (valueClass.equals(Float.class)) { value = number.floatValue(); } else if (valueClass.equals(Double.class)) { value = number.doubleValue(); } else if (valueClass.equals(BigInteger.class)) { value = BigInteger.valueOf(number.longValue()); } else if (valueClass.equals(BigDecimal.class)) { value = new BigDecimal(Double.toString(number.doubleValue())); } else { throw new JRException(EXCEPTION_MESSAGE_KEY_UNKNOWN_NUMBER_TYPE, new Object[] { valueClass.getName() }); } return value; }
From source file:cycronix.cttraveler.CTtraveler.java
public CTtraveler(String[] arg) { long defaultDT = 100; // Concatenate all of the CTWriteMode types String possibleWriteModes = ""; for (CTWriteMode wm : CTWriteMode.values()) { possibleWriteModes = possibleWriteModes + ", " + wm.name(); }//ww w .j a va 2s . co m // Remove ", " from start of string possibleWriteModes = possibleWriteModes.substring(2); // // Argument processing using Apache Commons CLI // // 1. Setup command line options Options options = new Options(); options.addOption("h", "help", false, "Print this message."); options.addOption(Option.builder("o").argName("base output dir").hasArg().desc( "Base output directory when writing data to local folder (i.e., CTdata location); default = \"" + outLoc + "\".") .build()); options.addOption(Option.builder("s").argName("session name").hasArg() .desc("Session name to be prefixed to the source path; default = " + sessionName + ".").build()); options.addOption(Option.builder("d").argName("delta-Time").hasArg() .desc("Fixed delta-time (msec) between frames; default = " + Long.toString(defaultDT) + ".") .build()); options.addOption(Option.builder("f").argName("autoFlush").hasArg().desc( "Flush interval (sec); amount of data per zipfile; default = " + Double.toString(autoFlush) + ".") .build()); options.addOption(Option.builder("t").argName("trim-Time").hasArg().desc( "Trim (ring-buffer loop) time (sec); this is only used when writing data to local folder; specify 0 for indefinite; default = " + Double.toString(trimTime) + ".") .build()); options.addOption(Option.builder("bps").argName("blocks per seg").hasArg() .desc("Number of blocks per segment; specify 0 for no segments; default = " + Long.toString(blocksPerSegment) + ".") .build()); options.addOption(Option.builder("mc").argName("model color").hasArg().desc( "Color of the Unity model; must be one of: Red, Blue, Green, Yellow; default = " + modelColor + ".") .build()); options.addOption(Option.builder("mt").argName("model type").hasArg().desc( "Type of the Unity model; must be one of: Primplane, Ball, Biplane; default = " + modelType + ".") .build()); options.addOption( Option.builder("w").argName("write mode").hasArg().desc("Type of CT write connection; one of " + possibleWriteModes + "; default = " + writeMode.name() + ".").build()); options.addOption(Option.builder("host").argName("host[:port]").hasArg() .desc("Host:port when writing to CT via FTP, HTTP, HTTPS.").build()); options.addOption(Option.builder("u").argName("username,password").hasArg() .desc("Comma-delimited username and password when writing to CT via FTP, HTTP or HTTPS.").build()); options.addOption("x", "debug", false, "Enable CloudTurbine debug output."); // 2. Parse command line options CommandLineParser parser = new DefaultParser(); CommandLine line = null; try { line = parser.parse(options, arg); } catch (ParseException exp) { // oops, something went wrong System.err.println("Command line argument parsing failed: " + exp.getMessage()); return; } // 3. Retrieve the command line values if (line.hasOption("help")) { // Display help message and quit HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp("CTtraveler", options); return; } outLoc = line.getOptionValue("o", outLoc); if (!outLoc.endsWith("\\") && !outLoc.endsWith("/")) { outLoc = outLoc + File.separator; } // Make sure the base output folder location ends in "CTdata" if (!outLoc.endsWith("CTdata\\") && !outLoc.endsWith("CTdata/")) { outLoc = outLoc + "CTdata" + File.separator; } sessionName = line.getOptionValue("s", sessionName); if (sessionName.isEmpty()) { System.err.println("You must specify a Session name."); System.exit(0); } if (!sessionName.endsWith("\\") && !sessionName.endsWith("/")) { sessionName = sessionName + File.separator; } String sdt = line.getOptionValue("d", Long.toString(defaultDT)); long dt = Long.parseLong(sdt); autoFlush = Double.parseDouble(line.getOptionValue("f", "" + autoFlush)); if (autoFlush <= 0.0) { System.err.println("Auto flush must be a value greater than 0."); System.exit(0); } trimTime = Double.parseDouble(line.getOptionValue("t", Double.toString(trimTime))); blocksPerSegment = Long.parseLong(line.getOptionValue("bps", Long.toString(blocksPerSegment))); debug = line.hasOption("debug"); // Type of output connection String writeModeStr = line.getOptionValue("w", writeMode.name()); boolean bMatch = false; for (CTWriteMode wm : CTWriteMode.values()) { if (wm.name().toLowerCase().equals(writeModeStr.toLowerCase())) { writeMode = wm; bMatch = true; } } if (!bMatch) { System.err.println("Unrecognized write mode, \"" + writeModeStr + "\"; write mode must be one of " + possibleWriteModes); System.exit(0); } if (writeMode != CTWriteMode.LOCAL) { // User must have specified the host serverHost = line.getOptionValue("host", serverHost); if (serverHost.isEmpty()) { System.err.println( "When using write mode \"" + writeModeStr + "\", you must specify the server host."); System.exit(0); } } String userpassStr = line.getOptionValue("u", ""); if (!userpassStr.isEmpty()) { if (writeMode == CTWriteMode.LOCAL) { System.err.println("Username and password are not used when writing local CT files."); System.exit(0); } // This string should be comma-delimited username and password String[] userpassCSV = userpassStr.split(","); if (userpassCSV.length != 2) { System.err.println( "When specifying a username and password, separate the username and password by a comma."); System.exit(0); } serverUser = userpassCSV[0]; serverPassword = userpassCSV[1]; } if ((writeMode == CTWriteMode.HTTP) && (!serverUser.isEmpty())) { System.err.println( "Please note that the username and password are not encrypted when writing CT files via HTTP."); } // CT/Unity model parameters String modelColorRequest = line.getOptionValue("mc", modelColor); modelColor = ""; for (ModelColor mc : ModelColor.values()) { if (mc.name().toLowerCase().equals(modelColorRequest.toLowerCase())) { modelColor = mc.name(); } } if (modelColor.isEmpty()) { System.err.println( "Unrecognized model color, \"" + modelColorRequest + "\"; model color must be one of:"); for (ModelColor mc : ModelColor.values()) { System.err.println("\t" + mc.name()); } System.exit(0); } String modelTypeRequest = line.getOptionValue("mt", modelType); modelType = ""; for (ModelType mt : ModelType.values()) { if (mt.name().toLowerCase().equals(modelTypeRequest.toLowerCase())) { modelType = mt.name(); } } if (modelType.isEmpty()) { System.err.println("Unrecognized model type, \"" + modelTypeRequest + "\"; model type must be one of:"); for (ModelType mt : ModelType.values()) { System.err.println("\t" + mt.name()); } System.exit(0); } // // Create CTwriter (for writing data to CT format) // CTwriter ctw = null; System.err.println("Model: " + modelType); // If sessionName isn't blank, it will end in a file separator String srcName = sessionName + "GamePlay" + File.separator + playerName; System.err.println("Game source: " + srcName); System.err.println(" write out JSON data"); try { ctw = create_CT_source(srcName, true, zipMode); } catch (Exception e) { e.printStackTrace(); System.exit(0); } // Setup the data generator JsonGenerator jsonGenerator = new MouseDataGenerator(playerName, modelType); // Adjust sampInterval to keep the desired sample period long msec_adjust = 0; while (true) { long time_msec = System.currentTimeMillis(); // Generate updated data String unityStr = jsonGenerator.generateJson(time_msec); if ((unityStr != null) && (!unityStr.isEmpty())) { // Write to CT (note that we use auto-flush so there's no call to flush here) ctw.setTime(time_msec); try { ctw.putData("CTstates.json", unityStr); } catch (Exception e) { System.err.println("Exception putting data to CT:\n" + e); continue; } System.err.print("."); } // Automatically adjust sleep time (to try and maintain the desired delta-T) if (dt > 0) { if ((dt + msec_adjust) > 0) { try { Thread.sleep(dt + msec_adjust); } catch (Exception e) { } ; } long now_time_msec = System.currentTimeMillis(); if ((now_time_msec - time_msec) > (dt + 10)) { msec_adjust = msec_adjust - 1; } else if ((now_time_msec - time_msec) < (dt - 10)) { msec_adjust = msec_adjust + 1; } } } }
From source file:edu.wpi.first.wpilibj.templates.RobotTemplate.java
public void robotInit() { lcd.println(Line.kUser5, 1, "Robot Initialized"); lcd.println(Line.kUser4, 1, "Battery Voltage:"); lcd.println(Line.kUser3, 1, "Compensation Value:"); lcd.println(Line.kUser4, 17, Double.toString(robotBatteryVoltage)); lcd.println(Line.kUser3, 20, Double.toString(m)); lcd.updateLCD();//from www.j a va 2 s. co m //Hashtable<String, Double> autonParams = // autonParams = new Hashtable<String, Double>(); //autonParams.put("winchSpeed", ); }
From source file:com.clustercontrol.plugin.factory.ModifyDbmsScheduler.java
private void setEntityInfo(DbmsSchedulerEntity entity, JobDetail jobDetail, Trigger trigger) throws InvalidClassException { entity.setMisfireInstr(trigger.getMisfireInstruction()); entity.setDurable(jobDetail.isDurable()); entity.setJobClassName(jobDetail.getJobDataMap().getString(ReflectionInvokerJob.KEY_CLASS_NAME)); entity.setJobMethodName(jobDetail.getJobDataMap().getString(ReflectionInvokerJob.KEY_METHOD_NAME)); if (trigger instanceof CronTrigger) { entity.setTriggerType(SchedulerPlugin.TriggerType.CRON.name()); entity.setCronExpression(((CronTrigger) trigger).getCronExpression()); } else if (trigger instanceof SimpleTrigger) { entity.setTriggerType(SchedulerPlugin.TriggerType.SIMPLE.name()); entity.setRepeatInterval(((SimpleTrigger) trigger).getPeriod()); }/*from w ww . j av a 2s .c om*/ entity.setTriggerState(TriggerState.VIRGIN.name()); entity.setStartTime(trigger.getStartTime()); entity.setEndTime(trigger.getEndTime()); entity.setNextFireTime(trigger.getNextFireTime()); entity.setPrevFireTime(trigger.getPreviousFireTime()); @SuppressWarnings("unchecked") Class<? extends Serializable>[] argsType = (Class<? extends Serializable>[]) jobDetail.getJobDataMap() .get(ReflectionInvokerJob.KEY_ARGS_TYPE); Object[] args = (Object[]) jobDetail.getJobDataMap().get(ReflectionInvokerJob.KEY_ARGS); entity.setJobArgNum(args.length); for (int i = 0; i < args.length; i++) { String arg = ""; if (m_log.isDebugEnabled()) m_log.debug("arg[" + i + "]:" + args[i]); if (argsType[i] == String.class) { arg = (String) args[i]; } else if (argsType[i] == Boolean.class) { arg = Boolean.toString((Boolean) args[i]); } else if (argsType[i] == Integer.class) { arg = Integer.toString((Integer) args[i]); } else if (argsType[i] == Long.class) { arg = Long.toString((Long) args[i]); } else if (argsType[i] == Short.class) { arg = Short.toString((Short) args[i]); } else if (argsType[i] == Float.class) { arg = Float.toString((Float) args[i]); } else if (argsType[i] == Double.class) { arg = Double.toString((Double) args[i]); } else { m_log.error("not support class"); throw new InvalidClassException(argsType[i].getName()); } String typeArg = argsType[i].getSimpleName() + ":" + arg; if (arg == null) { typeArg = "nullString"; } if (m_log.isDebugEnabled()) m_log.debug("typeArg[" + i + "]:" + typeArg); switch (i) { case 0: entity.setJobArg00(typeArg); break; case 1: entity.setJobArg01(typeArg); break; case 2: entity.setJobArg02(typeArg); break; case 3: entity.setJobArg03(typeArg); break; case 4: entity.setJobArg04(typeArg); break; case 5: entity.setJobArg05(typeArg); break; case 6: entity.setJobArg06(typeArg); break; case 7: entity.setJobArg07(typeArg); break; case 8: entity.setJobArg08(typeArg); break; case 9: entity.setJobArg09(typeArg); break; case 10: entity.setJobArg10(typeArg); break; case 11: entity.setJobArg11(typeArg); break; case 12: entity.setJobArg12(typeArg); break; case 13: entity.setJobArg13(typeArg); break; case 14: entity.setJobArg14(typeArg); break; default: m_log.error("arg count ng."); } } }
From source file:de.kirchnerei.bicycle.battery.BatteryEditFragment.java
private void updateMileage(int mileage) { String value = Double.toString((double) mileage / 10); item.setLeftover(mileage);/*from ww w .jav a2 s .c o m*/ mMileage.setText(mileage != 0 ? value : ""); }
From source file:com.mutu.gpstracker.streaming.CustomUpload.java
@Override public void onReceive(Context context, Intent intent) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String prefUrl = preferences.getString(ApplicationPreferenceActivity.CUSTOMUPLOAD_URL, "http://www.example.com"); Integer prefBacklog = Integer.valueOf(preferences .getString(ApplicationPreferenceActivity.CUSTOMUPLOAD_BACKLOG, CUSTOMUPLOAD_BACKLOG_DEFAULT)); Location loc = intent.getParcelableExtra(Constants.EXTRA_LOCATION); Uri trackUri = intent.getParcelableExtra(Constants.EXTRA_TRACK); String buildUrl = prefUrl;//from ww w . ja va2s . c om buildUrl = buildUrl.replace("@LAT@", Double.toString(loc.getLatitude())); buildUrl = buildUrl.replace("@LON@", Double.toString(loc.getLongitude())); buildUrl = buildUrl.replace("@ID@", trackUri.getLastPathSegment()); buildUrl = buildUrl.replace("@TIME@", Long.toString(loc.getTime())); buildUrl = buildUrl.replace("@SPEED@", Float.toString(loc.getSpeed())); buildUrl = buildUrl.replace("@ACC@", Float.toString(loc.getAccuracy())); buildUrl = buildUrl.replace("@ALT@", Double.toString(loc.getAltitude())); buildUrl = buildUrl.replace("@BEAR@", Float.toString(loc.getBearing())); HttpClient client = new DefaultHttpClient(); URI uploadUri; try { uploadUri = new URI(buildUrl); HttpGet currentRequest = new HttpGet(uploadUri); sRequestBacklog.add(currentRequest); if (sRequestBacklog.size() > prefBacklog) { sRequestBacklog.poll(); } while (!sRequestBacklog.isEmpty()) { HttpGet request = sRequestBacklog.peek(); HttpResponse response = client.execute(request); sRequestBacklog.poll(); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { throw new IOException("Invalid response from server: " + status.toString()); } clearNotification(context); } } catch (URISyntaxException e) { notifyError(context, e); } catch (ClientProtocolException e) { notifyError(context, e); } catch (IOException e) { notifyError(context, e); } }
From source file:ml.shifu.shifu.core.binning.EqualPopulationBinningTest.java
/** * @return/*from ww w. jav a 2s .c o m*/ */ private EqualPopulationBinning createBinning() { Random rd = new Random(System.currentTimeMillis()); EqualPopulationBinning binning = new EqualPopulationBinning(20); for (int i = 0; i < 18000; i++) { binning.addData(Double.toString(rd.nextDouble() % 1000)); } return binning; }
From source file:com.munichtrading.tracking.camera.APIIPCamera.java
private void sendGet(String parameter, double value) { String string_val = Double.toString(value); this.sendGet(parameter, string_val); }