Example usage for java.lang Float intValue

List of usage examples for java.lang Float intValue

Introduction

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

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Float as an int after a narrowing primitive conversion.

Usage

From source file:org.wso2.cdm.agent.AuthenticationActivity.java

private void startLocalNotification(Float interval) {
    long firstTime = SystemClock.elapsedRealtime();
    firstTime += 1 * 1000;//w w w  .j a  v  a2  s.  c o  m

    Intent downloader = new Intent(context, AlarmReceiver.class);
    PendingIntent recurringDownload = PendingIntent.getBroadcast(context, 0, downloader,
            PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Float seconds = interval;
    if (interval < 1.0) {

        alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, seconds.intValue(),
                recurringDownload);
    } else {
        alarms.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, seconds.intValue(),
                recurringDownload);
    }

}

From source file:org.wso2.carbon.appmgt.migration.client.MigrationClientImpl.java

private void migrateMobileAppRatings(Map<String, Float> appRating, String tenantDomain)
        throws APPMMigrationException {
    Connection connection = null;
    PreparedStatement statement = null;

    try {//from ww w.j av  a  2 s.c  om
        if (log.isDebugEnabled()) {
            log.debug("Executing: " + Constants.INSERT_SOCIAL_CACHE);
        }
        connection = getConnection(Constants.SOCIAL_DB_NAME);
        statement = connection.prepareStatement(Constants.INSERT_SOCIAL_CACHE);
        for (String contextId : appRating.keySet()) {
            statement.setString(1, contextId);
            Float rating = appRating.get(contextId);
            statement.setInt(2, rating.intValue());
            statement.setInt(3, 1);
            statement.setDouble(4, rating.doubleValue());
            statement.setString(5, tenantDomain);
            statement.addBatch();
        }
        statement.executeBatch();
    } catch (SQLException e) {
        handleException("Error occurred while migrating mobile application ratings for tenant " + tenantDomain,
                e);
    } catch (DataSourceException e) {
        handleException("Error occurred while obtaining datasource connection for " + Constants.SOCIAL_DB_NAME
                + " during mobile application ratings migration for tenant " + tenantDomain, e);
    } finally {
        closeConnection(connection);
        if (statement != null) {
            try {
                statement.close();
            } catch (SQLException e) {
                handleException(
                        "Error occurred while closing prepared statement for Mobile app Social Cache update "
                                + "for tenant " + tenantDomain,
                        e);
            }
        }
    }

}

From source file:org.openhab.binding.nanoleaf.internal.handler.NanoleafControllerHandler.java

private void updateFromControllerInfo() throws NanoleafException, NanoleafUnauthorizedException {
    logger.debug("Update channels for controller {}", thing.getUID());
    this.controllerInfo = receiveControllerInfo();
    boolean isOn = controllerInfo.getState().getOn().getValue();
    updateState(CHANNEL_POWER, isOn ? OnOffType.ON : OnOffType.OFF);
    updateState(CHANNEL_COLOR_TEMPERATURE_ABS,
            new DecimalType(controllerInfo.getState().getColorTemperature().getValue().intValue()));
    Float colorTempPercent = (controllerInfo.getState().getColorTemperature().getValue().floatValue()
            - controllerInfo.getState().getColorTemperature().getMin().floatValue())
            / (controllerInfo.getState().getColorTemperature().getMax().floatValue()
                    - controllerInfo.getState().getColorTemperature().getMin().floatValue())
            * PercentType.HUNDRED.intValue();
    updateState(CHANNEL_COLOR_TEMPERATURE, new PercentType(colorTempPercent.intValue()));
    updateState(CHANNEL_EFFECT, new StringType(controllerInfo.getEffects().getSelect()));
    updateState(CHANNEL_COLOR,/*from   w ww .  j a va 2  s. c  o m*/
            new HSBType(new DecimalType(controllerInfo.getState().getHue().getValue()),
                    new PercentType(controllerInfo.getState().getSaturation().getValue()),
                    new PercentType(isOn ? controllerInfo.getState().getBrightness().getValue() : 0)));
    updateState(CHANNEL_COLOR_MODE, new StringType(controllerInfo.getState().getColorMode()));
    updateState(CHANNEL_RHYTHM_ACTIVE,
            controllerInfo.getRhythm().getRhythmActive().booleanValue() ? OnOffType.ON : OnOffType.OFF);
    updateState(CHANNEL_RHYTHM_MODE, new DecimalType(controllerInfo.getRhythm().getRhythmMode().intValue()));
    updateState(CHANNEL_RHYTHM_STATE,
            controllerInfo.getRhythm().getRhythmConnected().booleanValue() ? OnOffType.ON : OnOffType.OFF);

    // update bridge properties which may have changed, or are not present during discovery
    Map<String, String> properties = editProperties();
    properties.put(Thing.PROPERTY_SERIAL_NUMBER, controllerInfo.getSerialNo());
    properties.put(Thing.PROPERTY_FIRMWARE_VERSION, controllerInfo.getFirmwareVersion());
    updateProperties(properties);

    // update the color channels of each panel
    this.getThing().getThings().forEach(child -> {
        NanoleafPanelHandler panelHandler = (NanoleafPanelHandler) child.getHandler();
        if (panelHandler != null) {
            logger.debug("Update color channel for panel {}", panelHandler.getThing().getUID());
            panelHandler.updatePanelColorChannel();
        }
    });
}

From source file:psidev.psi.mi.tab.converter.xml2tab.InteractorConverter.java

public psidev.psi.mi.tab.model.Interactor toMitab(Participant xmlParticipant) throws TabConversionException {

    if (xmlParticipant == null) {
        throw new IllegalArgumentException("Participant must not be null");
    }//from  w w  w  .  ja  v a2s.  c o  m

    Interactor xmlInteractor = xmlParticipant.getInteractor();

    if (xmlInteractor == null) {
        throw new IllegalArgumentException("Interactor must not be null");
    }

    List<CrossReference> identifiers = new ArrayList<CrossReference>();
    List<CrossReference> altIdentifiers = new ArrayList<CrossReference>();
    List<CrossReference> xrefs = new ArrayList<CrossReference>();

    Collection<DbReference> identityRefs;

    // primary accession id
    if (xmlInteractor.getXref() != null) {

        identityRefs = XrefUtils.searchByType(xmlInteractor.getXref(), IDENTITY, IDENTITY_REF);
        // identityRefs.addAll(XrefUtils.searchByType( interactor.getXref(), SOURCE_REFERENCE, SOURCE_REFERENCE_REF ));    \
        if (!identityRefs.isEmpty()) {
            //We have the unique identifier in this list

            CrossReference primaryIdentifier = selectBestIdentfier(identityRefs);
            if (primaryIdentifier != null) {
                identifiers.add(primaryIdentifier);
            }
            //            for (DbReference ref : identityRefs) {
            //                CrossReference cr = buildCrossReference(ref);
            //                if (!identifiers.contains(cr)) {
            //                    identifiers.add(cr);
            //                }
            //            }
            // alternative Ids

            // -> use the rest of identify xrefs that are not the unique identifier
            for (DbReference ref : identityRefs) {
                CrossReference cr = buildCrossReference(ref);
                if (!altIdentifiers.contains(cr)) {
                    altIdentifiers.add(cr);
                }
            }
            //We remove the unique identifier from alternatives identifiers
            altIdentifiers.remove(primaryIdentifier);

            // xrefs
            List<DbReference> allRefs = XrefUtils.getAllDbReferences(xmlInteractor.getXref());

            // -> use the rest of non-identify xrefs that are not the unique identifier
            if (allRefs != null) {
                for (DbReference ref : allRefs) {
                    if (!ref.hasRefType()
                            || (ref.hasRefType() && !ref.getRefType().equalsIgnoreCase("identity"))) {
                        CrossReference cr = buildCrossReference(ref);
                        if (!xrefs.contains(cr)) {
                            xrefs.add(cr);
                        }
                    }
                }
            }
        } else {

            //Here we don't have identity objects, then the unique id must be a xrefs for the interactor
            List<DbReference> allRefs = XrefUtils.getAllDbReferences(xmlInteractor.getXref());

            if (identifiers.isEmpty() && !allRefs.isEmpty()) {

                // sort identifiers
                //TODO Why do we need sort if all are equal? Why don't we choose the first one?
                allRefs = XrefUtils.sortByIdentifier(allRefs);

                CrossReference primaryIdentifier = buildCrossReference(allRefs.iterator().next());

                // pick the first one in the list
                identifiers.add(primaryIdentifier);

                /* Xrefs Columns 23, 24 */

                // -> use the rest of non-identify xrefs that are not the unique identifier
                for (DbReference ref : allRefs) {
                    CrossReference cr = buildCrossReference(ref);
                    if (!xrefs.contains(cr)) {
                        xrefs.add(cr);
                    }
                }
                //We remove the unique identifier from alternatives identifiers
                xrefs.remove(primaryIdentifier);
            }
        }
        if (identifiers.isEmpty()) {
            throw new TabConversionException(
                    "Could not find any identifiers for interactor " + xmlInteractor.getId());
        }

    } // xrefs

    //TODO Check if we need add information of the participant in altIds or Xrefs

    /* Primary identifier Columns 1, 2 */
    T tabInteractor = newInteractor(identifiers);

    /* Alternative Identifiers Columns 3, 4 */
    if (!altIdentifiers.isEmpty()) {
        tabInteractor.setAlternativeIdentifiers(altIdentifiers);
    }

    /* Xrefs Columns 23, 24 */
    if (!xrefs.isEmpty()) {
        tabInteractor.setXrefs(xrefs);
    }
    //        //   -> use the gene name
    //        Collection<Alias> aliases = AliasUtils.getAllAliases(interactor.getNames());
    //        Alias gn = AliasUtils.getGeneName(aliases);
    //        if (gn != null) {
    //            aliases.remove(gn); // (!) the rest will be stored in the alias builder
    //            String geneNameValue = gn.getValue();
    //
    //            if (geneNameValue != null && geneNameValue.trim().length() > 0) {
    //                CrossReference cr = new CrossReferenceImpl(UNIPROT, geneNameValue);
    //                cr.setText(gn.getType());
    //                altIdentifiers.add(cr);
    //                tabInteractor.setAlternativeIdentifiers(altIdentifiers);
    //            } else {
    //                log.warn("Found alias (gene name) without value. Ignoring");
    //            }
    //        }

    // aliases
    if (xmlInteractor.getNames() != null) {

        List<psidev.psi.mi.tab.model.Alias> tabAliases = new ArrayList<psidev.psi.mi.tab.model.Alias>();
        Collection<Alias> aliases = xmlInteractor.getNames().getAliases();

        if (aliases != null) {
            for (Alias alias : aliases) {

                String aliasValue = alias.getValue();

                if (aliasValue != null && aliasValue.trim().length() > 0) {
                    String db;
                    if (uniprotKeys.contains(alias.getType())) {
                        db = UNIPROT;
                    } else {
                        db = UNKNOWN;
                    }
                    psidev.psi.mi.tab.model.Alias a = new psidev.psi.mi.tab.model.AliasImpl(db, aliasValue);
                    a.setAliasType(alias.getType());
                    tabAliases.add(a);
                } else {
                    log.warn("Found alias without value. Ignoring alias");
                }
            }
        }

        // shortlabel
        //We put in alias because we don't have another place now
        String shortLabel = xmlInteractor.getNames().getShortLabel();
        if (shortLabel != null) {
            psidev.psi.mi.tab.model.Alias a = new psidev.psi.mi.tab.model.AliasImpl(UNKNOWN, shortLabel);
            a.setAliasType(SHORT_LABEL);
            tabAliases.add(a);

        }

        // fullName
        String fullName = xmlInteractor.getNames().getFullName();
        if (fullName != null) {
            psidev.psi.mi.tab.model.Alias a = new psidev.psi.mi.tab.model.AliasImpl(UNKNOWN, fullName);
            a.setAliasType(FULL_NAME);
            tabAliases.add(a);
        }

        /* Aliases Columns 5,6 */
        if (!tabAliases.isEmpty()) {
            tabInteractor.setAliases(tabAliases);
        }
    }

    // taxonomy
    if (xmlInteractor.hasOrganism()) {
        psidev.psi.mi.xml.model.Organism o = xmlInteractor.getOrganism();
        List<CrossReference> organismXrefs = new ArrayList<CrossReference>();
        String taxId = String.valueOf(o.getNcbiTaxId());

        if (o.hasNames()) {
            // shortlabel
            String shortLabel = o.getNames().getShortLabel();
            if (shortLabel != null) {
                organismXrefs.add(new CrossReferenceImpl("taxid", taxId, shortLabel));
            }

            // fullName
            String fullName = o.getNames().getFullName();
            if (fullName != null && !shortLabel.equalsIgnoreCase(fullName)) {
                organismXrefs.add(new CrossReferenceImpl("taxid", taxId, fullName));
            }

            if (shortLabel == null && fullName == null) {
                organismXrefs.add(new CrossReferenceImpl("taxid", taxId));
            }
        } else {
            organismXrefs.add(new CrossReferenceImpl("taxid", taxId));
        }

        /* Organism Columns 10, 11 */
        tabInteractor.setOrganism(new OrganismImpl(organismXrefs));
    }

    //biological roles
    if (xmlParticipant.hasBiologicalRole()) {

        List<CrossReference> tabBioRole = new ArrayList<CrossReference>();

        BiologicalRole xmlBioRole = xmlParticipant.getBiologicalRole();
        CrossReference cr = cvConverter.toMitab(xmlBioRole);

        if (cr != null) {
            tabBioRole.add(cr);
        }

        if (!tabBioRole.isEmpty()) {
            /* Biological Roles Columns 17, 18 */
            tabInteractor.setBiologicalRoles(tabBioRole);
        }
    }

    //experimental roles
    if (xmlParticipant.hasExperimentalRoles()) {

        List<CrossReference> tabExpRoles = new ArrayList<CrossReference>();
        Collection<ExperimentalRole> xmlExpRoles = xmlParticipant.getExperimentalRoles();

        for (ExperimentalRole xmlExpRole : xmlExpRoles) {
            CrossReference cr = cvConverter.toMitab(xmlExpRole);

            if (cr != null && !tabExpRoles.contains(cr)) {
                tabExpRoles.add(cr);
            }
        }

        if (!tabExpRoles.isEmpty()) {

            /* Biological Roles Columns 19, 20 */
            tabInteractor.setExperimentalRoles(tabExpRoles);
        }

    }

    //interactor type
    if (xmlInteractor.getInteractorType() != null) {

        List<CrossReference> tabInteractorType = new ArrayList<CrossReference>();

        InteractorType xmlInteractorType = xmlInteractor.getInteractorType();
        CrossReference cr = cvConverter.toMitab(xmlInteractorType);

        if (cr != null) {
            tabInteractorType.add(cr);
        }

        if (!tabInteractorType.isEmpty()) {

            /* Interactor Type Columns 21, 22 */
            tabInteractor.setInteractorTypes(tabInteractorType);
        }
    }

    //xrefs. See identifiers
    /* Xrefs Columns 23, 24 */

    //annotations && checksum
    List<Annotation> annotations = new ArrayList<Annotation>();
    List<Checksum> checksums = new ArrayList<Checksum>();

    if (xmlInteractor.getAttributes() != null) {
        Collection<Attribute> xmlInteractorAttributes = xmlInteractor.getAttributes();
        for (Attribute xmlInteractorAttribute : xmlInteractorAttributes) {
            String name = xmlInteractorAttribute.getName();
            String text = xmlInteractorAttribute.getValue();
            if (checksumNames.contains(name.toLowerCase())) {
                //Is a checksum
                checksums.add(new ChecksumImpl(name, text));
            } else {
                //Is a normal attribute
                annotations.add(new AnnotationImpl(name, text));
            }
        }
    }
    if (xmlParticipant.getAttributes() != null) {
        Collection<Attribute> xmlParticipantAttributes = xmlParticipant.getAttributes();
        for (Attribute xmlParticipantAttribute : xmlParticipantAttributes) {
            String name = xmlParticipantAttribute.getName();
            String text = xmlParticipantAttribute.getValue();
            if (checksumNames.contains(name.toLowerCase())) {
                //Is a checksum
                checksums.add(new ChecksumImpl(name, text));
            } else {
                //Is a normal attribute
                annotations.add(new AnnotationImpl(name, text));
            }
        }
    }

    if (!annotations.isEmpty()) {

        /* Annotations Columns 26, 27 */
        tabInteractor.setAnnotations(annotations);
    }

    if (!checksums.isEmpty()) {

        /* Annotations Columns 33, 34 */
        tabInteractor.setChecksums(checksums);
    }

    if (xmlParticipant.getFeatures() != null) {

        Collection<Feature> xmlFeatures = xmlParticipant.getFeatures();
        List<psidev.psi.mi.tab.model.Feature> tabFeatures = new ArrayList<psidev.psi.mi.tab.model.Feature>();

        for (Feature xmlFeature : xmlFeatures) {

            List<String> ranges = null;
            String tabFeatureType;
            String text = null;

            if (xmlFeature.getRanges() != null && !xmlFeature.getRanges().isEmpty()) {
                ranges = RangeUtils.toMitab(xmlFeature.getRanges());
            }

            if (xmlFeature.hasFeatureType()) {
                FeatureType featureType = xmlFeature.getFeatureType();
                if (featureType.hasNames()) {
                    String shortLabel = featureType.getNames().getShortLabel();
                    String fullName = featureType.getNames().getFullName();

                    if (shortLabel != null) {
                        tabFeatureType = shortLabel;
                    } else if (fullName != null) {
                        tabFeatureType = fullName;
                    } else {
                        throw new TabConversionException("The feature need a feature type");
                    }

                } else {
                    throw new TabConversionException("The feature need a feature type");
                }

            } else {
                throw new TabConversionException("The feature need a feature type");

            }

            if (xmlFeature.hasNames()) {

                String shortLabel = xmlFeature.getNames().getShortLabel();
                String fullName = xmlFeature.getNames().getFullName();

                if (shortLabel != null) {
                    text = shortLabel;
                } else if (fullName != null) {
                    text = fullName;
                }

            }
            tabFeatures.add(new FeatureImpl(tabFeatureType, ranges, text));
        }

        /* Features Columns 37, 38 */
        if (!tabFeatures.isEmpty()) {
            tabInteractor.setFeatures(tabFeatures);
        }

    }

    /* Stoichiometry Columns 39, 40 */
    if (xmlParticipant.getAttributes() != null) {
        Collection<Attribute> attributes = xmlParticipant.getAttributes();

        List<Integer> tabStoichiometry = new ArrayList<Integer>();

        for (Attribute attribute : attributes) {
            if (attribute.getName().equals("comment") || attribute.getNameAc().equals("MI:0612")) {
                if (attribute.getValue() != null && attribute.getValue().contains("Stoichiometry:")) {
                    String[] s = attribute.getValue().split(" ");
                    try {
                        if (s.length == 2) {
                            Float st = Float.parseFloat(s[1]);
                            tabStoichiometry.add(st.intValue());
                        }
                    } catch (NumberFormatException e) {
                        log.error("The stoichiometry can not be converted, " + attribute.toString(), e);
                    }
                }
            }
        }

        /* Stoichiometry Columns 39, 40 */
        if (!tabStoichiometry.isEmpty()) {
            tabInteractor.setStoichiometry(tabStoichiometry);
        }
    }

    if (xmlParticipant.getParticipantIdentificationMethods() != null) {

        List<psidev.psi.mi.tab.model.CrossReference> tabPartIdentMethods = new ArrayList<psidev.psi.mi.tab.model.CrossReference>();
        Collection<ParticipantIdentificationMethod> xmlPartIdentMethodsRoles = xmlParticipant
                .getParticipantIdentificationMethods();

        for (ParticipantIdentificationMethod xmlPartIdentMethodsRole : xmlPartIdentMethodsRoles) {
            psidev.psi.mi.tab.model.CrossReference cr = cvConverter.toMitab(xmlPartIdentMethodsRole);

            if (cr != null && !tabPartIdentMethods.contains(cr)) {
                tabPartIdentMethods.add(cr);
            }
        }

        if (!tabPartIdentMethods.isEmpty()) {

            /* Participant Identification Methods Columns 41, 42 */
            tabInteractor.setParticipantIdentificationMethods(tabPartIdentMethods);
        }

    }

    return tabInteractor;
}

From source file:org.transdroid.daemon.Synology.SynologyAdapter.java

private Torrent parseTorrent(long id, JSONObject jsonTorrent) throws JSONException, DaemonException {
    JSONObject additional = jsonTorrent.getJSONObject("additional");
    JSONObject detail = additional.getJSONObject("detail");
    JSONObject transfer = additional.getJSONObject("transfer");
    long downloaded = transfer.getLong("size_downloaded");
    int speed = transfer.getInt("speed_download");
    long size = jsonTorrent.getLong("size");
    Float eta = Float.valueOf(size - downloaded) / speed;
    int totalSeeders = 0;
    int totalLeechers = 0;
    if (additional.has("tracker")) {
        JSONArray tracker = additional.getJSONArray("tracker");
        for (int i = 0; i < tracker.length(); i++) {
            JSONObject t = tracker.getJSONObject(i);
            if ("Success".equals(t.getString("status"))) {
                totalLeechers += t.getInt("peers");
                totalSeeders += t.getInt("seeds");
            }//from  w w w .  j a  va  2 s.com
        }
    }
    // @formatter:off
    return new Torrent(id, jsonTorrent.getString("id"), jsonTorrent.getString("title"),
            torrentStatus(jsonTorrent.getString("status")), detail.getString("destination"), speed,
            transfer.getInt("speed_upload"), detail.getInt("connected_seeders"), totalSeeders,
            detail.getInt("connected_leechers"), totalLeechers, eta.intValue(), downloaded,
            transfer.getLong("size_uploaded"), size, (size == 0) ? 0 : (Float.valueOf(downloaded) / size), 0,
            jsonTorrent.getString("title"), new Date(detail.getLong("create_time") * 1000), null, "",
            settings.getType()
    // @formatter:on
    );
}

From source file:au.org.ala.layers.dao.LayerIntersectDAOImpl.java

/**
 * Single coordinate sampling./*from ww  w. j a v a 2  s.  co  m*/
 *
 * @param fieldIds  comma separated field ids.
 * @param longitude
 * @param latitude
 * @return the intersection value for each input field id as a \n separated
 * String.
 */
@Override
public String sampling(String fieldIds, double longitude, double latitude) {
    init();

    double[][] p = { { longitude, latitude } };
    String[] fields = fieldIds.split(",");

    //count el fields
    int elCount = 0;
    for (int i = 0; i < fields.length; i++) {
        if (fields[i].length() > 0 && fields[i].charAt(0) == 'e') {
            elCount++;
        }
    }

    StringBuilder sb = new StringBuilder();
    HashMap<String, Float> gridValues = null;
    for (String fid : fields) {
        IntersectionFile f = getConfig().getIntersectionFile(fid);

        if (sb.length() > 0) {
            sb.append("\n");
        }

        if (f != null) {
            if (f.getShapeFields() != null && getConfig().getShapeFileCache() != null) {
                SimpleShapeFile ssf = getConfig().getShapeFileCache().get(f.getFilePath());
                if (ssf != null) {
                    int column_idx = ssf.getColumnIdx(f.getShapeFields());
                    String[] categories = ssf.getColumnLookup(column_idx);
                    short[] idx = ssf.getColumnIdxs(f.getShapeFields());
                    int value = ssf.intersectInt(longitude, latitude);
                    if (value >= 0) {
                        sb.append(categories[idx[value]]);
                    }
                } else {
                    ObjectDAO objectDao = (ObjectDAO) appcontext.getBean("objectDao");
                    Objects o = objectDao.getObjectByIdAndLocation(f.getFieldId(), longitude, latitude);
                    if (o != null) {
                        sb.append(o.getName());
                    }
                }
            } else {
                if (gridValues == null && gridReaders != null && elCount > gridGroupCount) {
                    try {
                        GridCacheReader gcr = gridReaders.take();
                        gridValues = gcr.sample(longitude, latitude);
                        gridReaders.put(gcr);
                    } catch (Exception e) {
                        logger.error("GridCacheReader failed.", e);
                    }
                }

                if (gridValues != null) {
                    Float v = gridValues.get(fid);
                    if (v == null && !gridValues.containsKey(fid)) {
                        Grid g = new Grid(f.getFilePath());
                        if (g != null) {
                            float fv = g.getValues(p)[0];
                            if (f.getClasses() != null) {
                                GridClass gc = f.getClasses().get((int) fv);
                                if (gc != null) {
                                    sb.append(gc.getName());
                                }
                            } else {
                                if (!Float.isNaN(fv)) {
                                    sb.append(String.valueOf(fv));
                                }
                            }
                        }
                    } else {
                        if (f.getClasses() != null) {
                            GridClass gc = f.getClasses().get(v.intValue());
                            if (gc != null) {
                                sb.append(gc.getName());
                            }
                        } else {
                            if (v != null && !v.isNaN()) {
                                sb.append(String.valueOf(v));
                            }
                        }
                    }
                } else {
                    Grid g = new Grid(f.getFilePath());
                    if (g != null) {
                        float fv = g.getValues(p)[0];
                        if (f.getClasses() != null) {
                            GridClass gc = f.getClasses().get((int) fv);
                            if (gc != null) {
                                sb.append(gc.getName());
                            }
                        } else {
                            if (!Float.isNaN(fv)) {
                                sb.append(String.valueOf(fv));
                            }
                        }
                    }
                }
            }
        } else {
            String[] info = getConfig().getAnalysisLayerInfo(fid);

            if (info != null) {
                String filename = info[1];
                Grid grid = new Grid(filename);

                if (grid != null && (new File(filename + ".grd").exists())) {
                    sb.append(String.valueOf(grid.getValues(p)[0]));
                }
            }
        }
    }

    return sb.toString();
}

From source file:com.ecarinfo.weichexin.httpserver.module.CarManager.java

@RequestURI(value = "/addRemind", method = RequestMethod.GET)
public String addRemind(Long uid, String org_code, String bydate, Float bymiles, String njdate, String xbdate,
        String licenseDate, String changedate) {
    String html = null;//from  w  ww  . j a  v  a  2s.  c  o m
    try {
        FivesaasCarInfo five = this.genericDao.findOne(FivesaasCarInfo.class,
                new Criteria().eq(FivesaasCarInfoRM.wcxUserId, uid).eq(FivesaasCarInfoRM.orgCode, org_code,
                        CondtionSeparator.AND));
        Criteria whereBy = new Criteria();
        CarNoticeDto dto = new CarNoticeDto();
        this.updateMaintanceNoticeTime(five, bydate, bymiles);
        if (five.getMaintenanceNoticeTime() != null) {
            whereBy.update(FivesaasCarInfoRM.maintenanceNoticeTime,
                    DateUtils.dateToString(five.getMaintenanceNoticeTime(), TimeFormatter.FORMATTER1));
        } else {
            whereBy.update(FivesaasCarInfoRM.maintenanceNoticeTime, null);
        }
        if (StringUtils.isNotBlank(bydate)) {//?
            whereBy.update(FivesaasCarInfoRM.toMTime, bydate);
            dto.setNextMaintenanceTime(DateUtils.stringToDate(bydate, TimeFormatter.YYYY_MM_DD));
        }
        if (bymiles != null && bymiles > 0) {//?
            whereBy.update(FivesaasCarInfoRM.toMMileage, bymiles);
            dto.setNextMaintenanceMile(bymiles.intValue());
        }
        if (StringUtils.isNotBlank(njdate)) {//
            whereBy.update(FivesaasCarInfoRM.yearCheckDate, njdate);
            dto.setYearCheckTime(DateUtils.stringToDate(njdate, TimeFormatter.YYYY_MM_DD));
        }
        if (StringUtils.isNotBlank(xbdate)) {//?
            whereBy.update(FivesaasCarInfoRM.renewInsuranceDate, xbdate);
            dto.setXubaoNoticeTime(DateUtils.stringToDate(xbdate, TimeFormatter.YYYY_MM_DD));
        }
        if (StringUtils.isNotBlank(licenseDate)) {//
            whereBy.update(FivesaasCarInfoRM.drivingLicenseYearCareDate, licenseDate);
            dto.setDriveLiceiceSlaveTime(DateUtils.stringToDate(licenseDate, TimeFormatter.YYYY_MM_DD));
        }
        if (StringUtils.isNotBlank(changedate)) {//??
            whereBy.update(FivesaasCarInfoRM.drivingLicenseExpireDate, changedate);
            dto.setDriveLiceiceExpiredTime(DateUtils.stringToDate(changedate, TimeFormatter.YYYY_MM_DD));
        }
        this.genericService.updateWithCriteria(FivesaasCarInfo.class,
                whereBy.eq(FivesaasCarInfoRM.wcxUserId, uid).eq(FivesaasCarInfoRM.orgCode, org_code,
                        CondtionSeparator.AND));
        if (five.getCarSource() != 1) {//?
            logger.info("----------REMIND    SEND  START-----------------");
            dto.setCarId(five.getCarId());
            esCarNoticeService.updateNotice(dto);
            logger.info("----------REMIND    SEND  end-----------------");
        }
        html = "true";
    } catch (Exception e) {
        logger.error("??!", e);
        html = "false";
    }
    return html;
}

From source file:com.google.appinventor.components.runtime.GoogleMap.java

@SimpleFunction(description = "Set the property of an existing circle. Properties include: "
        + "\"alpha\"(number, value ranging from 0~255), \"color\" (nimber, hue value ranging 0~360), "
        + "\"radius\"(number in meters)")
public void UpdateCircle(int circleId, String propertyName, Object value) {
    Log.i(TAG, "inputs: " + circleId + "," + propertyName + ", " + value);
    float[] hsv = new float[3];
    Object circle = getCircleIfExisted(circleId); // if it's null, getCircleIfExisted will show error msg
    Circle updateCircle = null; // the real circle content that gets updated

    if (circle != null) {
        if (circle instanceof DraggableCircle) {
            updateCircle = ((DraggableCircle) circle).getCircle();

        }/* w w w. j  a  va 2 s . co m*/
        if (circle instanceof Circle) {
            updateCircle = (Circle) circle;

        }
        try {

            Float val = Float.parseFloat(value.toString());
            if (propertyName.equals("alpha")) {

                int color = updateCircle.getFillColor();
                Color.colorToHSV(color, hsv);
                Integer alphaVal = val.intValue();
                //Color.HSVToColor(mAlpha, new float[] {mColorHue, 1, 1});//default to red, medium level hue color
                int newColor = Color.HSVToColor(alphaVal, hsv);
                updateCircle.setFillColor(newColor);
            }

            if (propertyName.equals("color")) {
                int alpha = Color.alpha(updateCircle.getFillColor());

                int newColor = Color.HSVToColor(alpha, new float[] { val, 1, 1 });
                updateCircle.setFillColor(newColor);
            }

            if (propertyName.equals("radius")) {
                // need to cast value to float
                Float radius = val;
                updateCircle.setRadius(radius);
                // if it's a draggableCircle, then we need to remove the previous marker and get new radius marker
                if (circle instanceof DraggableCircle) {
                    // remove previous radius marker
                    Marker centerMarker = ((DraggableCircle) circle).getCenterMarker();
                    Marker oldMarker = ((DraggableCircle) circle).getRadiusMarker();
                    oldMarker.remove();
                    Marker newMarker = mMap.addMarker(new MarkerOptions()
                            .position(toRadiusLatLng(centerMarker.getPosition(), radius)).draggable(true)
                            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));

                    ((DraggableCircle) circle).setRadiusMarker(newMarker);
                    // create a new draggabble circle

                }

            }

        } catch (NumberFormatException e) { //can't parse the string
            form.dispatchErrorOccurredEvent(this, "UpdateCircle", ErrorMessages.ERROR_GOOGLE_MAP_INVALID_INPUT,
                    value.toString());
        }

    } else {
        // the circle doesn't exist
        form.dispatchErrorOccurredEvent(this, "UpdateCircle", ErrorMessages.ERROR_GOOGLE_MAP_CIRCLE_NOT_EXIST,
                circleId);
    }
}