List of usage examples for javax.swing ButtonGroup ButtonGroup
public ButtonGroup()
ButtonGroup
. From source file:lejos.pc.charting.LogChartFrame.java
/** All the setup of components, etc. What's scary is Swing is a "lightweight" GUI framework... * @throws Exception/* w w w . j a v a2 s . c o m*/ */ private void jbInit() throws Exception { this.setJMenuBar(menuBar); this.setSize(new Dimension(819, 613)); this.setMinimumSize(new Dimension(819, 613)); this.setTitle("NXT Charting Logger"); this.setEnabled(true); // enforce minimum window size this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { JFrame theFrame = (JFrame) e.getSource(); Dimension d1 = theFrame.getMinimumSize(); Dimension d2 = theFrame.getSize(); boolean enforce = false; if (theFrame.getWidth() < d1.getWidth()) { d2.setSize(d1.getWidth(), d2.getHeight()); enforce = true; } if (theFrame.getHeight() < d1.getHeight()) { d2.setSize(d2.getWidth(), d1.getHeight()); enforce = true; } if (enforce) theFrame.setSize(d2); } }); this.getContentPane().setLayout(gridBagLayout1); MenuActionListener menuItemActionListener = new MenuActionListener(); MenuEventListener menuListener = new MenuEventListener(); menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); menuBar.add(menu); menuItem = new JMenuItem("Copy Chart Image", KeyEvent.VK_I); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Copy Data Log", KeyEvent.VK_D); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.setActionCommand("VIEW_MENU"); menu.addMenuListener(menuListener); menuBar.add(menu); menuItem = new JMenuItem("Expand Chart", KeyEvent.VK_F); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Chart in New Window", KeyEvent.VK_N); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem("Chart controls", KeyEvent.VK_C); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Generate sample data", KeyEvent.VK_G); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.addActionListener(menuItemActionListener); jTabbedPane1.setPreferredSize(new Dimension(621, 199)); jTabbedPane1.setMinimumSize(new Dimension(621, 199)); menu.add(menuItem); jButtonConnect.setText("Connect"); jButtonConnect.setBounds(new Rectangle(25, 65, 115, 25)); jButtonConnect.setToolTipText("Connect/disconnect toggle"); jButtonConnect.setMnemonic('C'); jButtonConnect.setSelected(true); jButtonConnect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButtonConnect_actionPerformed(e); } }); UIPanel.setSize(new Dimension(820, 200)); UIPanel.setLayout(null); UIPanel.setPreferredSize(new Dimension(300, 200)); UIPanel.setMinimumSize(new Dimension(300, 200)); UIPanel.setBounds(new Rectangle(0, 350, 820, 200)); UIPanel.setMaximumSize(new Dimension(300, 32767)); connectionPanel.setBounds(new Rectangle(10, 10, 175, 100)); connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection")); connectionPanel.setLayout(null); connectionPanel.setFont(new Font("Tahoma", 0, 11)); jLabel1logfilename.setText("Log File:"); jLabel1logfilename.setBounds(new Rectangle(10, 125, 165, 20)); jLabel1logfilename.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel1logfilename.setHorizontalAlignment(SwingConstants.LEFT); jLabel1logfilename.setToolTipText("Specify the name of your log file here"); jTextFieldNXTName.setBounds(new Rectangle(5, 40, 165, 20)); jTextFieldNXTName.setToolTipText( "The name or Address of the NXT. Leave empty and the first one found will be used."); jTextFieldNXTName.requestFocus(); jTextAreaStatus.setLineWrap(true); jTextAreaStatus.setFont(new Font("Tahoma", 0, 11)); jTextAreaStatus.setWrapStyleWord(true); jTextAreaStatus.setBackground(SystemColor.window); dataLogTextArea.setLineWrap(false); dataLogTextArea.setFont(new Font("Tahoma", 0, 11)); dataLogTextArea.setBackground(SystemColor.window); FQPathTextArea.setBounds(new Rectangle(5, 170, 185, 40)); FQPathTextArea.setLineWrap(true); FQPathTextArea.setText(getCanonicalName(new File(".", ""))); FQPathTextArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); FQPathTextArea.setRows(2); FQPathTextArea.setFont(new Font("Tahoma", 0, 9)); FQPathTextArea.setOpaque(false); FQPathTextArea.setEditable(false); selectFolderButton.setText("Folder..."); selectFolderButton.setBounds(new Rectangle(120, 125, 70, 20)); selectFolderButton.setMargin(new Insets(1, 1, 1, 1)); selectFolderButton.setFocusable(false); selectFolderButton.setMnemonic('F'); selectFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectFolderButton_actionPerformed(e); } }); // domain display limits GUI chartOptionsPanel.setLayout(null); chartDomLimitsPanel.setBounds(new Rectangle(5, 35, 180, 135)); chartDomLimitsPanel.setLayout(gridLayout1); chartDomLimitsPanel.setBorder(BorderFactory.createTitledBorder("Domain Display Limiting")); domainDisplayLimitSlider.setEnabled(false); domainDisplayLimitSlider.setMaximum(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.setMinimum(MINDOMAIN_LIMIT); domainDisplayLimitSlider.setValue(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { domainDisplayLimitSlider_stateChanged(e); } }); useTimeRadioButton.setText("By Time"); useTimeRadioButton.setEnabled(false); useTimeRadioButton.setMnemonic('I'); useTimeRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); useDataPointsRadioButton.setText("By Data Points"); ButtonGroup bg1 = new ButtonGroup(); bg1.add(useTimeRadioButton); bg1.add(useDataPointsRadioButton); useDataPointsRadioButton.setSelected(true); useDataPointsRadioButton.setEnabled(false); useDataPointsRadioButton.setMnemonic('P'); useDataPointsRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); datasetLimitEnableCheckBox.setText("Enable"); datasetLimitEnableCheckBox.setRolloverEnabled(true); datasetLimitEnableCheckBox.setMnemonic('A'); datasetLimitEnableCheckBox.setToolTipText("Enable Domain Clipping"); datasetLimitEnableCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { datasetLimitEnableCheckBox_actionPerformed(e); } }); domainLimitLabel.setText(String.format("%1$,d datapoints", MAXDOMAIN_DATAPOINT_LIMIT).toString()); domainLimitLabel.setEnabled(false); gridLayout1.setRows(5); gridLayout1.setColumns(1); jLabel1.setText("Chart Title:"); jLabel1.setBounds(new Rectangle(200, 10, 85, 20)); jLabel1.setPreferredSize(new Dimension(115, 14)); jLabel2.setText("Range Axis 1 Label:"); jLabel2.setBounds(new Rectangle(200, 35, 115, 20)); jLabel2.setSize(new Dimension(115, 20)); jLabel3.setText("Range Axis 2 Label:"); jLabel3.setBounds(new Rectangle(200, 60, 115, 20)); jLabel3.setSize(new Dimension(115, 20)); jLabel4.setText("Range Axis 3 Label:"); jLabel4.setBounds(new Rectangle(200, 85, 115, 20)); jLabel4.setSize(new Dimension(115, 20)); jLabel6.setText("Range Axis 4 Label:"); jLabel6.setBounds(new Rectangle(200, 110, 115, 20)); jLabel6.setSize(new Dimension(115, 20)); titleLabelChangeNotifier notifier = new titleLabelChangeNotifier(); chartTitleTextField.setBounds(new Rectangle(315, 10, 290, 20)); chartTitleTextField.getDocument().addDocumentListener(notifier); axis1LabelTextField.setBounds(new Rectangle(315, 35, 290, 20)); axis1LabelTextField.getDocument().addDocumentListener(notifier); axis2LabelTextField.setBounds(new Rectangle(315, 60, 290, 20)); axis2LabelTextField.getDocument().addDocumentListener(notifier); axis3LabelTextField.setBounds(new Rectangle(315, 85, 290, 20)); axis3LabelTextField.getDocument().addDocumentListener(notifier); axis4LabelTextField.setBounds(new Rectangle(315, 110, 290, 20)); showCommentsCheckBox.setText("Show Comment Markers"); showCommentsCheckBox.setBounds(new Rectangle(200, 140, 185, 25)); showCommentsCheckBox.setToolTipText("Show/Hide any comment markers on the chart"); showCommentsCheckBox.setRolloverEnabled(true); showCommentsCheckBox.setSelected(true); showCommentsCheckBox.setMnemonic('M'); showCommentsCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { customChartPanel.setCommentsVisible(e.getStateChange() == ItemEvent.SELECTED); } }); scrollDomainCheckBox.setText("Scroll Domain"); scrollDomainCheckBox.setBounds(new Rectangle(10, 5, 175, 20)); scrollDomainCheckBox.setSize(new Dimension(175, 25)); scrollDomainCheckBox.setSelected(true); scrollDomainCheckBox.setMnemonic('O'); scrollDomainCheckBox.setToolTipText("Checked to scroll domain as new data is received"); scrollDomainCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scrollDomainCheckBox_actionPerformed(e); } }); axis4LabelTextField.getDocument().addDocumentListener(notifier); logFileTextField.setBounds(new Rectangle(10, 145, 180, 20)); logFileTextField.setText("NXTData.txt"); logFileTextField.setPreferredSize(new Dimension(180, 20)); logFileTextField.setToolTipText("File name. Leave empty to not log to file."); statusScrollPane.setOpaque(false); dataLogScrollPane.setOpaque(false); customChartPanel.setMinimumSize(new Dimension(400, 300)); customChartPanel.setPreferredSize(new Dimension(812, 400)); jLabel5.setText("NXT Name/Address:"); jLabel5.setBounds(new Rectangle(5, 20, 160, 20)); jLabel5.setToolTipText(jTextFieldNXTName.getToolTipText()); jLabel5.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); connectionPanel.add(jTextFieldNXTName, null); connectionPanel.add(jButtonConnect, null); connectionPanel.add(jLabel5, null); dataLogScrollPane.setViewportView(dataLogTextArea); jTabbedPane1.addTab("Data Log", dataLogScrollPane); statusScrollPane.setViewportView(jTextAreaStatus); jTabbedPane1.addTab("Status", statusScrollPane); jTabbedPane1.addTab("Chart", chartOptionsPanel); chartDomLimitsPanel.add(datasetLimitEnableCheckBox, null); chartDomLimitsPanel.add(useDataPointsRadioButton, null); chartDomLimitsPanel.add(useTimeRadioButton, null); chartDomLimitsPanel.add(domainDisplayLimitSlider, null); chartDomLimitsPanel.add(domainLimitLabel, null); chartOptionsPanel.add(scrollDomainCheckBox, null); chartOptionsPanel.add(showCommentsCheckBox, null); chartOptionsPanel.add(axis4LabelTextField, null); chartOptionsPanel.add(axis3LabelTextField, null); chartOptionsPanel.add(axis2LabelTextField, null); chartOptionsPanel.add(axis1LabelTextField, null); chartOptionsPanel.add(chartTitleTextField, null); chartOptionsPanel.add(jLabel6, null); chartOptionsPanel.add(jLabel4, null); chartOptionsPanel.add(jLabel3, null); chartOptionsPanel.add(jLabel2, null); chartOptionsPanel.add(jLabel1, null); chartOptionsPanel.add(chartDomLimitsPanel, null); tglbtnpauseplay = new JToggleButton(""); tglbtnpauseplay.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (lpm == null) return; boolean doPause = false; if (e.getStateChange() == ItemEvent.SELECTED) { doPause = true; } lpm.setReaderPaused(doPause); } }); // tglbtnpauseplay.addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent e) { // System.out.println(e.toString()); // //lpm.setReaderPaused(doPause) // } // }); tglbtnpauseplay .setSelectedIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/play.png"))); tglbtnpauseplay.setIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/pause.png"))); tglbtnpauseplay.setBounds(571, 135, 30, 30); chartOptionsPanel.add(tglbtnpauseplay); jTabbedPane1.setToolTipTextAt(0, "The tab-delimited log of the data sent from the NXT"); jTabbedPane1.setToolTipTextAt(1, "Status output"); jTabbedPane1.setToolTipTextAt(2, "Chart options"); jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_D); jTabbedPane1.setMnemonicAt(1, KeyEvent.VK_S); jTabbedPane1.setMnemonicAt(2, KeyEvent.VK_T); this.getContentPane().add(customChartPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.getContentPane().add(UIPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -107, 0)); this.getContentPane().add(jTabbedPane1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); UIPanel.add(connectionPanel, null); UIPanel.add(selectFolderButton, null); UIPanel.add(logFileTextField, null); UIPanel.add(jLabel1logfilename, null); UIPanel.add(FQPathTextArea, null); ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { String theData = null; for (;;) { theData = LogChartFrame.this.logDataQueue.poll(); if (theData == null) break; try { dataLogTextArea.getDocument().insertString(dataLogTextArea.getDocument().getLength(), theData, null); } catch (BadLocationException e) { System.out.print( "BadLocationException in datalog textarea updater thread:" + e.toString() + "\n"); } } } }; this.updateLogTextAreaTimer = new Timer(1000, taskPerformer); this.updateLogTextAreaTimer.start(); }
From source file:org.pf.midea.MainUI.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents menuMain = new JMenuBar(); menuFile = new JMenu(); menuItemQuit = new JMenuItem(); menuTools = new JMenu(); menuConstellations = new JMenu(); menuItemASK = new JMenuItem(); menuItemFSK = new JMenuItem(); menuItemBPSK = new JMenuItem(); menuItemQPSK = new JMenuItem(); menuItem8PSK = new JMenuItem(); menuItem16PSK = new JMenuItem(); menuItem32PSK = new JMenuItem(); menuItem16QAM = new JMenuItem(); menuItem32QAM = new JMenuItem(); menuItem64QAM = new JMenuItem(); menuItem256QAM = new JMenuItem(); menuHelp = new JMenu(); menuItemAbout = new JMenuItem(); labelSource = new JLabel(); SourceCell[] sourceCells = { new SourceCell(PlanStates.SourceType.ST_TEST), new SourceCell(PlanStates.SourceType.ST_RANDOM) }; chooserSource = new JComboBox(sourceCells); chooserSource.setRenderer(new SourceCellRenderer()); buttonAddToPlan = new JButton(); panelPlan = new JPanel(); scrollPane1 = new JScrollPane(); listPlan = new JList(); labelCode = new JLabel(); CodeCell[] codeCells = { new CodeCell(PlanStates.CodeType.CT_NONE), new CodeCell(PlanStates.CodeType.CT_HAMMING74), new CodeCell(PlanStates.CodeType.CT_CYCLIC), new CodeCell(PlanStates.CodeType.CT_BCH155) }; chooserCode = new JComboBox(codeCells); chooserCode.setRenderer(new CodeCellRenderer()); labelModulation = new JLabel(); ModulationCell[] modulationCells = { new ModulationCell(PlanStates.ModulationType.MT_ASK), new ModulationCell(PlanStates.ModulationType.MT_FSK), new ModulationCell(PlanStates.ModulationType.MT_BPSK), new ModulationCell(PlanStates.ModulationType.MT_QPSK), new ModulationCell(PlanStates.ModulationType.MT_8PSK), new ModulationCell(PlanStates.ModulationType.MT_16PSK), new ModulationCell(PlanStates.ModulationType.MT_32PSK), new ModulationCell(PlanStates.ModulationType.MT_16QAM), new ModulationCell(PlanStates.ModulationType.MT_32QAM), new ModulationCell(PlanStates.ModulationType.MT_64QAM), new ModulationCell(PlanStates.ModulationType.MT_256QAM) }; chooserModulation = new JComboBox(modulationCells); chooserModulation.setRenderer(new ModulationCellRenderer()); labelChannel = new JLabel(); ChannelCell[] channelCells = { new ChannelCell(PlanStates.ChannelType.CHT_AWGN), new ChannelCell(PlanStates.ChannelType.CHT_RAYLEIGH) }; chooserChannel = new JComboBox(channelCells); chooserChannel.setRenderer(new ChannelCellRenderer()); buttonClearPlan = new JButton(); labelErrors = new JLabel(); ErrorsCell[] errorCells = { new ErrorsCell(PlanStates.ErrorsType.ET_SER), new ErrorsCell(PlanStates.ErrorsType.ET_BER) }; chooserErrors = new JComboBox(errorCells); chooserErrors.setRenderer(new ErrorsCellRenderer()); labelLineWidth = new JLabel(); spinnerLineWidth = new JSpinner(); buttonRemoveFromPlan = new JButton(); labelLineColor = new JLabel(); ColorCell[] colorCells = { new ColorCell(null), new ColorCell(Color.black), new ColorCell(Color.red), new ColorCell(Color.green), new ColorCell(Color.blue) }; chooserLineColor = new JComboBox(colorCells); chooserLineColor.setRenderer(new ColorCellRenderer()); labelHSquare = new JLabel(); spinnerHSquareLow = new JSpinner(); labelEllipsis = new JLabel(); spinnerHSquareHigh = new JSpinner(); panelInner1 = new JPanel(); labelHSquareStep = new JLabel(); spinnerHSquareStep = new JSpinner(); labelMeasurementUnit = new JLabel(); radioButtonMeasurementUnitTimes = new JRadioButton(); radioButtonMeasurementUnitdB = new JRadioButton(); buttonRunSimulation = new JButton(); labelIterations = new JLabel(); spinnerIterations = new JSpinner(); checkBoxShowLineNumbers = new JCheckBox(); tabbedPaneResults = new JTabbedPane(); panelChart = new JPanel(); panelNumeric = new JPanel(); scrollPane2 = new JScrollPane(); textAreaNumeric = new JTextArea(); progressBar = new JProgressBar(); //======== this ======== setLayout(new FormLayout("3*(default, $lcgap), 36dlu, $lcgap, 122dlu:grow", "[21px,default], 9*($lgap, default), $lgap, default:grow, $lgap, default")); //======== menuMain ======== {/*www.j av a 2s . c o m*/ //======== menuFile ======== { menuFile.setText("\u0424\u0430\u0439\u043b"); //---- menuItemQuit ---- menuItemQuit.setText("\u0412\u0438\u0439\u0442\u0438"); menuItemQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK)); menuItemQuit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemQuitActionPerformed(e); } }); menuFile.add(menuItemQuit); } menuMain.add(menuFile); //======== menuTools ======== { menuTools.setText("\u0406\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438"); //======== menuConstellations ======== { menuConstellations.setText( "\u0421\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u0456 \u0441\u0443\u0437\u0456\u0440\u2019\u044f"); //---- menuItemASK ---- menuItemASK.setText("\u0410\u041c\u043d\u2026"); menuItemASK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemASKActionPerformed(e); } }); menuConstellations.add(menuItemASK); //---- menuItemFSK ---- menuItemFSK.setText("\u0427\u041c\u043d\u2026"); menuItemFSK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemFSKActionPerformed(e); } }); menuConstellations.add(menuItemFSK); //---- menuItemBPSK ---- menuItemBPSK.setText("\u0424\u041c\u043d\u2026"); menuItemBPSK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemBPSKActionPerformed(e); } }); menuConstellations.add(menuItemBPSK); //---- menuItemQPSK ---- menuItemQPSK.setText("\u0424\u041c-4\u2026"); menuItemQPSK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemQPSKActionPerformed(e); } }); menuConstellations.add(menuItemQPSK); //---- menuItem8PSK ---- menuItem8PSK.setText("\u0424\u041c-8\u2026"); menuItem8PSK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem8PSKActionPerformed(e); } }); menuConstellations.add(menuItem8PSK); //---- menuItem16PSK ---- menuItem16PSK.setText("\u0424\u041c-16\u2026"); menuItem16PSK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem16PSKActionPerformed(e); } }); menuConstellations.add(menuItem16PSK); //---- menuItem32PSK ---- menuItem32PSK.setText("\u0424\u041c-32\u2026"); menuItem32PSK.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem32PSKActionPerformed(e); } }); menuConstellations.add(menuItem32PSK); //---- menuItem16QAM ---- menuItem16QAM.setText("\u041a\u0410\u041c-16\u2026"); menuItem16QAM.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem16QAMActionPerformed(e); } }); menuConstellations.add(menuItem16QAM); //---- menuItem32QAM ---- menuItem32QAM.setText("\u041a\u0410\u041c-32\u2026"); menuItem32QAM.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem32QAMActionPerformed(e); } }); menuConstellations.add(menuItem32QAM); //---- menuItem64QAM ---- menuItem64QAM.setText("\u041a\u0410\u041c-64\u2026"); menuItem64QAM.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem64QAMActionPerformed(e); } }); menuConstellations.add(menuItem64QAM); //---- menuItem256QAM ---- menuItem256QAM.setText("\u041a\u0410\u041c-256\u2026"); menuItem256QAM.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItem256QAMActionPerformed(e); } }); menuConstellations.add(menuItem256QAM); } menuTools.add(menuConstellations); } menuMain.add(menuTools); //======== menuHelp ======== { menuHelp.setText("\u0414\u043e\u0432\u0456\u0434\u043a\u0430"); //---- menuItemAbout ---- menuItemAbout.setText("\u041f\u0440\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0443\u2026"); menuItemAbout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { menuItemAboutActionPerformed(e); } }); menuHelp.add(menuItemAbout); } menuMain.add(menuHelp); } add(menuMain, CC.xywh(1, 1, 9, 1, CC.FILL, CC.FILL)); //---- labelSource ---- labelSource.setText("\u0414\u0436\u0435\u0440\u0435\u043b\u043e:"); add(labelSource, CC.xy(1, 3)); add(chooserSource, CC.xy(3, 3)); //---- buttonAddToPlan ---- buttonAddToPlan.setText("\u2192"); buttonAddToPlan.setToolTipText( "\u0414\u043e\u0434\u0430\u0442\u0438 \u0434\u043e \u043f\u043b\u0430\u043d\u0443 \u0435\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443"); buttonAddToPlan.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buttonAddToPlanActionPerformed(e); } }); add(buttonAddToPlan, CC.xywh(5, 3, 1, 5)); //======== panelPlan ======== { panelPlan.setLayout(new GridLayout()); //======== scrollPane1 ======== { scrollPane1.setViewportView(listPlan); } panelPlan.add(scrollPane1); } add(panelPlan, CC.xywh(7, 3, 3, 13)); //---- labelCode ---- labelCode.setText("\u041a\u043e\u0434:"); add(labelCode, CC.xy(1, 5)); add(chooserCode, CC.xy(3, 5)); //---- labelModulation ---- labelModulation.setText("\u041c\u043e\u0434\u0443\u043b\u044f\u0446\u0456\u044f:"); add(labelModulation, CC.xy(1, 7)); add(chooserModulation, CC.xy(3, 7)); //---- labelChannel ---- labelChannel.setText("\u041a\u0430\u043d\u0430\u043b:"); add(labelChannel, CC.xy(1, 9)); add(chooserChannel, CC.xy(3, 9)); //---- buttonClearPlan ---- buttonClearPlan.setText("X"); buttonClearPlan.setToolTipText( "\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u0438 \u043f\u043b\u0430\u043d \u0435\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443"); buttonClearPlan.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buttonClearPlanActionPerformed(e); } }); add(buttonClearPlan, CC.xy(5, 9)); //---- labelErrors ---- labelErrors.setText("\u041f\u043e\u043c\u0438\u043b\u043a\u0438:"); add(labelErrors, CC.xy(1, 11)); add(chooserErrors, CC.xy(3, 11)); //---- labelLineWidth ---- labelLineWidth.setText("\u0422\u043e\u0432\u0449\u0438\u043d\u0430 \u043b\u0456\u043d\u0456\u0457:"); add(labelLineWidth, CC.xy(1, 13)); //---- spinnerLineWidth ---- spinnerLineWidth.setModel(new SpinnerNumberModel(2, 1, 5, 1)); add(spinnerLineWidth, CC.xy(3, 13)); //---- buttonRemoveFromPlan ---- buttonRemoveFromPlan.setText("\u2190"); buttonRemoveFromPlan.setToolTipText( "\u0412\u0438\u0434\u0430\u043b\u0438\u0442\u0438 \u0437 \u043f\u043b\u0430\u043d\u0443 \u0435\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443"); buttonRemoveFromPlan.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buttonRemoveFromPlanActionPerformed(e); } }); add(buttonRemoveFromPlan, CC.xywh(5, 11, 1, 5)); //---- labelLineColor ---- labelLineColor.setText("\u041a\u043e\u043b\u0456\u0440 \u043b\u0456\u043d\u0456\u0457:"); add(labelLineColor, CC.xy(1, 15)); add(chooserLineColor, CC.xy(3, 15)); //---- labelHSquare ---- labelHSquare.setText("h\u00b2="); add(labelHSquare, CC.xy(1, 17)); //---- spinnerHSquareLow ---- spinnerHSquareLow.setModel(new SpinnerNumberModel(0.0, null, null, 1.0)); add(spinnerHSquareLow, CC.xy(3, 17)); //---- labelEllipsis ---- labelEllipsis.setText("\u2026"); add(labelEllipsis, CC.xy(5, 17, CC.CENTER, CC.DEFAULT)); //---- spinnerHSquareHigh ---- spinnerHSquareHigh.setModel(new SpinnerNumberModel(15.0, null, null, 1.0)); add(spinnerHSquareHigh, CC.xy(7, 17)); //======== panelInner1 ======== { panelInner1.setLayout(new FormLayout("5*(default, $lcgap), default:grow", "default")); //---- labelHSquareStep ---- labelHSquareStep.setText(", \u043a\u0440\u043e\u043a:"); panelInner1.add(labelHSquareStep, CC.xy(1, 1)); //---- spinnerHSquareStep ---- spinnerHSquareStep.setModel(new SpinnerNumberModel(0.5, 0.001, null, 0.1)); panelInner1.add(spinnerHSquareStep, CC.xy(3, 1)); //---- labelMeasurementUnit ---- labelMeasurementUnit.setText(", \u043e\u0434\u0438\u043d\u0438\u0446\u0456:"); panelInner1.add(labelMeasurementUnit, CC.xy(5, 1)); //---- radioButtonMeasurementUnitTimes ---- radioButtonMeasurementUnitTimes.setText("\u0440\u0430\u0437\u0438"); radioButtonMeasurementUnitTimes.setSelected(true); panelInner1.add(radioButtonMeasurementUnitTimes, CC.xy(7, 1, CC.LEFT, CC.DEFAULT)); //---- radioButtonMeasurementUnitdB ---- radioButtonMeasurementUnitdB.setText("\u0434\u0411"); panelInner1.add(radioButtonMeasurementUnitdB, CC.xy(9, 1, CC.LEFT, CC.DEFAULT)); //---- buttonRunSimulation ---- buttonRunSimulation.setText("\u0412\u0438\u043a\u043e\u043d\u0430\u0442\u0438"); buttonRunSimulation.setToolTipText( "\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u044e\u0432\u0430\u043d\u043d\u044f"); buttonRunSimulation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buttonRunSimulationActionPerformed(e); } }); panelInner1.add(buttonRunSimulation, CC.xy(11, 1, CC.RIGHT, CC.DEFAULT)); } add(panelInner1, CC.xy(9, 17)); //---- labelIterations ---- labelIterations.setText("\u0406\u0442\u0435\u0440\u0430\u0446\u0456\u0439:"); add(labelIterations, CC.xy(1, 19)); //---- spinnerIterations ---- spinnerIterations.setModel(new SpinnerNumberModel(200000, 1, null, 50000)); add(spinnerIterations, CC.xy(3, 19)); //---- checkBoxShowLineNumbers ---- checkBoxShowLineNumbers.setText( "\u041d\u0443\u043c\u0435\u0440\u0443\u0432\u0430\u0442\u0438 \u0433\u0440\u0430\u0444\u0456\u043a\u0438"); add(checkBoxShowLineNumbers, CC.xywh(7, 19, 3, 1)); //======== tabbedPaneResults ======== { //======== panelChart ======== { panelChart.setLayout(new BoxLayout(panelChart, BoxLayout.X_AXIS)); } tabbedPaneResults.addTab("\u0413\u0440\u0430\u0444\u0456\u043a\u0438", panelChart); //======== panelNumeric ======== { panelNumeric.setLayout(new FormLayout("default:grow", "default:grow")); //======== scrollPane2 ======== { //---- textAreaNumeric ---- textAreaNumeric.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); textAreaNumeric.setEditable(false); scrollPane2.setViewportView(textAreaNumeric); } panelNumeric.add(scrollPane2, CC.xy(1, 1, CC.DEFAULT, CC.FILL)); } tabbedPaneResults.addTab("\u0427\u0438\u0441\u043b\u043e\u0432\u0456 \u0434\u0430\u043d\u0456", panelNumeric); } add(tabbedPaneResults, CC.xywh(1, 21, 9, 1, CC.DEFAULT, CC.FILL)); add(progressBar, CC.xywh(1, 23, 9, 1)); //---- buttonGroupMeasurementUnit ---- ButtonGroup buttonGroupMeasurementUnit = new ButtonGroup(); buttonGroupMeasurementUnit.add(radioButtonMeasurementUnitTimes); buttonGroupMeasurementUnit.add(radioButtonMeasurementUnitdB); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:net.sf.jabref.openoffice.OpenOfficePanel.java
private void showSettingsPopup() { JPopupMenu menu = new JPopupMenu(); final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem( Localization.lang("Automatically sync bibliography when inserting citations"), Globals.prefs.getBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING)); final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in the active tab only")); final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in all open databases")); final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings")); ButtonGroup bg = new ButtonGroup(); bg.add(useActiveBase);/*from w w w . j a v a2 s.com*/ bg.add(useAllBases); if (Globals.prefs.getBoolean(JabRefPreferences.USE_ALL_OPEN_BASES)) { useAllBases.setSelected(true); } else { useActiveBase.setSelected(true); } autoSync.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING, autoSync.isSelected())); useAllBases.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, useAllBases.isSelected())); useActiveBase.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, !useActiveBase.isSelected())); clearConnectionSettings.addActionListener(e -> { Globals.prefs.clear(JabRefPreferences.OO_PATH); Globals.prefs.clear(JabRefPreferences.OO_EXECUTABLE_PATH); Globals.prefs.clear(JabRefPreferences.OO_JARS_PATH); frame.output(Localization.lang("Cleared connection settings.")); }); menu.add(autoSync); menu.addSeparator(); menu.add(useActiveBase); menu.add(useAllBases); menu.addSeparator(); menu.add(clearConnectionSettings); menu.show(settingsB, 0, settingsB.getHeight()); }
From source file:de.bwravencl.controllerbuddy.gui.Main.java
private Main() { Singleton.start(this, SINGLETON_ID); frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { @Override/*from w w w . j a v a 2 s. c o m*/ public void windowClosing(final WindowEvent e) { super.windowClosing(e); if (showMenuItem != null) showMenuItem.setEnabled(true); } @Override public void windowDeiconified(final WindowEvent e) { super.windowDeiconified(e); if (showMenuItem != null) showMenuItem.setEnabled(false); } @Override public void windowIconified(final WindowEvent e) { super.windowIconified(e); if (showMenuItem != null) showMenuItem.setEnabled(true); } @Override public void windowOpened(final WindowEvent e) { super.windowOpened(e); if (showMenuItem != null) showMenuItem.setEnabled(false); } }); frame.setBounds(DIALOG_BOUNDS_X, DIALOG_BOUNDS_Y, DIALOG_BOUNDS_WIDTH, DIALOG_BOUNDS_HEIGHT); frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); final var icons = new ArrayList<Image>(); for (final var path : ICON_RESOURCE_PATHS) { final var icon = new ImageIcon(Main.class.getResource(path)); icons.add(icon.getImage()); } frame.setIconImages(icons); frame.setJMenuBar(menuBar); menuBar.add(fileMenu); final QuitAction quitAction = new QuitAction(); fileMenu.add(quitAction); menuBar.add(deviceMenu); if (windows) { menuBar.add(localMenu, 2); final var buttonGroupLocalState = new ButtonGroup(); startLocalRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("START_MENU_ITEM")); startLocalRadioButtonMenuItem.setAction(new StartLocalAction()); buttonGroupLocalState.add(startLocalRadioButtonMenuItem); localMenu.add(startLocalRadioButtonMenuItem); stopLocalRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("STOP_MENU_ITEM")); stopLocalRadioButtonMenuItem.setAction(new StopLocalAction()); buttonGroupLocalState.add(stopLocalRadioButtonMenuItem); localMenu.add(stopLocalRadioButtonMenuItem); menuBar.add(clientMenu); final var buttonGroupClientState = new ButtonGroup(); startClientRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("START_MENU_ITEM")); startClientRadioButtonMenuItem.setAction(new StartClientAction()); buttonGroupClientState.add(startClientRadioButtonMenuItem); clientMenu.add(startClientRadioButtonMenuItem); stopClientRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("STOP_MENU_ITEM")); stopClientRadioButtonMenuItem.setAction(new StopClientAction()); buttonGroupClientState.add(stopClientRadioButtonMenuItem); clientMenu.add(stopClientRadioButtonMenuItem); } final var buttonGroupServerState = new ButtonGroup(); startServerRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("START_MENU_ITEM")); startServerRadioButtonMenuItem.setAction(new StartServerAction()); buttonGroupServerState.add(startServerRadioButtonMenuItem); serverMenu.add(startServerRadioButtonMenuItem); stopServerRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("STOP_MENU_ITEM")); stopServerRadioButtonMenuItem.setAction(new StopServerAction()); buttonGroupServerState.add(stopServerRadioButtonMenuItem); serverMenu.add(stopServerRadioButtonMenuItem); final var helpMenu = new JMenu(rb.getString("HELP_MENU")); menuBar.add(helpMenu); helpMenu.add(new ShowAboutDialogAction()); frame.getContentPane().add(tabbedPane); settingsPanel = new JPanel(); settingsPanel.setLayout(new GridBagLayout()); settingsScrollPane.setViewportView(settingsPanel); tabbedPane.addTab(rb.getString("SETTINGS_TAB"), null, settingsScrollPane); final var panelGridBagConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 5); final var panelFlowLayout = new FlowLayout(FlowLayout.LEADING, 10, 10); final var pollIntervalPanel = new JPanel(panelFlowLayout); settingsPanel.add(pollIntervalPanel, panelGridBagConstraints); final var pollIntervalLabel = new JLabel(rb.getString("POLL_INTERVAL_LABEL")); pollIntervalLabel.setPreferredSize(new Dimension(120, 15)); pollIntervalPanel.add(pollIntervalLabel); final var pollIntervalSpinner = new JSpinner(new SpinnerNumberModel( preferences.getInt(PREFERENCES_POLL_INTERVAL, OutputThread.DEFAULT_POLL_INTERVAL), 10, 500, 1)); final JSpinner.DefaultEditor pollIntervalSpinnerEditor = new JSpinner.NumberEditor(pollIntervalSpinner, "#"); ((DefaultFormatter) pollIntervalSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true); pollIntervalSpinner.setEditor(pollIntervalSpinnerEditor); pollIntervalSpinner.addChangeListener( e -> preferences.putInt(PREFERENCES_POLL_INTERVAL, (int) ((JSpinner) e.getSource()).getValue())); pollIntervalPanel.add(pollIntervalSpinner); if (windows) { final var vJoyDirectoryPanel = new JPanel(panelFlowLayout); settingsPanel.add(vJoyDirectoryPanel, panelGridBagConstraints); final var vJoyDirectoryLabel = new JLabel(rb.getString("VJOY_DIRECTORY_LABEL")); vJoyDirectoryLabel.setPreferredSize(new Dimension(120, 15)); vJoyDirectoryPanel.add(vJoyDirectoryLabel); vJoyDirectoryLabel1 = new JLabel( preferences.get(PREFERENCES_VJOY_DIRECTORY, VJoyOutputThread.getDefaultInstallationPath())); vJoyDirectoryPanel.add(vJoyDirectoryLabel1); final var vJoyDirectoryButton = new JButton(new ChangeVJoyDirectoryAction()); vJoyDirectoryPanel.add(vJoyDirectoryButton); final var vJoyDevicePanel = new JPanel(panelFlowLayout); settingsPanel.add(vJoyDevicePanel, panelGridBagConstraints); final var vJoyDeviceLabel = new JLabel(rb.getString("VJOY_DEVICE_LABEL")); vJoyDeviceLabel.setPreferredSize(new Dimension(120, 15)); vJoyDevicePanel.add(vJoyDeviceLabel); final var vJoyDeviceSpinner = new JSpinner(new SpinnerNumberModel( preferences.getInt(PREFERENCES_VJOY_DEVICE, VJoyOutputThread.DEFAULT_VJOY_DEVICE), 1, 16, 1)); final JSpinner.DefaultEditor vJoyDeviceSpinnerEditor = new JSpinner.NumberEditor(vJoyDeviceSpinner, "#"); ((DefaultFormatter) vJoyDeviceSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true); vJoyDeviceSpinner.setEditor(vJoyDeviceSpinnerEditor); vJoyDeviceSpinner.addChangeListener( e -> preferences.putInt(PREFERENCES_VJOY_DEVICE, (int) ((JSpinner) e.getSource()).getValue())); vJoyDevicePanel.add(vJoyDeviceSpinner); final var hostPanel = new JPanel(panelFlowLayout); settingsPanel.add(hostPanel, panelGridBagConstraints); final var hostLabel = new JLabel(rb.getString("HOST_LABEL")); hostLabel.setPreferredSize(new Dimension(120, 15)); hostPanel.add(hostLabel); hostTextField = new JTextField(preferences.get(PREFERENCES_HOST, ClientVJoyOutputThread.DEFAULT_HOST), 10); final var setHostAction = new SetHostAction(hostTextField); hostTextField.addActionListener(setHostAction); hostTextField.addFocusListener(setHostAction); hostPanel.add(hostTextField); } final var portPanel = new JPanel(panelFlowLayout); settingsPanel.add(portPanel, panelGridBagConstraints); final var portLabel = new JLabel(rb.getString("PORT_LABEL")); portLabel.setPreferredSize(new Dimension(120, 15)); portPanel.add(portLabel); final var portSpinner = new JSpinner(new SpinnerNumberModel( preferences.getInt(PREFERENCES_PORT, ServerOutputThread.DEFAULT_PORT), 1024, 65535, 1)); final JSpinner.DefaultEditor portSpinnerEditor = new JSpinner.NumberEditor(portSpinner, "#"); ((DefaultFormatter) portSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true); portSpinner.setEditor(portSpinnerEditor); portSpinner.addChangeListener( e -> preferences.putInt(PREFERENCES_PORT, (int) ((JSpinner) e.getSource()).getValue())); portPanel.add(portSpinner); final var timeoutPanel = new JPanel(panelFlowLayout); settingsPanel.add(timeoutPanel, panelGridBagConstraints); final var timeoutLabel = new JLabel(rb.getString("TIMEOUT_LABEL")); timeoutLabel.setPreferredSize(new Dimension(120, 15)); timeoutPanel.add(timeoutLabel); final var timeoutSpinner = new JSpinner(new SpinnerNumberModel( preferences.getInt(PREFERENCES_TIMEOUT, ServerOutputThread.DEFAULT_TIMEOUT), 10, 60000, 1)); final JSpinner.DefaultEditor timeoutSpinnerEditor = new JSpinner.NumberEditor(timeoutSpinner, "#"); ((DefaultFormatter) timeoutSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true); timeoutSpinner.setEditor(timeoutSpinnerEditor); timeoutSpinner.addChangeListener( e -> preferences.putInt(PREFERENCES_TIMEOUT, (int) ((JSpinner) e.getSource()).getValue())); timeoutPanel.add(timeoutSpinner); final var alwaysOnTopSupported = Toolkit.getDefaultToolkit().isAlwaysOnTopSupported(); if (alwaysOnTopSupported || preferences.getBoolean(PREFERENCES_SHOW_OVERLAY, alwaysOnTopSupported)) { final var overlaySettingsPanel = new JPanel(panelFlowLayout); settingsPanel.add(overlaySettingsPanel, panelGridBagConstraints); final var overlayLabel = new JLabel(rb.getString("OVERLAY_LABEL")); overlayLabel.setPreferredSize(new Dimension(120, 15)); overlaySettingsPanel.add(overlayLabel); final var showOverlayCheckBox = new JCheckBox(rb.getString("SHOW_OVERLAY_CHECK_BOX")); showOverlayCheckBox.setSelected(preferences.getBoolean(PREFERENCES_SHOW_OVERLAY, true)); showOverlayCheckBox.addActionListener(e -> { final boolean showOverlay = ((JCheckBox) e.getSource()).isSelected(); preferences.putBoolean(PREFERENCES_SHOW_OVERLAY, showOverlay); }); overlaySettingsPanel.add(showOverlayCheckBox); } if (windows) { if (preferences.getBoolean(PREFERENCES_SHOW_VR_OVERLAY, true)) { final var vrOverlaySettingsPanel = new JPanel(panelFlowLayout); settingsPanel.add(vrOverlaySettingsPanel, panelGridBagConstraints); final var vrOverlayLabel = new JLabel(rb.getString("VR_OVERLAY_LABEL")); vrOverlayLabel.setPreferredSize(new Dimension(120, 15)); vrOverlaySettingsPanel.add(vrOverlayLabel); final var showVrOverlayCheckBox = new JCheckBox(rb.getString("SHOW_VR_OVERLAY_CHECK_BOX")); showVrOverlayCheckBox.setSelected(preferences.getBoolean(PREFERENCES_SHOW_VR_OVERLAY, true)); showVrOverlayCheckBox.addActionListener(e -> { final var showVrOverlay = ((JCheckBox) e.getSource()).isSelected(); preferences.putBoolean(PREFERENCES_SHOW_VR_OVERLAY, showVrOverlay); }); vrOverlaySettingsPanel.add(showVrOverlayCheckBox); } final var preventPowerSaveModeSettingsPanel = new JPanel(panelFlowLayout); settingsPanel.add(preventPowerSaveModeSettingsPanel, panelGridBagConstraints); final var preventPowerSaveModeLabel = new JLabel(rb.getString("POWER_SAVE_MODE_LABEL")); preventPowerSaveModeLabel.setPreferredSize(new Dimension(120, 15)); preventPowerSaveModeSettingsPanel.add(preventPowerSaveModeLabel); final var preventPowerSaveModeCheckBox = new JCheckBox( rb.getString("PREVENT_POWER_SAVE_MODE_CHECK_BOX")); preventPowerSaveModeCheckBox .setSelected(preferences.getBoolean(PREFERENCES_PREVENT_POWER_SAVE_MODE, true)); preventPowerSaveModeCheckBox.addActionListener(e -> { final var preventPowerSaveMode = ((JCheckBox) e.getSource()).isSelected(); preferences.putBoolean(PREFERENCES_PREVENT_POWER_SAVE_MODE, preventPowerSaveMode); }); preventPowerSaveModeSettingsPanel.add(preventPowerSaveModeCheckBox); } if (SystemTray.isSupported()) { final var popupMenu = new PopupMenu(); final var showAction = new ShowAction(); showMenuItem = new MenuItem((String) showAction.getValue(Action.NAME)); showMenuItem.addActionListener(showAction); popupMenu.add(showMenuItem); popupMenu.addSeparator(); final var openMenuItem = new MenuItem((String) openAction.getValue(Action.NAME)); openMenuItem.addActionListener(openAction); popupMenu.add(openMenuItem); popupMenu.addSeparator(); final var quitMenuItem = new MenuItem((String) quitAction.getValue(Action.NAME)); quitMenuItem.addActionListener(quitAction); popupMenu.add(quitMenuItem); trayIcon = new TrayIcon(frame.getIconImage()); trayIcon.addActionListener(showAction); trayIcon.setPopupMenu(popupMenu); try { SystemTray.getSystemTray().add(trayIcon); } catch (final AWTException e) { log.log(Logger.Level.ERROR, e.getMessage(), e); } } updateTitleAndTooltip(); settingsPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); final var outsideBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); final var insideBorder = BorderFactory.createEmptyBorder(0, 5, 0, 5); statusLabel.setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder)); frame.add(statusLabel, BorderLayout.SOUTH); final var glfwInitialized = glfwInit(); if (!glfwInitialized) if (windows) JOptionPane.showMessageDialog(frame, rb.getString("COULD_NOT_INITIALIZE_GLFW_DIALOG_TEXT_WINDOWS"), rb.getString("ERROR_DIALOG_TITLE"), JOptionPane.ERROR_MESSAGE); else { JOptionPane.showMessageDialog(frame, rb.getString("COULD_NOT_INITIALIZE_GLFW_DIALOG_TEXT"), rb.getString("ERROR_DIALOG_TITLE"), JOptionPane.ERROR_MESSAGE); quit(); } final var presentJids = new HashSet<Integer>(); for (var jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++) if (glfwJoystickPresent(jid) && glfwJoystickIsGamepad(jid)) presentJids.add(jid); final var lastControllerGuid = preferences.get(PREFERENCES_LAST_CONTROLLER, null); for (final var jid : presentJids) { final var lastControllerFound = lastControllerGuid != null ? lastControllerGuid.equals(glfwGetJoystickGUID(jid)) : false; if (!isSelectedJidValid() || lastControllerFound) selectedJid = jid; if (lastControllerFound) break; } newProfile(); onControllersChanged(true); glfwSetJoystickCallback(new GLFWJoystickCallback() { @Override public void invoke(final int jid, final int event) { final var disconnected = event == GLFW_DISCONNECTED; if (disconnected || glfwJoystickIsGamepad(jid)) { if (disconnected && selectedJid == jid) selectedJid = INVALID_JID; invokeOnEventDispatchThreadIfRequired(() -> onControllersChanged(false)); } } }); if (glfwInitialized && presentJids.isEmpty()) { if (windows) JOptionPane.showMessageDialog(frame, rb.getString("NO_CONTROLLER_CONNECTED_DIALOG_TEXT_WINDOWS"), rb.getString("INFORMATION_DIALOG_TITLE"), JOptionPane.INFORMATION_MESSAGE); else JOptionPane.showMessageDialog(frame, rb.getString("NO_CONTROLLER_CONNECTED_DIALOG_TEXT"), rb.getString("INFORMATION_DIALOG_TITLE"), JOptionPane.INFORMATION_MESSAGE); } else { final String path = preferences.get(PREFERENCES_LAST_PROFILE, null); if (path != null) loadProfile(new File(path)); } }
From source file:it.isislab.dmason.tools.batch.BatchWizard.java
/** * Create the frame.//from ww w.jav a 2 s.com */ public BatchWizard() { setPreferredSize(new Dimension(800, 600)); setTitle("Batch wizard"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 849, 620); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new GridLayout(1, 0, 0, 0)); JPanel panel = new JPanel(); panel.setToolTipText(""); contentPane.add(panel); panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Param Option", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); JPanel panel_2 = new JPanel(); panel_2.setBorder( new TitledBorder(null, "Params List", TitledBorder.LEADING, TitledBorder.TOP, null, null)); JPanel panel_3 = new JPanel(); JPanel panel_4 = new JPanel(); GroupLayout gl_panel = new GroupLayout(panel); gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGroup(gl_panel .createSequentialGroup().addContainerGap() .addComponent( panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel.createSequentialGroup() .addComponent(panel_4, GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE).addGap(20)) .addGroup(gl_panel.createSequentialGroup() .addComponent(panel_2, GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE).addGap(4)))) .addComponent(panel_3, GroupLayout.DEFAULT_SIZE, 823, Short.MAX_VALUE)); gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.TRAILING).addGroup(gl_panel .createSequentialGroup() .addComponent(panel_3, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel.createSequentialGroup() .addComponent(panel_2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(25) .addComponent(panel_4, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)) .addComponent(panel_1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); final JButton btnSave = new JButton("Save"); btnSave.setEnabled(false); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { File saveFile = SaveFileChooser(); createXML(saveFile.getAbsoluteFile().getPath()); } }); lblTotTests = new JLabel(totTestsMessage); GroupLayout gl_panel_4 = new GroupLayout(panel_4); gl_panel_4.setHorizontalGroup(gl_panel_4.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_4.createSequentialGroup().addGap(21).addComponent(lblTotTests) .addPreferredGap(ComponentPlacement.RELATED, 515, Short.MAX_VALUE).addComponent(btnSave) .addGap(21))); gl_panel_4.setVerticalGroup(gl_panel_4.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_4.createSequentialGroup().addContainerGap() .addGroup(gl_panel_4.createParallelGroup(Alignment.BASELINE).addComponent(btnSave) .addComponent(lblTotTests)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_4.setLayout(gl_panel_4); top = new DefaultMutableTreeNode("Parameters"); JScrollPane scrollPaneTree = new JScrollPane(); JLabel lblNumberOfWorkers = new JLabel("Number of Workers:"); textFieldNumberOfWorkers = new JTextField(); textFieldNumberOfWorkers.setText("1"); textFieldNumberOfWorkers.setColumns(10); textFieldNumberOfWorkers.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { if (textFieldNumberOfWorkers.isVisible()) { boolean checkNumberOfWorkers = true; while (checkNumberOfWorkers) { String dist = textFieldNumberOfWorkers.getText(); boolean validateDist = dist.matches("(\\d)+"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldNumberOfWorkers.setText(newDist); } else { checkNumberOfWorkers = false; } } } } }); checkBoxLoadBalancing = new JCheckBox("Load Balancing", false); checkBoxLoadBalancing.setEnabled(true); GroupLayout gl_panel_2 = new GroupLayout(panel_2); gl_panel_2.setHorizontalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_2 .createSequentialGroup().addContainerGap() .addGroup(gl_panel_2.createParallelGroup(Alignment.LEADING) .addComponent(scrollPaneTree, GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE) .addGroup(gl_panel_2.createSequentialGroup().addComponent(lblNumberOfWorkers) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(textFieldNumberOfWorkers, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)) .addComponent(checkBoxLoadBalancing, GroupLayout.PREFERRED_SIZE, 114, GroupLayout.PREFERRED_SIZE)) .addContainerGap())); gl_panel_2.setVerticalGroup(gl_panel_2.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_2 .createSequentialGroup().addContainerGap() .addComponent(scrollPaneTree, GroupLayout.PREFERRED_SIZE, 271, GroupLayout.PREFERRED_SIZE) .addGap(33) .addGroup(gl_panel_2.createParallelGroup(Alignment.BASELINE).addComponent(lblNumberOfWorkers) .addComponent(textFieldNumberOfWorkers, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(checkBoxLoadBalancing, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) .addContainerGap(56, Short.MAX_VALUE))); final JTree treeParams = new JTree(top); scrollPaneTree.setViewportView(treeParams); treeParams.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent selected) { // DefaultMutableTreeNode parent = // selected.getPath().getParentPath() DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeParams.getLastSelectedPathComponent(); if (node.getParent() != null) { if (node.getParent() == simParams || node.getParent().equals(generalParams)) { selectedParam = (Param) node.getUserObject(); if (node.getParent() == simParams) { selectedParamIndex = simParams.getIndex(node); paramType = "simParam"; } else { selectedParamIndex = generalParams.getIndex(node); paramType = "generalParam"; } if (selectedParam instanceof ParamFixed) { ParamFixed pf = (ParamFixed) selectedParam; lblParamType.setText(pf.getName() + ": " + pf.getType()); if (suggestion.get(pf.getName()) != null) { lblDomain.setText("Domain: " + suggestion.get(pf.getName()).getDomain()); lblSuggested.setText( "Suggested Value: " + suggestion.get(pf.getName()).getSuggestedValue()); } textFieldRuns.setText("" + pf.getRuns()); textFieldValue.setText(pf.getValue()); rdbtnFixed.doClick(); lblMessage.setVisible(false); setModifyControlEnable(true); } if (selectedParam instanceof ParamRange) { ParamRange pf = (ParamRange) selectedParam; lblParamType.setText(pf.getName() + ": " + pf.getType()); if (suggestion.get(pf.getName()) != null) { lblDomain.setText("Domain: " + suggestion.get(pf.getName()).getDomain()); lblSuggested.setText( "Suggested Value: " + suggestion.get(pf.getName()).getSuggestedValue()); } textFieldRuns.setText("" + pf.getRuns()); textFieldStartValue.setText(pf.getStart()); textFieldEndValue.setText(pf.getEnd()); textFieldIncrement.setText(pf.getIncrement()); rdbtnRange.doClick(); lblMessage.setVisible(false); setModifyControlEnable(true); } if (selectedParam instanceof ParamList) { ParamList pl = (ParamList) selectedParam; if (suggestion.get(pl.getName()) != null) { lblDomain.setText("Domain: " + suggestion.get(pl.getName()).getDomain()); lblSuggested.setText( "Suggested Value: " + suggestion.get(pl.getName()).getSuggestedValue()); } lblParamType.setText(pl.getName() + ": " + pl.getType()); textFieldRuns.setText("" + pl.getRuns()); StringBuilder b = new StringBuilder(); boolean isFirst = true; for (String element : pl.getValues()) { if (isFirst) { b.append(element); isFirst = false; } else b.append("," + element); } textFieldList.setText(b.toString()); rdbtnByvalues.doClick(); setListControlvisibility(true); lblMessage.setVisible(false); setModifyControlEnable(true); } if (selectedParam instanceof ParamDistribution) { DistributionType distType = DistributionType.none; if (selectedParam instanceof ParamDistributionUniform) { ParamDistributionUniform pu = (ParamDistributionUniform) selectedParam; lblParamType.setText(pu.getName() + ": " + pu.getType()); if (suggestion.get(pu.getName()) != null) { lblDomain.setText("Domain: " + suggestion.get(pu.getName()).getDomain()); lblSuggested.setText( "Suggested Value: " + suggestion.get(pu.getName()).getSuggestedValue()); } textFieldRuns.setText("" + pu.getRuns()); textFieldA.setText(pu.getA()); textFieldB.setText(pu.getB()); textFieldNumberOfValues.setText("" + pu.getNumberOfValues()); distType = DistributionType.uniform; } if (selectedParam instanceof ParamDistributionExponential) { ParamDistributionExponential pe = (ParamDistributionExponential) selectedParam; lblParamType.setText(pe.getName() + ": " + pe.getType()); if (suggestion.get(pe.getName()) != null) { lblDomain.setText("Domain: " + suggestion.get(pe.getName()).getDomain()); lblSuggested.setText( "Suggested Value: " + suggestion.get(pe.getName()).getSuggestedValue()); } textFieldRuns.setText("" + pe.getRuns()); textFieldA.setText(pe.getLambda()); textFieldNumberOfValues.setText("" + pe.getNumberOfValues()); distType = DistributionType.exponential; } if (selectedParam instanceof ParamDistributionNormal) { ParamDistributionNormal pn = (ParamDistributionNormal) selectedParam; lblParamType.setText(pn.getName() + ": " + pn.getType()); if (suggestion.get(pn.getName()) != null) { lblDomain.setText("Domain: " + suggestion.get(pn.getName()).getDomain()); lblSuggested.setText( "Suggested Value: " + suggestion.get(pn.getName()).getSuggestedValue()); } textFieldRuns.setText("" + pn.getRuns()); textFieldA.setText(pn.getMean()); textFieldB.setText(pn.getStdDev()); textFieldNumberOfValues.setText("" + pn.getNumberOfValues()); distType = DistributionType.normal; } rdbtnByDistribution.doClick(); setDistributionControlVisibility(distType); setDistributionComboBoxVisibility(true); lblMessage.setVisible(false); setModifyControlEnable(true); } } } } }); panel_2.setLayout(gl_panel_2); JLabel lblSelectSimulationJar = new JLabel("Select simulation jar:"); textFieldSimJarPath = new JTextField(); textFieldSimJarPath.setColumns(10); btnLoadParams = new JButton("Load Params"); btnLoadParams.setEnabled(false); btnLoadParams.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ArrayList<Param> params = loadParams(); if (params != null) { top.removeAllChildren(); createNodes(top, params); treeParams.expandPath(new TreePath(top.getPath())); treeParams.expandPath(new TreePath(simParams.getPath())); treeParams.expandPath(new TreePath(generalParams.getPath())); } lblTotTests.setText(totTestsMessage + " " + getTotTests()); btnSave.setEnabled(true); } }); JButton bntChooseSimulation = new JButton(); bntChooseSimulation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { simulationFile = showFileChooser(); if (simulationFile != null) { textFieldSimJarPath.setText(simulationFile.getAbsolutePath()); btnLoadParams.setEnabled(true); isThin = isThinSimulation(simulationFile); checkBoxLoadBalancing.setEnabled(!isThin); } } }); bntChooseSimulation.setIcon( new ImageIcon(BatchWizard.class.getResource("/it.isislab.dmason/resource/image/openFolder.png"))); GroupLayout gl_panel_3 = new GroupLayout(panel_3); gl_panel_3.setHorizontalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_3 .createSequentialGroup().addContainerGap().addComponent(lblSelectSimulationJar) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(textFieldSimJarPath, GroupLayout.PREFERRED_SIZE, 250, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(bntChooseSimulation, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) .addGap(26).addComponent(btnLoadParams).addContainerGap(172, Short.MAX_VALUE))); gl_panel_3.setVerticalGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_3 .createSequentialGroup().addContainerGap() .addGroup(gl_panel_3.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_3 .createParallelGroup(Alignment.BASELINE).addComponent(lblSelectSimulationJar) .addComponent(textFieldSimJarPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(bntChooseSimulation, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) .addComponent(btnLoadParams)) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_3.setLayout(gl_panel_3); lblParamType = new JLabel("Param : type"); lblParamType.setFont(new Font("Tahoma", Font.BOLD, 11)); JLabel lblRuns = new JLabel("Runs:"); textFieldRuns = new JTextField(); textFieldRuns.setColumns(10); textFieldRuns.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { if (textFieldRuns.isVisible()) { boolean checkRuns = true; while (checkRuns) { String dist = textFieldRuns.getText(); boolean validateDist = dist.matches("(\\d)+"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldRuns.setText(newDist); } else { checkRuns = false; } } } } }); JLabel lblParameterSpace = new JLabel("Parameter Space"); lblParameterSpace.setFont(new Font("Tahoma", Font.BOLD, 11)); lblValue = new JLabel("Value:"); textFieldValue = new JTextField(); textFieldValue.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldValue.isVisible()) { boolean checkValue = true; while (checkValue) { String dist = textFieldValue.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldValue.setText(newDist); } else { checkValue = false; } } } } }); textFieldValue.setColumns(10); /*textFieldValue.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent arg0) {} @Override public void keyReleased(KeyEvent arg0) { checkError(); } @Override public void keyPressed(KeyEvent arg0) {} }); */ lblStartValue = new JLabel("Start value:"); textFieldStartValue = new JTextField(); textFieldStartValue.setText("1"); textFieldStartValue.setColumns(10); textFieldStartValue.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldStartValue.isVisible()) { boolean checkStartValue = true; while (checkStartValue) { String dist = textFieldStartValue.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldStartValue.setText(newDist); } else { checkStartValue = false; } } } } }); lblEndValue = new JLabel("End value:"); textFieldEndValue = new JTextField(); textFieldEndValue.setText("1"); textFieldEndValue.setColumns(10); textFieldEndValue.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldEndValue.isVisible()) { boolean checkEndValue = true; while (checkEndValue) { String dist = textFieldEndValue.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldEndValue.setText(newDist); } else { checkEndValue = false; } } } } }); lblIncrement = new JLabel("Increment:"); textFieldIncrement = new JTextField(); textFieldIncrement.setText("1"); textFieldIncrement.setColumns(10); textFieldIncrement.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldIncrement.isVisible()) { boolean checkIncrement = true; while (checkIncrement) { String dist = textFieldIncrement.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldIncrement.setText(newDist); } else { checkIncrement = false; } } } } }); rdbtnFixed = new JRadioButton("Fixed"); rdbtnFixed.setSelected(true); rdbtnFixed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setListControlvisibility(false); setDistributionComboBoxVisibility(false); setRangeControlVisibility(false); setFixedControlVisibility(true); setDistributionControlVisibility(DistributionType.none); } }); rdbtnRange = new JRadioButton("Range"); rdbtnRange.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRangeControlVisibility(true); setFixedControlVisibility(false); setListControlvisibility(false); setDistributionComboBoxVisibility(false); setDistributionControlVisibility(DistributionType.none); } }); rdbtnByvalues = new JRadioButton("By Values"); rdbtnByvalues.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRangeControlVisibility(false); setFixedControlVisibility(false); setListControlvisibility(true); setDistributionComboBoxVisibility(false); setDistributionControlVisibility(DistributionType.none); } }); rdbtnByDistribution = new JRadioButton("By Distribution"); rdbtnByDistribution.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRangeControlVisibility(false); setFixedControlVisibility(false); setListControlvisibility(false); setDistributionComboBoxVisibility(true); setDistributionControlVisibility(DistributionType.none); } }); // Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(rdbtnFixed); group.add(rdbtnRange); group.add(rdbtnByvalues); group.add(rdbtnByDistribution); setRangeControlVisibility(false); setFixedControlVisibility(false); lblMessage = new JLabel(message); btnModify = new JButton("Modify"); btnModify.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (rdbtnFixed.isSelected()) { ParamFixed param = new ParamFixed(selectedParam.getName(), selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()), textFieldValue.getText()); DefaultMutableTreeNode p = new DefaultMutableTreeNode(param); if (paramType.equals("simParam")) { simParams.remove(selectedParamIndex); simParams.insert(p, selectedParamIndex); } else { generalParams.remove(selectedParamIndex); generalParams.insert(p, selectedParamIndex); } treeParams.updateUI(); /* * ((ParamFixed) * selectedParam).setValue(textFieldValue.getText()); * selectedParam * .setRuns(Integer.parseInt(textFieldRuns.getText())); * treeParams.repaint(); */ } if (rdbtnRange.isSelected()) { ParamRange param = new ParamRange(selectedParam.getName(), selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()), textFieldStartValue.getText(), textFieldEndValue.getText(), textFieldIncrement.getText()); DefaultMutableTreeNode p = new DefaultMutableTreeNode(param); if (paramType.equals("simParam")) { simParams.remove(selectedParamIndex); simParams.insert(p, selectedParamIndex); } else { generalParams.remove(selectedParamIndex); generalParams.insert(p, selectedParamIndex); } treeParams.updateUI(); // treeParams.repaint(); } if (rdbtnByvalues.isSelected()) { StringTokenizer st = new StringTokenizer(textFieldList.getText(), ","); ArrayList<String> values = new ArrayList<String>(); while (st.hasMoreTokens()) values.add(st.nextToken()); ParamList param = new ParamList(selectedParam.getName(), selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()), values); DefaultMutableTreeNode p = new DefaultMutableTreeNode(param); if (paramType.equals("simParam")) { simParams.remove(selectedParamIndex); simParams.insert(p, selectedParamIndex); } else { generalParams.remove(selectedParamIndex); generalParams.insert(p, selectedParamIndex); } treeParams.updateUI(); // treeParams.repaint(); } if (rdbtnByDistribution.isSelected()) { DefaultMutableTreeNode p; switch (selectedDistribution) { case uniform: p = new DefaultMutableTreeNode( new ParamDistributionUniform(selectedParam.getName(), selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()), textFieldA.getText(), textFieldB.getText(), Integer.parseInt(textFieldNumberOfValues.getText()))); break; case exponential: p = new DefaultMutableTreeNode(new ParamDistributionExponential(selectedParam.getName(), selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()), textFieldA.getText(), Integer.parseInt(textFieldNumberOfValues.getText()))); break; case normal: p = new DefaultMutableTreeNode( new ParamDistributionNormal(selectedParam.getName(), selectedParam.getType(), Integer.parseInt(textFieldRuns.getText()), textFieldA.getText(), textFieldA.getText(), Integer.parseInt(textFieldNumberOfValues.getText()))); break; default: p = new DefaultMutableTreeNode(); break; } if (paramType.equals("simParam")) { simParams.remove(selectedParamIndex); simParams.insert(p, selectedParamIndex); } else { generalParams.remove(selectedParamIndex); generalParams.insert(p, selectedParamIndex); } treeParams.updateUI(); // treeParams.repaint(); } lblMessage.setVisible(true); setModifyControlEnable(false); setDistributionControlVisibility(DistributionType.none); setDistributionComboBoxVisibility(false); setListControlvisibility(false); int tot = getTotTests(); if (tot >= testAlertThreshold) lblTotTests.setForeground(Color.RED); else lblTotTests.setForeground(Color.BLACK); lblTotTests.setText(totTestsMessage + " " + tot); } }); btnCancel = new JButton("Cancel"); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { lblMessage.setVisible(true); setModifyControlEnable(false); } }); lblCommaSeparatedList = new JLabel("List:"); lblCommaSeparatedList.setVisible(false); textFieldList = new JTextField(); textFieldList.setVisible(false); textFieldList.setToolTipText("Comma separated"); textFieldList.setColumns(10); textFieldList.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { /*if(textFieldList.isVisible()) { boolean checkList=true; while(checkList){ String dist=textFieldList.getText(); boolean validateDist=dist.matches("(\\d)+|((\\d)+\\.(\\d)+)(,(\\d)+|((\\d)+\\.(\\d)+))*"); if(!validateDist){ String newDist= JOptionPane.showInputDialog(null,"Insert comma separate number list","Number Format Error", 0); textFieldList.setText(newDist); } else{ checkList=false; } } }*/ } }); lblDistribution = new JLabel("Distribution"); lblDistribution.setVisible(false); lblA = new JLabel("a:"); lblA.setVisible(false); textFieldA = new JTextField(); textFieldA.setText("1"); textFieldA.setVisible(false); textFieldA.setColumns(10); textFieldA.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldA.isVisible()) { boolean checkA = true; while (checkA) { String dist = textFieldA.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldA.setText(newDist); } else { checkA = false; } } } } }); lblB = new JLabel("b:"); lblB.setVisible(false); textFieldB = new JTextField(); textFieldB.setText("1"); textFieldB.setVisible(false); textFieldB.setColumns(10); textFieldB.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { String regex = "(\\d)+|((\\d)+\\.(\\d)+)"; if (textFieldB.isVisible()) { boolean checkB = true; while (checkB) { String dist = textFieldB.getText(); boolean validateDist = dist.matches(regex); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldB.setText(newDist); } else { checkB = false; } } } } }); jComboBoxDistribution = new JComboBox(); jComboBoxDistribution.setVisible(false); jComboBoxDistribution.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // Prevent executing listener's actions two times if (e.getStateChange() != ItemEvent.SELECTED) return; selectedDistribution = ((DistributionType) jComboBoxDistribution.getSelectedItem()); setDistributionControlVisibility(DistributionType.none); setDistributionControlVisibility(selectedDistribution); } }); lblOfValues = new JLabel("# of values:"); lblOfValues.setVisible(false); textFieldNumberOfValues = new JTextField(); textFieldNumberOfValues.setText("1"); textFieldNumberOfValues.setVisible(false); textFieldNumberOfValues.setColumns(10); textFieldNumberOfValues.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent arg0) { if (textFieldNumberOfValues.isVisible()) { boolean checkNumberOfValues = true; while (checkNumberOfValues) { String dist = textFieldNumberOfValues.getText(); boolean validateDist = dist.matches("(\\d)+"); if (!validateDist) { String newDist = JOptionPane.showInputDialog(null, "Insert a number", "Number Format Error", 0); textFieldNumberOfValues.setText(newDist); } else { checkNumberOfValues = false; } } } } }); lblSuggested = new JLabel("Suggested Value:"); lblDomain = new JLabel("Domain:"); GroupLayout gl_panel_1 = new GroupLayout(panel_1); gl_panel_1.setHorizontalGroup(gl_panel_1.createParallelGroup(Alignment.TRAILING).addGroup(gl_panel_1 .createSequentialGroup().addContainerGap() .addGroup(gl_panel_1.createParallelGroup(Alignment.TRAILING).addGroup(gl_panel_1 .createSequentialGroup() .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING).addComponent(lblParamType) .addComponent(lblMessage).addComponent(lblSuggested)) .addContainerGap(77, Short.MAX_VALUE)) .addGroup(gl_panel_1.createSequentialGroup().addComponent(btnModify) .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnCancel) .addContainerGap()) .addGroup(gl_panel_1.createSequentialGroup().addGroup(gl_panel_1 .createParallelGroup(Alignment.LEADING).addComponent(lblParameterSpace) .addGroup(gl_panel_1.createSequentialGroup() .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING) .addComponent(rdbtnFixed).addComponent(rdbtnRange)) .addGap(31) .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING) .addComponent(rdbtnByDistribution).addComponent(rdbtnByvalues))) .addGroup(gl_panel_1.createSequentialGroup().addGroup(gl_panel_1 .createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblValue) .addPreferredGap(ComponentPlacement.RELATED, 59, Short.MAX_VALUE) .addComponent(textFieldValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(Alignment.LEADING, gl_panel_1.createSequentialGroup().addComponent(lblStartValue) .addPreferredGap(ComponentPlacement.RELATED, 46, Short.MAX_VALUE) .addComponent(textFieldStartValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_1.createSequentialGroup() .addComponent(lblCommaSeparatedList) .addPreferredGap(ComponentPlacement.RELATED, 69, Short.MAX_VALUE) .addComponent(textFieldList, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_1.createSequentialGroup() .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING) .addComponent(lblEndValue).addComponent(lblIncrement) .addComponent(lblDistribution)) .addGap(45) .addGroup(gl_panel_1.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING) .addGroup(gl_panel_1 .createParallelGroup(Alignment.LEADING, false) .addComponent(jComboBoxDistribution, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(textFieldA, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldB, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(textFieldNumberOfValues, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addComponent(textFieldIncrement, 89, 89, 89)) .addComponent(textFieldEndValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(ComponentPlacement.RELATED, 8, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblA).addPreferredGap( ComponentPlacement.RELATED, 173, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblB).addPreferredGap( ComponentPlacement.RELATED, 173, GroupLayout.PREFERRED_SIZE)) .addComponent(lblOfValues) .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblRuns) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(textFieldRuns, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, 65, GroupLayout.PREFERRED_SIZE))) .addGap(35)) .addGroup(gl_panel_1.createSequentialGroup().addComponent(lblDomain).addContainerGap(186, Short.MAX_VALUE))))); gl_panel_1.setVerticalGroup(gl_panel_1.createParallelGroup(Alignment.LEADING).addGroup(gl_panel_1 .createSequentialGroup().addGap(4).addComponent(lblMessage).addGap(18).addComponent(lblParamType) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblSuggested) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblDomain).addGap(7) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblRuns).addComponent( textFieldRuns, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblParameterSpace) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(rdbtnFixed) .addComponent(rdbtnByvalues)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(rdbtnRange) .addComponent(rdbtnByDistribution)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE) .addComponent(textFieldValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblValue)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE) .addComponent(textFieldList, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblCommaSeparatedList)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblStartValue) .addComponent(textFieldStartValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblEndValue).addComponent( textFieldEndValue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE) .addComponent(textFieldIncrement, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblIncrement)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE) .addComponent(jComboBoxDistribution, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(lblDistribution)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panel_1 .createParallelGroup(Alignment.BASELINE).addComponent(lblA).addComponent(textFieldA, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panel_1 .createParallelGroup(Alignment.BASELINE).addComponent(lblB).addComponent(textFieldB, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE).addComponent(lblOfValues).addComponent( textFieldNumberOfValues, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED, 18, Short.MAX_VALUE).addGroup(gl_panel_1 .createParallelGroup(Alignment.BASELINE).addComponent(btnModify).addComponent(btnCancel)))); panel_1.setLayout(gl_panel_1); panel.setLayout(gl_panel); setModifyControlEnable(false); loadDistribution(); }
From source file:net.sourceforge.entrainer.gui.EntrainerFX.java
private void addEspDevices(JMenu menu) { List<RawEspConnection> connections = EspConnectionRegister.getEspConnections(); ButtonGroup bg = new ButtonGroup(); connections.forEach(connection -> addEspDevice(menu, connection, bg)); }
From source file:MiGA.StatsSelection.java
public StatsSelection(final String[] organisms, final boolean flag) { setTitle("MiGA"); setSize(800, 600);/*from ww w .ja v a 2 s . c o m*/ setLocationRelativeTo(null); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Image im = Toolkit.getDefaultToolkit().getImage("ssr.png"); this.setIconImage(im); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } countmono = new ArrayList<Integer>(); countdi = new ArrayList<Integer>(); counttri = new ArrayList<Integer>(); counttetra = new ArrayList<Integer>(); countpenta = new ArrayList<Integer>(); counthexa = new ArrayList<Integer>(); countmonore = new ArrayList<Integer>(); countdire = new ArrayList<Integer>(); counttrire = new ArrayList<Integer>(); counttetrare = new ArrayList<Integer>(); countpentare = new ArrayList<Integer>(); counthexare = new ArrayList<Integer>(); Amono = new ArrayList<Integer>(); Tmono = new ArrayList<Integer>(); Gmono = new ArrayList<Integer>(); Cmono = new ArrayList<Integer>(); Adi = new ArrayList<Integer>(); Tdi = new ArrayList<Integer>(); Gdi = new ArrayList<Integer>(); Cdi = new ArrayList<Integer>(); Atri = new ArrayList<Integer>(); Ttri = new ArrayList<Integer>(); Gtri = new ArrayList<Integer>(); Ctri = new ArrayList<Integer>(); Atetra = new ArrayList<Integer>(); Ttetra = new ArrayList<Integer>(); Gtetra = new ArrayList<Integer>(); Ctetra = new ArrayList<Integer>(); Apenta = new ArrayList<Integer>(); Tpenta = new ArrayList<Integer>(); Gpenta = new ArrayList<Integer>(); Cpenta = new ArrayList<Integer>(); Ahexa = new ArrayList<Integer>(); Thexa = new ArrayList<Integer>(); Ghexa = new ArrayList<Integer>(); Chexa = new ArrayList<Integer>(); for (int i = 0; i < organisms.length; i++) { countmono.add(0); countdi.add(0); counttri.add(0); counttetra.add(0); countpenta.add(0); counthexa.add(0); countmonore.add(0); countdire.add(0); counttrire.add(0); counttetrare.add(0); countpentare.add(0); counthexare.add(0); Amono.add(0); Tmono.add(0); Gmono.add(0); Cmono.add(0); Adi.add(0); Tdi.add(0); Gdi.add(0); Cdi.add(0); Atri.add(0); Ttri.add(0); Gtri.add(0); Ctri.add(0); Atetra.add(0); Ttetra.add(0); Gtetra.add(0); Ctetra.add(0); Apenta.add(0); Tpenta.add(0); Gpenta.add(0); Cpenta.add(0); Ahexa.add(0); Thexa.add(0); Ghexa.add(0); Chexa.add(0); } lab = new JLabel( "<html><b><p>To retrieve the sequence you want</p><p>simply copy and paste in the fields below</p><p>the data you were given in your result's file</p></b></html>"); startlab = new JLabel("Start:"); endlab = new JLabel("End:"); titlelab = new JLabel("Chromosome or field:"); startnum = new JTextField(); startnum.setColumns(5); endnum = new JTextField(); endnum.setColumns(5); titlef = new JTextField(); titlef.setColumns(30); flankst = new JLabel("Flanking region before: "); flankst.setEnabled(false); flankst.setVisible(false); flankend = new JLabel("Flanking region after: "); flankend.setEnabled(false); flankend.setVisible(false); flankstn = new JTextField(); flankstn.setColumns(5); flankstn.setEnabled(false); flankstn.setVisible(false); flankendn = new JTextField(); flankendn.setColumns(5); flankendn.setEnabled(false); flankendn.setVisible(false); result = new JTextArea("", 6, 90); result.setText(" "); result.setEditable(false); result.setLineWrap(true); result.setAutoscrolls(true); sbrText = new JScrollPane(result); sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); flk = new JCheckBox("Flanking Regions"); flk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (flk.isSelected()) { flankst.setEnabled(true); flankst.setVisible(true); flankend.setEnabled(true); flankend.setVisible(true); flankstn.setEnabled(true); flankstn.setVisible(true); flankendn.setEnabled(true); flankendn.setVisible(true); } if (!flk.isSelected()) { flankst.setEnabled(false); flankst.setVisible(false); flankend.setEnabled(false); flankend.setVisible(false); flankstn.setEnabled(false); flankstn.setVisible(false); flankendn.setEnabled(false); flankendn.setVisible(false); } } }); retrieve = new JButton("Retrieve"); retrieve.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int start = 0; int end = 0; BufferedReader in = null; String location = ""; String newlocation = ""; String bufferpre = ""; String bufferpost = ""; String pre = ""; String post = ""; String mid = ""; try { String[] locationarray = titlef.getText().split("data/"); location = locationarray[0] + locationarray[1]; newlocation = ""; if (location.contains("local")) { in = new BufferedReader(new FileReader(location + ".txt")); } else if (location.contains("organisms")) { String[] loc = location.split("/"); try { if (CheckForKaryotype(loc[1])) { newlocation = loc[0] + "/" + loc[1] + "/chrom-" + loc[2] + "-slices.txt"; } else { newlocation = loc[0] + "/" + loc[1] + "/slice-" + loc[2] + ".txt"; } } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } in = new BufferedReader(new FileReader(newlocation)); } } catch (FileNotFoundException ex) { msg.showMessageDialog(paneldown, "Wrong field", "Error", JOptionPane.ERROR_MESSAGE); } int rest = Integer.parseInt(startnum.getText()) % 20000; int lines = Integer.parseInt(startnum.getText()) / 20000; lines++; String buffer1 = ""; for (int c = 0; c < lines; c++) { try { buffer1 = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } if (flk.isSelected()) { boolean tfs = false, tfe = false; int fs = 0, fe = 0; try { fs = Integer.parseInt(flankstn.getText()); tfs = true; } catch (NumberFormatException ex) { tfs = false; } try { fe = Integer.parseInt(flankendn.getText()); tfe = true; } catch (NumberFormatException ex) { tfe = false; } if (tfs && tfe) { start = rest - Integer.parseInt(flankstn.getText()); end = rest + Integer.parseInt(endnum.getText()) - Integer.parseInt(startnum.getText()) + Integer.parseInt(flankendn.getText()); try { in = new BufferedReader(new FileReader(newlocation)); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } if (start < 0 && lines == 1) { start = 0; } else if (start < 0 && lines > 1) { for (int j = 0; j < lines - 1; j++) { try { bufferpre = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } pre = bufferpre.substring(20000 + start); mid = buffer1.substring(0, end); try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } int cl = 0; try { cl = countlines(newlocation); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } try { in = new BufferedReader(new FileReader(newlocation)); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } if (end > 20000 && lines == cl - 1) { if (end - 20000 >= rest) { end = rest; mid = buffer1.substring(start); post = bufferpost; } else { for (int j = 0; j < lines - 1; j++) { try { bufferpost = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } mid = buffer1.substring(start); post = bufferpre.substring(0, end - 20000); try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } } else if (end > 20000 && lines < cl - 1) { for (int j = 0; j < lines + 1; j++) { try { bufferpost = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } mid = buffer1.substring(start); post = bufferpost.substring(0, end - 20000); try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } if (start >= 0 && (end <= 20000 || end <= rest)) { mid = buffer1.substring(start, end); } } else { if (!tfs) { msg.showMessageDialog(paneldown, "Flanking region start is empty.\nFill in the gap or uncheck the\nflanking regions checkbox", "Error", JOptionPane.ERROR_MESSAGE); } if (!tfe) { msg.showMessageDialog(paneldown, "Flanking region end is empty.\nFill in the gap or uncheck the\nflanking regions checkbox", "Error", JOptionPane.ERROR_MESSAGE); } } // } if (!flk.isSelected()) { start = rest; end = rest + Integer.parseInt(endnum.getText()) - Integer.parseInt(startnum.getText()); try { in = new BufferedReader(new FileReader(newlocation)); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } if (start < 0 && lines == 1) { start = 0; } else if (start < 0 && lines > 1) { for (int j = 0; j < lines - 1; j++) { try { bufferpre = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } pre = bufferpre.substring(start); mid = buffer1.substring(0, end); try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } int cl = 0; try { cl = countlines(newlocation); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } try { in = new BufferedReader(new FileReader(newlocation)); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } if (end > 20000 && lines == cl - 1) { if (end - 20000 >= rest) { end = rest; mid = buffer1.substring(start); post = bufferpost; } else { for (int j = 0; j < lines - 1; j++) { try { bufferpost = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } mid = buffer1.substring(start); post = bufferpre.substring(0, end - 20000); try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } } else if (end > 20000 && lines < cl - 1) { for (int j = 0; j < lines + 1; j++) { try { bufferpost = in.readLine(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } mid = buffer1.substring(start); post = bufferpost.substring(0, end - 20000); try { in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } if (start >= 0 && (end <= 20000 || end <= rest)) { mid = buffer1.substring(start, end); } } result.setText(pre + mid + post); } }); mono = new JCheckBox("Mononucleotide"); di = new JCheckBox("Dinucleotide"); tri = new JCheckBox("Trinucleotide"); tetra = new JCheckBox("Tetranucleotide"); penta = new JCheckBox("Pentanucleotide"); hexa = new JCheckBox("Hexanucleotide"); SSR = new ArrayList<String>(); repeats = new ArrayList<Integer>(); EndOfSsr = new ArrayList<Integer>(); start = new ArrayList<Integer>(); select = new JLabel("Select type: "); minimumssrlen = new JLabel("Minimum SSR length(bp)"); minimumssrlen.setVisible(false); score = new JTextField(); score.setColumns(5); score.setVisible(false); msg = new JOptionPane(); gapmax = new JLabel("Maximum Mismatch length for Imperfect SSRs(bp)"); gapmax.setVisible(false); max = new JTextField(); max.setColumns(5); max.setVisible(false); minlenpregap = new JLabel("Minimum SSR length before given Mismatch length(bp)"); minlenpregap.setVisible(false); minpregap = new JTextField(); minpregap.setColumns(5); minpregap.setVisible(false); gapcomp = new JLabel("Maximum Inter-repeat R for Compound SSRs(bp)"); gapcomp.setVisible(false); maxgapcomp = new JTextField(); maxgapcomp.setColumns(5); maxgapcomp.setVisible(false); box1 = new JCheckBox("Perfect"); box2 = new JCheckBox("Imperfect"); box3 = new JCheckBox("Compound"); com = new JCheckBox("Perfect Compound"); incom = new JCheckBox("Imperfect Compound"); box1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (box2.isSelected() || box3.isSelected()) { if (box1.isSelected()) { std.setEnabled(true); no_st.setEnabled(true); part_st.setEnabled(true); full_st.setEnabled(true); if (!box3.isSelected()) { minimumssrlen.setVisible(true); score.setVisible(true); } } if (!box1.isSelected()) { std.setEnabled(false); no_st.setEnabled(false); part_st.setEnabled(false); full_st.setEnabled(false); if (!box3.isSelected()) { minimumssrlen.setVisible(false); score.setVisible(false); } } } else { if (box1.isSelected()) { std.setEnabled(true); no_st.setEnabled(true); part_st.setEnabled(true); full_st.setEnabled(true); panel2.setVisible(true); minimumssrlen.setVisible(true); score.setVisible(true); } if (!box1.isSelected()) { std.setEnabled(false); no_st.setEnabled(false); part_st.setEnabled(false); full_st.setEnabled(false); panel2.setVisible(false); minimumssrlen.setVisible(false); score.setVisible(false); } } } }); box2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (box1.isSelected() || box3.isSelected()) { if (box2.isSelected()) { gapmax.setVisible(true); max.setVisible(true); minlenpregap.setVisible(true); minpregap.setVisible(true); } if (!box2.isSelected()) { gapmax.setVisible(false); max.setVisible(false); minlenpregap.setVisible(false); minpregap.setVisible(false); } } else { if (box2.isSelected()) { panel2.setVisible(true); gapmax.setVisible(true); max.setVisible(true); minlenpregap.setVisible(true); minpregap.setVisible(true); } if (!box2.isSelected()) { panel2.setVisible(false); gapmax.setVisible(false); max.setVisible(false); minlenpregap.setVisible(false); minpregap.setVisible(false); } } } }); box3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (box1.isSelected() || box2.isSelected()) { if (box3.isSelected()) { paneldownleft.setVisible(true); if (!box1.isSelected()) { minimumssrlen.setVisible(true); score.setVisible(true); } gapcomp.setVisible(true); maxgapcomp.setVisible(true); com.setVisible(true); incom.setVisible(true); } if (!box3.isSelected()) { paneldownleft.setVisible(false); gapcomp.setVisible(false); maxgapcomp.setVisible(false); if (!box1.isSelected()) { minimumssrlen.setVisible(false); score.setVisible(false); com.setVisible(false); incom.setVisible(false); } } } else { if (box3.isSelected()) { paneldownleft.setVisible(true); panel2.setVisible(true); minimumssrlen.setVisible(true); score.setVisible(true); gapcomp.setVisible(true); maxgapcomp.setVisible(true); com.setVisible(true); incom.setVisible(true); } if (!box3.isSelected()) { paneldownleft.setVisible(false); panel2.setVisible(false); minimumssrlen.setVisible(false); score.setVisible(false); gapcomp.setVisible(false); maxgapcomp.setVisible(false); com.setVisible(false); incom.setVisible(false); } } } }); /* incom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (incom.isSelected()) { if (!box2.isSelected()) { gapmax.setVisible(true); max.setVisible(true); minlenpregap.setVisible(true); minpregap.setVisible(true); } } if (!incom.isSelected()) { if (!box2.isSelected()) { gapmax.setVisible(false); max.setVisible(false); minlenpregap.setVisible(false); minpregap.setVisible(false); } } } });*/ std = new JPanel(); no_st = new JRadioButton("Not Standardized"); part_st = new JRadioButton("Partial Standardized"); full_st = new JRadioButton("Full Standardized"); no_st.setSelected(true); no_st.setEnabled(false); part_st.setEnabled(false); full_st.setEnabled(false); standard = new ButtonGroup(); standard.add(no_st); standard.add(part_st); standard.add(full_st); show = new JButton("Run"); show.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); if (!box1.isSelected() && !box2.isSelected() && !box3.isSelected()) { msg.showMessageDialog(paneldown, "Please select a type", "Error", JOptionPane.ERROR_MESSAGE); } for (int i = 0; i < organisms.length; i++) { File f = new File("organisms/" + organisms[i] + "/stats/"); if (f.exists()) { f.delete(); } } calendar = Calendar.getInstance(); now = calendar.getTime(); if (box1.isSelected()) { if (!score.getText().isEmpty()) { boolean isnumber = false; int minlen = 0; try { minlen = Integer.parseInt(score.getText()); isnumber = true; } catch (NumberFormatException ex) { isnumber = false; } if (isnumber) { try { getPerfectSSRs(organisms, minlen, flag); for (int i = 0; i < organisms.length; i++) { map = new HashMap<String, motifStats>(); String location = ""; String location2 = ""; PrintWriter out = null; // 18/11/2013 added starting here String filetype = ""; String filepro = ""; if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } //List<String> files = getFiles(organisms[i], minlen, flag); // 18/11/2013 added ending here PrintWriter stats = null; PrintWriter html = null; PrintWriter motifstats = null; PrintWriter motifhtml = null; DataOutputStream lt = null; if (filetype.contains("organisms")) { File f = new File("organisms/" + organisms[i] + "/stats/"); if (!f.exists()) { f.mkdir(); } stats = new PrintWriter(new FileWriter("organisms/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt", true)); motifstats = new PrintWriter(new FileWriter("organisms/" + organisms[i] + "/stats/" + "motif_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt", true)); motifhtml = new PrintWriter(new FileWriter("organisms/" + organisms[i] + "/stats/" + "motif_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".html", true)); html = new PrintWriter(new FileWriter("organisms/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".html", true)); lt = new DataOutputStream(new BufferedOutputStream( new FileOutputStream("organisms/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".perf"))); File fi = new File("organisms/" + organisms[i] + "/results/"); if (!fi.exists()) { fi.mkdir(); } String toopen = "organisms/" + organisms[i] + "/results/allPerfect_" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; location = toopen; location2 = "organisms/" + organisms[i] + "/stats/" + "motif_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; out = new PrintWriter(toopen); out.println("Results for organism: " + organisms[i] + "\t Search Parameters --> Minimum SSR Length (bp): " + minlen); out.println( " SSR repeats start-end length Path(../organism/data/chromosome)"); } else if (filetype.contains("local")) { File f = new File("local/" + organisms[i] + "/stats/"); if (!f.exists()) { f.mkdir(); } stats = new PrintWriter(new FileWriter("local/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt", true)); motifstats = new PrintWriter(new FileWriter("local/" + organisms[i] + "/stats/" + "motif_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt", true)); motifhtml = new PrintWriter(new FileWriter("local/" + organisms[i] + "/stats/" + "motif_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".html", true)); lt = new DataOutputStream(new BufferedOutputStream( new FileOutputStream("local/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".perf"))); html = new PrintWriter(new FileWriter("local/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".html", true)); File fi = new File("local/" + organisms[i] + "/results/"); if (!fi.exists()) { fi.mkdir(); } String toopen = "local/" + organisms[i] + "/results/allPerfect_" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; location = toopen; location2 = "local/" + organisms[i] + "/stats/" + "motif_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; out = new PrintWriter(toopen); out.println("Results for project: " + organisms[i] + "\t Search Parameters --> Minimum SSR Length (bp): " + minlen); out.println( " SSR repeats start-end length Path(../organism/data/chromosome)"); out.println(); } if (mono.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } //List<String> files = getFiles(organisms[i], minlen, flag); //for (int j = 0; j < files.size(); j++) { while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + minlen + "_monoPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int repeats = in.readInt(); int end = in.readInt(); out.println(cell(ssr, 6) + " " + cell(repeats, 11) + " " + cell(Integer .toString(end - repeats * ssr.length() + 1) + "-" + Integer.toString(end + 1), 20) + " " + cell(repeats * ssr.length(), 6) + " " + files.substring(0, files.lastIndexOf('.'))); // map for motifstats if (!map.containsKey(ssr)) { motifStats m = new motifStats(ssr, repeats); map.put(ssr, m); } else { map.get(ssr).update(repeats); } } catch (EOFException exc) { eof = true; } } in.close(); } } if (di.isSelected()) { //for (int j = 0; j < files.size(); j++) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } //List<String> files = getFiles(organisms[i], minlen, flag); while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream(new BufferedInputStream( new FileInputStream(files + "_" + minlen + "_diPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int repeats = in.readInt(); int end = in.readInt(); //out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); out.println(cell(ssr, 6) + " " + cell(repeats, 11) + " " + cell(Integer .toString(end - repeats * ssr.length() + 1) + "-" + Integer.toString(end + 1), 20) + " " + cell(repeats * ssr.length(), 6) + " " + files.substring(0, files.lastIndexOf('.'))); if (!map.containsKey(ssr)) { motifStats m = new motifStats(ssr, repeats); map.put(ssr, m); } else { map.get(ssr).update(repeats); } } catch (EOFException exc) { eof = true; } } in.close(); } } if (tri.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } //for (int j = 0; j < files.size(); j++) { while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + minlen + "_triPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int repeats = in.readInt(); int end = in.readInt(); //out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); out.println(cell(ssr, 6) + " " + cell(repeats, 11) + " " + cell(Integer .toString(end - repeats * ssr.length() + 1) + "-" + Integer.toString(end + 1), 20) + " " + cell(repeats * ssr.length(), 6) + " " + files.substring(0, files.lastIndexOf('.'))); if (!map.containsKey(ssr)) { motifStats m = new motifStats(ssr, repeats); map.put(ssr, m); } else { map.get(ssr).update(repeats); } } catch (EOFException exc) { eof = true; } } in.close(); } } if (tetra.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + minlen + "_tetraPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int repeats = in.readInt(); int end = in.readInt(); // out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); out.println(cell(ssr, 6) + " " + cell(repeats, 11) + " " + cell(Integer .toString(end - repeats * ssr.length() + 1) + "-" + Integer.toString(end + 1), 20) + " " + cell(repeats * ssr.length(), 6) + " " + files.substring(0, files.lastIndexOf('.'))); if (!map.containsKey(ssr)) { motifStats m = new motifStats(ssr, repeats); map.put(ssr, m); } else { map.get(ssr).update(repeats); } } catch (EOFException exc) { eof = true; } } in.close(); } } if (penta.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + minlen + "_pentaPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int repeats = in.readInt(); int end = in.readInt(); // out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); out.println(cell(ssr, 6) + " " + cell(repeats, 11) + " " + cell(Integer .toString(end - repeats * ssr.length() + 1) + "-" + Integer.toString(end + 1), 20) + " " + cell(repeats * ssr.length(), 6) + " " + files.substring(0, files.lastIndexOf('.'))); if (!map.containsKey(ssr)) { motifStats m = new motifStats(ssr, repeats); map.put(ssr, m); } else { map.get(ssr).update(repeats); } } catch (EOFException exc) { eof = true; } } in.close(); } } if (hexa.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + minlen + "_hexaPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int repeats = in.readInt(); int end = in.readInt(); // out.println("SSR: " + ssr + " repeats: " + repeats + " start-end " + (end - repeats * ssr.length()) + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); out.println(cell(ssr, 6) + " " + cell(repeats, 11) + " " + cell(Integer .toString(end - repeats * ssr.length() + 1) + "-" + Integer.toString(end + 1), 20) + " " + cell(repeats * ssr.length(), 6) + " " + files.substring(0, files.lastIndexOf('.'))); if (!map.containsKey(ssr)) { motifStats m = new motifStats(ssr, repeats); map.put(ssr, m); } else { map.get(ssr).update(repeats); } } catch (EOFException exc) { eof = true; } } in.close(); } } out.close(); Runtime.getRuntime().exec("notepad " + location); DecimalFormat round = new DecimalFormat("#.###"); html.println("<html><h1>******* Perfect SSRs *******</h1>"); html.println("<h4>Results for project: " + organisms[i] + "</h4><h4>Search Parameters --> Minimum SSR Length (bp): " + minlen + "</h4>"); html.println( "<table border=\"1\"><tr><td><b>motif</b></td><td><b>count</b></td><td><b>bp</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td><td><b>Relative Frequency</b></td><td><b>Abundance</b></td><td><b>Relative Abundance</b></td></tr>"); stats.println("******* Perfect SSRs *******"); stats.println("Results for project: " + organisms[i] + "\n Search Parameters --> Minimum SSR Length (bp): " + minlen); stats.println( " ____________________________________________________________________________________________________________ "); stats.println( "| | | | | | | | Relative | | Relative |"); stats.println( "| motif | count | bp | A% | T% | C% | G% | Frequency | Abundance | Abundance |"); stats.println( "|=======|=======|============|=======|=======|=======|=======|===============|===============|===============|"); int totalcount = 0; long bpcount = 0; int Aperc = 0; int Tperc = 0; int Gperc = 0; int Cperc = 0; float relfreq = 0; float abfreq = 0; long seqcount = 0; if (mono.isSelected()) { totalcount += countmono.get(i); bpcount += countmonore.get(i); } if (di.isSelected()) { totalcount += countdi.get(i); bpcount += countdire.get(i) * 2; } if (tri.isSelected()) { totalcount += counttri.get(i); bpcount += counttrire.get(i) * 3; } if (tetra.isSelected()) { totalcount += counttetra.get(i); bpcount += counttetrare.get(i) * 4; } if (penta.isSelected()) { totalcount += countpenta.get(i); bpcount += countpentare.get(i) * 5; } if (hexa.isSelected()) { totalcount += counthexa.get(i); bpcount += counthexare.get(i) * 6; } try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } Connection con = null; try { con = DriverManager.getConnection("jdbc:mysql://localhost:3306", "biouser", "thesis2012"); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } Statement st = null; try { st = con.createStatement(); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } st.executeUpdate("use lobid"); seqcount = 0; if (filetype.contains("organisms")) { ResultSet rs = st.executeQuery( "SELECT end FROM slices INNER JOIN organism WHERE slices.org_id=organism.org_id AND organism.name='" + organisms[i] + "'"); while (rs.next()) { seqcount += Long.parseLong(rs.getString(1)); } } else if (filetype.contains("local")) { BufferedReader in = new BufferedReader( new FileReader("local/" + organisms[i] + "/index.txt")); int count = countlines("local/" + organisms[i] + "/index.txt"); for (int c = 0; c < count; c++) { String temp = in.readLine(); BufferedReader tmp = new BufferedReader( new FileReader("local/" + organisms[i] + "/" + temp + ".txt")); boolean eof = false; while (!eof) { String s = tmp.readLine(); if (s != null) { seqcount += s.length(); } else { eof = true; } } tmp.close(); } } if (mono.isSelected()) { Aperc += Amono.get(i); Tperc += Tmono.get(i); Gperc += Gmono.get(i); Cperc += Cmono.get(i); //lt.writeInt(countmono);lt.writeInt(countmonore);lt.writeFloat((float)Amono*100/countmonore);lt.writeFloat((float)Tmono*100/countmonore);lt.writeFloat((float)Gmono*100/countmonore);lt.writeFloat((float)Cmono*100/countmonore);lt.writeFloat((float) countmono / totalcount);lt.writeFloat((float) countmonore / seqcount);lt.writeFloat((float) countmonore / bpcount); stats.printf("|mono |" + cell(Integer.toString(countmono.get(i)), 7) + "|" + cell(Integer.toString(1 * countmonore.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) countmono.get(i) / totalcount, 15) + "|" + cell((float) countmonore.get(i) / seqcount, 15) + "|" + cell((float) countmonore.get(i) / bpcount, 15) + "|\n", cell((float) (Amono.get(i) * 100) / (countmonore.get(i)), 7), cell((float) (Tmono.get(i) * 100) / (countmonore.get(i)), 7), cell((float) (Cmono.get(i) * 100) / (countmonore.get(i)), 7), cell((float) (Gmono.get(i) * 100) / (countmonore.get(i)), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>mono</b></td><td>" + countmono.get(i) + "</td><td>" + (1 * countmonore.get(i)) + "</td><td>" + round.format((float) (Amono.get(i) * 100) / (countmonore.get(i))) + "</td><td>" + round.format((float) (Tmono.get(i) * 100) / (countmonore.get(i))) + "</td><td>" + round.format((float) (Cmono.get(i) * 100) / (countmonore.get(i))) + "</td><td>" + round.format((float) (Gmono.get(i) * 100) / (countmonore.get(i))) + "</td><td>" + round.format((float) countmono.get(i) / totalcount) + "</td><td>" + round.format((float) countmonore.get(i) / seqcount) + "</td><td>" + round.format((float) countmonore.get(i) / bpcount) + "</td></tr>"); } if (di.isSelected()) { Aperc += Adi.get(i); Tperc += Tdi.get(i); Gperc += Gdi.get(i); Cperc += Cdi.get(i); //lt.writeInt(countdi);lt.writeInt(countdire*2);lt.writeFloat((float)Adi*100/countdire*2);lt.writeFloat((float)Tdi*100/countdire*2);lt.writeFloat((float)Gdi*100/countdire*2);lt.writeFloat((float)Cdi*100/countdire*2);lt.writeFloat((float) countdi / totalcount);lt.writeFloat((float) countdire*2 / seqcount);lt.writeFloat((float) countdire*2 / bpcount); stats.printf("|di |" + cell(Integer.toString(countdi.get(i)), 7) + "|" + cell(Integer.toString(countdire.get(i) * 2), 12) + "|%s|%s|%s|%s|" + cell((float) countdi.get(i) / totalcount, 15) + "|" + cell((float) countdire.get(i) * 2 / seqcount, 15) + "|" + cell((float) countdire.get(i) * 2 / bpcount, 15) + "|\n", cell((float) (Adi.get(i) * 100) / (countdire.get(i) * 2), 7), cell((float) (Tdi.get(i) * 100) / (countdire.get(i) * 2), 7), cell((float) (Cdi.get(i) * 100) / (countdire.get(i) * 2), 7), cell((float) (Gdi.get(i) * 100) / (countdire.get(i) * 2), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>di</b></td><td>" + countdi.get(i) + "</td><td>" + (2 * countdire.get(i)) + "</td><td>" + round.format((float) (Adi.get(i) * 100) / (2 * countdire.get(i))) + "</td><td>" + round.format((float) (Tdi.get(i) * 100) / (2 * countdire.get(i))) + "</td><td>" + round.format((float) (Cdi.get(i) * 100) / (2 * countdire.get(i))) + "</td><td>" + round.format((float) (Gdi.get(i) * 100) / (2 * countdire.get(i))) + "</td><td>" + round.format((float) countdi.get(i) / totalcount) + "</td><td>" + round.format((float) 2 * countdire.get(i) / seqcount) + "</td><td>" + round.format((float) 2 * countdire.get(i) / bpcount) + "</td></tr>"); } if (tri.isSelected()) { Aperc += Atri.get(i); Tperc += Ttri.get(i); Gperc += Gtri.get(i); Cperc += Ctri.get(i); //lt.writeInt(counttri);lt.writeInt(counttrire*3);lt.writeFloat((float)Atri*100/counttrire*3);lt.writeFloat((float)Ttri*100/counttrire*3);lt.writeFloat((float)Gtri*100/counttrire*3);lt.writeFloat((float)Ctri*100/counttrire*3);lt.writeFloat((float) counttri / totalcount);lt.writeFloat((float) counttrire*3 / seqcount);lt.writeFloat((float) counttrire*3 / bpcount); stats.printf("|tri |" + cell(Integer.toString(counttri.get(i)), 7) + "|" + cell(Integer.toString(counttrire.get(i) * 3), 12) + "|%s|%s|%s|%s|" + cell((float) counttri.get(i) / totalcount, 15) + "|" + cell((float) counttrire.get(i) * 3 / seqcount, 15) + "|" + cell((float) counttrire.get(i) * 3 / bpcount, 15) + "|\n", cell((float) (Atri.get(i) * 100) / (counttrire.get(i) * 3), 7), cell((float) (Ttri.get(i) * 100) / (counttrire.get(i) * 3), 7), cell((float) (Ctri.get(i) * 100) / (counttrire.get(i) * 3), 7), cell((float) (Gtri.get(i) * 100) / (counttrire.get(i) * 3), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>tri</b></td><td>" + counttri.get(i) + "</td><td>" + (3 * counttrire.get(i)) + "</td><td>" + round.format( (float) (Atri.get(i) * 100) / (3 * counttrire.get(i))) + "</td><td>" + round.format( (float) (Ttri.get(i) * 100) / (3 * counttrire.get(i))) + "</td><td>" + round.format( (float) (Ctri.get(i) * 100) / (3 * counttrire.get(i))) + "</td><td>" + round.format( (float) (Gtri.get(i) * 100) / (3 * counttrire.get(i))) + "</td><td>" + round.format((float) counttri.get(i) / totalcount) + "</td><td>" + round.format((float) 3 * counttrire.get(i) / seqcount) + "</td><td>" + round.format((float) 3 * counttrire.get(i) / bpcount) + "</td></tr>"); } if (tetra.isSelected()) { Aperc += Atetra.get(i); Tperc += Ttetra.get(i); Gperc += Gtetra.get(i); Cperc += Ctetra.get(i); //lt.writeInt(counttetra);lt.writeInt(counttetrare*4);lt.writeFloat((float)Atetra*100/counttetrare*4);lt.writeFloat((float)Ttetra*100/counttetrare*4);lt.writeFloat((float)Gtetra*100/counttetrare*4);lt.writeFloat((float)Ctetra*100/counttetrare*4);lt.writeFloat((float) counttetra / totalcount);lt.writeFloat((float) counttetrare*4 / seqcount);lt.writeFloat((float) counttetrare*4 / bpcount); stats.printf("|tetra |" + cell(Integer.toString(counttetra.get(i)), 7) + "|" + cell(Integer.toString(counttetrare.get(i) * 4), 12) + "|%s|%s|%s|%s|" + cell((float) counttetra.get(i) / totalcount, 15) + "|" + cell((float) counttetrare.get(i) * 4 / seqcount, 15) + "|" + cell((float) counttetrare.get(i) * 4 / bpcount, 15) + "|\n", cell((float) (Atetra.get(i) * 100) / (counttetrare.get(i) * 4), 7), cell((float) (Ttetra.get(i) * 100) / (counttetrare.get(i) * 4), 7), cell((float) (Ctetra.get(i) * 100) / (counttetrare.get(i) * 4), 7), cell((float) (Gtetra.get(i) * 100) / (counttetrare.get(i) * 4), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>tetra</b></td><td>" + counttetra.get(i) + "</td><td>" + (4 * counttetrare.get(i)) + "</td><td>" + round.format( (float) (Atetra.get(i) * 100) / (4 * counttetrare.get(i))) + "</td><td>" + round.format( (float) (Ttetra.get(i) * 100) / (4 * counttetrare.get(i))) + "</td><td>" + round.format( (float) (Ctetra.get(i) * 100) / (4 * counttetrare.get(i))) + "</td><td>" + round.format( (float) (Gtetra.get(i) * 100) / (4 * counttetrare.get(i))) + "</td><td>" + round.format((float) counttetra.get(i) / totalcount) + "</td><td>" + round.format((float) 4 * counttetrare.get(i) / seqcount) + "</td><td>" + round.format((float) 4 * counttetrare.get(i) / bpcount) + "</td></tr>"); } if (penta.isSelected()) { Aperc += Apenta.get(i); Tperc += Tpenta.get(i); Gperc += Gpenta.get(i); Cperc += Cpenta.get(i); //lt.writeInt(countpenta);lt.writeInt(countpentare*5);lt.writeFloat((float)Apenta*100/countpentare*5);lt.writeFloat((float)Tpenta*100/countpentare*5);lt.writeFloat((float)Gpenta*100/countpentare*5);lt.writeFloat((float)Cpenta*100/countpentare*5);lt.writeFloat((float) countpenta / totalcount);lt.writeFloat((float) countpentare*5 / seqcount);lt.writeFloat((float) countpentare*5 / bpcount); stats.printf("|penta |" + cell(Integer.toString(countpenta.get(i)), 7) + "|" + cell(Integer.toString(countpentare.get(i) * 5), 12) + "|%s|%s|%s|%s|" + cell((float) countpenta.get(i) / totalcount, 15) + "|" + cell((float) countpentare.get(i) * 5 / seqcount, 15) + "|" + cell((float) countpentare.get(i) * 5 / bpcount, 15) + "|\n", cell((float) (Apenta.get(i) * 100) / (countpentare.get(i) * 5), 7), cell((float) (Tpenta.get(i) * 100) / (countpentare.get(i) * 5), 7), cell((float) (Cpenta.get(i) * 100) / (countpentare.get(i) * 5), 7), cell((float) (Gpenta.get(i) * 100) / (countpentare.get(i) * 5), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>penta</b></td><td>" + countpenta.get(i) + "</td><td>" + (5 * countpentare.get(i)) + "</td><td>" + round.format( (float) (Apenta.get(i) * 100) / (5 * countpentare.get(i))) + "</td><td>" + round.format( (float) (Tpenta.get(i) * 100) / (5 * countpentare.get(i))) + "</td><td>" + round.format( (float) (Cpenta.get(i) * 100) / (5 * countpentare.get(i))) + "</td><td>" + round.format( (float) (Gpenta.get(i) * 100) / (5 * countpentare.get(i))) + "</td><td>" + round.format((float) countpenta.get(i) / totalcount) + "</td><td>" + round.format((float) 5 * countpentare.get(i) / seqcount) + "</td><td>" + round.format((float) 5 * countpentare.get(i) / bpcount) + "</td></tr>"); } if (hexa.isSelected()) { Aperc += Ahexa.get(i); Tperc += Thexa.get(i); Gperc += Ghexa.get(i); Cperc += Chexa.get(i); //lt.writeInt(counthexa);lt.writeInt(counthexare*6);lt.writeFloat((float)Ahexa*100/counthexare*6);lt.writeFloat((float)Thexa*100/counthexare*6);lt.writeFloat((float)Ghexa*100/counthexare*6);lt.writeFloat((float)Chexa*100/counthexare*6);lt.writeFloat((float) counthexa / totalcount);lt.writeFloat((float) counthexare*6 / seqcount);lt.writeFloat((float) counthexare*6 / bpcount); stats.printf("|hexa |" + cell(Integer.toString(counthexa.get(i)), 7) + "|" + cell(Integer.toString(counthexare.get(i) * 6), 12) + "|%s|%s|%s|%s|" + cell((float) counthexa.get(i) / totalcount, 15) + "|" + cell((float) counthexare.get(i) * 6 / seqcount, 15) + "|" + cell((float) counthexare.get(i) * 6 / bpcount, 15) + "|\n", cell((float) (Ahexa.get(i) * 100) / (counthexare.get(i) * 6), 7), cell((float) (Thexa.get(i) * 100) / (counthexare.get(i) * 6), 7), cell((float) (Chexa.get(i) * 100) / (counthexare.get(i) * 6), 7), cell((float) (Ghexa.get(i) * 100) / (counthexare.get(i) * 6), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>hexa</b></td><td>" + counthexa.get(i) + "</td><td>" + (6 * counthexare.get(i)) + "</td><td>" + round.format( (float) (Ahexa.get(i) * 100) / (6 * counthexare.get(i))) + "</td><td>" + round.format( (float) (Thexa.get(i) * 100) / (6 * counthexare.get(i))) + "</td><td>" + round.format( (float) (Chexa.get(i) * 100) / (6 * counthexare.get(i))) + "</td><td>" + round.format( (float) (Ghexa.get(i) * 100) / (6 * counthexare.get(i))) + "</td><td>" + round.format((float) counthexa.get(i) / totalcount) + "</td><td>" + round.format((float) 6 * counthexare.get(i) / seqcount) + "</td><td>" + round.format((float) 6 * counthexare.get(i) / bpcount) + "</td></tr>"); } if (mono.isSelected()) { relfreq += (float) countmono.get(i) / totalcount; abfreq += (float) countmonore.get(i) / bpcount; } if (di.isSelected()) { relfreq += (float) countdi.get(i) / totalcount; abfreq += (float) countdire.get(i) * 2 / bpcount; } if (tri.isSelected()) { relfreq += (float) counttri.get(i) / totalcount; abfreq += (float) counttrire.get(i) * 3 / bpcount; } if (tetra.isSelected()) { relfreq += (float) counttetra.get(i) / totalcount; abfreq += (float) counttetrare.get(i) * 4 / bpcount; } if (penta.isSelected()) { relfreq += (float) countpenta.get(i) / totalcount; abfreq += (float) countpentare.get(i) * 5 / bpcount; } if (hexa.isSelected()) { relfreq += (float) counthexa.get(i) / totalcount; abfreq += (float) counthexare.get(i) * 6 / bpcount; } Globals.A = Aperc; Globals.T = Tperc; Globals.G = Gperc; Globals.C = Cperc; lt.writeLong(seqcount); lt.writeInt(totalcount); lt.writeLong(bpcount); lt.writeInt(Aperc); lt.writeInt(Tperc); lt.writeInt(Gperc); lt.writeInt(Cperc); stats.println("|TOTAL |" + cell(Integer.toString(totalcount), 7) + "|" + cell(Long.toString(bpcount), 12) + "|" + cell((float) Aperc * 100 / bpcount, 7) + "|" + cell((float) Tperc * 100 / bpcount, 7) + "|" + cell((float) Cperc * 100 / bpcount, 7) + "|" + cell((float) Gperc * 100 / bpcount, 7) + "|" + cell(relfreq, 15) + "|" + cell((float) bpcount / seqcount, 15) + "|" + cell((float) abfreq, 15) + "|"); stats.println( "|_______|_______|____________|_______|_______|_______|_______|_______________|_______________|_______________|"); stats.println("Genome length (bp): " + seqcount); stats.println("Relative Frequency: Count of each motif type / total SSR count"); stats.println("Abundance: bp of each motif type / total sequence bp"); stats.println( "Relative Abundance: bp of each motif type / total microsatellites bp"); stats.println(); stats.println(); stats.close(); lt.close(); html.println("<tr><td><b>TOTAL</b></td><td>" + totalcount + "</td><td>" + bpcount + "</td><td>" + round.format((float) Aperc * 100 / bpcount) + "</td><td>" + round.format((float) Tperc * 100 / bpcount) + "</td><td>" + round.format((float) Cperc * 100 / bpcount) + "</td><td>" + round.format((float) Gperc * 100 / bpcount) + "</td><td>" + round.format((float) relfreq) + "</td><td>" + round.format((float) bpcount / seqcount) + "</td><td>" + round.format((float) abfreq) + "</td></tr></table></html>"); html.close(); // it = map.keySet().iterator(); for (String key : map.keySet()) { map.get(key).refresh(); } List<String> n1 = new ArrayList<String>(); List<String> n2 = new ArrayList<String>(); List<String> n3 = new ArrayList<String>(); List<String> n4 = new ArrayList<String>(); List<String> n5 = new ArrayList<String>(); List<String> n6 = new ArrayList<String>(); Iterator<String> it = map.keySet().iterator(); while (it.hasNext()) { String next = it.next(); int len = next.length(); if (len == 1) n1.add(next); else if (len == 2) n2.add(next); else if (len == 3) n3.add(next); else if (len == 4) n4.add(next); else if (len == 5) n5.add(next); else if (len == 6) n6.add(next); } Collections.sort(n1); Collections.sort(n2); Collections.sort(n3); Collections.sort(n4); Collections.sort(n5); Collections.sort(n6); boolean[] id1 = new boolean[n1.size()]; boolean[] id2 = new boolean[n2.size()]; boolean[] id3 = new boolean[n3.size()]; boolean[] id4 = new boolean[n4.size()]; boolean[] id5 = new boolean[n5.size()]; boolean[] id6 = new boolean[n6.size()]; motifhtml.println("<html><head><title>Motif Statistics</title></head><body>"); int stand = checkStandardize(); // stand=2; debug if (stand == 0) { motifstats.println("**** Not Standardized ****"); motifhtml.println("<h1>**** Not Standardized ****</h1>"); Arrays.fill(id1, true); Arrays.fill(id2, true); Arrays.fill(id3, true); Arrays.fill(id4, true); Arrays.fill(id5, true); Arrays.fill(id6, true); } else { if (stand == 1) { motifstats.println("**** Partially Standardized ****"); motifhtml.println("<h1>**** Partially Standardized ****</h1>"); matrix = new parser(1); } if (stand == 2) { motifstats.println("**** Fully Standardized ****"); motifhtml.println("<h1>**** Fully Standardized ****</h1>"); matrix = new parser(2); } Arrays.fill(id1, true); Arrays.fill(id2, true); Arrays.fill(id3, true); Arrays.fill(id4, true); Arrays.fill(id5, true); Arrays.fill(id6, true); for (int n = 0; n < n1.size(); n++) { int id = -2; id = matrix.SearchMap(1, n1.get(n)); if (id >= 0) { int found = matrix.checkFound(1, id); if (found >= 0) { map.get(n1.get(found)).merge(map.get(n1.get(n))); id1[n] = false; // gia clean twn listwn apo merged TODO * } if (found == -4) { matrix.makeFound(1, id, n); } } } for (int n = 0; n < n2.size(); n++) { int id = -2; id = matrix.SearchMap(2, n2.get(n)); if (id >= 0) { int found = matrix.checkFound(2, id); if (found >= 0) { map.get(n2.get(found)).merge(map.get(n2.get(n))); id2[n] = false; // gia clean twn listwn apo merged TODO * } else { matrix.makeFound(2, id, n); id2[n] = true; } } } for (int n = 0; n < n3.size(); n++) { int id = -2; id = matrix.SearchMap(3, n3.get(n)); if (id >= 0) { int found = matrix.checkFound(3, id); if (found >= 0) { map.get(n3.get(found)).merge(map.get(n3.get(n))); id3[n] = false; // gia clean twn listwn apo merged TODO * } else { matrix.makeFound(3, id, n); id3[n] = true; } } } for (int n = 0; n < n4.size(); n++) { int id = -2; id = matrix.SearchMap(4, n4.get(n)); if (id >= 0) { int found = matrix.checkFound(4, id); if (found >= 0) { map.get(n4.get(found)).merge(map.get(n4.get(n))); id4[n] = false; // gia clean twn listwn apo merged TODO * } else { matrix.makeFound(4, id, n); id4[n] = true; } } } for (int n = 0; n < n5.size(); n++) { int id = -2; id = matrix.SearchMap(5, n5.get(n)); if (id >= 0) { int found = matrix.checkFound(5, id); if (found >= 0) { map.get(n5.get(found)).merge(map.get(n5.get(n))); id5[n] = false; // gia clean twn listwn apo merged TODO * } else { matrix.makeFound(5, id, n); id5[n] = true; } } } for (int n = 0; n < n6.size(); n++) { int id = -2; id = matrix.SearchMap(6, n6.get(n)); if (id >= 0) { int found = matrix.checkFound(6, id); if (found >= 0) { map.get(n6.get(found)).merge(map.get(n6.get(n))); id6[n] = false; // gia clean twn listwn apo merged TODO * } else { matrix.makeFound(6, id, n); id6[n] = true; } } } } for (String key : map.keySet()) { map.get(key).refresh(); } motifstats.println( " Motif Count Repeats bp Avg_Length SD_Length Max_Length Avg_Repeats A% T% C% G% "); motifhtml.println( "<table border=\"1\"><tr><td><b>Motif</b></td><td><b>Count</b></td><td><b>Repeats</b></td><td><b>bp</b></td><td><b>Avg_Length</b></td><td><b>SD_Length</b></td><td><b>Max_Length</b></td><td><b>Avg_Repeats</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td></tr>"); if (mono.isSelected()) { for (int z = 0; z < n1.size(); z++) { if (id1[z] && !map.get(n1.get(z)).getMotif().contains("N")) { motifstats.println(map.get(n1.get(z)).toString()); motifhtml.println(map.get(n1.get(z)).toHTML()); } } } if (di.isSelected()) { for (int z = 0; z < n2.size(); z++) { if (id2[z] && !map.get(n2.get(z)).getMotif().contains("N")) { motifstats.println(map.get(n2.get(z)).toString()); motifhtml.println(map.get(n2.get(z)).toHTML()); } } } if (tri.isSelected()) { for (int z = 0; z < n3.size(); z++) { if (id3[z] && !map.get(n3.get(z)).getMotif().contains("N")) { motifstats.println(map.get(n3.get(z)).toString()); motifhtml.println(map.get(n3.get(z)).toHTML()); } } } if (tetra.isSelected()) { for (int z = 0; z < n4.size(); z++) { if (id4[z] && !map.get(n4.get(z)).getMotif().contains("N")) { motifstats.println(map.get(n4.get(z)).toString()); motifhtml.println(map.get(n4.get(z)).toHTML()); } } } if (penta.isSelected()) { for (int z = 0; z < n5.size(); z++) { if (id5[z] && !map.get(n5.get(z)).getMotif().contains("N")) { motifstats.println(map.get(n5.get(z)).toString()); motifhtml.println(map.get(n5.get(z)).toHTML()); } } } if (hexa.isSelected()) { for (int z = 0; z < n6.size(); z++) { if (id6[z] && !map.get(n6.get(z)).getMotif().contains("N")) { motifstats.println(map.get(n6.get(z)).toString()); motifhtml.println(map.get(n6.get(z)).toHTML()); } } } motifstats.close(); motifhtml.println("</table></body></html>"); motifhtml.close(); Runtime.getRuntime().exec("notepad " + location2); } } catch (FileNotFoundException ex) { //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE); Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } else { msg.showMessageDialog(paneldown, "Minimum length requires an Integer", "Error", JOptionPane.ERROR_MESSAGE); } } else { msg.showMessageDialog(paneldown, "Please fill in the minimum length (Integers only)", "Error", JOptionPane.ERROR_MESSAGE); } } if (box2.isSelected()) { boolean gapisnumber = false; boolean minisnumber = false; int gap = 0; int min = 0; try { gap = Integer.parseInt(max.getText()); gapisnumber = true; } catch (NumberFormatException ex) { gapisnumber = false; } try { min = Integer.parseInt(minpregap.getText()); minisnumber = true; } catch (NumberFormatException ex) { minisnumber = false; } if (gapisnumber && minisnumber) { try { getImPerfectSSRs(organisms, min, flag, gap); for (int i = 0; i < organisms.length; i++) { PrintWriter stats = null; PrintWriter html = null; String location = ""; // 18/11/2013 added starting here String filetype = ""; String filepro = ""; if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } //List<String> files = getFiles(organisms[i], minlen, flag); // 18/11/2013 added ending here PrintWriter out = null; DataOutputStream lt = null; if (filetype.contains("organisms")) { File f = new File("organisms/" + organisms[i] + "/stats/"); if (!f.exists()) { f.mkdir(); } stats = new PrintWriter(new FileWriter( "organisms/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt", true)); lt = new DataOutputStream(new BufferedOutputStream( new FileOutputStream("organisms/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".imperf"))); html = new PrintWriter(new FileWriter( "organisms/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".html", true)); File fi = new File("organisms/" + organisms[i] + "/results/"); if (!fi.exists()) { fi.mkdir(); } String toopen = "organisms/" + organisms[i] + "/results/allImPerfect_" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; location = toopen; out = new PrintWriter(toopen); out.println("Results for organism: " + organisms[i] + "\t Search Parameters --> Maximum Mismatch length for ImPerfect SSRs : " + gap + " minimum SSR length before given gap: " + min); } else if (filetype.contains("local")) { File f = new File("local/" + organisms[i] + "/stats/"); if (!f.exists()) { f.mkdir(); } stats = new PrintWriter(new FileWriter( "local/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt", true)); lt = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("local/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".imperf"))); html = new PrintWriter(new FileWriter( "local/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".html", true)); File fi = new File("local/" + organisms[i] + "/results/"); if (!fi.exists()) { fi.mkdir(); } String toopen = "local/" + organisms[i] + "/results/allImPerfect_" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; location = toopen; out = new PrintWriter(toopen); out.println("Results for project: " + organisms[i] + "\t Search Parameters --> Maximum Mismatch length for ImPerfect SSRs : " + gap + " minimum SSR length before given gap: " + min); } if (mono.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + min + "_" + gap + "_monoImPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int start = in.readInt(); int end = in.readInt(); if (!ssr.contains("N")) out.println("SSR: " + ssr + " start-end " + start + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); } catch (EOFException exc) { eof = true; } } in.close(); } } if (di.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + min + "_" + gap + "_diImPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int start = in.readInt(); int end = in.readInt(); if (!ssr.contains("N")) out.println("SSR: " + ssr + " start-end " + start + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); } catch (EOFException exc) { eof = true; } } in.close(); } } if (tri.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + min + "_" + gap + "_triImPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int start = in.readInt(); int end = in.readInt(); if (!ssr.contains("N")) out.println("SSR: " + ssr + " start-end " + start + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); } catch (EOFException exc) { eof = true; } } in.close(); } } if (tetra.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + min + "_" + gap + "_tetraImPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int start = in.readInt(); int end = in.readInt(); if (!ssr.contains("N")) out.println("SSR: " + ssr + " start-end " + start + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); } catch (EOFException exc) { eof = true; } } in.close(); } } if (penta.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + min + "_" + gap + "_pentaImPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int start = in.readInt(); int end = in.readInt(); if (!ssr.contains("N")) out.println("SSR: " + ssr + " start-end " + start + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); } catch (EOFException exc) { eof = true; } } in.close(); } } if (hexa.isSelected()) { // 18/11/2013 added starting here if (flag) { filetype = "organisms"; filepro = "organisms/" + organisms[i] + "/data/"; int ret = getOrganismStatus(organisms[i]); if (ret == -1) indexer = new Indexer(chromosomelist); else indexer = new Indexer(ret); } else { filetype = "local"; filepro = "local/" + organisms[i] + "/data/"; String indexfile = "local/" + organisms[i] + "/index.txt"; indexer = new Indexer(indexfile); } while (indexer.hasNext()) { String files = filepro + indexer.getNextFileName(); DataInputStream in = new DataInputStream( new BufferedInputStream(new FileInputStream( files + "_" + min + "_" + gap + "_hexaImPerfect.temp"))); boolean eof = false; while (!eof) { try { String ssr = in.readUTF(); int start = in.readInt(); int end = in.readInt(); if (!ssr.contains("N")) out.println("SSR: " + ssr + " start-end " + start + "-" + end + " Path(../data/chromosome): " + files.substring(0, files.lastIndexOf('.'))); } catch (EOFException exc) { eof = true; } } in.close(); } } out.close(); Runtime.getRuntime().exec("notepad " + location); DecimalFormat round = new DecimalFormat("#.###"); html.println("<html><h1>******* ImPerfect SSRs *******</h1>"); html.println("<h4>Results for project: " + organisms[i] + "</h4><h4>Search Parameters --> Maximum Mismatch length for ImPerfect SSRs (bp): " + gap + "</h4><h4>minimum SSR length before given Mismatch length (bp): " + min + "</h4>"); html.println( "<table border=\"1\"><tr><td><b>motif</b></td><td><b>count</b></td><td><b>bp</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td><td><b>Relative Frequency</b></td><td><b>Abundance</b></td><td><b>Relative Abundance</b></td></tr>"); stats.println("******* ImPerfect SSRs *******"); stats.println("Results for project: " + organisms[i] + "\n Search Parameters --> Maximum Mismatch length for ImPerfect SSRs (bp): " + gap + " \nminimum SSR length before given Mismatch length (bp): " + min); stats.println( " ____________________________________________________________________________________________________________ "); stats.println( "| | | | | | | | Relative | | Relative |"); stats.println( "| motif | count | bp | A% | T% | C% | G% | Frequency | Abundance | Abundance |"); stats.println( "|=======|=======|============|=======|=======|=======|=======|===============|===============|===============|"); int totalcount = 0; long bpcount = 0; int Aperc = 0; int Tperc = 0; int Gperc = 0; int Cperc = 0; float relfreq = 0; float abfreq = 0; long seqcount = 0; if (mono.isSelected()) { totalcount += countmono.get(i); bpcount += countmonore.get(i); } if (di.isSelected()) { totalcount += countdi.get(i); bpcount += countdire.get(i); } if (tri.isSelected()) { totalcount += counttri.get(i); bpcount += counttrire.get(i); } if (tetra.isSelected()) { totalcount += counttetra.get(i); bpcount += counttetrare.get(i); } if (penta.isSelected()) { totalcount += countpenta.get(i); bpcount += countpentare.get(i); } if (hexa.isSelected()) { totalcount += counthexa.get(i); bpcount += counthexare.get(i); } try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } Connection con = null; try { con = DriverManager.getConnection("jdbc:mysql://localhost:3306", "biouser", "thesis2012"); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } Statement st = null; try { st = con.createStatement(); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } st.executeUpdate("use lobid"); seqcount = 0; if (filetype.contains("organisms")) { ResultSet rs = st.executeQuery( "SELECT end FROM slices INNER JOIN organism WHERE slices.org_id=organism.org_id AND organism.name='" + organisms[i] + "'"); while (rs.next()) { seqcount += Long.parseLong(rs.getString(1)); } } else if (filetype.contains("local")) { BufferedReader in = new BufferedReader( new FileReader("local/" + organisms[i] + "/index.txt")); int count = countlines("local/" + organisms[i] + "/index.txt"); for (int c = 0; c < count; c++) { String temp = in.readLine(); BufferedReader tmp = new BufferedReader( new FileReader("local/" + organisms[i] + "/" + temp + ".txt")); boolean eof = false; while (!eof) { String s = tmp.readLine(); if (s != null) { seqcount += s.length(); } else { eof = true; } } tmp.close(); } } int tempmono = countmonore.get(i); int tempdi = countdire.get(i); int temptri = counttrire.get(i); int temptetra = counttetrare.get(i); int temppenta = countpentare.get(i); int temphexa = counthexare.get(i); if (tempmono == 0) tempmono = 1; if (tempdi == 0) tempdi = 1; if (temptri == 0) temptri = 1; if (temptetra == 0) temptetra = 1; if (temppenta == 0) temppenta = 1; if (temphexa == 0) temphexa = 1; if (mono.isSelected()) { Aperc += Amono.get(i); Tperc += Tmono.get(i); Gperc += Gmono.get(i); Cperc += Cmono.get(i); //lt.writeInt(countmono.get(i));lt.writeInt(countmonore.get(i));lt.writeFloat((float)Amono.get(i)*100/tempmono);lt.writeFloat((float)Tmono.get(i)*100/tempmono);lt.writeFloat((float)Gmono.get(i)*100/tempmono);lt.writeFloat((float)Cmono.get(i)*100/tempmono);lt.writeFloat((float) countmono.get(i) / totalcount);lt.writeFloat((float) countmonore.get(i) / seqcount);lt.writeFloat((float) countmonore.get(i) / bpcount); stats.printf("|mono |" + cell(Integer.toString(countmono.get(i)), 7) + "|" + cell(Integer.toString(countmonore.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) countmono.get(i) / totalcount, 15) + "|" + cell((float) countmonore.get(i) / seqcount, 15) + "|" + cell((float) countmonore.get(i) / bpcount, 15) + "|\n", cell((float) (Amono.get(i) * 100) / (tempmono), 7), cell((float) (Tmono.get(i) * 100) / (tempmono), 7), cell((float) (Cmono.get(i) * 100) / (tempmono), 7), cell((float) (Gmono.get(i) * 100) / (tempmono), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>mono</b></td><td>" + countmono.get(i) + "</td><td>" + (countmonore.get(i)) + "</td><td>" + round.format((float) (Amono.get(i) * 100) / (tempmono)) + "</td><td>" + round.format((float) (Tmono.get(i) * 100) / (tempmono)) + "</td><td>" + round.format((float) (Cmono.get(i) * 100) / (tempmono)) + "</td><td>" + round.format((float) (Gmono.get(i) * 100) / (tempmono)) + "</td><td>" + round.format((float) countmono.get(i) / totalcount) + "</td><td>" + round.format((float) countmonore.get(i) / seqcount) + "</td><td>" + round.format((float) countmonore.get(i) / bpcount) + "</td></tr>"); } if (di.isSelected()) { Aperc += Adi.get(i); Tperc += Tdi.get(i); Gperc += Gdi.get(i); Cperc += Cdi.get(i); //lt.writeInt(countdi.get(i));lt.writeInt(countdi.get(i)re.get(i));lt.writeFloat((float)Adi.get(i)*100/tempdi);lt.writeFloat((float)Tdi.get(i)*100/tempdi);lt.writeFloat((float)Gdi.get(i)*100/tempdi);lt.writeFloat((float)Cdi.get(i)*100/tempdi);lt.writeFloat((float) countdi.get(i) / totalcount);lt.writeFloat((float) countdi.get(i)re.get(i) / seqcount);lt.writeFloat((float) countdi.get(i)re.get(i) / bpcount); stats.printf( "|di |" + cell(Integer.toString(countdi.get(i)), 7) + "|" + cell(Integer.toString(countdire.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) countdi.get(i) / totalcount, 15) + "|" + cell((float) countdi.get(i) / seqcount, 15) + "|" + cell((float) countdi.get(i) / bpcount, 15) + "|\n", cell((float) (Adi.get(i) * 100) / (tempdi), 7), cell((float) (Tdi.get(i) * 100) / (tempdi), 7), cell((float) (Cdi.get(i) * 100) / (tempdi), 7), cell((float) (Gdi.get(i) * 100) / (tempdi), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>di</b></td><td>" + countdi.get(i) + "</td><td>" + (countdire.get(i)) + "</td><td>" + round.format((float) (Adi.get(i) * 100) / (tempdi)) + "</td><td>" + round.format((float) (Tdi.get(i) * 100) / (tempdi)) + "</td><td>" + round.format((float) (Cdi.get(i) * 100) / (tempdi)) + "</td><td>" + round.format((float) (Gdi.get(i) * 100) / (tempdi)) + "</td><td>" + round.format((float) countdi.get(i) / totalcount) + "</td><td>" + round.format((float) countdire.get(i) / seqcount) + "</td><td>" + round.format((float) countdire.get(i) / bpcount) + "</td></tr>"); } if (tri.isSelected()) { Aperc += Atri.get(i); Tperc += Ttri.get(i); Gperc += Gtri.get(i); Cperc += Ctri.get(i); //lt.writeInt(counttri.get(i));lt.writeInt(counttrire.get(i).get(i));lt.writeFloat((float)Atri.get(i)*100/temptri);lt.writeFloat((float)Ttri.get(i)*100/temptri);lt.writeFloat((float)Gtri.get(i)*100/temptri);lt.writeFloat((float)Ctri.get(i)*100/temptri);lt.writeFloat((float) counttri.get(i) / totalcount);lt.writeFloat((float) counttrire.get(i).get(i) / seqcount);lt.writeFloat((float) counttrire.get(i).get(i) / bpcount); stats.printf("|tri |" + cell(Integer.toString(counttri.get(i)), 7) + "|" + cell(Integer.toString(counttrire.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) counttri.get(i) / totalcount, 15) + "|" + cell((float) counttrire.get(i) / seqcount, 15) + "|" + cell((float) counttrire.get(i) / bpcount, 15) + "|\n", cell((float) (Atri.get(i) * 100) / (temptri), 7), cell((float) (Ttri.get(i) * 100) / (temptri), 7), cell((float) (Ctri.get(i) * 100) / (temptri), 7), cell((float) (Gtri.get(i) * 100) / (temptri), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>tri</b></td><td>" + counttri.get(i) + "</td><td>" + (counttrire.get(i)) + "</td><td>" + round.format((float) (Atri.get(i) * 100) / (temptri)) + "</td><td>" + round.format((float) (Ttri.get(i) * 100) / (temptri)) + "</td><td>" + round.format((float) (Ctri.get(i) * 100) / (temptri)) + "</td><td>" + round.format((float) (Gtri.get(i) * 100) / (temptri)) + "</td><td>" + round.format((float) counttri.get(i) / totalcount) + "</td><td>" + round.format((float) counttrire.get(i) / seqcount) + "</td><td>" + round.format((float) counttrire.get(i) / bpcount) + "</td></tr>"); } if (tetra.isSelected()) { Aperc += Atetra.get(i); Tperc += Ttetra.get(i); Gperc += Gtetra.get(i); Cperc += Ctetra.get(i); //lt.writeInt(counttetra.get(i));lt.writeInt(counttetrare.get(i));lt.writeFloat((float)Atetra.get(i)*100/temptetra);lt.writeFloat((float)Ttetra.get(i)*100/temptetra);lt.writeFloat((float)Gtetra.get(i)*100/temptetra);lt.writeFloat((float)Ctetra.get(i)*100/temptetra);lt.writeFloat((float) counttetra.get(i) / totalcount);lt.writeFloat((float) counttetrare.get(i) / seqcount);lt.writeFloat((float) counttetrare.get(i) / bpcount); stats.printf("|tetra |" + cell(Integer.toString(counttetra.get(i)), 7) + "|" + cell(Integer.toString(counttetrare.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) counttetra.get(i) / totalcount, 15) + "|" + cell((float) counttetrare.get(i) / seqcount, 15) + "|" + cell((float) counttetrare.get(i) / bpcount, 15) + "|\n", cell((float) (Atetra.get(i) * 100) / (temptetra), 7), cell((float) (Ttetra.get(i) * 100) / (temptetra), 7), cell((float) (Ctetra.get(i) * 100) / (temptetra), 7), cell((float) (Gtetra.get(i) * 100) / (temptetra), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>tetra</b></td><td>" + counttetra.get(i) + "</td><td>" + (counttetrare.get(i)) + "</td><td>" + round.format((float) (Atetra.get(i) * 100) / (temptetra)) + "</td><td>" + round.format((float) (Ttetra.get(i) * 100) / (temptetra)) + "</td><td>" + round.format((float) (Ctetra.get(i) * 100) / (temptetra)) + "</td><td>" + round.format((float) (Gtetra.get(i) * 100) / (temptetra)) + "</td><td>" + round.format((float) counttetra.get(i) / totalcount) + "</td><td>" + round.format((float) counttetrare.get(i) / seqcount) + "</td><td>" + round.format((float) counttetrare.get(i) / bpcount) + "</td></tr>"); } if (penta.isSelected()) { Aperc += Apenta.get(i); Tperc += Tpenta.get(i); Gperc += Gpenta.get(i); Cperc += Cpenta.get(i); //lt.writeInt(countpenta.get(i));lt.writeInt(countpentare.get(i));lt.writeFloat((float)Apenta.get(i)*100/temppenta);lt.writeFloat((float)Tpenta.get(i)*100/temppenta);lt.writeFloat((float)Gpenta.get(i)*100/temppenta);lt.writeFloat((float)Cpenta.get(i)*100/temppenta);lt.writeFloat((float) countpenta.get(i) / totalcount);lt.writeFloat((float) countpentare.get(i) / seqcount);lt.writeFloat((float) countpentare.get(i) / bpcount); stats.printf("|penta |" + cell(Integer.toString(countpenta.get(i)), 7) + "|" + cell(Integer.toString(countpentare.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) countpenta.get(i) / totalcount, 15) + "|" + cell((float) countpentare.get(i) / seqcount, 15) + "|" + cell((float) countpentare.get(i) / bpcount, 15) + "|\n", cell((float) (Apenta.get(i) * 100) / (temppenta), 7), cell((float) (Tpenta.get(i) * 100) / (temppenta), 7), cell((float) (Cpenta.get(i) * 100) / (temppenta), 7), cell((float) (Gpenta.get(i) * 100) / (temppenta), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>penta</b></td><td>" + countpenta.get(i) + "</td><td>" + (countpentare.get(i)) + "</td><td>" + round.format((float) (Apenta.get(i) * 100) / (temppenta)) + "</td><td>" + round.format((float) (Tpenta.get(i) * 100) / (temppenta)) + "</td><td>" + round.format((float) (Cpenta.get(i) * 100) / (temppenta)) + "</td><td>" + round.format((float) (Gpenta.get(i) * 100) / (temppenta)) + "</td><td>" + round.format((float) countpenta.get(i) / totalcount) + "</td><td>" + round.format((float) countpentare.get(i) / seqcount) + "</td><td>" + round.format((float) countpentare.get(i) / bpcount) + "</td></tr>"); } if (hexa.isSelected()) { Aperc += Ahexa.get(i); Tperc += Thexa.get(i); Gperc += Ghexa.get(i); Cperc += Chexa.get(i); //lt.writeInt(counthexa.get(i));lt.writeInt(counthexare.get(i));lt.writeFloat((float)Ahexa.get(i)*100/temphexa);lt.writeFloat((float)Thexa.get(i)*100/temphexa);lt.writeFloat((float)Ghexa.get(i)*100/temphexa);lt.writeFloat((float)Chexa.get(i)*100/temphexa);lt.writeFloat((float) counthexa.get(i) / totalcount);lt.writeFloat((float) counthexare.get(i) / seqcount);lt.writeFloat((float) counthexare.get(i) / bpcount); stats.printf("|hexa |" + cell(Integer.toString(counthexa.get(i)), 7) + "|" + cell(Integer.toString(counthexare.get(i)), 12) + "|%s|%s|%s|%s|" + cell((float) counthexa.get(i) / totalcount, 15) + "|" + cell((float) counthexare.get(i) / seqcount, 15) + "|" + cell((float) counthexare.get(i) / bpcount, 15) + "|\n", cell((float) (Ahexa.get(i) * 100) / (temphexa), 7), cell((float) (Thexa.get(i) * 100) / (temphexa), 7), cell((float) (Chexa.get(i) * 100) / (temphexa), 7), cell((float) (Ghexa.get(i) * 100) / (temphexa), 7)); stats.println( "|-------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>hexa</b></td><td>" + counthexa.get(i) + "</td><td>" + (counthexare.get(i)) + "</td><td>" + round.format((float) (Ahexa.get(i) * 100) / (temphexa)) + "</td><td>" + round.format((float) (Thexa.get(i) * 100) / (temphexa)) + "</td><td>" + round.format((float) (Chexa.get(i) * 100) / (temphexa)) + "</td><td>" + round.format((float) (Ghexa.get(i) * 100) / (temphexa)) + "</td><td>" + round.format((float) counthexa.get(i) / totalcount) + "</td><td>" + round.format((float) counthexare.get(i) / seqcount) + "</td><td>" + round.format((float) counthexare.get(i) / bpcount) + "</td></tr>"); } if (mono.isSelected()) { relfreq += (float) countmono.get(i) / totalcount; abfreq += (float) countmonore.get(i) / bpcount; } if (di.isSelected()) { relfreq += (float) countdi.get(i) / totalcount; abfreq += (float) countdire.get(i) / bpcount; } if (tri.isSelected()) { relfreq += (float) counttri.get(i) / totalcount; abfreq += (float) counttrire.get(i) / bpcount; } if (tetra.isSelected()) { relfreq += (float) counttetra.get(i) / totalcount; abfreq += (float) counttetrare.get(i) / bpcount; } if (penta.isSelected()) { relfreq += (float) countpenta.get(i) / totalcount; abfreq += (float) countpentare.get(i) / bpcount; } if (hexa.isSelected()) { relfreq += (float) counthexa.get(i) / totalcount; abfreq += (float) counthexare.get(i) / bpcount; } lt.writeLong(seqcount); lt.writeInt(totalcount); lt.writeLong(bpcount); lt.writeInt(Aperc); lt.writeInt(Tperc); lt.writeInt(Gperc); lt.writeInt(Cperc); stats.println("|TOTAL |" + cell(Integer.toString(totalcount), 7) + "|" + cell(Long.toString(bpcount), 12) + "|" + cell((float) Aperc * 100 / bpcount, 7) + "|" + cell((float) Tperc * 100 / bpcount, 7) + "|" + cell((float) Cperc * 100 / bpcount, 7) + "|" + cell((float) Gperc * 100 / bpcount, 7) + "|" + cell(relfreq, 15) + "|" + cell((float) bpcount / seqcount, 15) + "|" + cell((float) abfreq, 15) + "|"); stats.println( "|_______|_______|____________|_______|_______|_______|_______|_______________|_______________|_______________|"); stats.println("Genome length (bp): " + seqcount); stats.println("Relative Frequency: Count of each motif type / total SSR count"); stats.println("Abundance: bp of each motif type / total sequence bp"); stats.println( "Relative Abundance: bp of each motif type / total microsatellites bp"); stats.println(); stats.println(); stats.close(); lt.close(); html.println("<tr><td><b>TOTAL</b></td><td>" + totalcount + "</td><td>" + bpcount + "</td><td>" + round.format((float) Aperc * 100 / bpcount) + "</td><td>" + round.format((float) Tperc * 100 / bpcount) + "</td><td>" + round.format((float) Cperc * 100 / bpcount) + "</td><td>" + round.format((float) Gperc * 100 / bpcount) + "</td><td>" + round.format((float) relfreq) + "</td><td>" + round.format((float) bpcount / seqcount) + "</td><td>" + round.format((float) abfreq) + "</td></tr></table></html>"); html.close(); } } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } else { if (!gapisnumber && !minisnumber) { msg.showMessageDialog(paneldown, "Fill in Mismatch length for Imperfect SSRs \n and the minimum sequence length before the Mismatch length\n (Integers only)", "Error", JOptionPane.ERROR_MESSAGE); } else { if (!gapisnumber) { msg.showMessageDialog(paneldown, "Fill in Mismatch length for Imperfect SSRs (Integer only)", "Error", JOptionPane.ERROR_MESSAGE); } if (!minisnumber) { msg.showMessageDialog(paneldown, "Fill in the minimum sequence length before the Mismatch length (Integer only)", "Error", JOptionPane.ERROR_MESSAGE); } } } } if (box3.isSelected()) { boolean lenisnumber; boolean gapisnumber; int minlen = 0; int gap = 0; if (!com.isSelected() && !incom.isSelected()) { msg.showMessageDialog(paneldown, "Select a Compound SSR Option", "Error", JOptionPane.ERROR_MESSAGE); } else { try { minlen = Integer.parseInt(score.getText()); lenisnumber = true; } catch (NumberFormatException ex) { lenisnumber = false; } try { gap = Integer.parseInt(maxgapcomp.getText()); gapisnumber = true; } catch (NumberFormatException ex) { gapisnumber = false; } if (lenisnumber && gapisnumber) { if (com.isSelected()) { try { getCompoundPerfectSSRs(organisms, minlen, flag, gap); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } if (incom.isSelected()) { try { getImPerfectCompoundSSRs(organisms, minlen, flag, gap); } catch (SQLException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); //msg.showMessageDialog(paneldown, "Update your selected species", "Error", JOptionPane.ERROR_MESSAGE); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } } else { if (!lenisnumber) { msg.showMessageDialog(paneldown, "Minimum length requires an Integer", "Error", JOptionPane.ERROR_MESSAGE); } if (!gapisnumber) { msg.showMessageDialog(paneldown, "Inter-repeat Region between compound SSRs requires an Integer", "Error", JOptionPane.ERROR_MESSAGE); } } } } if (box1.isSelected() || box2.isSelected() || box3.isSelected() || com.isSelected() || incom.isSelected()) { PrintWriter out = null; PrintWriter html = null; boolean orgs = true; DecimalFormat round = new DecimalFormat("#.###"); //String file=""; for (int i = 0; i < organisms.length; i++) { String file = "organisms/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; File stats = new File(file); if (!stats.exists()) { orgs = false; file = "local/" + organisms[i] + "/stats/" + "summary_statistics" + now.toString().replace(':', '_').replace(' ', '_') + ".txt"; } try { html = new PrintWriter( new FileWriter(file.substring(0, file.indexOf(".")) + ".html", true)); html.println("<html><h1>******* SUMMARY TABLE *******</h1>"); html.println( "<table border=\"1\"><tr><td>type</td><td><b>count</b></td><td><b>bp</b></td><td><b>A%</b></td><td><b>T%</b></td><td><b>C%</b></td><td><b>G%</b></td><td><b>Relative Frequency</b></td><td><b>Abundance</b></td><td><b>Relative Abundance</b></td></tr>"); out = new PrintWriter(new FileWriter(file, true)); out.println("******* SUMMARY TABLE *******"); out.println( " _________________________________________________________________________________________________________________ "); out.println( "| | | | | | | | Relative | | Relative |"); out.println( "| type | count | bp | A% | T% | C% | G% | Frequency | Abundance | Abundance |"); out.println( "|============|=======|============|=======|=======|=======|=======|===============|===============|===============|"); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } //TOTAL long seqcount = 0; int SSRcount = 0; int SSRbpcount = 0; int A = 0, T = 0, G = 0, C = 0; float relfreq = 0; float abfreq = 0; //perfect int pcount = 0; long pbpcount = 0; int Ap = 0, Tp = 0, Gp = 0, Cp = 0; //imperfect int imcount = 0; long imbpcount = 0; int Aim = 0, Tim = 0, Gim = 0, Cim = 0; //compound perfect int ccount = 0; long cbpcount = 0; int Ac = 0, Tc = 0, Gc = 0, Cc = 0; //compound imperfect int cicount = 0; long cibpcount = 0; int Aci = 0, Tci = 0, Gci = 0, Cci = 0; if (box1.isSelected()) { DataInputStream in = null; if (orgs) { try { in = new DataInputStream( new BufferedInputStream(new FileInputStream("organisms/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".perf"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } else { try { in = new DataInputStream(new BufferedInputStream(new FileInputStream("local/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".perf"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } try { seqcount = in.readLong(); pcount = in.readInt(); pbpcount = in.readLong(); Ap = in.readInt(); Tp = in.readInt(); Gp = in.readInt(); Cp = in.readInt(); A += Ap; T += Tp; G += Gp; C += Cp; SSRcount += pcount; SSRbpcount += pbpcount; in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } if (box2.isSelected()) { DataInputStream in = null; if (orgs) { try { in = new DataInputStream( new BufferedInputStream(new FileInputStream("organisms/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".imperf"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } else { try { in = new DataInputStream(new BufferedInputStream(new FileInputStream("local/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".imperf"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } try { seqcount = in.readLong(); imcount = in.readInt(); imbpcount = in.readLong(); Aim = in.readInt(); Tim = in.readInt(); Gim = in.readInt(); Cim = in.readInt(); A += Aim; T += Tim; G += Gim; C += Cim; SSRcount += imcount; SSRbpcount += imbpcount; in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } if (box3.isSelected()) { if (com.isSelected()) { DataInputStream in = null; if (orgs) { try { in = new DataInputStream(new BufferedInputStream( new FileInputStream("organisms/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".compp"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } else { try { in = new DataInputStream(new BufferedInputStream( new FileInputStream("local/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".compp"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } try { seqcount = in.readLong(); ccount = in.readInt(); cbpcount = in.readInt(); Ac = in.readInt(); Tc = in.readInt(); Gc = in.readInt(); Cc = in.readInt(); A += Ac; T += Tc; G += Gc; C += Cc; SSRcount += ccount; SSRbpcount += cbpcount; in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } if (incom.isSelected()) { DataInputStream in = null; if (orgs) { try { in = new DataInputStream(new BufferedInputStream( new FileInputStream("organisms/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".compim"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } else { try { in = new DataInputStream(new BufferedInputStream( new FileInputStream("local/" + organisms[i] + "/data/" + now.toString().replace(':', '_').replace(' ', '_') + ".compim"))); } catch (FileNotFoundException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } try { seqcount = in.readLong(); cicount = in.readInt(); cibpcount = in.readInt(); Aci = in.readInt(); Tci = in.readInt(); Gci = in.readInt(); Cci = in.readInt(); A += Aci; T += Tci; G += Gci; C += Cci; SSRcount += cicount; SSRbpcount += cibpcount; in.close(); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } } if (box1.isSelected()) { relfreq += (float) pcount / SSRcount; abfreq += (float) pbpcount / SSRbpcount; out.printf( "|Perfect |" + cell(Integer.toString(pcount), 7) + "|" + cell(Long.toString(pbpcount), 12) + "|%s|%s|%s|%s|" + cell((float) pcount / SSRcount, 15) + "|" + cell((float) pbpcount / seqcount, 15) + "|" + cell((float) pbpcount / SSRbpcount, 15) + "|\n", cell((float) (Ap * 100) / (SSRbpcount), 7), cell((float) (Tp * 100) / (SSRbpcount), 7), cell((float) (Cp * 100) / (SSRbpcount), 7), cell((float) (Gp * 100) / (SSRbpcount), 7)); out.println( "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>Perfect</b></td><td>" + pcount + "</td><td>" + pbpcount + "</td><td>" + round.format((float) Ap * 100 / SSRbpcount) + "</td><td>" + round.format((float) Tp * 100 / SSRbpcount) + "</td><td>" + round.format((float) Cp * 100 / SSRbpcount) + "</td><td>" + round.format((float) Gp * 100 / SSRbpcount) + "</td><td>" + round.format((float) pcount / SSRcount) + "</td><td>" + round.format((float) pbpcount / seqcount) + "</td><td>" + round.format((float) pbpcount / SSRbpcount) + "</td></tr>"); } if (box2.isSelected()) { relfreq += (float) imcount / SSRcount; abfreq += (float) imbpcount / SSRbpcount; out.printf( "|Imperfect |" + cell(Integer.toString(imcount), 7) + "|" + cell(Long.toString(imbpcount), 12) + "|%s|%s|%s|%s|" + cell((float) imcount / SSRcount, 15) + "|" + cell((float) imbpcount / seqcount, 15) + "|" + cell((float) imbpcount / SSRbpcount, 15) + "|\n", cell((float) (Aim * 100) / (SSRbpcount), 7), cell((float) (Tim * 100) / (SSRbpcount), 7), cell((float) (Cim * 100) / (SSRbpcount), 7), cell((float) (Gim * 100) / (SSRbpcount), 7)); out.println( "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>Imperfect</b></td><td>" + imcount + "</td><td>" + imbpcount + "</td><td>" + round.format((float) Aim * 100 / SSRbpcount) + "</td><td>" + round.format((float) Tim * 100 / SSRbpcount) + "</td><td>" + round.format((float) Cim * 100 / SSRbpcount) + "</td><td>" + round.format((float) Gim * 100 / SSRbpcount) + "</td><td>" + round.format((float) imcount / SSRcount) + "</td><td>" + round.format((float) imbpcount / seqcount) + "</td><td>" + round.format((float) imbpcount / SSRbpcount) + "</td></tr>"); } if (box3.isSelected()) { if (com.isSelected()) { abfreq += (float) cbpcount / SSRbpcount; relfreq += (float) ccount / SSRcount; out.printf( "|Compound Per|" + cell(Integer.toString(ccount), 7) + "|" + cell(Long.toString(cbpcount), 12) + "|%s|%s|%s|%s|" + cell((float) ccount / SSRcount, 15) + "|" + cell((float) cbpcount / seqcount, 15) + "|" + cell((float) cbpcount / SSRbpcount, 15) + "|\n", cell((float) (Ac * 100) / (SSRbpcount), 7), cell((float) (Tc * 100) / (SSRbpcount), 7), cell((float) (Cc * 100) / (SSRbpcount), 7), cell((float) (Gc * 100) / (SSRbpcount), 7)); out.println( "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>Compound Perf.</b></td><td>" + ccount + "</td><td>" + cbpcount + "</td><td>" + round.format((float) Ac * 100 / SSRbpcount) + "</td><td>" + round.format((float) Tc * 100 / SSRbpcount) + "</td><td>" + round.format((float) Cc * 100 / SSRbpcount) + "</td><td>" + round.format((float) Gc * 100 / SSRbpcount) + "</td><td>" + round.format((float) ccount / SSRcount) + "</td><td>" + round.format((float) cbpcount / seqcount) + "</td><td>" + round.format((float) cbpcount / SSRbpcount) + "</td></tr>"); } if (incom.isSelected()) { abfreq += (float) cibpcount / SSRbpcount; relfreq += (float) cicount / SSRcount; out.printf( "|Compound Imp|" + cell(Integer.toString(cicount), 7) + "|" + cell(Long.toString(cibpcount), 12) + "|%s|%s|%s|%s|" + cell((float) cicount / SSRcount, 15) + "|" + cell((float) cibpcount / seqcount, 15) + "|" + cell((float) cibpcount / SSRbpcount, 15) + "|\n", cell((float) (Aci * 100) / (SSRbpcount), 7), cell((float) (Tci * 100) / (SSRbpcount), 7), cell((float) (Cci * 100) / (SSRbpcount), 7), cell((float) (Gci * 100) / (SSRbpcount), 7)); out.println( "|------------|-------|------------|-------|-------|-------|-------|---------------|---------------|---------------|"); html.println("<tr><td><b>Compound Imperf.</b></td><td>" + cicount + "</td><td>" + cibpcount + "</td><td>" + round.format((float) Aci * 100 / SSRbpcount) + "</td><td>" + round.format((float) Tci * 100 / SSRbpcount) + "</td><td>" + round.format((float) Cci * 100 / SSRbpcount) + "</td><td>" + round.format((float) Gci * 100 / SSRbpcount) + "</td><td>" + round.format((float) cicount / SSRcount) + "</td><td>" + round.format((float) cibpcount / seqcount) + "</td><td>" + round.format((float) cibpcount / SSRbpcount) + "</td></tr>"); } } out.println("|TOTAL |" + cell(Integer.toString(SSRcount), 7) + "|" + cell(Long.toString(SSRbpcount), 12) + "|" + cell((float) A * 100 / SSRbpcount, 7) + "|" + cell((float) T * 100 / SSRbpcount, 7) + "|" + cell((float) C * 100 / SSRbpcount, 7) + "|" + cell((float) G * 100 / SSRbpcount, 7) + "|" + cell(relfreq, 15) + "|" + cell((float) SSRbpcount / seqcount, 15) + "|" + cell((float) abfreq, 15) + "|"); out.println( "|____________|_______|____________|_______|_______|_______|_______|_______________|_______________|_______________|"); out.println("Genome length (bp): " + seqcount); out.println("Relative Frequency: Count of each motif type / total SSR count"); out.println("Abundance: bp of each motif type / total sequence bp"); out.println("Relative Abundance: bp of each motif type / total microsatellites bp"); out.println(); out.println(); out.close(); html.println("<tr><td><b>TOTAL</b></td><td>" + SSRcount + "</td><td>" + SSRbpcount + "</td><td>" + round.format((float) A * 100 / SSRbpcount) + "</td><td>" + round.format((float) T * 100 / SSRbpcount) + "</td><td>" + round.format((float) C * 100 / SSRbpcount) + "</td><td>" + round.format((float) G * 100 / SSRbpcount) + "</td><td>" + round.format((float) relfreq) + "</td><td>" + round.format((float) SSRbpcount / seqcount) + "</td><td>" + round.format((float) abfreq) + "</td></tr></table></html>"); html.close(); try { Runtime.getRuntime().exec("notepad " + file); } catch (IOException ex) { Logger.getLogger(StatsSelection.class.getName()).log(Level.SEVERE, null, ex); } } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); selectsp = new JButton("Select new Species"); selectsp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { input_frame frame = new input_frame(); } catch (ClassNotFoundException ex) { Logger.getLogger(updateframe.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(updateframe.class.getName()).log(Level.SEVERE, null, ex); } dispose(); } }); quit = new JButton("Quit"); quit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); tab = new JTabbedPane(); tab.setSize(790, 590); // about us panel ImageIcon image = new ImageIcon("miga.png"); JLabel label = new JLabel("", image, JLabel.CENTER); contact = new JLabel( "<html><b><p>Machine Learning and Knowledge Discovery Group</p><p>Computer Science Department</p><p>Aristotle University of Thessaloniki</p><p> </p><p>In collaboration with the laboratory of</p><p> </p><p>Population Genetics of Animal Organisms</p><p>Department of Genetics, Development and Molecular Biology</p><p>School of Biology</p><p>Aristotle University of Thessaloniki</p><p> </p><p> </p><p>For any comments or information please contact with:</p><p><a href=\"mailto:ikavak@csd.auth.gr\">ikavak@csd.auth.gr</a></p></b></html>"); about = new JPanel(); about.setLayout(new GridBagLayout()); GridBagConstraints ab = new GridBagConstraints(); ab.fill = GridBagConstraints.WEST; ab.weightx = 0.5; ab.weighty = 0.5; ab.gridx = 0; ab.gridy = 0; about.add(label, ab); ab.fill = GridBagConstraints.WEST; ab.weightx = 0.5; ab.weighty = 0.5; ab.gridx = 0; ab.gridy = 1; about.add(contact, ab); //end of about us //below are the rest of th panels paneltop = new JPanel(); TitledBorder t = BorderFactory.createTitledBorder("Select Period"); paneltop.setBorder(t); paneltop.setLayout(new GridBagLayout()); GridBagConstraints pt = new GridBagConstraints(); pt.fill = GridBagConstraints.HORIZONTAL; pt.weightx = 0.5; pt.weighty = 0.5; pt.gridx = 0; pt.gridy = 0; paneltop.add(mono, pt); pt.fill = GridBagConstraints.HORIZONTAL; pt.weightx = 0.5; pt.weighty = 0.5; pt.gridx = 0; pt.gridy = -1; paneltop.add(di, pt); pt.fill = GridBagConstraints.HORIZONTAL; pt.weightx = 0.5; pt.weighty = 0.5; pt.gridx = 0; pt.gridy = -2; paneltop.add(tri, pt); pt.fill = GridBagConstraints.HORIZONTAL; pt.weightx = 0.5; pt.weighty = 0.5; pt.gridx = 0; pt.gridy = -3; paneltop.add(tetra, pt); pt.fill = GridBagConstraints.HORIZONTAL; pt.weightx = 0.5; pt.weighty = 0.5; pt.gridx = 0; pt.gridy = -4; paneltop.add(penta, pt); pt.fill = GridBagConstraints.HORIZONTAL; pt.weightx = 0.5; pt.weighty = 0.5; pt.gridx = 0; pt.gridy = -5; paneltop.add(hexa, pt); panel1 = new JPanel(); TitledBorder title = BorderFactory.createTitledBorder("Type"); panel1.setBorder(title); panel1.setLayout(new GridBagLayout()); GridBagConstraints a = new GridBagConstraints(); a.fill = GridBagConstraints.HORIZONTAL; a.weightx = 0.5; a.weighty = 0.5; a.gridx = 0; a.gridy = 0; panel1.add(select, a); a.fill = GridBagConstraints.HORIZONTAL; a.weightx = 0.5; a.weighty = 0.5; a.gridx = 0; a.gridy = -1; panel1.add(box1, a); a.fill = GridBagConstraints.HORIZONTAL; a.weightx = 0.5; a.weighty = 0.5; a.gridx = 0; a.gridy = -2; panel1.add(box2, a); a.fill = GridBagConstraints.HORIZONTAL; a.weightx = 0.5; a.weighty = 0.5; a.gridx = 0; a.gridy = -3; panel1.add(box3, a); panel2 = new JPanel(); panel2.setVisible(false); TitledBorder title2 = BorderFactory.createTitledBorder("More Options"); panel2.setBorder(title2); panel2.setLayout(new GridBagLayout()); GridBagConstraints b = new GridBagConstraints(); b.fill = GridBagConstraints.HORIZONTAL; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 0; b.gridy = 0; panel2.add(minimumssrlen, b); b.fill = GridBagConstraints.CENTER; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 1; b.gridy = 0; panel2.add(score, b); b.fill = GridBagConstraints.HORIZONTAL; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 0; b.gridy = -1; panel2.add(gapmax, b); b.fill = GridBagConstraints.CENTER; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 1; b.gridy = -1; panel2.add(max, b); b.fill = GridBagConstraints.HORIZONTAL; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 0; b.gridy = -2; panel2.add(minlenpregap, b); b.fill = GridBagConstraints.CENTER; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 1; b.gridy = -2; panel2.add(minpregap, b); b.fill = GridBagConstraints.HORIZONTAL; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 0; b.gridy = -3; panel2.add(gapcomp, b); b.fill = GridBagConstraints.CENTER; b.weightx = 0.5; b.weighty = 0.5; b.gridx = 1; b.gridy = -3; panel2.add(maxgapcomp, b); paneldownleft = new JPanel(); paneldownleft.setVisible(false); TitledBorder titledl = BorderFactory.createTitledBorder("Compound SSR options"); paneldownleft.setBorder(titledl); paneldownleft.setLayout(new GridBagLayout()); GridBagConstraints dl = new GridBagConstraints(); dl.fill = GridBagConstraints.CENTER; dl.weightx = 0.5; dl.weighty = 0.5; dl.gridx = 0; dl.gridy = 0; paneldownleft.add(com, dl); dl.fill = GridBagConstraints.CENTER; dl.weightx = 0.5; dl.weighty = 0.5; dl.gridx = 0; dl.gridy = -1; paneldownleft.add(incom, dl); paneldownright = new JPanel(); paneldownright.setLayout(new GridBagLayout()); GridBagConstraints dr = new GridBagConstraints(); dr.fill = GridBagConstraints.CENTER; dr.weightx = 0.5; dr.weighty = 0.5; dr.gridx = 0; dr.gridy = 0; paneldownright.add(show, dr); dr.fill = GridBagConstraints.CENTER; dr.weightx = 0.5; dr.weighty = 0.5; dr.gridx = 0; dr.gridy = -1; paneldownright.add(selectsp, dr); dr.fill = GridBagConstraints.CENTER; dr.weightx = 0.5; dr.weighty = 0.5; dr.gridx = 0; dr.gridy = -2; paneldownright.add(quit, dr); panelup = new JPanel(); TitledBorder titleup = BorderFactory.createTitledBorder("Statistics"); panelup.setBorder(titleup); panelup.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.5; c.gridx = 0; c.gridy = 0; panelup.add(paneltop, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.5; c.gridx = 1; c.gridy = 0; panelup.add(panel1, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.5; c.gridx = 0; c.gridy = -1; panelup.add(paneldownleft, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.5; c.gridx = 1; c.gridy = -1; panelup.add(panel2, c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.5; c.gridx = 0; c.gridy = -2; panelup.add(paneldownright, c); TitledBorder s = BorderFactory.createTitledBorder("Standardization"); std.setBorder(s); std.add(no_st); std.add(part_st); std.add(full_st); std.setEnabled(false); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.weighty = 0.5; c.gridx = 0; c.gridy = -3; panelup.add(std, c); tab.add(panelup, "Statistics"); panelshow = new JPanel(); TitledBorder ps = BorderFactory.createTitledBorder("Sequence Retrieval"); panelshow.setBorder(ps); panelshow.setLayout(new GridBagLayout()); GridBagConstraints psg = new GridBagConstraints(); panelshowup = new JPanel(); panelshowup.setLayout(new GridBagLayout()); GridBagConstraints p = new GridBagConstraints(); p.fill = GridBagConstraints.WEST; p.weightx = 0.5; p.weighty = 0.5; p.gridx = 0; p.gridy = 0; panelshowup.add(lab, p); panelshowd = new JPanel(); panelshowd.setLayout(new GridBagLayout()); GridBagConstraints pd = new GridBagConstraints(); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 0; pd.gridy = -1; panelshowd.add(startlab, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -1; panelshowd.add(startnum, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 0; pd.gridy = -2; panelshowd.add(endlab, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -2; panelshowd.add(endnum, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 0; pd.gridy = -3; panelshowd.add(titlelab, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -3; panelshowd.add(titlef, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 0; pd.gridy = -4; panelshowd.add(flk, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -4; panelshowd.add(new JLabel(" "), pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 0; pd.gridy = -5; panelshowd.add(flankst, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -5; panelshowd.add(flankstn, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 0; pd.gridy = -6; panelshowd.add(flankend, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -6; panelshowd.add(flankendn, pd); pd.fill = GridBagConstraints.CENTER; pd.weightx = 0.5; pd.weighty = 0.5; pd.gridx = 1; pd.gridy = -7; panelshowd.add(retrieve, pd); psg.fill = GridBagConstraints.CENTER; psg.weightx = 0.5; psg.weighty = 0.5; psg.gridx = 0; psg.gridy = 0; panelshow.add(panelshowup, psg); psg.fill = GridBagConstraints.CENTER; psg.weightx = 0.5; psg.weighty = 0.5; psg.gridx = 0; psg.gridy = -1; panelshow.add(panelshowd, psg); psg.fill = GridBagConstraints.CENTER; psg.weightx = 0.5; psg.weighty = 0.5; psg.gridx = 0; psg.gridy = -2; panelshow.add(sbrText, psg); tab.add(panelshow, "Sequence Retrieval"); tab.add(about, "About us"); add(tab); setVisible(true); }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
public JMenu getViewMenu() { if (viewMenu == null) { viewMenu = new JMenu(viewMenuLabelText); ButtonGroup viewButtonGroup = new ButtonGroup(); for (int i = 0; i < VIEWTYPE_COUNT; i++) { JRadioButtonMenuItem mi = new JRadioButtonMenuItem(); mi.setAction(new ViewTypeAction(i)); viewButtonGroup.add(mi);/*from ww w . j a v a2s . co m*/ viewMenu.add(mi); } updateViewMenu(); } return viewMenu; }
From source file:com.mirth.connect.client.ui.DashboardPanel.java
private void initComponents() { splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); splitPane.setOneTouchExpandable(true); topPanel = new JPanel(); topPanel.setBackground(UIConstants.BACKGROUND_COLOR); dashboardTable = null;/* ww w . ja va 2 s.co m*/ dashboardTableScrollPane = new JScrollPane(); dashboardTableScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); dashboardTableScrollPane.setViewportView(dashboardTable); dashboardTableScrollPane.setDoubleBuffered(true); controlPanel = new JPanel(); controlPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(164, 164, 164))); controlPanel.setPreferredSize(new Dimension(100, 20)); tagFilterButton = new IconButton(); tagFilterButton .setIcon(new ImageIcon(getClass().getResource("/com/mirth/connect/client/ui/images/wrench.png"))); // NOI18N tagFilterButton.setToolTipText("Show Channel Filter"); tagFilterButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { tagFilterButtonActionPerformed(); } }); tagsLabel = new JLabel(); ButtonGroup showStatsButtonGroup = new ButtonGroup(); showCurrentStatsButton = new JRadioButton("Current Statistics"); showCurrentStatsButton.setSelected(true); showCurrentStatsButton .setToolTipText("Show the statistics accumulated since the last time the statistics were reset"); showCurrentStatsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { showCurrentStatsButtonActionPerformed(); } }); showStatsButtonGroup.add(showCurrentStatsButton); showLifetimeStatsButton = new JRadioButton("Lifetime Statistics"); showLifetimeStatsButton .setToolTipText("Show the statistics accumulated over the entire lifetime of the channel"); showLifetimeStatsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { showLifetimeStatsButtonActionPerformed(); } }); showStatsButtonGroup.add(showLifetimeStatsButton); pluginContainerPanel = new JPanel(); controlSeparator = new JSeparator(SwingConstants.VERTICAL); ButtonGroup tableModeButtonGroup = new ButtonGroup(); tableModeGroupsButton = new IconToggleButton(UIConstants.ICON_GROUP); tableModeGroupsButton.setToolTipText("Groups"); tableModeGroupsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { switchTableMode(true); } }); tableModeButtonGroup.add(tableModeGroupsButton); tableModeChannelsButton = new IconToggleButton(UIConstants.ICON_CHANNEL); tableModeChannelsButton.setToolTipText("Channels"); tableModeChannelsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { switchTableMode(false); } }); tableModeButtonGroup.add(tableModeChannelsButton); tabPane = new JTabbedPane(); splitPane.setTopComponent(topPanel); splitPane.setBottomComponent(tabPane); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
@SuppressWarnings("unchecked") protected void changeLookAndFeel() { final JDialog dialog = new JDialog(mainFrame, "Design ndern"); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); Collection<TwoObjectsX<String, String>> lookAndFeels = FunctionsX.asList( new TwoObjectsX<String, String>("Metal", UIManager.getCrossPlatformLookAndFeelClassName()), new TwoObjectsX<String, String>("Betriebssystem Standard", UIManager.getSystemLookAndFeelClassName()), new TwoObjectsX<String, String>("Nimbus", NimbusLookAndFeel.class.getName())); dialog.setLayout(new GridLayout(0, 1)); ButtonGroup b = new ButtonGroup(); for (final TwoObjectsX<String, String> lookAndFeel : lookAndFeels) { JRadioButton rb = new JRadioButton(lookAndFeel.getObjectA()); if (iliasProperties.getLookAndFeel().equals(lookAndFeel.getObjectB())) { rb.setSelected(true);/*from w w w . j ava 2 s .c o m*/ } rb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { UIManager.setLookAndFeel(lookAndFeel.getObjectB()); iliasProperties.setLookAndFeel(lookAndFeel.getObjectB()); saveProperties(iliasProperties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { showError("Fehler beim ndern des Designs", e1); } SwingUtilities.updateComponentTreeUI(mainFrame); SwingUtilities.updateComponentTreeUI(dialog); } }); b.add(rb); dialog.add(rb); } dialog.pack(); dialog.setLocationRelativeTo(mainFrame); dialog.setVisible(true); }