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:com.ushahidi.swiftriver.core.api.dao.impl.JpaRiverDaoTest.java

@Test
public void getDropsSince() {
    Account account = accountDao.findById(1L);
    DropFilter filter = new DropFilter();
    filter.setSinceId(3L);/*w w w. j  a va 2  s .  c o  m*/
    List<Drop> drops = riverDao.getDrops(1L, filter, 1, 1, account);

    assertEquals(1, drops.size());

    Drop drop = drops.get(0);
    assertTrue(drop.getId() > 3);
    assertEquals(false, drop.getRead());
    assertEquals("twitter", drop.getChannel());
    assertEquals("droplet 4 title", drop.getTitle());
    assertEquals("droplet 4 content", drop.getContent());
    assertEquals("4", drop.getOriginalId());
    assertEquals(25, drop.getCommentCount());
    assertEquals(2, drop.getIdentity().getId());
    assertEquals("identity2_name", drop.getIdentity().getName());
    assertEquals("identity2_avatar", drop.getIdentity().getAvatar());
    assertNotNull(drop.getOriginalUrl());
    assertEquals(3, drop.getOriginalUrl().getId());
    assertEquals("http://www.bbc.co.uk/nature/20273855", drop.getOriginalUrl().getUrl());

    assertEquals(1, drop.getTags().size());
    Tag tag = drop.getTags().get(0);
    assertEquals(1, tag.getId());
    assertEquals("Jeremy Hunt", tag.getTag());
    assertEquals("person", tag.getType());

    assertEquals(1, drop.getLinks().size());
    Link link = drop.getLinks().get(0);
    assertEquals(10, link.getId());
    assertEquals("http://www.bbc.co.uk/sport/0/football/20319573", link.getUrl());

    assertEquals(1, drop.getMedia().size());
    Media media = drop.getMedia().get(0);
    assertEquals(1, media.getId());
    assertEquals("http://gigaom2.files.wordpress.com/2012/10/datacapspercentage.jpeg", media.getUrl());
    assertEquals("image", media.getType());

    assertEquals(2, media.getThumbnails().size());
    MediaThumbnail thumbnail = media.getThumbnails().get(0);
    assertEquals(
            "https://2bcbd22fbb0a02d76141-1680e9dfed1be27cdc47787ec5d4ef89.ssl.cf1.rackcdn.com/625dd7cb656d258b4effb325253e880631699d80345016e9e755b4a04341cda1.peg",
            thumbnail.getUrl());
    assertEquals(80, thumbnail.getSize());

    assertEquals(1, drop.getPlaces().size());
    Place place = drop.getPlaces().get(0);
    assertEquals(1, place.getId());
    assertEquals("Wales", place.getPlaceName());
    assertEquals(new Float(146.11), place.getLongitude());
    assertEquals(new Float(-33), place.getLatitude());

}

From source file:gui.TwopointPWDPanelnonsnp.java

private void appendMarker(CMarker m, PhasePair pp) {
    // Update the values in the table
    Object[] row = { m.safeName.substring(3), m, new Float(pp.rfq), new Float(pp.lod) };

    phaseModel.addRow(row);/* w w w.j  a v a2 s .c  o  m*/

    rfqChart.dataset.addValue(pp.rfq, "", m.safeName.substring(3));
    lodChart.dataset.addValue(pp.lod, "", m.safeName.substring(3));
}

From source file:Coordinate.java

/**
 * A method to add distance in an easterly direction to a coordinate
 *
 * @param latitude  a latitude coordinate in decimal notation
 * @param longitude a longitude coordinate in decimal notation
 * @param distance  the distance to add in metres
 *
 * @return          the new coordinate// ww  w. ja  va  2 s  . co m
 */
public static Coordinate addDistanceEast(float latitude, float longitude, int distance) {

    // check on the parameters
    if (isValidLatitude(latitude) == false || isValidLongitude(longitude) == false || distance <= 0) {
        throw new IllegalArgumentException("All parameters are required and must be valid");
    }

    // convert the distance from metres to kilometers
    float kilometers = distance / 1000;

    // calculate the new longitude
    double newLng = longitude + (distance / longitudeConstant(latitude));

    return new Coordinate(latitude, new Float(newLng).floatValue());
}

From source file:edu.umd.umiacs.clip.tools.classifier.LibSVMUtils.java

public static Triple<String, List<Pair<Integer, Float>>, String> split(String line) {
    String[] fields = line.split(" ");
    if (fields[0].isEmpty() || fields.length == 1) {
        return Triple.of(fields[0], asList(), "");
    }/*from   ww  w. jav  a2  s .c o  m*/
    StringBuilder prefix = new StringBuilder();
    int i = 0;
    for (; i < fields.length; i++) {
        int index = fields[i].indexOf(":");
        if (index < 0 || !fields[i].substring(0, index).matches("[0-9]+")) {
            prefix.append(fields[i]).append(" ");
        } else {
            break;
        }
    }

    List<Pair<Integer, Float>> pairs = new ArrayList<>();

    for (; i < fields.length; i++) {
        if (fields[i].startsWith("#")) {
            break;
        }
        int index = fields[i].indexOf(":");
        pairs.add(
                Pair.of(new Integer(fields[i].substring(0, index)), new Float(fields[i].substring(index + 1))));
    }

    StringBuilder suffix = new StringBuilder();
    for (; i < fields.length; i++) {
        suffix.append(" ").append(fields[i]);
    }

    return Triple.of(prefix.toString(), pairs, suffix.toString());
}

From source file:gui.TwopointPWDPanel.java

private void appendMarker(CMarker m, PhasePair pp) {
    Object[] row = { Integer.parseInt(m.safeName.substring(3)) + "", m, new Float(pp.rfq), new Float(pp.lod) };

    phaseModel.addRow(row);/*w w  w  . ja v  a 2s  .  c o m*/

    rfqChart.dataset.addValue(pp.rfq, "", m.safeName.substring(3));
    lodChart.dataset.addValue(pp.lod, "", m.safeName.substring(3));
}

From source file:BasicPlayer.java

/**
 * Inits AudioInputStream and AudioFileFormat from the data source.
 * @throws BasicPlayerException//  ww  w . j av a 2s.  c  om
 */
protected void initAudioInputStream() throws BasicPlayerException {
    try {
        reset();
        notifyEvent(BasicPlayerEvent.OPENING, getEncodedStreamPosition(), -1, m_dataSource);
        if (m_dataSource instanceof URL) {
            initAudioInputStream((URL) m_dataSource);
        } else if (m_dataSource instanceof File) {
            initAudioInputStream((File) m_dataSource);
        } else if (m_dataSource instanceof InputStream) {
            initAudioInputStream((InputStream) m_dataSource);
        }
        createLine();
        // Notify listeners with AudioFileFormat properties.
        Map properties = null;
        if (m_audioFileFormat instanceof TAudioFileFormat) {
            // Tritonus SPI compliant audio file format.
            properties = ((TAudioFileFormat) m_audioFileFormat).properties();
            // Clone the Map because it is not mutable.
            properties = deepCopy(properties);
        } else
            properties = new HashMap();
        // Add JavaSound properties.
        if (m_audioFileFormat.getByteLength() > 0)
            properties.put("audio.length.bytes", new Integer(m_audioFileFormat.getByteLength()));
        if (m_audioFileFormat.getFrameLength() > 0)
            properties.put("audio.length.frames", new Integer(m_audioFileFormat.getFrameLength()));
        if (m_audioFileFormat.getType() != null)
            properties.put("audio.type", (m_audioFileFormat.getType().toString()));
        // Audio format.
        AudioFormat audioFormat = m_audioFileFormat.getFormat();
        if (audioFormat.getFrameRate() > 0)
            properties.put("audio.framerate.fps", new Float(audioFormat.getFrameRate()));
        if (audioFormat.getFrameSize() > 0)
            properties.put("audio.framesize.bytes", new Integer(audioFormat.getFrameSize()));
        if (audioFormat.getSampleRate() > 0)
            properties.put("audio.samplerate.hz", new Float(audioFormat.getSampleRate()));
        if (audioFormat.getSampleSizeInBits() > 0)
            properties.put("audio.samplesize.bits", new Integer(audioFormat.getSampleSizeInBits()));
        if (audioFormat.getChannels() > 0)
            properties.put("audio.channels", new Integer(audioFormat.getChannels()));
        if (audioFormat instanceof TAudioFormat) {
            // Tritonus SPI compliant audio format.
            Map addproperties = ((TAudioFormat) audioFormat).properties();
            properties.putAll(addproperties);
        }
        // Add SourceDataLine
        properties.put("basicplayer.sourcedataline", m_line);
        Iterator it = m_listeners.iterator();
        while (it.hasNext()) {
            BasicPlayerListener bpl = (BasicPlayerListener) it.next();
            bpl.opened(m_dataSource, properties);
        }
        m_status = OPENED;
        notifyEvent(BasicPlayerEvent.OPENED, getEncodedStreamPosition(), -1, null);
    } catch (LineUnavailableException e) {
        throw new BasicPlayerException(e);
    } catch (UnsupportedAudioFileException e) {
        throw new BasicPlayerException(e);
    } catch (IOException e) {
        throw new BasicPlayerException(e);
    }
}

From source file:hermes.providers.messages.MessageImpl.java

public void setFloatProperty(String arg0, float arg1) throws JMSException {
    header.put(arg0, new Float(arg1));
}

From source file:nz.co.senanque.validationengine.ValidationUtils.java

public static Comparable<?> convertTo(final Class<Comparable<?>> clazz, Object obj) {
    if (obj == null) {
        return null;
    }//  w  w  w .j av a2  s . c om
    if (clazz.isAssignableFrom(obj.getClass())) {
        return (Comparable<?>) obj;
    }
    final String oStr = String.valueOf(obj);
    if (clazz.equals(String.class)) {
        return oStr;
    }
    if (clazz.equals(Long.class) || clazz.equals(Long.TYPE)) {
        if (Number.class.isAssignableFrom(obj.getClass())) {
            return new Long(((Number) obj).longValue());
        }
        return Long.valueOf(oStr);
    }
    if (clazz.equals(Integer.class) || clazz.equals(Integer.TYPE)) {
        if (Number.class.isAssignableFrom(obj.getClass())) {
            return new Integer(((Number) obj).intValue());
        }
        return Integer.valueOf(oStr);
    }
    if (clazz.equals(Double.class) || clazz.equals(Double.TYPE)) {
        if (Number.class.isAssignableFrom(obj.getClass())) {
            return new Double(((Number) obj).doubleValue());
        }
        return Double.valueOf(oStr);
    }
    if (clazz.equals(Float.class) || clazz.equals(Float.TYPE)) {
        if (Number.class.isAssignableFrom(obj.getClass())) {
            return new Float(((Number) obj).floatValue());
        }
        return Float.valueOf(oStr);
    }
    if (clazz.equals(BigDecimal.class)) {
        return new BigDecimal(oStr);
    }
    if (clazz.equals(java.util.Date.class)) {
        return java.sql.Date.valueOf(oStr);
    }
    if (clazz.equals(java.sql.Date.class)) {
        return java.sql.Date.valueOf(oStr);
    }
    return null;
}

From source file:blue.orchestra.blueSynthBuilder.BSBLineObject.java

public void setXMax(float max) {
    float oldMax = xMax;
    xMax = max;/*from w  w w. ja v  a  2 s  .co m*/

    if (propListeners != null) {
        propListeners.firePropertyChange("yMax", new Float(oldMax), new Float(xMax));
    }
}

From source file:jp.terasoluna.fw.web.struts.reset.ResetterImpl.java

/**
 * ANVtH?[wv?peBZbg?B//from w w w . j  ava2 s.  co m
 * v?peB^boolean^?ABoolean^??false??B
 * v~eBu^bp?[^???A0??B
 * v?peB^bp?[^OObject^??null??B<br>
 * ??A?entrynulln?B
 *
 * @param form ?NGXggpANVtH?[
 * @param entry Zbg?v?peB?lGg
 * @throws PropertyAccessException v?peBl?s??
 */
protected void resetValue(FormEx form, Entry<String, Object> entry) {
    if (log.isDebugEnabled()) {
        log.debug("resetValue(" + form + ", " + entry.getKey() + ") called.");
    }
    String propName = entry.getKey();
    try {
        Object value = entry.getValue();
        if (value == null) {
            return;
        }
        Class type = null;
        type = value.getClass();
        if (type != null) {
            // ^???B
            if (type == Boolean.TYPE || type == Boolean.class) {
                BeanUtil.setBeanProperty(form, propName, Boolean.FALSE);
            } else if (type == Byte.TYPE || type == Byte.class) {
                BeanUtil.setBeanProperty(form, propName, new Byte((byte) 0));
            } else if (type == Character.TYPE || type == Character.class) {
                BeanUtil.setBeanProperty(form, propName, new Character((char) 0));
            } else if (type == Double.TYPE || type == Double.class) {
                BeanUtil.setBeanProperty(form, propName, new Double(0.0));
            } else if (type == Float.TYPE || type == Float.class) {
                BeanUtil.setBeanProperty(form, propName, new Float((float) 0.0));
            } else if (type == Integer.TYPE || type == Integer.class) {
                BeanUtil.setBeanProperty(form, propName, new Integer(0));
            } else if (type == Long.TYPE || type == Long.class) {
                BeanUtil.setBeanProperty(form, propName, new Long(0));
            } else if (type == Short.TYPE || type == Short.class) {
                BeanUtil.setBeanProperty(form, propName, new Short((short) 0));
            } else {
                // v~eBu^?Abp?[^??null?
                BeanUtil.setBeanProperty(form, propName, null);
            }
        }
    } catch (PropertyAccessException e) {
        log.error("cannot access property " + form + "." + propName, e);
    }
}