Example usage for java.text NumberFormat setMaximumFractionDigits

List of usage examples for java.text NumberFormat setMaximumFractionDigits

Introduction

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

Prototype

public void setMaximumFractionDigits(int newValue) 

Source Link

Document

Sets the maximum number of digits allowed in the fraction portion of a number.

Usage

From source file:Demo3D.java

/**
 * This run method allows to launch the computation of all frames per second
 * for the framemeter.//w ww .j  ava  2s .c  o  m
 */
public void run() {
    long lastFrameTime;
    double fps;
    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;
    long count = 0;
    double sum = 0;
    double mean = 0;

    while (true) {
        lastFrameTime = viewBr.view.getLastFrameDuration();

        if (lastFrameTime > 0) {
            fps = 1000 / (double) lastFrameTime;
            count += 1;
            sum += fps;
            mean = sum / count;

            // To format all fps-informations.
            NumberFormat numbForm;
            numbForm = NumberFormat.getInstance();
            numbForm.setMaximumFractionDigits(decimalForAllFps);

            if (min > fps && fps != 0 && count > 4)
                min = fps;
            if (max < fps)
                max = fps;

            jLabel.setText("Frames/sec = " + numbForm.format(fps) + "  ;    minFrames/sec = "
                    + numbForm.format(min) + "  ;    maxFrames/sec = " + numbForm.format(max)
                    + "  ;    meanFrames/sec = " + numbForm.format(mean));

            // System.out.println("Frames per second = " + fps);
        }

        try {
            Thread.sleep(sleepDuration);
        } catch (InterruptedException e) {
        }
    }
}

From source file:com.alvermont.terraj.planet.ui.MainFrame.java

/** This method is called from within the constructor to
 * initialize the form./*  ww w  . j  ava2s  . co m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    projPanel = new javax.swing.JPanel();
    projComboBox = new javax.swing.JComboBox<Projector>();
    jLabel1 = new javax.swing.JLabel();
    latSpinner = new javax.swing.JSpinner();
    lonSpinner = new javax.swing.JSpinner();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    previewLabel = new javax.swing.JLabel();
    heightfieldCheckbox = new javax.swing.JCheckBox();
    jLabel17 = new javax.swing.JLabel();
    NumberFormat format = NumberFormat.getInstance();
    format.setMinimumFractionDigits(12);
    format.setMaximumFractionDigits(12);
    seedField = new JFormattedTextField(format);
    randomSeedButton = new javax.swing.JButton();
    randomAllButton = new javax.swing.JButton();
    jPanel1 = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    vgridSpinner = new javax.swing.JSpinner();
    hgridSpinner = new javax.swing.JSpinner();
    outputJPanel = new javax.swing.JPanel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    widthComboBox = new javax.swing.JComboBox<String>();
    heightComboBox = new javax.swing.JComboBox<String>();
    reverseCheckbox = new javax.swing.JCheckBox();
    jLabel18 = new javax.swing.JLabel();
    scaleSpinner = new javax.swing.JSpinner();
    jPanel3 = new javax.swing.JPanel();
    oceanColourButton = new javax.swing.JButton();
    shoreColourButton = new javax.swing.JButton();
    lowColourButton = new javax.swing.JButton();
    highColourButton = new javax.swing.JButton();
    mountainColourButton = new javax.swing.JButton();
    rockyColourButton = new javax.swing.JButton();
    peakColourButton = new javax.swing.JButton();
    spaceColourButton = new javax.swing.JButton();
    lineColourButton = new javax.swing.JButton();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    jLabel12 = new javax.swing.JLabel();
    jLabel13 = new javax.swing.JLabel();
    jLabel14 = new javax.swing.JLabel();
    jLabel15 = new javax.swing.JLabel();
    jLabel16 = new javax.swing.JLabel();
    randomAllColourButton = new javax.swing.JButton();
    randomOceanColourButton = new javax.swing.JButton();
    randomShoreColourButton = new javax.swing.JButton();
    randomLowColourButton = new javax.swing.JButton();
    randomHighColourButton = new javax.swing.JButton();
    randomMountainColourButton = new javax.swing.JButton();
    randomRockyColourButton = new javax.swing.JButton();
    randomPeakColourButton = new javax.swing.JButton();
    randomSpaceColourButton = new javax.swing.JButton();
    randomLineColourButton = new javax.swing.JButton();
    optionsPanel = new javax.swing.JPanel();
    altColourCheckbox = new javax.swing.JCheckBox();
    laticCheckbox = new javax.swing.JCheckBox();
    shadeCheckbox = new javax.swing.JCheckBox();
    shadeAngleSpinner = new javax.swing.JSpinner();
    lighterSpinner = new javax.swing.JSpinner();
    jLabel19 = new javax.swing.JLabel();
    outlineCheckbox = new javax.swing.JCheckBox();
    edgesCheckbox = new javax.swing.JCheckBox();
    jMenuBar1 = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    loadParamsItem = new javax.swing.JMenuItem();
    saveParamsItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    exitItem = new javax.swing.JMenuItem();
    optionsMenu = new javax.swing.JMenu();
    nativeLAFCheckbox = new javax.swing.JCheckBoxMenuItem();
    helpMenu = new javax.swing.JMenu();
    aboutItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Terrain Generator");
    jButton1.setAction(new GenerateAction(this, "Generate"));
    jButton1.setText("Generate ...");
    jButton1.setToolTipText("Generate the terrain using the parameters you have set up");
    jButton1.setPreferredSize(new java.awt.Dimension(120, 23));

    jTabbedPane1.setToolTipText("");
    projPanel.setRequestFocusEnabled(false);
    projComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            projComboBoxActionPerformed(evt);
        }
    });

    jLabel1.setText("Projection Type");
    jLabel1.setToolTipText("Specify the map projection to be used");

    latSpinner.setModel(new SpinnerNumberModel(0.0, -90.0, 90.0, 0.001));
    latSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            latSpinnerStateChanged(evt);
        }
    });

    lonSpinner.setModel(new SpinnerNumberModel(0.0, -180.0, 180.0, 0.001));
    lonSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            lonSpinnerStateChanged(evt);
        }
    });

    jLabel2.setText("Latitude");
    jLabel2.setToolTipText("Set the latitude for the projection");

    jLabel3.setText("Longitude");
    jLabel3.setToolTipText("Set the longitude for the projection");

    previewLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    previewLabel.setText("Not Initialized!");
    previewLabel.setToolTipText("A preview of the map projection");
    previewLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

    heightfieldCheckbox.setText("Don't use a projection, generate heightfield output");
    heightfieldCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    heightfieldCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    heightfieldCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            heightfieldCheckboxActionPerformed(evt);
        }
    });

    jLabel17.setText("Seed value for random terrain generation");
    jLabel17.setToolTipText("Set the seed value. A  particular seed will produce the same terrain");

    seedField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    seedField.setText("0.0");
    seedField.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            seedFieldActionPerformed(evt);
        }
    });

    randomSeedButton.setText("Random Seed");
    randomSeedButton.setToolTipText("Pick a random seed value");
    randomSeedButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomSeedButtonActionPerformed(evt);
        }
    });

    randomAllButton.setText("Randomize All");
    randomAllButton.setToolTipText("Randomize all the items on this page");
    randomAllButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomAllButtonActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout projPanelLayout = new org.jdesktop.layout.GroupLayout(projPanel);
    projPanel.setLayout(projPanelLayout);
    projPanelLayout.setHorizontalGroup(projPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, projPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, previewLabel,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 662, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, heightfieldCheckbox)
                            .add(projPanelLayout.createSequentialGroup()
                                    .add(projPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(jLabel1).add(jLabel2).add(jLabel3).add(jLabel17))
                                    .add(145, 145, 145)
                                    .add(projPanelLayout
                                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, lonSpinner,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, latSpinner,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, projComboBox, 0, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, seedField,
                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 318,
                                                    Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.TRAILING, projPanelLayout
                                                    .createSequentialGroup().add(randomSeedButton)
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED,
                                                            116, Short.MAX_VALUE)
                                                    .add(randomAllButton)))))
                    .addContainerGap()));
    projPanelLayout.setVerticalGroup(projPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(projPanelLayout.createSequentialGroup().addContainerGap()
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel1).add(projComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(latSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel2))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lonSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel3))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel17).add(seedField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(projPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(randomAllButton).add(randomSeedButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(previewLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(heightfieldCheckbox)
                    .addContainerGap()));
    jTabbedPane1.addTab("Project", null, projPanel, "Set the projection parameters");

    jLabel4.setText("Add a grid at this vertical spacing in degrees (0 = none)");

    jLabel5.setText("Add a grid at this horizontal spacing in degrees (0 = none)");

    vgridSpinner.setModel(new SpinnerNumberModel(0.0, -90.0, 90.0, 0.001));
    vgridSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            vgridSpinnerStateChanged(evt);
        }
    });

    hgridSpinner.setModel(new SpinnerNumberModel(0.0, -180.0, 180.0, 0.001));
    hgridSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            hgridSpinnerStateChanged(evt);
        }
    });

    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel4)
                            .add(jLabel5))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 290, Short.MAX_VALUE)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(hgridSpinner).add(vgridSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    93, Short.MAX_VALUE))
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel4).add(vgridSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel5).add(hgridSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(334, Short.MAX_VALUE)));
    jTabbedPane1.addTab("Grid", null, jPanel1, "Set the grid parameters");

    jLabel6.setText("Output width in pixels");

    jLabel7.setText("Output height in pixels");

    widthComboBox.setEditable(true);
    widthComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { "320", "640", "800", "1024", "1280", "1600" }));
    widthComboBox.setSelectedIndex(2);
    widthComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            widthComboBoxActionPerformed(evt);
        }
    });

    heightComboBox.setEditable(true);
    heightComboBox.setModel(
            new javax.swing.DefaultComboBoxModel<>(new String[] { "200", "480", "600", "1024", "1200" }));
    heightComboBox.setSelectedIndex(2);
    heightComboBox.addActionListener(evt -> heightComboBoxActionPerformed(evt)); /*new java.awt.event.ActionListener()
                                                                                 {
                                                                                 public void actionPerformed(java.awt.event.ActionEvent evt)
                                                                                 {
                                                                                 heightComboBoxActionPerformed(evt);
                                                                                 }
                                                                                 });*/

    reverseCheckbox.setText("Reverse the background on the output");
    reverseCheckbox.setToolTipText("If selected will invert the background colour");
    reverseCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    reverseCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));

    jLabel18.setText("Scale (1.0 = normal)");

    scaleSpinner.setModel(new SpinnerNumberModel(1.0, 0.01, 10.0, 0.01));
    scaleSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            scaleSpinnerStateChanged(evt);
        }
    });

    org.jdesktop.layout.GroupLayout outputJPanelLayout = new org.jdesktop.layout.GroupLayout(outputJPanel);
    outputJPanel.setLayout(outputJPanelLayout);
    outputJPanelLayout.setHorizontalGroup(outputJPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(outputJPanelLayout.createSequentialGroup().addContainerGap().add(outputJPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(outputJPanelLayout.createSequentialGroup()
                            .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel6).add(jLabel7))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 458, Short.MAX_VALUE)
                            .add(outputJPanelLayout
                                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(heightComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE)
                                    .add(widthComboBox, 0, 85, Short.MAX_VALUE)))
                    .add(outputJPanelLayout.createSequentialGroup().add(jLabel18)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 401, Short.MAX_VALUE)
                            .add(scaleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(reverseCheckbox)).addContainerGap()));
    outputJPanelLayout.setVerticalGroup(outputJPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(outputJPanelLayout.createSequentialGroup().addContainerGap()
                    .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel6).add(widthComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel7).add(heightComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(outputJPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jLabel18).add(scaleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(reverseCheckbox)
                    .addContainerGap(283, Short.MAX_VALUE)));
    jTabbedPane1.addTab("Output", null, outputJPanel, "Set the output parameters");

    oceanColourButton.setText("Select ...");
    oceanColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            oceanColourButtonActionPerformed(evt);
        }
    });

    shoreColourButton.setText("Select ...");
    shoreColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            shoreColourButtonActionPerformed(evt);
        }
    });

    lowColourButton.setText("Select ...");
    lowColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            lowColourButtonActionPerformed(evt);
        }
    });

    highColourButton.setText("Select ...");
    highColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            highColourButtonActionPerformed(evt);
        }
    });

    mountainColourButton.setText("Select ...");
    mountainColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            mountainColourButtonActionPerformed(evt);
        }
    });

    rockyColourButton.setText("Select ...");
    rockyColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            rockyColourButtonActionPerformed(evt);
        }
    });

    peakColourButton.setText("Select ...");
    peakColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            peakColourButtonActionPerformed(evt);
        }
    });

    spaceColourButton.setText("Select ...");
    spaceColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            spaceColourButtonActionPerformed(evt);
        }
    });

    lineColourButton.setText("Select ...");
    lineColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            lineColourButtonActionPerformed(evt);
        }
    });

    jLabel8.setText("Colour to use for ocean depths");

    jLabel9.setText("Colour to use for shores");

    jLabel10.setText("Colour to use for lowlands");

    jLabel11.setText("Colour to use for highlands");

    jLabel12.setText("Colour to use for mountains");

    jLabel13.setText("Colour to use for high rocky peaks");

    jLabel14.setText("Colour to use for peaks");

    jLabel15.setText("Colour to use for space");

    jLabel16.setText("Colour to use for lines");

    randomAllColourButton.setText("Randomize All Colours");
    randomAllColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomAllColourButtonActionPerformed(evt);
        }
    });

    randomOceanColourButton.setText("Random");
    randomOceanColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomOceanColourButtonActionPerformed(evt);
        }
    });

    randomShoreColourButton.setText("Random");
    randomShoreColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomShoreColourButtonActionPerformed(evt);
        }
    });

    randomLowColourButton.setText("Random");
    randomLowColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomLowColourButtonActionPerformed(evt);
        }
    });

    randomHighColourButton.setText("Random");
    randomHighColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomHighColourButtonActionPerformed(evt);
        }
    });

    randomMountainColourButton.setText("Random");
    randomMountainColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomMountainColourButtonActionPerformed(evt);
        }
    });

    randomRockyColourButton.setText("Random");
    randomRockyColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomRockyColourButtonActionPerformed(evt);
        }
    });

    randomPeakColourButton.setText("Random");
    randomPeakColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomPeakColourButtonActionPerformed(evt);
        }
    });

    randomSpaceColourButton.setText("Random");
    randomSpaceColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomSpaceColourButtonActionPerformed(evt);
        }
    });

    randomLineColourButton.setText("Random");
    randomLineColourButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            randomLineColourButtonActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout
            .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup().addContainerGap().add(jPanel3Layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
                                    jPanel3Layout
                                            .createSequentialGroup().add(
                                                    jPanel3Layout
                                                            .createParallelGroup(
                                                                    org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(jLabel8).add(jLabel9).add(jLabel10)
                                                            .add(jLabel11).add(jLabel12).add(jLabel13)
                                                            .add(jLabel14).add(jLabel15).add(jLabel16))
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 222,
                                                    Short.MAX_VALUE)
                                            .add(jPanel3Layout
                                                    .createParallelGroup(
                                                            org.jdesktop.layout.GroupLayout.TRAILING)
                                                    .add(randomOceanColourButton).add(randomShoreColourButton)
                                                    .add(randomLowColourButton).add(randomMountainColourButton)
                                                    .add(randomRockyColourButton).add(
                                                            randomPeakColourButton)
                                                    .add(randomSpaceColourButton).add(randomLineColourButton)
                                                    .add(randomHighColourButton))
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(jPanel3Layout
                                                    .createParallelGroup(
                                                            org.jdesktop.layout.GroupLayout.LEADING, false)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            oceanColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            shoreColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            lowColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            highColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            mountainColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            rockyColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            peakColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            spaceColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                            lineColourButton,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, randomAllColourButton))
                            .addContainerGap()));
    jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup().addContainerGap()
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(oceanColourButton).add(jLabel8).add(randomOceanColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(shoreColourButton).add(jLabel9).add(randomShoreColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lowColourButton).add(jLabel10).add(randomLowColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(highColourButton).add(jLabel11).add(randomHighColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(mountainColourButton).add(jLabel12).add(randomMountainColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(rockyColourButton).add(jLabel13).add(randomRockyColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(peakColourButton).add(jLabel14).add(randomPeakColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(spaceColourButton).add(jLabel15).add(randomSpaceColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lineColourButton).add(jLabel16).add(randomLineColourButton))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 91, Short.MAX_VALUE)
                    .add(randomAllColourButton).addContainerGap()));
    jTabbedPane1.addTab("Colours", null, jPanel3, "Set the colour parameters");

    altColourCheckbox.setText("Use an alternative colouring scheme");
    altColourCheckbox.setToolTipText("An alternate colour scheme more like an atlas");
    altColourCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    altColourCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    altColourCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            altColourCheckboxActionPerformed(evt);
        }
    });

    laticCheckbox.setText("Use latitude based colouring");
    laticCheckbox.setToolTipText("Colour terrain based on latitude");
    laticCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    laticCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    laticCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            laticCheckboxActionPerformed(evt);
        }
    });

    shadeCheckbox.setText("Do shading with light angle (degrees)");
    shadeCheckbox.setToolTipText("Use bumpmap shading on the terrain");
    shadeCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    shadeCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    shadeCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            shadeCheckboxActionPerformed(evt);
        }
    });

    shadeAngleSpinner.setModel(new SpinnerNumberModel(150.0, 0.0, 360.0, 0.1));
    shadeAngleSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            shadeAngleSpinnerStateChanged(evt);
        }
    });

    lighterSpinner.setModel(new SpinnerNumberModel(0, 0, 100, 1));
    lighterSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            lighterSpinnerStateChanged(evt);
        }
    });

    jLabel19.setText("Lighten colours by this amount (doesn't work with alt colours)");
    jLabel19.setToolTipText("Use lighter colouring");

    outlineCheckbox.setText("Draw in outline mode only");
    outlineCheckbox.setToolTipText("Draw a black and white coastline output only");
    outlineCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    outlineCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    outlineCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            outlineCheckboxActionPerformed(evt);
        }
    });

    edgesCheckbox.setText("Draw the edges of coastlines in black");
    edgesCheckbox.setToolTipText("Outline the coasts in black");
    edgesCheckbox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    edgesCheckbox.setMargin(new java.awt.Insets(0, 0, 0, 0));
    edgesCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            edgesCheckboxActionPerformed(evt);
        }
    });

    org.jdesktop.layout.GroupLayout optionsPanelLayout = new org.jdesktop.layout.GroupLayout(optionsPanel);
    optionsPanel.setLayout(optionsPanelLayout);
    optionsPanelLayout.setHorizontalGroup(optionsPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(optionsPanelLayout.createSequentialGroup().addContainerGap().add(optionsPanelLayout
                    .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(altColourCheckbox)
                    .add(laticCheckbox)
                    .add(optionsPanelLayout.createSequentialGroup().add(shadeCheckbox)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 304, Short.MAX_VALUE)
                            .add(shadeAngleSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                            optionsPanelLayout.createSequentialGroup().add(17, 17, 17).add(jLabel19)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 189,
                                            Short.MAX_VALUE)
                                    .add(lighterSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 163,
                                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(optionsPanelLayout.createSequentialGroup().add(17, 17, 17).add(outlineCheckbox))
                    .add(edgesCheckbox)).addContainerGap()));
    optionsPanelLayout.setVerticalGroup(optionsPanelLayout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(optionsPanelLayout.createSequentialGroup().addContainerGap().add(altColourCheckbox)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(laticCheckbox)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(optionsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(shadeCheckbox).add(shadeAngleSpinner,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(optionsPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lighterSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel19))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(edgesCheckbox)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(outlineCheckbox)
                    .addContainerGap(250, Short.MAX_VALUE)));

    optionsPanelLayout.linkSize(new java.awt.Component[] { altColourCheckbox, laticCheckbox, shadeCheckbox },
            org.jdesktop.layout.GroupLayout.VERTICAL);

    jTabbedPane1.addTab("Options", null, optionsPanel, "Set the rest of the options");

    fileMenu.setText("File");
    loadParamsItem.setText("Load Settings ...");
    loadParamsItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadParamsItemActionPerformed(evt);
        }
    });

    fileMenu.add(loadParamsItem);

    saveParamsItem.setText("Save Settings ...");
    saveParamsItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveParamsItemActionPerformed(evt);
        }
    });

    fileMenu.add(saveParamsItem);

    fileMenu.add(jSeparator1);

    exitItem.setText("Exit ...");
    exitItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitItemActionPerformed(evt);
        }
    });

    fileMenu.add(exitItem);

    jMenuBar1.add(fileMenu);

    optionsMenu.setText("Options");
    nativeLAFCheckbox.setText("Use system look and feel");
    nativeLAFCheckbox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            nativeLAFCheckboxActionPerformed(evt);
        }
    });

    optionsMenu.add(nativeLAFCheckbox);

    jMenuBar1.add(optionsMenu);

    helpMenu.setText("Help");
    aboutItem.setText("About ...");
    aboutItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            aboutItemActionPerformed(evt);
        }
    });

    helpMenu.add(aboutItem);

    jMenuBar1.add(helpMenu);

    setJMenuBar(jMenuBar1);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton1,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 687,
                                    Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup().addContainerGap()
                    .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 715) / 2, (screenSize.height - 515) / 2, 715, 515);
}

From source file:net.sourceforge.eclipsetrader.core.internal.XMLRepository.java

private void saveSecurity(Security security, Document document, Element root) {
    Element element = document.createElement("security"); //$NON-NLS-1$
    element.setAttribute("id", String.valueOf(security.getId())); //$NON-NLS-1$
    root.appendChild(element);/*from   w w w  . jav a  2 s  .  c  o  m*/

    Element node = document.createElement("code"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(security.getCode()));
    element.appendChild(node);
    node = document.createElement("description"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(security.getDescription()));
    element.appendChild(node);
    if (security.getCurrency() != null) {
        node = document.createElement("currency"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(security.getCurrency().getCurrencyCode()));
        element.appendChild(node);
    }

    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMinimumIntegerDigits(2);
    nf.setMinimumFractionDigits(0);
    nf.setMaximumFractionDigits(0);

    Element collectorNode = document.createElement("dataCollector"); //$NON-NLS-1$
    collectorNode.setAttribute("enable", String.valueOf(security.isEnableDataCollector())); //$NON-NLS-1$
    element.appendChild(collectorNode);
    node = document.createElement("begin"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(
            nf.format(security.getBeginTime() / 60) + ":" + nf.format(security.getBeginTime() % 60))); //$NON-NLS-1$
    collectorNode.appendChild(node);
    node = document.createElement("end"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(
            nf.format(security.getEndTime() / 60) + ":" + nf.format(security.getEndTime() % 60))); //$NON-NLS-1$
    collectorNode.appendChild(node);
    node = document.createElement("weekdays"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(security.getWeekDays())));
    collectorNode.appendChild(node);
    node = document.createElement("keepdays"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(String.valueOf(security.getKeepDays())));
    collectorNode.appendChild(node);

    if (security.getQuoteFeed() != null || security.getLevel2Feed() != null
            || security.getHistoryFeed() != null) {
        Node feedsNode = document.createElement("feeds"); //$NON-NLS-1$
        element.appendChild(feedsNode);
        if (security.getQuoteFeed() != null) {
            node = document.createElement("quote"); //$NON-NLS-1$
            node.setAttribute("id", security.getQuoteFeed().getId()); //$NON-NLS-1$
            if (security.getQuoteFeed().getExchange() != null)
                node.setAttribute("exchange", security.getQuoteFeed().getExchange()); //$NON-NLS-1$
            node.appendChild(document.createTextNode(security.getQuoteFeed().getSymbol()));
            feedsNode.appendChild(node);
        }
        if (security.getLevel2Feed() != null) {
            node = document.createElement("level2"); //$NON-NLS-1$
            node.setAttribute("id", security.getLevel2Feed().getId()); //$NON-NLS-1$
            if (security.getLevel2Feed().getExchange() != null)
                node.setAttribute("exchange", security.getLevel2Feed().getExchange()); //$NON-NLS-1$
            node.appendChild(document.createTextNode(security.getLevel2Feed().getSymbol()));
            feedsNode.appendChild(node);
        }
        if (security.getHistoryFeed() != null) {
            node = document.createElement("history"); //$NON-NLS-1$
            node.setAttribute("id", security.getHistoryFeed().getId()); //$NON-NLS-1$
            if (security.getHistoryFeed().getExchange() != null)
                node.setAttribute("exchange", security.getHistoryFeed().getExchange()); //$NON-NLS-1$
            node.appendChild(document.createTextNode(security.getHistoryFeed().getSymbol()));
            feedsNode.appendChild(node);
        }
    }

    if (security.getTradeSource() != null) {
        TradeSource source = security.getTradeSource();

        Element feedsNode = document.createElement("tradeSource"); //$NON-NLS-1$
        feedsNode.setAttribute("id", source.getTradingProviderId()); //$NON-NLS-1$
        if (source.getExchange() != null)
            feedsNode.setAttribute("exchange", source.getExchange()); //$NON-NLS-1$
        element.appendChild(feedsNode);

        if (!source.getSymbol().equals("")) //$NON-NLS-1$
        {
            node = document.createElement("symbol"); //$NON-NLS-1$
            node.appendChild(document.createTextNode(source.getSymbol()));
            feedsNode.appendChild(node);
        }
        if (source.getAccountId() != null) {
            node = document.createElement("account"); //$NON-NLS-1$
            node.appendChild(document.createTextNode(String.valueOf(source.getAccountId())));
            feedsNode.appendChild(node);
        }
        node = document.createElement("quantity"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(source.getQuantity())));
        feedsNode.appendChild(node);
    }

    if (security.getQuote() != null) {
        Quote quote = security.getQuote();
        Node quoteNode = document.createElement("quote"); //$NON-NLS-1$

        if (quote.getDate() != null) {
            node = document.createElement("date"); //$NON-NLS-1$
            node.appendChild(document.createTextNode(dateTimeFormat.format(quote.getDate())));
            quoteNode.appendChild(node);
        }
        node = document.createElement("last"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(quote.getLast())));
        quoteNode.appendChild(node);
        node = document.createElement("bid"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(quote.getBid())));
        quoteNode.appendChild(node);
        node = document.createElement("ask"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(quote.getAsk())));
        quoteNode.appendChild(node);
        node = document.createElement("bidSize"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(quote.getBidSize())));
        quoteNode.appendChild(node);
        node = document.createElement("askSize"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(quote.getAskSize())));
        quoteNode.appendChild(node);
        node = document.createElement("volume"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(quote.getVolume())));
        quoteNode.appendChild(node);

        element.appendChild(quoteNode);
    }

    Node dataNode = document.createElement("data"); //$NON-NLS-1$
    element.appendChild(dataNode);

    if (security.getOpen() != null) {
        node = document.createElement("open"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(security.getOpen())));
        dataNode.appendChild(node);
    }
    if (security.getHigh() != null) {
        node = document.createElement("high"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(security.getHigh())));
        dataNode.appendChild(node);
    }
    if (security.getLow() != null) {
        node = document.createElement("low"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(security.getLow())));
        dataNode.appendChild(node);
    }
    if (security.getClose() != null) {
        node = document.createElement("close"); //$NON-NLS-1$
        node.appendChild(document.createTextNode(String.valueOf(security.getClose())));
        dataNode.appendChild(node);
    }

    node = document.createElement("comment"); //$NON-NLS-1$
    node.appendChild(document.createTextNode(security.getComment()));
    element.appendChild(node);

    for (Iterator iter = security.getSplits().iterator(); iter.hasNext();) {
        Split split = (Split) iter.next();
        node = document.createElement("split"); //$NON-NLS-1$
        node.setAttribute("date", dateTimeFormat.format(split.getDate())); //$NON-NLS-1$
        node.setAttribute("fromQuantity", String.valueOf(split.getFromQuantity())); //$NON-NLS-1$
        node.setAttribute("toQuantity", String.valueOf(split.getToQuantity())); //$NON-NLS-1$
        element.appendChild(node);
    }

    for (Iterator iter = security.getDividends().iterator(); iter.hasNext();) {
        Dividend dividend = (Dividend) iter.next();
        node = document.createElement("dividend"); //$NON-NLS-1$
        node.setAttribute("date", dateTimeFormat.format(dividend.getDate())); //$NON-NLS-1$
        node.setAttribute("value", String.valueOf(dividend.getValue())); //$NON-NLS-1$
        element.appendChild(node);
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void buttonPDT_actionPerformed(ActionEvent event) {
    try {/*from   ww w.ja v a2s. co  m*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        String answer = nf.format(_precursorDiscoveryMzTolerance);
        String newAnswer = JOptionPane.showInputDialog("New value for precursor tolerance:", answer);
        _precursorDiscoveryMzTolerance = (float) Double.parseDouble(newAnswer);
        initStuff();
    } catch (Exception e) {
        ApplicationContext.infoMessage("Bad value for precursor tolerance.");
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void buttonDTOL_actionPerformed(ActionEvent event) {
    try {//from  w w  w .  j av  a2 s .co m
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(4);
        nf.setMinimumFractionDigits(4);
        String answer = nf.format(_daughterMzTolerance);
        String newAnswer = JOptionPane.showInputDialog("New value for product tolerance:", answer);
        _daughterMzTolerance = (float) Double.parseDouble(newAnswer);
        initStuff();
    } catch (Exception e) {
        ApplicationContext.infoMessage("Bad value for product tolerance.");
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

protected XYSeries makeParentSeries(MRMTransition parent) {

    float minMz = parent.getPrecursorMz() - _precursorDiscoveryMzTolerance - _precursorChromatogramWindow;
    float maxMz = parent.getPrecursorMz() + _precursorDiscoveryMzTolerance + _precursorChromatogramWindow;
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(1);
    nf.setMinimumFractionDigits(1);//from   w  ww .j  a  v  a  2  s . co  m

    XYSeries result = new XYSeries(parent.getName() + "\u00B1"
            + nf.format(_precursorDiscoveryMzTolerance + _precursorChromatogramWindow));
    //precursor scans
    for (int i = parent.getMinScanOfDaughters(); i <= parent.getMaxScanOfDaughters(); i++) {
        int scanNum = _run.getIndexForScanNum(i);
        if (scanNum <= 0)
            continue;
        MSRun.MSScan ms1Scan = _run.getScan(scanNum);
        boolean sim_only = _sim;
        String scanType = ms1Scan.getScanType();
        if (!sim_only || (sim_only && scanType.equalsIgnoreCase("SIM")))
            result.add(ms1Scan.getDoubleRetentionTime(), Utils.getMaxIntensityForScan(ms1Scan, minMz, maxMz));
    }
    return result;
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void buttonSICUpdate_actionPerformed(ActionEvent event) {
    try {//from w  ww  .j ava2 s .  c om
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        String answer = nf.format(_precursorChromatogramWindow);
        String newAnswer = JOptionPane.showInputDialog("New value for MS1 SIC tolerance:", answer);
        _precursorChromatogramWindow = (float) Double.parseDouble(newAnswer);

        for (MRMTransition t : _mrmTransitions) {
            t.setGraphData(null);
            for (MRMDaughter d : t.getDaughters().values()) {
                d.setGraphData(null);
            }
        }
        updateChartsAndFields(false);
    } catch (Exception e) {
        ApplicationContext.infoMessage("Bad value for MZ tolerance, please try again");
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void menuItemAMin_actionPerformed(ActionEvent event) {
    try {/*from www .  j a  v  a 2s  .c om*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        nf.setGroupingUsed(false);
        String answer = nf.format(_minAreaCutoff);
        String newAnswer = JOptionPane.showInputDialog("New value for min AUC cutoff:", answer);
        if (newAnswer == null)
            return;
        float newCutoff = Float.parseFloat(newAnswer);
        if (newCutoff > 0.0f) {
            for (MRMTransition mrt : _mrmTransitions) {
                for (MRMDaughter curd : mrt.getDaughters().values()) {
                    if (curd.getBestElutionCurve() != null && curd.getBestElutionCurve().getAUC() < newCutoff) {
                        ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false),
                                curd.getElutionDataTableRow(), peaksData.Accept.colno);
                    }
                }
            }
        }
        _minAreaCutoff = newCutoff;
    } catch (Exception e) {
        ApplicationContext.infoMessage("Failed to change min acceptable AUC: " + e);
    }
}

From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java

public void menuItemPMin_actionPerformed(ActionEvent event) {
    try {/*w w w  . j  av  a  2s  . c o m*/
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setMinimumFractionDigits(2);
        nf.setGroupingUsed(false);
        String answer = nf.format(_minPeakCutoff);
        String newAnswer = JOptionPane.showInputDialog("New value for min peak cutoff:", answer);
        if (newAnswer == null)
            return;
        float newCutoff = Float.parseFloat(newAnswer);
        if (newCutoff > 0.0f) {
            for (MRMTransition mrt : _mrmTransitions) {
                for (MRMDaughter curd : mrt.getDaughters().values()) {
                    if (curd.getBestElutionCurve() != null
                            && curd.getBestElutionCurve().getHighestPointY() < newCutoff) {
                        ((PeaksTableModel) (peaksTable.getModel())).setValueAt(new Boolean(false),
                                curd.getElutionDataTableRow(), peaksData.Accept.colno);
                    }
                }
            }
        }
        _minPeakCutoff = newCutoff;
    } catch (Exception e) {
        ApplicationContext.infoMessage("Failed to change min acceptable peak height: " + e);
    }
}

From source file:com.shahnami.fetch.Controller.FetchMovies.java

public List<Movie> getBollyMovies(String query) {
    try {//from   w w w .ja v  a 2 s. c  om
        Document doc;
        Elements searchDetails;
        String link;
        String title;
        String image = null;
        Elements linkAndTitles;
        Document movieDetails;
        double rating = 0;
        String magnetLink;
        String torrentFile;
        NumberFormat formatter;
        String output;
        if (query.equalsIgnoreCase("")) {
            //
        } else {
            doc = Jsoup.connect("https://1337x.to/search/" + URLEncoder.encode(query, "UTF-8") + "+hindi/1/")
                    .userAgent("Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.2) Gecko/20040803").get();
            searchDetails = doc.getElementsByClass("coll-1");
            for (Element e : searchDetails) {
                linkAndTitles = e.getElementsByTag("strong");
                for (Element e1 : linkAndTitles) {
                    link = "https://1337x.to" + e1.getElementsByTag("a").first().attr("href");
                    title = e1.getElementsByTag("a").first().html();
                    if (!link.contains("/mirror")) {
                        Movie m = new Movie();
                        m.setTitle(title.replace("<b>", "").replace("</b>", "").trim()); //.substring(0, 47)+ "..."
                        m.setLanguage("Hindi");
                        m.setUrl(link);
                        Pattern pattern = Pattern.compile(".*([\\s(]+[0-9]{4}[\\s)]+).*");
                        Matcher matcher = pattern.matcher(title);
                        while (matcher.find()) {
                            m.setYear(Integer
                                    .parseInt(matcher.group(1).replace("(", "").replace(")", "").trim()));
                        }
                        movieDetails = Jsoup.connect(link).get();
                        try {
                            image = movieDetails.getElementsByClass("moive-box").first().getElementsByTag("img")
                                    .first().attr("src");
                            rating = Float.parseFloat(
                                    movieDetails.getElementsByClass("rateing").first().getElementsByTag("i")
                                            .attr("style").split(":")[1].replace("%;", "").trim());
                        } catch (Exception ex) {
                            //
                        }
                        magnetLink = movieDetails.getElementsByClass("magnet").first().attr("href");
                        torrentFile = movieDetails.getElementsByClass("torrent").first().attr("href");
                        formatter = NumberFormat.getNumberInstance();
                        formatter.setMinimumFractionDigits(2);
                        formatter.setMaximumFractionDigits(2);
                        output = formatter.format(rating / 10);
                        rating = Double.parseDouble(output);
                        if (rating < 1) {
                            rating = 0;
                        }
                        m.setRating(rating);
                        m.setSmall_cover_image(image);
                        List<Torrent> torrents = new ArrayList<>();
                        Torrent t = new Torrent();
                        t.setUrl(magnetLink);
                        Torrent t2 = new Torrent();
                        t2.setUrl(torrentFile);
                        torrents.add(t);
                        torrents.add(t2);
                        m.setTorrents(torrents);
                        m.getTorrents().get(0).setSeeds(
                                Integer.valueOf(movieDetails.getElementsByClass("green").first().text()));
                        m.getTorrents().get(0).setPeers(
                                Integer.valueOf(movieDetails.getElementsByClass("red").first().text()));
                        m.setIsBollywood(true);
                        m.setSize(movieDetails.getElementsByClass("list").first().getElementsByTag("li").get(3)
                                .text().substring(10).trim());
                        _movies.add(m);
                    }
                }
                //String link = linkAndTitle.getElementsByAttribute("href").first().text();
                //System.out.println(link);
                //String title = linkAndTitle.getElementsByTag("b").text();
                //System.out.println(title);
            }
        }
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(FetchMovies.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(FetchMovies.class.getName()).log(Level.SEVERE, null, ex);
    }
    return _movies;
}