List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:com.whirlycott.cache.CacheDecorator.java
/** * Returns an efficiency report string for this cache. * // w w w . j ava 2s . co m * @return efficiency report for this cache. */ public String getEfficiencyReport() { final Object[] args = { new Integer(managedCache.size()), new Long(recordKeeper.getTotalOperations()), new Long(recordKeeper.getHits()), new Float(getAdaptiveRatio()), new Float(getTotalHitrate()) }; return Messages.getCompoundString("CacheDecorator.efficiency_report", args); //$NON-NLS-1$ }
From source file:com.aurel.track.dbase.UpdateDbSchema.java
/** * Run an SQL script/*w w w . j a v a 2s .c om*/ * @param script */ @SuppressWarnings("resource") private static void runSQLScript(String script, int maxValue, String progressText) { String folderName = getDbScriptFolder(); int line = 0; int noOfLines = 0; int progress = 0; Connection cono = null; try { long start = new Date().getTime(); cono = InitDatabase.getConnection(); cono.setAutoCommit(false); Statement ostmt = cono.createStatement(); script = "/dbase/" + folderName + "/" + script; URL populateURL = ApplicationBean.getInstance().getServletContext().getResource(script); InputStream in = populateURL.openStream(); java.util.Scanner s = new java.util.Scanner(in, "UTF-8").useDelimiter(";"); while (s.hasNext()) { ++noOfLines; s.nextLine(); } int mod = noOfLines / maxValue; in.close(); in = populateURL.openStream(); s = new java.util.Scanner(in, "UTF-8").useDelimiter(";"); String st = null; StringBuilder stb = new StringBuilder(); int modc = 0; progress = Math.round(new Float(mod) / new Float(noOfLines) * maxValue); LOGGER.info("Running SQL script " + script); while (s.hasNext()) { stb.append(s.nextLine().trim()); st = stb.toString(); ++line; ++modc; if (!st.isEmpty() && !st.startsWith("--") && !st.startsWith("/*") && !st.startsWith("#")) { if (st.trim().equalsIgnoreCase("go")) { try { cono.commit(); } catch (Exception ex) { LOGGER.error(ExceptionUtils.getStackTrace(ex)); } stb = new StringBuilder(); } else { if (st.endsWith(";")) { stb = new StringBuilder(); // clear buffer st = st.substring(0, st.length() - 1); // remove the semicolon try { if ("commit".equals(st.trim().toLowerCase()) || "go".equals(st.trim().toLowerCase())) { cono.commit(); } else { ostmt.executeUpdate(st); if (mod > 4 && modc >= mod) { modc = 0; ApplicationStarter.getInstance().actualizePercentComplete(progress, progressText); } } } catch (Exception exc) { if (!("Derby".equals(folderName) && exc.getMessage().contains("DROP TABLE") && exc.getMessage().contains("not exist"))) { LOGGER.error("Problem executing DDL statements: " + exc.getMessage()); LOGGER.error("Line " + line + ": " + st); } } } else { stb.append(" "); } } } else { stb = new StringBuilder(); } } in.close(); cono.commit(); cono.setAutoCommit(true); long now = new Date().getTime(); LOGGER.info("Database schema creation took " + (now - start) / 1000 + " seconds."); } catch (Exception e) { LOGGER.error("Problem upgrading database schema in line " + line + " of file " + script, e); } finally { try { if (cono != null) { cono.close(); } } catch (Exception e) { LOGGER.info("Closing the connection failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
public void mouseReleased(MouseEvent e) { try {/*from ww w.j av a 2 s . co m*/ if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) { // Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea( // (int) this.coElutionStart.getX(), (int) this.coElutionStart.getY()); JFreeChart jfc = _cp.getChart(); XYPlot p = jfc.getXYPlot(); CenterZoomNumberAxis czna = (CenterZoomNumberAxis) p.getDomainAxis(); Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY()); Rectangle2D plotboundaries = _cp.getChartRenderingInfo().getPlotInfo().getPlotArea(); double leftmostOnAxis = czna.getLowerBound(); double rightmostOnAxis = czna.getUpperBound(); double leftmostOnRange = this.coElutionRegion.getX(); double rightmostOnRange = this.coElutionRegion.getX() + this.coElutionRegion.getWidth(); double leftmostonscreen = screenDataArea.getX(); double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth(); double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen); double transformedLeftRange = (slope * (leftmostOnRange - leftmostonscreen)) + leftmostOnAxis; double transformedRightRange = (slope * (rightmostOnRange - leftmostonscreen)) + leftmostOnAxis; shifted = false; MRMDialog ultimateParent = (MRMDialog) MRMAncestor(); if (ultimateParent != null) { MRMTransition transition = ultimateParent.transitionOnPlot; MRMTransition mrmt = transition; if (mrmt != null) { int row = mrmt.getTableRow(); _ptm.data[row][MRMDialog.peaksData.CoStart.colno] = new Float(0f); _ptm.data[row][MRMDialog.peaksData.CoEnd.colno] = new Float(10000000f); _ptm.setValueAt(new Float(transformedRightRange), row, MRMDialog.peaksData.CoEnd.colno); _ptm.setValueAt(new Float(transformedLeftRange), row, MRMDialog.peaksData.CoStart.colno); } } Graphics2D g2 = (Graphics2D) _cp.getGraphics(); if (this.coElutionRegion != null) drawCoElutionRegion(g2); this.coElutionRegion = null; this.coElutionStart = null; } else { _cp.mouseReleased(e); } } catch (Exception ee) { } }
From source file:com.openbravo.pos.util.JRPrinterAWT411.java
/** * *//*from w ww.j ava2s.co m*/ private Image printPageToImage(int pageIndex, float zoom) throws JRException { Image pageImage = new BufferedImage((int) (jasperPrint.getPageWidth() * zoom) + 1, (int) (jasperPrint.getPageHeight() * zoom) + 1, BufferedImage.TYPE_INT_RGB); JRGraphics2DExporter exporter = new JRGraphics2DExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint); exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics()); exporter.setParameter(JRExporterParameter.PAGE_INDEX, Integer.valueOf(pageIndex)); exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom)); exporter.exportReport(); return pageImage; }
From source file:org.n52.oxf.render.sos.TimeSeriesChartRenderer4xPhenomenons.java
protected TimeSeriesCollection createDataset(String[] foiIdArray, ObservationSeriesCollection tuples4FOI, int observedPropertyIndex) { TimeSeriesCollection dataset = new TimeSeriesCollection(); for (String featureID : foiIdArray) { Map<ITimePosition, ObservedValueTuple> tupleMap = tuples4FOI.getAllTuples(featureID); if (tupleMap != null) { // for each selected <feature,observedPropertyIndex> pair construct a new TimeSeries: TimeSeries timeSeries = new TimeSeries( featureID + "___" + this.observedProperties[observedPropertyIndex], Second.class); for (ITimePosition timePos : tupleMap.keySet()) { ObservedValueTuple tuple = tupleMap.get(timePos); Number result = (Number) tuple.getValue(observedPropertyIndex); timeSeries.add(new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(), timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()), result); }/*from w w w. jav a 2s. c om*/ dataset.addSeries(timeSeries); } } dataset.setDomainIsPointsInTime(true); return dataset; }
From source file:net.sourceforge.subsonic.backend.controller.IPNController.java
private void processPaymentRequest(HttpServletRequest request) { String item = request.getParameter("item_number"); if (item == null) { item = request.getParameter("item_number1"); }//from w w w.j av a 2s . c o m String paymentStatus = request.getParameter("payment_status"); String paymentType = request.getParameter("payment_type"); int paymentAmount = Math.round(new Float(request.getParameter("mc_gross"))); String paymentCurrency = request.getParameter("mc_currency"); String txnId = request.getParameter("txn_id"); String txnType = request.getParameter("txn_type"); String payerEmail = request.getParameter("payer_email"); String payerFirstName = request.getParameter("first_name"); String payerLastName = request.getParameter("last_name"); String payerCountry = request.getParameter("residence_country"); // Update of an existing transaction? Payment paymentForTx = paymentDao.getPaymentByTransactionId(txnId); if (paymentForTx != null) { paymentForTx.setPaymentStatus(paymentStatus); paymentForTx.setLastUpdated(new Date()); paymentDao.updatePayment(paymentForTx); } else { Payment paymentForEmail = paymentDao.getPaymentByEmail(payerEmail); Date validTo = computeValidTo(paymentForEmail, request); Payment newPayment = new Payment(null, txnId, txnType, item, paymentType, paymentStatus, paymentAmount, paymentCurrency, payerEmail, payerFirstName, payerLastName, payerCountry, ProcessingStatus.NEW, validTo, new Date(), new Date()); paymentDao.createPayment(newPayment); } }
From source file:de.odysseus.calyxo.base.util.ParseUtils.java
public void testNullPrimitive() throws Exception { assertEquals(Boolean.FALSE, ParseUtils.parse(boolean.class, null)); assertEquals(new Character((char) 0), ParseUtils.parse(char.class, null)); assertEquals(new Byte((byte) 0), ParseUtils.parse(byte.class, null)); assertEquals(new Short((short) 0), ParseUtils.parse(short.class, null)); assertEquals(new Integer(0), ParseUtils.parse(int.class, null)); assertEquals(new Long(0), ParseUtils.parse(long.class, null)); assertEquals(new Float(0), ParseUtils.parse(float.class, null)); assertEquals(new Double(0), ParseUtils.parse(double.class, null)); }/*ww w . j a v a 2 s. co m*/
From source file:com.jeeframework.util.validate.GenericTypeValidator.java
/** * Checks if the value can safely be converted to a float primitive. * *@param value The value validation is being performed on. *@return the converted Float value./* www . j a va 2 s.co m*/ */ public static Float formatFloat(String value) { if (value == null) { return null; } try { return new Float(value); } catch (NumberFormatException e) { return null; } }
From source file:org.hdiv.web.servlet.tags.form.OptionsTagTests.java
protected void extendRequest(MockHttpServletRequest request) { TestBean bean = new TestBean(); bean.setName("foo"); bean.setCountry("UK"); bean.setMyFloat(new Float("12.34")); request.setAttribute(COMMAND_NAME, bean); request.setAttribute("countries", Country.getCountries()); List floats = new ArrayList(); floats.add(new Float("12.30")); floats.add(new Float("12.31")); floats.add(new Float("12.32")); floats.add(new Float("12.33")); floats.add(new Float("12.34")); floats.add(new Float("12.35")); request.setAttribute("floats", floats); }
From source file:blue.mixer.Channel.java
public void setLevel(float level) { if (levelParameter.isAutomationEnabled()) { float time = ParameterTimeManagerFactory.getInstance().getTime(); if (time < 0) { return; }/*from w ww.jav a 2 s. com*/ updatingLine = true; LinePoint found = null; Line line = levelParameter.getLine(); for (int i = 0; i < line.size(); i++) { LinePoint point = line.getLinePoint(i); if (point.getX() == time) { found = point; break; } } if (found != null) { found.setLocation(found.getX(), level); } else { LinePoint lp = new LinePoint(); lp.setLocation(time, level); line.insertLinePoint(lp); } updatingLine = false; } else { levelParameter.setValue(level); } float oldVal = this.level; this.level = level; firePropertyChange(LEVEL, new Float(oldVal), new Float(level)); }