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.yahoo.egads.models.adm.NaiveModel.java

public NaiveModel(Properties config) {
    super(config);

    if (config.getProperty("MAX_ANOMALY_TIME_AGO") == null) {
        throw new IllegalArgumentException("MAX_ANOMALY_TIME_AGO is NULL");
    }/*from w  w w. jav  a  2s  .  co m*/
    this.maxHrsAgo = new Integer(config.getProperty("MAX_ANOMALY_TIME_AGO"));
    if (config.getProperty("WINDOW_SIZE") == null) {
        throw new IllegalArgumentException("WINDOW_SIZE is NULL");
    }
    this.window_size = new Float(config.getProperty("WINDOW_SIZE"));
    if (config.getProperty("THRESHOLD") == null) {
        throw new IllegalArgumentException("THRESHOLD is NULL");
    }
    this.threshold = parseMap(config.getProperty("THRESHOLD"));
    if (config.getProperty("THRESHOLD") != null && this.threshold.isEmpty() == true) {
        throw new IllegalArgumentException("THRESHOLD PARSE ERROR");
    }
}

From source file:blue.Marker.java

public void setTime(float time) {
    float oldVal = this.time;

    this.time = time;

    PropertyChangeEvent pce = new PropertyChangeEvent(this, "time", new Float(oldVal), new Float(time));

    firePropertyChangeEvent(pce);/*  w ww  .ja v  a  2  s  .  c o m*/
}

From source file:org.openmrs.module.vcttrac.web.view.chart.VCTVersusPITChartView.java

@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {

    DefaultPieDataset pieDataset = new DefaultPieDataset();

    VCTModuleService service = Context.getService(VCTModuleService.class);

    try {/* w  w  w  .ja  v a  2s. co  m*/
        Date reportingDate = new Date();
        int numberOfClientInVCT = service.getNumberOfClientByVCTOrPIT(1, reportingDate);
        int numberOfClientInPIT = service.getNumberOfClientByVCTOrPIT(2, reportingDate);

        int all = numberOfClientInVCT + numberOfClientInPIT;

        Float percentageVCT = new Float(100 * numberOfClientInVCT / all);
        pieDataset.setValue(VCTTracUtil.getMessage("vcttrac.home.vctclient", null) + " (" + numberOfClientInVCT
                + " , " + percentageVCT + "%)", percentageVCT);

        Float percentagePIT = new Float(100 * numberOfClientInPIT / all);
        pieDataset.setValue(VCTTracUtil.getMessage("vcttrac.home.pitclient", null) + " (" + numberOfClientInPIT
                + " , " + percentagePIT + "%)", percentagePIT);

        JFreeChart chart = ChartFactory.createPieChart(
                VCTTracUtil.getMessage("vcttrac.home.vctclient", null) + " "
                        + VCTTracUtil.getMessage("vcttrac.graph.statistic.comparedto", null) + " "
                        + VCTTracUtil.getMessage("vcttrac.home.pitclient", null),
                pieDataset, true, true, false);

        return chart;
    } catch (Exception e) {
        log.error(">>VCT>>vs>>PIT>>PIE>>CHART>> " + e.getMessage());
        e.printStackTrace();
        return null;
    }
}

From source file:edu.umd.umiacs.clip.tools.scor.IndriBM25Scorer.java

@Override
public Object getProcessedQuery(String query) {
    String[] tokens = query.replace("(", "( ").replace(")", " ) ").replaceAll("\\s+\\(", "(").trim()
            .split("\\s+");
    List<Pair<List<Pair<String, Float>>, Float>> processed = new ArrayList<>();
    for (int i = 0; i < tokens.length; i++) {
        String token = tokens[i];
        if (token.startsWith("#syn(") || token.startsWith("#wsyn(")) {
            float df = 0;
            boolean isWeighted = token.startsWith("#wsyn(");
            List<Pair<String, Float>> list = new ArrayList<>();
            for (i++; i < tokens.length; i++) {
                token = tokens[i];// w w w  .  j av  a2 s . c o m
                if (token.equals(")")) {
                    break;
                }
                float weight = 1f;
                if (isWeighted) {
                    weight = new Float(tokens[i++]);
                    token = tokens[i];
                }
                list.add(Pair.of(token, weight));
                df += weight * df(token);
            }
            processed.add(Pair.of(list, idf(df)));
        } else {
            processed.add(Pair.of(asList(Pair.of(token, 1f)), idf(df(token))));
        }
    }
    return processed;
}

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

public Object sub(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.discursive.jccook.collections.lazy.LazyMapExample.java

public void start() throws Exception {

    StockQuoteTransformer sqTransformer = new StockQuoteTransformer();
    sqTransformer.setQuoteURL(new URL("http://quotes.company.com"));
    sqTransformer.setTimeout(500);//from   w  ww . j a va2  s  . c  om

    stockQuotes = new LRUMap(5);
    stockQuotes = LazyMap.decorate(stockQuotes, sqTransformer);

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

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

    // CSCO was the first price requested, it is therefor the
    // least recently used.
    if (!stockQuotes.containsKey("CSCO")) {
        System.out.println("As expected CSCO was discarded");
    }
}

From source file:blue.soundObject.pianoRoll.PianoNote.java

public void setDuration(float duration) {
    PropertyChangeEvent pce = new PropertyChangeEvent(this, "duration", new Float(this.duration),
            new Float(duration));
    this.duration = duration;
    firePropertyChange(pce);/*  w  w  w . j av a 2s.co  m*/
}

From source file:com.ibuildapp.romanblack.FanWallPlugin.data.JSONParser.java

/**
 * Parses JSON comments data.//from w  w  w.  java  2 s.c  o  m
 *
 * @param data JSON data to parse.
 * @return comments array
 */
public static ArrayList<FanWallMessage> parseMessagesString(String data) {
    try {
        String resp = data;

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

        if (resp.length() == 0) {
            return null;
        }

        JSONObject mainObject = new JSONObject(resp);

        JSONArray messagesJSON = mainObject.getJSONArray("posts");

        ArrayList<FanWallMessage> parsedMessages = new ArrayList<FanWallMessage>();

        for (int i = 0; i < messagesJSON.length(); i++) {
            JSONObject messageJSON = messagesJSON.getJSONObject(i);

            FanWallMessage tmpMessage = new FanWallMessage();
            tmpMessage.setId(new Long(messageJSON.getString("post_id")).longValue());
            tmpMessage.setAuthor(messageJSON.getString("user_name"));
            tmpMessage.setDate(new Date(new Long(messageJSON.getString("create")).longValue()));
            tmpMessage.setUserAvatarUrl(messageJSON.getString("user_avatar"));
            tmpMessage.setText(messageJSON.getString("text"));
            try {
                tmpMessage.setPoint(new Float(messageJSON.getString("latitude")).floatValue(),
                        new Float(messageJSON.getString("longitude")).floatValue());
            } catch (NumberFormatException nFEx) {
                Log.e("", "");
            }

            try {
                tmpMessage.setParentId(new Integer(messageJSON.getString("parent_id")).intValue());
            } catch (NumberFormatException nFEx) {
                Log.e("", "");
            }

            try {
                tmpMessage.setReplyId(new Integer(messageJSON.getString("reply_id")).intValue());
            } catch (NumberFormatException nFEx) {
                Log.e("", "");
            }

            tmpMessage.setTotalComments(new Integer(messageJSON.getString("total_comments")).intValue());

            JSONArray imagesJSON = messageJSON.getJSONArray("images");
            if (imagesJSON.length() > 0) {
                tmpMessage.setImageUrl(imagesJSON.getString(0));
            }

            tmpMessage.setAccountId(messageJSON.getString("account_id"));
            tmpMessage.setAccountType(messageJSON.getString("account_type"));

            parsedMessages.add(tmpMessage);
        }

        return parsedMessages;
    } catch (JSONException jSSONEx) {
        return null;
    }
}

From source file:srdes.menupp.EntreeDbAdapter.java

/**
 * @brief   Create a new review using the title and body provided. If the review is
 *          successfully created return the new rowId for that review, otherwise return
 *          a -1 to indicate failure.//from  w w w . ja  v a  2  s. c o m
 * 
 * @param    title the title of the note
 * 
 * @param    body the body of the note
 * 
 * @param    entree the name of the entree the review is for
 * 
 * @param    rating the rating given to the entree in the review
 * 
 * @throws    JSONException if cannot get rowID
 * 
 * @return    rowId or -1 if failed
 */
public static Long createReview(String title, String body, String entree, float rating) throws JSONException {

    //add column information to pass to database
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair(KEY_TITLE, title));
    nameValuePairs.add(new BasicNameValuePair(KEY_BODY, body));
    nameValuePairs.add(new BasicNameValuePair(KEY_ENTREE, entree));
    nameValuePairs.add(new BasicNameValuePair(KEY_RATING, new Float(rating).toString()));

    //http post
    JSONObject response = null;
    try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(INSERT_REVIEW_SCRIPT);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String responseBody = httpclient.execute(httppost, responseHandler);
        response = new JSONObject(responseBody);

    } catch (ClientProtocolException e) {
        DebugLog.LOGD("Protocol error in http connection " + e.toString());
    } catch (UnsupportedEncodingException e) {
        DebugLog.LOGD("Encoding error in http connection " + e.toString());
    } catch (IOException e) {
        DebugLog.LOGD("IO error in http connection " + e.toString());
    }
    //rowID encoded in response
    return (Long) response.get(KEY_ROWID);
}

From source file:Main.java

/**
 * <p>Inserts the specified element at the specified position in the array. 
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component 
 * type of the returned array is always the same as that of the input 
 * array.</p>/*from   w w w  . j av  a 2 s .  c  om*/
 *
 * <p>If the input array is <code>null</code>, a new one element array is returned
 *  whose component type is the same as the element.</p>
 * 
 * <pre>
 * ArrayUtils.add([1.1f], 0, 2.2f)               = [2.2f, 1.1f]
 * ArrayUtils.add([2.3f, 6.4f], 2, 10.5f)        = [2.3f, 6.4f, 10.5f]
 * ArrayUtils.add([2.6f, 6.7f], 0, -4.8f)        = [-4.8f, 2.6f, 6.7f]
 * ArrayUtils.add([2.9f, 6.0f, 0.3f], 2, 1.0f)   = [2.9f, 6.0f, 1.0f, 0.3f]
 * </pre>
 * 
 * @param array  the array to add the element to, may be <code>null</code>
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range 
 * (index < 0 || index > array.length).
 */
public static float[] add(float[] array, int index, float element) {
    return (float[]) add(array, index, new Float(element), Float.TYPE);
}