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:Main.java

public static float toFloat(String s) {
    return new Float(s).floatValue();
}

From source file:gov.nih.nci.ncicb.cadsr.common.persistence.dao.jdbc.JDBCFormValidValueDAO.java

/**
 * Test application/* w  ww  .  jav a 2 s.  c  o m*/
 */
public static void main(String[] args) {
    ServiceLocator locator = new SimpleServiceLocator();
    JDBCFormValidValueDAO test = new JDBCFormValidValueDAO(locator);

    try {
        // test createValidValueComponent method.
        // for each test, change long name(preferred name generated from long name)
        FormValidValue formValidValue = new FormValidValueTransferObject();

        Form form = new FormTransferObject();
        form.setFormIdseq("99CD59C5-A8B7-3FA4-E034-080020C9C0E0");
        Protocol prot = new ProtocolTransferObject();
        prot.setProtoIdseq("B1EACF79-3F60-3053-E034-0003BA12F5E7");
        //multiple protocols
        List protocols = new ArrayList(1);
        protocols.add(prot);
        form.setProtocols(protocols);
        Module module = new ModuleTransferObject();
        module.setModuleIdseq("D45A49A8-167D-0422-E034-0003BA0B1A09");
        module.setForm(form);
        Question question = new QuestionTransferObject();
        question.setQuesIdseq("99CD59C6-17B8-3FA4-E034-080020C9C0E0");
        question.setModule(module);

        formValidValue.setQuestion(question);
        formValidValue.setVersion(new Float(2.31));
        formValidValue.setLongName("Test ValidValue Long Name 022904 1");
        formValidValue.setPreferredDefinition("Test Valid Value pref def");
        Context conte = new ContextTransferObject();
        conte.setConteIdseq("29A8FB18-0AB1-11D6-A42F-0010A4C1E842");
        formValidValue.setContext(conte);
        formValidValue.setAslName("DRAFT NEW");
        formValidValue.setCreatedBy("Hyun Kim");
        formValidValue.setVpIdseq("99BA9DC8-5B9F-4E69-E034-080020C9C0E0");
        formValidValue.setDisplayOrder(100);

        //String res = test.createFormValidValueComponent(formValidValue);
        //System.out.println("\n*****Create Valid Value Result 2: " + res);

        //Test a List
        List list = new ArrayList();
        list.add(formValidValue);
        test.createFormValidValueComponents(list, "99CD59C6-17B8-3FA4-E034-080020C9C0E0");

    } catch (DMLException de) {
        de.printStackTrace();
    }

    /*     
    // test for deleteQuestion
    try {
      int res = test.deleteFormValidValue("D472B2E9-BB01-21C2-E034-0003BA0B1A09");
      System.out.println("\n*****Delete Valid Value Result 1: " + res);
    }
    catch (DMLException de) {
      de.printStackTrace();
    }
    */
    // test for updateDisplayOrder
    /* try {
       int res = test.updateDisplayOrder("D458E178-32A5-7522-E034-0003BA0B1A09", 7);
       System.out.println("\n*****Update Display Order 1: " + res);
     }
     catch (DMLException de) {
       de.printStackTrace();
     }
     */
}

From source file:Main.java

public static Bitmap getImageThumbnail(Bitmap input) {
    int desiredWidth = 500;
    Float width = new Float(input.getWidth());
    Float height = new Float(input.getHeight());
    Float ratio = width / height;
    return Bitmap.createScaledBitmap(input, (int) (desiredWidth * ratio), desiredWidth, false);
}

From source file:Main.java

public static Object wrapperClassCloner(Object value) {
    if (value instanceof Double)
        return new Double(((Double) value).doubleValue());
    else if (value instanceof Float)
        return new Float(((Float) value).floatValue());
    else if (value instanceof Long)
        return new Long(((Long) value).longValue());
    else if (value instanceof Boolean)
        return new Boolean(((Boolean) value).booleanValue());
    else if (value instanceof Integer)
        return new Integer(((Integer) value).intValue());
    else/*from w  ww.j a v  a  2s  .c o  m*/
        return null;
}

From source file:Main.java

public static String convertByte(long size) {
    DecimalFormat df = new DecimalFormat("###.##");
    float f;/*www  . ja  va  2s . c o m*/
    if (size < 1024 * 1024) {
        f = (float) ((float) size / (float) 1024);
        return (df.format(new Float(f).doubleValue()) + "KB");
    } else {
        f = (float) ((float) size / (float) (1024 * 1024));
        return (df.format(new Float(f).doubleValue()) + "MB");
    }
}

From source file:Main.java

public static void setRaiting(Activity r, final RatingBar v, final String value) {
    r.runOnUiThread(new Runnable() {
        @Override/*from  w  ww  .j a  v  a  2s .c  o m*/
        public void run() {
            try {
                v.setRating(new Float(value));
            } catch (Exception e) {
            }
        }
    });
}

From source file:Main.java

public static String setFileSize(long size) {
    DecimalFormat df = new DecimalFormat("###.##");
    float f = ((float) size / (float) (1024 * 1024));

    if (f < 1.0) {
        float f2 = ((float) size / (float) (1024));

        return df.format(new Float(f2).doubleValue()) + "KB";

    } else {/*from w  w w .j  a  va  2  s . com*/
        return df.format(new Float(f).doubleValue()) + "M";
    }
}

From source file:Main.java

public static float getFloatProperty(Element properties, String name) {
    return new Float(getPropertyNode(properties, name).getAttributes().getNamedItem(FLOAT_ATTR).getNodeValue());
}

From source file:Main.java

public static double getFloatProperty(Element properties, String name) {
    return new Float(getPropertyNode(properties, name).getAttributes().getNamedItem(FLOAT_ATTR).getNodeValue());
}

From source file:Main.java

public static Object getPropertyValue(Element element) {
    NamedNodeMap map = element.getAttributes();
    map.removeNamedItem(NAME_ATTR);//  w  w w . jav a2  s  . c o m

    if (map.item(0).getNodeName().equals(STRING_ATTR))
        return map.item(0).getNodeValue();
    else if (map.item(0).getNodeName().equals(INTEGER_ATTR))
        return new Integer(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(DOUBLE_ATTR))
        return new Double(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(FLOAT_ATTR))
        return new Float(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(BOOLEAN_ATTR))
        return Boolean.valueOf(map.item(0).getNodeValue());
    else if (map.item(0).getNodeName().equals(COLOR_ATTR)) {
        String[] rgb = map.item(0).getNodeValue().split(",");
        return new Color(new Integer(rgb[0]), new Integer(rgb[1]), new Integer(rgb[2]));
    } else if (map.item(0).getNodeName().equals(FONT_ATTR)) {
        String[] font = map.item(0).getNodeValue().split(",");
        return new Font(font[0], new Integer(font[1]), new Integer(font[2]));
    } else {
        return null;
    }
}