Examples of NumberFormatter


Examples of javax.swing.text.NumberFormatter

     *        
     * @throws NullPointerException   if the model is <code>null</code>
     */
    public static JFormattedTextField createLongField(ValueModel valueModel,
            NumberFormat numberFormat, Long emptyNumber) {
        NumberFormatter numberFormatter =
            new EmptyNumberFormatter(numberFormat, emptyNumber);
        numberFormatter.setValueClass(Long.class);

        return createFormattedTextField(valueModel, numberFormatter);
    }
View Full Code Here

Examples of javax.swing.text.NumberFormatter

        DefaultFormatter formatter;
        if (value instanceof Date) {
            formatter = new DateFormatter();
        }
        else if (value instanceof Number) {
            formatter = new NumberFormatter();
        }
        else {
            formatter = new DefaultFormatter();
        }
        if (logger.isDebugEnabled()) {
View Full Code Here

Examples of javax.swing.text.NumberFormatter

        minimum = new Integer(min);
        maximum = new Integer(max);

        //Set up the editor for the integer cells.
        integerFormat = NumberFormat.getIntegerInstance();
        NumberFormatter intFormatter = new NumberFormatter(integerFormat);
        intFormatter.setFormat(integerFormat);
        intFormatter.setMinimum(minimum);
        intFormatter.setMaximum(maximum);

        ftf.setFormatterFactory(
                new DefaultFormatterFactory(intFormatter));
        ftf.setValue(minimum);
        ftf.setHorizontalAlignment(JTextField.TRAILING);
View Full Code Here

Examples of javax.swing.text.NumberFormatter

    // Set up the editor for the integer cells.
    percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMinimumIntegerDigits(1);
    percentFormat.setMinimumFractionDigits(2);
    percentFormat.setMaximumFractionDigits(2);
    NumberFormatter percentFormatter = new NumberFormatter(percentFormat);
    percentFormatter.setFormat(percentFormat);

    ftf.setFormatterFactory(new DefaultFormatterFactory(percentFormatter));
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
View Full Code Here

Examples of javax.swing.text.NumberFormatter

    // Set up the editor for the integer cells.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMinimumFractionDigits(2);
    numberFormat.setMaximumFractionDigits(2);
    numberFormat.setMinimumIntegerDigits(1);
    NumberFormatter numberFormatter = new NumberFormatter(numberFormat);
    numberFormatter.setFormat(numberFormat);

    ftf.setFormatterFactory(new DefaultFormatterFactory(numberFormatter));
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
View Full Code Here

Examples of javax.swing.text.NumberFormatter

     * @param boleto
     *
     */
    public InputStream transform(Boleto boleto) {

        NumberFormatter formatter = new NumberFormatter(new DecimalFormat(
                "#,##0.00"));

        // gera template com o fundo do boleto
        URL imagemTitulo = BoletoTransformer.class
                .getResource("/br/com/caelum/stella/boleto/img/template.png");

        try {
            this.writer.writeImage(0, 55, imageFor(imagemTitulo), 514.22f,
                    385.109f);
            this.writer.writeImage(0, 805 - 486, imageFor(boleto.getBanco()
                    .getImage()), 100, 23);
        } catch (IOException e) {
            throw new GeracaoBoletoException(
                    "Erro na leitura das imagens do boleto", e);
        }

        for (int i = 0; i < boleto.getDescricoes().size(); i++)
            this.writer.writeBold(5, 805 - 70 - i * 15, boleto.getDescricoes()
                    .get(i));

        this.writer.write(50, LINHA1, boleto.getEmissor().getCedente());

        this.writer.write(5, LINHA2, boleto.getSacado().getNome());

        this.writer.write(230, LINHA2, formatDate(boleto.getDatas()
                .getVencimento()));

        try {
            this.writer.write(400, LINHA2, formatter.valueToString(boleto
                    .getValorBoleto().doubleValue()));
        } catch (NumberFormatException e) {
            throw new CriacaoBoletoException(
                    "Erro na formatação do valor do boleto", e);
        } catch (ParseException e) {
            throw new CriacaoBoletoException(
                    "Erro na formatação do valor do boleto", e);
        }

        this.writer.write(5, LINHA3, boleto.getEmissor().getAgencia() + "-"
                + boleto.getEmissor().getDvAgencia() + " / "
                + boleto.getEmissor().getContaCorrente() + "-"
                + boleto.getEmissor().getDvContaCorrente());

        this.writer.write(146, LINHA3, boleto.getEmissor()
                .getNossoNumeroFormatado());

        this.writer.writeBold(125, LINHA4, boleto.getBanco()
                .getNumeroFormatado());

        this.writer.writeBold(175, LINHA4, boleto.getBanco()
                .geraLinhaDigitavelPara(boleto));

        for (int i = 0; i < boleto.getLocaisDePagamento().size(); i++)
            this.writer.write(5, LINHA5 - (i - 1) * 10, boleto
                    .getLocaisDePagamento().get(i));

        this.writer.write(425, LINHA5, formatDate(boleto.getDatas()
                .getVencimento()));

        this.writer.write(5, LINHA6, boleto.getEmissor().getCedente());

        this.writer.write(420, LINHA6, boleto.getEmissor().getAgencia() + " - "
                + boleto.getEmissor().getDvAgencia() + " / "
                + boleto.getEmissor().getContaCorrente() + "-"
                + boleto.getEmissor().getDvContaCorrente());

        this.writer.write(5, LINHA7, formatDate(boleto.getDatas()
                .getDocumento()));

        this.writer.write(70, LINHA7,
                !boleto.getNoDocumento().equals("") ? boleto
                        .getNoDocumentoFormatado() : boleto.getEmissor()
                        .getNossoNumeroFormatado());

        this.writer.write(180, LINHA7, boleto.getEspecieDocumento());

        this.writer.write(250, LINHA7, boleto.getAceite() ? "S" : "N");

        this.writer.write(300, LINHA7, formatDate(boleto.getDatas()
                .getProcessamento()));

        this.writer.write(410, LINHA7, boleto.getEmissor().getCarteira()
                + " / " + boleto.getEmissor().getNossoNumeroFormatado());

        this.writer.write(122, LINHA8, boleto.getEmissor().getCarteira());

        this.writer.write(190, LINHA8, boleto.getEspecieMoeda());

        try {
            this.writer.write(430, LINHA8, formatter.valueToString(boleto
                    .getValorBoleto().doubleValue()));
        } catch (NumberFormatException e) {
            throw new CriacaoBoletoException(
                    "Erro na formatação do valor do boleto", e);
        } catch (ParseException e) {
View Full Code Here

Examples of javax.swing.text.NumberFormatter

    super(new JFormattedTextField());
    ftf = (JFormattedTextField)getComponent();

    //Set up the editor for the integer cells.
    integerFormat = NumberFormat.getIntegerInstance();
    NumberFormatter intFormatter = new NumberFormatter(integerFormat);
    intFormatter.setFormat(integerFormat);

    ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);
View Full Code Here

Examples of net.sf.saxon.number.NumberFormatter

        }

        if (formatAtt != null) {
            format = makeAttributeValueTemplate(formatAtt);
            if (format instanceof StringLiteral) {
                formatter = new NumberFormatter();
                formatter.prepare(((StringLiteral)format).getStringValue());
            }
            // else we'll need to allocate the formatter at run-time
        } else {
            formatter = new NumberFormatter();
            formatter.prepare("1");
        }

        if (gsepAtt!=null && gsizeAtt!=null) {
            // the spec says that if only one is specified, it is ignored
View Full Code Here

Examples of net.sf.saxon.number.NumberFormatter

        }

        if (formatAtt != null) {
            format = makeAttributeValueTemplate(formatAtt);
            if (format instanceof StringValue) {
                formatter = new NumberFormatter();
                formatter.prepare(((StringValue)format).getStringValue());
            }
            // else we'll need to allocate the formatter at run-time
        } else {
            formatter = new NumberFormatter();
            formatter.prepare("1");
        }

        if (gsepAtt!=null && gsizeAtt!=null) {
            // the spec says that if only one is specified, it is ignored
View Full Code Here

Examples of net.sf.saxon.number.NumberFormatter

        if (vec == null) {
            vec = new ArrayList(1);
            vec.add(new Long(value));
        }

        NumberFormatter nf;
        if (formatter == null) {              // format not known until run-time
            nf = new NumberFormatter();
            nf.prepare(format.evaluateAsString(context));
        } else {
            nf = formatter;
        }

        String s = nf.format(vec, gpsize, gpseparator, letterVal, ordinalVal, numb);
        return new StringValue(s);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.