List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:org.jts.eclipse.conversion.cjsidl.ConversionUtil.java
/** * Used to fill a gap where a maximum value isn't specified in a range. * @param val - the current value, if there is one. * @param inputType - the input data type that the maximum should fit within * //from w ww.ja va 2s. c om * @return - the original value if it exists, or the maximum value allowed within * the inputType specified. */ public static String getCountMax(String val, String inputType) { String result = val; if (result == null || result.isEmpty()) { if (inputType.equals("byte") || inputType.equals("int8")) { result = Byte.toString(Byte.MAX_VALUE); } else if (inputType.equals("short integer") || inputType.equals("int16")) { result = Short.toString(Short.MAX_VALUE); } else if (inputType.equals("integer") || inputType.equals("int32")) { result = Integer.toString(Integer.MAX_VALUE); } else if (inputType.equals("long integer") || inputType.equals("int64")) { result = Long.toString(Long.MAX_VALUE); } else if (inputType.equals("unsigned byte") || inputType.equals("uint8")) { result = Short.toString((short) (Byte.MAX_VALUE * 2 + 1)); } else if (inputType.equals("unsigned short integer") || inputType.equals("uint16")) { result = Integer.toString((int) (Short.MAX_VALUE * 2 + 1)); } else if (inputType.equals("unsigned integer") || inputType.equals("uint32")) { result = Long.toString((long) (Integer.MAX_VALUE * 2 + 1)); } else if (inputType.equals("unsigned long integer") || inputType.equals("uint64")) { result = "18446744073709551615"; } else if (inputType.equals("float") || inputType.equals("float")) { result = Float.toString(Float.MAX_VALUE); } else if (inputType.equals("long float") || inputType.equals("double")) { result = Double.toString(Double.MAX_VALUE); } } return result; }
From source file:dk.dma.epd.common.prototype.settings.AisSettings.java
/** * Updates the the given {@code props} properties with the the AIS-specific settings * //from w w w .j a v a 2 s . c o m * @param props * the properties to update */ public void setProperties(Properties props) { props.put(PREFIX + "visible", Boolean.toString(visible)); props.put(PREFIX + "strict", Boolean.toString(strict)); props.put(PREFIX + "minRedrawInterval", Integer.toString(minRedrawInterval)); props.put(PREFIX + "allowSending", Boolean.toString(allowSending)); props.put(PREFIX + "sartPrefix", Integer.toString(sartPrefix)); props.put(PREFIX + "simulatedSartMmsi", StringUtils.defaultString(StringUtils.join(simulatedSartMmsi, ","))); props.put(PREFIX + "showNameLabels", Boolean.toString(showNameLabels)); props.put(PREFIX + "pastTrackMaxTime", Integer.toString(pastTrackMaxTime)); props.put(PREFIX + "pastTrackDisplayTime", Integer.toString(pastTrackDisplayTime)); props.put(PREFIX + "pastTrackMinDist", Integer.toString(pastTrackMinDist)); props.put(PREFIX + "pastTrackOwnShipMinDist", Integer.toString(pastTrackOwnShipMinDist)); props.put(PREFIX + this.varNameCogVectorLengthMin, Integer.toString(this.cogVectorLengthMin)); props.put(PREFIX + this.varNameCogVectorLengthMax, Integer.toString(this.cogVectorLengthMax)); props.put(PREFIX + this.varNameCogVectorLengthScaleInterval, Float.toString(this.cogVectorLengthScaleInterval)); props.put(PREFIX + this.varNameCogVectorHideBelow, Float.toString(this.cogVectorHideBelow)); }
From source file:org.apache.jackrabbit.core.persistence.mem.InMemBundlePersistenceManager.java
public String getLoadFactor() { return Float.toString(loadFactor); }
From source file:net.myrrix.online.eval.AbstractEvaluator.java
private Multimap<Long, RecommendedItem> split(File dataDir, File trainingFile, double trainPercentage, double evaluationPercentage, RescorerProvider provider) throws IOException { DataFileContents dataFileContents = readDataFile(dataDir, evaluationPercentage, provider); Multimap<Long, RecommendedItem> data = dataFileContents.getData(); log.info("Read data for {} users from input; splitting...", data.size()); Multimap<Long, RecommendedItem> testData = ArrayListMultimap.create(); Writer trainingOut = IOUtils.buildGZIPWriter(trainingFile); try {//from w w w . j a v a2s. c o m Iterator<Map.Entry<Long, Collection<RecommendedItem>>> it = data.asMap().entrySet().iterator(); while (it.hasNext()) { Map.Entry<Long, Collection<RecommendedItem>> entry = it.next(); long userID = entry.getKey(); List<RecommendedItem> userPrefs = Lists.newArrayList(entry.getValue()); it.remove(); if (isSplitTestByPrefValue()) { // Sort low to high, leaving high values at end for testing as "relevant" items Collections.sort(userPrefs, ByValueAscComparator.INSTANCE); } // else leave sorted in time order int numTraining = FastMath.max(1, (int) (trainPercentage * userPrefs.size())); for (RecommendedItem rec : userPrefs.subList(0, numTraining)) { trainingOut.write(Long.toString(userID)); trainingOut.write(DELIMITER); trainingOut.write(Long.toString(rec.getItemID())); trainingOut.write(DELIMITER); trainingOut.write(Float.toString(rec.getValue())); trainingOut.write('\n'); } for (RecommendedItem rec : userPrefs.subList(numTraining, userPrefs.size())) { testData.put(userID, rec); } } // All tags go in training data for (Map.Entry<String, RecommendedItem> entry : dataFileContents.getItemTags().entries()) { trainingOut.write(entry.getKey()); trainingOut.write(DELIMITER); trainingOut.write(Long.toString(entry.getValue().getItemID())); trainingOut.write(DELIMITER); trainingOut.write(Float.toString(entry.getValue().getValue())); trainingOut.write('\n'); } for (Map.Entry<String, RecommendedItem> entry : dataFileContents.getUserTags().entries()) { trainingOut.write(Long.toString(entry.getValue().getItemID())); trainingOut.write(DELIMITER); trainingOut.write(entry.getKey()); trainingOut.write(DELIMITER); trainingOut.write(Float.toString(entry.getValue().getValue())); trainingOut.write('\n'); } } finally { trainingOut.close(); // Want to know of output stream close failed -- maybe failed to write } log.info("{} users in test data", testData.size()); return testData; }
From source file:de.uni_weimar.m18.anatomiederstadt.element.LocationFragment.java
private void handleNewLocation(Location location) { Log.d(LOG_TAG, "Handling location: " + location.toString()); //double currentLatitude = location.getLatitude(); //double currentLongitude = location.getLongitude(); Location target = new Location("target"); target.setLatitude(Double.parseDouble(mLatitude)); target.setLongitude(Double.parseDouble(mLongitude)); float distance = target.distanceTo(location); Log.d(LOG_TAG, "Distance to target is approximately " + Float.toString(distance) + "meters"); if (distance > 25.0f) { if (mInfoText != null) { String distanceFormat = new DecimalFormat("#").format(distance); mInfoText.setText("Du bist noch ca " + distanceFormat + "m entfernt."); mInfoText.setVisibility(View.VISIBLE); }/*from w w w . j av a2s.c o m*/ } else { // we are in proximity, call action to advance mListener.inProximityAction(mTargetId); } }
From source file:sundroid.code.SundroidActivity.java
/** Called when the activity is first created. ***/ @Override/*from w w w.ja v a2 s . c o m*/ public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); this.chk_usecelsius = (CheckBox) findViewById(R.id.chk_usecelsius); Button cmd_submit = (Button) findViewById(R.id.cmd_submit); cmd_submit.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { try { ///////////////// Code to get weather conditions for entered place /////////////////////////////////////////////////// String cityParamString = ((EditText) findViewById(R.id.edit_input)).getText().toString(); String queryString = "https://www.google.com/ig/api?weather=" + cityParamString; queryString = queryString.replace("#", ""); /* Parsing the xml file*/ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); GoogleWeatherHandler gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(queryString.replace(" ", "%20")); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); ByteArrayInputStream is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); Log.d("Sundroid", "parse complete"); WeatherSet ws = gwh.getWeatherSet(); newupdateWeatherInfoView(R.id.weather_today, ws.getWeatherCurrentCondition(), " " + cityParamString, ""); ///////////////// Code to get weather conditions for entered place ends /////////////////////////////////////////////////// ///////////////// Code to get latitude and longitude using zipcode starts /////////////////////////////////////////////////// String latlng_querystring = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + cityParamString.replace(" ", "%20") + "&sensor=false"; URL url_latlng = new URL(latlng_querystring); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); xr = sp.getXMLReader(); xmlhandler_latlong xll = new xmlhandler_latlong(); xr.setContentHandler(xll); xr.parse(new InputSource(url_latlng.openStream())); Latitude_longitude ll = xll.getLatlng_resultset(); double selectedLat = ll.getLat_lng_pair().getLat(); double selectedLng = ll.getLat_lng_pair().getLon(); ///////////////// Code to get latitude and longitude using zipcode ends /////////////////////////////////////////////////// ///////////////// Code to get miles from text box & convert to meters for passing into the api link//////////////////////// EditText edt = (EditText) findViewById(R.id.edit_miles); float miles = Float.valueOf(edt.getText().toString()); float meters = (float) (miles * 1609.344); ///////////////// Code to get miles from text box & convert to meters for passing into the api link ends ///////////////// ///////////////// Code to pass lat,long and radius and get destinations from places api starts////////// ///////////////// URL queryString_1 = new URL("https://maps.googleapis.com/maps/api/place/search/xml?location=" + Double.toString(selectedLat) + "," + Double.toString(selectedLng) + "&radius=" + Float.toString(meters) + "&types=park|types=aquarium|types=point_of_interest|types=establishment|types=museum&sensor=false&key=AIzaSyDmP0SB1SDMkAJ1ebxowsOjpAyeyiwHKQU"); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); xr = sp.getXMLReader(); xmlhandler_places xhp = new xmlhandler_places(); xr.setContentHandler(xhp); xr.parse(new InputSource(queryString_1.openStream())); int arraysize = xhp.getVicinity_List().size(); String[] place = new String[25]; String[] place_name = new String[25]; Double[] lat_pt = new Double[25]; Double[] lng_pt = new Double[25]; int i; //Getting name and vicinity tags from the xml file// for (i = 0; i < arraysize; i++) { place[i] = xhp.getVicinity_List().get(i); place_name[i] = xhp.getPlacename_List().get(i); lat_pt[i] = xhp.getLatlist().get(i); lng_pt[i] = xhp.getLonglist().get(i); System.out.println("long -" + lng_pt[i]); place[i] = place[i].replace("#", ""); } ///////////////// Code to pass lat,long and radius and get destinations from places api ends////////// ///////////////// //////////////////////while loop for getting top 5 from the array//////////////////////////////////////////////// int count = 0; int while_ctr = 0; String str_weathercondition; str_weathercondition = ""; WeatherCurrentCondition reftemp; //Places to visit if none of places in the given radius are sunny/clear/partly cloudy String[] rainy_place = { "Indoor Mall", "Watch a Movie", "Go to a Restaurant", "Shopping!" }; double theDistance = 0; String str_dist = ""; while (count < 5) { //Checking if xml vicinity value is empty while (place[while_ctr] == null || place[while_ctr].length() < 2) { while_ctr = while_ctr + 1; } //First search for places that are sunny or clear if (while_ctr < i - 1) { queryString = "https://www.google.com/ig/api?weather=" + place[while_ctr]; System.out.println("In while loop - " + queryString); theDistance = (Math.sin(Math.toRadians(selectedLat)) * Math.sin(Math.toRadians(lat_pt[while_ctr])) + Math.cos(Math.toRadians(selectedLat)) * Math.cos(Math.toRadians(lat_pt[while_ctr])) * Math.cos(Math.toRadians(selectedLng - lng_pt[while_ctr]))); str_dist = new Double((Math.toDegrees(Math.acos(theDistance))) * 69.09).intValue() + " miles"; System.out.println(str_dist); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); xr = sp.getXMLReader(); gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); httpclient = new DefaultHttpClient(); httpget = new HttpGet(queryString.replace(" ", "%20")); responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); if (gwh.isIn_error_information()) { System.out.println("Error Info flag set"); } else { ws = gwh.getWeatherSet(); reftemp = ws.getWeatherCurrentCondition(); str_weathercondition = reftemp.getCondition(); // Check if the condition is sunny or partly cloudy if (str_weathercondition.equals("Sunny") || str_weathercondition.equals("Mostly Sunny") || str_weathercondition.equals("Clear")) { System.out.println("Sunny Loop"); // Increment the count ++count; // Disply the place on the widget if (count == 1) { newupdateWeatherInfoView(R.id.weather_1, reftemp, place_name[while_ctr], str_dist); } else if (count == 2) { newupdateWeatherInfoView(R.id.weather_2, reftemp, place_name[while_ctr], str_dist); } else if (count == 3) { newupdateWeatherInfoView(R.id.weather_3, reftemp, place_name[while_ctr], str_dist); } else if (count == 4) { newupdateWeatherInfoView(R.id.weather_4, reftemp, place_name[while_ctr], str_dist); } else if (count == 5) { newupdateWeatherInfoView(R.id.weather_5, reftemp, place_name[while_ctr], str_dist); } else { } } } } // If Five sunny places not found then search for partly cloudy places else if (while_ctr >= i && while_ctr < i * 2) { queryString = "https://www.google.com/ig/api?weather=" + place[while_ctr - i]; queryString = queryString.replace(" ", " "); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); // Get the XMLReader of the SAXParser we created. xr = sp.getXMLReader(); gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); // Use HTTPClient to deal with the URL httpclient = new DefaultHttpClient(); httpget = new HttpGet(queryString.replace(" ", "%20")); responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); Log.d(DEBUG_TAG, "parse complete"); if (gwh.isIn_error_information()) { } else { ws = gwh.getWeatherSet(); reftemp = ws.getWeatherCurrentCondition(); str_weathercondition = reftemp.getCondition(); // Check if the condition is sunny or partly cloudy if (str_weathercondition.equals("Partly Cloudy")) { count = count + 1; // Display the place if (count == 1) { newupdateWeatherInfoView(R.id.weather_1, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 2) { newupdateWeatherInfoView(R.id.weather_2, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 3) { newupdateWeatherInfoView(R.id.weather_3, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 4) { newupdateWeatherInfoView(R.id.weather_4, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 5) { newupdateWeatherInfoView(R.id.weather_5, reftemp, place_name[while_ctr - i], str_dist); } else { } } } } //////////////////////////////// Give suggestions for a rainy day else { queryString = "https://www.google.com/ig/api?weather=" + cityParamString; queryString = queryString.replace("#", ""); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); // Get the XMLReader of the SAXParser we created. xr = sp.getXMLReader(); gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); httpclient = new DefaultHttpClient(); httpget = new HttpGet(queryString.replace(" ", "%20")); // create a response handler responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); if (gwh.isIn_error_information()) { } else { ws = gwh.getWeatherSet(); reftemp = ws.getWeatherCurrentCondition(); str_weathercondition = reftemp.getCondition(); if (count == 0) { newupdateWeatherInfoView(R.id.weather_1, reftemp, rainy_place[0], ""); newupdateWeatherInfoView(R.id.weather_2, reftemp, rainy_place[1], ""); newupdateWeatherInfoView(R.id.weather_3, reftemp, rainy_place[2], ""); newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[3], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else if (count == 1) { newupdateWeatherInfoView(R.id.weather_2, reftemp, rainy_place[1], ""); newupdateWeatherInfoView(R.id.weather_3, reftemp, rainy_place[2], ""); newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[3], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[0], ""); } else if (count == 2) { newupdateWeatherInfoView(R.id.weather_3, reftemp, rainy_place[2], ""); newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[0], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else if (count == 3) { newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[0], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else if (count == 4) { newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else { } count = 5; } count = 5; } while_ctr++; } /////////////Closing the soft keypad//////////////// InputMethodManager iMethodMgr = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); iMethodMgr.hideSoftInputFromWindow(edt.getWindowToken(), 0); } catch (Exception e) { resetWeatherInfoViews(); Log.e(DEBUG_TAG, "WeatherQueryError", e); } } }); }
From source file:com.lauszus.dronedraw.DroneDrawActivity.java
private void uploadCsvFile() { if (!mDrawView.mFullPath.isEmpty()) { File csvFileLocation = new File(getFilesDir(), "path.csv"); try {//from www. j a va 2 s .c om CSVWriter writer = new CSVWriter(new FileWriter(csvFileLocation), ',', CSVWriter.NO_QUOTE_CHARACTER); final int dataSize = 10 * mDrawView.touchCounter; // Sample path 10 times more than actual touches for (int i = 0; i <= dataSize; i++) { PathMeasure mPathMeasure = new PathMeasure(mDrawView.mFullPath, false); final float t = (float) i / (float) dataSize; float[] xy = new float[2]; mPathMeasure.getPosTan(mPathMeasure.getLength() * t, xy, null); // Normalize coordinates based on maximum dimension final float maxDimension = Math.max(mDrawView.getWidth(), mDrawView.getHeight()); final float x = xy[0] / maxDimension; final float y = (mDrawView.getHeight() - xy[1]) / maxDimension; // Make y-axis point upward writer.writeNext(new String[] { Integer.toString(i), Float.toString(x), Float.toString(y) }); //if (D) Log.d(TAG, "t: " + t + " x: " + x + " y: " + y); } writer.close(); //sendEmail(csvFileLocation); uploadFileToDropbox(csvFileLocation); } catch (IOException e) { e.printStackTrace(); } } }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device battery level. *///from ww w . j av a 2s . c o m static String getBatteryLevel(Context context) { try { Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); // Error checking that probably isn't needed but I added just in case. if (level > -1 && scale > 0) { return Float.toString(((float) level / (float) scale) * 100.0f); } } catch (Exception e) { if (Countly.sharedInstance().isLoggingEnabled()) { Log.i(Countly.TAG, "Can't get batter level"); } } return null; }
From source file:PictureScaler.java
/** * Render all scaled versions 10 times, timing each version and * reporting the results below the appropriate scaled image. *///ww w. j av a2 s .com protected void paintComponent(Graphics g) { // Scale with NEAREST_NEIGHBOR int xLoc = PADDING, yLoc = PADDING; long startTime, endTime; float totalTime; int iterations = 10; ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); startTime = System.nanoTime(); for (int i = 0; i < iterations; ++i) { g.drawImage(picture, xLoc, yLoc, scaleW, scaleH, null); } endTime = System.nanoTime(); totalTime = (float) ((endTime - startTime) / 1000000) / iterations; g.drawString("NEAREST ", xLoc, yLoc + scaleH + PADDING); g.drawString(Float.toString(totalTime) + " ms", xLoc, yLoc + scaleH + PADDING + 10); System.out.println("NEAREST: " + ((endTime - startTime) / 1000000)); // Scale with BILINEAR xLoc += scaleW + PADDING; ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); startTime = System.nanoTime(); for (int i = 0; i < iterations; ++i) { g.drawImage(picture, xLoc, yLoc, scaleW, scaleH, null); } endTime = System.nanoTime(); totalTime = (float) ((endTime - startTime) / 1000000) / iterations; g.drawString("BILINEAR", xLoc, yLoc + scaleH + PADDING); g.drawString(Float.toString(totalTime) + " ms", xLoc, yLoc + scaleH + PADDING + 10); System.out.println("BILINEAR: " + ((endTime - startTime) / 1000000)); // Scale with BICUBIC xLoc += scaleW + PADDING; ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); startTime = System.nanoTime(); for (int i = 0; i < iterations; ++i) { g.drawImage(picture, xLoc, yLoc, scaleW, scaleH, null); } endTime = System.nanoTime(); totalTime = (float) ((endTime - startTime) / 1000000) / iterations; g.drawString("BICUBIC", xLoc, yLoc + scaleH + PADDING); g.drawString(Float.toString(totalTime) + " ms", xLoc, yLoc + scaleH + PADDING + 10); System.out.println("BICUBIC: " + ((endTime - startTime) / 1000000)); // Scale with getScaledInstance xLoc += scaleW + PADDING; startTime = System.nanoTime(); for (int i = 0; i < iterations; ++i) { Image scaledPicture = picture.getScaledInstance(scaleW, scaleH, Image.SCALE_AREA_AVERAGING); g.drawImage(scaledPicture, xLoc, yLoc, null); } endTime = System.nanoTime(); totalTime = (float) ((endTime - startTime) / 1000000) / iterations; g.drawString("getScaled", xLoc, yLoc + scaleH + PADDING); g.drawString(Float.toString(totalTime) + " ms", xLoc, yLoc + scaleH + PADDING + 10); System.out.println("getScaled: " + ((endTime - startTime) / 1000000)); // Scale with Progressive Bilinear xLoc += scaleW + PADDING; startTime = System.nanoTime(); for (int i = 0; i < iterations; ++i) { Image scaledPicture = getFasterScaledInstance(picture, scaleW, scaleH, RenderingHints.VALUE_INTERPOLATION_BILINEAR, true); g.drawImage(scaledPicture, xLoc, yLoc, null); } endTime = System.nanoTime(); totalTime = (float) ((endTime - startTime) / 1000000) / iterations; g.drawString("Progressive", xLoc, yLoc + scaleH + PADDING); g.drawString(Float.toString(totalTime) + " ms", xLoc, yLoc + scaleH + PADDING + 10); System.out.println("Progressive: " + ((endTime - startTime) / 1000000)); }
From source file:com.moviejukebox.plugin.MovieListingPluginCustomCsv.java
/** * @param sItemType// www . j a va 2 s . c o m * @param movie * @return output string properly formatted for CSV output */ @SuppressWarnings("deprecation") private String toCSV(String sItemType, Movie movie) { Collection<ExtraFile> extras = movie.getExtraFiles(); Collection<MovieFile> movieFiles = movie.getMovieFiles(); Collection<String> genres = movie.getGenres(); Collection<String> cast = movie.getCast(); StringBuilder sb = new StringBuilder(); for (String header : mFields) { if (sb.length() > 0) { sb.append(mDelimiter); } if (checkHeaderField(header, "Type")) { sb.append(prep(sItemType)); } else if (checkHeaderField(header, "Title")) { sb.append(prep(movie.getTitle())); } else if (checkHeaderField(header, "TitleSort")) { sb.append(prep(movie.getTitleSort())); } else if (checkHeaderField(header, "OriginalTitle")) { sb.append(prep(movie.getOriginalTitle())); } else if (checkHeaderField(header, "IMDB ID")) { sb.append(prep(movie.getId(ImdbPlugin.IMDB_PLUGIN_ID))); } else if (checkHeaderField(header, "TheTVDB ID")) { sb.append(prep(movie.getId(TheTvDBPlugin.THETVDB_PLUGIN_ID))); } else if (checkHeaderField(header, "Director")) { sb.append(prep(movie.getDirector())); } else if (checkHeaderField(header, "Company")) { sb.append(prep(movie.getCompany())); } else if (checkHeaderField(header, "Country")) { sb.append(prep(movie.getCountriesAsString())); } else if (checkHeaderField(header, "Language")) { sb.append(prep(movie.getLanguage())); } else if (checkHeaderField(header, "Runtime")) { sb.append(prep(movie.getRuntime())); } else if (checkHeaderField(header, "Release Date")) { sb.append(prep(movie.getReleaseDate())); } else if (checkHeaderField(header, "Year")) { sb.append(prep(movie.getYear())); } else if (checkHeaderField(header, "Certification")) { sb.append(prep(movie.getCertification())); } else if (checkHeaderField(header, "Season #")) { sb.append(prep(blankNegatives(movie.getSeason()))); } else if (checkHeaderField(header, "VideoSource")) { sb.append(prep(movie.getVideoSource())); } else if (checkHeaderField(header, "Container")) { sb.append(prep(movie.getContainer())); } else if (checkHeaderField(header, "File")) { sb.append(prep(movie.getContainerFile().getAbsolutePath())); } else if (checkHeaderField(header, "Audio Codec")) { sb.append(prep(movie.getAudioCodec())); } else if (checkHeaderField(header, "Audio Channels")) { sb.append(prep(movie.getAudioChannels())); } else if (checkHeaderField(header, "Resolution")) { sb.append(prep(movie.getResolution())); } else if (checkHeaderField(header, "Video Codec")) { sb.append(prep(movie.getVideoCodec())); } else if (checkHeaderField(header, "Video Output")) { sb.append(prep(movie.getVideoOutput())); } else if (checkHeaderField(header, "FPS")) { sb.append(prep(Float.toString(movie.getFps()))); } else if (checkHeaderField(header, "# Files")) { sb.append(prep(String.valueOf(null == movieFiles ? "0" : movieFiles.size()))); } else if (checkHeaderField(header, "# Extras")) { sb.append(prep(String.valueOf(null == extras ? "0" : extras.size()))); } else if (checkHeaderField(header, "# Genres")) { sb.append(prep(String.valueOf(null == genres ? "0" : genres.size()))); } else if (checkHeaderField(header, "# Cast")) { sb.append(prep(String.valueOf(null == cast ? "0" : cast.size()))); } else if (checkHeaderField(header, "SubTitles?")) { sb.append(prep(movie.getSubtitles())); } else if (checkHeaderField(header, "Poster?")) { sb.append(prep( String.valueOf(StringTools.isValidString(movie.getPosterFilename()) ? "True" : "False"))); } else if (checkHeaderField(header, "Poster Filename")) { sb.append(prep(movie.getPosterFilename())); } else if (checkHeaderField(header, "Fanart?")) { sb.append(prep( String.valueOf(StringTools.isValidString(movie.getFanartFilename()) ? "True" : "False"))); } else if (checkHeaderField(header, "Fanart Filename")) { sb.append(prep(movie.getFanartFilename())); } else if (checkHeaderField(header, "Rating #")) { if (mRatingFactor != null) { double fr = mRatingFactor * movie.getRating(); sb.append(prep(mRatingFormatter.format(fr))); } else { sb.append(prep(Integer.toString(movie.getRating()))); } } else if (checkHeaderField(header, "Top 250 #")) { sb.append(prep(Integer.toString(movie.getTop250()))); } else if (checkHeaderField(header, "Library Description")) { sb.append(prep(movie.getLibraryDescription())); } else if (checkHeaderField(header, "Library Path")) { sb.append(prep(movie.getLibraryPath())); } else if (checkHeaderField(header, "Allocine ID")) { sb.append(prep(movie.getId(AllocinePlugin.ALLOCINE_PLUGIN_ID))); } else if (checkHeaderField(header, "FilmUpIT ID")) { sb.append(prep(movie.getId(FilmUpITPlugin.FILMUPIT_PLUGIN_ID))); } else if (checkHeaderField(header, "FilmWeb ID")) { sb.append(prep(movie.getId(FilmwebPlugin.FILMWEB_PLUGIN_ID))); } else if (checkHeaderField(header, "Kinopoisk ID")) { sb.append(prep(movie.getId(KinopoiskPlugin.KINOPOISK_PLUGIN_ID))); } else if (checkHeaderField(header, "Animator ID")) { sb.append(prep(movie.getId(AnimatorPlugin.ANIMATOR_PLUGIN_ID))); } else if (checkHeaderField(header, "Sratim ID")) { sb.append(prep(movie.getId(SratimPlugin.SRATIM_PLUGIN_ID))); } else if (checkHeaderField(header, "Last Modified Date")) { if (mDateFormatter != null) { sb.append(prep(mDateFormatter.format(new Date(movie.getLastModifiedTimestamp())))); } else { sb.append(prep(new Timestamp(movie.getLastModifiedTimestamp()).toString())); } } else if (checkHeaderField(header, "File Size")) { sb.append(prep(movie.getFileSizeString())); } else if (checkHeaderField(header, "Genres")) { if (null != genres) { int counter = 1; StringBuilder tmp = new StringBuilder(); for (String string : genres) { if (counter++ > limitGenres) { break; } if (tmp.length() > 0) { tmp.append(mSecondDelimiter); } tmp.append(string); } sb.append(prep(tmp.toString())); } } else if (checkHeaderField(header, "Cast")) { if (null != cast) { int counter = 1; StringBuilder tmp = new StringBuilder(); for (String string : cast) { if (counter++ > limitCast) { break; } if (tmp.length() > 0) { tmp.append(mSecondDelimiter); } tmp.append(string); } sb.append(prep(tmp.toString())); } } else if (checkHeaderField(header, "Plot")) { sb.append(prep(movie.getPlot())); } else if (checkHeaderField(header, "Outline")) { sb.append(prep(movie.getOutline())); } else if (checkHeaderField(header, "Thumbnail Filename")) { sb.append(prep(movie.getThumbnailFilename())); } else if (checkHeaderField(header, "Detail Poster Filename")) { sb.append(prep(movie.getDetailPosterFilename())); } else if (checkHeaderField(header, "Watched")) { sb.append(prep(String.valueOf(movie.isWatched()))); } else { LOG.debug("Unknown field: '{}'", header); } } return sb.toString(); }