Example usage for java.lang Double floatValue

List of usage examples for java.lang Double floatValue

Introduction

In this page you can find the example usage for java.lang Double floatValue.

Prototype

public float floatValue() 

Source Link

Document

Returns the value of this Double as a float after a narrowing primitive conversion.

Usage

From source file:com.gwac.service.Ot2CheckServiceImpl.java

void searchOT2(OtLevel2 ot2) {

    if (ot2.getRa() < 0 || ot2.getRa() > 360 || ot2.getDec() < -90 || ot2.getDec() > 90) {
        return;//w w  w .  j a  va 2  s  .c o  m
    }
    log.debug("search ot2: " + ot2.getName());
    Boolean flag = false;
    Map<Cvs, Double> tcvsm = matchOt2InCvs(ot2, cvsSearchbox, cvsMag);
    for (Map.Entry<Cvs, Double> entry : tcvsm.entrySet()) {
        Cvs tcvs = (Cvs) entry.getKey();
        Double distance = (Double) entry.getValue();
        MatchTable ott = mtDao.getMatchTableByTypeName("cvs");
        OtLevel2Match ot2m = new OtLevel2Match();
        ot2m.setOtId(ot2.getOtId());
        ot2m.setMtId(ott.getMtId());
        ot2m.setMatchId(Long.valueOf(tcvs.getIdnum()));
        ot2m.setRa(tcvs.getRadeg());
        ot2m.setDec(tcvs.getDedeg());
        ot2m.setMag(tcvs.getMag());
        ot2m.setDistance(distance.floatValue());
        ot2m.setD25(new Float(0));
        ot2mDao.save(ot2m);

        String cvsInfo = tcvs.getCvsid() + " " + tcvs.getRadeg() + " " + tcvs.getDedeg() + " " + tcvs.getMag();
        log.debug("cvsInfo: " + cvsInfo);
        flag = true;
    }
    if (tcvsm.size() > 0) {
        ot2.setCvsMatch((short) tcvsm.size());
        ot2Dao.updateCvsMatch(ot2);
        log.debug(ot2.getName() + " cvs :" + tcvsm.size());
    }

    Map<MergedOther, Double> tmom = matchOt2InMergedOther(ot2, mergedSearchbox, mergedMag);
    for (Map.Entry<MergedOther, Double> entry : tmom.entrySet()) {
        MergedOther tmo = (MergedOther) entry.getKey();
        Double distance = (Double) entry.getValue();

        MatchTable ott = getMtDao().getMatchTableByTypeName("merged_other");
        OtLevel2Match ot2m = new OtLevel2Match();
        ot2m.setOtId(ot2.getOtId());
        ot2m.setMtId(ott.getMtId());
        ot2m.setMatchId(Long.valueOf(tmo.getIdnum()));
        ot2m.setRa(tmo.getRadeg());
        ot2m.setDec(tmo.getDedeg());
        ot2m.setMag(tmo.getMag());
        ot2m.setDistance(distance.floatValue());
        ot2m.setD25(new Float(0));
        ot2mDao.save(ot2m);

        String moInfo = tmo.getIdnum() + " " + tmo.getRadeg() + " " + tmo.getDedeg() + " " + tmo.getMag();
        log.debug("moInfo: " + moInfo);
        flag = true;
    }
    if (tmom.size() > 0) {
        ot2.setOtherMatch((short) tmom.size());
        ot2Dao.updateOtherMatch(ot2);
        log.debug(ot2.getName() + " other :" + tmom.size());
    }

    Map<Rc3, Double> trc3m = matchOt2InRc3(ot2, rc3Searchbox, rc3MinMag, rc3MaxMag);
    for (Map.Entry<Rc3, Double> entry : trc3m.entrySet()) {
        Rc3 trc3 = (Rc3) entry.getKey();
        Double distance = (Double) entry.getValue();

        MatchTable ott = getMtDao().getMatchTableByTypeName("rc3");
        OtLevel2Match ot2m = new OtLevel2Match();
        ot2m.setOtId(ot2.getOtId());
        ot2m.setMtId(ott.getMtId());
        ot2m.setMatchId(Long.valueOf(trc3.getIdnum()));
        ot2m.setRa(trc3.getRadeg());
        ot2m.setDec(trc3.getDedeg());
        ot2m.setMag(trc3.getMvmag());
        ot2m.setDistance(distance.floatValue());
        ot2m.setD25(trc3.getD25());
        ot2mDao.save(ot2m);

        String moInfo = trc3.getIdnum() + " " + trc3.getRadeg() + " " + trc3.getDedeg() + " " + trc3.getMvmag();
        log.debug("rc3Info: " + moInfo);
        flag = true;
    }
    if (trc3m.size() > 0) {
        ot2.setRc3Match((short) trc3m.size());
        ot2Dao.updateRc3Match(ot2);
        log.debug(ot2.getName() + " rc3 :" + trc3m.size());
    }

    Map<MinorPlanet, Double> tmpm = matchOt2InMinorPlanet(ot2, minorPlanetSearchbox, minorPlanetMag);//minorPlanetSearchbox
    for (Map.Entry<MinorPlanet, Double> entry : tmpm.entrySet()) {
        MinorPlanet tmp = (MinorPlanet) entry.getKey();
        Double distance = (Double) entry.getValue();

        MatchTable ott = getMtDao().getMatchTableByTypeName("minor_planet");
        OtLevel2Match ot2m = new OtLevel2Match();
        ot2m.setOtId(ot2.getOtId());
        ot2m.setMtId(ott.getMtId());
        ot2m.setMatchId(Long.valueOf(tmp.getIdnum()));
        ot2m.setRa(tmp.getLon());
        ot2m.setDec(tmp.getLat());
        ot2m.setMag(tmp.getVmag());
        ot2m.setDistance(distance.floatValue());
        ot2m.setD25(new Float(0));
        ot2mDao.save(ot2m);

        String moInfo = tmp.getIdnum() + " " + tmp.getMpid() + " " + tmp.getLon() + " " + tmp.getLat();
        log.debug("moInfo: " + moInfo);
        flag = true;
    }
    if (tmpm.size() > 0) {
        ot2.setMinorPlanetMatch((short) tmpm.size());
        ot2Dao.updateMinorPlanetMatch(ot2);
        log.debug(ot2.getName() + " minor planet :" + tmpm.size());
    }

    long startTime = System.nanoTime();
    Map<OtLevel2, Double> tOT2Hism = matchOt2His(ot2, ot2Searchbox, 0);
    Boolean hisType = false;
    for (Map.Entry<OtLevel2, Double> entry : tOT2Hism.entrySet()) {
        OtLevel2 tot2 = (OtLevel2) entry.getKey();
        Double distance = (Double) entry.getValue();

        MatchTable ott = getMtDao().getMatchTableByTypeName("ot_level2_his");
        OtLevel2Match ot2m = new OtLevel2Match();
        ot2m.setOtId(ot2.getOtId());
        ot2m.setMtId(ott.getMtId());
        ot2m.setMatchId(Long.valueOf(tot2.getOtId()));
        ot2m.setRa(tot2.getRa());
        ot2m.setDec(tot2.getDec());
        ot2m.setMag(tot2.getMag());
        ot2m.setDistance(distance.floatValue());
        ot2mDao.save(ot2m);
        flag = true;

        if (!hisType && tot2.getOtType() != null
                && ((tot2.getOtType() >= 8 && tot2.getOtType() <= 11) || tot2.getOtType() == 15)) {
            ot2.setOtType(tot2.getOtType());
            ot2Dao.updateOTType(ot2);
            hisType = true;
        }
    }
    if (tOT2Hism.size() > 0) {
        ot2.setOt2HisMatch((short) tOT2Hism.size());
        ot2Dao.updateOt2HisMatch(ot2);
        log.debug(ot2.getName() + " ot2his :" + tOT2Hism.size());
    }
    long endTime = System.nanoTime();
    log.debug("search ot2 history consume " + 1.0 * (endTime - startTime) / 1e9 + " seconds.");

    if (ot2.getDataProduceMethod() == '8') {
        startTime = System.nanoTime();
        Map<UsnoCatalog, Double> tusno = matchOt2InUsnoCatalog2(ot2);//minorPlanetSearchbox
        //      log.debug("ot2: " + ot2.getName());
        //        log.debug("usnoMag: " + usnoMag);
        //      log.debug("usno match size: " + tusno.size());
        for (Map.Entry<UsnoCatalog, Double> entry : tusno.entrySet()) {
            UsnoCatalog tmp = (UsnoCatalog) entry.getKey();
            Double distance = (Double) entry.getValue();

            MatchTable ott = getMtDao().getMatchTableByTypeName("usno");
            OtLevel2Match ot2m = new OtLevel2Match();
            ot2m.setOtId(ot2.getOtId());
            ot2m.setMtId(ott.getMtId());
            ot2m.setMatchId(Long.valueOf(tmp.getRcdid()));
            ot2m.setRa(tmp.getrAdeg());
            ot2m.setDec(tmp.getdEdeg());
            ot2m.setMag(tmp.getRmag());
            ot2m.setDistance(distance.floatValue());
            ot2m.setD25(new Float(0));
            ot2mDao.save(ot2m);
            flag = true;
        }
        if (tusno.size() > 0) {
            ot2.setUsnoMatch((short) tusno.size());
            ot2Dao.updateUsnoMatch(ot2);
            log.debug(ot2.getName() + " usno :" + tusno.size());
        }
        endTime = System.nanoTime();
        log.debug("search usno table consume " + 1.0 * (endTime - startTime) / 1e9 + " seconds.");
    }

    try {
        boolean tflag = filtOT2InCcdPixel(ot2);
        if (tflag) {
            flag = tflag;
        }
    } catch (Exception e) {
        log.error("filt ot2 " + ot2.getName() + " in ccd pixel error!", e);
    }

    if (flag) {
        ot2.setIsMatch((short) 2);
        ot2Dao.updateIsMatch(ot2);
    } else {//???
        ot2.setIsMatch((short) 1);
        ot2Dao.updateIsMatch(ot2);
    }
}

From source file:net.kjmaster.cookiemom.summary.SummarySalesFragment.java

@AfterViews
void afterViews() {
    List<CookieTransactions> list = Main.daoSession.getCookieTransactionsDao().loadAll();
    int total = 0;
    Double totalCash = 0.0;
    int totalScout = 0;
    int totalBooth = 0;
    Double totalScoutCash = 0.0;//  ww w .  ja  va2s  . c om
    Double totalBoothCash = 0.0;
    final HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
    for (CookieTransactions cookieTransactions : list) {

        totalCash += cookieTransactions.getTransCash();
        if (cookieTransactions.getTransBoothId() >= 0) {
            totalBooth += (cookieTransactions.getTransBoxes());
            totalBoothCash += cookieTransactions.getTransCash();
        } else {
            if (cookieTransactions.getTransScoutId() >= 0) {
                totalScout += (cookieTransactions.getTransBoxes());
                totalScoutCash += cookieTransactions.getTransCash();
            } else {
                total += cookieTransactions.getTransBoxes();
            }

        }
    }
    NumberFormat fmt = NumberFormat.getCurrencyInstance();
    fmt.setMaximumFractionDigits(0);
    fmt.setMinimumFractionDigits(0);

    ArrayList<Bar> points = new ArrayList<Bar>();
    Bar d = new Bar();

    d.setColor(getResources().getColor(R.color.bar_due));
    d.setName("Due");
    d.setValue(total * 4);
    hashMap.put("Due", total);
    d.setValueString(fmt.format(total * 4));
    Bar d2 = new Bar();
    d2.setColor(getResources().getColor(R.color.bar_cash));
    d2.setName("Cash");
    d2.setValue(totalCash.floatValue());
    d2.setValueString(fmt.format(totalCash));
    hashMap.put("Cash", (totalBooth + totalScout) * -1);
    //        Bar d3=new Bar();
    //        d3.setColor(Color.parseColor("#99CC00"));
    //        d3.setName("Booths");
    //        d3.setValue(totalBooth*-4);
    //        d3.setValueString(fmt.format(totalBooth*4));
    Bar d4 = new Bar();
    d4.setColor(getResources().getColor(R.color.bar_booth));
    d4.setName("Booths");
    d4.setValue(totalBoothCash.floatValue());
    d4.setValueString(fmt.format(totalBoothCash));
    hashMap.put("Booths", totalBooth * -1);
    //     Bar d5=new Bar();
    //        d5.setColor(Color.parseColor("#99CC00"));
    //        d5.setName("Scouts");
    //        d5.setValue(totalScout*-4);
    //        d5.setValueString(fmt.format(totalScout*4));
    Bar d6 = new Bar();
    d6.setColor(getResources().getColor(R.color.bar_scout));
    d6.setName("Scouts");
    d6.setValue(totalScoutCash.floatValue());
    d6.setValueString(fmt.format(totalScoutCash));
    hashMap.put("Scouts", totalScout * -1);
    points.add(d);
    points.add(d2);
    //points.add(d3);
    points.add(d4);
    //       points.add(d5);
    points.add(d6);

    BarGraph g = barGraph;
    g.setBars(points);

    g.setOnBarClickedListener(new BarGraph.OnBarClickedListener() {

        @Override
        public void onClick(int index) {
            legend.setText(hashMap.get(barGraph.getBars().get(index).getName()).toString() + " bxs.");
        }

    });
}

From source file:com.wikitude.phonegap.WikitudePlugin.java

@Override
public boolean execute(final String action, final JSONArray args, final CallbackContext callContext) {

    /* hide architect-view -> destroy and remove from activity */
    if (WikitudePlugin.ACTION_CLOSE.equals(action)) {
        if (this.architectView != null) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override/*www  .  ja  v  a 2  s. c o m*/
                public void run() {
                    removeArchitectView();
                }
            });
            callContext.success(action + ": architectView is present");
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* return success only if view is opened (no matter if visible or not) */
    if (WikitudePlugin.ACTION_STATE_ISOPEN.equals(action)) {
        if (this.architectView != null) {
            callContext.success(action + ": architectView is present");
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* return success only if view is opened (no matter if visible or not) */
    if (WikitudePlugin.ACTION_IS_DEVICE_SUPPORTED.equals(action)) {
        if (ArchitectView.isDeviceSupported(this.cordova.getActivity()) && hasNeonSupport()) {
            callContext.success(action + ": this device is ARchitect-ready");
        } else {
            callContext.error(action + action + ":Sorry, this device is NOT ARchitect-ready");
        }
        return true;
    }

    if (WikitudePlugin.ACTION_CAPTURE_SCREEN.equals(action)) {
        if (architectView != null) {

            int captureMode = ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW;

            try {
                captureMode = (args.getBoolean(0))
                        ? ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW
                        : ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM;
            } catch (Exception e) {
                // unexpected error;
            }

            architectView.captureScreen(captureMode, new CaptureScreenCallback() {

                @Override
                public void onScreenCaptured(Bitmap screenCapture) {
                    try {
                        // final File imageDirectory = cordova.getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
                        final File imageDirectory = Environment.getExternalStorageDirectory();
                        if (imageDirectory == null) {
                            callContext.error("External storage not available");
                        }

                        final File screenCaptureFile = new File(imageDirectory,
                                System.currentTimeMillis() + ".jpg");

                        if (screenCaptureFile.exists()) {
                            screenCaptureFile.delete();
                        }
                        final FileOutputStream out = new FileOutputStream(screenCaptureFile);
                        screenCapture.compress(Bitmap.CompressFormat.JPEG, 90, out);
                        out.flush();
                        out.close();

                        cordova.getActivity().runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                final String absoluteCaptureImagePath = screenCaptureFile.getAbsolutePath();
                                callContext.success(absoluteCaptureImagePath);

                                //                         in case you want to sent the pic to other applications, uncomment these lines (for future use)
                                //                        final Intent share = new Intent(Intent.ACTION_SEND);
                                //                        share.setType("image/jpg");
                                //                        share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(screenCaptureFile));
                                //                        final String chooserTitle = "Share Snaphot";
                                //                        cordova.getActivity().startActivity(Intent.createChooser(share, chooserTitle));
                            }
                        });
                    } catch (Exception e) {
                        callContext.error(e.getMessage());
                    }

                }
            });
            return true;
        }
    }

    /* life-cycle's RESUME */
    if (WikitudePlugin.ACTION_ON_RESUME.equals(action)) {

        if (this.architectView != null) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    WikitudePlugin.this.architectView.onResume();
                    callContext.success(action + ": architectView is present");
                    locationProvider.onResume();
                }
            });

            // callContext.success( action + ": architectView is present" );
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* life-cycle's PAUSE */
    if (WikitudePlugin.ACTION_ON_PAUSE.equals(action)) {
        if (architectView != null) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    WikitudePlugin.this.architectView.onPause();
                    locationProvider.onPause();
                }
            });

            callContext.success(action + ": architectView is present");
        } else {
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    /* set visibility to "visible", return error if view is null */
    if (WikitudePlugin.ACTION_SHOW.equals(action)) {

        this.cordova.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (architectView != null) {
                    architectView.setVisibility(View.VISIBLE);
                    callContext.success(action + ": architectView is present");
                } else {
                    callContext.error(action + ": architectView is not present");
                }
            }
        });

        return true;
    }

    /* set visibility to "invisible", return error if view is null */
    if (WikitudePlugin.ACTION_HIDE.equals(action)) {

        this.cordova.getActivity().runOnUiThread(new Runnable() {

            @Override
            public void run() {
                if (architectView != null) {
                    architectView.setVisibility(View.INVISIBLE);
                    callContext.success(action + ": architectView is present");
                } else {
                    callContext.error(action + ": architectView is not present");
                }
            }
        });

        return true;
    }

    /* define call-back for url-invocations */
    if (WikitudePlugin.ACTION_ON_URLINVOKE.equals(action)) {
        this.urlInvokeCallback = callContext;
        final PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT,
                action + ": registered callback");
        result.setKeepCallback(true);
        callContext.sendPluginResult(result);
        return true;
    }

    /* location update */
    if (WikitudePlugin.ACTION_SET_LOCATION.equals(action)) {
        if (this.architectView != null) {
            try {
                final double lat = args.getDouble(0);
                final double lon = args.getDouble(1);
                float alt = Float.MIN_VALUE;
                try {
                    alt = (float) args.getDouble(2);
                } catch (Exception e) {
                    // invalid altitude -> ignore it
                }
                final float altitude = alt;
                Double acc = null;
                try {
                    acc = args.getDouble(3);
                } catch (Exception e) {
                    // invalid accuracy -> ignore it
                }
                final Double accuracy = acc;
                if (this.cordova != null && this.cordova.getActivity() != null) {
                    cordova.getActivity().runOnUiThread(
                            //                  this.cordova.getThreadPool().execute( 
                            new Runnable() {

                                @Override
                                public void run() {
                                    if (accuracy != null) {
                                        WikitudePlugin.this.architectView.setLocation(lat, lon, altitude,
                                                accuracy.floatValue());
                                    } else {
                                        WikitudePlugin.this.architectView.setLocation(lat, lon, altitude);
                                    }
                                }
                            });
                }

            } catch (Exception e) {
                callContext.error(
                        action + ": exception thrown, " + e != null ? e.getMessage() : "(exception is NULL)");
                return true;
            }
            callContext.success(action + ": updated location");
            return true;
        } else {
            /* return error if there is no architect-view active*/
            callContext.error(action + ": architectView is not present");
        }
        return true;
    }

    if (WikitudePlugin.ACTION_CALL_JAVASCRIPT.equals(action)) {

        String logMsg = null;
        try {
            final String callJS = args.getString(0);
            logMsg = callJS;

            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    if (architectView != null) {
                        WikitudePlugin.this.architectView.callJavascript(callJS);
                    } else {
                        callContext.error(action + ": architectView is not present");
                    }
                }
            });

        } catch (JSONException je) {
            callContext.error(
                    action + ": exception thrown, " + je != null ? je.getMessage() : "(exception is NULL)");
            return true;
        }
        callContext.success(action + ": called js, '" + logMsg + "'");

        return true;
    }

    /* initial set-up, show ArchitectView full-screen in current screen/activity */
    if (WikitudePlugin.ACTION_OPEN.equals(action)) {
        this.openCallback = callContext;
        PluginResult result = null;
        try {
            final String apiKey = args.getString(0);
            final String filePath = args.getString(1);

            this.cordova.getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    try {
                        WikitudePlugin.this.addArchitectView(apiKey, filePath);

                        /* call success method once architectView was added successfully */
                        if (openCallback != null) {
                            PluginResult result = new PluginResult(PluginResult.Status.OK);
                            result.setKeepCallback(false);
                            openCallback.sendPluginResult(result);
                        }
                    } catch (Exception e) {
                        /* in case "addArchitectView" threw an exception -> notify callback method asynchronously */
                        openCallback.error(e != null ? e.getMessage() : "Exception is 'null'");
                    }
                }
            });

        } catch (Exception e) {
            result = new PluginResult(PluginResult.Status.ERROR,
                    action + ": exception thown, " + e != null ? e.getMessage() : "(exception is NULL)");
            result.setKeepCallback(false);
            callContext.sendPluginResult(result);
            return true;
        }

        /* adding architect-view is done in separate thread, ensure to setKeepCallback so one can call success-method properly later on */
        result = new PluginResult(PluginResult.Status.NO_RESULT,
                action + ": no result required, just registered callback-method");
        result.setKeepCallback(true);
        callContext.sendPluginResult(result);
        return true;
    }

    /* fall-back return value */
    callContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, "no such action: " + action));
    return false;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.masterDegree.administrativeOffice.MakeCandidateStudyPlanDispatchAction.java

/**
 * @param mapping//w  ww. j a  v  a 2 s  .  com
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */

public ActionForward chooseCurricularCourses(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    User userView = Authenticate.getUser();

    DynaActionForm chooseCurricularCoursesForm = (DynaActionForm) form;

    String[] selection = (String[]) chooseCurricularCoursesForm.get("selection");
    String degreeCurricularPlanID = (String) chooseCurricularCoursesForm.get("degreeCurricularPlanID");

    request.setAttribute("degreeCurricularPlanID", degreeCurricularPlanID);

    if (!validChoice(selection)) {
        throw new NoChoiceMadeActionException(null);
    }

    String candidateID = (String) chooseCurricularCoursesForm.get("candidateID");

    String attributedCreditsString = (String) chooseCurricularCoursesForm.get("attributedCredits");

    Double attributedCredits = null;
    if ((attributedCreditsString == null) || (attributedCreditsString.length() == 0)) {
        attributedCredits = new Double(0);
    } else {
        attributedCredits = Double.valueOf(attributedCreditsString);
    }

    String givenCreditsRemarks = (String) chooseCurricularCoursesForm.get("givenCreditsRemarks");

    Set<String> selectedCurricularCourses = convertStringArrayToSet(selection);

    try {

        WriteCandidateEnrolments.runWriteCandidateEnrolments(selectedCurricularCourses, candidateID,
                attributedCredits, givenCreditsRemarks);
    } catch (NotAuthorizedException e) {
        throw new NotAuthorizedActionException(e);
    } catch (NonExistingServiceException e) {
        throw new NonExistingActionException(e);
    }

    List candidateEnrolments = null;

    try {
        candidateEnrolments = ReadCandidateEnrolmentsByCandidateID
                .runReadCandidateEnrolmentsByCandidateID(candidateID);
    } catch (FenixServiceException e) {
        throw new FenixActionException(e);
    }

    Iterator coursesIter = candidateEnrolments.iterator();
    float credits = attributedCredits.floatValue();

    while (coursesIter.hasNext()) {
        InfoCandidateEnrolment infoCandidateEnrolment = (InfoCandidateEnrolment) coursesIter.next();

        credits += infoCandidateEnrolment.getInfoCurricularCourse().getCredits().floatValue();
    }

    request.setAttribute("givenCredits", new Double(credits));

    if ((candidateEnrolments != null) && (candidateEnrolments.size() != 0)) {
        orderCandidateEnrolments(candidateEnrolments);
        request.setAttribute("candidateEnrolments", candidateEnrolments);
    }

    InfoExecutionDegree infoExecutionDegree = null;

    try {
        infoExecutionDegree = ReadExecutionDegreeByCandidateID.runReadExecutionDegreeByCandidateID(candidateID);
    } catch (FenixServiceException e) {
        throw new FenixActionException(e);
    }

    request.setAttribute("executionDegree", infoExecutionDegree);
    request.setAttribute("candidateID", candidateID);

    return mapping.findForward("ChooseSuccess");
}

From source file:uk.ac.diamond.scisoft.ncd.rcp.views.NcdDataReductionParameters.java

@Override
public void saveState(IMemento memento) {

    if (memento != null) {
        memento.putBoolean(NcdPreferences.NCD_STAGE_NORMALISATION, normButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_STAGE_BACKGROUND, bgButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_STAGE_RESPONSE, drButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_STAGE_SECTOR, secButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_STAGE_INVARIANT, invButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_STAGE_AVERAGE, aveButton.getSelection());

        memento.putBoolean(NcdPreferences.NCD_SECTOR_RADIAL, radialButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_SECTOR_AZIMUTH, azimuthalButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_SECTOR_FAST, fastIntButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_SECTOR_MASK, useMask.getSelection());
        memento.putString(NcdPreferences.NCD_SECTOR_MASKFILE, maskFileSelector.getText());

        memento.putBoolean(NcdPreferences.NCD_PLOT_LOGLOG, loglogButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_PLOT_GUINIER, guinierButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_PLOT_POROD, porodButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_PLOT_KRATKY, kratkyButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_PLOT_ZIMM, zimmButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_PLOT_DEBYEBUECHE, debyebuecheButton.getSelection());

        memento.putString(NcdPreferences.NCD_BACKGROUNDSUBTRACTION, bgFileSelector.getText());
        memento.putString(NcdPreferences.NCD_DETECTORRESPONSE, drFileSelector.getText());

        Double sampleThicknessVal = getSampleThickness();
        if (sampleThicknessVal != null) {
            memento.putFloat(NcdPreferences.NCD_SAMPLETHICKNESS, sampleThicknessVal.floatValue());
        }//from   w  w  w.  j  av a 2s .  c o m
        Double absScaleVal = getAbsScale();
        if (absScaleVal != null) {
            memento.putFloat(NcdPreferences.NCD_ABSOLUTESCALE, absScaleVal.floatValue());
        }
        Double bgScaleVal = getBgScale();
        if (bgScaleVal != null) {
            memento.putFloat(NcdPreferences.NCD_BACKGROUNDSCALE, bgScaleVal.floatValue());
        }
        memento.putString(NcdPreferences.NCD_BGFIRSTFRAME, bgFramesStart.getText());
        memento.putString(NcdPreferences.NCD_BGLASTFRAME, bgFramesStop.getText());
        memento.putString(NcdPreferences.NCD_BGFRAMESELECTION, bgAdvanced.getText());
        memento.putString(NcdPreferences.NCD_DATAFIRSTFRAME, detFramesStart.getText());
        memento.putString(NcdPreferences.NCD_DATALASTFRAME, detFramesStop.getText());
        memento.putString(NcdPreferences.NCD_DATAFRAMESELECTION, detAdvanced.getText());
        memento.putBoolean(NcdPreferences.NCD_BGADVANCED, bgAdvancedButton.getSelection());
        memento.putBoolean(NcdPreferences.NCD_DATAADVANCED, detAdvancedButton.getSelection());

        memento.putString(NcdPreferences.NCD_GRIDAVERAGESELECTION, gridAverage.getText());
        memento.putBoolean(NcdPreferences.NCD_GRIDAVERAGE, gridAverageButton.getSelection());

        memento.putString(NcdPreferences.NCD_DIRECTORY, inputDirectory);

        memento.putBoolean(NcdPreferences.NCD_USEFORMSAMPLETHICKNESS,
                useFormSampleThicknessButton.getSelection());
    }
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void ambientSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_ambientSpinnerStateChanged
{//GEN-HEADEREND:event_ambientSpinnerStateChanged

    final JSpinner source = (JSpinner) evt.getSource();

    Double value = (Double) ambientSpinner.getValue();

    this.parent.getParameters().getRenderParameters().setAmbient(value.floatValue());
}

From source file:com.visionet.platform.cooperation.service.OrderService.java

/**
 * ?// www  .  j  av  a  2s  .  c  o m
 *
 * @return
 * @throws Exception
 */
public OrderResultDTO insertOrder(String partnerOrderId, String partnerOrderNo, Integer businessType,
        Integer orderType, String carType, String startPlace, String startGps, String endPlace,
        Double expectedKm, String endGps, String expectedPrice, String customerPhone, String customerName,
        String callDate, String bookDate, Integer orderSource, String city, Integer cityId, String sign,
        String channel) throws Exception {
    if (!"1".equals(RECIVE_SHOUYUE_ORDER)) {
        throw new BizException("?");
    }

    if (cityId == null || "".equals(cityId)) {
        throw new BizException("?ID?");
    }
    ThirdPartyCity thirdPartyCity = thirdPartyCityMapper.selectByDzcxCityId(cityId, 1);
    if (thirdPartyCity == null) {
        throw new BizException("?");
    }
    Integer reciveOrder = thirdPartyCity.getReciveOrder();
    if (reciveOrder == 0) {
        throw new BizException("?");
    }
    Date orderBookDate = null;
    // ----------------?? -------------------
    if (StringUtils.isEmpty(partnerOrderId)) {
        throw new BizException("???ID");
    }
    if (StringUtils.isEmpty(partnerOrderNo)) {
        throw new BizException("???");
    }
    ThirdPartyOrder tpo = thirdPartyOrderMapper.selectOneByPartnerOrderNo(partnerOrderNo);
    if (tpo != null) {
        throw new BizException("???");
    }
    if (StringUtils.isEmpty(customerPhone)) {
        throw new BizException("??");
    }
    if (expectedKm == null || "".equals(expectedKm)) {
        throw new BizException("");
    }
    if (expectedPrice == null || "".equals(expectedPrice)) {
        throw new BizException("?");
    }
    if (StringUtils.isEmpty(bookDate)) {
        throw new BizException("??");
    } else {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            orderBookDate = sdf.parse(bookDate);
        } catch (Exception e) {
            throw new BizException("???yyyy-MM-dd HH:mm:ss");
        }
        if (orderBookDate.before(new Date())) {
            throw new BizException("????");
        }
    }
    if (orderType == null || "".equals(orderType)) {
        throw new BizException("?");
    }

    if (StringUtils.isEmpty(city)) {
        throw new BizException("??");
    }
    if (businessType == null || "".equals(businessType)) {
        throw new BizException("??");
    }
    // ----------------?? ?-------------------

    // -------------??? ------------------
    Customer customer = customerMapper.selectByPrimaryKey(customerPhone);
    if (customer == null) {
        // ?
        Customer customer_new = new Customer();
        customer_new.setPhone(customerPhone);
        customer_new.setName(customerName);
        customer_new.setCreateDate(new Date());
        customer_new.setDelFlag(1);
        customer_new.setIsValid(0);
        customer_new.setLevel(1);
        customer_new.setIsApp(0);// 0APP
        customer_new.setStatus(4);// 4
        customer_new.setIsLogin(0);// 10
        customer_new.setSource("5");// 5
        customer_new.setCity(city);
        customer_new.setCityId(cityId);
        customerMapper.insertSelective(customer_new);
    }
    // -----------------??? ?---------------

    // ----------------------? ---------------------
    OrderResultDTO orderResultDTO = new OrderResultDTO();
    Order tOrder = new Order();
    Date date = new Date();
    String orderID = OrderCreaterUtil.createrOrder(businessType + "");
    tOrder.setOrderId(orderID);
    tOrder.setBusinessType(businessType);
    tOrder.setOrderType(orderType);// 6 
    tOrder.setOrderSource(4);// 4 
    tOrder.setCarType(carType);
    tOrder.setCarNumber(1);
    tOrder.setStartPlace(startPlace);
    tOrder.setStartGps(startGps);
    tOrder.setEndPlace(endPlace);
    tOrder.setEndGps(endGps);
    tOrder.setCustomerPhone(customerPhone);
    tOrder.setCustomerName(customerName);
    tOrder.setCallDate(date);// ??
    tOrder.setStatus(0);// ?0
    tOrder.setExpectedKm(expectedKm.floatValue());
    tOrder.setVirtual(0f);
    tOrder.setExpectedPrice(Float.valueOf(expectedPrice));
    tOrder.setIncreasePrice(0.0);
    tOrder.setIncreaseType(0);// ?012
    tOrder.setCity(city);
    tOrder.setCityId(cityId);
    tOrder.setBookDate(orderBookDate);

    orderMapper.insertSelective(tOrder);// ?

    SQSService.put(JSONObject.toJSONString(tOrder)); // aws SQS

    // ?????
    OrderStatusTracking orderStatusTracking = new OrderStatusTracking();
    orderStatusTracking.setOrderId(orderID);
    orderStatusTracking.setCustomerPhone(customerPhone);
    orderStatusTracking.setBusinessType(businessType);
    orderStatusTracking.setNewStatus(0);// 0?
    orderStatusTracking.setCreateDate(date);
    orderStatusTracking.setOperator(0);// 
    orderStatusTrackingMapper.insertSelective(orderStatusTracking);

    // ???
    Integer thirdPartyOrderType = 1;// 0 ? 1 ?
    Long minutes = DateUtil.minusTime(new Date(), orderBookDate);
    if (yuyuedanShishidanPoint > minutes) {
        thirdPartyOrderType = 0;
    }
    ThirdPartyOrder thirdPartyOrder = new ThirdPartyOrder();
    thirdPartyOrder.setMerchantId(1);// 1
    thirdPartyOrder.setSource(1);// ???0?1
    thirdPartyOrder.setOrderId(orderID);// ??
    thirdPartyOrder.setPartnerOrderId(partnerOrderId);
    thirdPartyOrder.setPartnerOrderNo(partnerOrderNo);
    thirdPartyOrder.setCreateDate(new Date());
    thirdPartyOrder.setOrderType(thirdPartyOrderType);
    thirdPartyOrder.setNotice(0);
    thirdPartyOrderMapper.insertSelective(thirdPartyOrder);

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

    orderResultDTO.setOrderNo(orderID);
    return orderResultDTO;
}

From source file:com.clark.func.Functions.java

/**
 * <p>/*w  w  w .j  a  va 2s .com*/
 * Turns a string value into a java.lang.Number.
 * </p>
 * 
 * <p>
 * First, the value is examined for a type qualifier on the end (
 * <code>'f','F','d','D','l','L'</code>). If it is found, it starts trying
 * to create successively larger types from the type specified until one is
 * found that can represent the value.
 * </p>
 * 
 * <p>
 * If a type specifier is not found, it will check for a decimal point and
 * then try successively larger types from <code>Integer</code> to
 * <code>BigInteger</code> and from <code>Float</code> to
 * <code>BigDecimal</code>.
 * </p>
 * 
 * <p>
 * If the string starts with <code>0x</code> or <code>-0x</code>, it will be
 * interpreted as a hexadecimal integer. Values with leading <code>0</code>
 * 's will not be interpreted as octal.
 * </p>
 * 
 * <p>
 * Returns <code>null</code> if the string is <code>null</code>.
 * </p>
 * 
 * <p>
 * This method does not trim the input string, i.e., strings with leading or
 * trailing spaces will generate NumberFormatExceptions.
 * </p>
 * 
 * @param str
 *            String containing a number, may be null
 * @return Number created from the string
 * @throws NumberFormatException
 *             if the value cannot be converted
 */
public static Number createNumber(String str) throws NumberFormatException {
    if (str == null) {
        return null;
    }
    if (isBlank(str)) {
        throw new NumberFormatException("A blank string is not a valid number");
    }
    if (str.startsWith("--")) {
        // this is protection for poorness in java.lang.BigDecimal.
        // it accepts this as a legal value, but it does not appear
        // to be in specification of class. OS X Java parses it to
        // a wrong value.
        return null;
    }
    if (str.startsWith("0x") || str.startsWith("-0x")) {
        return createInteger(str);
    }
    char lastChar = str.charAt(str.length() - 1);
    String mant;
    String dec;
    String exp;
    int decPos = str.indexOf('.');
    int expPos = str.indexOf('e') + str.indexOf('E') + 1;

    if (decPos > -1) {

        if (expPos > -1) {
            if (expPos < decPos) {
                throw new NumberFormatException(str + " is not a valid number.");
            }
            dec = str.substring(decPos + 1, expPos);
        } else {
            dec = str.substring(decPos + 1);
        }
        mant = str.substring(0, decPos);
    } else {
        if (expPos > -1) {
            mant = str.substring(0, expPos);
        } else {
            mant = str;
        }
        dec = null;
    }
    if (!Character.isDigit(lastChar) && lastChar != '.') {
        if (expPos > -1 && expPos < str.length() - 1) {
            exp = str.substring(expPos + 1, str.length() - 1);
        } else {
            exp = null;
        }
        // Requesting a specific type..
        String numeric = str.substring(0, str.length() - 1);
        boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
        switch (lastChar) {
        case 'l':
        case 'L':
            if (dec == null && exp == null
                    && (numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {
                try {
                    return createLong(numeric);
                } catch (NumberFormatException nfe) {
                    // Too big for a long
                }
                return createBigInteger(numeric);

            }
            throw new NumberFormatException(str + " is not a valid number.");
        case 'f':
        case 'F':
            try {
                Float f = createFloat(numeric);
                if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
                    // If it's too big for a float or the float value =
                    // 0
                    // and the string
                    // has non-zeros in it, then float does not have the
                    // precision we want
                    return f;
                }

            } catch (NumberFormatException nfe) {
                // ignore the bad number
            }
            //$FALL-THROUGH$
        case 'd':
        case 'D':
            try {
                Double d = createDouble(numeric);
                if (!(d.isInfinite() || (d.floatValue() == 0.0D && !allZeros))) {
                    return d;
                }
            } catch (NumberFormatException nfe) {
                // ignore the bad number
            }
            try {
                return createBigDecimal(numeric);
            } catch (NumberFormatException e) {
                // ignore the bad number
            }
            //$FALL-THROUGH$
        default:
            throw new NumberFormatException(str + " is not a valid number.");

        }
    } else {
        // User doesn't have a preference on the return type, so let's start
        // small and go from there...
        if (expPos > -1 && expPos < str.length() - 1) {
            exp = str.substring(expPos + 1, str.length());
        } else {
            exp = null;
        }
        if (dec == null && exp == null) {
            // Must be an int,long,bigint
            try {
                return createInteger(str);
            } catch (NumberFormatException nfe) {
                // ignore the bad number
            }
            try {
                return createLong(str);
            } catch (NumberFormatException nfe) {
                // ignore the bad number
            }
            return createBigInteger(str);

        } else {
            // Must be a float,double,BigDec
            boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
            try {
                Float f = createFloat(str);
                if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
                    return f;
                }
            } catch (NumberFormatException nfe) {
                // ignore the bad number
            }
            try {
                Double d = createDouble(str);
                if (!(d.isInfinite() || (d.doubleValue() == 0.0D && !allZeros))) {
                    return d;
                }
            } catch (NumberFormatException nfe) {
                // ignore the bad number
            }

            return createBigDecimal(str);

        }
    }
}