List of usage examples for java.lang Float valueOf
@HotSpotIntrinsicCandidate public static Float valueOf(float f)
From source file:Highcharts.ExportController.java
private static Float widthToFloat(String width) { width = sanitize(width);// w w w. j ava 2s .c o m if (width != null) { Float parsedWidth = Float.valueOf(width); if (parsedWidth.compareTo(MAX_WIDTH) > 0) { return MAX_WIDTH; } if (parsedWidth.compareTo(0.0F) > 0) { return parsedWidth; } } return null; }
From source file:de.ingrid.iplug.opensearch.converter.IngridRSSConverter.java
/** * Extract the score value from a given node and return it as a float value. * In case no score node could be found 0.0f is returned. This score will * not be put into an IngridHit then./*from w w w . ja v a2 s.c om*/ * * @param item * is the node to look for the score entry * @return the score but 0.0f if no ranking is supported * @throws XPathExpressionException */ private float getScore(Node item) throws XPathExpressionException { XPath xpath = XPathFactory.newInstance().newXPath(); Node node = (Node) xpath.evaluate("score", item, XPathConstants.NODE); if (node != null) { return Float.valueOf(node.getTextContent()); } return 0.0f; }
From source file:org.dcm4chee.dashboard.ui.report.display.DisplayReportDiagramPanel.java
@Override public void onBeforeRender() { super.onBeforeRender(); Connection jdbcConnection = null; try {//from w w w .ja v a 2 s . c o m if (report == null) throw new Exception("No report given to render diagram"); jdbcConnection = DatabaseUtils.getDatabaseConnection(report.getDataSource()); ResultSet resultSet = DatabaseUtils.getResultSet(jdbcConnection, report.getStatement(), parameters); ResultSetMetaData metaData = resultSet.getMetaData(); JFreeChart chart = null; resultSet.beforeFirst(); // Line chart - 1 numeric value if (report.getDiagram() == 0) { if (metaData.getColumnCount() != 1) throw new Exception( new ResourceModel("dashboard.report.reportdiagram.image.render.error.1numvalues") .wrapOnAssignment(this).getObject()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); while (resultSet.next()) dataset.addValue(resultSet.getDouble(1), metaData.getColumnName(1), String.valueOf(resultSet.getRow())); chart = ChartFactory.createLineChart( new ResourceModel("dashboard.report.reportdiagram.image.label").wrapOnAssignment(this) .getObject(), new ResourceModel("dashboard.report.reportdiagram.image.row-label").wrapOnAssignment(this) .getObject(), metaData.getColumnName(1), dataset, PlotOrientation.VERTICAL, true, true, true); // XY Series chart - 2 numeric values } else if (report.getDiagram() == 1) { if (metaData.getColumnCount() != 2) throw new Exception( new ResourceModel("dashboard.report.reportdiagram.image.render.error.2numvalues") .wrapOnAssignment(this).getObject()); XYSeries series = new XYSeries(metaData.getColumnName(1) + " / " + metaData.getColumnName(2)); while (resultSet.next()) series.add(resultSet.getDouble(1), resultSet.getDouble(2)); chart = ChartFactory.createXYLineChart( new ResourceModel("dashboard.report.reportdiagram.image.label").wrapOnAssignment(this) .getObject(), metaData.getColumnName(1), metaData.getColumnName(2), new XYSeriesCollection(series), PlotOrientation.VERTICAL, true, true, true); // Category chart - 1 numeric value, 1 comparable value } else if (report.getDiagram() == 2) { if (metaData.getColumnCount() != 2) throw new Exception( new ResourceModel("dashboard.report.reportdiagram.image.render.error.2values") .wrapOnAssignment(this).getObject()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); while (resultSet.next()) dataset.setValue(resultSet.getDouble(1), metaData.getColumnName(1) + " / " + metaData.getColumnName(2), resultSet.getString(2)); chart = new JFreeChart( new ResourceModel("dashboard.report.reportdiagram.image.label").wrapOnAssignment(this) .getObject(), new CategoryPlot(dataset, new LabelAdaptingCategoryAxis(14, metaData.getColumnName(2)), new NumberAxis(metaData.getColumnName(1)), new CategoryStepRenderer(true))); // Pie chart - 1 numeric value, 1 comparable value (used as category) } else if ((report.getDiagram() == 3) || (report.getDiagram() == 4)) { if (metaData.getColumnCount() != 2) throw new Exception( new ResourceModel("dashboard.report.reportdiagram.image.render.error.2values") .wrapOnAssignment(this).getObject()); DefaultPieDataset dataset = new DefaultPieDataset(); while (resultSet.next()) dataset.setValue(resultSet.getString(2), resultSet.getDouble(1)); if (report.getDiagram() == 3) // Pie chart 2D chart = ChartFactory .createPieChart(new ResourceModel("dashboard.report.reportdiagram.image.label") .wrapOnAssignment(this).getObject(), dataset, true, true, true); else if (report.getDiagram() == 4) { // Pie chart 3D chart = ChartFactory .createPieChart3D(new ResourceModel("dashboard.report.reportdiagram.image.label") .wrapOnAssignment(this).getObject(), dataset, true, true, true); ((PiePlot3D) chart.getPlot()).setForegroundAlpha( Float.valueOf(new ResourceModel("dashboard.report.reportdiagram.image.alpha") .wrapOnAssignment(this).getObject())); } // Bar chart - 1 numeric value, 2 comparable values (used as category, series) } else if (report.getDiagram() == 5) { if ((metaData.getColumnCount() != 2) && (metaData.getColumnCount() != 3)) throw new Exception( new ResourceModel("dashboard.report.reportdiagram.image.render.error.3values") .wrapOnAssignment(this).getObject()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); while (resultSet.next()) dataset.setValue(resultSet.getDouble(1), resultSet.getString(2), resultSet.getString(metaData.getColumnCount())); chart = ChartFactory.createBarChart( new ResourceModel("dashboard.report.reportdiagram.image.label").wrapOnAssignment(this) .getObject(), metaData.getColumnName(2), metaData.getColumnName(1), dataset, PlotOrientation.VERTICAL, true, true, true); } int[] winSize = DashboardCfgDelegate.getInstance().getWindowSize("reportDiagramImage"); addOrReplace(new JFreeChartImage("diagram", chart, winSize[0], winSize[1])); final JFreeChart downloadableChart = chart; addOrReplace(new Link<Object>("diagram-download") { private static final long serialVersionUID = 1L; @Override public void onClick() { RequestCycle.get().setRequestTarget(new IRequestTarget() { public void respond(RequestCycle requestCycle) { WebResponse wr = (WebResponse) requestCycle.getResponse(); wr.setContentType("image/png"); wr.setHeader("content-disposition", "attachment;filename=diagram.png"); OutputStream os = wr.getOutputStream(); try { ImageIO.write(downloadableChart.createBufferedImage(800, 600), "png", os); os.close(); } catch (IOException e) { log.error(this.getClass().toString() + ": " + "respond: " + e.getMessage()); log.debug("Exception: ", e); } wr.close(); } @Override public void detach(RequestCycle arg0) { } }); } }.add(new Image("diagram-download-image", ImageManager.IMAGE_DASHBOARD_REPORT_DOWNLOAD) .add(new ImageSizeBehaviour()) .add(new TooltipBehaviour("dashboard.report.reportdiagram.", "image.downloadlink")))); addOrReplace(new Image("diagram-print-image", ImageManager.IMAGE_DASHBOARD_REPORT_PRINT) .add(new ImageSizeBehaviour()) .add(new TooltipBehaviour("dashboard.report.reportdiagram.", "image.printbutton"))); addOrReplace(new Label("error-message", "").setVisible(false)); addOrReplace(new Label("error-reason", "").setVisible(false)); } catch (Exception e) { log.error("Exception: " + e.getMessage()); addOrReplace(((DynamicDisplayPage) this.getPage()).new PlaceholderLink("diagram-download") .setVisible(false)); addOrReplace(new Image("diagram-print-image").setVisible(false)); addOrReplace(new Image("diagram").setVisible(false)); addOrReplace(new Label("error-message", new ResourceModel("dashboard.report.reportdiagram.statement.error").wrapOnAssignment(this) .getObject()) .add(new AttributeModifier("class", true, new Model<String>("message-error")))); addOrReplace(new Label("error-reason", e.getMessage()) .add(new AttributeModifier("class", true, new Model<String>("message-error")))); log.debug(getClass() + ": ", e); } finally { try { jdbcConnection.close(); } catch (Exception ignore) { } } }
From source file:com.pool.rest.CarPoolRestService.java
@POST @Path("/raiseJoinRequest") public Response raiseJoinRequest(@FormParam("carPoolId") String carPoolId, @FormParam("srcLattitude") String srcLattitude, @FormParam("srcLongitude") String srcLongitude, @FormParam("destLattitude") String destLattitude, @FormParam("destLongitude") String destLongitude, @FormParam("tripCost") String tripCost, @FormParam("pickupTime") String pickupTime, @FormParam("pickupDistance") String pickupDistance) { _validateSession();//from w w w. ja v a 2 s. c om HttpSession session = request.getSession(false); User user = (User) session.getAttribute("USER"); CarPoolService service = new CarPoolService(); Carpool carPool = service.findPoolById(carPoolId); Request request = new Request(); request.setToUserId(carPool.getOwnerId()); request.setFromUserId(user.getUserId()); request.setCarPoolId(Long.parseLong(carPoolId)); request.setCreateDate(new Date().getTime() / 1000); request.setRequestTypeId(PoolConstants.REQUEST_JOIN_POOL_REQUEST_ID); request.setSrcLattitude(Double.parseDouble(srcLattitude)); request.setSrcLongitude(Double.parseDouble(srcLongitude)); request.setDestLattitude(Double.parseDouble(destLattitude)); request.setDestLongitude(Double.parseDouble(destLongitude)); request.setTripCost(Float.valueOf(tripCost)); request.setPickupDistance(Float.valueOf(pickupDistance)); request.setStartTime(Long.valueOf(pickupTime)); service.saveOrUpdate(request); Notification note = new Notification(); note.setCarPoolId(request.getCarPoolId()); note.setCreateDate((new Date()).getTime() / 1000); note.setFromUserId(user.getUserId()); note.setToUserId(carPool.getOwnerId()); note.setNotificationTypeId(PoolConstants.NOTI_JOIN_REQUEST_RECEIVED_ID); note.setRequestId(request.getRequestId()); service.saveOrUpdate(note); return Response.status(Response.Status.OK).build(); }
From source file:com.datatorrent.demos.dimensions.generic.EventSchema.java
public Object typeCast(String input, String fieldKey) { if (input == null) return null; Class<?> c = getType(fieldKey); if (c.equals(Integer.class)) return Integer.valueOf(input); else if (c.equals(Long.class)) return Long.valueOf(input); else if (c.equals(Float.class)) return Float.valueOf(input); else if (c.equals(Double.class)) return Float.valueOf(input); else//w ww .j av a 2s . co m return input; }
From source file:me.utils.excel.ImportExcelme.java
/** * ??/*from www . jav a 2 s. c o m*/ * @param cls */ public <E> List<E> getDataList(Class<E> cls, List<Zbx> zbxList) throws Exception { String title = (String) getMergedRegionValue(sheet, 0, 1);//? String tbDw = StringUtils.substringAfter((String) getMergedRegionValue(sheet, 1, 0), "");// Date tbDate = DateUtils .parseDate((StringUtils.substringAfter((String) getMergedRegionValue(sheet, 1, 4), ":")));//5? // Date tbDate = DateUtil.getJavaDate(Double.valueOf(StringUtils.substringAfter((String)getMergedRegionValue(sheet, 1, 4), ":"))) ;//5? Map<String, String> map = Maps.newHashMap(); for (Zbx zbx : zbxList) { map.put(zbx.getPropertyText(), zbx.getPropertyName()); } List<String> propertyNames = Lists.newArrayList(); for (int i = 0; i < this.getLastCellNum(); i++) {//?header ? Row row = this.getRow(this.getHeaderRowNum()); Object val = this.getCellValue(row, i); String propertyName = map.get(val); if (StringUtils.isEmpty(propertyName)) { throw new BusinessException("" + val + "?"); } propertyNames.add(propertyName); } //log.debug("Import column count:"+annotationList.size()); // Get excel data List<E> dataList = Lists.newArrayList(); for (int i = this.getDataRowNum(); i <= this.getLastDataRowNum(); i++) { E e = (E) cls.newInstance(); int column = 0; Row row = this.getRow(i); StringBuilder sb = new StringBuilder(); for (String propertyName : propertyNames) { Object val = this.getCellValue(row, column++);//string if (val != null) { // Get param type and type cast Class<?> valType = Reflections.getAccessibleField(e, propertyName).getType(); check(e, propertyName, val, i, column); //log.debug("Import value type: ["+i+","+column+"] " + valType); try { if (valType == String.class) { String s = String.valueOf(val.toString()); if (StringUtils.endsWith(s, ".0")) { val = StringUtils.substringBefore(s, ".0"); } else { val = String.valueOf(val.toString()); } } else if (valType == Integer.class) { val = Double.valueOf(val.toString()).intValue(); } else if (valType == Long.class) { val = Double.valueOf(val.toString()).longValue(); } else if (valType == Double.class) { val = Double.valueOf(val.toString()); } else if (valType == Float.class) { val = Float.valueOf(val.toString()); } else if (valType == Date.class) { // val = DateUtil.getJavaDate((Double)val); val = DateUtils.parseDate(val.toString()); } else {//? wjmany-to-one etc. } } catch (Exception ex) { log.info("Get cell value [" + i + "," + column + "] error: " + ex.toString()); val = null; } // set entity value Reflections.invokeSetter(e, propertyName, val); } sb.append(val + ", "); } Reflections.invokeSetter(e, "title", title); Reflections.invokeSetter(e, "tbDw", tbDw); Reflections.invokeSetter(e, "tbDate", tbDate); dataList.add(e); log.debug("Read success: [" + i + "] " + sb.toString()); } return dataList; }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
/** * @param chart// www . ja v a 2 s. c om * @param width * @param height * @param minimumDrawWidth * @param minimumDrawHeight * @param maximumDrawWidth * @param maximumDrawHeight * @param useBuffer * @param properties * @param copy * @param save * @param print * @param zoom * @param tooltips */ public Plot1DPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean copy, boolean save, boolean print, boolean zoom, boolean tooltips) { super(chart, width, height, minimumDrawWidth, minimumDrawHeight, maximumDrawWidth, maximumDrawHeight, useBuffer, properties, copy, save, print, zoom, tooltips); createMaskColors(false); String horizontalMarginProperty = System.getProperty(StaticValues.HORIZONTAL_MARGIN_PROPERTY); if (horizontalMarginProperty != null) { float horizontalMargin = 0.05f; try { horizontalMargin = Float.valueOf(horizontalMarginProperty); getHorizontalAxis().setLowerMargin(horizontalMargin); getHorizontalAxis().setUpperMargin(horizontalMargin); } catch (Exception e) { } } internalLegendSetup = new Rectangle2D.Double(152, 20, 150, 20); isInternalLegendSelected = false; mouseFollowerXPrecision = 2; mouseFollowerYPrecision = 2; indexInTooltip = false; String indexInTooltipProperty = System.getProperty(PROPERTY_INDEX_IN_TOOLTIP); if (indexInTooltipProperty != null) { try { indexInTooltip = Boolean.valueOf(indexInTooltipProperty); } catch (Exception e) { } } }
From source file:candr.yoclip.option.OptionSetter.java
protected void setFloatOption(final T bean, final String value) { final Float floatValue = StringUtils.isEmpty(value) ? 0.0f : Float.valueOf(value); set(bean, new Value<T>() { public void set(final T bean, final Method setter) throws InvocationTargetException, IllegalAccessException { setter.invoke(bean, floatValue); }/*from w ww . j a v a 2s . c om*/ }); }
From source file:com.inloc.dr.StepService.java
public void reloadSettings() { mSettings = PreferenceManager.getDefaultSharedPreferences(this); if (mStepDetector != null) { mStepDetector.setSensitivity(Float.valueOf(mSettings.getString("sensitivity", "10"))); }//from www . ja v a 2s . com if (mStepDisplayer != null) mStepDisplayer.reloadSettings(); }
From source file:magma.agent.perception.impl.ServerMessageParser.java
/** * Parse a symbol tree node into a Universal Joint Perceptor object * /*from ww w . ja v a 2 s . co m*/ * @param node Symbol tree node * @return Universal Joint Perceptor object * @throws PerceptorConversionException */ private UniversalJointPerceptor parseUniversalJoint(SymbolNode node) throws PerceptorConversionException { try { // Sanity checks assert node.getChild(1) instanceof SymbolNode : "Malformed Message: " + node.toString(); assert node.getChild(2) instanceof SymbolNode : "Malformed Message: " + node.toString(); assert node.getChild(3) instanceof SymbolNode : "Malformed Message: " + node.toString(); /* Check content */ SymbolNode nameNode = (SymbolNode) node.getChild(1); SymbolNode axis1Node = (SymbolNode) node.getChild(2); SymbolNode axis2Node = (SymbolNode) node.getChild(3); assert nameNode.getChild(0).content().equals("n") : "name expected: " + node.toString(); assert axis1Node.getChild(0).content().equals("ax1") : "axis expected: " + node.toString(); assert axis2Node.getChild(0).content().equals("ax2") : "axis expected: " + node.toString(); return new UniversalJointPerceptor(nameNode.getChild(1).content(), Float.valueOf(axis1Node.getChild(1).content()), Float.valueOf(axis2Node.getChild(1).content())); } catch (IndexOutOfBoundsException e) { throw new PerceptorConversionException("Malformed node: " + node.toString()); } }