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:gov.nih.nci.caintegrator.ui.graphing.chart.plot.PrincipalComponentAnalysisPlot.java

/**
 * Build the legend/*from   w w w.  ja  v a 2 s . c  o m*/
 *
 */
protected void buildLegend() {

    LegendTitle legend = pcaChart.getLegend();
    LegendItemSource[] sources = new LegendItemSource[1];
    PcaLegendItemSource legendSrc = new PcaLegendItemSource();
    LegendItem item = null;

    //Rect=survival less than 10 months
    item = new LegendItem("Survival less than 10 months", null, null, null, new Rectangle2D.Double(0, 0, 8, 8),
            Color.BLACK);
    legendSrc.addLegendItem(item);

    //Circle=survival 10 months or more
    item = new LegendItem("Survival over 10 months", null, null, null, new Ellipse2D.Double(0, 0, 8, 8),
            Color.BLACK);
    legendSrc.addLegendItem(item);

    //Triangle if data if survival data is missing
    GeneralPath triangle = new GeneralPath();
    //     triangle.moveTo(1.0f,0.0f);
    //     triangle.moveTo(0.0f,1.0f);
    //     triangle.moveTo(1.0f,1.0f);
    triangle.moveTo(0.0f, -4.0f);
    triangle.lineTo(4.0f, 4.0f);
    triangle.lineTo(-4.0f, 4.0f);
    triangle.closePath();
    //triangle.closePath();
    item = new LegendItem("Survival Unknown", null, null, null, triangle, Color.BLACK);
    legendSrc.addLegendItem(item);

    //Diamond=survival N/A, for non_tumor/normal
    Shape r = new Rectangle2D.Double(0, 0, 8, 8);
    Shape d = ShapeUtilities.rotateShape(r, new Double(0.785398163), new Float(0), new Float(0));
    item = new LegendItem("Survival N/A", null, null, null, d, Color.BLACK);
    legendSrc.addLegendItem(item);

    if (colorBy == PCAcolorByType.Disease) {
        //go through the disease color map and add legend items
        String diseaseName = null;
        Color diseaseColor = null;
        DiseaseType[] diseases = DiseaseType.values();
        for (int i = 0; i < diseases.length; i++) {
            diseaseName = diseases[i].name();
            if (diseases[i].equals(DiseaseType.UNCLASSIFIED)) {
                continue; //remove unclassified from the legend
            }
            diseaseColor = diseases[i].getColor();
            item = new LegendItem(diseaseName, null, null, null, new Line2D.Double(0, 0, 6, 6),
                    new BasicStroke(3.0f), diseaseColor);
            //item = new LegendItem(diseaseName, null, null, null, new Rectangle2D.Double(0,0,6,6), diseaseColor);
            legendSrc.addLegendItem(item);
        }
        //      item = new LegendItem("Unknown", null, null, null, new Line2D.Double(0,0,6,6), new BasicStroke(3.0f), Color.GRAY);
        //      legendSrc.addLegendItem(item);
    } else if (colorBy == PCAcolorByType.Gender) {
        String genderName = null;
        Color genderColor = null;
        GenderType[] genderTypes = GenderType.values();
        for (int i = 0; i < genderTypes.length; i++) {
            genderName = genderTypes[i].toString();
            genderColor = genderTypes[i].getColor();
            item = new LegendItem(genderName, null, null, null, new Line2D.Double(0, 0, 6, 6),
                    new BasicStroke(3.0f), genderColor);
            legendSrc.addLegendItem(item);
        }
        //        item = new LegendItem("Male", null, null, null, new Line2D.Double(0,0,6,6), new BasicStroke(3.0f), Color.BLUE);
        //        legendSrc.addLegendItem(item);
        //        item = new LegendItem("Female", null, null, null, new Line2D.Double(0,0,6,6), new BasicStroke(3.0f), Color.PINK);
        //        legendSrc.addLegendItem(item);
        //        item = new LegendItem("Unknown", null, null, null, new Line2D.Double(0,0,6,6), new BasicStroke(3.0f),Color.GRAY);
        //        legendSrc.addLegendItem(item);
    }

    sources[0] = legendSrc;
    legend.setSources(sources);
}

From source file:com.wxxr.nirvana.json.JSONInterceptorTest.java

public void testSMDPrimitivesNoResult() throws Exception {
    // request//  w  ww  .  ja v  a  2s.c  o  m
    setRequestContent("smd-6.txt");
    this.request.addHeader("content-type", "application/json-rpc");

    JSONInterceptor interceptor = new JSONInterceptor();
    interceptor.setEnableSMD(true);
    SMDActionTest1 action = new SMDActionTest1();

    this.invocation.setAction(action);

    // can't be invoked
    interceptor.intercept(this.invocation);
    assertFalse(this.invocation.isInvoked());

    // asert values were passed properly
    assertEquals("string", action.getStringParam());
    assertEquals(1, action.getIntParam());
    assertEquals(true, action.isBooleanParam());
    assertEquals('c', action.getCharParam());
    assertEquals(2, action.getLongParam());
    assertEquals(new Float(3.3), action.getFloatParam());
    assertEquals(4.4, action.getDoubleParam());
    assertEquals(5, action.getShortParam());
    assertEquals(6, action.getByteParam());

    String json = response.getContentAsString();

    String normalizedActual = TestUtils.normalize(json, true);
    String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
    assertEquals(normalizedExpected, normalizedActual);

    assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
}

From source file:com.redhat.rhn.manager.monitoring.MonitoringManager.java

/**
 * Get the timeseries data for a probe// w  w  w .j a  v  a 2  s.  c o m
 * @param probeIn probe we want data for
 * @param metricId probe metric we are going to search for
 * @param startTime start time to lookup
 * @param endTime end time to lookup
 * @return array of TimeSeriesData DTO objects
 */
public TimeSeriesData[] getProbeData(Probe probeIn, String metricId, Timestamp startTime, Timestamp endTime) {

    SelectMode tsMode = ModeFactory.getMode("Monitoring_queries", "time_series_for_probe");
    // Convert to minutes from millis
    Long startMinutes = new Long(startTime.getTime() / 1000);
    Long endMinutes = new Long(endTime.getTime() / 1000);

    Map<String, Object> params = new HashMap<String, Object>();
    //Must concat the values together
    //to produce the oid: 1-3-pctfree
    //     orgId-probeId-metric
    StringBuilder oid = new StringBuilder();
    oid.append(probeIn.getOrg().getId());
    oid.append("-");
    oid.append(probeIn.getId());
    oid.append("-");
    oid.append(metricId);
    params.put("oid", oid.toString());
    params.put("start_time", startMinutes);
    params.put("end_time", endMinutes);
    log.debug("Params: " + params);
    DataResult dr = tsMode.execute(params);
    log.debug("results: " + dr);
    if (dr.size() == 0) {
        return null;
    }

    Iterator i = dr.iterator();
    List retval = new LinkedList();
    while (i.hasNext()) {
        Map row = (Map) i.next();
        // Have to multiply by 1000 since
        // this table stores the data as seconds since 1970,
        // not millis.
        Timestamp entryTime = new Timestamp(((Long) row.get("entry_time")).longValue() * 1000);
        String sdata = (String) row.get("data");

        if (sdata == null) {
            sdata = "0.0";
        }
        Float data = new Float(sdata);
        TimeSeriesData tsd = new TimeSeriesData(oid.toString(), data, entryTime, metricId);
        retval.add(tsd);
    }
    return (TimeSeriesData[]) retval.toArray(new TimeSeriesData[0]);
}

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

public void setFloat(String arg0, float arg1) throws JMSException {
    body.put(arg0, new Float(arg1));

}

From source file:com.turn.shapeshifter.NamedSchemaParser.java

/**
 * Reads the value of a JSON node and returns the corresponding Java object.
 *
 * @param jsonNode the node to convert to a Java object
 * @param field the protocol buffer field to which the resulting value will be assigned
 * @param registry a schema registry in which enclosed message fields are expected to
 * be defined/*from  w ww . ja  v a  2s. c o m*/
 * @return a Java object representing the field's value
 * @throws ParsingException In case the JSON node cannot be parsed
 * @throws UnmappableValueException in case the JSON value node cannot be converted
 * to a Java object that could be assigned to {@code field}
 */
private Object parseValue(JsonNode jsonNode, FieldDescriptor field, ReadableSchemaRegistry registry)
        throws ParsingException {
    Object value = null;
    if (schema.getTransforms().containsKey(field.getName())) {
        return schema.getTransforms().get(field.getName()).parse(jsonNode);
    }
    switch (field.getType()) {
    case BOOL:
        JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_BOOLEAN_TOKENS);
        value = Boolean.valueOf(jsonNode.asBoolean());
        break;
    case BYTES:
        JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_STRING_TOKENS);
        String content = jsonNode.asText();
        byte[] bytes = new byte[content.length()];
        for (int i = 0; i < content.length(); i++) {
            bytes[i] = (byte) content.charAt(i);
        }
        value = ByteString.copyFrom(bytes);
        break;
    case DOUBLE:
        value = new Double(jsonNode.asDouble());
        break;
    case ENUM:
        JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_ENUM_TOKENS);
        String enumValue = schema.getEnumCaseFormat().to(NamedSchema.PROTO_ENUM_CASE_FORMAT, jsonNode.asText());
        value = field.getEnumType().findValueByName(enumValue);
        break;
    case FLOAT:
        JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_FLOAT_TOKENS);
        value = new Float(jsonNode.asDouble());
        break;
    case GROUP:
        break;
    case FIXED32:
    case INT32:
    case SFIXED32:
    case SINT32:
    case UINT32:
        JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_INTEGER_TOKENS);
        value = new Integer(jsonNode.asInt());
        break;
    case FIXED64:
    case INT64:
    case SFIXED64:
    case SINT64:
    case UINT64:
        if (schema.getSurfaceLongsAsStrings()) {
            JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_STRING_TOKENS);
            String longValue = jsonNode.asText();
            value = Long.parseLong(longValue);
        } else {
            JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_INTEGER_TOKENS);
            value = new Long(jsonNode.asLong());
        }
        break;
    case MESSAGE:
        if (!jsonNode.isObject()) {
            throw new IllegalArgumentException(
                    "Expected to parse object, found value of type " + jsonNode.asToken());
        }
        Schema subSchema = null;
        if (schema.getSubObjectsSchemas().containsKey(field.getName())) {
            String schemaName = schema.getSubObjectsSchemas().get(field.getName());
            if (registry.contains(schemaName)) {
                subSchema = registry.get(schemaName);
            } else {
                throw new IllegalStateException();
            }
        } else {
            try {
                subSchema = registry.get(field.getMessageType());
            } catch (SchemaObtentionException soe) {
                throw new ParsingException(soe);
            }
        }
        value = subSchema.getParser().parse(jsonNode, registry);
        break;
    case STRING:
        JsonTokens.checkJsonValueConformance(jsonNode, JsonTokens.VALID_STRING_TOKENS);
        value = jsonNode.asText();
        break;
    default:
        break;
    }
    return value;
}

From source file:com.jaspersoft.jasperserver.remote.utils.RepositoryHelper.java

/**
 *  This method get a string and tries to convert the string into the requested object.
 *  Valid classes are:/*from  www .j a  va  2 s .  com*/
 *    java.util.Date (the string is supposed to represent a number of milliseconds)
 *    Number
 *    BigDecimal
 *    Byte
 *    Short
 *    Integer
 *    Long
 *    Float
 *    Double
 *    Boolean
 *    String
 *    java.util.Locale
 * 
 *  The default returned object is of type String
 * @param str the string representing the value
 * @param clazz The class of the result (not garanteed)
 * @return return an Object hopefully of the requested class (or a String)
 * 
 */
public static Object stringToValue(String str, Class clazz) {
    Object value = str;
    if (value == null) {
        return value;
    }

    if (java.util.Date.class.getName().equals(clazz.getName())) {
        value = new java.util.Date(Long.valueOf(value.toString()).longValue());
    } else if (java.sql.Date.class.getName().equals(clazz.getName())) {
        value = new java.sql.Date(Long.valueOf(value.toString()).longValue());
    } else if (java.sql.Timestamp.class.getName().equals(clazz.getName())) {
        value = new java.sql.Timestamp(Long.valueOf(value.toString()).longValue());
    } else if (Number.class.isAssignableFrom(clazz)) {
        value = new java.math.BigDecimal(value.toString());
        if (Byte.class.getName().equals(clazz.getName())) {
            value = new Byte(((Number) value).byteValue());
        } else if (Short.class.getName().equals(clazz.getName())) {
            value = new Short(((Number) value).shortValue());
        } else if (Integer.class.getName().equals(clazz.getName())) {
            value = new Integer(((Number) value).intValue());
        } else if (Long.class.getName().equals(clazz.getName())) {
            value = new Long(((Number) value).longValue());
        } else if (Float.class.getName().equals(clazz.getName())) {
            value = new Float(((Number) value).floatValue());
        } else if (Double.class.getName().equals(clazz.getName())) {
            value = new Double(((Number) value).doubleValue());
        }
    } else if (Boolean.class.getName().equals(clazz.getName())) {
        value = Boolean.valueOf(value.toString());
    } else if (Locale.class.getName().equals(clazz.getName())) {
        value = LocaleHelper.getInstance().getLocale(str);
    } else if (DateRange.class.equals(clazz)) {
        try {
            value = DateRangeFactory.getInstance(str, Date.class);
        } catch (InvalidDateRangeExpressionException e) {
            //if DateRange passed as string with milliseconds we need to parse it
            Date dateValue = (Date) stringToValue(str, Date.class);
            value = DateRangeFactory.getInstance(dateValue);
        }
    } else if (TimestampRange.class.equals(clazz)) {
        try {
            value = DateRangeFactory.getInstance(str, Timestamp.class);
        } catch (InvalidDateRangeExpressionException e) {
            //if TimestampRange passed as string with milliseconds we need to parse it
            Timestamp timestamp = (Timestamp) stringToValue(str, Timestamp.class);
            value = DateRangeFactory.getInstance(timestamp);
        }
    }
    return value;
}

From source file:com.edmunds.autotest.AutoTestGetterSetter.java

private static Map<Class<?>, Object> createValueMap() {
    Map<Class<?>, Object> valueMap = new HashMap<Class<?>, Object>();

    valueMap.put(byte.class, new Byte((byte) 40));
    valueMap.put(short.class, new Short((short) 41));
    valueMap.put(int.class, new Integer(42));
    valueMap.put(long.class, new Long(43));
    valueMap.put(float.class, new Float(44));
    valueMap.put(double.class, new Double(45));
    valueMap.put(boolean.class, Boolean.TRUE);
    valueMap.put(char.class, new Character((char) 46));

    valueMap.put(Byte.class, new Byte((byte) 40));
    valueMap.put(Short.class, new Short((short) 41));
    valueMap.put(Integer.class, new Integer(42));
    valueMap.put(Long.class, new Long(43));
    valueMap.put(Float.class, new Float(44));
    valueMap.put(Double.class, new Double(45));
    valueMap.put(Boolean.class, Boolean.TRUE);
    valueMap.put(Character.class, new Character((char) 46));

    return valueMap;
}

From source file:com.mortardata.pig.storage.DynamoDBStorage.java

/** FRONTEND and BACKEND **/
@Override//from   w w w .ja  v  a  2  s  . c  o  m
public void setStoreLocation(String location, Job job) throws IOException {
    this.hadoopJobInfo = loadHadoopJobInfo(job);
    Configuration conf = this.hadoopJobInfo.getJobConfiguration();
    this.maxRetryWaitMilliseconds = conf.getLong(MAX_RETRY_WAIT_MILLISECONDS_PROPERTY,
            MAX_RETRY_WAIT_MILLISECONDS_DEFAULT);
    this.maxNumRetriesPerBatchWrite = conf.getInt(MAX_NUM_RETRIES_PER_BATCH_WRITE_PROPERTY,
            MAX_NUM_RETRIES_PER_BATCH_WRITE);
    this.throughputWritePercent = new Float(
            conf.getFloat(THROUGHPUT_WRITE_PERCENT_PROPERTY, THROUGHPUT_WRITE_PERCENT_DEFAULT)).doubleValue();
    if (this.throughputWritePercent < 0.1 || this.throughputWritePercent > 1.5) {
        throw new IOException(THROUGHPUT_WRITE_PERCENT_PROPERTY + " must be between 0.1 and 1.5.  Got: "
                + this.throughputWritePercent);
    }

    this.minBatchSize = conf.getInt(MINIMUM_BATCH_SIZE_PROPERTY, MINIMUM_BATCH_SIZE_DEFAULT);
    if (this.minBatchSize < 1 || this.minBatchSize > DYNAMO_MAX_ITEMS_IN_BATCH_WRITE_REQUEST) {
        throw new IOException(MINIMUM_BATCH_SIZE_PROPERTY + " must be between 1 and "
                + DYNAMO_MAX_ITEMS_IN_BATCH_WRITE_REQUEST + ". Got: " + this.minBatchSize);
    }
}

From source file:org.n52.oxf.render.sos.TimeSeriesMapChartRenderer.java

/**
 * The resulting chart consists a TimeSeries for each FeatureOfInterest contained in the
 * observationCollection.//from w  w w. j a  v  a  2 s  .c o m
 * 
 * @param foiIdArray
 *        the IDs of the FeaturesOfInterest whose Observations shall be rendered
 * @param observationCollection
 * @return
 */
protected XYPlot drawChart4FOI(String foiID, Map<ITimePosition, ObservedValueTuple> timeMap) {

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    TimeSeries timeSeries = new TimeSeries(foiID, Second.class);

    for (ITimePosition timePos : timeMap.keySet()) {
        Number value = (Number) timeMap.get(timePos).getValue(0);
        timeSeries.add(
                new Second(new Float(timePos.getSecond()).intValue(), timePos.getMinute(), timePos.getHour(),
                        timePos.getDay(), timePos.getMonth(), new Long(timePos.getYear()).intValue()),
                value);
    }

    dataset.addSeries(timeSeries);
    dataset.setDomainIsPointsInTime(true);

    //
    // create Plot:
    //

    XYPlot plot = new XYPlot();

    plot.setDataset(dataset);
    plot.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);

    DateAxis dateAxis = new DateAxis();
    dateAxis.setTickMarkPosition(DateTickMarkPosition.START);
    dateAxis.setTickMarksVisible(true);
    dateAxis.setVerticalTickLabels(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("dd'.'MM'.'"));
    plot.setDomainAxis(dateAxis);

    plot.setRangeAxis(new NumberAxis());

    return plot;
}

From source file:io.jeandavid.projects.vod.entities.DvdOrder.java

public void computePrice() {
    Float result = new Float(0);
    for (DvdOrderDvd dvdOrderDvd : dvdOrderDvds) {
        result += dvdOrderDvd.computePrice();
    }/*from   ww w  .j ava2  s.c  o  m*/
    this.price = result;
}