Package fr.soleil.lib.project.swing.text

Examples of fr.soleil.lib.project.swing.text.DocumentNumber


    }

    protected void addNewPoint(final int index) {
//        points.add(e);
        DocumentNumber doc = new DocumentNumber();
        doc.setAllowFloatValues(true);
        doc.setAllowNegativeValues(true);
        final JTextField pointTextField = new JTextField(doc, trajectory.getPoints().get(index) + "", 5);
        pointTextField.setMaximumSize(new Dimension(40, 23));
        pointTextField.setMinimumSize(new Dimension(40, 23));
        pointTextField.setPreferredSize(new Dimension(40, 23));
        pointTextField.addMouseListener(new MouseAdapter() {
View Full Code Here


    protected void addNewInterval(final Interval interval, JPanel intervalsPanel) {
        // intervals.add(interval);
        JPanel intervalPanel = new JPanel();
        intervalPanel.setLayout(new GridBagLayout());

        DocumentNumber fromDoc = new DocumentNumber();
        fromDoc.setAllowFloatValues(true);
        fromDoc.setAllowNegativeValues(true);
        final JTextField fromTextField = new JTextField(fromDoc, interval.getFrom() + "", 15);
        fromTextField.setBorder(new TitledBorder("From"));

        fromTextField.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void removeUpdate(DocumentEvent e) {
                String text = fromTextField.getText();
                updateValue(interval, text);

            }

            @Override
            public void insertUpdate(DocumentEvent e) {
                String text = fromTextField.getText();
                updateValue(interval, text);

            }

            @Override
            public void changedUpdate(DocumentEvent e) {

            }

            protected void updateValue(final Interval interval, String text) {

                try {
                    if (!text.isEmpty()) {
                        double value = Double.parseDouble(text.trim());
                        if (value != interval.getTo()) {
                            interval.setFrom(value);
                            fireEditionStateChanged(true);
                        } else {
                            displayError("Min and max values for interval trajectory shall be different");
                            fireEditionStateChanged(false);
                        }

                    }
                } catch (NumberFormatException e1) {
                    displayError("Illegal value for trajectory interval min boundary: " + text);
                }
            }
        });

        DocumentNumber toDoc = new DocumentNumber();
        toDoc.setAllowFloatValues(true);
        toDoc.setAllowNegativeValues(true);
        final JTextField toTextField = new JTextField(toDoc, interval.getTo() + "", 15);
        toTextField.setBorder(new TitledBorder("To"));

        toTextField.getDocument().addDocumentListener(new DocumentListener() {

            @Override
            public void removeUpdate(DocumentEvent e) {
                String text = toTextField.getText();
                updateValue(interval, text);

            }

            @Override
            public void insertUpdate(DocumentEvent e) {
                String text = toTextField.getText();
                updateValue(interval, text);

            }

            @Override
            public void changedUpdate(DocumentEvent e) {

            }

            protected void updateValue(final Interval interval, String text) {

                try {
                    if (!text.isEmpty()) {
                        double value = Double.parseDouble(text.trim());
                        if (value != interval.getFrom()) {
                            interval.setTo(value);
                            fireEditionStateChanged(true);
                        } else {
                            displayError("Min and max values for interval trajectory shall be different");
                            fireEditionStateChanged(false);
                        }
                    }
                } catch (NumberFormatException e1) {
                    displayError("Illegal value for trajectory interval max boundary: " + text);
                }
            }
        });

        DocumentNumber nbAcqDoc = new DocumentNumber();
        nbAcqDoc.setAllowFloatValues(false);
        nbAcqDoc.setAllowNegativeValues(false);
        final JTextField nbAcqTextField = new JTextField(nbAcqDoc, interval.getNbAcq() + "", 15);
        nbAcqTextField.setBorder(new TitledBorder("Acquisition points count"));

        nbAcqTextField.getDocument().addDocumentListener(new DocumentListener() {
View Full Code Here

TOP

Related Classes of fr.soleil.lib.project.swing.text.DocumentNumber

Copyright © 2018 www.massapicom. 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.