Example usage for java.lang Float MAX_VALUE

List of usage examples for java.lang Float MAX_VALUE

Introduction

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

Prototype

float MAX_VALUE

To view the source code for java.lang Float MAX_VALUE.

Click Source Link

Document

A constant holding the largest positive finite value of type float , (2-2-23)·2127.

Usage

From source file:org.broad.igv.track.TrackMenuUtils.java

public static JMenuItem getDataRangeItem(final Collection<Track> selectedTracks) {
    JMenuItem item = new JMenuItem("Set Data Range...");

    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            if (selectedTracks.size() > 0) {
                // Create a datarange that spans the extent of prev tracks range
                float mid = 0;
                float min = Float.MAX_VALUE;
                float max = Float.MIN_VALUE;
                boolean drawBaseline = false;
                for (Track t : selectedTracks) {
                    DataRange dr = t.getDataRange();
                    min = Math.min(min, dr.getMinimum());
                    max = Math.max(max, dr.getMaximum());
                    mid += dr.getBaseline();
                }//w  w w  . ja  v a  2s . c  om
                mid /= selectedTracks.size();
                if (mid < min) {
                    mid = min;
                } else if (mid > max) {
                    min = max;
                }

                DataRange prevAxisDefinition = new DataRange(min, mid, max, drawBaseline);
                DataRangeDialog dlg = new DataRangeDialog(IGV.getMainFrame(), prevAxisDefinition);
                dlg.setVisible(true);
                if (!dlg.isCanceled()) {
                    min = Math.min(dlg.getMax(), dlg.getMin());
                    max = Math.max(dlg.getMin(), dlg.getMax());
                    mid = dlg.getBase();
                    mid = Math.max(min, Math.min(mid, max));

                    DataRange axisDefinition = new DataRange(dlg.getMin(), dlg.getBase(), dlg.getMax());

                    for (Track track : selectedTracks) {
                        track.setDataRange(axisDefinition);
                        if (track instanceof DataTrack) {
                            ((DataTrack) track).setAutoscale(false);
                        }
                    }
                    IGV.getInstance().repaint();
                }

            }
        }
    });
    return item;
}

From source file:com.purelink.cluelin.barcodescanner.BarcodeCaptureActivity.java

/**
 * onTap returns the tapped barcode result to the calling Activity.
 *
 * @param rawX - the raw position of the tap
 * @param rawY - the raw position of the tap.
 * @return true if the activity is ending.
 *///from w  w  w .j av a 2 s  .  c o  m
private boolean onTap(float rawX, float rawY) {
    // Find tap point in preview frame coordinates.
    int[] location = new int[2];
    mGraphicOverlay.getLocationOnScreen(location);
    float x = (rawX - location[0]) / mGraphicOverlay.getWidthScaleFactor();
    float y = (rawY - location[1]) / mGraphicOverlay.getHeightScaleFactor();

    // Find the barcode whose center is closest to the tapped point.
    Barcode best = null;
    float bestDistance = Float.MAX_VALUE;
    for (BarcodeGraphic graphic : mGraphicOverlay.getGraphics()) {
        Barcode barcode = graphic.getBarcode();
        if (barcode.getBoundingBox().contains((int) x, (int) y)) {
            // Exact hit, no need to keep looking.
            best = barcode;
            break;
        }
        float dx = x - barcode.getBoundingBox().centerX();
        float dy = y - barcode.getBoundingBox().centerY();
        float distance = (dx * dx) + (dy * dy); // actually squared distance
        if (distance < bestDistance) {
            best = barcode;
            bestDistance = distance;
        }
    }

    if (best != null) {

        //   ??    .
        Intent data = new Intent();
        data.putExtra(BarcodeObject, best);
        setResult(CommonStatusCodes.SUCCESS, data);
        finish();
        return true;
    }
    return false;
}

From source file:org.opencms.ui.components.CmsResourceTable.java

/**
 * Static helper method to initialize the 'standard' properties of a data item from a given resource.<p>
 * @param resourceItem the resource item to fill
 * @param cms the CMS context/*  w  ww  .j a v  a2s  .  c o m*/
 * @param resource the resource
 * @param messages the message bundle
 * @param locale the locale
 */
public static void fillItemDefault(Item resourceItem, CmsObject cms, CmsResource resource, CmsMessages messages,
        Locale locale) {

    if (resource == null) {
        LOG.error("Error rendering item for 'null' resource");
        return;
    }

    if (resourceItem == null) {
        LOG.error("Error rendering 'null' item for resource " + resource.getRootPath());
        return;
    }
    if (cms == null) {
        cms = A_CmsUI.getCmsObject();
        LOG.warn("CmsObject was 'null', using thread local CmsObject");
    }
    CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource);
    Map<String, CmsProperty> resourceProps = null;
    try {
        List<CmsProperty> props = cms.readPropertyObjects(resource, false);
        resourceProps = new HashMap<String, CmsProperty>();
        for (CmsProperty prop : props) {
            resourceProps.put(prop.getName(), prop);
        }
    } catch (CmsException e1) {
        LOG.debug("Unable to read properties for resource '" + resource.getRootPath() + "'.", e1);
    }
    I_CmsResourceType type = OpenCms.getResourceManager().getResourceType(resource);
    if (resourceItem.getItemProperty(PROPERTY_TYPE_ICON) != null) {
        resourceItem.getItemProperty(PROPERTY_TYPE_ICON)
                .setValue(new CmsResourceIcon(resUtil, resource.getState(), true));
    }

    if (resourceItem.getItemProperty(PROPERTY_PROJECT) != null) {
        Image projectFlag = null;
        switch (resUtil.getProjectState().getMode()) {
        case 1:
            projectFlag = new Image(resUtil.getLockedInProjectName(),
                    new ThemeResource(OpenCmsTheme.PROJECT_CURRENT_PATH));
            break;
        case 2:
            projectFlag = new Image(resUtil.getLockedInProjectName(),
                    new ThemeResource(OpenCmsTheme.PROJECT_OTHER_PATH));
            break;
        case 5:
            projectFlag = new Image(resUtil.getLockedInProjectName(),
                    new ThemeResource(OpenCmsTheme.PROJECT_PUBLISH_PATH));
            break;
        default:
        }
        if (projectFlag != null) {
            projectFlag.setDescription(resUtil.getLockedInProjectName());
        }
        resourceItem.getItemProperty(PROPERTY_PROJECT).setValue(projectFlag);
    }

    if (resourceItem.getItemProperty(PROPERTY_INSIDE_PROJECT) != null) {
        resourceItem.getItemProperty(PROPERTY_INSIDE_PROJECT)
                .setValue(Boolean.valueOf(resUtil.isInsideProject()));
    }

    if (resourceItem.getItemProperty(PROPERTY_RELEASED_NOT_EXPIRED) != null) {
        resourceItem.getItemProperty(PROPERTY_RELEASED_NOT_EXPIRED)
                .setValue(Boolean.valueOf(resUtil.isReleasedAndNotExpired()));
    }

    if (resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME) != null) {
        resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME).setValue(resource.getName());
    }

    if (resourceItem.getItemProperty(PROPERTY_SITE_PATH) != null) {
        resourceItem.getItemProperty(PROPERTY_SITE_PATH).setValue(cms.getSitePath(resource));
    }

    if ((resourceItem.getItemProperty(PROPERTY_TITLE) != null) && (resourceProps != null)) {
        resourceItem.getItemProperty(PROPERTY_TITLE)
                .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_TITLE)
                        ? resourceProps.get(CmsPropertyDefinition.PROPERTY_TITLE).getValue()
                        : "");
    }
    boolean inNavigation = false;
    if ((resourceItem.getItemProperty(PROPERTY_NAVIGATION_TEXT) != null) && (resourceProps != null)) {
        resourceItem.getItemProperty(PROPERTY_NAVIGATION_TEXT)
                .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT)
                        ? resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVTEXT).getValue()
                        : "");
        inNavigation = resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVTEXT);
    }

    if ((resourceItem.getItemProperty(PROPERTY_NAVIGATION_POSITION) != null) && (resourceProps != null)) {
        try {
            Float navPos = resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVPOS)
                    ? Float.valueOf(resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVPOS).getValue())
                    : (inNavigation ? Float.valueOf(Float.MAX_VALUE) : null);
            resourceItem.getItemProperty(PROPERTY_NAVIGATION_POSITION).setValue(navPos);
            inNavigation = navPos != null;
        } catch (Exception e) {
            LOG.debug("Error evaluating navPos property", e);
        }
    }

    if (resourceItem.getItemProperty(PROPERTY_IN_NAVIGATION) != null) {
        if (inNavigation && (resourceProps != null)
                && resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_NAVINFO)
                && CmsClientSitemapEntry.HIDDEN_NAVIGATION_ENTRY
                        .equals(resourceProps.get(CmsPropertyDefinition.PROPERTY_NAVINFO).getValue())) {
            inNavigation = false;
        }
        resourceItem.getItemProperty(PROPERTY_IN_NAVIGATION).setValue(Boolean.valueOf(inNavigation));
    }

    if ((resourceItem.getItemProperty(PROPERTY_COPYRIGHT) != null) && (resourceProps != null)) {
        resourceItem.getItemProperty(PROPERTY_COPYRIGHT)
                .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_COPYRIGHT)
                        ? resourceProps.get(CmsPropertyDefinition.PROPERTY_COPYRIGHT).getValue()
                        : "");
    }

    if ((resourceItem.getItemProperty(PROPERTY_CACHE) != null) && (resourceProps != null)) {
        resourceItem.getItemProperty(PROPERTY_CACHE)
                .setValue(resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_CACHE)
                        ? resourceProps.get(CmsPropertyDefinition.PROPERTY_CACHE).getValue()
                        : "");
    }

    if (resourceItem.getItemProperty(PROPERTY_RESOURCE_TYPE) != null) {
        resourceItem.getItemProperty(PROPERTY_RESOURCE_TYPE)
                .setValue(CmsWorkplaceMessages.getResourceTypeName(locale, type.getTypeName()));
    }

    if (resourceItem.getItemProperty(PROPERTY_IS_FOLDER) != null) {
        resourceItem.getItemProperty(PROPERTY_IS_FOLDER).setValue(Boolean.valueOf(resource.isFolder()));
    }

    if (resourceItem.getItemProperty(PROPERTY_SIZE) != null) {
        if (resource.isFile()) {
            resourceItem.getItemProperty(PROPERTY_SIZE).setValue(Integer.valueOf(resource.getLength()));
        }
    }

    if (resourceItem.getItemProperty(PROPERTY_PERMISSIONS) != null) {
        resourceItem.getItemProperty(PROPERTY_PERMISSIONS).setValue(resUtil.getPermissionString());
    }

    if (resourceItem.getItemProperty(PROPERTY_DATE_MODIFIED) != null) {
        resourceItem.getItemProperty(PROPERTY_DATE_MODIFIED)
                .setValue(Long.valueOf(resource.getDateLastModified()));
    }

    if (resourceItem.getItemProperty(PROPERTY_USER_MODIFIED) != null) {
        resourceItem.getItemProperty(PROPERTY_USER_MODIFIED).setValue(resUtil.getUserLastModified());
    }

    if (resourceItem.getItemProperty(PROPERTY_DATE_CREATED) != null) {
        resourceItem.getItemProperty(PROPERTY_DATE_CREATED).setValue(Long.valueOf(resource.getDateCreated()));
    }

    if (resourceItem.getItemProperty(PROPERTY_USER_CREATED) != null) {
        resourceItem.getItemProperty(PROPERTY_USER_CREATED).setValue(resUtil.getUserCreated());
    }

    if (resourceItem.getItemProperty(PROPERTY_DATE_RELEASED) != null) {
        long release = resource.getDateReleased();
        if (release != CmsResource.DATE_RELEASED_DEFAULT) {
            resourceItem.getItemProperty(PROPERTY_DATE_RELEASED).setValue(Long.valueOf(release));
        }
    }

    if (resourceItem.getItemProperty(PROPERTY_DATE_EXPIRED) != null) {
        long expire = resource.getDateExpired();
        if (expire != CmsResource.DATE_EXPIRED_DEFAULT) {
            resourceItem.getItemProperty(PROPERTY_DATE_EXPIRED).setValue(Long.valueOf(expire));
        }
    }

    if (resourceItem.getItemProperty(PROPERTY_STATE_NAME) != null) {
        resourceItem.getItemProperty(PROPERTY_STATE_NAME).setValue(resUtil.getStateName());
    }

    if (resourceItem.getItemProperty(PROPERTY_STATE) != null) {
        resourceItem.getItemProperty(PROPERTY_STATE).setValue(resource.getState());
    }

    if (resourceItem.getItemProperty(PROPERTY_USER_LOCKED) != null) {
        resourceItem.getItemProperty(PROPERTY_USER_LOCKED).setValue(resUtil.getLockedByName());
    }
}

From source file:edu.fullerton.viewerplugin.SpectrumPlot.java

@Override
public void setParameters(Map<String, String[]> parameterMap) {
    this.parameterMap = parameterMap;
    String[] t;//from   ww w.  ja va2s .co m
    t = parameterMap.get("window");
    String it = t != null && t.length > 0 ? t[0] : "";

    if (it.isEmpty() || it.equalsIgnoreCase("none")) {
        window = Window.NONE;
    } else if (it.equalsIgnoreCase("hanning")) {
        window = Window.HANNING;
    } else if (it.equalsIgnoreCase("flattop")) {
        window = Window.FLATTOP;
    } else {
        window = Window.HANNING;
    }

    t = parameterMap.get("scaling");
    it = t != null && t.length > 0 ? t[0] : "";
    if (it.equalsIgnoreCase("Amplitude spectrum")) {
        pwrScale = Scaling.AS;
    } else if (it.equalsIgnoreCase("Amplitude spectral density")) {
        pwrScale = Scaling.ASD;
    } else if (it.equalsIgnoreCase("Power specturm")) {
        pwrScale = Scaling.PS;
    } else if (it.equalsIgnoreCase("Power spectral density")) {
        pwrScale = Scaling.PSD;
    }

    t = parameterMap.get("sp_linethickness");
    if (t == null || !t[0].trim().matches("^\\d+$")) {
        lineThickness = 2;
    } else {
        lineThickness = Integer.parseInt(t[0]);
    }

    t = parameterMap.get("secperfft");
    if (t == null) {
        secperfft = 1;
    } else if (t[0].matches("[\\d\\.]+")) {
        this.secperfft = (float) Double.parseDouble(t[0]);
    } else {
        vpage.add("Invalid entry for seconds per fft, using 1");
    }

    t = parameterMap.get("fftoverlap");
    if (t == null) {
        overlap = secperfft / 2;
    } else if (t[0].matches("[\\d\\.]+")) {
        double tmp = Double.parseDouble(t[0]);
        if (tmp >= 0 && tmp < 1) {
            this.overlap = (float) (tmp * secperfft);
        } else {
            vpage.add("Invalid entry for overlap, using 0.5");
            overlap = secperfft / 2;
        }
    } else {
        vpage.add("Invalid entry for overlap, using 0.5");
        overlap = secperfft / 2;
    }

    t = parameterMap.get("fmin");
    if (t == null) {
        fmin = Float.MIN_VALUE;
    } else if (t[0].matches("[\\d\\.]+")) {
        fmin = (float) Double.parseDouble(t[0]);
    } else {
        fmin = Float.MIN_VALUE;
    }

    t = parameterMap.get("fmax");
    if (t == null) {
        fmax = Float.MAX_VALUE;
    } else if (t[0].matches("[\\d\\.]+")) {
        fmax = (float) Double.parseDouble(t[0]);
    } else {
        fmax = Float.MAX_VALUE;
    }
    t = parameterMap.get("sp_logx");
    logXaxis = t != null;

    t = parameterMap.get("sp_logy");
    logYaxis = t != null;
}

From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java

/**
     * Returns the most accurate and timely previously detected location.
     * Where the last result is beyond the specified maximum distance or
     * latency a one-off location update is returned via the {@link LocationListener}
     * specified in {@link setChangedLocationListener}.
     * @param minDistance Minimum distance before we require a location update.
     * @param minTime Minimum time required between location updates.
     * @return The most accurate and / or timely previously detected location.
     *//*from ww w. j av  a  2s.com*/
    public Location getLastBestLocation() {
        int minDistance = (int) stationaryRadius;
        long minTime = System.currentTimeMillis() - (locationTimeout * 1000);

        Log.i(TAG, "- fetching last best location " + minDistance + "," + minTime);
        Location bestResult = null;
        float bestAccuracy = Float.MAX_VALUE;
        long bestTime = Long.MIN_VALUE;

        // Iterate through all the providers on the system, keeping
        // note of the most accurate result within the acceptable time limit.
        // If no result is found within maxTime, return the newest Location.
        List<String> matchingProviders = locationManager.getAllProviders();
        for (String provider : matchingProviders) {
            Log.d(TAG, "- provider: " + provider);
            Location location = locationManager.getLastKnownLocation(provider);
            if (location != null) {
                Log.d(TAG, " location: " + location.getLatitude() + "," + location.getLongitude() + ","
                        + location.getAccuracy() + "," + location.getSpeed() + "m/s");
                float accuracy = location.getAccuracy();
                long time = location.getTime();
                Log.d(TAG, "time>minTime: " + (time > minTime) + ", accuracy<bestAccuracy: "
                        + (accuracy < bestAccuracy));
                if ((time > minTime && accuracy < bestAccuracy)) {
                    bestResult = location;
                    bestAccuracy = accuracy;
                    bestTime = time;
                }
            }
        }
        return bestResult;
    }

From source file:th.in.ffc.person.PersonDetailEditFragment.java

@Override
public boolean onSave(EditTransaction et) {
    String id = citizenId.getText().toString();
    if (!TextUtils.isEmpty(id)) {
        if (!ThaiCitizenID.Validate(id) && !isCurrentId) {
            et.showErrorMessage(citizenId, "Invalid checksum citizen id");
            return false;
        } else if (!isUseableId) {
            et.showErrorMessage(citizenId, "Duplicate Id");
            return false;
        }/*  ww w  .  j av a2s.  com*/
        et.retrieveData(Person.CITIZEN_ID, citizenId, true, "\\d{13}", "Invalid citizen id Lenght");
    } else {
        if (newPid > 0) {
            String cid = "";
            String pid = "" + newPid;
            int loop = (13 - pid.length());
            for (int i = 1; i <= loop; i++)
                cid += "0";
            cid += newPid;
            et.getContentValues().put(Person.CITIZEN_ID, cid);
        }
    }

    et.retrieveData(Person.FIRST_NAME, fname, false, null, null);
    et.retrieveData(Person.LAST_NAME, lname, false, null, null);
    et.retrieveData(Person.BIRTH, birthday, null, Date.newInstance(DateTime.getCurrentDate()),
            "can't create person of the future");
    et.retrieveData(Person.NATION, nation, false, null, "please select one nation");
    et.retrieveData(Person.ORIGIN, origin, false, null, "please select one origin nation");
    et.retrieveData(Person.OCCUPA, occupa, false, null, "please select one occupa");
    et.retrieveData(Person.INCOME, income, true, 0.00f, Float.MAX_VALUE, "Is that to much income");
    et.retrieveData(Person.TEL, tel, true, "\\d{9,12}", "tel number out of lenght");
    et.retrieveData(Person.ALLERGIC, allergic, true, null, null);

    et.retrieveData(Person.ADDR_NO, hno, false, null, "please insert house number");
    et.retrieveData(Person.ADDR_MU, mu, false, null, null);
    et.retrieveData(Person.ADDR_ROAD, road, true, null, null);
    et.retrieveData(Person.ADDR_SUBDIST, subdistcode, false, null, "please select sub-distict");
    et.retrieveData(Person.ADDR_DIST, distcode, false, null, "please select distict");
    et.retrieveData(Person.ADDR_PROVICE, provcode, false, null, "please select Provice");
    et.retrieveData(Person.POSTCODE, postcode, false, "\\d{5}", "please insert 5 digit");

    ContentValues cv = et.getContentValues();

    RadioButton maleRadio = (RadioButton) sex.findViewById(R.id.male);
    cv.put(Person.SEX, maleRadio.isChecked() ? 1 : 2);
    cv.put(Person.PRENAME, prename.getSelectionId());
    cv.put(Person.BLOOD_GROUP, bloodType.getSelectionId());
    cv.put(Person.BLOOD_RH, bloodRh.getSelectionId());
    cv.put(Person.RELIGION, religion.getSelectionId());
    cv.put(Person.EDUCATION, education.getSelectionId());
    cv.put(Person.HCODE, house.getSelectedItemId());
    cv.put(Person._DATEUPDATE, DateTime.getCurrentDateTime());

    if (newPid > 0) {
        cv.put(Person.PID, newPid);
        cv.put(Person.PCUPERSONCODE, getFFCActivity().getPcuCode());
    }

    return et.canCommit();
}

From source file:com.clustercontrol.ping.factory.RunMonitorPing.java

/**
 *    fping???IP??????<BR>/*  w ww.ja  v  a2 s.  com*/
 *  nodeMap?????public
 * 
 * @param hosts      fping???
 * @param message    
 * @param count      ping
 * @return (IP ??)??
 */
public Hashtable<String, PingResult> wrapUpFping(ArrayList<String> messages, int count, int version) {

    Hashtable<String, PingResult> ret = new Hashtable<String, PingResult>();
    HashMap<String, String> normalMap = new HashMap<String, String>(); //IP, 
    HashMap<String, String> aberrantMap = new HashMap<String, String>(); //IP, 
    HashSet<String> hostSet = new HashSet<String>();

    /**
     * ????????5?
     * ???
     * 
     **/
    String msg;
    String msgOrg;
    int lost;
    float average = 0;
    float reachRatio;

    //IP???

    Pattern patternIp;
    if (version == 6) {
        patternIp = Pattern.compile("^([0-9].*)|^(\\:\\:.*)");
    } else {
        patternIp = Pattern.compile("^([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}.*)");
    }

    //fping??
    Pattern patternSp = Pattern.compile("(\\s:\\s|\\s)+");
    //?
    Pattern patternNormal = Pattern.compile("([0-9]+\\.[0-9]+|-)");

    //IP
    Matcher matcherIp;
    Matcher matcherValue;

    String message;

    /*
     * fping???
     * ???                     127.0.0.1 : 0.10 1.23
     * ????                     127.0.0.1 : - -
     * ???(?IP???)         127.0.0.1 : duplicate for [0], xx bytes, x.xx ms
     * ???(GW??????)   127.0.0.1 : ()
     * ??
     * ????????????????????
     * 2????????????
     * ???????IP????????
     * ?????
     */

    /*
     * ?????
     */
    Iterator<String> itr = messages.iterator();
    m_log.debug("wrapUpFping(): start logic: " + messages.size());
    while (itr.hasNext()) {

        message = itr.next();
        m_log.debug("wrapUpFping(): checkpoint");

        //IP??????????
        boolean bValidIP = false;
        if (version == 6) {
            m_log.debug("wrapUpFping(): into IPv6 loop");
            String[] strs = message.split(" ");
            try {
                InetAddress.getByName(strs[0]);
                bValidIP = true;
            } catch (Exception e) {
                m_log.warn("wrapUpFping() invalid IPv6 adress: original message: " + message, e);
                m_log.warn("wrapUpFping() stack trace: " + e.getClass().getSimpleName() + ", " + e.getMessage(),
                        e);
            }
        } else {
            matcherIp = patternIp.matcher(message);
            if (matcherIp.matches()) {
                bValidIP = true;
            }
        }
        if (bValidIP) {

            //?IP????????
            String[] strs = patternSp.split(message);

            //?IP???
            boolean isNormal = true;
            for (int i = 1; i < strs.length; i++) {

                matcherValue = patternNormal.matcher(strs[i]);
                if (!matcherValue.matches()) {
                    isNormal = false;
                }
            }

            if (isNormal) {
                normalMap.put(strs[0], message);
                m_log.debug("wrapUpFping() : normalValue : " + message);
            } else {
                // ??IP???????
                if (aberrantMap.get(strs[0]) != null && !(aberrantMap.get(strs[0])).equals("")) {
                    String aberrantMessage = aberrantMap.get(strs[0]);
                    aberrantMessage = aberrantMessage + "\n" + message;
                    aberrantMap.put(strs[0], aberrantMessage);
                } else {
                    aberrantMap.put(strs[0], message);
                }
                m_log.debug("wrapUpFping() : aberrantValue : " + message);
            }

            hostSet.add(strs[0]);
        }
    }

    /*
     * ??????????
     */
    itr = hostSet.iterator();
    m_log.debug("wrapUpFping() : before into check result append loop");
    while (itr.hasNext()) {
        m_log.debug("wrapUpFping() : after into check result append loop");

        String host = itr.next();
        String normalMessage = normalMap.get(host);
        String aberrantMessage = aberrantMap.get(host);

        if (normalMessage != null && !normalMessage.equals("")) {

            // String ??
            String[] strs = patternSp.split(normalMessage);

            /*????????*/
            float max = 0; //(?0)
            float min = Float.MAX_VALUE; //?(?Float?)
            int num = 0; //?

            //????????
            for (int i = 1; i <= count; i++) {

                if (strs[i].equals("-")) {

                    //?-????????

                } else {

                    //?count up
                    num++;

                    //???
                    if (max < Float.parseFloat(strs[i])) {
                        max = Float.parseFloat(strs[i]);
                    }

                    //????
                    if (min > Float.parseFloat(strs[i])) {
                        min = Float.parseFloat(strs[i]);
                    }

                    //?
                    average += Float.parseFloat(strs[i]);
                }
            }

            //?????????????
            average /= num;

            /*
             * ???
             */

            StringBuffer buffer = new StringBuffer();
            buffer.append("Pinging " + host + " (" + host + ") .\n\n");

            // ??0??
            if (num == 0) {
                //??0??lost100 reach0
                lost = 100;
                reachRatio = 0;

                for (int i = 0; i < count; i++)
                    // buffer.append("From " + strs[0] + " icmp_seq="+ index +" Destination Host Unreachable");
                    buffer.append("Reply from " + host + " icmp_seq=" + i + " Destination Host Unreachable\n");

                buffer.append("\nPing statistics for " + host + ":\n");
                buffer.append("Packets: Sent = " + count + ", Received = " + num + ", Lost = " + (count - num)
                        + " (" + lost + "% loss),");

            } else {
                lost = (count - num) * 100 / count;
                reachRatio = (float) num * 100 / count;

                buffer.append("\nPing statistics for " + host + ":\n");
                buffer.append("Packets: Sent = " + count + ", Received = " + num + ", Lost = " + (count - num)
                        + " (" + lost + "% loss),");
                buffer.append("Approximate round trip times in milli-seconds:\n");
                buffer.append(
                        "\tMinimum = " + min + "ms, Maximum = " + max + "ms, Average = " + average + "ms\n");
            }

            // ?????msgOrg?
            if (aberrantMessage != null && !aberrantMessage.equals("")) {
                buffer.append("\n\n" + aberrantMessage + "\n");
            }

            msgOrg = buffer.toString();
            msg = "Packets: Sent = " + count + ", Received = " + num + ", Lost = " + (count - num) + " (" + lost
                    + "% loss)";

            PingResult res = new PingResult(host, msg, msgOrg, lost, average, reachRatio);

            ret.put(host, res);

            m_log.debug("wrapUpFping() : success msg = " + msg + ", msgOrg = " + msgOrg);

            msg = "";
            msgOrg = "";
            lost = 100;
            average = 0;
            reachRatio = 0;

        }
        // ??????
        else {

            msg = "Failed to get a value.";
            msgOrg = "Failed to get a value.";
            if (aberrantMessage != null && !aberrantMessage.equals("")) {
                msgOrg = msgOrg + "\n\n" + aberrantMessage;
            }

            PingResult res = new PingResult(host, msg, msgOrg, -1, -1, -1);

            ret.put(host, res);

            m_log.debug("wrapUpFping() : failure msg = " + msg + ", msgOrg = " + msgOrg);

            msg = "";
            msgOrg = "";
        }

    }

    return ret;
}

From source file:org.fhcrc.cpl.toolbox.proteomics.feature.FeatureSet.java

public Feature findNearestFeature(int scan, float mz) {
    return findNearestFeature(scan, mz, Integer.MAX_VALUE, Float.MAX_VALUE);
}

From source file:cerrla.Performance.java

/**
 * Notes the rewards the sample received.
 * /*from   w ww.j  a  v a  2  s. c  om*/
 * @param policyRewards
 *            The rewards the sample received.
 * @param currentEpisode
 *            The current episode.
 * @return The computed average of the internal rewards.
 */
public double noteSampleRewards(ArrayList<double[]> policyRewards, int currentEpisode) {
    // First pass through the rewards to determine min reward.
    double environmentAverage = 0;
    double internalAverage = 0;
    minEpisodeReward_ = Float.MAX_VALUE;
    for (double[] reward : policyRewards) {
        double internalReward = reward[RRLObservations.INTERNAL_INDEX];
        minEpisodeReward_ = Math.min(internalReward, minEpisodeReward_);
        minMaxReward_[0] = Math.min(internalReward, minMaxReward_[0]);
        minMaxReward_[1] = Math.max(internalReward, minMaxReward_[1]);
        internalAverage += internalReward;

        environmentAverage += reward[RRLObservations.ENVIRONMENTAL_INDEX];
    }
    internalAverage /= policyRewards.size();
    environmentAverage /= policyRewards.size();

    // Second pass through to note the internal policy SDs
    for (double[] reward : policyRewards) {
        if (internalSDs_.size() == ProgramArgument.PERFORMANCE_TESTING_SIZE.intValue()
                * ProgramArgument.POLICY_REPEATS.intValue())
            internalSDs_.poll();
        internalSDs_.add(reward[RRLObservations.ENVIRONMENTAL_INDEX] - minEpisodeReward_);
    }

    // Note scores only if there are enough to average (or simply frozen).
    boolean noteScores = frozen_;
    if (!noteScores && recentScores_.size() == ProgramArgument.PERFORMANCE_TESTING_SIZE.intValue()) {
        recentScores_.poll();
        noteScores = true;
    }
    recentScores_.add(environmentAverage);
    if (!frozen_)
        recordPerformanceScore(currentEpisode);

    return internalAverage;
}

From source file:org.fhcrc.cpl.toolbox.proteomics.feature.FeatureSet.java

public int findNearestFeatureIndex(int scan, float mz, int maxScanDistance, float maxMzDistance) {
    Feature feature = new Feature(scan, mz, 1);
    int index = Arrays.binarySearch(_features, feature, new Feature.MzScanAscComparator());
    double minDistance = Float.MAX_VALUE;
    int nearestFeature = -1;

    if (index >= 0)
        return index;

    int pos = -index - 1;

    //Didn't find an exact match. Search for nearest feature in 2 dimensions
    for (int i = pos - 1; i >= 0; i--) {
        Feature f = _features[i];/*  w  w  w .  j  a va 2 s .c o m*/
        float mzDist = Math.abs(mz - f.mz);
        if (mzDist > maxMzDistance || mzDist > minDistance)
            break;

        int scanDist = Math.abs(scan - f.scan);
        if (scanDist > maxScanDistance)
            continue;

        double distance = Math.sqrt(scanDist * scanDist + mzDist * mzDist);
        if (distance < minDistance) {
            minDistance = distance;
            nearestFeature = i;
        }
    }

    for (int i = pos; i < _features.length; i++) {
        Feature f = _features[i];
        float mzDist = Math.abs(mz - f.mz);
        if (mzDist > minDistance || mzDist > maxMzDistance) //Not going to get any closer since sorted by Mz
            return nearestFeature;

        int scanDist = Math.abs(scan - f.scan);
        if (scanDist > maxScanDistance)
            continue;

        double distance = Math.sqrt(scanDist * scanDist + mzDist * mzDist);
        if (distance < minDistance) {
            minDistance = distance;
            nearestFeature = i;
        }
    }

    return nearestFeature;
}