List of usage examples for java.lang Float Float
@Deprecated(since = "9") public Float(String s) throws NumberFormatException
From source file:com.pronoiahealth.olhie.server.services.BookCoverImageService.java
/** * Initialize the various maps, fonts, etc.. *//* w w w. jav a 2 s.com*/ @PostConstruct protected void postActivate() { try { // Init the coverMap and load the images coverMap = new HashMap<String, byte[]>(); List<BookCover> covers = coverDisplayData.getCovers(); for (BookCover cover : covers) { coverMap.put(cover.getCoverName(), readResourceToByteArray("/" + cover.getImgUrl(), servletContext)); } // Load needed fonts medulaOneRegularFont = Font.createFont(Font.TRUETYPE_FONT, servletContext.getResourceAsStream("/Olhie/font/MedulaOne-Regular.ttf")); medulaOneRegularFont48 = medulaOneRegularFont.deriveFont(new Float(48.0)); arialBoldFont13 = new Font("Arial Bold", Font.BOLD, 13); arialBoldFont16 = new Font("Arial Bold", Font.ITALIC, 16); // Init font maps // author authorFontMap = new Hashtable<TextAttribute, Object>(); authorFontMap.put(TextAttribute.FONT, arialBoldFont16); authorFontMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); // Title titleFontMap = new Hashtable<TextAttribute, Object>(); titleFontMap.put(TextAttribute.FONT, medulaOneRegularFont48); titleFontMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); // Back cover title backTitleFontMap = new Hashtable<TextAttribute, Object>(); backTitleFontMap.put(TextAttribute.FONT, arialBoldFont13); backTitleFontMap.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); backTitleFontMap.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_ONE_PIXEL); // Build palette factory palFac = new PaletteFactory(); } catch (Exception e) { log.log(Level.SEVERE, "Error occured during BookCoverImageService initialization.", e); } }
From source file:com.mongodb.hadoop.input.BSONFileRecordReader.java
@Override public float getProgress() throws IOException, InterruptedException { if (this.finished) return 1f; if (in != null) return new Float(in.getPos() - this.fileSplit.getStart()) / this.fileSplit.getLength(); return 0f;// ww w . j a v a 2 s.c o m }
From source file:com.baculsoft.beanutils.test.TestBeanUtil2.java
@Test public void testDescribe() throws Throwable { PojoExample pojoSource = new PojoExample(); pojoSource.setStringProp("String Property"); pojoSource.setBooleanProp(true);// w ww . j av a2 s .c om pojoSource.setBooleanProp1(Boolean.TRUE); pojoSource.setDateProp(new Date()); pojoSource.setByteProp1(new Byte((byte) 11)); pojoSource.setByteProp((byte) 11); pojoSource.setIntProp1(new Integer(15125)); pojoSource.setIntProp(155); pojoSource.setLongProp1(new Long(20053215235l)); pojoSource.setLongProp(12325352l); pojoSource.setFloatProp1(new Float(20053215235f)); pojoSource.setFloatProp(498485802.4f); pojoSource.setDoubleProp1(new Double(99593884364.25326214)); pojoSource.setDoubleProp(0.96925326214); pojoDescriptor.describe(pojoSource); org.apache.commons.beanutils.BeanUtils.describe(pojoSource); long t1 = System.currentTimeMillis(); for (int i = 0; i < 50; i++) { pojoDescriptor.describe(pojoSource); } t1 = System.currentTimeMillis() - t1; long t2 = System.currentTimeMillis(); for (int i = 0; i < 50; i++) { org.apache.commons.beanutils.BeanUtils.describe(pojoSource); } t2 = System.currentTimeMillis() - t2; System.out.println("Time to describe "); System.out.println("this class : t1 --->" + t1); System.out.println("apache commons : t2 --->" + t2); System.out.println(pojoDescriptor.describe(pojoSource).equals(pojoDescriptor.describe(pojoSource))); assertEquals(pojoDescriptor.describe(pojoSource), pojoDescriptor.describe(pojoSource)); System.out.println("----------------------------------------------------------"); }
From source file:net.sf.jasperreports.engine.util.JRFontUtil.java
/** * *//*from w w w . j a v a 2 s . co m*/ public static Map<Attribute, Object> getAttributesWithoutAwtFont(Map<Attribute, Object> attributes, JRFont font) { attributes.put(TextAttribute.FAMILY, font.getFontName()); attributes.put(TextAttribute.SIZE, new Float(font.getFontSize())); if (font.isBold()) { attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); } if (font.isItalic()) { attributes.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE); } if (font.isUnderline()) { attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); } if (font.isStrikeThrough()) { attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); } attributes.put(JRTextAttribute.PDF_FONT_NAME, font.getPdfFontName()); attributes.put(JRTextAttribute.PDF_ENCODING, font.getPdfEncoding()); if (font.isPdfEmbedded()) { attributes.put(JRTextAttribute.IS_PDF_EMBEDDED, Boolean.TRUE); } return attributes; }
From source file:org.hdiv.web.servlet.tags.form.RadioButtonTagTests.java
private Float getFloat() { return new Float("12.99"); }
From source file:org.crazydog.util.spring.NumberUtils.java
/** * Convert the given number into an instance of the given target class. * * @param number the number to convert * @param targetClass the target class to convert to * @return the converted number// w w w .j av a 2s.c om * @throws IllegalArgumentException if the target class is not supported * (i.e. not a standard Number subclass as included in the JDK) * @see Byte * @see Short * @see Integer * @see Long * @see BigInteger * @see Float * @see Double * @see BigDecimal */ @SuppressWarnings("unchecked") public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass) throws IllegalArgumentException { org.springframework.util.Assert.notNull(number, "Number must not be null"); org.springframework.util.Assert.notNull(targetClass, "Target class must not be null"); if (targetClass.isInstance(number)) { return (T) number; } else if (Byte.class == targetClass) { long value = number.longValue(); if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Byte(number.byteValue()); } else if (Short.class == targetClass) { long value = number.longValue(); if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Short(number.shortValue()); } else if (Integer.class == targetClass) { long value = number.longValue(); if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { raiseOverflowException(number, targetClass); } return (T) new Integer(number.intValue()); } else if (Long.class == targetClass) { BigInteger bigInt = null; if (number instanceof BigInteger) { bigInt = (BigInteger) number; } else if (number instanceof BigDecimal) { bigInt = ((BigDecimal) number).toBigInteger(); } // Effectively analogous to JDK 8's BigInteger.longValueExact() if (bigInt != null && (bigInt.compareTo(LONG_MIN) < 0 || bigInt.compareTo(LONG_MAX) > 0)) { raiseOverflowException(number, targetClass); } return (T) new Long(number.longValue()); } else if (BigInteger.class == targetClass) { if (number instanceof BigDecimal) { // do not lose precision - use BigDecimal's own conversion return (T) ((BigDecimal) number).toBigInteger(); } else { // original value is not a Big* number - use standard long conversion return (T) BigInteger.valueOf(number.longValue()); } } else if (Float.class == targetClass) { return (T) new Float(number.floatValue()); } else if (Double.class == targetClass) { return (T) new Double(number.doubleValue()); } else if (BigDecimal.class == targetClass) { // always use BigDecimal(String) here to avoid unpredictability of BigDecimal(double) // (see BigDecimal javadoc for details) return (T) new BigDecimal(number.toString()); } else { throw new IllegalArgumentException("Could not convert number [" + number + "] of type [" + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]"); } }
From source file:org.openmrs.module.vcttrac.web.view.chart.VCTCreatePieChartView.java
private JFreeChart createGenderPieChartView() { DefaultPieDataset pieDataset = new DefaultPieDataset(); VCTModuleService service = Context.getService(VCTModuleService.class); try {//from ww w. j a v a 2 s . c o m Date reportingDate = new Date(); int numberOffemale = service.getVCTClientsBasedOnGender("f", reportingDate).size(); int numberOfMale = service.getVCTClientsBasedOnGender("m", reportingDate).size(); int all = numberOffemale + numberOfMale; Float percentageFemale = new Float(100 * numberOffemale / all); pieDataset.setValue(VCTTracUtil.getMessage("vcttrac.person.female", null) + " (" + numberOffemale + " , " + percentageFemale + "%)", percentageFemale); Float percentageMale = new Float(100 * numberOfMale / all); pieDataset.setValue(VCTTracUtil.getMessage("vcttrac.person.male", null) + " (" + numberOfMale + " , " + percentageMale + "%)", percentageMale); JFreeChart chart = ChartFactory.createPieChart(VCTTracUtil.getMessage("vcttrac.person.gender", null), pieDataset, true, true, false); return chart; } catch (Exception e) { log.error(">>GENDER>>PIE>>CHART>> " + e.getMessage()); e.printStackTrace(); return ChartFactory.createPieChart(VCTTracUtil.getMessage("vcttrac.person.gender", null), null, true, true, false); } }
From source file:gov.nih.nci.rembrandt.web.plots.RBTPrincipalComponentAnalysisPlot.java
/** * This chart uses the XYAnnotation as a glyph to represent * a single pca data point. Glyph shape is determined by survival time. * Survival of more than 10 months is represented by a circle. 10 months or less * is represented by a square. Component1 values are represented by X * Component2 values are represented by Y *//*from w w w . j ava 2 s . c o m*/ protected void createGlyphsAndAddToPlot(XYPlot plot) { //for RBT, if its non_tumor, show a diamond meaning "N/A for survival" XYShapeAnnotation glyph; Shape glyphShape; Color glyphColor; PrincipalComponentAnalysisDataPoint pcaPoint; double x, y; for (Iterator i = dataPoints.iterator(); i.hasNext();) { pcaPoint = (PrincipalComponentAnalysisDataPoint) i.next(); x = pcaPoint.getComponentValue(component1); y = pcaPoint.getComponentValue(component2); double survival = pcaPoint.getSurvivalInMonths(); String diseaseName = pcaPoint.getDiseaseName(); if (this.colorBy.equals(PCAcolorByType.NONE)) { Ellipse2D.Double circle = new Ellipse2D.Double(); circle.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = circle; } else if (diseaseName.equals(RembrandtConstants.NON_TUMOR) || diseaseName.equals("CELL_LINE")) { //glyphShape = ShapeUtilities.createDiamond(new Float(x)); Rectangle2D.Double rect = new Rectangle2D.Double(); rect.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = rect; Shape gShape = ShapeUtilities.rotateShape(glyphShape, new Double(0.785398163), new Float(x), new Float(y)); glyphShape = gShape; } else if ((survival > 0) && (survival < 10.0)) { Rectangle2D.Double rect = new Rectangle2D.Double(); rect.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = rect; } else if ((survival > 0) && (survival >= 10.0)) { Ellipse2D.Double circle = new Ellipse2D.Double(); circle.setFrameFromCenter(x, y, x + 2, y + 2); glyphShape = circle; } else { GeneralPath gp = new GeneralPath(); float xf = (float) x; float yf = (float) y; //make a triangle gp.moveTo(xf, yf); gp.lineTo(xf + 3.0f, yf - 3.0f); gp.lineTo(xf - 3.0f, yf - 3.0f); gp.closePath(); glyphShape = gp; } glyphColor = getColorForDataPoint(pcaPoint); glyph = new XYShapeAnnotation(glyphShape, new BasicStroke(1.0f), Color.BLACK, glyphColor); String tooltip = ""; if (pcaPoint.getSurvivalInMonths() <= 0.0) { tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName(); } else { tooltip = pcaPoint.getSampleId() + " " + pcaPoint.getDiseaseName() + " survivalMonths=" + nf.format(pcaPoint.getSurvivalInMonths()); } glyph.setToolTipText(tooltip); plot.addAnnotation(glyph); } }
From source file:adams.data.statistics.StatUtils.java
/** * Turns the float array into a Float array. * * @param array the array to convert/*from ww w .j a va 2 s . c o m*/ * @return the converted array */ public static Number[] toNumberArray(float[] array) { Float[] result; int i; result = new Float[array.length]; for (i = 0; i < array.length; i++) result[i] = new Float(array[i]); return result; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleSettingsFactory.java
/** * *//* w ww . j a v a2s . c o m*/ public static final ChartThemeSettings createChartThemeSettings() { ChartThemeSettings settings = new ChartThemeSettings(); ChartSettings chartSettings = settings.getChartSettings(); chartSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); chartSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png")); chartSettings.setBackgroundImageAlignment(new Integer(Align.TOP_RIGHT)); chartSettings.setBackgroundImageAlpha(new Float(1f)); chartSettings.setBorderVisible(Boolean.TRUE); chartSettings.setBorderPaint(new ColorProvider(Color.GREEN)); chartSettings.setBorderStroke(new BasicStroke(1f)); chartSettings.setAntiAlias(Boolean.TRUE); chartSettings.setTextAntiAlias(Boolean.TRUE); chartSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); TitleSettings titleSettings = settings.getTitleSettings(); titleSettings.setShowTitle(Boolean.TRUE); titleSettings.setPosition(EdgeEnum.TOP); titleSettings.setForegroundPaint(new ColorProvider(Color.black)); titleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); titleSettings.getFont().setBold(Boolean.TRUE); titleSettings.getFont().setFontSize(22); titleSettings.setHorizontalAlignment(HorizontalAlignment.CENTER); titleSettings.setVerticalAlignment(VerticalAlignment.TOP); titleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); TitleSettings subtitleSettings = settings.getSubtitleSettings(); subtitleSettings.setShowTitle(Boolean.TRUE); subtitleSettings.setPosition(EdgeEnum.TOP); subtitleSettings.setForegroundPaint(new ColorProvider(Color.red)); subtitleSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); subtitleSettings.getFont().setBold(Boolean.TRUE); subtitleSettings.setHorizontalAlignment(HorizontalAlignment.LEFT); subtitleSettings.setVerticalAlignment(VerticalAlignment.CENTER); subtitleSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); LegendSettings legendSettings = settings.getLegendSettings(); legendSettings.setShowLegend(Boolean.TRUE); legendSettings.setPosition(EdgeEnum.BOTTOM); legendSettings.setForegroundPaint(new ColorProvider(Color.black)); legendSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); legendSettings.getFont().setBold(Boolean.TRUE); legendSettings.setHorizontalAlignment(HorizontalAlignment.CENTER); legendSettings.setVerticalAlignment(VerticalAlignment.BOTTOM); //FIXMETHEME legendSettings.setBlockFrame(); legendSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); PlotSettings plotSettings = settings.getPlotSettings(); plotSettings.setOrientation(PlotOrientation.VERTICAL); // plotSettings.setForegroundAlpha(new Float(0.5f)); plotSettings.setBackgroundPaint(new GradientPaintProvider(Color.green, Color.blue)); // plotSettings.setBackgroundAlpha(new Float(0.5f)); plotSettings.setBackgroundImage(new FileImageProvider("net/sf/fspdfs/chartthemes/simple/fspdfs.png")); plotSettings.setBackgroundImageAlpha(new Float(0.5f)); plotSettings.setBackgroundImageAlignment(new Integer(Align.NORTH_WEST)); plotSettings.setLabelRotation(new Double(0)); plotSettings.setPadding(new RectangleInsets(UnitType.ABSOLUTE, 1.1, 2.2, 3.3, 4.4)); plotSettings.setOutlineVisible(Boolean.TRUE); plotSettings.setOutlinePaint(new ColorProvider(Color.red)); plotSettings.setOutlineStroke(new BasicStroke(1f)); plotSettings.setSeriesColorSequence(COLORS); // plotSettings.setSeriesGradientPaintSequence(GRADIENT_PAINTS); plotSettings.setSeriesOutlinePaintSequence(COLORS_DARKER); plotSettings.setSeriesStrokeSequence(STROKES); plotSettings.setSeriesOutlineStrokeSequence(OUTLINE_STROKES); plotSettings.setDomainGridlineVisible(Boolean.TRUE); plotSettings.setDomainGridlinePaint(new ColorProvider(Color.DARK_GRAY)); plotSettings.setDomainGridlineStroke(new BasicStroke(0.5f)); plotSettings.setRangeGridlineVisible(Boolean.TRUE); plotSettings.setRangeGridlinePaint(new ColorProvider(Color.BLACK)); plotSettings.setRangeGridlineStroke(new BasicStroke(0.5f)); plotSettings.getTickLabelFont().setFontName("Courier"); plotSettings.getTickLabelFont().setBold(Boolean.TRUE); plotSettings.getTickLabelFont().setFontSize(10); plotSettings.getDisplayFont().setFontName("Arial"); plotSettings.getDisplayFont().setBold(Boolean.TRUE); plotSettings.getDisplayFont().setFontSize(12); AxisSettings domainAxisSettings = settings.getDomainAxisSettings(); domainAxisSettings.setVisible(Boolean.TRUE); domainAxisSettings.setLocation(AxisLocation.BOTTOM_OR_RIGHT); domainAxisSettings.setLinePaint(new ColorProvider(Color.green)); domainAxisSettings.setLineStroke(new BasicStroke(1f)); domainAxisSettings.setLineVisible(Boolean.TRUE); // domainAxisSettings.setLabel("Domain Axis"); domainAxisSettings.setLabelAngle(new Double(0.0)); domainAxisSettings.setLabelPaint(new ColorProvider(Color.magenta)); domainAxisSettings.getLabelFont().setBold(Boolean.TRUE); domainAxisSettings.getLabelFont().setItalic(Boolean.TRUE); domainAxisSettings.getLabelFont().setFontName("Comic Sans MS"); domainAxisSettings.getLabelFont().setFontSize(12); domainAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1)); domainAxisSettings.setLabelVisible(Boolean.TRUE); domainAxisSettings.setTickLabelPaint(new ColorProvider(Color.cyan)); domainAxisSettings.getTickLabelFont().setBold(Boolean.TRUE); domainAxisSettings.getTickLabelFont().setItalic(Boolean.FALSE); domainAxisSettings.getTickLabelFont().setFontName("Arial"); domainAxisSettings.getTickLabelFont().setFontSize(10); domainAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5)); domainAxisSettings.setTickLabelsVisible(Boolean.TRUE); domainAxisSettings.setTickMarksInsideLength(new Float(0.1f)); domainAxisSettings.setTickMarksOutsideLength(new Float(0.2f)); domainAxisSettings.setTickMarksPaint(new ColorProvider(Color.ORANGE)); domainAxisSettings.setTickMarksStroke(new BasicStroke(1f)); domainAxisSettings.setTickMarksVisible(Boolean.TRUE); domainAxisSettings.setTickCount(new Integer(5)); AxisSettings rangeAxisSettings = settings.getRangeAxisSettings(); rangeAxisSettings.setVisible(Boolean.TRUE); rangeAxisSettings.setLocation(AxisLocation.TOP_OR_RIGHT); rangeAxisSettings.setLinePaint(new ColorProvider(Color.yellow)); rangeAxisSettings.setLineStroke(new BasicStroke(1f)); rangeAxisSettings.setLineVisible(Boolean.TRUE); // rangeAxisSettings.setLabel("Range Axis"); rangeAxisSettings.setLabelAngle(new Double(Math.PI / 2.0)); rangeAxisSettings.setLabelPaint(new ColorProvider(Color.green)); rangeAxisSettings.getLabelFont().setBold(Boolean.TRUE); rangeAxisSettings.getLabelFont().setItalic(Boolean.TRUE); rangeAxisSettings.getLabelFont().setFontName("Comic Sans MS"); rangeAxisSettings.getLabelFont().setFontSize(12); rangeAxisSettings.setLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 1, 1)); rangeAxisSettings.setLabelVisible(Boolean.TRUE); rangeAxisSettings.setTickLabelPaint(new ColorProvider(Color.pink)); rangeAxisSettings.getTickLabelFont().setBold(Boolean.FALSE); rangeAxisSettings.getTickLabelFont().setItalic(Boolean.TRUE); rangeAxisSettings.getTickLabelFont().setFontName("Arial"); rangeAxisSettings.getTickLabelFont().setFontSize(10); rangeAxisSettings.setTickLabelInsets(new RectangleInsets(UnitType.ABSOLUTE, 0.5, 0.5, 0.5, 0.5)); rangeAxisSettings.setTickLabelsVisible(Boolean.TRUE); rangeAxisSettings.setTickMarksInsideLength(new Float(0.2f)); rangeAxisSettings.setTickMarksOutsideLength(new Float(0.1f)); rangeAxisSettings.setTickMarksPaint(new ColorProvider(Color.black)); rangeAxisSettings.setTickMarksStroke(new BasicStroke(1f)); rangeAxisSettings.setTickMarksVisible(Boolean.TRUE); rangeAxisSettings.setTickCount(new Integer(6)); return settings; }