Example usage for java.text NumberFormat setGroupingUsed

List of usage examples for java.text NumberFormat setGroupingUsed

Introduction

In this page you can find the example usage for java.text NumberFormat setGroupingUsed.

Prototype

public void setGroupingUsed(boolean newValue) 

Source Link

Document

Set whether or not grouping will be used in this format.

Usage

From source file:org.mycore.datamodel.ifs2.MCRStore.java

private String createIDWithLeadingZeros(final int ID) {
    final NumberFormat numWithLeadingZerosFormat = NumberFormat.getIntegerInstance(Locale.ROOT);
    numWithLeadingZerosFormat.setMinimumIntegerDigits(idLength);
    numWithLeadingZerosFormat.setGroupingUsed(false);
    final String id = numWithLeadingZerosFormat.format(ID);
    return id;//from   www. j  a  v  a2  s.  c  om
}

From source file:org.apache.ambari.server.serveraction.kerberos.MITKerberosOperationHandler.java

/**
 * Retrieves the current key number assigned to the identity identified by the specified principal
 *
 * @param principal a String declaring the principal to look up
 * @return an Integer declaring the current key number
 * @throws KerberosKDCConnectionException       if a connection to the KDC cannot be made
 * @throws KerberosAdminAuthenticationException if the administrator credentials fail to authenticate
 * @throws KerberosRealmException               if the realm does not map to a KDC
 * @throws KerberosOperationException           if an unexpected error occurred
 *//*from w w w  .  j  a  v a  2 s .com*/
private Integer getKeyNumber(String principal) throws KerberosOperationException {
    if (!isOpen()) {
        throw new KerberosOperationException("This operation handler has not been opened");
    }

    if (StringUtils.isEmpty(principal)) {
        throw new KerberosOperationException(
                "Failed to get key number for principal  - no principal specified");
    } else {
        // Create the kdamin query:  get_principal <principal>
        ShellCommandUtil.Result result = invokeKAdmin(String.format("get_principal %s", principal));

        String stdOut = result.getStdout();
        if (stdOut == null) {
            String message = String.format(
                    "Failed to get key number for %s:\n\tExitCode: %s\n\tSTDOUT: NULL\n\tSTDERR: %s", principal,
                    result.getExitCode(), result.getStderr());
            LOG.warn(message);
            throw new KerberosOperationException(message);
        }

        Matcher matcher = PATTERN_GET_KEY_NUMBER.matcher(stdOut);
        if (matcher.matches()) {
            NumberFormat numberFormat = NumberFormat.getIntegerInstance();
            String keyNumber = matcher.group(1);

            numberFormat.setGroupingUsed(false);
            try {
                Number number = numberFormat.parse(keyNumber);
                return (number == null) ? 0 : number.intValue();
            } catch (ParseException e) {
                String message = String.format(
                        "Failed to get key number for %s - invalid key number value (%s):\n\tExitCode: %s\n\tSTDOUT: NULL\n\tSTDERR: %s",
                        principal, keyNumber, result.getExitCode(), result.getStderr());
                LOG.warn(message);
                throw new KerberosOperationException(message);
            }
        } else {
            String message = String.format(
                    "Failed to get key number for %s - unexpected STDOUT data:\n\tExitCode: %s\n\tSTDOUT: NULL\n\tSTDERR: %s",
                    principal, result.getExitCode(), result.getStderr());
            LOG.warn(message);
            throw new KerberosOperationException(message);
        }
    }
}

From source file:org.efaps.esjp.common.file.FileUtil_Base.java

/**
 * Method to get a file with given name and ending.
 *
 * @param _name name for the file/*from www .  j  a v  a2  s.com*/
 * @return file
 * @throws EFapsException on error
 */
public File getFile(final String _name) throws EFapsException {
    File ret = null;
    try {
        File tmpfld = AppConfigHandler.get().getTempFolder();
        if (tmpfld == null) {
            final File temp = File.createTempFile("eFaps", ".tmp");
            tmpfld = temp.getParentFile();
            temp.delete();
        }
        final File storeFolder = new File(tmpfld, FileUtil_Base.TMPFOLDERNAME);
        final NumberFormat formater = NumberFormat.getInstance();
        formater.setMinimumIntegerDigits(8);
        formater.setGroupingUsed(false);
        final File userFolder = new File(storeFolder,
                formater.format(Context.getThreadContext().getPersonId()));
        if (!userFolder.exists()) {
            userFolder.mkdirs();
        }
        final String name = StringUtils.stripAccents(_name);
        ret = new File(userFolder, name.replaceAll("[^a-zA-Z0-9.-]", "_"));
    } catch (final IOException e) {
        throw new EFapsException(FileUtil_Base.class, "IOException", e);
    }
    return ret;
}

From source file:com.nextgis.mobile.fragment.AttributesFragment.java

private String parseAttributes(String data) throws RuntimeException {
    String selection = Constants.FIELD_ID + " = ?";
    Cursor attributes = mLayer.query(null, selection, new String[] { mItemId + "" }, null, null);
    if (null == attributes || attributes.getCount() == 0)
        return data;

    if (attributes.moveToFirst()) {
        for (int i = 0; i < attributes.getColumnCount(); i++) {
            String column = attributes.getColumnName(i);
            String text, alias;//w  w  w . j ava  2s .c  om

            if (column.startsWith(Constants.FIELD_GEOM_))
                continue;

            if (column.equals(Constants.FIELD_GEOM)) {
                switch (mLayer.getGeometryType()) {
                case GTPoint:
                    try {
                        GeoPoint pt = (GeoPoint) GeoGeometryFactory.fromBlob(attributes.getBlob(i));
                        data += getRow(getString(R.string.coordinates), formatCoordinates(pt));
                    } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    continue;
                case GTMultiPoint:
                    try {
                        GeoMultiPoint mpt = (GeoMultiPoint) GeoGeometryFactory.fromBlob(attributes.getBlob(i));
                        data += getRow(getString(R.string.center),
                                formatCoordinates(mpt.getEnvelope().getCenter()));
                    } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    continue;
                case GTLineString:
                    try {
                        GeoLineString line = (GeoLineString) GeoGeometryFactory.fromBlob(attributes.getBlob(i));
                        data += getRow(getString(R.string.length),
                                LocationUtil.formatLength(getContext(), line.getLength(), 3));
                    } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    continue;
                case GTMultiLineString:
                    try {
                        GeoMultiLineString multiline = (GeoMultiLineString) GeoGeometryFactory
                                .fromBlob(attributes.getBlob(i));
                        data += getRow(getString(R.string.length),
                                LocationUtil.formatLength(getContext(), multiline.getLength(), 3));
                    } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    continue;
                case GTPolygon:
                    try {
                        GeoPolygon polygon = (GeoPolygon) GeoGeometryFactory.fromBlob(attributes.getBlob(i));
                        data += getRow(getString(R.string.perimeter),
                                LocationUtil.formatLength(getContext(), polygon.getPerimeter(), 3));
                        data += getRow(getString(R.string.area),
                                LocationUtil.formatArea(getContext(), polygon.getArea()));
                    } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    continue;
                case GTMultiPolygon:
                    try {
                        GeoMultiPolygon polygon = (GeoMultiPolygon) GeoGeometryFactory
                                .fromBlob(attributes.getBlob(i));
                        data += getRow(getString(R.string.perimeter),
                                LocationUtil.formatLength(getContext(), polygon.getPerimeter(), 3));
                        data += getRow(getString(R.string.area),
                                LocationUtil.formatArea(getContext(), polygon.getArea()));
                    } catch (IOException | ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                    continue;
                default:
                    continue;
                }
            }

            Field field = mLayer.getFieldByName(column);
            int fieldType = field != null ? field.getType() : Constants.NOT_FOUND;
            switch (fieldType) {
            case GeoConstants.FTInteger:
                text = attributes.getInt(i) + "";
                break;
            case GeoConstants.FTReal:
                NumberFormat nf = NumberFormat.getInstance();
                nf.setMaximumFractionDigits(4);
                nf.setGroupingUsed(false);
                text = nf.format(attributes.getDouble(i));
                break;
            case GeoConstants.FTDate:
            case GeoConstants.FTTime:
            case GeoConstants.FTDateTime:
                text = formatDateTime(attributes.getLong(i), fieldType);
                break;
            default:
                text = toString(attributes.getString(i));
                Pattern pattern = Pattern.compile(URL_PATTERN);
                Matcher match = pattern.matcher(text);
                while (match.matches()) {
                    String url = text.substring(match.start(), match.end());
                    text = text.replaceFirst(URL_PATTERN, "<a href = '" + url + "'>" + url + "</a>");
                    match = pattern.matcher(text.substring(match.start() + url.length() * 2 + 17));
                }
                break;
            }

            if (field != null)
                alias = field.getAlias();
            else if (column.equals(Constants.FIELD_ID))
                alias = Constants.FIELD_ID;
            else
                alias = "";

            data += getRow(alias, text);
        }
    }

    attributes.close();
    return data;
}

From source file:org.diretto.web.richwebclient.view.sections.UploadSection.java

/**
 * Loads the content of this {@link Section}.
 *///from   w  ww .  j  a  v a 2 s . co  m
private void loadComponents() {
    removeAllComponents();

    captionLayout = new HorizontalLayout();
    captionLayout.addComponent(StyleUtils.getLabelH1(title));
    captionLayout.addComponent(getPollingProgressIndicator());
    addComponent(captionLayout);

    mainLayout = new VerticalLayout();
    mainLayout.setStyleName(Reindeer.LAYOUT_BLACK);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    addComponent(mainLayout);

    mainLayout.addComponent(StyleUtils.getLabelH2("File Upload"));
    mainLayout.addComponent(StyleUtils.getHorizontalLine());
    mainLayout.addComponent(StyleUtils.getLabel("Select the files which you want to upload"));
    mainLayout.addComponent(StyleUtils
            .getLabelSmall("(To choose multiple files, just press the CTRL-key while selecting the files)"));
    mainLayout.addComponent(StyleUtils.getVerticalSpaceSmall());

    multipleUpload = new MultipleUpload(application, "Select Files", Reindeer.BUTTON_DEFAULT);

    multipleUpload.addMultipleUploadHandler(new MultipleUploadHandler() {
        @Override
        public void onUploadsSelected(List<FileInfo> fileInfos) {
            for (FileInfo file : fileInfos) {
                if (file != null) {
                    files.put(file.getName(), file);

                    if (!fileNames.contains(file.getName())) {
                        fileNames.add(file.getName());
                    }
                }
            }

            handleNextFile();
        }

        @Override
        public void onUploadStarted(FileInfo fileInfo) {
            return;
        }

        @SuppressWarnings("unchecked")
        @Override
        public void onUploadFinished(final FileInfo fileInfo, final File file) {
            final UploadSettings uploadSettings = settings.remove(fileInfo.getName());
            final UserSession userSession = authenticationRegistry.getActiveUserSession();

            Embedded embedded;

            synchronized (UploadSection.this) {
                embedded = ((List<Embedded>) uploadedEmbeddeds.get(fileInfo)).get(0);
                uploadedEmbeddeds.remove(fileInfo, embedded);

                if (embedded != null) {
                    embedded.setSource(ResourceUtils.RUNO_ICON_32_OK_RESOURCE);

                    requestRepaint();
                }
            }

            new Thread(new Runnable() {
                @Override
                public void run() {
                    if (uploadSettings != null && userSession != null) {
                        PlatformMediaType platformMediaType = coreService
                                .getPlatformMediaType(fileInfo.getType());
                        PlatformAttachmentCreationData platformAttachmentCreationData = ((PlatformAttachmentCreationData.Builder) new PlatformAttachmentCreationData.Builder()
                                .fileSize(fileInfo.getSize()).platformMediaType(platformMediaType)
                                .title(uploadSettings.getTitle()).description(uploadSettings.getDescription())
                                .license(uploadSettings.getLicense())
                                .contributors(uploadSettings.getContributors())
                                .creators(uploadSettings.getCreators())).build();
                        UploadInfo uploadInfo = coreService.createDocument(userSession,
                                platformAttachmentCreationData, uploadSettings.getTopographicPoint(),
                                uploadSettings.getTimeRange());

                        UploadProcess uploadProcess = storageService.createUploadProcess(userSession,
                                uploadInfo, file);
                        UploadReport uploadReport = storageService.executeUploadProcess(uploadProcess);

                        Embedded embedded;

                        synchronized (UploadSection.this) {
                            embedded = ((List<Embedded>) publishedEmbeddeds.get(fileInfo)).get(0);
                            publishedEmbeddeds.remove(fileInfo, embedded);
                        }

                        if (uploadReport != null) {
                            for (String tag : uploadSettings.getTags()) {
                                Document document = coreService
                                        .getDocument((DocumentID) uploadReport.getAttachmentID().getRootID());
                                document.addTag(userSession, tag);
                            }

                            NumberFormat numberFormat = NumberFormat.getInstance();
                            numberFormat.setGroupingUsed(false);

                            System.out.println("==================================");
                            System.out.println("vvvvvvvvvv UploadReport vvvvvvvvvv");
                            System.out.println("AttachmentID: "
                                    + uploadReport.getAttachmentID().getUniqueResourceURL().toExternalForm());
                            System.out.println("File URL: " + uploadReport.getFileURL().toExternalForm());
                            System.out.println("Media Type: " + uploadReport.getPlatformMediaType().getID());
                            System.out.println("File Size: " + uploadReport.getFileSize() + " Bytes");
                            System.out.println("Upload Time: "
                                    + numberFormat.format(uploadReport.getUploadTime()) + " ms");
                            System.out.println("Upload Rate: "
                                    + numberFormat.format(uploadReport.getUploadRate()) + " Bytes/s");
                            System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
                            System.out.println("==================================");

                            synchronized (UploadSection.this) {
                                if (embedded != null) {
                                    embedded.setSource(ResourceUtils.RUNO_ICON_32_OK_RESOURCE);

                                    requestRepaint();
                                }
                            }
                        } else {
                            System.err.println("UploadReport: null");

                            synchronized (UploadSection.this) {
                                if (embedded != null) {
                                    embedded.setSource(ResourceUtils.RUNO_ICON_32_CANCEL_RESOURCE);

                                    requestRepaint();
                                }
                            }
                        }
                    }

                    if (file.exists()) {
                        file.delete();
                    }
                }
            }).start();
        }

        @SuppressWarnings("unchecked")
        @Override
        public void onUploadFailed(FileInfo fileInfo, Exception exception) {
            Embedded uploadedEmbedded;

            synchronized (UploadSection.this) {
                uploadedEmbedded = ((List<Embedded>) uploadedEmbeddeds.get(fileInfo)).get(0);
                uploadedEmbeddeds.remove(fileInfo, uploadedEmbedded);

                if (uploadedEmbedded != null) {
                    uploadedEmbedded.setSource(ResourceUtils.RUNO_ICON_32_CANCEL_RESOURCE);

                    requestRepaint();
                }
            }

            Embedded publishedEmbedded;

            synchronized (UploadSection.this) {
                publishedEmbedded = ((List<Embedded>) publishedEmbeddeds.get(fileInfo)).get(0);
                publishedEmbeddeds.remove(fileInfo, publishedEmbedded);

                if (publishedEmbedded != null) {
                    publishedEmbedded.setSource(ResourceUtils.RUNO_ICON_32_CANCEL_RESOURCE);

                    requestRepaint();
                }
            }

            settings.remove(fileInfo.getName());
        }
    });

    mainLayout.addComponent(multipleUpload);
    mainLayout.addComponent(StyleUtils.getHorizontalLine());
}

From source file:mx.edu.um.mateo.activos.web.ActivoController.java

@RequestMapping("/dia")
public String dia(Model modelo, @RequestParam(required = false) Integer anio) throws ParseException {
    log.debug("Reporte DIA para el anio {}", anio);
    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);/*from  w  w  w  .  j a  va 2  s . c  om*/
    if (anio != null) {
        Map<String, Object> params = activoDao.reporteDIA(anio, ambiente.obtieneUsuario());
        modelo.addAllAttributes(params);
        modelo.addAttribute("anio", anio);
        modelo.addAttribute("year", nf.format(anio));
    } else {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.YEAR, -1);
        int year = cal.get(Calendar.YEAR);
        modelo.addAttribute("anio", year);
        modelo.addAttribute("year", nf.format(year));
    }
    return "activoFijo/activo/dia";
}

From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java

/**
 * Converts the input as a number using java's number formatter to a string output.
 *//*from  w  ww  .  j  a v a 2s.  co m*/
private String doConvertFromNumberToString(Map<String, Object> context, Object value, Class toType) {
    // XW-409: If the input is a Number we should format it to a string using the choosen locale and use java's numberformatter
    if (Number.class.isAssignableFrom(toType)) {
        NumberFormat numFormat = NumberFormat.getInstance(getLocale(context));
        if (isIntegerType(toType)) {
            numFormat.setParseIntegerOnly(true);
        }
        numFormat.setGroupingUsed(true);
        numFormat.setMaximumFractionDigits(99); // to be sure we include all digits after decimal seperator, otherwise some of the fractions can be chopped

        String number = numFormat.format(value);
        if (number != null) {
            return number;
        }
    }

    return null; // no number
}

From source file:de.cismet.cids.custom.utils.berechtigungspruefung.BerechtigungspruefungHandler.java

/**
 * DOCUMENT ME!/*from   w ww  .  j  a  v a  2 s . co m*/
 *
 * @param   user          DOCUMENT ME!
 * @param   downloadInfo  DOCUMENT ME!
 *
 * @return  DOCUMENT ME!
 */
public String createNewSchluessel(final User user, final BerechtigungspruefungDownloadInfo downloadInfo) {
    synchronized (this) {
        final String type;
        if (BerechtigungspruefungBescheinigungDownloadInfo.PRODUKT_TYP.equals(downloadInfo.getProduktTyp())) {
            type = "BlaB";
        } else if (BerechtigungspruefungAlkisDownloadInfo.PRODUKT_TYP.equals(downloadInfo.getProduktTyp())) {
            type = "LB";
        } else {
            type = "?";
        }

        final int year = Calendar.getInstance().get(Calendar.YEAR);
        final CidsBean lastAnfrageBean = loadLastAnfrageBeanByTypeAndYear(user, type, year);
        final String lastAnfrageSchluessel = (lastAnfrageBean != null)
                ? (String) lastAnfrageBean.getProperty("schluessel")
                : null;
        final int lastNumber;
        if (lastAnfrageSchluessel != null) {
            final Pattern pattern = Pattern.compile("^" + type + "-" + year + "-(\\d{5})$");
            final Matcher matcher = pattern.matcher(lastAnfrageSchluessel);
            if (matcher.matches()) {
                final String group = matcher.group(1);
                lastNumber = (group != null) ? Integer.parseInt(group) : 0;
            } else {
                lastNumber = 0;
            }
        } else {
            lastNumber = 0;
        }

        final int newNumber = lastNumber + 1;

        final NumberFormat format = NumberFormat.getIntegerInstance();
        format.setMinimumIntegerDigits(5);
        format.setGroupingUsed(false);

        final String newAnfrageSchluessel = type + "-" + Integer.toString(year) + "-"
                + format.format(newNumber);
        return newAnfrageSchluessel;
    }
}

From source file:com.vgi.mafscaling.Rescale.java

private void createControlPanel(JPanel dataPanel) {
    JPanel cntlPanel = new JPanel();
    GridBagConstraints gbl_ctrlPanel = new GridBagConstraints();
    gbl_ctrlPanel.insets = insets3;//from   ww  w . j  a  v  a 2 s .  com
    gbl_ctrlPanel.anchor = GridBagConstraints.PAGE_START;
    gbl_ctrlPanel.fill = GridBagConstraints.HORIZONTAL;
    gbl_ctrlPanel.weightx = 1.0;
    gbl_ctrlPanel.gridx = 0;
    gbl_ctrlPanel.gridy = 0;
    dataPanel.add(cntlPanel, gbl_ctrlPanel);

    GridBagLayout gbl_cntlPanel = new GridBagLayout();
    gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_cntlPanel.rowHeights = new int[] { 0, 0 };
    gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    gbl_cntlPanel.rowWeights = new double[] { 0 };
    cntlPanel.setLayout(gbl_cntlPanel);

    NumberFormat doubleFmt = NumberFormat.getNumberInstance();
    doubleFmt.setGroupingUsed(false);
    doubleFmt.setMaximumIntegerDigits(1);
    doubleFmt.setMinimumIntegerDigits(1);
    doubleFmt.setMaximumFractionDigits(3);
    doubleFmt.setMinimumFractionDigits(1);
    doubleFmt.setRoundingMode(RoundingMode.HALF_UP);

    NumberFormat scaleDoubleFmt = NumberFormat.getNumberInstance();
    scaleDoubleFmt.setGroupingUsed(false);
    scaleDoubleFmt.setMaximumIntegerDigits(1);
    scaleDoubleFmt.setMinimumIntegerDigits(1);
    scaleDoubleFmt.setMaximumFractionDigits(8);
    scaleDoubleFmt.setMinimumFractionDigits(1);
    scaleDoubleFmt.setRoundingMode(RoundingMode.HALF_UP);

    GridBagConstraints gbc_cntlPanelLabel = new GridBagConstraints();
    gbc_cntlPanelLabel.anchor = GridBagConstraints.EAST;
    gbc_cntlPanelLabel.insets = new Insets(2, 3, 2, 1);
    gbc_cntlPanelLabel.gridx = 0;
    gbc_cntlPanelLabel.gridy = 0;

    GridBagConstraints gbc_cntlPanelInput = new GridBagConstraints();
    gbc_cntlPanelInput.anchor = GridBagConstraints.WEST;
    gbc_cntlPanelInput.insets = new Insets(2, 1, 2, 3);
    gbc_cntlPanelInput.gridx = 1;
    gbc_cntlPanelInput.gridy = 0;

    cntlPanel.add(new JLabel("New Max V"), gbc_cntlPanelLabel);

    newMaxVFmtTextBox = new JFormattedTextField(doubleFmt);
    newMaxVFmtTextBox.setColumns(7);
    newMaxVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == newMaxVFmtTextBox)
                updateNewMafScale();
        }
    });
    cntlPanel.add(newMaxVFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Min V"), gbc_cntlPanelLabel);

    minVFmtTextBox = new JFormattedTextField(doubleFmt);
    minVFmtTextBox.setColumns(7);
    minVFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == minVFmtTextBox)
                updateNewMafScale();
        }
    });
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(minVFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Max Unchanged"), gbc_cntlPanelLabel);

    maxVUnchangedFmtTextBox = new JFormattedTextField(doubleFmt);
    maxVUnchangedFmtTextBox.setColumns(7);
    maxVUnchangedFmtTextBox.addPropertyChangeListener("value", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            Object source = e.getSource();
            if (source == maxVUnchangedFmtTextBox)
                updateNewMafScale();
        }
    });
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(maxVUnchangedFmtTextBox, gbc_cntlPanelInput);

    gbc_cntlPanelLabel.gridx += 2;
    cntlPanel.add(new JLabel("Mode deltaV"), gbc_cntlPanelLabel);

    modeDeltaVFmtTextBox = new JFormattedTextField(scaleDoubleFmt);
    modeDeltaVFmtTextBox.setColumns(7);
    modeDeltaVFmtTextBox.setEditable(false);
    modeDeltaVFmtTextBox.setBackground(new Color(210, 210, 210));
    gbc_cntlPanelInput.gridx += 2;
    cntlPanel.add(modeDeltaVFmtTextBox, gbc_cntlPanelInput);
}

From source file:voldemort.performance.benchmark.Benchmark.java

@SuppressWarnings("cast")
public long runTests(boolean runBenchmark) throws Exception {

    int localOpsCounts = 0;
    String label = null;/*ww w  .ja v a2 s .co m*/
    if (runBenchmark) {
        localOpsCounts = this.opsCount;
        label = new String("benchmark");
    } else {
        localOpsCounts = this.recordCount;
        label = new String("warmup");
    }
    Vector<Thread> threads = new Vector<Thread>();

    for (int index = 0; index < this.numThreads; index++) {
        VoldemortWrapper db = new VoldemortWrapper(storeClient, this.verifyRead && this.warmUpCompleted,
                this.ignoreNulls, this.localMode);
        WorkloadPlugin plugin = null;
        if (this.pluginName != null && this.pluginName.length() > 0) {
            Class<?> cls = Class.forName(this.pluginName);
            try {
                plugin = (WorkloadPlugin) cls.newInstance();
            } catch (IllegalAccessException e) {
                System.err.println("Class not accessible ");
                System.exit(1);
            } catch (InstantiationException e) {
                System.err.println("Class not instantiable.");
                System.exit(1);
            }
            plugin.setDb(db);
        }

        int opsPerThread = localOpsCounts / this.numThreads;
        // Make the last thread handle the remainder.
        if (index == this.numThreads - 1) {
            opsPerThread += localOpsCounts % this.numThreads;
        }

        threads.add(new ClientThread(db, runBenchmark, this.workLoad, opsPerThread,
                this.perThreadThroughputPerMs, this.verbose, plugin));
    }

    long startRunBenchmark = System.currentTimeMillis();
    for (Thread currentThread : threads) {
        currentThread.start();
    }

    StatusThread statusThread = null;
    if (this.statusIntervalSec > 0) {
        statusThread = new StatusThread(threads, this.statusIntervalSec, startRunBenchmark);
        statusThread.start();
    }

    for (Thread currentThread : threads) {
        try {
            currentThread.join();
        } catch (InterruptedException e) {
            if (this.verbose)
                e.printStackTrace();
        }
    }
    long endRunBenchmark = System.currentTimeMillis();

    if (this.statusIntervalSec > 0) {
        statusThread.interrupt();
    }

    // Print the output
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(4);
    nf.setGroupingUsed(false);

    System.out.println("[" + label + "]\tRunTime(ms): " + nf.format((endRunBenchmark - startRunBenchmark)));
    double throughput = Time.MS_PER_SECOND * ((double) localOpsCounts)
            / ((double) (endRunBenchmark - startRunBenchmark));
    System.out.println("[" + label + "]\tThroughput(ops/sec): " + nf.format(throughput));

    if (runBenchmark) {
        Metrics.getInstance().printReport(System.out);
    }
    return (endRunBenchmark - startRunBenchmark);
}