public int showDialog() { options = new OptionsPanel(6, 6); options.addComponent(autoScaleCheck); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(fromLabel); panel.add(fromNumberField); panel.add(toLabel); panel.add(toNumberField); options.addComponent(panel); JPanel panel1 = new JPanel(); panel1.setLayout(new FlowLayout()); panel1.add(new JLabel("Width from:")); panel1.add(fromWidthField); panel1.add(new JLabel("to:")); panel1.add(toWidthField); options.addComponent(panel1); JOptionPane optionPane = new JOptionPane( options, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); final JDialog dialog = optionPane.createDialog(frame, "Setup colour range"); dialog.pack(); autoScaleCheck.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean enabled = !autoScaleCheck.isSelected(); fromLabel.setEnabled(enabled); fromNumberField.setEnabled(enabled); toLabel.setEnabled(enabled); toNumberField.setEnabled(enabled); } }); dialog.setVisible(true); int result = JOptionPane.CANCEL_OPTION; Integer value = (Integer) optionPane.getValue(); if (value != null && value.intValue() != -1) { result = value.intValue(); } return result; }
public ChartSetupDialog( final JFrame frame, boolean canLogXAxis, boolean canLogYAxis, int defaultMinXAxisFlag, int defaultMaxXAxisFlag, int defaultMinYAxisFlag, int defaultMaxYAxisFlag) { this.frame = frame; this.canLogXAxis = canLogXAxis; this.canLogYAxis = canLogYAxis; this.defaultMinXAxisFlag = defaultMinXAxisFlag; this.defaultMaxXAxisFlag = defaultMaxXAxisFlag; this.defaultMinYAxisFlag = defaultMinYAxisFlag; this.defaultMaxYAxisFlag = defaultMaxYAxisFlag; logXAxis = new JCheckBox("Log axis"); manualXAxis = new JCheckBox("Manual range"); minXValue = new RealNumberField(); minXValue.setColumns(12); maxXValue = new RealNumberField(); maxXValue.setColumns(12); logYAxis = new JCheckBox("Log axis"); manualYAxis = new JCheckBox("Manual range"); minYValue = new RealNumberField(); minYValue.setColumns(12); maxYValue = new RealNumberField(); maxYValue.setColumns(12); optionPanel = new OptionsPanel(12, 12); optionPanel.addSpanningComponent(new JLabel("X Axis")); if (canLogXAxis) { optionPanel.addComponent(logXAxis); } optionPanel.addComponent(manualXAxis); final JLabel minXLabel = new JLabel("Minimum Value:"); optionPanel.addComponents(minXLabel, minXValue); final JLabel maxXLabel = new JLabel("Maximum Value:"); optionPanel.addComponents(maxXLabel, maxXValue); manualXAxis.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { final boolean xaSelected = manualXAxis.isSelected(); minXLabel.setEnabled(xaSelected); minXValue.setEnabled(xaSelected); maxXLabel.setEnabled(xaSelected); maxXValue.setEnabled(xaSelected); } }); manualXAxis.setSelected(true); manualXAxis.setSelected(false); optionPanel.addSeparator(); optionPanel.addSpanningComponent(new JLabel("Y Axis")); if (canLogYAxis) { optionPanel.addComponent(logYAxis); } optionPanel.addComponent(manualYAxis); final JLabel minYLabel = new JLabel("Minimum Value:"); optionPanel.addComponents(minYLabel, minYValue); final JLabel maxYLabel = new JLabel("Maximum Value:"); optionPanel.addComponents(maxYLabel, maxYValue); manualYAxis.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { final boolean yaSelected = manualYAxis.isSelected(); minYLabel.setEnabled(yaSelected); minYValue.setEnabled(yaSelected); maxYLabel.setEnabled(yaSelected); maxYValue.setEnabled(yaSelected); } }); manualYAxis.setSelected(true); manualYAxis.setSelected(false); }
public MCMCPanel(BeautiFrame parent) { setLayout(new BorderLayout()); // Mac OS X components have more spacing round them already optionsPanel = new OptionsPanel(12, (OSType.isMac() ? 6 : 24)); this.frame = parent; setOpaque(false); optionsPanel.setOpaque(false); chainLengthField.setValue(100000); chainLengthField.setColumns(10); optionsPanel.addComponentWithLabel("Length of chain:", chainLengthField); chainLengthField.addKeyListener( new java.awt.event.KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) { options.chainLength = chainLengthField.getValue(); frame.setDirty(); } }); optionsPanel.addSeparator(); echoEveryField.setValue(1000); echoEveryField.setColumns(10); optionsPanel.addComponentWithLabel("Echo state to screen every:", echoEveryField); echoEveryField.addKeyListener( new java.awt.event.KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) { options.echoEvery = echoEveryField.getValue(); frame.setDirty(); } }); logEveryField.setValue(100); logEveryField.setColumns(10); optionsPanel.addComponentWithLabel("Log parameters every:", logEveryField); logEveryField.addKeyListener( new java.awt.event.KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) { options.logEvery = logEveryField.getValue(); frame.setDirty(); } }); optionsPanel.addSeparator(); fileNameStemField.setColumns(32); optionsPanel.addComponentWithLabel("File name stem:", fileNameStemField); fileNameStemField.setEditable(true); fileNameStemField.addKeyListener( new java.awt.event.KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) { options.fileNameStem = fileNameStemField.getText(); updateOtherFileNames(options); frame.setDirty(); } }); optionsPanel.addComponent(addTxt); if (OSType.isWindows()) { addTxt.setSelected(true); } else { addTxt.setSelected(false); } addTxt.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { setOptions(options); frame.setDirty(); } }); optionsPanel.addSeparator(); logFileNameField.setColumns(32); optionsPanel.addComponentWithLabel("Log file name:", logFileNameField); logFileNameField.setEditable(false); // optionsPanel.addComponent(allowOverwriteLogCheck); // allowOverwriteLogCheck.setSelected(false); // allowOverwriteLogCheck.addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent changeEvent) { // options.allowOverwriteLog = allowOverwriteLogCheck.isSelected(); // } // }); treeFileNameField.setColumns(32); optionsPanel.addComponentWithLabel("Trees file name:", treeFileNameField); treeFileNameField.setEditable(false); // addComponent(mapTreeLogCheck); // mapTreeLogCheck.setOpaque(false); // mapTreeLogCheck.addActionListener(new java.awt.event.ActionListener() { // public void actionPerformed(ActionEvent e) { // mapTreeFileNameField.setEnabled(mapTreeLogCheck.isSelected()); // } // }); // // mapTreeFileNameField.setColumns(32); // addComponentWithLabel("MAP tree file name:", mapTreeFileNameField); optionsPanel.addComponent(substTreeLogCheck); substTreeLogCheck.setOpaque(false); substTreeLogCheck.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { options.substTreeLog = substTreeLogCheck.isSelected(); updateTreeFileNameList(); substTreeFileNameField.setEnabled(substTreeLogCheck.isSelected()); if (substTreeLogCheck.isSelected()) { substTreeFileNameField.setText(displayTreeList(options.substTreeFileName)); } else { substTreeFileNameField.setText(""); } frame.setDirty(); } }); substTreeFileNameField.setColumns(32); substTreeFileNameField.setEditable(false); substTreeFileNameField.setEnabled(false); optionsPanel.addComponentWithLabel("Substitutions trees file name:", substTreeFileNameField); optionsPanel.addComponent(operatorAnalaysisCheck); operatorAnalaysisCheck.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { options.operatorAnalysis = operatorAnalaysisCheck.isSelected(); updateOtherFileNames(options); frame.setDirty(); } }); operatorAnalaysisFileNameField.setColumns(32); operatorAnalaysisFileNameField.setEditable(false); operatorAnalaysisFileNameField.setEnabled(false); optionsPanel.addComponentWithLabel( "Operator analysis file name:", operatorAnalaysisFileNameField); optionsPanel.addSeparator(); optionsPanel.addComponent(samplePriorCheckBox); samplePriorCheckBox.setOpaque(false); samplePriorCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { frame.setDirty(); } }); // logFileNameField.addKeyListener(listener); // treeFileNameField.addKeyListener(listener); // mapTreeFileNameField.addKeyListener(listener); // substTreeFileNameField.addKeyListener(listener); // optionsPanel.setPreferredSize(new java.awt.Dimension(500, 600)); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); panel.add(optionsPanel, BorderLayout.CENTER); panel.setOpaque(false); JScrollPane scrollPane = new JScrollPane( panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setOpaque(false); scrollPane.setBorder(null); scrollPane.getViewport().setOpaque(false); add(scrollPane, BorderLayout.CENTER); }
public BeastDialog(final JFrame frame, final String titleString, final Icon icon) { this.frame = frame; optionPanel = new OptionsPanel(12, 12); // this.frame = frame; JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); final OptionsPanel optionPanel3 = new OptionsPanel(0, 3); final JLabel titleIcon = new JLabel(); titleIcon.setIcon(icon); final JLabel titleText = new JLabel(titleString); optionPanel3.addComponent(titleText); // final JButton aboutButton = new JButton("About BEAST..."); // //aboutButton.setAction(); // optionPanel3.addComponent(aboutButton); optionPanel.addComponents(titleIcon, optionPanel3); final JButton inputFileButton = new JButton("Choose File..."); final JTextField inputFileNameText = new JTextField("not selected", 16); inputFileButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { FileDialog dialog = new FileDialog(frame, "Select target file...", FileDialog.LOAD); dialog.setVisible(true); if (dialog.getFile() == null) { // the dialog was cancelled... return; } inputFile = new File(dialog.getDirectory(), dialog.getFile()); inputFileNameText.setText(inputFile.getName()); } }); inputFileNameText.setEditable(false); JPanel panel1 = new JPanel(new BorderLayout(0, 0)); panel1.add(inputFileNameText, BorderLayout.CENTER); panel1.add(inputFileButton, BorderLayout.EAST); inputFileNameText.setToolTipText( "<html>Drag a BEAST XML file here or use the button to<br>" + "select one from a file dialog box.</html>"); inputFileButton.setToolTipText( "<html>Drag a BEAST XML file here or use the button to<br>" + "select one from a file dialog box.</html>"); optionPanel.addComponentWithLabel("BEAST XML File: ", panel1); Color focusColor = UIManager.getColor("Focus.color"); Border focusBorder = BorderFactory.createMatteBorder(2, 2, 2, 2, focusColor); new FileDrop( null, inputFileNameText, focusBorder, new FileDrop.Listener() { public void filesDropped(java.io.File[] files) { inputFile = files[0]; inputFileNameText.setText(inputFile.getName()); } // end filesDropped }); // end FileDrop.Listener overwriteCheckBox.setToolTipText( "<html>Specify whether BEAST will overwrite existing log files<br>" + "with the same name.</html>"); optionPanel.addComponent(overwriteCheckBox); optionPanel.addSeparator(); seedText.setColumns(12); seedText.setToolTipText( "<html>Specify a particular random number seed to replicate<br>" + "precisely the sequence of steps in the MCMC chain. By<br>" + "default this uses system information to provide a new<br>" + "seed each run.</html>"); optionPanel.addComponentWithLabel("Random number seed: ", seedText); threadsCombo.setToolTipText( "<html>Specify how large a thread pool to use.<br>" + "In most circumstances this should be set to 'automatic'<br>" + "but in some circumstances it may be desirable to restict<br>" + "the number of cores being used. 0 will turn off threading</html>"); optionPanel.addComponentWithLabel("Thread pool size: ", threadsCombo); optionPanel.addSeparator(); optionPanel.addSpanningComponent(beagleCheckBox); beagleCheckBox.setSelected(true); final OptionsPanel optionPanel1 = new OptionsPanel(0, 6); // optionPanel1.setBorder(BorderFactory.createEmptyBorder()); optionPanel1.setBorder(new TitledBorder("")); OptionsPanel optionPanel2 = new OptionsPanel(0, 3); optionPanel2.setBorder(BorderFactory.createEmptyBorder()); final JLabel label1 = optionPanel2.addComponentWithLabel("Prefer use of: ", beagleResourceCombo); optionPanel2.addComponent(beagleSSECheckBox); beagleSSECheckBox.setSelected(true); final JLabel label2 = optionPanel2.addComponentWithLabel("Prefer precision: ", beaglePrecisionCombo); final JLabel label3 = optionPanel2.addComponentWithLabel("Rescaling scheme: ", beagleScalingCombo); optionPanel2.addComponent(beagleInfoCheckBox); optionPanel2.setBorder(BorderFactory.createEmptyBorder()); optionPanel1.addComponent(optionPanel2); final JEditorPane beagleInfo = new JEditorPane( "text/html", "<html><div style=\"font-family:'helvetica neue light',helvetica,sans-serif;font-size:12;\"><p>BEAGLE is a high-performance phylogenetic library that can make use of<br>" + "additional computational resources such as graphics boards. It must be<br>" + "downloaded and installed independently of BEAST:</p>" + "<pre><a href=\"http://beagle-lib.googlecode.com/\">http://beagle-lib.googlecode.com/</a></pre></div>"); beagleInfo.setOpaque(false); beagleInfo.setEditable(false); beagleInfo.addHyperlinkListener(new SimpleLinkListener()); optionPanel1.addComponent(beagleInfo); optionPanel1.setBorder(BorderFactory.createEmptyBorder()); optionPanel.addSpanningComponent(optionPanel1); beagleInfoCheckBox.setEnabled(false); beagleCheckBox.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { beagleInfo.setEnabled(beagleCheckBox.isSelected()); beagleInfoCheckBox.setEnabled(beagleCheckBox.isSelected()); label1.setEnabled(beagleCheckBox.isSelected()); beagleResourceCombo.setEnabled(beagleCheckBox.isSelected()); beagleSSECheckBox.setEnabled(beagleCheckBox.isSelected()); label2.setEnabled(beagleCheckBox.isSelected()); beaglePrecisionCombo.setEnabled(beagleCheckBox.isSelected()); label3.setEnabled(beagleCheckBox.isSelected()); beagleScalingCombo.setEnabled(beagleCheckBox.isSelected()); } }); beagleCheckBox.setSelected(false); beagleResourceCombo.setSelectedItem("CPU"); }