List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:com.judoscript.jamaica.MyUtils.java
public static Object number2object(long val, String typeHint) { if (typeHint != null) { if (typeHint.equals("int")) return new Integer((int) val); if (typeHint.equals("long")) return new Long(val); if (typeHint.equals("short")) return new Short((short) val); if (typeHint.equals("char")) return new Character((char) val); if (typeHint.equals("byte")) return new Byte((byte) val); if (typeHint.equals("double")) return new Double(val); if (typeHint.equals("float")) return new Float(val); }//from ww w . j av a2 s . c o m return new Long(val); }
From source file:au.com.ish.derbydump.derbydump.main.DumpTest.java
@Parameterized.Parameters(name = "{0}") public static Collection<Object[]> setupTestMatrix() throws Exception { List<Object[]> result = new ArrayList<Object[]>(); //testing numbers (BIGINT, DECIMAL, REAL, SMALLINT, INTEGER, DOUBLE) {//from w ww . j a v a2s . c o m //standard set of numbers String[] columns = new String[] { "c1 BIGINT", "c2 DECIMAL(10,2)", "c3 REAL", "c4 SMALLINT", "c5 INTEGER", "c6 DOUBLE" }; Object[] row1 = new Object[] { new BigInteger("12"), new BigDecimal("12.12"), new Float("12.1"), Integer.valueOf(12), Integer.valueOf(24), Double.valueOf(12.12) }; String validOutput1 = "(12,12.12,12.1,12,24,12.12),"; Object[] row2 = new Object[] { new BigInteger("42"), new BigDecimal("42.12"), new Float("42.14"), Integer.valueOf(42), Integer.valueOf(64), Double.valueOf(42.14) }; String validOutput2 = "(42,42.12,42.14,42,64,42.14),"; Object[] row3 = new Object[] { new BigInteger("42"), new BigDecimal("42"), new Float("42"), Integer.valueOf(42), Integer.valueOf(64), Double.valueOf(42) }; String validOutput3 = "(42,42.00,42.0,42,64,42.0),"; Object[] row4 = new Object[] { new BigInteger("42"), new BigDecimal("42.1234"), new Float("42.1434"), Integer.valueOf(42), Integer.valueOf(64), Double.valueOf(42.1234) }; String validOutput4 = "(42,42.12,42.1434,42,64,42.1234),"; Object[] row5 = new Object[] { BigDecimal.ZERO, BigDecimal.ZERO, new Float("0"), Integer.valueOf(0), Integer.valueOf(0), Double.valueOf(0) }; String validOutput5 = "(0,0.00,0.0,0,0,0.0),"; //test nulls Object[] row6 = new Object[] { null, null, null, null, null, null }; String validOutput6 = "(NULL,NULL,NULL,NULL,NULL,NULL);"; Object[] values = new Object[] { row1, row2, row3, row4, row5, row6 }; String[] validOutput = new String[] { validOutput1, validOutput2, validOutput3, validOutput4, validOutput5, validOutput6 }; result.add(new Object[] { "testNumbers", null, columns, values, validOutput, false, false }); } //testing strings { String[] columns = new String[] { "c1 VARCHAR(20)", "c2 VARCHAR(20)", "c3 VARCHAR(20)" }; //test normal characters Object[] row1 = new Object[] { "123", "abc", "" }; String validOutput1 = "('123','abc',''),"; //test nulls Object[] row2 = new Object[] { "%", null, "" }; String validOutput2 = "('%',NULL,''),"; //test quotes and tabs Object[] row3 = new Object[] { "'test'", "\"test\"", "\t" }; String validOutput3 = "('\\'test\\'','\"test\"','\\t'),"; //test new line chars Object[] row4 = new Object[] { "\n", "\r", "\n\r" }; String validOutput4 = "('\\n','\\r','\\n\\r');"; Object[] values = new Object[] { row1, row2, row3, row4 }; String[] validOutput = new String[] { validOutput1, validOutput2, validOutput3, validOutput4 }; result.add(new Object[] { "testStrings", null, columns, values, validOutput, false, false }); } //testing dates { String[] columns = new String[] { "c1 TIMESTAMP", "c2 TIMESTAMP" }; // test standard dates Calendar c = Calendar.getInstance(TimeZone.getDefault()); c.set(Calendar.YEAR, 2013); c.set(Calendar.MONTH, 5); c.set(Calendar.DAY_OF_MONTH, 6); c.set(Calendar.HOUR_OF_DAY, 11); c.set(Calendar.MINUTE, 10); c.set(Calendar.SECOND, 10); c.set(Calendar.MILLISECOND, 11); Calendar c2 = (Calendar) c.clone(); c2.add(Calendar.DATE, -5000); Object[] row1 = new Object[] { c.getTime(), c2.getTime() }; String validOutput1 = "('2013-06-06 11:10:10.011','1999-09-28 11:10:10.011'),"; Object[] row2 = new Object[] { "2012-07-07 08:54:33", "1999-09-09 10:04:10" }; String validOutput2 = "('2012-07-07 08:54:33.0','1999-09-09 10:04:10.0'),"; Object[] row3 = new Object[] { null, null }; String validOutput3 = "(NULL,NULL);"; Object[] values = new Object[] { row1, row2, row3 }; String[] validOutput = new String[] { validOutput1, validOutput2, validOutput3 }; result.add(new Object[] { "testDates", null, columns, values, validOutput, false, false }); } //testing CLOB { String[] columns = new String[] { "c1 CLOB" }; Object[] row1 = new Object[] { "<clob value here>" }; String validOutput1 = "('<clob value here>'),"; Object[] row2 = new Object[] { null }; String validOutput2 = "(NULL);"; Object[] values = new Object[] { row1, row2 }; String[] validOutput = new String[] { validOutput1, validOutput2 }; result.add(new Object[] { "testClob", null, columns, values, validOutput, false, false }); } //testing BLOB { String[] columns = new String[] { "c1 BLOB" }; Object[] row1 = new Object[] { getTestImage() }; Blob serialBlob = new SerialBlob(IOUtils.toByteArray(getTestImage())); String validOutput1 = "(" + Column.processBinaryData(serialBlob) + "),"; Object[] row2 = new Object[] { null }; String validOutput2 = "(NULL);"; Object[] values = new Object[] { row1, row2 }; String[] validOutput = new String[] { validOutput1, validOutput2 }; result.add(new Object[] { "testBlob", null, columns, values, validOutput, false, false }); } //testing skipping table { String[] columns = new String[] { "c1 VARCHAR(5)" }; Object[] row1 = new Object[] { "123" }; String validOutput1 = ""; Object[] row2 = new Object[] { null }; String validOutput2 = "(NULL);"; Object[] values = new Object[] { row1, row2 }; String[] validOutput = new String[] { validOutput1, validOutput2 }; result.add(new Object[] { "testSkip", null, columns, values, validOutput, true, false }); } //testing renaming table { String[] columns = new String[] { "c1 VARCHAR(5)" }; Object[] row1 = new Object[] { "123" }; String validOutput1 = "('123'),"; Object[] row2 = new Object[] { null }; String validOutput2 = "(NULL);"; Object[] values = new Object[] { row1, row2 }; String[] validOutput = new String[] { validOutput1, validOutput2 }; result.add(new Object[] { "testRename", "testRenameNew", columns, values, validOutput, false, false }); } //testing empty table { String[] columns = new String[] { "c1 VARCHAR(5)" }; Object[] values = new Object[] { new Object[] {} }; String[] validOutput = new String[] {}; result.add(new Object[] { "testEmptyTable", null, columns, values, validOutput, true, false }); } //testing truncate table { String[] columns = new String[] { "c1 VARCHAR(5)" }; Object[] values = new Object[] { new Object[] {} }; String[] validOutput = new String[] {}; result.add(new Object[] { "testTruncateTable", null, columns, values, validOutput, true, true }); } return result; }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
public void mouseClicked(MouseEvent e) { if (e.getSource() instanceof ChartPanel && ((e.getButton() == MouseEvent.BUTTON2) || (e.getButton() == MouseEvent.BUTTON1) && ((e.getModifiers() & InputEvent.CTRL_MASK) != 0))) { CenterZoomNumberAxis czna = (CenterZoomNumberAxis) _cp.getChart().getXYPlot().getDomainAxis(); NumberAxis range = (NumberAxis) _cp.getChart().getXYPlot().getRangeAxis(); Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY()); double y1 = czna.getLowerBound(); double y2 = czna.getUpperBound(); double x1 = screenDataArea.getX(); double x2 = x1 + screenDataArea.getWidth(); double transformedx = (((y2 - y1) / (x2 - x1)) * (e.getX() - x1)) + y1; MRMDialog mrmd = (MRMDialog) MRMAncestor(); PeaksTableModel model = (PeaksTableModel) mrmd.peaksTable.getModel(); MRMTransition mrt = mrmd.transitionOnPlot; mrt.setCalcXatMaxYAllDaughters(transformedx); mrt.setCalcMaxYAllDaughters(/*from w w w . j a va 2 s.c om*/ range.getLowerBound() + 0.95 * (range.getUpperBound() - range.getLowerBound())); model.setValueAt(new Float(mrt.getCalcXatMaxYAllDaughters()), mrt.getTableRow(), MRMDialog.peaksData.MidTime.colno); for (MRMDaughter d : mrt.getDaughters().values()) { model.setValueAt(new Float(mrt.getCalcXatMaxYAllDaughters()), d.getElutionDataTableRow(), MRMDialog.peaksData.MidTime.colno); } mrmd.updateChartsAndFields(false); } if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) { _cp.mouseClicked(e); } else { _cp.mouseClicked(e); } }
From source file:org.sentilo.platform.server.test.parser.AdminParserTest.java
@Test public void parseStatsWriteResponse() throws Exception { final Events events = new Events(new Long(10), new Long(3), new Long(4), new Long(3)); final Performance performance = new Performance(new Float(54.84), new Float(14.65), new Float(784.84)); final Statistics stats = new Statistics(events, performance); final SentiloResponse response = SentiloResponse .build(new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_0, 200, ""))); parser.writeStatsResponse(sentiloRequest, response, stats); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); ((ByteArrayEntity) response.getHttpResponse().getEntity()).writeTo(baos); final String expected = "{\"events\":{\"total\":10,\"observations\":4,\"alarms\":3,\"orders\":3},\"performance\":{\"instantAvg\":54.84,\"dailyAvg\":14.65,\"maxAvg\":784.84}}"; assertEquals(expected, baos.toString()); }
From source file:org.hdiv.web.servlet.tags.form.TextareaTagTests.java
protected TestBean createTestBean() { // set up test data this.rob = new TestBean(); rob.setName("Rob"); rob.setMyFloat(new Float(12.34)); TestBean sally = new TestBean(); sally.setName("Sally"); rob.setSpouse(sally);/*from w w w.ja v a2s . c om*/ return rob; }
From source file:net.sf.nmedit.jtheme.image.SVGImageResource.java
private static Image renderSVGImage(Reader source, int width, int height) { ImageTranscoder pngt = new PNGTranscoder(); TranscoderInput input = new TranscoderInput(source); ByteArrayOutputStream out = new ByteArrayOutputStream(8096); try {//from www . j av a2 s . co m TranscoderOutput output = new TranscoderOutput(out); if (width > 0 && height > 0) { Float w = new Float(width); pngt.addTranscodingHint(PNGTranscoder.KEY_WIDTH, w); pngt.addTranscodingHint(PNGTranscoder.KEY_MAX_WIDTH, w); Float h = new Float(height); pngt.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, h); pngt.addTranscodingHint(PNGTranscoder.KEY_MAX_HEIGHT, h); } // TODO other solution for SAX parser / class loader issue ? Thread.currentThread().setContextClassLoader(ImageResource.class.getClassLoader()); // Save the image. try { pngt.transcode(input, output); } catch (TranscoderException e) { Log log = LogFactory.getLog(ImageResource.class); if (log.isWarnEnabled()) { log.warn("could not render image", e); } return null; } } finally { try { source.close(); } catch (IOException e) { Log log = LogFactory.getLog(ImageResource.class); if (log.isWarnEnabled()) { log.warn("could not close stream", e); } } } return Toolkit.getDefaultToolkit().createImage(out.toByteArray()); }
From source file:com.xpn.xwiki.objects.classes.NumberClass.java
@Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); String ntype = getNumberType(); Number nvalue = null;//from w w w .j a v a 2 s. c o m try { if (ntype.equals("integer")) { if ((value != null) && (!value.equals(""))) { nvalue = new Integer(value); } } else if (ntype.equals("float")) { if ((value != null) && (!value.equals(""))) { nvalue = new Float(value); } } else if (ntype.equals("double")) { if ((value != null) && (!value.equals(""))) { nvalue = new Double(value); } } else { if ((value != null) && (!value.equals(""))) { nvalue = new Long(value); } } } catch (NumberFormatException e) { LOG.warn("Invalid number entered for property " + getName() + " of class " + getObject().getName() + ": " + value); // Returning null makes sure that the old value (if one exists) will not be discarded/replaced return null; } property.setValue(nvalue); return property; }
From source file:org.openmrs.module.pmtct.web.view.chart.HivStatusPieChartView.java
@SuppressWarnings("static-access") @Override// w w w. j a v a 2 s .com protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { UserContext userContext = Context.getUserContext(); ApplicationContext appContext = ContextProvider.getApplicationContext(); PmtctService pmtct = Context.getService(PmtctService.class); DefaultPieDataset pieDataset = new DefaultPieDataset(); List<Object> objects = null; PMTCTModuleTag tag = new PMTCTModuleTag(); List<String> hivOptions = new ArrayList<String>(); List<Integer> hivOptionValues = new ArrayList<Integer>(); Collection<ConceptAnswer> answers = Context.getConceptService() .getConcept(PMTCTConstants.RESULT_OF_HIV_TEST).getAnswers(); try { objects = pmtct.getCurrentPatientsInPmtct(); for (ConceptAnswer str : answers) { hivOptions.add(str.getAnswerConcept().getName().getName()); hivOptionValues.add(0); } hivOptions.add("Others"); hivOptionValues.add(0); for (Object ob : objects) { int patientId = (Integer) ((Object[]) ob)[0]; String patientHivStatus = tag.lastObsValueByConceptId(patientId, PMTCTConstants.RESULT_OF_HIV_TEST); int i = 0; boolean found = false; for (String s : hivOptions) { if ((s.compareToIgnoreCase(patientHivStatus)) == 0) { hivOptionValues.set(i, hivOptionValues.get(i) + 1); found = true; } i++; } if (!found) { hivOptionValues.set(hivOptionValues.size() - 1, hivOptionValues.get(hivOptionValues.size() - 1) + 1); } } int i = 0; for (String s : hivOptions) { if (hivOptionValues.get(i) > 0) { Float percentage = new Float(100 * hivOptionValues.get(i) / objects.size()); pieDataset.setValue(s + " (" + hivOptionValues.get(i) + " , " + percentage + "%)", percentage); } i++; } } catch (Exception e) { e.printStackTrace(); } String title = appContext.getMessage("pmtct.menu.patientInPmtct", null, userContext.getLocale()); JFreeChart chart = ChartFactory.createPieChart(title + " : " + Context.getConceptService() .getConcept(PMTCTConstants.HIV_STATUS).getPreferredName(userContext.getLocale()), pieDataset, true, true, false); return chart; }
From source file:gov.nih.nci.ncicb.cadsr.common.lov.ClassificationsLOVBean.java
private void getClassificationBean(HttpServletRequest request, DBUtil dbUtil, String additionalWhere) { try {//w w w . j a v a 2 s .c o m // searchStr = request.getParameter("SEARCH"); searchStr = request.getParameterValues("SEARCH"); String csWhere = ""; String csvWhere = ""; String csiWhere = ""; if (searchStr != null) { for (int i = 0; i < searchStr.length; i++) { if (searchStr[i] == null) searchStr[i] = ""; } if (!searchStr[0].equals("")) { String newSearchStr0 = StringReplace.strReplace(searchStr[0], "*", "%"); // Release 3.0, TT#1178 newSearchStr0 = StringReplace.strReplace(newSearchStr0, "'", "''"); csWhere = " and (upper (cs.long_name) like upper ( '" + newSearchStr0 + "') " + " OR upper (cs.preferred_name) like upper ( '" + newSearchStr0 + "')) "; } // Release 3.2 GF#1247 if (!searchStr[1].equals("")) { Float newSearchFlt1 = new Float(searchStr[1]); csvWhere = " and cs.version = " + newSearchFlt1.toString() + " "; } if (!searchStr[2].equals("")) { String newSearchStr1 = StringReplace.strReplace(searchStr[2], "*", "%"); // Release 3.0, TT#1178 newSearchStr1 = StringReplace.strReplace(newSearchStr1, "'", "''"); csiWhere = " and upper (csi.long_name) like upper ( '" + newSearchStr1 + "') "; } if (request.getParameter("chkContext") == null) { whereClause = csWhere + csvWhere + csiWhere; } else { whereClause = csWhere + csvWhere + csiWhere + additionalWhere; isContextSpecific = true; } } // pass the following parameters to CommonListCntrlBean String[] searchParm = { "cs.long_name", "Classification Scheme", "cs.version", "CS Version", // Release 3.2 GF#1247 "csi.long_name csi_name", "Class Scheme Item" }; String[] jspLinkParm = { "csc.cs_csi_idseq", "P_ID" }; String[] displayParm = { "csi.long_name csi_name", "Class Scheme Item Name", "csi.csi_id||'v'||" + "case when csi.version = trunc(csi.version) " + "then to_char(csi.version,'99.9') " + "else to_char(csi.version,'99.99') " + "end csi_version", "CSI Public ID Version", "cs.long_name", "CS Long Name", "cs.cs_id||'v'||" + "case when cs.version = trunc(cs.version) " + "then to_char(cs.version,'99.9') " + "else to_char(cs.version,'99.99') " + "end csversion", "CS Public ID Version", // Release 3.2 GF#1247 "cs_conte.name", "CS Context", "cs.asl_name", "CS Workflow Status", "cs.preferred_definition", "CS Definition" }; String[] sqlStmtParm = new String[2]; sqlStmtParm[0] = " from sbr.classification_schemes_view cs, sbr.contexts_view cs_conte, " + " sbr.cs_items_view csi, sbr.cs_csi_view csc " + " where cs.conte_idseq = cs_conte.conte_idseq " //+ // Release 3.2 GF#1247 " and cs.latest_version_ind = 'Yes' " // + //" and cs.deleted_ind = 'No' " //when using view no need for this + " and cs.cs_idseq = csc.cs_idseq " + " and csi.csi_idseq = csc.csi_idseq " + " and cs.asl_name not in ('RETIRED PHASED OUT','RETIRED DELETED') " + whereClause; sqlStmtParm[1] = " order by cs.long_name, csi.long_name "; int[] lovPassbackCols = { 0, 4 }; clb = new CommonLOVBean(request, // dBBroker, dbUtil, searchParm, jspLinkParm, displayParm, sqlStmtParm, false, lovPassbackCols); clb.setCompressFlag(false); // set compress flag clb.setLinkCol(0); // set detail page link column, 0-> first; // 1->second clb.setDetailReq_Type("value_domains"); // set req_type for detail // page clb.setShowRowNum(40); // clb.setPerformQueryToFalse(); //clb.setJsId(StringEscapeUtils.escapeHtml(request.getParameter("idVar"))); clb.setJsId("jspClassification"); //clb.setJsName(StringEscapeUtils.escapeHtml(request.getParameter("nameVar"))); clb.setJsName("txtClassSchemeItem"); if (isContextSpecific) clb.setExtraURLInfo("&performQuery=false&ckhContext=yes"); else clb.setExtraURLInfo("&performQuery=false"); } catch (SQLException e) { //this.dBBroker = dBBroker; log.error("Exception: ", e); } }
From source file:com.judoscript.jamaica.MyUtils.java
public static Object number2object(double val, String typeHint) { if (typeHint != null) { if (typeHint.equals("double")) return new Double(val); if (typeHint.equals("float")) return new Float((float) val); if (typeHint.equals("int")) return new Integer((int) val); if (typeHint.equals("long")) return new Long((long) val); if (typeHint.equals("short")) return new Short((short) val); if (typeHint.equals("char")) return new Character((char) val); if (typeHint.equals("byte")) return new Byte((byte) val); }//from w w w . j av a2s .c om return new Double(val); }