Example usage for java.lang NumberFormatException printStackTrace

List of usage examples for java.lang NumberFormatException printStackTrace

Introduction

In this page you can find the example usage for java.lang NumberFormatException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.pingan.reinsurance.Reinsurance.java

private String transfer(ChaincodeStub stub, String[] args) {
    System.out.println("in transfer");
    if (args.length != 3) {
        System.out.println("Incorrect number of arguments:" + args.length);
        return "{\"Error\":\"Incorrect number of arguments. Expecting 3: from, to, amount\"}";
    }// ww w.  j  ava2s. c o m
    String fromName = args[0];
    String fromAm = stub.getState(fromName);
    String toName = args[1];
    String toAm = stub.getState(toName);
    String am = args[2];
    int valFrom = 0;
    if (fromAm != null && !fromAm.isEmpty()) {
        try {
            valFrom = Integer.parseInt(fromAm);
        } catch (NumberFormatException e) {
            System.out.println(
                    "{\"Error\":\"Expecting integer value for asset holding of " + fromName + " \"}" + e);
            return "{\"Error\":\"Expecting integer value for asset holding of " + fromName + " \"}";
        }
    } else {
        return "{\"Error\":\"Failed to get state for " + fromName + "\"}";
    }

    int valTo = 0;
    if (toAm != null && !toAm.isEmpty()) {
        try {
            valTo = Integer.parseInt(toAm);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return "{\"Error\":\"Expecting integer value for asset holding of " + toName + " \"}";
        }
    } else {
        return "{\"Error\":\"Failed to get state for " + toName + "\"}";
    }

    int valA = 0;
    try {
        valA = Integer.parseInt(am);
    } catch (NumberFormatException e) {
        e.printStackTrace();
        return "{\"Error\":\"Expecting integer value for amount \"}";
    }
    if (valA > valFrom)
        return "{\"Error\":\"Insufficient asset holding value for requested transfer amount \"}";
    valFrom = valFrom - valA;
    valTo = valTo + valA;
    System.out.println("Transfer " + fromName + ">" + toName + " am='" + am + "' new values='" + valFrom + "','"
            + valTo + "'");
    stub.putState(fromName, "" + valFrom);
    stub.putState(toName, "" + valTo);

    System.out.println("Transfer complete");

    return null;

}

From source file:com.kdmanalytics.toif.convert.internal.ToifImporter.java

/**
 * Get the finding based on the fact "FindingHasCodeLocation" we do this because we already have
 * the locations./*from w  w  w  .j  a  v  a  2 s.  c o m*/
 * 
 * This method also adds toolgroups to the locationgroups.
 * 
 * @param locationGroup
 *          The location grouping for this finding.
 * @param codeLocation
 *          The value of the location.
 * @throws RepositoryException
 * @throws MalformedQueryException
 * @throws QueryEvaluationException
 */
private int getFinding(LocationGroup locationGroup, CachedCodeLocation ccl)
        throws RepositoryException, MalformedQueryException, QueryEvaluationException {
    int count = 0;
    List<Value> findings = ccl.getFindings();
    for (Value finding : findings) {
        FindingEntry entry = new FindingEntry(finding);

        initializeTrust(entry);
        initializeIsOk(entry);

        // get the tool.
        ToolGroup tool = getTool(finding);

        // add the tool group to the location group
        tool = locationGroup.AddToolGroup(tool);

        // add the finding entry to the tool group.
        entry.setParent(tool);

        tool.setParent(locationGroup);

        // give the findings a weakness description.
        entry.setDescription(getWeaknessDescription(finding));
        entry.setTraces(getTraces(finding));
        entry.setCwe(getCwe(finding));
        entry.setSfp(getSfp(finding));
        entry.setPath(ccl.getPath());
        try {
            entry.setLineNumber(Integer.parseInt(ccl.getLineNumber()));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        if (!tool.addFinding(entry)) {
            System.err.println("  - " + ccl.getPath() + " " + ccl.getLineNumber());
        }
        ++count;

        for (IToifImportListener listener : listeners) {
            listener.add(entry);
        }
    }
    return count;
}

From source file:com.github.akinaru.rfdroid.activity.BtDevicesActivity.java

/**
 * trigger a BLE scan//  ww  w  .  j a  v a 2  s  .co  m
 */
public void triggerNewScan() {

    if (currentService != null && !currentService.isScanning()) {

        showProgressBar();

        Log.i(TAG, "start scanning...");

        currentService.disconnectall();

        int scanInterval = DEFAULT_SCAN_INTERVAL;
        int scanWindow = DEFAULT_SCAN_WINDOW;

        try {
            if (scanIntervalTv != null)
                scanInterval = Integer.parseInt(scanIntervalTv.getText().toString());
            if (scanWindowTv != null)
                scanWindow = Integer.parseInt(scanWindowTv.getText().toString());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        currentService.startScan(scanInterval, scanWindow);

        SharedPreferences.Editor prefEditor = sharedpreferences.edit();
        prefEditor.putInt(JsonConstants.BT_SCAN_INTERVAL, scanInterval);
        prefEditor.putInt(JsonConstants.BT_SCAN_WINDOW, scanWindow);
        prefEditor.commit();

    } else {
        Toast.makeText(BtDevicesActivity.this, "Scanning already engaged...", Toast.LENGTH_SHORT).show();
    }
}

From source file:de.julielab.jcore.reader.file.main.FileReader.java

/**
 * if publicationDatesFile is available, this method retrieves the
 * publication date for the given article id and adds it to the passed
 * header/*from   www  . ja  v  a2 s .c om*/
 * 
 * @param header
 * @param id
 */
private void addDateForID(Header header, JCas jCas, String id) {
    if (publicationDatesFile != null && publicationDatesFile.exists() && publicationDatesFile.isFile()) {
        // read the file and search for the given id
        try {
            BufferedReader br = new BufferedReader(new java.io.FileReader(publicationDatesFile));
            String line = "";
            while ((line = br.readLine()) != null) {
                // split line at whitespace
                String[] tokens = line.split("\\s+");
                if (tokens.length == 2 && tokens[0].equals(id) && tokens[1].length() == 7) {
                    Date pubDate = new Date(jCas);
                    // extract year and month from token of format 2002-01
                    int year = 0;
                    int month = 0;
                    try {
                        year = Integer.parseInt(tokens[1].substring(0, 4));
                        month = Integer.parseInt(tokens[1].substring(5));
                    } catch (NumberFormatException e) {
                    }
                    if (month != 0) {
                        pubDate.setMonth(month);
                    }
                    if (year != 0) {
                        pubDate.setYear(year);
                        pubDate.addToIndexes();
                        // TODO, why doesn't this work??
                        // header.setDate(pubDate);
                    }
                    break;
                }
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:edu.ksu.cs.a4vm.bse.BullInfo.java

public void onResume() {
    super.onResume();
    bullKey = getIntent().getStringExtra("bullKey");

    //load data//from   ww  w.ja va 2s  . co m
    if (!Util.setFields(SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_BULL_INFO, bullKey),
            fields)) {
        Date cDate = new Date();
        String fDate = new SimpleDateFormat("yyyy-MM-dd").format(cDate);
        dob.setText(fDate);
        ageYrs.setText("0");
        ageMths.setText("0");
    }

    save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                if (validDob) {
                    if ((idTag.getText().toString().trim().length() > 0
                            || idTattoo.getText().toString().trim().length() > 0
                            || idRfid.getText().toString().trim().length() > 0
                            || idBrand.getText().toString().trim().length() > 0)) {

                        if ((ageYrs.getText().toString().trim().length() == 0
                                || Integer.valueOf(ageYrs.getText().toString().trim()) <= 25)
                                && (ageMths.getText().toString().trim().length() == 0
                                        || Integer.valueOf(ageMths.getText().toString().trim()) <= 18)) {
                            //save bull info
                            HashSet<String> data = new LinkedHashSet<String>();
                            data.add(idTag.getHint().toString().trim() + "="
                                    + idTag.getText().toString().trim().replace(",", ";"));
                            data.add(idTattoo.getHint().toString().trim() + "="
                                    + idTattoo.getText().toString().trim().replace(",", ";"));
                            data.add(idRfid.getHint().toString().trim() + "="
                                    + idRfid.getText().toString().trim().replace(",", ";"));
                            data.add(idBrand.getHint().toString().trim() + "="
                                    + idBrand.getText().toString().trim().replace(",", ";"));
                            data.add(dob.getHint().toString().trim() + "="
                                    + dob.getText().toString().trim().replace(",", ";"));
                            data.add(ageYrs.getHint().toString().trim() + "="
                                    + ageYrs.getText().toString().trim().replace(",", ";"));
                            data.add(ageMths.getHint().toString().trim() + "="
                                    + ageMths.getText().toString().trim().replace(",", ";"));
                            data.add(lot.getHint().toString().trim() + "="
                                    + lot.getText().toString().trim().replace(",", ";"));
                            data.add(breed.getHint().toString().trim() + "="
                                    + breed.getText().toString().trim().replace(",", ";"));
                            data.add(comments.getHint().toString().trim() + "="
                                    + comments.getText().toString().trim().replace(",", ";"));

                            //capture timestamp
                            Date cDate = new Date();
                            String fDate = new SimpleDateFormat("dd-MM-yyyy hh.mm.ss").format(cDate);

                            data.add("TimeStamp=" + fDate);

                            //persist VetInfo
                            if (bullKey != null) {
                                //saving key
                                final Set<String> keySet = SharedPrefUtil.getValue(getApplicationContext(),
                                        Constant.PREFS_BULL_INFO, Constant.KEY_BULL);
                                /*
                                creating a copy of keySet because if sets retrieved from a shared pref file
                                is modified, it could lead to unexpected behavior.
                                 */
                                Set<String> keySet1 = null;
                                if (keySet != null) {
                                    keySet1 = new HashSet<String>();
                                    Iterator<String> it = keySet.iterator();
                                    while (it.hasNext()) {
                                        keySet1.add(it.next());
                                    }
                                    if (!keySet1.contains(bullKey)) {
                                        keySet1.add(bullKey);
                                    }
                                } else {
                                    keySet1 = new HashSet<String>();
                                    keySet1.add(bullKey);

                                }

                                if (keySet1 != null && bullKey != null) {
                                    SharedPrefUtil.saveGroup(getApplicationContext(), Constant.PREFS_BULL_INFO,
                                            Constant.KEY_BULL, keySet1);

                                    //saving data
                                    SharedPrefUtil.saveGroup(getApplicationContext(), Constant.PREFS_BULL_INFO,
                                            bullKey, data);
                                    Toast.makeText(getApplicationContext(), "Saved!", Toast.LENGTH_SHORT)
                                            .show();

                                    //display
                                    Intent goPrev = new Intent(getApplicationContext(), BullExam.class);
                                    goPrev.putExtra("bullKey", bullKey);
                                    startActivity(goPrev);
                                    /*Util.setFields(SharedPrefUtil.getValue(getApplicationContext(),
                                        Constant.PREFS_BULL_INFO, bullKey), fields);*/
                                } else {
                                    Toast.makeText(getApplicationContext(),
                                            "Oops! could not save due to internal app error.",
                                            Toast.LENGTH_SHORT).show();
                                }

                            } else {
                                Toast.makeText(getApplicationContext(),
                                        "Oops! something went wrong. Please try again", Toast.LENGTH_SHORT)
                                        .show();
                            }

                        } else {
                            Toast.makeText(getApplicationContext(), "Date or DOB not filled correctly",
                                    Toast.LENGTH_LONG).show();
                            ageYrs.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                            ageMths.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        }

                    } else {
                        Toast.makeText(getApplicationContext(), "At least one ID field should be filled",
                                Toast.LENGTH_LONG).show();
                        idTag.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        idTattoo.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        idRfid.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        idBrand.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));

                    }
                } else {
                    Toast.makeText(getApplicationContext(), "Cannot save incorrect dob", Toast.LENGTH_LONG)
                            .show();
                }
            } catch (NumberFormatException e) {
                e.printStackTrace();

                Toast.makeText(getApplicationContext(), "Please correct the fields marked red",
                        Toast.LENGTH_LONG).show();
                ageYrs.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                ageMths.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                dob.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));

            }
        }
    });

    dob.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                String birthDt = dob.getText().toString().trim();
                if (birthDt.length() > 0) {
                    String[] arrBirthDt = birthDt.split("-");
                    try {
                        validDob = true;
                        if (arrBirthDt != null && arrBirthDt.length == 3) {
                            validDob = true;
                            int todayYr = Calendar.getInstance().get(Calendar.YEAR);
                            int todayMth = Calendar.getInstance().get(Calendar.MONTH) + 1;
                            int birthYr = Integer.valueOf(arrBirthDt[0]);
                            int birthMth = Integer.valueOf(arrBirthDt[1]);
                            int birthDay = Integer.valueOf((arrBirthDt[2]));
                            int ageY = 0;
                            int ageM = 0;

                            if (todayYr >= birthYr) {
                                ageY = todayYr - birthYr;
                                if (todayMth >= birthMth)
                                    ageM = todayMth - birthMth;
                                else {
                                    ageM = todayMth + (12 - birthMth);
                                    ageY = ageY - 1;
                                }
                            }
                            if (ageYrs != null && ageMths != null && ageY <= 25 && ageM < 12
                                    && birthDay <= Util.get_days_of_a_month(birthMth, birthYr)) {
                                yearCalculated = true;
                                ageYrs.setText(String.valueOf(ageY));
                                mthCalculated = true;
                                ageMths.setText(String.valueOf(ageM));
                                dob.setBackground(ContextCompat.getDrawable(getApplicationContext(),
                                        R.drawable.focus_color));
                            } else {
                                validDob = false;
                                Toast.makeText(getApplicationContext(), "Invalid DOB", Toast.LENGTH_SHORT)
                                        .show();
                                dob.setBackground(ContextCompat.getDrawable(getApplicationContext(),
                                        R.drawable.highlight));
                            }

                        } else {
                            Toast.makeText(getApplicationContext(), "Incorrect date format", Toast.LENGTH_SHORT)
                                    .show();
                            dob.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                            validDob = false;
                        }

                    } catch (NumberFormatException ne) {
                        ne.printStackTrace();
                        Toast.makeText(getApplicationContext(), "Birth date cannot have non-numbers",
                                Toast.LENGTH_SHORT).show();
                        dob.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        validDob = false;
                    } catch (Exception pe) {
                        pe.printStackTrace();
                        Toast.makeText(getApplicationContext(), "Incorrect birth date", Toast.LENGTH_SHORT)
                                .show();
                        dob.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        validDob = false;
                    }
                }
            }
        }
    });

    ageYrs.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                String year = ageYrs.getText().toString().trim();
                try {
                    if (Integer.valueOf(year) > 25) {
                        ageYrs.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        Toast.makeText(getApplicationContext(), "Max age is 25", Toast.LENGTH_SHORT).show();
                    } else
                        ageYrs.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                } catch (NumberFormatException ne) {
                    if (year.length() > 0) {
                        ageYrs.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        Toast.makeText(getApplicationContext(), "Age cannot be non-number", Toast.LENGTH_SHORT)
                                .show();
                    } else
                        ageYrs.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));

                } catch (Exception e) {
                    ageYrs.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                    Toast.makeText(getApplicationContext(), "Invalid age", Toast.LENGTH_SHORT).show();
                }
            }

        }
    });

    ageYrs.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //do nothing
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //do nothing
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (yearCalculated)
                yearCalculated = false;
            else
                dob.setText("");

        }
    });

    ageMths.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                String year = ageMths.getText().toString().trim();
                try {
                    if (Integer.valueOf(year) > 18) {
                        ageMths.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        Toast.makeText(getApplicationContext(), "Month cannot be more than 18",
                                Toast.LENGTH_SHORT).show();
                    } else
                        ageMths.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                } catch (NumberFormatException ne) {
                    if (year.length() > 0) {
                        ageMths.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        Toast.makeText(getApplicationContext(), "Age cannot be non-number", Toast.LENGTH_SHORT)
                                .show();
                    } else
                        ageMths.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));

                } catch (Exception e) {
                    ageMths.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                    Toast.makeText(getApplicationContext(), "Invalid age", Toast.LENGTH_SHORT).show();
                }
            }

        }
    });

    ageMths.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            //do nothing
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            //do nothing
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mthCalculated)
                mthCalculated = false;
            else
                dob.setText("");
        }
    });

    idTag.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                if (idTag.getText().toString().trim().length() > 0) {
                    idTag.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idTattoo.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idRfid.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idBrand.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                }
            }
        }
    });

    idTattoo.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                if (idTattoo.getText().toString().trim().length() > 0) {
                    idTag.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idTattoo.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idRfid.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idBrand.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                }
            }
        }
    });

    idRfid.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                if (idRfid.getText().toString().trim().length() > 0) {
                    idTag.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idTattoo.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idRfid.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idBrand.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                }
            }
        }
    });

    idBrand.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                if (idBrand.getText().toString().trim().length() > 0) {
                    idTag.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idTattoo.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idRfid.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    idBrand.setBackground(
                            ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                }
            }
        }
    });

}

From source file:com.example.emachine.FXcalcActivity.java

private void calculateScreen() {
    if (et_us.getText().toString() == null || et_us.getText().length() == 0) {
        return;//from   ww  w.  ja  v a  2  s . c  om
    }
    try {
        if (Integer.valueOf(et_us.getText().toString()) == 0) {
            alert(getString(R.string.str_positive_amount));
        } else if (Double.valueOf(et_us.getText().toString()) > calcCeilingValue()) {
            alert(getString(R.string.str_exceeded_largest));
        } else {
            maxValue = calcMaxValue(Double.valueOf(et_us.getText().toString()));
            tv_max = (TextView) findViewById(R.id.tv_max);
            tv_max.setText(fmt(maxValue));
            tv_mid = (TextView) findViewById(R.id.tv_mid);
            tv_mid.setText(fmt(maxValue / 2));

            Double usValue = Double.valueOf(et_us.getText().toString());

            tv_england.setText(Double.valueOf((englandValue = round((usValue * englandRate), 4))).toString());
            tv_euro.setText(Double.valueOf((euroValue = round((usValue * euroRate), 4))).toString());
            tv_brazil.setText(Double.valueOf((brazilValue = round((usValue * brazilRate), 4))).toString());
            tv_japan.setText(Double.valueOf((japanValue = round((usValue * japanRate), 4))).toString());

            Integer englandGraph, euroGraph, brazilGraph, japanGraph = 0;
            pb_us.setProgress(ratioValue(maxRate, usValue)); // Set the progress of the AnimatedProgressBar
            pb_england.setProgress(englandGraph = ratioValue(maxRate, englandValue)); // Set the progress of the AnimatedProgressBar
            pb_euro.setProgress(euroGraph = ratioValue(maxRate, euroValue)); // Set the progress of the AnimatedProgressBar
            pb_brazil.setProgress(brazilGraph = ratioValue(maxRate, brazilValue)); // Set the progress of the AnimatedProgressBar
            pb_japan.setProgress(japanGraph = ratioValue(maxRate, japanValue)); // Set the progress of the AnimatedProgressBar
        }
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }
}

From source file:eu.udig.tools.jgrass.navigationview.NavigationView.java

public void widgetSelected(SelectionEvent e) {
    ViewportModel viewportModel = (ViewportModel) ApplicationGIS.getActiveMap().getViewportModel();

    Object source = e.getSource();
    if (source.equals(scaleCombo)) {
        int index = scaleCombo.getSelectionIndex();
        String item = scaleCombo.getItem(index);
        String scaleString = item.split(":")[1];
        double scale = Double.parseDouble(scaleString);
        viewportModel.setScale(scale);/*  w ww . jav a2 s.  c o  m*/
    }
    if (source.equals(dateTimeCombo)) {
        int index = dateTimeCombo.getSelectionIndex();
        String item = dateTimeCombo.getItem(index);
        DateTime date = ISO_DATE_TIME_PARSER.parseDateTime(item);
        viewportModel.setCurrentTimestep(date);
    }
    if (source.equals(verticalCombo)) {
        int index = verticalCombo.getSelectionIndex();
        String item = verticalCombo.getItem(index);
        try {
            double vertical = Double.parseDouble(item);
            viewportModel.setCurrentElevation(vertical);
        } catch (NumberFormatException e1) {
            e1.printStackTrace();
        }
    }
    if (source.equals(verticalDownButton)) {
        int selectionIndex = verticalCombo.getSelectionIndex();
        selectionIndex++;
        if (selectionIndex > verticalCombo.getItemCount() - 1) {
            selectionIndex = verticalCombo.getItemCount() - 1;
        }
        String item = verticalCombo.getItem(selectionIndex);
        double vertical = Double.parseDouble(item);
        viewportModel.setCurrentElevation(vertical);
        verticalCombo.select(selectionIndex);
    }
    if (source.equals(verticalUpButton)) {
        int selectionIndex = verticalCombo.getSelectionIndex();
        selectionIndex--;
        if (selectionIndex < 0) {
            selectionIndex = 0;
        }
        String item = verticalCombo.getItem(selectionIndex);
        double vertical = Double.parseDouble(item);
        viewportModel.setCurrentElevation(vertical);
        verticalCombo.select(selectionIndex);
    }
    if (source.equals(scaleDownButton)) {
        int selectionIndex = scaleCombo.getSelectionIndex();
        selectionIndex--;
        if (selectionIndex < 0) {
            selectionIndex = 0;
        }
        String item = scaleCombo.getItem(selectionIndex);
        double scale = Double.parseDouble(item.split(":")[1]);
        viewportModel.setScale(scale);
        scaleCombo.select(selectionIndex);
    }
    if (source.equals(scaleUpButton)) {
        int selectionIndex = scaleCombo.getSelectionIndex();
        selectionIndex++;
        if (selectionIndex > scaleCombo.getItemCount() - 1) {
            selectionIndex = scaleCombo.getItemCount() - 1;
        }
        String item = scaleCombo.getItem(selectionIndex);
        double scale = Double.parseDouble(item.split(":")[1]);
        viewportModel.setScale(scale);
        scaleCombo.select(selectionIndex);
    }
    if (source.equals(dtDownButton)) {
        int selectionIndex = dateTimeCombo.getSelectionIndex();
        selectionIndex--;
        if (selectionIndex < 0) {
            selectionIndex = 0;
        }
        String item = dateTimeCombo.getItem(selectionIndex);
        DateTime dt = ISO_DATE_TIME_PARSER.parseDateTime(item);
        viewportModel.setCurrentTimestep(dt);
        dateTimeCombo.select(selectionIndex);
    }
    if (source.equals(dtUpButton)) {
        int selectionIndex = dateTimeCombo.getSelectionIndex();
        selectionIndex++;
        if (selectionIndex > dateTimeCombo.getItemCount() - 1) {
            selectionIndex = dateTimeCombo.getItemCount() - 1;
        }
        String item = dateTimeCombo.getItem(selectionIndex);
        DateTime dt = ISO_DATE_TIME_PARSER.parseDateTime(item);
        viewportModel.setCurrentTimestep(dt);
        dateTimeCombo.select(selectionIndex);
    }
    updateData();
}

From source file:org.kuali.ole.fp.businessobject.DisbursementVoucherPayeeDetail.java

/**
 * Gets the disbVchrVendorIdNumber attribute as an Integer.
 * /*  ww w.j a v  a2  s. c om*/
 * @return Returns the disbVchrVendorIdNumber in Integer form. This is the format used on the VendorDetail.
 */
public Integer getDisbVchrVendorHeaderIdNumberAsInteger() {
    if (getDisbVchrVendorHeaderIdNumber() != null)
        try {
            return new Integer(getDisbVchrVendorHeaderIdNumber());
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    return null;
}

From source file:org.kuali.ole.fp.businessobject.DisbursementVoucherPayeeDetail.java

/**
 * This method.../*from   w  w  w. j a  va 2s  .  com*/
 * 
 * @return
 */
public Integer getDisbVchrVendorDetailAssignedIdNumberAsInteger() {
    if (getDisbVchrVendorDetailAssignedIdNumber() != null)
        try {
            return new Integer(getDisbVchrVendorDetailAssignedIdNumber());
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    return null;
}

From source file:org.kuali.ole.fp.businessobject.DisbursementVoucherPayeeDetail.java

/**
 * Gets the disbVchrVendorAddressIdNumber attribute.
 * /*w w w.ja  va 2 s .  c o  m*/
 * @return Returns the disbVchrVendorAddressIdNumber.
 */
public Integer getDisbVchrVendorAddressIdNumberAsInteger() {
    if (getDisbVchrVendorAddressIdNumber() != null)
        try {
            return new Integer(getDisbVchrVendorAddressIdNumber());
        } catch (NumberFormatException nfe) {
            nfe.printStackTrace();
        }
    return null;
}