Example usage for java.lang Float Float

List of usage examples for java.lang Float Float

Introduction

In this page you can find the example usage for java.lang Float Float.

Prototype

@Deprecated(since = "9")
public Float(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string.

Usage

From source file:quanlyhocvu.api.mongodb.DTO.Teacher.DiemDTO.java

public DiemDTO() {
    listDiemKTMieng = new ArrayList();
    listDiemKTMieng.add(new Float(-1));
    listDiemKT15 = new ArrayList();
    listDiemKT15.add(new Float(-1));
    listDiemKT1Tiet = new ArrayList();
    listDiemKT1Tiet.add(new Float(-1));
}

From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.FloatCalculator.java

public Object add(Object obj1, Object obj2) {
    Float floatData1 = (Float) obj1;
    Float floatData2 = (Float) obj2;

    return (Object) (new Float((float) (floatData1.floatValue() + floatData2.floatValue())));
}

From source file:com.jaspersoft.studio.editor.preview.input.array.number.FloatElement.java

@Override
protected Object convertString(String str) {
    return new Float(str);
}

From source file:Main.java

/**
 * Sums an array of numbers together while using the correct class type.
 *
 * @param numbers/*from  w ww . ja va2 s .  co m*/
 *
 * @return the sum contained in the most appropriate number class
 */
static Number sum(Number[] numbers) {
    Number newSum = (Number) getObject(numbers);

    if (newSum == null) {
        return null;
    }

    //Integer, Long, Float, Double
    if (newSum instanceof Integer) {
        int sum = 0;
        int nextValue;

        for (int i = 0; i < numbers.length; i++) {
            nextValue = numbers[i].intValue();
            sum += nextValue;
        }

        newSum = new Integer(sum);
    } else if (newSum instanceof Long) {
        long sum = 0;
        long nextValue;

        for (int i = 0; i < numbers.length; i++) {
            nextValue = numbers[i].longValue();
            sum += nextValue;
        }

        newSum = new Long(sum);
    } else if (newSum instanceof Float) {
        float sum = 0;
        float nextValue;

        for (int i = 0; i < numbers.length; i++) {
            nextValue = numbers[i].floatValue();
            sum += nextValue;
        }

        newSum = new Float(sum);
    } else if (newSum instanceof Double) {
        double sum = 0;
        double nextValue;

        for (int i = 0; i < numbers.length; i++) {
            nextValue = numbers[i].doubleValue();
            sum += nextValue;
        }

        newSum = new Double(sum);
    } else {
        return null;
    }

    return newSum;
}

From source file:io.headpro.entity.PeriodTotal.java

public PeriodTotal(Date startDate, Date endDate, Double total) {
    this(startDate, endDate, new Float(total));
}

From source file:com.bstek.dorado.data.type.FloatDataType.java

@Override
public Object fromObject(Object value) {
    if (value == null) {
        return null;
    } else if (value instanceof Float) {
        return value;
    } else if (value instanceof Number) {
        return new Float(((Number) value).floatValue());
    } else if (value instanceof String) {
        return fromText((String) value);
    } else {// www. j  a  v a2 s .c  om
        throw new DataConvertException(value.getClass(), Float.class);
    }
}

From source file:com.discursive.jccook.collections.cache.LRUCacheExample.java

private void start() {
    cache = new LRUMap(5);

    // Populate the cache with 5 stock prices
    cache.put("MSFT", new Float(0.03));
    cache.put("TSC", new Float(0.001));
    cache.put("LU", new Float(23.30));
    cache.put("CSCO", new Float(242.20));
    cache.put("P", new Float(10.23));

    // Now use some of the entries in the cache
    Float cscoPrice = (Float) cache.get("CSCO");
    Float msPrice = (Float) cache.get("MSFT");
    Float tscPrice = (Float) cache.get("TSC");
    Float luPrice = (Float) cache.get("LU");
    Float pPrice = (Float) cache.get("P");
    Float msPrice2 = (Float) cache.get("MSFT");

    // Add another price to the Map, this should kick out the LRU item.
    cache.put("AA", new Float(203.20));

    // CSCO was the first price requested, it is therefor the
    // least recently used.
    if (!cache.containsKey("CSCO")) {
        System.out.println("As expected CSCO was discarded");
    }/*from www .ja  v a 2  s .com*/
}

From source file:com.glaf.jbpm.util.CustomFieldInstantiator.java

public static Object getValue(Class<?> type, Element propertyElement) {
    Object value = null;//  ww  w .j  a  va2s .c o  m
    if (type == String.class) {
        value = propertyElement.getText();
    } else if ((type == Integer.class) || (type == int.class)) {
        value = Integer.parseInt(propertyElement.getTextTrim());
    } else if ((type == Long.class) || (type == long.class)) {
        value = Long.parseLong(propertyElement.getTextTrim());
    } else if ((type == Float.class) || (type == float.class)) {
        value = new Float(propertyElement.getTextTrim());
    } else if ((type == Double.class) || (type == double.class)) {
        value = Double.parseDouble(propertyElement.getTextTrim());
    } else if ((type == Boolean.class) || (type == boolean.class)) {
        value = Boolean.valueOf(propertyElement.getTextTrim());
    } else if ((type == Character.class) || (type == char.class)) {
        value = Character.valueOf(propertyElement.getTextTrim().charAt(0));
    } else if ((type == Short.class) || (type == short.class)) {
        value = Short.valueOf(propertyElement.getTextTrim());
    } else if ((type == Byte.class) || (type == byte.class)) {
        value = Byte.valueOf(propertyElement.getTextTrim());
    } else if (type.isAssignableFrom(java.util.Date.class)) {
        value = DateUtils.toDate(propertyElement.getTextTrim());
    } else if (type.isAssignableFrom(List.class)) {
        value = getCollectionValue(propertyElement, new java.util.ArrayList<Object>());
    } else if (type.isAssignableFrom(Set.class)) {
        value = getCollectionValue(propertyElement, new LinkedHashSet<Object>());
    } else if (type.isAssignableFrom(Collection.class)) {
        value = getCollectionValue(propertyElement, new java.util.ArrayList<Object>());
    } else if (type.isAssignableFrom(Map.class)) {
        value = getMapValue(propertyElement, new LinkedHashMap<Object, Object>());
    } else if (type == Element.class) {
        value = propertyElement;
    } else {
        try {
            Constructor<?> constructor = type.getConstructor(new Class[] { String.class });
            if ((propertyElement.isTextOnly()) && (constructor != null)) {
                value = constructor.newInstance(new Object[] { propertyElement.getTextTrim() });
            }
        } catch (Exception ex) {
            logger.error("couldn't parse the bean property value '" + propertyElement.asXML() + "' to a '"
                    + type.getName() + "'");
            throw new RuntimeException(ex);
        }
    }

    return value;
}

From source file:MainClass.java

public void paint(Graphics g) {
    Dimension size = getSize();//from  ww  w  .  ja v a  2  s.  c o m

    String s = "To java2s.com or not to java2s.com, that is a question";

    Hashtable map = new Hashtable();
    map.put(TextAttribute.SIZE, new Float(32.0f));

    AttributedString as = new AttributedString(s, map);

    map = new Hashtable();
    map.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);

    as.addAttributes(map, 33, 52);

    AttributedCharacterIterator aci = as.getIterator();

    int startIndex = aci.getBeginIndex();
    int endIndex = aci.getEndIndex();

    LineBreakMeasurer measurer;
    measurer = new LineBreakMeasurer(aci, new FontRenderContext(null, false, false));
    measurer.setPosition(startIndex);

    float wrappingWidth = (float) size.width;

    float Y = 0.0f;

    while (measurer.getPosition() < endIndex) {
        TextLayout layout = measurer.nextLayout(wrappingWidth);

        Y += layout.getAscent();

        float X = 0.0f;

        switch (justify) {
        case LEFT:
            if (layout.isLeftToRight())
                X = 0.0f;
            else
                X = wrappingWidth - layout.getAdvance();
            break;

        case RIGHT:
            if (layout.isLeftToRight())
                X = wrappingWidth - layout.getVisibleAdvance();
            else
                X = wrappingWidth;
            break;

        case CENTER:
            if (layout.isLeftToRight())
                X = (wrappingWidth - layout.getVisibleAdvance()) / 2;
            else
                X = (wrappingWidth + layout.getAdvance()) / 2 - layout.getAdvance();
            break;

        case EQUALITY:
            layout = layout.getJustifiedLayout(wrappingWidth);
        }

        layout.draw((Graphics2D) g, X, Y);

        Y += layout.getDescent() + layout.getLeading();
    }
}

From source file:org.killbill.billing.plugin.analytics.json.XY.java

public XY(final String x, final Integer y) {
    this(x, new Float(y.doubleValue()));
}