List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
From source file:net.rptools.maptool.launcher.MapToolLauncher.java
private JPanel buildTroubleshootingPanel() { final JPanel p = new JPanel(); p.setLayout(new BorderLayout()); ActionListener levelChange = new ActionListener() { @Override/* w w w. jav a 2 s . com*/ public void actionPerformed(ActionEvent e) { Level x = Level.parse(e.getActionCommand()); if (Level.OFF.equals(x) || Level.INFO.equals(x) || Level.WARNING.equals(x) || Level.SEVERE.equals(x)) log.setLevel(x); } }; JPanel logPanel = new JPanel(); logPanel.setLayout(new GridLayout(0, 1)); logPanel.setBorder(new TitledBorder(new LineBorder(Color.BLACK), CopiedFromOtherJars.getText("msg.logDetailPanel.border"))); //$NON-NLS-1$ logPanel.setAlignmentX(Component.LEFT_ALIGNMENT); ButtonGroup logGroup = new ButtonGroup(); for (Level type : new Level[] { Level.OFF, Level.INFO, Level.WARNING, Level.SEVERE }) { JRadioButton jrb = new JRadioButton(type.toString()); jrb.setActionCommand(type.toString()); jrb.addActionListener(levelChange); jrb.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), jrb.getBorder())); logPanel.add(jrb); logGroup.add(jrb); if (type == Level.WARNING) { jrb.setSelected(true); log.setLevel(type); } } jcbEnableAssertions.setAlignmentX(Component.LEFT_ALIGNMENT); jcbEnableAssertions.setText(CopiedFromOtherJars.getText("msg.info.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.enableAssertions")); //$NON-NLS-1$ jcbEnableAssertions.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { if (!extraArgs.contains(ASSERTIONS_OPTION)) { extraArgs = (ASSERTIONS_OPTION + " " + extraArgs); //$NON-NLS-1$ } } else if (e.getStateChange() == ItemEvent.DESELECTED) { extraArgs = extraArgs.replace(ASSERTIONS_OPTION, ""); //$NON-NLS-1$ } extraArgs = extraArgs.trim(); jtfArgs.setText(extraArgs); updateCommand(); } }); p.add(logPanel, BorderLayout.NORTH); Box other = new Box(BoxLayout.PAGE_AXIS); other.add(jcbEnableAssertions); other.add(Box.createVerticalGlue()); p.add(other, BorderLayout.CENTER); return p; }
From source file:it.isislab.dmason.tools.batch.BatchWizard.java
/** * Create the frame./*from w w w . j av a2 s.co m*/ */ 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:de.dmarcini.submatix.pclogger.gui.ProgramProperetysDialog.java
/** * Alle sprachabhngigen String setzen Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * /* w w w .j a v a 2 s . co m*/ * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 03.08.2012 * @return alles ok? */ public int setLanguageStrings() { try { setTitle(LangStrings.getString("ProgramProperetysDialog.title.text")); databaseDirLabel.setText(LangStrings.getString("ProgramProperetysDialog.databaseDirLabel.text")); logfileLabel.setText(LangStrings.getString("ProgramProperetysDialog.logFileLabel.text")); databaseDirTextField.setToolTipText( LangStrings.getString("ProgramProperetysDialog.databaseDirTextField.tooltiptext")); logfileNameTextField.setToolTipText( LangStrings.getString("ProgramProperetysDialog.logfileNameTextField.tooltiptext")); moveDataCheckBox.setText(LangStrings.getString("ProgramProperetysDialog.moveDataCheckBox.text")); moveDataCheckBox .setToolTipText(LangStrings.getString("ProgramProperetysDialog.moveDataCheckBox.tooltiptext")); btnCancel.setText(LangStrings.getString("ProgramProperetysDialog.btnCancel.text")); btnCancel.setToolTipText(LangStrings.getString("ProgramProperetysDialog.btnCancel.tooltiptext")); btnOk.setText(LangStrings.getString("ProgramProperetysDialog.btnOk.text")); btnOk.setToolTipText(LangStrings.getString("ProgramProperetysDialog.btnOk.tooltiptext")); ((TitledBorder) (pahtsPanel.getBorder())) .setTitle(" " + LangStrings.getString("ProgramProperetysDialog.pathBorderTitle.text") + " "); ((TitledBorder) (unitsPanel.getBorder())) .setTitle(" " + LangStrings.getString("ProgramProperetysDialog.unitsBorderTitle.text") + " "); defaultUnitsLabel.setText(LangStrings.getString("ProgramProperetysDialog.defaultUnitsLabel.text")); metricUnitsLabel.setText(LangStrings.getString("ProgramProperetysDialog.metricUnitsLabel.text")); imperialUnitsLabel.setText(LangStrings.getString("ProgramProperetysDialog.imperialUnitsLabel.text")); approveLogButtonText = LangStrings.getString("ProgramProperetysDialog.approveLogButtonText.text"); approveLogButtonTooltip = LangStrings.getString("ProgramProperetysDialog.approveLogButtonTooltip.text"); fileChooserLogTitle = LangStrings.getString("ProgramProperetysDialog.fileChooserLogTitle.text"); approveDirButtonText = LangStrings.getString("ProgramProperetysDialog.approveDirButtonText.text"); approveDirButtonTooltip = LangStrings.getString("ProgramProperetysDialog.approveDirButtonTooltip.text"); fileChooserDirTitle = LangStrings.getString("ProgramProperetysDialog.fileChooserDirTitle.text"); fileChooserExportDirTitle = LangStrings .getString("ProgramProperetysDialog.fileChooserExportDirTitle.text"); exportDirLabel.setText(LangStrings.getString("ProgramProperetysDialog.exportDirLabel.text")); exportDirTextField.setToolTipText( LangStrings.getString("ProgramProperetysDialog.exportDirTextField.tooltiptext")); defaultUnitsRadioButton = new JRadioButton( LangStrings.getString("ProgramPropertysDialog.defaultUnitsRadioButton.text")); //$NON-NLS-1$ metricUnitsRadioButton = new JRadioButton( LangStrings.getString("ProgramPropertysDialog.metricUnitsRadioButton.text")); imperialUnitsRadioButton = new JRadioButton( LangStrings.getString("ProgramPropertysDialog.imperialUnitsRadioButton.text")); } catch (NullPointerException ex) { System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); return (-1); } catch (MissingResourceException ex) { System.out.println( "ERROR set language strings - the given key can be found <" + ex.getMessage() + "> ABORT!"); return (0); } catch (ClassCastException ex) { System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); return (0); } return (1); }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
@SuppressWarnings("serial") private JPanel createParamsweepGUI() { // left//from w w w. j a v a2 s . co m parameterList = new JList(); parameterList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); new ListAction(parameterList, new AbstractAction() { public void actionPerformed(final ActionEvent event) { final AvailableParameter selectedParameter = (AvailableParameter) parameterList.getSelectedValue(); addParameterToTree(new AvailableParameter[] { selectedParameter }, parameterTreeBranches.get(0)); enableDisableParameterCombinationButtons(); } }); parameterList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!parameterList.isSelectionEmpty()) { boolean success = true; if (editedNode != null) success = modify(); if (success) { cancelAllSelectionBut(parameterList); resetSettings(); updateDescriptionField(parameterList.getSelectedValues()); enableDisableParameterCombinationButtons(); } else parameterList.clearSelection(); } } }); final JScrollPane parameterListPane = new JScrollPane(parameterList); parameterListPane.setBorder(BorderFactory.createTitledBorder("")); // for rounded border parameterListPane.setPreferredSize(new Dimension(300, 300)); final JPanel parametersPanel = FormsUtils.build("p ' p:g", "[DialogBorder]00||" + "12||" + "34||" + // "56||" + "55||" + "66 f:p:g", new FormsUtils.Separator("<html><b>General parameters</b></html>"), NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsFieldPSW, NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT, numberTimestepsIgnoredPSW, // UPDATE_CHARTS_LABEL_TEXT,onLineChartsCheckBoxPSW, new FormsUtils.Separator("<html><b>Model parameters</b></html>"), parameterListPane).getPanel(); combinationsPanel = new JPanel(new GridLayout(0, 1, 5, 5)); combinationsScrPane = new JScrollPane(combinationsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); combinationsScrPane.setBorder(null); combinationsScrPane.setPreferredSize(new Dimension(550, 500)); parameterDescriptionLabel = new JXLabel(); parameterDescriptionLabel.setLineWrap(true); parameterDescriptionLabel.setVerticalAlignment(SwingConstants.TOP); final JScrollPane descriptionScrollPane = new JScrollPane(parameterDescriptionLabel); descriptionScrollPane.setBorder(BorderFactory.createTitledBorder(null, "Description", TitledBorder.LEADING, TitledBorder.BELOW_TOP)); descriptionScrollPane.setPreferredSize( new Dimension(PARAMETER_DESCRIPTION_LABEL_WIDTH, PARAMETER_DESCRIPTION_LABEL_HEIGHT)); descriptionScrollPane.setViewportBorder(null); final JButton addNewBoxButton = new JButton("Add new combination"); addNewBoxButton.setActionCommand(ACTIONCOMMAND_ADD_BOX); final JPanel left = FormsUtils.build("p ~ f:p:g ~ p", "011 f:p:g ||" + "0_2 p", parametersPanel, combinationsScrPane, addNewBoxButton).getPanel(); left.setBorder(BorderFactory.createTitledBorder(null, "Specify parameter combinations", TitledBorder.LEADING, TitledBorder.BELOW_TOP)); Style.registerCssClasses(left, Dashboard.CSS_CLASS_COMMON_PANEL); final JPanel leftAndDesc = new JPanel(new BorderLayout()); leftAndDesc.add(left, BorderLayout.CENTER); leftAndDesc.add(descriptionScrollPane, BorderLayout.SOUTH); Style.registerCssClasses(leftAndDesc, Dashboard.CSS_CLASS_COMMON_PANEL); // right editedParameterText = new JLabel(ORIGINAL_TEXT); editedParameterText.setPreferredSize(new Dimension(280, 40)); constDef = new JRadioButton("Constant"); listDef = new JRadioButton("List"); incrDef = new JRadioButton("Increment"); final JPanel rightTop = FormsUtils.build("p:g", "[DialogBorder]0||" + "1||" + "2||" + "3", editedParameterText, constDef, listDef, incrDef).getPanel(); Style.registerCssClasses(rightTop, Dashboard.CSS_CLASS_COMMON_PANEL); constDefField = new JTextField(); final JPanel constDefPanel = FormsUtils .build("p ~ p:g", "[DialogBorder]01 p", "Constant value: ", CellConstraints.TOP, constDefField) .getPanel(); listDefArea = new JTextArea(); final JScrollPane listDefScr = new JScrollPane(listDefArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); final JPanel listDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01|" + "_1 f:p:g||" + "_2 p", "Value list: ", listDefScr, "(Separate values with spaces!)").getPanel(); incrStartValueField = new JTextField(); incrEndValueField = new JTextField(); incrStepField = new JTextField(); final JPanel incrDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01||" + "23||" + "45", "Start value: ", incrStartValueField, "End value: ", incrEndValueField, "Step: ", incrStepField) .getPanel(); enumDefBox = new JComboBox(new DefaultComboBoxModel()); final JPanel enumDefPanel = FormsUtils .build("p ~ p:g", "[DialogBorder]01 p", "Constant value:", CellConstraints.TOP, enumDefBox) .getPanel(); submodelTypeBox = new JComboBox(); final JPanel submodelTypePanel = FormsUtils .build("p ~ p:g", "[DialogBorder]01", "Constant value:", CellConstraints.TOP, submodelTypeBox) .getPanel(); fileTextField = new JTextField(); fileTextField.addKeyListener(new KeyAdapter() { public void keyTyped(final KeyEvent e) { final char character = e.getKeyChar(); final File file = new File(Character.isISOControl(character) ? fileTextField.getText() : fileTextField.getText() + character); fileTextField.setToolTipText(file.getAbsolutePath()); } }); fileBrowseButton = new JButton(BROWSE_BUTTON_TEXT); fileBrowseButton.setActionCommand(ACTIONCOMMAND_BROWSE); final JPanel fileDefPanel = FormsUtils .build("p ~ p:g ~p", "[DialogBorder]012", "File:", fileTextField, fileBrowseButton).getPanel(); constDefPanel.setName("CONST"); listDefPanel.setName("LIST"); incrDefPanel.setName("INCREMENT"); enumDefPanel.setName("ENUM"); submodelTypePanel.setName("SUBMODEL"); fileDefPanel.setName("FILE"); Style.registerCssClasses(constDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(listDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(incrDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(enumDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(submodelTypePanel, Dashboard.CSS_CLASS_COMMON_PANEL); Style.registerCssClasses(fileDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL); rightMiddle = new JPanel(new CardLayout()); Style.registerCssClasses(rightMiddle, Dashboard.CSS_CLASS_COMMON_PANEL); rightMiddle.add(constDefPanel, constDefPanel.getName()); rightMiddle.add(listDefPanel, listDefPanel.getName()); rightMiddle.add(incrDefPanel, incrDefPanel.getName()); rightMiddle.add(enumDefPanel, enumDefPanel.getName()); rightMiddle.add(submodelTypePanel, submodelTypePanel.getName()); rightMiddle.add(fileDefPanel, fileDefPanel.getName()); modifyButton = new JButton("Modify"); cancelButton = new JButton("Cancel"); final JPanel rightBottom = FormsUtils .build("p:g p ~ p ~ p:g", "[DialogBorder]_01_ p", modifyButton, cancelButton).getPanel(); Style.registerCssClasses(rightBottom, Dashboard.CSS_CLASS_COMMON_PANEL); final JPanel right = new JPanel(new BorderLayout()); right.add(rightTop, BorderLayout.NORTH); right.add(rightMiddle, BorderLayout.CENTER); right.add(rightBottom, BorderLayout.SOUTH); right.setBorder(BorderFactory.createTitledBorder(null, "Parameter settings", TitledBorder.LEADING, TitledBorder.BELOW_TOP)); Style.registerCssClasses(right, Dashboard.CSS_CLASS_COMMON_PANEL); // the whole paramsweep panel final JPanel content = FormsUtils.build("p:g p", "01 f:p:g", leftAndDesc, right).getPanel(); Style.registerCssClasses(content, Dashboard.CSS_CLASS_COMMON_PANEL); sweepPanel = new JPanel(); Style.registerCssClasses(sweepPanel, Dashboard.CSS_CLASS_COMMON_PANEL); sweepPanel.setLayout(new BorderLayout()); final JScrollPane sp = new JScrollPane(content); sp.setBorder(null); sp.setViewportBorder(null); sweepPanel.add(sp, BorderLayout.CENTER); GUIUtils.createButtonGroup(constDef, listDef, incrDef); constDef.setSelected(true); constDef.setActionCommand("CONST"); listDef.setActionCommand("LIST"); incrDef.setActionCommand("INCREMENT"); constDefField.setActionCommand("CONST_FIELD"); incrStartValueField.setActionCommand("START_FIELD"); incrEndValueField.setActionCommand("END_FIELD"); incrStepField.setActionCommand("STEP_FIELD"); modifyButton.setActionCommand("EDIT"); cancelButton.setActionCommand("CANCEL"); listDefArea.setLineWrap(true); listDefArea.setWrapStyleWord(true); listDefScr.setPreferredSize(new Dimension(100, 200)); GUIUtils.addActionListener(this, modifyButton, cancelButton, constDef, listDef, incrDef, constDefField, incrStartValueField, incrEndValueField, incrStepField, addNewBoxButton, submodelTypeBox, fileBrowseButton); return sweepPanel; }
From source file:atlas.kingj.roi.FrmMain.java
/** * Initialize the contents of the frame. *///from www . j a v a 2 s. c o m private void initialize() { frmTitanRoiCalculator = new JFrame(); frmTitanRoiCalculator.addWindowListener(new FrmTitanRoiCalculatorWindowListener()); frmTitanRoiCalculator.setResizable(false); frmTitanRoiCalculator.setTitle("Titan Production Calculator"); try { frmTitanRoiCalculator.setIconImage(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/logo.png")));//Toolkit.getDefaultToolkit().getImage(FrmMain.class.getResource("/atlas/logo.png"))); } catch (NullPointerException e) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } frmTitanRoiCalculator.setBounds(100, 100, 800, 600); frmTitanRoiCalculator.setLocationRelativeTo(null); frmTitanRoiCalculator.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);//JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); frmTitanRoiCalculator.setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('F'); menuBar.add(mnFile); mntmOpen = new JMenuItem("Open"); mntmOpen.setMnemonic('O'); mntmOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); mntmOpen.addActionListener(new MntmOpenActionListener()); mnFile.add(mntmOpen); mntmSave = new JMenuItem("Save"); mntmSave.setMnemonic('S'); mntmSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); mntmSave.addActionListener(new MntmSaveActionListener()); mnFile.add(mntmSave); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.setMnemonic('X'); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { SaveAndClose(); } }); mntmSaveAll = new JMenuItem("Save All"); mntmSaveAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { SaveAll(); } }); mntmOpenAll = new JMenuItem("Open All"); mntmOpenAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { OpenAll(); } }); mnFile.add(mntmOpenAll); mntmSaveAll.setMnemonic('V'); mnFile.add(mntmSaveAll); mnExport = new JMenu("Export"); mnFile.add(mnExport); mntmSpreadsheet = new JMenuItem("Spreadsheet"); mntmSpreadsheet.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { ResetStatusLabel(); fc = new OpenSaveFileChooser(); fc.setFileFilter(new XLSfilter()); fc.type = 3; int returnVal = fc.showSaveDialog(frmTitanRoiCalculator); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String path = file.getAbsolutePath(); String extension = ".xls"; if (!path.endsWith(extension)) { file = new File(path + extension); } StatusDialog a = new StatusDialog("Generating spreadsheet..."); SaveFileWorker worker = new SaveFileWorker(file, a, false); worker.execute(); a.setLocationRelativeTo(frmTitanRoiCalculator); a.setVisible(true); if (FileSaveError) ShowMessage("File save error"); else if (FileSaveWarning) ShowMessage("File saved, but possible errors."); else ShowMessageSuccess("File saved."); } } }); mnExport.add(mntmSpreadsheet); mnFile.add(mntmExit); JMenu mnView = new JMenu("View"); mnView.setMnemonic('V'); menuBar.add(mnView); RoiData = new ROIData(); mntmUnitConverter = new JMenuItem("Unit Converter"); mntmUnitConverter.setMnemonic('C'); mntmUnitConverter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK)); mntmUnitConverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new UnitConverter(); } }); mnView.add(mntmUnitConverter); mnSettings = new JMenu("Settings"); mnSettings.setMnemonic('E'); menuBar.add(mnSettings); mnUnits = new JMenu("Units"); mnUnits.setMnemonic('U'); mnSettings.add(mnUnits); rdbtnmntmImperial = new JRadioButtonMenuItem("Imperial"); rdbtnmntmImperial.setMnemonic('I'); rdbtnmntmImperial.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK)); rdbtnmntmImperial.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (metric) { // Change units from metric to imperial ChangeUnits(); } } }); mnUnits.add(rdbtnmntmImperial); rdbtnmntmMetric = new JRadioButtonMenuItem("Metric"); rdbtnmntmMetric.setMnemonic('M'); rdbtnmntmMetric.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_MASK)); rdbtnmntmMetric.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!metric) { // Change units from imperial to metric ChangeUnits(); } } }); rdbtnmntmMetric.setSelected(true); mnUnits.add(rdbtnmntmMetric); btnsUnits.add(rdbtnmntmMetric); btnsUnits.add(rdbtnmntmImperial); JMenuItem mntmOptions_1 = new JMenuItem("Options"); mntmOptions_1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_MASK)); mntmOptions_1.setMnemonic('O'); mntmOptions_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Machine machine = null; if (listMachines.getSelectedIndex() > -1) machine = (Machine) listMachines.getSelectedValue(); OptionDialog options = new OptionDialog(environment, machine); options.setLocationRelativeTo(frmTitanRoiCalculator); options.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { UpdateAnalysis(); } }); options.setVisible(true); } }); mnTimings = new JMenu("Timings"); mnSettings.add(mnTimings); mntmSaveToFile = new JMenuItem("Save to File"); mntmSaveToFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OperatorTimings times = environment.timings; fc = new OpenSaveFileChooser(); fc.setFileFilter(new OBJfilter(3)); fc.type = 1; int returnVal = fc.showSaveDialog(frmTitanRoiCalculator); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String path = file.getAbsolutePath(); String extension = ".ser"; if (!path.endsWith(extension)) { file = new File(path + extension); } try { FileOutputStream fout = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(times); oos.close(); ShowMessageSuccess("File saved."); } catch (Exception e1) { JOptionPane.showMessageDialog(frmTitanRoiCalculator, "Error writing file.", "Error", JOptionPane.ERROR_MESSAGE); } } } }); mnTimings.add(mntmSaveToFile); mntmLoadFromFile = new JMenuItem("Load from File"); mntmLoadFromFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fc = new OpenSaveFileChooser(); fc.setFileFilter(new OBJfilter(3)); fc.type = 1; int returnVal = fc.showOpenDialog(frmTitanRoiCalculator); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); try { FileInputStream fin = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(fin); environment.timings = (OperatorTimings) ois.readObject(); ois.close(); ShowMessageSuccess("File loaded."); } catch (Exception e1) { ShowMessage("File error."); } } } }); mnTimings.add(mntmLoadFromFile); mnSettings.add(mntmOptions_1); JMenu mnHelp = new JMenu("Help"); mnHelp.setMnemonic('H'); menuBar.add(mnHelp); JMenuItem mntmInstructions = new JMenuItem("Instructions"); mntmInstructions.setMnemonic('I'); mntmInstructions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { InstructDialog instructions = new InstructDialog(); instructions.setLocationRelativeTo(frmTitanRoiCalculator); instructions.setVisible(true); } }); mnHelp.add(mntmInstructions); JMenuItem mntmAbout = new JMenuItem("About"); mntmAbout.setMnemonic('A'); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { AboutDialog about = new AboutDialog(); about.setLocationRelativeTo(frmTitanRoiCalculator); about.setVisible(true); } }); mnHelp.add(mntmAbout); tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.addChangeListener(TabChangeListener); frmTitanRoiCalculator.getContentPane().add(tabbedPane, BorderLayout.CENTER); pnlMachine = new JPanel(); tabbedPane.addTab("Machine Selection", null, pnlMachine, "Add and configure machine setups"); tabbedPane.setEnabledAt(0, true); pnlMachine.setLayout(null); grpMachines = new JPanel(); grpMachines.setFont(new Font("Tahoma", Font.PLAIN, 11)); grpMachines.setBounds(20, 72, 182, 256); grpMachines.setBorder( new TitledBorder(null, "Machine Type", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlMachine.add(grpMachines); grpMachines.setLayout(null); try { rdbtnER610 = new JRadioButton( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/er610.png")))); rdbtnER610.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/er610_dis.png")))); rdbtnER610.setDisabledSelectedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/er610_dis.png")))); rdbtnER610.setEnabled(false); rdbtnER610.setToolTipText("Titan ER610"); } catch (NullPointerException e1) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } rdbtnER610.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rdbtnClick("ER610"); UpdateMachine(); listMachines.repaint(); } }); rdbtnER610.setSelected(true); rdbtnER610.setBounds(13, 24, 155, 40); try { rdbtnER610.setPressedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/er610_down.png")))); rdbtnER610.setRolloverEnabled(true); rdbtnER610.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/er610_over.png")))); rdbtnER610.setSelectedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/er610_select.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } grpMachines.add(rdbtnER610); try { rdbtnSR9DS = new JRadioButton( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9ds.png")))); rdbtnSR9DS.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9ds_dis.png")))); rdbtnSR9DS.setEnabled(false); rdbtnSR9DS.setToolTipText("Titan SR9-DS"); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } rdbtnSR9DS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rdbtnClick("SR9DS"); UpdateMachine(); listMachines.repaint(); } }); try { rdbtnSR9DS.setPressedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9ds_down.png")))); rdbtnSR9DS.setRolloverEnabled(true); rdbtnSR9DS.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9ds_over.png")))); rdbtnSR9DS.setSelectedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9ds_select.png")))); rdbtnSR9DS.setBounds(13, 68, 155, 40); grpMachines.add(rdbtnSR9DS); rdbtnSR9DT = new JRadioButton( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9dt.png")))); rdbtnSR9DT.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9dt_dis.png")))); rdbtnSR9DT.setEnabled(false); rdbtnSR9DT.setToolTipText("Titan SR9-DT"); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } rdbtnSR9DT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rdbtnClick("SR9DT"); UpdateMachine(); listMachines.repaint(); } }); rdbtnSR9DT.setBounds(13, 112, 155, 40); try { rdbtnSR9DT.setPressedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9dt_down.png")))); rdbtnSR9DT.setRolloverEnabled(true); rdbtnSR9DT.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9dt_over.png")))); rdbtnSR9DT.setSelectedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr9dt_select.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } grpMachines.add(rdbtnSR9DT); try { rdbtnSR800 = new JRadioButton( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr800.png")))); rdbtnSR800.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr800_dis.png")))); rdbtnSR800.setEnabled(false); rdbtnSR800.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { rdbtnClick("SR800"); UpdateMachine(); listMachines.repaint(); } }); rdbtnSR800.setPressedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr800_down.png")))); rdbtnSR800.setRolloverEnabled(true); rdbtnSR800.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr800_over.png")))); rdbtnSR800.setSelectedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/sr800_select.png")))); } catch (IOException e2) { e2.printStackTrace(); } rdbtnSR800.setToolTipText("Titan SR800"); rdbtnSR800.setRolloverEnabled(true); rdbtnSR800.setBounds(13, 156, 155, 40); grpMachines.add(rdbtnSR800); try { rdbtnCustom = new JRadioButton( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/custom.png")))); rdbtnCustom.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/custom_dis.png")))); rdbtnCustom.setEnabled(false); rdbtnCustom.setPressedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/custom_down.png")))); rdbtnCustom.setRolloverEnabled(true); rdbtnCustom.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/custom_over.png")))); rdbtnCustom.setSelectedIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/custom_select.png")))); } catch (IOException e2) { e2.printStackTrace(); } rdbtnCustom.setToolTipText("Custom Machine"); rdbtnCustom.setRolloverEnabled(true); rdbtnCustom.setBounds(13, 200, 155, 40); grpMachines.add(rdbtnCustom); rdbtnCustom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { rdbtnClick("Custom"); UpdateMachine(); ResetStatusLabel(); listMachines.repaint(); } }); rdbtnsMachines.add(rdbtnER610); rdbtnsMachines.add(rdbtnSR9DS); rdbtnsMachines.add(rdbtnSR9DT); rdbtnsMachines.add(rdbtnSR800); rdbtnsMachines.add(rdbtnCustom); grpVariants = new JPanel(); grpVariants.setFont(new Font("Tahoma", Font.PLAIN, 11)); grpVariants.setBounds(20, 339, 482, 112); grpVariants .setBorder(new TitledBorder(null, "Variants", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlMachine.add(grpVariants); grpVariants.setLayout(null); cmbCorepos = new JComboBox(); cmbCorepos.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbCorepos.setToolTipText("Set the core positioning system"); cmbCorepos.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); } }); cmbCorepos.setEnabled(false); cmbCorepos.setBounds(104, 70, 122, 20); grpVariants.add(cmbCorepos); cmbCorepos.setModel(new DefaultComboBoxModel(new String[] { "Manual", "Laser" })); lblCorePositioning = new JLabel("Core Positioning:"); lblCorePositioning.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblCorePositioning.setToolTipText("Set the core positioning system"); lblCorePositioning.setEnabled(false); lblCorePositioning.setHorizontalAlignment(SwingConstants.RIGHT); lblCorePositioning.setBounds(12, 73, 88, 14); grpVariants.add(lblCorePositioning); lblKnifeControl = new JLabel("Knife Control:"); lblKnifeControl.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblKnifeControl.setToolTipText("Set the type of knife positioning system"); lblKnifeControl.setEnabled(false); lblKnifeControl.setHorizontalAlignment(SwingConstants.RIGHT); lblKnifeControl.setBounds(22, 48, 78, 14); grpVariants.add(lblKnifeControl); cmbKnives = new JComboBox(); cmbKnives.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbKnives.setToolTipText("Set the type of knife positioning system"); cmbKnives.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); } }); cmbKnives.setEnabled(false); cmbKnives.setBounds(104, 45, 122, 20); grpVariants.add(cmbKnives); cmbKnives.setModel(new DefaultComboBoxModel(new String[] { "Manual", "Auto" })); cmbUnloader = new JComboBox(); cmbUnloader.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbUnloader.setToolTipText("Set the unloader type"); cmbUnloader.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); } }); cmbUnloader.setEnabled(false); cmbUnloader.setBounds(350, 20, 122, 20); grpVariants.add(cmbUnloader); cmbUnloader.setModel(new DefaultComboBoxModel(new String[] { "Manual", "Pneumatic", "Electric" })); lblUnloader = new JLabel("Unloader:"); lblUnloader.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblUnloader.setToolTipText("Set the unloader type"); lblUnloader.setEnabled(false); lblUnloader.setHorizontalAlignment(SwingConstants.RIGHT); lblUnloader.setBounds(259, 23, 87, 14); grpVariants.add(lblUnloader); cmbSpeed = new JComboBox(); cmbSpeed.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbSpeed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (formReady) UpdateMachine(); } }); cmbSpeed.setEnabled(false); cmbSpeed.setToolTipText("Machine top speed in metres/min"); cmbSpeed.setBounds(104, 20, 122, 20); grpVariants.add(cmbSpeed); cmbSpeed.setModel(new DefaultComboBoxModel(new String[] { "450", "550" })); lblSpeed = new JLabel("Speed:"); lblSpeed.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblSpeed.setToolTipText("Machine top speed in metres/min"); lblSpeed.setEnabled(false); lblSpeed.setHorizontalAlignment(SwingConstants.RIGHT); lblSpeed.setBounds(54, 23, 46, 14); grpVariants.add(lblSpeed); cmbUnwindDrive = new JComboBox(); cmbUnwindDrive.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbUnwindDrive.setToolTipText("Unwind drive type"); cmbUnwindDrive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); } }); cmbUnwindDrive.setEnabled(false); cmbUnwindDrive.setBounds(350, 45, 122, 20); grpVariants.add(cmbUnwindDrive); cmbUnwindDrive.setModel(new DefaultComboBoxModel(new String[] { "Single", "Double" })); lblUnwindDrive = new JLabel("Unwind Drive:"); lblUnwindDrive.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblUnwindDrive.setToolTipText("Unwind drive type"); lblUnwindDrive.setEnabled(false); lblUnwindDrive.setHorizontalAlignment(SwingConstants.RIGHT); lblUnwindDrive.setBounds(259, 48, 87, 14); grpVariants.add(lblUnwindDrive); lblRewindControlLoop = new JLabel("Rewind Control Loop:"); lblRewindControlLoop.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblRewindControlLoop.setToolTipText("Rewind control loop type"); lblRewindControlLoop.setEnabled(false); lblRewindControlLoop.setHorizontalAlignment(SwingConstants.RIGHT); lblRewindControlLoop.setBounds(224, 73, 122, 14); grpVariants.add(lblRewindControlLoop); cmbRewindCtrl = new JComboBox(); cmbRewindCtrl.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbRewindCtrl.setToolTipText("Rewind control loop type"); cmbRewindCtrl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); } }); cmbRewindCtrl.setEnabled(false); cmbRewindCtrl.setBounds(350, 70, 122, 20); grpVariants.add(cmbRewindCtrl); cmbRewindCtrl.setModel(new DefaultComboBoxModel(new String[] { "Open", "Closed" })); listModel = new DefaultListModel(); jobModel = new DefaultListModel(); scheduleModel = new DefaultListModel(); listModel.removeAllElements(); /*listMachines.setModel(new AbstractListModel() { String[] values = new String[] {"ER610: My test 1", "SR9-DS: this is another test", "SR9-DT: third test", "ER610: test 2", "ER610: bla bla", "SR9-DS: this is another test", "SR9-DT: hello", "SR9-DT: third test"}; public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } });*/ JLabel lblMachines = new JLabel("Machines"); lblMachines.setFont(new Font("Tahoma", Font.BOLD, 12)); lblMachines.setBounds(522, 19, 85, 14); pnlMachine.add(lblMachines); btnMachDelete = new JButton(""); try { btnMachDelete .setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete.png")))); btnMachDelete.setRolloverEnabled(true); btnMachDelete.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete_over.png")))); btnMachDelete.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnMachDelete.setToolTipText("Delete machine"); btnMachDelete.setEnabled(false); btnMachDelete.addActionListener(new DeleteButtonListener()); btnMachDelete.setBounds(651, 460, 36, 36); pnlMachine.add(btnMachDelete); btnMachUp = new JButton(""); btnMachUp.setToolTipText("Move machine up"); btnMachUp.setEnabled(false); try { btnMachUp.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up.png")))); btnMachUp.setRolloverEnabled(true); btnMachUp.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up_over.png")))); btnMachUp.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnMachUp.addActionListener(new UpListener()); btnMachUp.setBounds(700, 463, 30, 30); pnlMachine.add(btnMachUp); btnMachDown = new JButton(""); btnMachDown.setToolTipText("Move machine down"); btnMachDown.setEnabled(false); try { btnMachDown.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down.png")))); btnMachDown.setRolloverEnabled(true); btnMachDown.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down_over.png")))); btnMachDown.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnMachDown.addActionListener(new DownListener()); btnMachDown.setBounds(737, 463, 30, 30); pnlMachine.add(btnMachDown); btnMachReset = new JButton("Reset"); btnMachReset.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnMachReset.setEnabled(false); btnMachReset.setToolTipText("Reset the form"); btnMachReset.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { ResetForm(); } }); btnMachReset.setBounds(20, 460, 100, 36); pnlMachine.add(btnMachReset); /*txtMachName.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (e.getKeyCode() == KeyEvent.VK_ENTER) btnAddMachine.doClick(); } });*/ btnNewMachine = new JButton("Add New"); btnNewMachine.setFont(new Font("Tahoma", Font.BOLD, 11)); btnNewMachine.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { formReady = false; ResetStatusLabel(); int index = listMachines.getSelectedIndex(); int size = listModel.getSize(); if (size >= Consts.MACH_LIST_LIMIT) { // Max list size ShowMessage( "Maximum number of machines allocated. Please delete before attempting to add more."); return; } String newName = getUniqueName("Machine"); txtMachName.setText(newName); machine = new Machine(newName); machNames.add(newName.toLowerCase()); //If no selection or if item in last position is selected, //add the new one to end of list, and select new one. if (index == -1 || (index + 1 == size)) { listModel.addElement(machine); listMachines.setSelectedIndex(size); RoiData.energies.add(RoiData.new EnergyData()); RoiData.maintenance.add(RoiData.new MaintData()); listCompare.addSelectionInterval(size, size); //Otherwise insert the new one after the current selection, //and select new one. } else { int[] sel = listCompare.getSelectedIndices(); int[] selection = new int[sel.length + 1]; System.arraycopy(sel, 0, selection, 0, sel.length); listCompare.setSelectedIndices(new int[] {}); listModel.insertElementAt(machine, index + 1); boolean max = false; for (int i = 0; i < selection.length; i++) { if (selection[i] >= index + 1 && !max) { if (i < selection.length - 1) System.arraycopy(selection, i, selection, i + 1, selection.length - i - 1); selection[i] = index + 1; max = true; } else if (selection[i] >= index + 1) selection[i] = selection[i] + 1; } RoiData.energies.add(index + 1, RoiData.new EnergyData()); RoiData.maintenance.add(index + 1, RoiData.new MaintData()); listCompare.setSelectedIndices(selection); //listCompareRoi.setSelectedIndices(selection); listMachines.setSelectedIndex(index + 1); //listCompare.addSelectionInterval(index + 1, index + 1); } ResetStatusLabel(); //UpdateForm(); already triggered in listchanged formReady = true; txtMachName.requestFocusInWindow(); } }); try { btnNewMachine .setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/plus.png")))); } catch (IOException e1) { e1.printStackTrace(); } btnNewMachine.setToolTipText("Add new machine"); btnNewMachine.setBounds(522, 460, 110, 36); pnlMachine.add(btnNewMachine); grpOptions = new JPanel(); grpOptions.setFont(new Font("Tahoma", Font.PLAIN, 11)); grpOptions.setBounds(212, 72, 290, 256); pnlMachine.add(grpOptions); grpOptions.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); grpOptions.setLayout(null); chckbxFlag = new JCheckBox("Flag Detection"); chckbxFlag.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxFlag.setToolTipText("Whether an automatic flag detection system is used"); chckbxFlag.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxFlag.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxFlag.setEnabled(false); chckbxFlag.setBounds(155, 104, 109, 23); grpOptions.add(chckbxFlag); chckbxSpliceTable = new JCheckBox("Splice Table"); chckbxSpliceTable.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxSpliceTable.setToolTipText("Whether a splice table is fitted"); chckbxSpliceTable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxSpliceTable.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxSpliceTable.setEnabled(false); chckbxSpliceTable.setBounds(22, 104, 109, 23); grpOptions.add(chckbxSpliceTable); chckbxAlignmentGuide = new JCheckBox("Alignment Guide"); chckbxAlignmentGuide.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxAlignmentGuide.setToolTipText("Whether an alignment guide is fitted"); chckbxAlignmentGuide.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxAlignmentGuide.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxAlignmentGuide.setEnabled(false); chckbxAlignmentGuide.setBounds(22, 130, 127, 23); grpOptions.add(chckbxAlignmentGuide); chckbxRollConditioning = new JCheckBox("Roll Conditioning"); chckbxRollConditioning.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxRollConditioning.setToolTipText("Whether the machine supports roll conditioning"); chckbxRollConditioning.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxRollConditioning.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxRollConditioning.setEnabled(false); chckbxRollConditioning.setBounds(22, 156, 127, 23); grpOptions.add(chckbxRollConditioning); chckbxTurretSupport = new JCheckBox("Turret Support"); chckbxTurretSupport.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxTurretSupport.setToolTipText("For dual turret machines: extra turret support"); chckbxTurretSupport.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxTurretSupport.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxTurretSupport.setEnabled(false); chckbxTurretSupport.setBounds(22, 182, 127, 23); grpOptions.add(chckbxTurretSupport); chckbxAutostripping = new JCheckBox("Autostripping"); chckbxAutostripping.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxAutostripping.setToolTipText("Whether an autostripping feature is present for reel unloading"); chckbxAutostripping.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxAutostripping.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxAutostripping.setEnabled(false); chckbxAutostripping.setBounds(22, 208, 97, 23); grpOptions.add(chckbxAutostripping); chckbxExtraRewind = new JCheckBox("850mm Rewind"); chckbxExtraRewind.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxExtraRewind.setToolTipText("Extra wide 850mm max diameter rewind support"); chckbxExtraRewind.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxExtraRewind.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxExtraRewind.setEnabled(false); chckbxExtraRewind.setBounds(155, 208, 109, 23); grpOptions.add(chckbxExtraRewind); chckbxAutoCutoff = new JCheckBox("Auto Cut-off"); chckbxAutoCutoff.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxAutoCutoff.setToolTipText("Whether the web is cut automatically when a run completes"); chckbxAutoCutoff.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxAutoCutoff.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxAutoCutoff.setEnabled(false); chckbxAutoCutoff.setBounds(155, 130, 109, 23); grpOptions.add(chckbxAutoCutoff); chckbxAutoTapeCore = new JCheckBox("Auto Tape Core"); chckbxAutoTapeCore.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxAutoTapeCore.setToolTipText("Whether new reels are automatically taped before a run begins"); chckbxAutoTapeCore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxAutoTapeCore.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxAutoTapeCore.setEnabled(false); chckbxAutoTapeCore.setBounds(155, 156, 109, 23); grpOptions.add(chckbxAutoTapeCore); chckbxAutoTapeTail = new JCheckBox("Auto Tape Tail"); chckbxAutoTapeTail.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxAutoTapeTail.setToolTipText("Whether the tails of completed reels are automatically taped down"); chckbxAutoTapeTail.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (formReady) UpdateMachine(); if (!chckbxAutoTapeTail.isSelected()) chckbxSelectAll.setSelected(false); else UpdateSelectAllChckbx(); } }); chckbxAutoTapeTail.setEnabled(false); chckbxAutoTapeTail.setBounds(155, 182, 109, 23); grpOptions.add(chckbxAutoTapeTail); txtMachName = new JTextField(); txtMachName.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtMachName.selectAll(); } }); txtMachName.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent arg0) { } @Override public void insertUpdate(DocumentEvent arg0) { UpdateMachineName(); } @Override public void removeUpdate(DocumentEvent arg0) { UpdateMachineName(); } }); txtMachName.setEnabled(false); txtMachName.setBounds(125, 35, 137, 28); grpOptions.add(txtMachName); txtMachName.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { // text was deleted } public void insertUpdate(DocumentEvent e) { // text was inserted } }); txtMachName.setToolTipText("Enter a name to refer to this particular machine by"); txtMachName.setFont(new Font("Tahoma", Font.BOLD, 12)); txtMachName.setColumns(10); lblMachName = new JLabel("Machine name:"); lblMachName.setToolTipText("Enter a name to refer to this particular machine by"); lblMachName.setEnabled(false); lblMachName.setBounds(26, 36, 91, 24); grpOptions.add(lblMachName); lblMachName.setFont(new Font("Tahoma", Font.PLAIN, 13)); chckbxSelectAll = new JCheckBox("Select All"); chckbxSelectAll.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxSelectAll.setToolTipText("Select all available options"); chckbxSelectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (chckbxSelectAll.isSelected()) { if (chckbxAlignmentGuide.isEnabled()) chckbxAlignmentGuide.setSelected(true); if (chckbxAutoCutoff.isEnabled()) chckbxAutoCutoff.setSelected(true); if (chckbxAutostripping.isEnabled()) chckbxAutostripping.setSelected(true); if (chckbxAutoTapeCore.isEnabled()) chckbxAutoTapeCore.setSelected(true); if (chckbxAutoTapeTail.isEnabled()) chckbxAutoTapeTail.setSelected(true); if (chckbxExtraRewind.isEnabled()) chckbxExtraRewind.setSelected(true); if (chckbxFlag.isEnabled()) chckbxFlag.setSelected(true); if (chckbxRollConditioning.isEnabled()) chckbxRollConditioning.setSelected(true); if (chckbxSpliceTable.isEnabled()) chckbxSpliceTable.setSelected(true); if (chckbxTurretSupport.isEnabled()) chckbxTurretSupport.setSelected(true); } else { chckbxAlignmentGuide.setSelected(false); chckbxAutoCutoff.setSelected(false); chckbxAutostripping.setSelected(false); chckbxAutoTapeCore.setSelected(false); chckbxAutoTapeTail.setSelected(false); chckbxExtraRewind.setSelected(false); chckbxFlag.setSelected(false); chckbxRollConditioning.setSelected(false); chckbxSpliceTable.setSelected(false); chckbxTurretSupport.setSelected(false); } if (formReady) UpdateMachine(); } }); chckbxSelectAll.setEnabled(false); chckbxSelectAll.setBounds(22, 78, 97, 23); grpOptions.add(chckbxSelectAll); lblMachineConfiguration = new JLabel("Machine Configuration"); lblMachineConfiguration.setFont(new Font("Tahoma", Font.BOLD, 18)); lblMachineConfiguration.setBounds(29, 18, 269, 22); pnlMachine.add(lblMachineConfiguration); lblAddNewMachines = new JLabel( "Add new machines to the list on the right, then configure their options and variants below"); lblAddNewMachines.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblAddNewMachines.setBounds(29, 45, 433, 14); pnlMachine.add(lblAddNewMachines); btnCustomMachine = new JButton("Custom Machine Options"); btnCustomMachine.setEnabled(false); btnCustomMachine.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnCustomMachine.setBounds(322, 460, 180, 36); pnlMachine.add(btnCustomMachine); btnCustomMachine.setToolTipText("Edit settings for a custom machine type"); scrollPane = new JScrollPane(); scrollPane.setBorder(null); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBounds(522, 44, 245, 405); pnlMachine.add(scrollPane); panel_6 = new JPanel(); panel_6.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, new Color(192, 192, 192), null, null, null)); panel_6.setBackground(Color.WHITE); panel_6.setToolTipText("Select a machine to edit options, re-order, or delete"); scrollPane.setViewportView(panel_6); panel_6.setLayout(new BorderLayout(0, 0)); //Create the list and put it in a scroll pane. listMachines = new JList(listModel); panel_6.add(listMachines, BorderLayout.NORTH); listMachines.addListSelectionListener(new MachineListSelectionListener()); listMachines.setCellRenderer(new MachineListRenderer()); listMachines.setBorder(null); listMachines.setToolTipText("Select a machine to edit options, re-order, or delete"); listMachines.setFont(new Font("Tahoma", Font.PLAIN, 13)); listMachines.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); btnOverrideDefaultAcceleration = new JButton("Override Default Acceleration"); btnOverrideDefaultAcceleration.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnOverrideDefaultAcceleration .setToolTipText("Set new values for the acceleration/deceleration of this machine"); btnOverrideDefaultAcceleration.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // check list selected listMachines.getSelectedIndex(); } catch (Exception e2) { return; } Machine currMachine = (Machine) listMachines.getSelectedValue(); AccelDecel dialog = new AccelDecel(currMachine); dialog.setLocationRelativeTo(frmTitanRoiCalculator); dialog.setVisible(true); } }); btnOverrideDefaultAcceleration.setEnabled(false); btnOverrideDefaultAcceleration.setBounds(130, 460, 182, 36); pnlMachine.add(btnOverrideDefaultAcceleration); btnCustomMachine.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ResetStatusLabel(); //rdbtnOther.doClick(); MachineBuilder newmach = new MachineBuilder(machine); newmach.setLocationRelativeTo(frmTitanRoiCalculator); newmach.setVisible(true); } }); pnlJob = new JPanel(); tabbedPane.addTab("Job Selection", null, pnlJob, "Add and configure machine jobs"); tabbedPane.setEnabledAt(1, true); pnlJob.setLayout(null); JPanel pnlMaterials = new JPanel(); pnlMaterials.setBounds(280, 72, 227, 124); pnlMaterials.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Material Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlJob.add(pnlMaterials); pnlMaterials.setLayout(null); Material[] materials = { new Material("Custom", 1.0, 20), new Material("Aluminium", 2.7, 40), new Material("Board", 1.3, 80), new Material("Cellophane", 1.5, 20), new Material("HDPE/BOPE", 0.94, 20), new Material("Laminate", 1.0, 20), new Material("LDPE/BOPE", 0.91, 20), new Material("LLDPE", 0.9, 20), new Material("MDPE", 0.925, 20), new Material("Nylon", 1.12, 20), new Material("Polypropylene", 0.91, 20), new Material("Polystyrene", 1.04, 20), new Material("Paper", 0.8, 100), new Material("PEEK", 1.3, 20), new Material("Polyester", 1.4, 20), new Material("PLA", 1.24, 20), new Material("Polyolefin", 0.92, 20), new Material("PSA Label", 1.1, 20), new Material("PVC", 1.36, 20), new Material("Shrink label", 0.91, 20), new Material("Tri. Lam.", 1.1, 20) }; cmbMaterials = new JComboBox(materials); cmbMaterials.setMaximumRowCount(20); cmbMaterials.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (jobFormReady) { Material m = (Material) cmbMaterials.getSelectedItem(); if (!(m.name.equals("Custom"))) { jobFormReady = false; txtThickness.setText(Double.toString(roundTwoDecimals(m.getThickness()))); if (lblGsm.getText().equals("(gsm)")) txtDensity.setText(Double.toString(roundTwoDecimals(m.getDensity()))); else txtDensity .setText(Double.toString(roundTwoDecimals(m.getDensity() * m.getThickness()))); if (!metric) { txtThickness .setText(Double.toString(roundTwoDecimals(Core.MicroToMil(m.getThickness())))); } jobFormReady = true; } UpdateJob(); } } }); cmbMaterials.setEnabled(false); cmbMaterials.setSelectedIndex(0); cmbMaterials.setToolTipText("Choose a preset material"); cmbMaterials.setBounds(81, 26, 117, 22); pnlMaterials.add(cmbMaterials); lblPresets = new JLabel("Presets:"); lblPresets.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPresets.setToolTipText("Choose a preset material"); lblPresets.setEnabled(false); lblPresets.setBounds(37, 29, 40, 15); pnlMaterials.add(lblPresets); lblThickness_1 = new JLabel("Thickness:"); lblThickness_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblThickness_1.setToolTipText("Material thickness"); lblThickness_1.setEnabled(false); lblThickness_1.setHorizontalAlignment(SwingConstants.RIGHT); lblThickness_1.setBounds(7, 61, 70, 14); pnlMaterials.add(lblThickness_1); lblDensity_1 = new JLabel("Density:"); lblDensity_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblDensity_1.setToolTipText("Material density (per volume, not area)"); lblDensity_1.setEnabled(false); lblDensity_1.setHorizontalAlignment(SwingConstants.RIGHT); lblDensity_1.setBounds(31, 86, 46, 14); pnlMaterials.add(lblDensity_1); txtThickness = new JTextField(); txtThickness.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtThickness.selectAll(); } }); txtThickness.setEnabled(false); txtThickness.getDocument().addDocumentListener(new JobInputChangeListener()); txtThickness.setToolTipText("Material thickness"); txtThickness.setText("20"); txtThickness.setBounds(81, 58, 86, 20); pnlMaterials.add(txtThickness); txtThickness.setColumns(10); txtDensity = new JTextField(); txtDensity.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtDensity.selectAll(); } }); txtDensity.setEnabled(false); txtDensity.getDocument().addDocumentListener(new JobInputChangeListener()); txtDensity.setToolTipText("Material density (per volume, not area)"); txtDensity.setText("0.92"); txtDensity.setBounds(81, 83, 86, 20); pnlMaterials.add(txtDensity); txtDensity.setColumns(10); lblmicro0 = new JLabel("(\u00B5m)"); lblmicro0.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblmicro0.setEnabled(false); lblmicro0.setBounds(177, 61, 46, 14); pnlMaterials.add(lblmicro0); lblgm3 = new JLabel("(g/cm )"); lblgm3.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblgm3.setEnabled(false); lblgm3.setBounds(177, 86, 46, 14); pnlMaterials.add(lblgm3); label_3 = new JLabel("3"); label_3.setEnabled(false); label_3.setFont(new Font("Tahoma", Font.PLAIN, 8)); label_3.setBounds(204, 83, 14, 14); pnlMaterials.add(label_3); JPanel pnlJobs = new JPanel(); pnlJobs.setBounds(20, 168, 250, 283); pnlJobs.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Rewind Settings", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); pnlJob.add(pnlJobs); pnlJobs.setLayout(null); lblTargetRewindLength = new JLabel("Rewind Output:"); lblTargetRewindLength.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblTargetRewindLength.setToolTipText("Quantity of rewind output"); lblTargetRewindLength.setEnabled(false); lblTargetRewindLength.setHorizontalAlignment(SwingConstants.RIGHT); lblTargetRewindLength.setBounds(17, 197, 88, 14); pnlJobs.add(lblTargetRewindLength); lblSlitWidth = new JLabel("Slit Width:"); lblSlitWidth.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblSlitWidth.setToolTipText("Width of each output reel"); lblSlitWidth.setEnabled(false); lblSlitWidth.setHorizontalAlignment(SwingConstants.RIGHT); lblSlitWidth.setBounds(46, 60, 59, 14); pnlJobs.add(lblSlitWidth); lblSlitCount = new JLabel("Reel Count:"); lblSlitCount.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblSlitCount.setToolTipText("Number of reels per set at the output"); lblSlitCount.setEnabled(false); lblSlitCount.setHorizontalAlignment(SwingConstants.RIGHT); lblSlitCount.setBounds(46, 33, 59, 14); pnlJobs.add(lblSlitCount); lblTrimtotal = new JLabel("Trim (total):"); lblTrimtotal.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblTrimtotal.setToolTipText("The trim resulting from the given slit widths"); lblTrimtotal.setEnabled(false); lblTrimtotal.setHorizontalAlignment(SwingConstants.RIGHT); lblTrimtotal.setBounds(20, 114, 85, 14); pnlJobs.add(lblTrimtotal); txtSlits = new JTextField(); txtSlits.setToolTipText("Number of reels per set at the output"); txtSlits.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtSlits.selectAll(); } }); txtSlits.getDocument().addDocumentListener(new JobInputChangeListener()); txtSlits.setEnabled(false); txtSlits.setText("1"); txtSlits.setBounds(109, 30, 86, 20); pnlJobs.add(txtSlits); txtSlits.setColumns(10); txtSlitWidth = new JTextField(); txtSlitWidth.setToolTipText("Width of each output reel"); txtSlitWidth.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtSlitWidth.selectAll(); } }); txtSlitWidth.getDocument().addDocumentListener(new JobInputChangeListener()); txtSlitWidth.setEnabled(false); txtSlitWidth.setText("1350"); txtSlitWidth.setBounds(109, 58, 86, 20); pnlJobs.add(txtSlitWidth); txtSlitWidth.setColumns(10); txtRewindAmount = new JTextField(); txtRewindAmount.setToolTipText("Quantity of rewind output"); txtRewindAmount.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtRewindAmount.selectAll(); } }); txtRewindAmount.getDocument().addDocumentListener(new JobInputChangeListener()); txtRewindAmount.setEnabled(false); txtRewindAmount.setName("RewindLength"); txtRewindAmount.setText("1000"); txtRewindAmount.setBounds(109, 194, 86, 20); pnlJobs.add(txtRewindAmount); txtRewindAmount.setColumns(10); lblTrim = new JLabel("0 mm"); lblTrim.setToolTipText("The trim resulting from the given slit widths"); lblTrim.setEnabled(false); lblTrim.setBounds(111, 114, 65, 14); pnlJobs.add(lblTrim); cmbRewindCore = new JComboBox(); cmbRewindCore.setToolTipText("Core diameter of rewind reels"); ((JTextField) cmbRewindCore.getEditor().getEditorComponent()).getDocument() .addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateJob(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateJob(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); /*cmbRewindCore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateJob(jobIndex); } });*/ cmbRewindCore.setEnabled(false); cmbRewindCore.setModel(new DefaultComboBoxModel(Consts.REWIND_CORE_MM)); cmbRewindCore.setSelectedIndex(1); cmbRewindCore.setBounds(109, 137, 87, 20); pnlJobs.add(cmbRewindCore); cmbRewindCore.setEditable(true); lblRewindCoremm = new JLabel("Rewind Core:"); lblRewindCoremm.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblRewindCoremm.setToolTipText("Core diameter of rewind reels"); lblRewindCoremm.setEnabled(false); lblRewindCoremm.setBounds(40, 140, 65, 14); pnlJobs.add(lblRewindCoremm); lblPer_1 = new JLabel("per:"); lblPer_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPer_1.setToolTipText("Set whether rewind output is measured per reel or per set"); lblPer_1.setEnabled(false); lblPer_1.setBounds(85, 248, 20, 14); pnlJobs.add(lblPer_1); cmbJobDomain = new JComboBox(); cmbJobDomain.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateSetReel(); //UpdateJob(); } }); cmbJobDomain.setEnabled(false); cmbJobDomain.setToolTipText("Set whether rewind output is measured per reel or per set"); cmbJobDomain.setModel(new DefaultComboBoxModel(new String[] { "Reel", "Set" })); cmbJobDomain.setBounds(109, 246, 95, 20); pnlJobs.add(cmbJobDomain); lblmm3 = new JLabel("(mm)"); lblmm3.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblmm3.setEnabled(false); lblmm3.setBounds(205, 61, 27, 14); pnlJobs.add(lblmm3); lblmm2 = new JLabel("(mm)"); lblmm2.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblmm2.setEnabled(false); lblmm2.setBounds(206, 140, 27, 14); pnlJobs.add(lblmm2); pnlUnwinds = new JPanel(); pnlUnwinds.setLayout(null); pnlUnwinds.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Unwind Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlUnwinds.setBounds(280, 207, 227, 162); pnlJob.add(pnlUnwinds); lblUnwindLength = new JLabel("Unwind Size:"); lblUnwindLength.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblUnwindLength.setToolTipText("Quantity of material per mother roll"); lblUnwindLength.setEnabled(false); lblUnwindLength.setHorizontalAlignment(SwingConstants.RIGHT); lblUnwindLength.setBounds(21, 104, 66, 14); pnlUnwinds.add(lblUnwindLength); txtUnwindAmount = new JTextField(); txtUnwindAmount.setToolTipText("Quantity of material per mother roll"); txtUnwindAmount.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { txtUnwindAmount.selectAll(); } }); txtUnwindAmount.getDocument().addDocumentListener(new JobInputChangeListener()); txtUnwindAmount.setEnabled(false); txtUnwindAmount.setName("UnwindLength"); txtUnwindAmount.setText("10000"); txtUnwindAmount.setBounds(92, 100, 86, 20); pnlUnwinds.add(txtUnwindAmount); txtUnwindAmount.setColumns(10); lblWebWidthmm = new JLabel("Web Width:"); lblWebWidthmm.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblWebWidthmm.setToolTipText("Width of mother rolls"); lblWebWidthmm.setEnabled(false); lblWebWidthmm.setBounds(31, 29, 57, 14); pnlUnwinds.add(lblWebWidthmm); lblUnwindCoremm = new JLabel("Unwind Core:"); lblUnwindCoremm.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblUnwindCoremm.setToolTipText("Core diameter of mother rolls"); lblUnwindCoremm.setEnabled(false); lblUnwindCoremm.setBounds(22, 54, 66, 14); pnlUnwinds.add(lblUnwindCoremm); cmbUnwindCore = new JComboBox(); cmbUnwindCore.setToolTipText("Core diameter of mother rolls"); ((JTextField) cmbUnwindCore.getEditor().getEditorComponent()).getDocument() .addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateJob(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateJob(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); cmbUnwindCore.setEnabled(false); cmbUnwindCore.setModel(new DefaultComboBoxModel(new String[] { "76", "152", "254" })); cmbUnwindCore.setBounds(92, 51, 86, 20); pnlUnwinds.add(cmbUnwindCore); cmbUnwindCore.setEditable(true); lblmm0 = new JLabel("(mm)"); lblmm0.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblmm0.setEnabled(false); lblmm0.setBounds(189, 29, 32, 14); pnlUnwinds.add(lblmm0); lblmm1 = new JLabel("(mm)"); lblmm1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblmm1.setEnabled(false); lblmm1.setBounds(189, 53, 32, 14); pnlUnwinds.add(lblmm1); pnlEnviron = new JPanel(); tabbedPane.addTab("Job Scheduling", null, pnlEnviron, "Edit the schedule of jobs to be analysed"); tabbedPane.setEnabledAt(2, true); pnlEnviron.setLayout(null); JPanel pnlShifts = new JPanel(); pnlShifts.setLayout(null); pnlShifts.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Shift Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlShifts.setBounds(20, 72, 287, 162); pnlEnviron.add(pnlShifts); JLabel lblShiftLength = new JLabel("Shift Length:"); lblShiftLength.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblShiftLength.setToolTipText("Hours per working shift"); lblShiftLength.setHorizontalAlignment(SwingConstants.RIGHT); lblShiftLength.setBounds(15, 28, 108, 14); pnlShifts.add(lblShiftLength); JLabel lblDayLength = new JLabel("Day Length:"); lblDayLength.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblDayLength.setToolTipText("Working hours per day"); lblDayLength.setHorizontalAlignment(SwingConstants.RIGHT); lblDayLength.setBounds(29, 78, 94, 14); pnlShifts.add(lblDayLength); JLabel lblShiftsDay = new JLabel("Shifts per Day:"); lblShiftsDay.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblShiftsDay.setToolTipText("Shifts per day"); lblShiftsDay.setHorizontalAlignment(SwingConstants.RIGHT); lblShiftsDay.setBounds(15, 53, 108, 14); pnlShifts.add(lblShiftsDay); JLabel lblDays = new JLabel("Days per Year:"); lblDays.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblDays.setToolTipText("Days per year"); lblDays.setHorizontalAlignment(SwingConstants.RIGHT); lblDays.setBounds(0, 106, 123, 14); pnlShifts.add(lblDays); txtShiftLength = new JTextField(); txtShiftLength.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateShifts(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateShifts(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); txtShiftLength.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { txtShiftLength.selectAll(); } }); txtShiftLength.setToolTipText("Hours per working shift"); txtShiftLength.setText("8"); txtShiftLength.setBounds(133, 25, 86, 20); pnlShifts.add(txtShiftLength); txtShiftLength.setColumns(10); txtShiftCount = new JTextField(); txtShiftCount.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateShifts(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateShifts(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); txtShiftCount.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtShiftCount.selectAll(); } }); txtShiftCount.setToolTipText("Shifts per day"); txtShiftCount.setText("3"); txtShiftCount.setBounds(133, 50, 86, 20); pnlShifts.add(txtShiftCount); txtShiftCount.setColumns(10); txtDaysYear = new JTextField(); txtDaysYear.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateShifts(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateShifts(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); txtDaysYear.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtDaysYear.selectAll(); } }); txtDaysYear.setToolTipText("Days per year"); txtDaysYear.setText("250"); txtDaysYear.setBounds(133, 103, 86, 20); pnlShifts.add(txtDaysYear); txtDaysYear.setColumns(10); lblDayLength2 = new JLabel("24 hours"); lblDayLength2.setToolTipText("Working hours per day"); lblDayLength2.setBounds(133, 78, 86, 14); pnlShifts.add(lblDayLength2); lblHoursYear = new JLabel("Hours per Year:"); lblHoursYear.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblHoursYear.setToolTipText("Working hours per year"); lblHoursYear.setBounds(47, 131, 76, 14); pnlShifts.add(lblHoursYear); lblHoursYear2 = new JLabel("6000 hours"); lblHoursYear2.setToolTipText("Working hours per year"); lblHoursYear2.setBounds(133, 131, 86, 14); pnlShifts.add(lblHoursYear2); lblHrs = new JLabel("hrs"); lblHrs.setBounds(229, 28, 46, 14); pnlShifts.add(lblHrs); btnAddAll = new JButton("Add All"); btnAddAll.setToolTipText("Add all jobs to the schedule in order"); btnAddAll.setFont(new Font("Tahoma", Font.BOLD, 11)); btnAddAll.setEnabled(false); try { btnAddAll.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/plus.png")))); } catch (IOException e1) { e1.printStackTrace(); } btnAddAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int i = 0; i < jobModel.getSize(); ++i) { listJobsAvail.setSelectedIndex(i); btnAddJob.doClick(); } } }); btnAddAll.setBounds(327, 460, 110, 36); pnlEnviron.add(btnAddAll); btnAddJob = new JButton(""); btnAddJob.setToolTipText("Add this job to the schedule"); btnAddJob.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //AddToSchedule(listJobsAvail.getSelectedValue()); ResetStatusLabel(); int index = listSchedule.getSelectedIndex(); //int source_index = listJobsAvail.getSelectedIndex(); Job sel = (Job) listJobsAvail.getSelectedValue(); JobItem j = environment.getSchedule().new JobItem(sel, 0, sel.getTotWeight(), sel.getTotLength()); int size = scheduleModel.getSize(); // no limit now there are scroll bars /* if(size >= Consts.JOB_LIST_LIMIT){ // Max list size ShowMessage("Maximum number of jobs scheduled. Please delete before attempting to add more."); return; }*/ //If no selection or if item in last position is selected, //add the new one to end of list, and select new one. if (index == -1 || (index + 1 == size)) { scheduleModel.addElement(sel); listSchedule.setSelectedIndex(size); environment.getSchedule().addJob(j); //Otherwise insert the new one after the current selection, //and select new one. } else { scheduleModel.insertElementAt(sel, index + 1); listSchedule.setSelectedIndex(index + 1); environment.getSchedule().insertJob(j, index + 1); } btnClearSchedule.setEnabled(true); } }); btnAddJob.setEnabled(false); try { btnAddJob.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/add_job.png")))); btnAddJob.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/add_job_dis.png")))); btnAddJob.setRolloverEnabled(true); btnAddJob.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/add_job_over.png")))); } catch (NullPointerException e111) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnAddJob.setBounds(521, 178, 54, 54); pnlEnviron.add(btnAddJob); btnRemoveJob = new JButton(""); btnRemoveJob.setToolTipText("Remove job from schedule"); btnRemoveJob.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ResetStatusLabel(); // Uncomment this code to allow jobs to be saved back after removal from schedule /*if(listSchedule.getSelectedIndex() > -1){ Job j = (Job) listSchedule.getSelectedValue(); String name = j.getName().toLowerCase(); if(!jobNames.contains(name) && !jobModel.contains(j)){ if(jobModel.size() < Consts.JOB_LIST_LIMIT){ jobNames.add(name); jobFormReady = true; int index = -1; if(listJobsAvail.getSelectedIndex() > -1) index = listJobsAvail.getSelectedIndex(); if(index < 0){ jobModel.addElement(j); listJobsAvail.setSelectedIndex(jobModel.size()-1); listJobs.setSelectedIndex(jobModel.size()-1); }else{ jobModel.insertElementAt(j, index+1); listJobsAvail.setSelectedIndex(index+1); listJobs.setSelectedIndex(index+1); } } } }*/ ListSelectionModel lsm = listSchedule.getSelectionModel(); int firstSelected = lsm.getMinSelectionIndex(); int lastSelected = lsm.getMaxSelectionIndex(); scheduleModel.removeRange(firstSelected, lastSelected); environment.getSchedule().remove(firstSelected); int size = scheduleModel.size(); if (size == 0) { //List is empty: disable delete, up, and down buttons. btnClearSchedule.setEnabled(false); btnUpSchedule.setEnabled(false); btnDownSchedule.setEnabled(false); listSchedule.clearSelection(); btnRemoveJob.setEnabled(false); btnViewSchedule.setEnabled(false); } else { //Adjust the selection. if (firstSelected == scheduleModel.getSize()) { //Removed item in last position. firstSelected--; } listSchedule.setSelectedIndex(firstSelected); if (size == 21) { // No longer full list ResetStatusLabel(); } } } }); btnRemoveJob.setEnabled(false); try { btnRemoveJob .setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/del_job.png")))); btnRemoveJob.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/del_job_dis.png")))); btnRemoveJob.setRolloverEnabled(true); btnRemoveJob.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/del_job_over.png")))); } catch (NullPointerException e111) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnRemoveJob.setBounds(520, 243, 54, 54); pnlEnviron.add(btnRemoveJob); lblJobSchedule_1 = new JLabel("Job Schedule"); lblJobSchedule_1.setFont(new Font("Tahoma", Font.BOLD, 18)); lblJobSchedule_1.setBounds(29, 18, 269, 22); pnlEnviron.add(lblJobSchedule_1); lblScheduleJobsTo = new JLabel("Schedule jobs to the right, then set shift options below"); lblScheduleJobsTo.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblScheduleJobsTo.setBounds(29, 45, 279, 14); pnlEnviron.add(lblScheduleJobsTo); lblAvailableJobs_1 = new JLabel("Available Jobs"); lblAvailableJobs_1.setFont(new Font("Tahoma", Font.BOLD, 12)); lblAvailableJobs_1.setBounds(327, 19, 137, 14); pnlEnviron.add(lblAvailableJobs_1); lblJobSchedule_2 = new JLabel("Job Schedule"); lblJobSchedule_2.setFont(new Font("Tahoma", Font.BOLD, 12)); lblJobSchedule_2.setBounds(577, 19, 110, 14); pnlEnviron.add(lblJobSchedule_2); panel = new JPanel(); panel.setLayout(null); panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Schedule Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setBounds(20, 245, 287, 104); pnlEnviron.add(panel); btnViewSchedule = new JButton("View Schedule Diagram"); btnViewSchedule.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnViewSchedule.setToolTipText("View chart of schedule timings"); btnViewSchedule.setEnabled(false); btnViewSchedule.setBounds(33, 27, 170, 29); panel.add(btnViewSchedule); chckbxSimulateScheduleStart = new JCheckBox("Ignore machine config & knife positioning times"); chckbxSimulateScheduleStart.setFont(new Font("Tahoma", Font.PLAIN, 11)); chckbxSimulateScheduleStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!initialising) environment.StartStopTimes = !chckbxSimulateScheduleStart.isSelected(); } }); chckbxSimulateScheduleStart.setToolTipText( "WARNING: Use ONLY when you wish to model the output of a single job over a long time period \u2013 such that the initial set-up time has no material impact on the production volume"); chckbxSimulateScheduleStart.setBounds(30, 62, 251, 18); panel.add(chckbxSimulateScheduleStart); lblhoverForInfo = new JLabel("(hover for info)"); lblhoverForInfo.setToolTipText( "WARNING: Use ONLY when you wish to model the output of a single job over a long time period \u2013 such that the initial set-up time has no material impact on the production volume"); lblhoverForInfo.setForeground(Color.GRAY); lblhoverForInfo.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblhoverForInfo.setBounds(34, 80, 147, 14); panel.add(lblhoverForInfo); btnUpSchedule = new JButton(""); btnUpSchedule.setToolTipText("Move job earlier in schedule"); btnUpSchedule.addActionListener(new ScheduleUpListener()); try { btnUpSchedule.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up.png")))); btnUpSchedule.setRolloverEnabled(true); btnUpSchedule.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up_over.png")))); btnUpSchedule.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnUpSchedule.setEnabled(false); btnUpSchedule.setBounds(700, 463, 30, 30); pnlEnviron.add(btnUpSchedule); btnDownSchedule = new JButton(""); btnDownSchedule.setToolTipText("Move job later in schedule"); btnDownSchedule.addActionListener(new ScheduleDownListener()); try { btnDownSchedule .setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down.png")))); btnDownSchedule.setRolloverEnabled(true); btnDownSchedule.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down_over.png")))); btnDownSchedule.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnDownSchedule.setEnabled(false); btnDownSchedule.setBounds(737, 463, 30, 30); pnlEnviron.add(btnDownSchedule); btnClearSchedule = new JButton("Clear"); btnClearSchedule.setToolTipText("Clear all jobs from the schedule"); btnClearSchedule.setFont(new Font("Tahoma", Font.BOLD, 11)); btnClearSchedule.setEnabled(false); try { btnClearSchedule .setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete.png")))); btnClearSchedule.setRolloverEnabled(true); btnClearSchedule.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete_over.png")))); btnClearSchedule.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnClearSchedule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scheduleModel.removeAllElements(); environment.getSchedule().empty(); } }); btnClearSchedule.setBounds(577, 460, 110, 36); pnlEnviron.add(btnClearSchedule); //listSchedule.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); //listSchedule.setBounds(577, 44, 190, 405); //pnlEnviron.add(listSchedule); btnViewSchedule.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { ScheduleChart ch = new ScheduleChart(environment.getSchedule()); ch.pack(); try { ch.setIconImage(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/logo.png"))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e) { e.printStackTrace(); } ch.setLocationRelativeTo(frmTitanRoiCalculator); ch.setVisible(true); } }); scrlSchedule = new JScrollPane(); scrlSchedule.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrlSchedule.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); scrlSchedule.setBounds(577, 44, 190, 405); scrlSchedule.getVerticalScrollBar().setUnitIncrement(16); pnlEnviron.add(scrlSchedule); panel_8 = new JPanel(); panel_8.setToolTipText("Select job to re-order or remove from schedule"); panel_8.setBackground(Color.WHITE); panel_8.setBorder(null); scrlSchedule.setViewportView(panel_8); panel_8.setLayout(new BorderLayout(0, 0)); listSchedule = new JList(scheduleModel); panel_8.add(listSchedule, BorderLayout.NORTH); listSchedule.setToolTipText("Select job to re-order or remove from schedule"); listSchedule.addListSelectionListener(new ScheduleSelectionListener()); listSchedule.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSchedule.setCellRenderer(new JobListRenderer()); panel_5 = new JPanel(); panel_5.setLayout(null); panel_5.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Notes", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_5.setBounds(20, 360, 287, 136); pnlEnviron.add(panel_5); lblToViewAnalysis = new JLabel("To view analysis for 1 job only, add just that job"); lblToViewAnalysis.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblToViewAnalysis.setBounds(24, 24, 241, 14); panel_5.add(lblToViewAnalysis); lblToTheSchedule = new JLabel("to the schedule."); lblToTheSchedule.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblToTheSchedule.setBounds(24, 38, 241, 14); panel_5.add(lblToTheSchedule); lblToModelMaintenance = new JLabel("To model maintenance or other downtime, edit the"); lblToModelMaintenance.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblToModelMaintenance.setBounds(24, 59, 253, 14); panel_5.add(lblToModelMaintenance); lblShiftOptionsAbove = new JLabel("shift options above. This will affect annual output,"); lblShiftOptionsAbove.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblShiftOptionsAbove.setBounds(24, 73, 253, 14); panel_5.add(lblShiftOptionsAbove); lblButNotThe = new JLabel("but not the rates or efficiencies. For these, use the"); lblButNotThe.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblButNotThe.setBounds(24, 87, 253, 14); panel_5.add(lblButNotThe); lbladvancedTabIn = new JLabel("'advanced' tab in the options menu box."); lbladvancedTabIn.setFont(new Font("Tahoma", Font.PLAIN, 11)); lbladvancedTabIn.setBounds(24, 101, 253, 14); panel_5.add(lbladvancedTabIn); scrollPane_2 = new JScrollPane(); scrollPane_2.setBorder(null); scrollPane_2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane_2.setBounds(327, 44, 190, 405); pnlEnviron.add(scrollPane_2); panel_9 = new JPanel(); panel_9.setToolTipText("Select job to be added"); scrollPane_2.setViewportView(panel_9); panel_9.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); panel_9.setBackground(Color.WHITE); panel_9.setLayout(new BorderLayout(0, 0)); listJobsAvail = new JList(jobModel); panel_9.add(listJobsAvail, BorderLayout.NORTH); listJobsAvail.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "add"); listJobsAvail.getActionMap().put("add", new AddScheduleBtn()); listJobsAvail.setToolTipText("Select job to be added"); listJobsAvail.addListSelectionListener(new JobAvailSelectionListener()); listJobsAvail.setCellRenderer(new JobListRenderer()); listJobsAvail.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listJobsAvail.setBorder(null); pnlCompare = new JPanel(); tabbedPane.addTab("Productivity Comparison", null, pnlCompare, "Productivity comparison data & graphs"); tabbedPane.setEnabledAt(3, true); pnlCompare.setLayout(null); pnlResults = new JPanel(); pnlResults.setBorder( new TitledBorder(null, "Numerical Results", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlResults.setBounds(20, 72, 479, 134); pnlCompare.add(pnlResults); pnlResults.setLayout(null); lblOutputLength = new JLabel("Output length over time period:"); lblOutputLength.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblOutputLength.setEnabled(false); lblOutputLength.setToolTipText("Quantity produced"); lblOutputLength.setBounds(220, 54, 152, 14); pnlResults.add(lblOutputLength); lblOutputWeight = new JLabel("Output weight over time period:"); lblOutputWeight.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblOutputWeight.setEnabled(false); lblOutputWeight.setToolTipText("Quantity produced"); lblOutputWeight.setBounds(220, 79, 162, 14); pnlResults.add(lblOutputWeight); cmbTimeRef = new JComboBox(); cmbTimeRef.setEnabled(false); cmbTimeRef.setToolTipText("Select a time range to display results over"); cmbTimeRef.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Refresh analyses UpdateNumericalAnalysis(); } }); cmbTimeRef.setModel( new DefaultComboBoxModel(new String[] { "Schedule", "Year", "Hour", "Shift", "Day"/*, "Week"*/ })); cmbTimeRef.setBounds(247, 98, 125, 24); pnlResults.add(cmbTimeRef); lblPer = new JLabel("Per:"); lblPer.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPer.setEnabled(false); lblPer.setBounds(220, 103, 20, 14); pnlResults.add(lblPer); lblAverageMmin = new JLabel("Average rate:"); lblAverageMmin.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblAverageMmin.setEnabled(false); lblAverageMmin.setToolTipText("Average quantity processed"); lblAverageMmin.setBounds(20, 54, 95, 14); pnlResults.add(lblAverageMmin); lblNumericsWeight = new JLabel("0.0 tons"); lblNumericsWeight.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblNumericsWeight.setEnabled(false); lblNumericsWeight.setToolTipText("Quantity produced"); lblNumericsWeight.setBounds(380, 79, 89, 14); pnlResults.add(lblNumericsWeight); lblNumericsLength = new JLabel("0.0 metres"); lblNumericsLength.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblNumericsLength.setEnabled(false); lblNumericsLength.setToolTipText("Quantity produced"); lblNumericsLength.setBounds(380, 54, 89, 14); pnlResults.add(lblNumericsLength); lblNumericsRate = new JLabel("0.0 m/hr"); lblNumericsRate.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblNumericsRate.setEnabled(false); lblNumericsRate.setToolTipText("Average quantity processed"); lblNumericsRate.setBounds(128, 54, 82, 14); pnlResults.add(lblNumericsRate); lblEfficiency = new JLabel("Machine running:"); lblEfficiency.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblEfficiency.setEnabled(false); lblEfficiency.setToolTipText("Proportion of total time for which the machine is running"); lblEfficiency.setBounds(20, 104, 95, 14); pnlResults.add(lblEfficiency); cmbMachines = new JComboBox(); cmbMachines.setMaximumRowCount(15); cmbMachines.setFont(new Font("Tahoma", Font.BOLD, 11)); cmbMachines.setEnabled(false); cmbMachines.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateNumericalAnalysis(); } }); cmbMachines.setToolTipText("Select machine"); cmbMachines.setBounds(128, 20, 244, 24); pnlResults.add(cmbMachines); lblMachine = new JLabel("Select Machine:"); lblMachine.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblMachine.setEnabled(false); lblMachine.setToolTipText("Select machine"); lblMachine.setBounds(20, 25, 77, 14); pnlResults.add(lblMachine); lblNumericsEff = new JLabel("0.0 %"); lblNumericsEff.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblNumericsEff.setEnabled(false); lblNumericsEff.setToolTipText("Machine efficiency"); lblNumericsEff.setBounds(128, 104, 65, 14); pnlResults.add(lblNumericsEff); lblscheduletimelbl = new JLabel("Time to run schedule:"); lblscheduletimelbl.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblscheduletimelbl.setToolTipText("Time to run schedule"); lblscheduletimelbl.setEnabled(false); lblscheduletimelbl.setBounds(20, 79, 103, 14); pnlResults.add(lblscheduletimelbl); lblscheduletime = new JLabel("0.0 hr"); lblscheduletime.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblscheduletime.setToolTipText("Time to run schedule"); lblscheduletime.setEnabled(false); lblscheduletime.setBounds(128, 79, 77, 14); pnlResults.add(lblscheduletime); pnlROI = new JPanel(); tabbedPane.addTab("Return on Investment", (Icon) null, pnlROI, "Return on investment comparison and analysis"); pnlROI.setLayout(null); tabbedPane.setEnabledAt(4, true); lblProductivityComparison = new JLabel("Productivity Comparison"); lblProductivityComparison.setFont(new Font("Tahoma", Font.BOLD, 18)); lblProductivityComparison.setBounds(29, 18, 269, 22); pnlCompare.add(lblProductivityComparison); lblSelectMultipleMachines = new JLabel( "Select multiple machines from the list on the right, then compare them below"); lblSelectMultipleMachines.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblSelectMultipleMachines.setBounds(29, 45, 433, 14); pnlCompare.add(lblSelectMultipleMachines); label_2 = new JLabel("Machines"); label_2.setFont(new Font("Tahoma", Font.BOLD, 12)); label_2.setBounds(522, 19, 85, 14); pnlCompare.add(label_2); pnlProdGraph = new JPanel(); pnlProdGraph.setBounds(20, 222, 479, 274); pnlCompare.add(pnlProdGraph); pnlProdGraph.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Graphical Results", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlProdGraph.setLayout(null); btnShowGraph = new JButton("Open Graph"); btnShowGraph.setFont(new Font("Tahoma", Font.BOLD, 11)); btnShowGraph.setToolTipText("Open graph in new window"); btnShowGraph.setEnabled(false); btnShowGraph.setBounds(366, 51, 99, 39); pnlProdGraph.add(btnShowGraph); btnSaveToFile = new JButton("Save to File"); btnSaveToFile.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnSaveToFile.setToolTipText("Save image to disk"); btnSaveToFile.setEnabled(false); btnSaveToFile.addActionListener(SaveActionListener); btnSaveToFile.setBounds(366, 97, 99, 24); pnlProdGraph.add(btnSaveToFile); pnlPreview = new JPanel(); pnlPreview.setBackground(Color.WHITE); pnlPreview.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); pnlPreview.setBounds(21, 51, 335, 205); pnlProdGraph.add(pnlPreview); pnlPreview.setLayout(null); pnlGraph = new ChartPanel(chart); pnlGraph.setBounds(2, 2, 331, 201); //pnlGraph.setPreferredSize(new java.awt.Dimension(243, 171)); pnlPreview.add(pnlGraph); try { picLabel = new JLabel( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/no_preview.png")))); } catch (IOException e2) { e2.printStackTrace(); } picLabel.setBounds(2, 2, 331, 201); pnlPreview.add(picLabel); pnlGraph.setVisible(false); lblPreview = new JLabel("Graph Preview"); lblPreview.setForeground(Color.DARK_GRAY); lblPreview.setFont(new Font("Tahoma", Font.BOLD, 12)); lblPreview.setEnabled(false); lblPreview.setBounds(21, 24, 99, 16); pnlProdGraph.add(lblPreview); lblType = new JLabel("Graph Type:"); lblType.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblType.setEnabled(false); lblType.setToolTipText("Choose measurement type"); lblType.setBounds(184, 26, 65, 14); pnlProdGraph.add(lblType); btnShowTimings = new JButton("Machine Runs"); btnShowTimings.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnShowTimings.setToolTipText("Show timing diagram for a single machine run"); btnShowTimings.setEnabled(false); btnShowTimings.addActionListener(new BtnShowTimingsActionListener()); btnShowTimings.setBounds(366, 201, 99, 24); pnlProdGraph.add(btnShowTimings); btnDowntime = new JButton("Productivity"); btnDowntime.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnDowntime.setToolTipText("View productivity breakdown charts for the selected machines"); btnDowntime.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ShowTimingBreakdown(); } }); btnDowntime.setEnabled(false); btnDowntime.setBounds(366, 232, 99, 24); pnlProdGraph.add(btnDowntime); lblbreakdown1 = new JLabel("Show timing"); lblbreakdown1.setEnabled(false); lblbreakdown1.setBounds(370, 166, 99, 14); pnlProdGraph.add(lblbreakdown1); lblbreakdown2 = new JLabel("breakdown for:"); lblbreakdown2.setEnabled(false); lblbreakdown2.setBounds(370, 182, 99, 14); pnlProdGraph.add(lblbreakdown2); panel_3 = new JPanel(); panel_3.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_3.setBounds(522, 459, 245, 37); pnlCompare.add(panel_3); panel_3.setLayout(null); btnNone = new JButton("None"); btnNone.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnNone.setEnabled(false); btnNone.setBounds(172, 7, 57, 23); panel_3.add(btnNone); btnNone.setToolTipText("Clear machine selection"); btnAll = new JButton("All"); btnAll.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnAll.setEnabled(false); btnAll.setBounds(105, 7, 57, 23); panel_3.add(btnAll); btnAll.setToolTipText("Select all machines"); lblSelect = new JLabel("Select:"); lblSelect.setEnabled(false); lblSelect.setBounds(37, 11, 46, 14); panel_3.add(lblSelect); scrollPane_3 = new JScrollPane(); scrollPane_3.setBorder(null); scrollPane_3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scrollPane_3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane_3.setBounds(522, 44, 245, 405); pnlCompare.add(scrollPane_3); panel_10 = new JPanel(); panel_10.setToolTipText( "Click a machine to select it. Select multiple machines to compare their performance under the chosen job schedule."); panel_10.setBackground(Color.WHITE); scrollPane_3.setViewportView(panel_10); panel_10.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); panel_10.setLayout(new BorderLayout(0, 0)); listCompare = new JList(listModel); panel_10.add(listCompare, BorderLayout.NORTH); listCompare.setCellRenderer(new MachineListRenderer()); listCompare.setToolTipText( "Click a machine to select it. Select multiple machines to compare their performance under the chosen job schedule."); listCompare.setBorder(null); listCompare.addListSelectionListener(new MultiSelectionListener()); btnAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] count = new int[listModel.size()]; for (int i = 0; i < listModel.size(); ++i) count[i] = i; listCompare.setSelectedIndices(count); } }); btnNone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { listCompare.clearSelection(); } }); btnShowGraph.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { // TODO base on cmbGraphType: or not if just using chart /*PieChart test = new PieChart("title","this is a pie chart"); test.pack(); test.setVisible(true); test.setLocationRelativeTo(null);*/ JFrame popGraph = new JFrame(); JFreeChart chartBig = null; try { chartBig = (JFreeChart) chart.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } //chartBig.setTitle("Productivity Comparison"); ChartPanel cpanel = new ChartPanel(chartBig); cpanel.setPreferredSize(new java.awt.Dimension(500, 300)); popGraph.setContentPane(cpanel); try { popGraph.setIconImage(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/logo.png"))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e) { e.printStackTrace(); } popGraph.setTitle("Productivity Graph"); popGraph.setSize(450, 300); popGraph.pack(); popGraph.setVisible(true); popGraph.setLocationRelativeTo(frmTitanRoiCalculator); } }); cmbGraphType = new JComboBox(); cmbGraphType.setMaximumRowCount(10); cmbGraphType.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbGraphType.setEnabled(false); cmbGraphType.setToolTipText("Choose measurement type"); cmbGraphType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Refresh analyses UpdateGraph(); } }); cmbGraphType.setModel(new DefaultComboBoxModel(new String[] { "Schedule Time", "Length per Hour", "Weight per Hour", "Length per Year", "Weight per Year", "Run Percentage" })); cmbGraphType.setSelectedIndex(0); cmbGraphType.setBounds(251, 21, 105, 24); pnlProdGraph.add(cmbGraphType); lblReturnOnInvestment = new JLabel("Return on Investment"); lblReturnOnInvestment.setFont(new Font("Tahoma", Font.BOLD, 18)); lblReturnOnInvestment.setBounds(29, 18, 269, 22); pnlROI.add(lblReturnOnInvestment); lblSelectMultipleMachines_1 = new JLabel( "Select multiple machines from the list on the right, then compare them below"); lblSelectMultipleMachines_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblSelectMultipleMachines_1.setBounds(29, 45, 433, 14); pnlROI.add(lblSelectMultipleMachines_1); lblCompareroiList = new JLabel("Machines"); lblCompareroiList.setFont(new Font("Tahoma", Font.BOLD, 12)); lblCompareroiList.setBounds(522, 19, 85, 14); pnlROI.add(lblCompareroiList); panel_4 = new JPanel(); panel_4.setLayout(null); panel_4.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_4.setBounds(522, 459, 245, 37); pnlROI.add(panel_4); btnROIselectnone = new JButton("None"); btnROIselectnone.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnROIselectnone.setEnabled(false); btnROIselectnone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { listCompareRoi.clearSelection(); } }); btnROIselectnone.setToolTipText("Clear machine selection"); btnROIselectnone.setBounds(172, 7, 57, 23); panel_4.add(btnROIselectnone); btnROIselectall = new JButton("All"); btnROIselectall.setFont(new Font("Tahoma", Font.PLAIN, 11)); btnROIselectall.setEnabled(false); btnROIselectall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { int[] count = new int[listModel.size()]; for (int i = 0; i < listModel.size(); ++i) count[i] = i; listCompareRoi.setSelectedIndices(count); } }); btnROIselectall.setToolTipText("Select all machines"); btnROIselectall.setBounds(105, 7, 57, 23); panel_4.add(btnROIselectall); lblROIselect = new JLabel("Select:"); lblROIselect.setEnabled(false); lblROIselect.setBounds(37, 11, 46, 14); panel_4.add(lblROIselect); tabsROI = new JTabbedPane(JTabbedPane.TOP); tabsROI.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { try { ResetStatusLabel(); } catch (NullPointerException e) { // Form is still initialising return; } int tab = tabsROI.getSelectedIndex(); switch (tab) { case 0: UpdateROIProd(); break; case 1: UpdateROIEnergy(); break; case 2: UpdateROIMaint(); break; case 3: UpdateROIWaste(); break; } } }); tabsROI.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); tabsROI.setBounds(29, 72, 470, 424); pnlROI.add(tabsROI); pnlProdROI = new JPanel(); pnlProdROI.setBackground(Color.WHITE); tabsROI.addTab("Productivity", null, pnlProdROI, "ROI based on productivity"); pnlProdROI.setLayout(null); lblThisToolIlllustrates = new JLabel( "This tool illlustrates the long-term financial benfits of particular machines and options in"); lblThisToolIlllustrates.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblThisToolIlllustrates.setForeground(Color.GRAY); lblThisToolIlllustrates.setBounds(10, 11, 439, 14); pnlProdROI.add(lblThisToolIlllustrates); lblInTermsOf = new JLabel("terms of productivity gains."); lblInTermsOf.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblInTermsOf.setForeground(Color.GRAY); lblInTermsOf.setBounds(10, 27, 317, 14); pnlProdROI.add(lblInTermsOf); pnlGraphProd = new JPanel(); pnlGraphProd.setBackground(Color.WHITE); pnlGraphProd.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); pnlGraphProd.setBounds(10, 100, 439, 230); pnlProdROI.add(pnlGraphProd); pnlGraphProd.setLayout(null); pnlGraphProdInner = new ChartPanel(null); pnlGraphProdInner.setBounds(2, 2, 435, 226); //pnlGraphProd.add(pnlGraphProdInner); try { lblNoGraph = new JLabel( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/no_preview.png")))); } catch (IOException e2) { e2.printStackTrace(); } lblNoGraph.setBounds(2, 2, 435, 226); pnlGraphProd.add(lblNoGraph); lblSellingPrice = new JLabel("Selling price:"); lblSellingPrice.setEnabled(false); lblSellingPrice.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblSellingPrice.setBounds(10, 52, 60, 14); pnlProdROI.add(lblSellingPrice); txtsellingprice = new JTextField(); txtsellingprice.setToolTipText("Average selling price of the material per unit weight"); txtsellingprice.setEnabled(false); txtsellingprice.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { txtsellingprice.selectAll(); } }); txtsellingprice.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent arg0) { } @Override public void insertUpdate(DocumentEvent arg0) { UpdateROIValue(); } @Override public void removeUpdate(DocumentEvent arg0) { UpdateROIValue(); } }); txtsellingprice.setFont(new Font("Tahoma", Font.PLAIN, 11)); txtsellingprice.setBounds(90, 49, 65, 20); pnlProdROI.add(txtsellingprice); txtsellingprice.setColumns(10); lblPerTonne = new JLabel("per tonne"); lblPerTonne.setEnabled(false); lblPerTonne.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPerTonne.setBounds(160, 52, 70, 14); pnlProdROI.add(lblPerTonne); lblContribution = new JLabel("Contribution:"); lblContribution.setEnabled(false); lblContribution.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblContribution.setBounds(10, 75, 70, 14); pnlProdROI.add(lblContribution); txtcontribution = new JTextField(); txtcontribution.setToolTipText("Contribution percentage"); txtcontribution.setEnabled(false); txtcontribution.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtcontribution.selectAll(); } }); txtcontribution.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { } @Override public void insertUpdate(DocumentEvent e) { UpdateROIValue(); } @Override public void removeUpdate(DocumentEvent e) { UpdateROIValue(); } }); txtcontribution.setFont(new Font("Tahoma", Font.PLAIN, 11)); txtcontribution.setBounds(90, 73, 65, 20); pnlProdROI.add(txtcontribution); txtcontribution.setColumns(10); lblpercent = new JLabel("%"); lblpercent.setEnabled(false); lblpercent.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblpercent.setBounds(160, 76, 11, 14); pnlProdROI.add(lblpercent); lblValueAddedlbl = new JLabel("Value added:"); lblValueAddedlbl.setEnabled(false); lblValueAddedlbl.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblValueAddedlbl.setBounds(279, 52, 70, 14); pnlProdROI.add(lblValueAddedlbl); lblvalueadded = new JLabel("\u00A30.00 / tonne"); lblvalueadded.setToolTipText("Value added per unit weight"); lblvalueadded.setEnabled(false); lblvalueadded.setFont(new Font("Tahoma", Font.BOLD, 12)); lblvalueadded.setBounds(279, 71, 170, 20); pnlProdROI.add(lblvalueadded); cmbMarg1 = new JComboBox(); cmbMarg1.setToolTipText("Old machine"); cmbMarg1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateROIProd(); } }); cmbMarg1.setEnabled(false); cmbMarg1.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMarg1.setBounds(10, 359, 111, 20); pnlProdROI.add(cmbMarg1); cmbMarg2 = new JComboBox(); cmbMarg2.setToolTipText("New machine"); cmbMarg2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateROIProd(); } }); cmbMarg2.setEnabled(false); cmbMarg2.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMarg2.setBounds(141, 359, 111, 20); pnlProdROI.add(cmbMarg2); lblMarginalImprovement = new JLabel("\u00A30.00 per annum"); lblMarginalImprovement.setToolTipText("Marginal improvement"); lblMarginalImprovement.setEnabled(false); lblMarginalImprovement.setFont(new Font("Tahoma", Font.BOLD, 13)); lblMarginalImprovement.setBounds(279, 358, 170, 20); pnlProdROI.add(lblMarginalImprovement); lblSelectMachines = new JLabel("Select 2 machines to view the marginal improvement between them:"); lblSelectMachines.setForeground(Color.GRAY); lblSelectMachines.setFont(new Font("Tahoma", Font.BOLD, 11)); lblSelectMachines.setBounds(10, 338, 412, 14); pnlProdROI.add(lblSelectMachines); lblpound1 = new JLabel("\u00A3"); lblpound1.setEnabled(false); lblpound1.setBounds(80, 52, 11, 14); pnlProdROI.add(lblpound1); lblTo = new JLabel("to"); lblTo.setForeground(Color.GRAY); lblTo.setFont(new Font("Tahoma", Font.BOLD, 11)); lblTo.setBounds(125, 362, 16, 14); pnlProdROI.add(lblTo); label = new JLabel("="); label.setForeground(Color.GRAY); label.setFont(new Font("Tahoma", Font.BOLD, 13)); label.setBounds(259, 362, 11, 14); pnlProdROI.add(label); pnlEnergy = new JPanel(); pnlEnergy.setBackground(Color.WHITE); tabsROI.addTab("Energy Efficiency", null, pnlEnergy, "ROI based on machine power usage"); pnlEnergy.setLayout(null); lblThisToolHighlights = new JLabel( "This tool highlights power consumption differences between machines, and the resulting"); lblThisToolHighlights.setForeground(Color.GRAY); lblThisToolHighlights.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblThisToolHighlights.setBounds(10, 11, 439, 14); pnlEnergy.add(lblThisToolHighlights); lblImpactOnFinancial = new JLabel("impact on financial returns."); lblImpactOnFinancial.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblImpactOnFinancial.setForeground(Color.GRAY); lblImpactOnFinancial.setBounds(10, 27, 439, 14); pnlEnergy.add(lblImpactOnFinancial); rdbtnAveragePower = new JRadioButton("Average power"); rdbtnAveragePower.setToolTipText("Select \"average power\" input type"); rdbtnAveragePower.setFont(new Font("Tahoma", Font.PLAIN, 11)); rdbtnAveragePower.setEnabled(false); rdbtnAveragePower.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { ClearPowerTxts(); txtaveragepower.setEnabled(true); txthourlyusage.setEnabled(false); txtannualusage.setEnabled(false); lblKw.setEnabled(true); lblKwh.setEnabled(false); lblKwh_1.setEnabled(false); txtaveragepower.requestFocusInWindow(); UpdateEnergyData(); } }); rdbtnAveragePower.setSelected(true); rdbtnAveragePower.setBackground(Color.WHITE); rdbtnAveragePower.setBounds(349, 44, 109, 23); pnlEnergy.add(rdbtnAveragePower); rdbtnHourlyUsage = new JRadioButton("Hourly usage"); rdbtnHourlyUsage.setToolTipText("Select \"hourly usage\" input type"); rdbtnHourlyUsage.setFont(new Font("Tahoma", Font.PLAIN, 11)); rdbtnHourlyUsage.setEnabled(false); rdbtnHourlyUsage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ClearPowerTxts(); txtaveragepower.setEnabled(false); txthourlyusage.setEnabled(true); txtannualusage.setEnabled(false); lblKw.setEnabled(false); lblKwh.setEnabled(true); lblKwh_1.setEnabled(false); txthourlyusage.requestFocusInWindow(); UpdateEnergyData(); } }); rdbtnHourlyUsage.setBackground(Color.WHITE); rdbtnHourlyUsage.setBounds(349, 70, 109, 23); pnlEnergy.add(rdbtnHourlyUsage); rdbtnAnnualUsage = new JRadioButton("Annual usage"); rdbtnAnnualUsage.setToolTipText("Select \"annual usage\" input type"); rdbtnAnnualUsage.setFont(new Font("Tahoma", Font.PLAIN, 11)); rdbtnAnnualUsage.setEnabled(false); rdbtnAnnualUsage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ClearPowerTxts(); txtaveragepower.setEnabled(false); txthourlyusage.setEnabled(false); txtannualusage.setEnabled(true); lblKw.setEnabled(false); lblKwh.setEnabled(false); lblKwh_1.setEnabled(true); txtannualusage.requestFocusInWindow(); UpdateEnergyData(); } }); rdbtnAnnualUsage.setBackground(Color.WHITE); rdbtnAnnualUsage.setBounds(349, 97, 109, 23); pnlEnergy.add(rdbtnAnnualUsage); rdbtnsPower.add(rdbtnAveragePower); rdbtnsPower.add(rdbtnHourlyUsage); rdbtnsPower.add(rdbtnAnnualUsage); lblEnergyCostl = new JLabel("Energy cost:"); lblEnergyCostl.setEnabled(false); lblEnergyCostl.setFont(new Font("Tahoma", Font.BOLD, 11)); lblEnergyCostl.setBounds(10, 101, 72, 14); pnlEnergy.add(lblEnergyCostl); lblpound2 = new JLabel("\u00A3"); lblpound2.setEnabled(false); lblpound2.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblpound2.setBounds(91, 100, 13, 14); pnlEnergy.add(lblpound2); txtenergycost = new JTextField(); txtenergycost.setToolTipText("Raw energy cost, per kWh"); txtenergycost.setEnabled(false); txtenergycost.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { txtenergycost.selectAll(); } }); txtenergycost.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateROIEnergy(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateROIEnergy(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); txtenergycost.setFont(new Font("Tahoma", Font.PLAIN, 12)); txtenergycost.setBounds(102, 98, 74, 20); pnlEnergy.add(txtenergycost); txtenergycost.setColumns(10); lblPerKwh = new JLabel("per kWh"); lblPerKwh.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPerKwh.setEnabled(false); lblPerKwh.setBounds(179, 101, 46, 14); pnlEnergy.add(lblPerKwh); txtaveragepower = new JTextField(); txtaveragepower.setToolTipText("Average power in kW"); txtaveragepower.setEnabled(false); txtaveragepower.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateEnergyData(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateEnergyData(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); txtaveragepower.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtaveragepower.selectAll(); } }); txtaveragepower.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { if (txtLimitRunSpeed.contains(arg0.getPoint())) { if (!txtaveragepower.isEnabled()) { rdbtnAveragePower.doClick(); } } } }); txtaveragepower.setBounds(233, 47, 86, 20); pnlEnergy.add(txtaveragepower); txtaveragepower.setColumns(10); txthourlyusage = new JTextField(); txthourlyusage.setToolTipText("Average hourly energy usage"); txthourlyusage.setEnabled(false); txthourlyusage.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateEnergyData(); } @Override public void insertUpdate(DocumentEvent e) { UpdateEnergyData(); } @Override public void changedUpdate(DocumentEvent e) { } }); txthourlyusage.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txthourlyusage.selectAll(); } }); txthourlyusage.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { if (txtLimitRunSpeed.contains(arg0.getPoint())) { if (!txthourlyusage.isEnabled()) rdbtnHourlyUsage.doClick(); } } }); txthourlyusage.setColumns(10); txthourlyusage.setBounds(233, 73, 86, 20); pnlEnergy.add(txthourlyusage); txtannualusage = new JTextField(); txtannualusage.setToolTipText("Average annual energy usage"); txtannualusage.setEnabled(false); txtannualusage.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateEnergyData(); } @Override public void insertUpdate(DocumentEvent e) { UpdateEnergyData(); } @Override public void changedUpdate(DocumentEvent e) { } }); txtannualusage.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtannualusage.selectAll(); } }); txtannualusage.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { if (txtLimitRunSpeed.contains(arg0.getPoint())) { if (!txtannualusage.isEnabled()) rdbtnAnnualUsage.doClick(); } } }); txtannualusage.setColumns(10); txtannualusage.setBounds(233, 99, 86, 20); pnlEnergy.add(txtannualusage); cmbMachineEnergy = new JComboBox(); cmbMachineEnergy.setEnabled(false); cmbMachineEnergy.setToolTipText("Select machine to edit"); cmbMachineEnergy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateEnergyView(); } }); cmbMachineEnergy.setBounds(69, 46, 152, 23); pnlEnergy.add(cmbMachineEnergy); lblMachine_1 = new JLabel("Machine:"); lblMachine_1.setEnabled(false); lblMachine_1.setFont(new Font("Tahoma", Font.BOLD, 11)); lblMachine_1.setBounds(10, 50, 59, 14); pnlEnergy.add(lblMachine_1); lblKw = new JLabel("kW"); lblKw.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblKw.setEnabled(false); lblKw.setBounds(323, 50, 15, 14); pnlEnergy.add(lblKw); lblKwh = new JLabel("kWh"); lblKwh.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblKwh.setEnabled(false); lblKwh.setBounds(323, 76, 26, 14); pnlEnergy.add(lblKwh); lblKwh_1 = new JLabel("MWh"); lblKwh_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblKwh_1.setEnabled(false); lblKwh_1.setBounds(323, 102, 26, 14); pnlEnergy.add(lblKwh_1); pnlGraphEnergy = new JPanel(); pnlGraphEnergy.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); pnlGraphEnergy.setBackground(Color.WHITE); pnlGraphEnergy.setBounds(10, 126, 439, 226); pnlEnergy.add(pnlGraphEnergy); pnlGraphEnergy.setLayout(null); try { lblNoGraph2 = new JLabel( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/no_preview.png")))); } catch (IOException e2) { e2.printStackTrace(); } lblNoGraph2.setBounds(2, 2, 435, 222); pnlGraphEnergy.add(lblNoGraph2); lblPleaseSetPower = new JLabel("Please set power usage for each machine"); lblPleaseSetPower.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPleaseSetPower.setEnabled(false); lblPleaseSetPower.setForeground(Color.GRAY); lblPleaseSetPower.setBounds(10, 74, 215, 14); pnlEnergy.add(lblPleaseSetPower); lblMarginalEnergy = new JLabel("\u00A30.00 per annum"); lblMarginalEnergy.setToolTipText("Marginal improvement"); lblMarginalEnergy.setFont(new Font("Tahoma", Font.BOLD, 13)); lblMarginalEnergy.setEnabled(false); lblMarginalEnergy.setBounds(279, 358, 170, 20); pnlEnergy.add(lblMarginalEnergy); label_4 = new JLabel("="); label_4.setForeground(Color.GRAY); label_4.setFont(new Font("Tahoma", Font.BOLD, 13)); label_4.setBounds(259, 362, 11, 14); pnlEnergy.add(label_4); cmbMargEnergy2 = new JComboBox(); cmbMargEnergy2.setToolTipText("New machine"); cmbMargEnergy2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateROIEnergy(); } }); cmbMargEnergy2.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMargEnergy2.setEnabled(false); cmbMargEnergy2.setBounds(141, 359, 111, 20); pnlEnergy.add(cmbMargEnergy2); label_5 = new JLabel("to"); label_5.setForeground(Color.GRAY); label_5.setFont(new Font("Tahoma", Font.BOLD, 11)); label_5.setBounds(125, 362, 16, 14); pnlEnergy.add(label_5); cmbMargEnergy1 = new JComboBox(); cmbMargEnergy1.setToolTipText("Old machine"); cmbMargEnergy1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateROIEnergy(); } }); cmbMargEnergy1.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMargEnergy1.setEnabled(false); cmbMargEnergy1.setBounds(10, 359, 111, 20); pnlEnergy.add(cmbMargEnergy1); pnlMaint = new JPanel(); pnlMaint.setBackground(Color.WHITE); tabsROI.addTab("Maintenance", null, pnlMaint, "ROI based on maintenance costs"); tabsROI.setMnemonicAt(2, 65); pnlMaint.setLayout(null); lblThisToolDemonstrates_1 = new JLabel( "This tool demonstrates the maintenance reduction benefits of machines."); lblThisToolDemonstrates_1.setBounds(10, 11, 421, 14); lblThisToolDemonstrates_1.setForeground(Color.GRAY); lblThisToolDemonstrates_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); pnlMaint.add(lblThisToolDemonstrates_1); lblMaintenanceHoursPer = new JLabel("Annual downtime:"); lblMaintenanceHoursPer.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblMaintenanceHoursPer.setEnabled(false); lblMaintenanceHoursPer.setBounds(10, 64, 86, 14); pnlMaint.add(lblMaintenanceHoursPer); lblRepairCostsPer = new JLabel("Labour costs per hour:"); lblRepairCostsPer.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblRepairCostsPer.setEnabled(false); lblRepairCostsPer.setBounds(255, 36, 111, 14); pnlMaint.add(lblRepairCostsPer); lblPartsCostsPer = new JLabel("Parts costs per year:"); lblPartsCostsPer.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPartsCostsPer.setEnabled(false); lblPartsCostsPer.setBounds(255, 64, 101, 14); pnlMaint.add(lblPartsCostsPer); cmbMachinesmaintenance = new JComboBox(); cmbMachinesmaintenance.setEnabled(false); cmbMachinesmaintenance.setToolTipText("Please set maintenance costs for each machine"); cmbMachinesmaintenance.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ViewMaintCosts(); } }); cmbMachinesmaintenance.setBounds(79, 30, 152, 23); pnlMaint.add(cmbMachinesmaintenance); txtmaintenancehours = new JTextField(); txtmaintenancehours.setToolTipText("Hours per year for which machine is not running due to maintenance"); txtmaintenancehours.setEnabled(false); txtmaintenancehours.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtmaintenancehours.selectAll(); } }); txtmaintenancehours.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateMaintCosts(); } @Override public void insertUpdate(DocumentEvent e) { UpdateMaintCosts(); } @Override public void changedUpdate(DocumentEvent e) { } }); txtmaintenancehours.setBounds(106, 61, 67, 20); pnlMaint.add(txtmaintenancehours); txtmaintenancehours.setColumns(10); txtmaintenanceperhour = new JTextField(); txtmaintenanceperhour.setToolTipText("Hourly labour costs for maintenance"); txtmaintenanceperhour.setEnabled(false); txtmaintenanceperhour.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtmaintenanceperhour.selectAll(); } }); txtmaintenanceperhour.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateMaintCosts(); } @Override public void insertUpdate(DocumentEvent e) { UpdateMaintCosts(); } @Override public void changedUpdate(DocumentEvent e) { } }); txtmaintenanceperhour.setColumns(10); txtmaintenanceperhour.setBounds(382, 33, 67, 20); pnlMaint.add(txtmaintenanceperhour); txtmaintenanceparts = new JTextField(); txtmaintenanceparts.setToolTipText("Annual cost of maintenance parts for this machine"); txtmaintenanceparts.setEnabled(false); txtmaintenanceparts.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtmaintenanceparts.selectAll(); } }); txtmaintenanceparts.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateMaintCosts(); } @Override public void insertUpdate(DocumentEvent e) { UpdateMaintCosts(); } @Override public void changedUpdate(DocumentEvent e) { } }); txtmaintenanceparts.setColumns(10); txtmaintenanceparts.setBounds(382, 61, 67, 20); pnlMaint.add(txtmaintenanceparts); lbltotalmaintcost = new JLabel("\u00A30.00 / year"); lbltotalmaintcost.setToolTipText("Total annual spend on maintenance for this machine (labour + parts)"); lbltotalmaintcost.setForeground(Color.GRAY); lbltotalmaintcost.setEnabled(false); lbltotalmaintcost.setHorizontalAlignment(SwingConstants.LEFT); lbltotalmaintcost.setFont(new Font("Tahoma", Font.BOLD, 11)); lbltotalmaintcost.setBounds(344, 87, 105, 14); pnlMaint.add(lbltotalmaintcost); lblpound10 = new JLabel("\u00A3"); lblpound10.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblpound10.setEnabled(false); lblpound10.setBounds(373, 36, 11, 14); pnlMaint.add(lblpound10); lblpound11 = new JLabel("\u00A3"); lblpound11.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblpound11.setEnabled(false); lblpound11.setBounds(373, 64, 11, 14); pnlMaint.add(lblpound11); pnlGraphMaint = new JPanel(); pnlGraphMaint.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); pnlGraphMaint.setBackground(Color.WHITE); pnlGraphMaint.setBounds(10, 110, 439, 242); pnlMaint.add(pnlGraphMaint); pnlGraphMaint.setLayout(null); try { lblNoGraph3 = new JLabel( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/no_preview.png")))); } catch (IOException e2) { e2.printStackTrace(); } lblNoGraph3.setBounds(2, 2, 435, 238); pnlGraphMaint.add(lblNoGraph3); cmbMargMaint1 = new JComboBox(); cmbMargMaint1.setToolTipText("Old machine"); cmbMargMaint1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateROIMaint(); } }); cmbMargMaint1.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMargMaint1.setEnabled(false); cmbMargMaint1.setBounds(10, 359, 111, 20); pnlMaint.add(cmbMargMaint1); label_8 = new JLabel("to"); label_8.setForeground(Color.GRAY); label_8.setFont(new Font("Tahoma", Font.BOLD, 11)); label_8.setBounds(125, 362, 16, 14); pnlMaint.add(label_8); cmbMargMaint2 = new JComboBox(); cmbMargMaint2.setToolTipText("New machine"); cmbMargMaint2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateROIMaint(); } }); cmbMargMaint2.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMargMaint2.setEnabled(false); cmbMargMaint2.setBounds(141, 359, 111, 20); pnlMaint.add(cmbMargMaint2); label_9 = new JLabel("="); label_9.setForeground(Color.GRAY); label_9.setFont(new Font("Tahoma", Font.BOLD, 13)); label_9.setBounds(259, 362, 11, 14); pnlMaint.add(label_9); lblMarginalMaint = new JLabel("\u00A30.00 per annum"); lblMarginalMaint.setToolTipText("Marginal improvement"); lblMarginalMaint.setFont(new Font("Tahoma", Font.BOLD, 13)); lblMarginalMaint.setEnabled(false); lblMarginalMaint.setBounds(279, 358, 170, 20); pnlMaint.add(lblMarginalMaint); lblProdLoss = new JLabel("\u00A30.00 / year"); lblProdLoss.setToolTipText("Loss in production value due to downtime"); lblProdLoss.setForeground(Color.GRAY); lblProdLoss.setEnabled(false); lblProdLoss.setHorizontalAlignment(SwingConstants.LEFT); lblProdLoss.setFont(new Font("Tahoma", Font.BOLD, 11)); lblProdLoss.setBounds(106, 87, 125, 14); pnlMaint.add(lblProdLoss); lblHrs_1 = new JLabel("hrs"); lblHrs_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblHrs_1.setEnabled(false); lblHrs_1.setBounds(180, 64, 16, 14); pnlMaint.add(lblHrs_1); label_10 = new JLabel("Machine:"); label_10.setEnabled(false); label_10.setFont(new Font("Tahoma", Font.BOLD, 11)); label_10.setBounds(10, 34, 59, 14); pnlMaint.add(label_10); label_11 = new JLabel("="); label_11.setEnabled(false); label_11.setForeground(Color.GRAY); label_11.setFont(new Font("Tahoma", Font.BOLD, 13)); label_11.setBounds(88, 87, 11, 14); pnlMaint.add(label_11); label_12 = new JLabel("="); label_12.setEnabled(false); label_12.setForeground(Color.GRAY); label_12.setFont(new Font("Tahoma", Font.BOLD, 13)); label_12.setBounds(323, 87, 11, 14); pnlMaint.add(label_12); lblAnnualTotal = new JLabel("Annual total"); lblAnnualTotal.setEnabled(false); lblAnnualTotal.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblAnnualTotal.setBounds(255, 87, 67, 14); pnlMaint.add(lblAnnualTotal); lblProductionLoss = new JLabel("Production loss"); lblProductionLoss.setEnabled(false); lblProductionLoss.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblProductionLoss.setBounds(10, 87, 77, 14); pnlMaint.add(lblProductionLoss); pnlWaste = new JPanel(); pnlWaste.setBackground(Color.WHITE); tabsROI.addTab("Waste Reduction", null, pnlWaste, "ROI based on waste reduction"); pnlWaste.setLayout(null); lblThisToolDemonstrates = new JLabel( "This tool demonstrates the waste reduction capabilities of particular machines."); lblThisToolDemonstrates.setForeground(Color.GRAY); lblThisToolDemonstrates.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblThisToolDemonstrates.setBounds(10, 11, 439, 14); pnlWaste.add(lblThisToolDemonstrates); lblWasteSavedPer_1 = new JLabel("Waste saved per splice due to flag detection camera:"); lblWasteSavedPer_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblWasteSavedPer_1.setEnabled(false); lblWasteSavedPer_1.setBounds(10, 39, 256, 14); pnlWaste.add(lblWasteSavedPer_1); txtwastesavedflags = new JTextField(); txtwastesavedflags.setToolTipText("Saving per splice"); txtwastesavedflags.setEnabled(false); txtwastesavedflags.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtwastesavedflags.selectAll(); } }); txtwastesavedflags.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateROIWaste(); } @Override public void insertUpdate(DocumentEvent e) { UpdateROIWaste(); } @Override public void changedUpdate(DocumentEvent e) { } }); txtwastesavedflags.setBounds(286, 36, 86, 20); pnlWaste.add(txtwastesavedflags); txtwastesavedflags.setColumns(10); lblM_1 = new JLabel("m"); lblM_1.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblM_1.setEnabled(false); lblM_1.setBounds(378, 39, 46, 14); pnlWaste.add(lblM_1); lblWasteSavedPer_2 = new JLabel("Waste saved per mother roll due to alignment guide:"); lblWasteSavedPer_2.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblWasteSavedPer_2.setEnabled(false); lblWasteSavedPer_2.setBounds(10, 64, 256, 14); pnlWaste.add(lblWasteSavedPer_2); txtwastesavedguide = new JTextField(); txtwastesavedguide.setToolTipText("Saving per mother roll"); txtwastesavedguide.setEnabled(false); txtwastesavedguide.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { UpdateROIWaste(); } @Override public void insertUpdate(DocumentEvent e) { UpdateROIWaste(); } @Override public void changedUpdate(DocumentEvent e) { } }); txtwastesavedguide.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtwastesavedguide.selectAll(); } }); txtwastesavedguide.setBounds(286, 61, 86, 20); pnlWaste.add(txtwastesavedguide); txtwastesavedguide.setColumns(10); lblM_2 = new JLabel("m"); lblM_2.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblM_2.setEnabled(false); lblM_2.setBounds(378, 64, 46, 14); pnlWaste.add(lblM_2); pnlGraphWaste = new JPanel(); pnlGraphWaste.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); pnlGraphWaste.setBackground(Color.WHITE); pnlGraphWaste.setBounds(10, 90, 439, 262); pnlWaste.add(pnlGraphWaste); pnlGraphWaste.setLayout(null); try { lblNoGraph4 = new JLabel( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/no_preview.png")))); } catch (IOException e2) { e2.printStackTrace(); } lblNoGraph4.setBounds(2, 2, 435, 258); pnlGraphWaste.add(lblNoGraph4); cmbMargWaste1 = new JComboBox(); cmbMargWaste1.setToolTipText("Old machine"); cmbMargWaste1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateROIWaste(); } }); cmbMargWaste1.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMargWaste1.setEnabled(false); cmbMargWaste1.setBounds(10, 359, 111, 20); pnlWaste.add(cmbMargWaste1); label_1 = new JLabel("to"); label_1.setForeground(Color.GRAY); label_1.setFont(new Font("Tahoma", Font.BOLD, 11)); label_1.setBounds(125, 362, 16, 14); pnlWaste.add(label_1); cmbMargWaste2 = new JComboBox(); cmbMargWaste2.setToolTipText("New machine"); cmbMargWaste2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateROIWaste(); } }); cmbMargWaste2.setFont(new Font("Tahoma", Font.PLAIN, 11)); cmbMargWaste2.setEnabled(false); cmbMargWaste2.setBounds(141, 359, 111, 20); pnlWaste.add(cmbMargWaste2); label_6 = new JLabel("="); label_6.setForeground(Color.GRAY); label_6.setFont(new Font("Tahoma", Font.BOLD, 13)); label_6.setBounds(259, 362, 11, 14); pnlWaste.add(label_6); lblMarginalWaste = new JLabel("0.00m per annum"); lblMarginalWaste.setToolTipText("Marginal improvement"); lblMarginalWaste.setFont(new Font("Tahoma", Font.BOLD, 13)); lblMarginalWaste.setEnabled(false); lblMarginalWaste.setBounds(279, 355, 170, 16); pnlWaste.add(lblMarginalWaste); lblMarginalWasteValue = new JLabel("(\u00A30.00 per annum)"); lblMarginalWasteValue.setToolTipText("Marginal improvement value"); lblMarginalWasteValue.setForeground(Color.GRAY); lblMarginalWasteValue.setFont(new Font("Tahoma", Font.BOLD, 11)); lblMarginalWasteValue.setBounds(279, 370, 170, 16); pnlWaste.add(lblMarginalWasteValue); machNames = new HashSet<String>(); jobNames = new HashSet<String>(); lblStatus = new JLabel(" Ready."); lblStatus.setFont(new Font("Tahoma", Font.PLAIN, 12)); frmTitanRoiCalculator.getContentPane().add(lblStatus, BorderLayout.SOUTH); lblmmin = new JLabel("(m/min)"); lblmmin.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblmmin.setEnabled(false); lblmmin.setBounds(206, 168, 44, 14); pnlJobs.add(lblmmin); objfilter = new OBJfilter(1); // labels for unit conversion labs = new JLabel[7]; labs[0] = lblmm0; labs[1] = lblmm1; labs[2] = lblmm2; labs[3] = lblgm3; labs[4] = lblmm3; labs[5] = lblmicro0; lblGsm = new JLabel("(gsm)"); lblGsm.setToolTipText("Switch the input type for density between gsm and g/cc"); lblGsm.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblGsm.setEnabled(false); lblGsm.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { if (lblGsm.isEnabled() && lblGsm.contains(arg0.getPoint())) { jobFormReady = false; try { //double oldval = Double.parseDouble(txtDensity.getText()); //double thickness = Double.parseDouble(txtThickness.getText()); double oldval = ((Job) listJobs.getSelectedValue()).getDensity(); double thickness = ((Job) listJobs.getSelectedValue()).getThickness(); if (lblGsm.getText().equals("(gsm)")) { lblGsm.setText("(g/cc)"); label_3.setVisible(false); lblgm3.setText("(gsm)"); txtDensity.setText(Double.toString(roundTwoDecimals(oldval * thickness))); ((Job) listJobs.getSelectedValue()).gsm = true; } else { lblGsm.setText("(gsm)"); label_3.setVisible(true); lblgm3.setText("(g/cm )"); txtDensity.setText(Double.toString(roundTwoDecimals(oldval))); ((Job) listJobs.getSelectedValue()).gsm = false; } } catch (Exception e) { lblGsm.setText("(gsm)"); label_3.setVisible(true); lblgm3.setText("(g/cm )"); txtDensity.setText("0.92"); } jobFormReady = true; } } @Override public void mouseEntered(MouseEvent arg0) { lblGsm.setForeground(new Color(0, 0, 128)); } @Override public void mouseExited(MouseEvent e) { lblGsm.setForeground(Color.black); } }); lblGsm.setForeground(new Color(0, 0, 0)); lblGsm.setCursor(new Cursor(Cursor.HAND_CURSOR)); lblGsm.setBounds(177, 102, 46, 14); pnlMaterials.add(lblGsm); lblOr = new JLabel("or:"); lblOr.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblOr.setEnabled(false); lblOr.setBounds(155, 102, 14, 14); pnlMaterials.add(lblOr); labs[6] = lblmmin; cmbUnwindType = new JComboBox(); cmbUnwindType.setToolTipText("Type of measure to use for the unwind quantity above"); cmbUnwindType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateUnwindAmount(); } }); cmbUnwindType.setEnabled(false); cmbUnwindType .setModel(new DefaultComboBoxModel(new String[] { "Length (m)", "Weight (kg)", "Diameter (mm)" })); cmbUnwindType.setBounds(92, 124, 95, 20); pnlUnwinds.add(cmbUnwindType); txtWebWidth = new JTextField(); txtWebWidth.setToolTipText("Width of mother rolls"); txtWebWidth.setText("1350"); txtWebWidth.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { txtWebWidth.selectAll(); } }); txtWebWidth.setEnabled(false); txtWebWidth.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { UpdateJob(); } @Override public void insertUpdate(DocumentEvent arg0) { UpdateJob(); } @Override public void changedUpdate(DocumentEvent arg0) { } }); txtWebWidth.setBounds(92, 26, 86, 20); pnlUnwinds.add(txtWebWidth); txtWebWidth.setColumns(10); lblAverageFlags = new JLabel("Average Flags:"); lblAverageFlags.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblAverageFlags.setToolTipText("The average number of flags in each mother roll"); lblAverageFlags.setEnabled(false); lblAverageFlags.setBounds(14, 79, 75, 14); pnlUnwinds.add(lblAverageFlags); txtFlagCount = new JTextField(); txtFlagCount.setToolTipText("The average number of flags in each mother roll"); txtFlagCount.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent arg0) { txtFlagCount.selectAll(); } }); txtFlagCount.getDocument().addDocumentListener(new JobInputChangeListener()); txtFlagCount.setEnabled(false); txtFlagCount.setText("1"); txtFlagCount.setBounds(92, 76, 43, 20); pnlUnwinds.add(txtFlagCount); txtFlagCount.setColumns(10); lblPerRoll = new JLabel("per roll"); lblPerRoll.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblPerRoll.setEnabled(false); lblPerRoll.setBounds(140, 79, 46, 14); pnlUnwinds.add(lblPerRoll); txtLimitRunSpeed = new JTextField(); txtLimitRunSpeed.setToolTipText( "Override for top machine speed (may be required for particular materials or environments)"); txtLimitRunSpeed.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { if (txtLimitRunSpeed.contains(arg0.getPoint())) { txtLimitRunSpeed.setEnabled(true); chckbxLimitRunSpeed.setSelected(true); txtLimitRunSpeed.requestFocusInWindow(); txtLimitRunSpeed.selectAll(); UpdateJob(); } } }); txtLimitRunSpeed.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { if (txtLimitRunSpeed.isEnabled()) { txtLimitRunSpeed.selectAll(); chckbxLimitRunSpeed.setSelected(true); } } }); txtLimitRunSpeed.getDocument().addDocumentListener(new JobInputChangeListener()); txtLimitRunSpeed.setEnabled(false); txtLimitRunSpeed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { chckbxLimitRunSpeed.setSelected(true); } }); txtLimitRunSpeed.setText("800"); txtLimitRunSpeed.setColumns(10); txtLimitRunSpeed.setBounds(130, 165, 65, 20); pnlJobs.add(txtLimitRunSpeed); cmbRewindType = new JComboBox(); cmbRewindType.setToolTipText("Type of measure to use for rewind output above"); cmbRewindType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateRewindAmount(); //UpdateJob(); } }); cmbRewindType.setEnabled(false); cmbRewindType .setModel(new DefaultComboBoxModel(new String[] { "Length (m)", "Weight (kg)", "Diameter (mm)" })); cmbRewindType.setBounds(109, 218, 95, 20); pnlJobs.add(cmbRewindType); chckbxLimitRunSpeed = new JCheckBox(""); chckbxLimitRunSpeed.setToolTipText( "Override for top machine speed (may be required for particular materials or environments)"); chckbxLimitRunSpeed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (chckbxLimitRunSpeed.isSelected()) { txtLimitRunSpeed.setEnabled(true); txtLimitRunSpeed.requestFocusInWindow(); txtLimitRunSpeed.selectAll(); } else { txtLimitRunSpeed.setEnabled(false); } UpdateJob(); } }); chckbxLimitRunSpeed.setEnabled(false); chckbxLimitRunSpeed.setBounds(105, 164, 20, 20); pnlJobs.add(chckbxLimitRunSpeed); lblLimitRunSpeed = new JLabel("Speed Limit:"); lblLimitRunSpeed.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblLimitRunSpeed.setToolTipText( "Override for top machine speed (may be required for particular materials or environments)"); lblLimitRunSpeed.setEnabled(false); lblLimitRunSpeed.setBounds(47, 168, 59, 14); pnlJobs.add(lblLimitRunSpeed); lblKnifeType = new JLabel("Knife Type:"); lblKnifeType.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblKnifeType.setToolTipText("Select knife type for this job"); lblKnifeType.setEnabled(false); lblKnifeType.setHorizontalAlignment(SwingConstants.RIGHT); lblKnifeType.setBounds(46, 89, 59, 14); pnlJobs.add(lblKnifeType); cmbKnifeType = new JComboBox(); cmbKnifeType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UpdateJob(); } }); cmbKnifeType.setModel(new DefaultComboBoxModel(new String[] { "Razor in Air", "Rotary Shear" })); cmbKnifeType.setToolTipText("Select knife type for this job"); cmbKnifeType.setEnabled(false); cmbKnifeType.setBounds(109, 86, 95, 20); pnlJobs.add(cmbKnifeType); tabbedPane.setMnemonicAt(0, KeyEvent.VK_M); tabbedPane.setMnemonicAt(1, KeyEvent.VK_J); tabbedPane.setMnemonicAt(2, KeyEvent.VK_S); tabbedPane.setMnemonicAt(3, KeyEvent.VK_P); tabbedPane.setMnemonicAt(4, KeyEvent.VK_R); tabsROI.setMnemonicAt(0, KeyEvent.VK_D); tabsROI.setMnemonicAt(1, KeyEvent.VK_N); tabsROI.setMnemonicAt(3, KeyEvent.VK_W); scrollPane_4 = new JScrollPane(); scrollPane_4.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scrollPane_4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane_4.setBorder(null); scrollPane_4.setBounds(522, 44, 245, 405); pnlROI.add(scrollPane_4); panel_11 = new JPanel(); panel_11.setToolTipText( "Click a machine to select it. Select two or more machines to compare their ROI measures."); scrollPane_4.setViewportView(panel_11); panel_11.setBackground(Color.WHITE); panel_11.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); panel_11.setLayout(new BorderLayout(0, 0)); listCompareRoi = new JList(listModel); panel_11.add(listCompareRoi, BorderLayout.NORTH); listCompareRoi.setToolTipText( "Click a machine to select it. Select two or more machines to compare their ROI measures."); listCompareRoi.setBorder(null); listCompareRoi.setSelectionModel(new DefaultListSelectionModel() { private static final long serialVersionUID = 1L; boolean gestureStarted = false; @Override public void setSelectionInterval(int index0, int index1) { if (!gestureStarted) { if (isSelectedIndex(index0)) { super.removeSelectionInterval(index0, index1); } else { super.addSelectionInterval(index0, index1); } } gestureStarted = true; } @Override public void setValueIsAdjusting(boolean isAdjusting) { if (isAdjusting == false) { gestureStarted = false; } } }); listCompareRoi.addListSelectionListener(new ROIListSelectionListener()); listCompareRoi.setCellRenderer(new MachineListRenderer()); listCompare.setSelectionModel(listCompareRoi.getSelectionModel()); btnJobUp = new JButton(""); btnJobUp.setToolTipText("Move job up"); btnJobUp.addActionListener(new JobUpListener()); try { btnJobUp.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up.png")))); btnJobUp.setRolloverEnabled(true); btnJobUp.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up_over.png")))); btnJobUp.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/up_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnJobUp.setEnabled(false); btnJobUp.setBounds(700, 463, 30, 30); pnlJob.add(btnJobUp); btnJobDown = new JButton(""); btnJobDown.setToolTipText("Move job down"); btnJobDown.addActionListener(new JobDownListener()); try { btnJobDown.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down.png")))); btnJobDown.setRolloverEnabled(true); btnJobDown.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down_over.png")))); btnJobDown.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/down_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnJobDown.setEnabled(false); btnJobDown.setBounds(737, 463, 30, 30); pnlJob.add(btnJobDown); btnNewJob = new JButton("Add New"); btnNewJob.setFont(new Font("Tahoma", Font.BOLD, 11)); btnNewJob.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jobFormReady = false; ResetStatusLabel(); EnableJobForm(); // new ResetJobForm(); lblGsm.setText("(gsm)"); label_3.setVisible(true); lblgm3.setText("(g/cm )"); txtDensity.setText("0.92"); btnJobDelete.setEnabled(true); btnAddAll.setEnabled(true); /*if(listJobs.getSelectedIndex() == 0) btnJobUp.setEnabled(false); else btnJobUp.setEnabled(true); if(listJobs.getSelectedIndex() == jobModel.getSize()-1) btnJobDown.setEnabled(false); else btnJobDown.setEnabled(true);*/ int index = listJobs.getSelectedIndex(); int size = jobModel.getSize(); if (size >= Consts.JOB_LIST_LIMIT) { // Max list size ShowMessage("Maximum number of jobs allocated. Please delete before attempting to add more."); return; } String newName = getUniqueJobName("Job"); txtJobName.setText(newName); job = new Job(newName); jobNames.add(newName.toLowerCase()); //If no selection or if item in last position is selected, //add the new one to end of list, and select new one. if (index == -1 || (index + 1 == size)) { jobModel.addElement(job); listJobs.setSelectedIndex(size); listJobsAvail.setSelectedIndex(size); if (size > 0) btnJobUp.setEnabled(true); //Otherwise insert the new one after the current selection, //and select new one. } else { jobModel.insertElementAt(job, index + 1); listJobs.setSelectedIndex(index + 1); listJobsAvail.setSelectedIndex(index + 1); } // TODO don't reset form, or add copy button ResetStatusLabel(); jobFormReady = true; UpdateJob(); txtJobName.requestFocusInWindow(); } }); try { btnNewJob.setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/plus.png")))); } catch (IOException e1) { e1.printStackTrace(); } btnNewJob.setToolTipText("Add new job"); btnNewJob.setBounds(522, 460, 110, 36); pnlJob.add(btnNewJob); lblJobConfiguration = new JLabel("Job Configuration"); lblJobConfiguration.setFont(new Font("Tahoma", Font.BOLD, 18)); lblJobConfiguration.setBounds(29, 18, 269, 22); pnlJob.add(lblJobConfiguration); btnJobDelete = new JButton(""); btnJobDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ResetStatusLabel(); Job selected = (Job) listJobs.getSelectedValue(); jobNames.remove(selected.getName().toLowerCase()); ListSelectionModel lsm = listJobs.getSelectionModel(); int firstSelected = lsm.getMinSelectionIndex(); int lastSelected = lsm.getMaxSelectionIndex(); jobModel.removeRange(firstSelected, lastSelected); int size = jobModel.size(); if (size == 0) { //List is empty: disable delete, up, and down buttons. /*btnJobDelete.setEnabled(false); btnJobUp.setEnabled(false); btnJobDown.setEnabled(false);*/ } else { //Adjust the selection. if (firstSelected == jobModel.getSize()) { //Removed item in last position. firstSelected--; } listJobs.setSelectedIndex(firstSelected); if (size == 21) { // No longer full list ResetStatusLabel(); } job = (Job) listJobs.getSelectedValue(); } } }); try { btnJobDelete .setIcon(new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete.png")))); btnJobDelete.setRolloverEnabled(true); btnJobDelete.setRolloverIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete_over.png")))); btnJobDelete.setDisabledIcon( new ImageIcon(ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/delete_dis.png")))); } catch (NullPointerException e11) { System.out.println("Image load error"); } catch (IOException e1) { e1.printStackTrace(); } btnJobDelete.setToolTipText("Delete job"); btnJobDelete.setRolloverEnabled(true); btnJobDelete.setEnabled(false); btnJobDelete.setBounds(651, 460, 36, 36); pnlJob.add(btnJobDelete); lblAddNewJobs = new JLabel( "Add new jobs to the list on the right, then configure unwind, rewind and material settings below"); lblAddNewJobs.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblAddNewJobs.setBounds(29, 45, 483, 14); pnlJob.add(lblAddNewJobs); lblJobs = new JLabel("Jobs"); lblJobs.setFont(new Font("Tahoma", Font.BOLD, 12)); lblJobs.setBounds(522, 19, 85, 14); pnlJob.add(lblJobs); panel_1 = new JPanel(); panel_1.setLayout(null); panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Total Output", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_1.setBounds(280, 380, 227, 116); pnlJob.add(panel_1); lblTargetOutputFor = new JLabel("Target output for job:"); lblTargetOutputFor.setEnabled(false); lblTargetOutputFor.setBounds(30, 22, 129, 14); panel_1.add(lblTargetOutputFor); txtTargetTotal = new JTextField(); txtTargetTotal.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtTargetTotal.selectAll(); } }); txtTargetTotal.getDocument().addDocumentListener(new JobInputChangeListener()); txtTargetTotal.setToolTipText("Total output quantity for this job"); txtTargetTotal.setText("10000"); txtTargetTotal.setEnabled(false); txtTargetTotal.setColumns(10); txtTargetTotal.setBounds(30, 43, 118, 20); panel_1.add(txtTargetTotal); cmbTargetTotal = new JComboBox(); cmbTargetTotal.setToolTipText("Type of measure to use for output quantity above"); cmbTargetTotal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UpdateTotalsAmount(); } }); cmbTargetTotal.setModel( new DefaultComboBoxModel(new String[] { "Length (m)", "Weight (kg)", "Weight (tonnes)" })); cmbTargetTotal.setEnabled(false); cmbTargetTotal.setBounds(30, 67, 118, 20); panel_1.add(cmbTargetTotal); lblCounts = new JLabel("0 reel(s), 0 set(s), 0 mother(s)"); lblCounts.setFont(new Font("Tahoma", Font.PLAIN, 11)); lblCounts.setForeground(Color.GRAY); lblCounts.setBounds(30, 92, 187, 14); panel_1.add(lblCounts); panel_2 = new JPanel(); panel_2.setLayout(null); panel_2.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Name", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); panel_2.setBounds(20, 72, 250, 83); pnlJob.add(panel_2); txtJobName = new JTextField(); txtJobName.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { txtJobName.selectAll(); } }); txtJobName.setBounds(90, 30, 145, 28); panel_2.add(txtJobName); txtJobName.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent arg0) { } @Override public void insertUpdate(DocumentEvent arg0) { UpdateJobName(); } @Override public void removeUpdate(DocumentEvent arg0) { UpdateJobName(); } }); txtJobName.setToolTipText("Set the name of this job"); txtJobName.setFont(new Font("Tahoma", Font.BOLD, 12)); txtJobName.setEnabled(false); txtJobName.setColumns(10); lblJobName = new JLabel("Job name:"); lblJobName.setToolTipText("Set the name of this job"); lblJobName.setEnabled(false); lblJobName.setBounds(22, 31, 60, 24); panel_2.add(lblJobName); lblJobName.setFont(new Font("Tahoma", Font.PLAIN, 13)); btnResetJobs = new JButton("Reset"); btnResetJobs.setBounds(20, 460, 100, 36); pnlJob.add(btnResetJobs); btnResetJobs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ResetJobForm(); UpdateJob(); } }); btnResetJobs.setToolTipText("Reset the form"); btnResetJobs.setEnabled(false); scrollPane_1 = new JScrollPane(); scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane_1.setBorder(null); scrollPane_1.setBounds(522, 44, 245, 405); pnlJob.add(scrollPane_1); panel_7 = new JPanel(); panel_7.setToolTipText("Select a job to edit options, re-order, or delete"); scrollPane_1.setViewportView(panel_7); panel_7.setBackground(Color.WHITE); panel_7.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, Color.LIGHT_GRAY, null, null, null)); panel_7.setLayout(new BorderLayout(0, 0)); listJobs = new JList(jobModel); listJobs.setSelectionModel(listJobsAvail.getSelectionModel()); panel_7.add(listJobs, BorderLayout.NORTH); listJobs.setToolTipText("Select a job to edit options, re-order, or delete"); listJobs.addListSelectionListener(new JobListSelectionListener()); listJobs.setBorder(null); listJobs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listJobs.setCellRenderer(new JobListRenderer()); pnlJob.setFocusTraversalPolicy(new FocusTraversalOnArray( new Component[] { cmbMaterials, txtThickness, txtDensity, cmbUnwindCore, txtUnwindAmount, txtSlits, txtSlitWidth, cmbRewindCore, txtRewindAmount, cmbJobDomain, lblPresets, lblThickness_1, lblDensity_1, pnlMaterials, lblWebWidthmm, lblmm0, lblUnwindCoremm, lblmm1, lblUnwindLength, pnlUnwinds, lblmicro0, lblgm3, label_3, pnlJobs, lblTargetRewindLength, lblSlitWidth, lblSlitCount, lblTrimtotal, lblTrim, lblRewindCoremm, lblPer_1, lblmm3, lblmm2 })); Image img = null; try { img = ImageIO.read(FrmMain.class.getResourceAsStream("/atlas/refresh.png")); } catch (IOException e1) { e1.printStackTrace(); } BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bi.createGraphics(); g.drawImage(img, 0, 0, 25, 25, null); LoadSettings(); DoLicenceCheck(); initialising = false; }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;/* w w w . j a v a2s . co m*/ JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:MiGA.StatsSelection.java
public StatsSelection(final String[] organisms, final boolean flag) { setTitle("MiGA"); setSize(800, 600);/*from w ww.j av a 2s . c om*/ 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.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;//from ww w . ja v a 2 s .c o 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);/* ww w . j av a 2 s .co 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); }
From source file:ffx.ui.ModelingPanel.java
private void loadCommand() { synchronized (this) { // Force Field X Command Element command;// w w w . j a v a 2s . co m // Command Options NodeList options; Element option; // Option Values NodeList values; Element value; // Options may be Conditional based on previous Option values (not // always supplied) NodeList conditionalList; Element conditional; // JobPanel GUI Components that change based on command JPanel optionPanel; // Clear the previous components commandPanel.removeAll(); optionsTabbedPane.removeAll(); conditionals.clear(); String currentCommand = (String) currentCommandBox.getSelectedItem(); if (currentCommand == null) { commandPanel.validate(); commandPanel.repaint(); return; } command = null; for (int i = 0; i < commandList.getLength(); i++) { command = (Element) commandList.item(i); String name = command.getAttribute("name"); if (name.equalsIgnoreCase(currentCommand)) { break; } } int div = splitPane.getDividerLocation(); descriptTextArea.setText(currentCommand.toUpperCase() + ": " + command.getAttribute("description")); splitPane.setBottomComponent(descriptScrollPane); splitPane.setDividerLocation(div); // The "action" tells Force Field X what to do when the // command finishes commandActions = command.getAttribute("action").trim(); // The "fileType" specifies what file types this command can execute // on String string = command.getAttribute("fileType").trim(); String[] types = string.split(" +"); commandFileTypes.clear(); for (String type : types) { if (type.contains("XYZ")) { commandFileTypes.add(FileType.XYZ); } if (type.contains("INT")) { commandFileTypes.add(FileType.INT); } if (type.contains("ARC")) { commandFileTypes.add(FileType.ARC); } if (type.contains("PDB")) { commandFileTypes.add(FileType.PDB); } if (type.contains("ANY")) { commandFileTypes.add(FileType.ANY); } } // Determine what options are available for this command options = command.getElementsByTagName("Option"); int length = options.getLength(); for (int i = 0; i < length; i++) { // This Option will be enabled (isEnabled = true) unless a // Conditional disables it boolean isEnabled = true; option = (Element) options.item(i); conditionalList = option.getElementsByTagName("Conditional"); /* * Currently, there can only be 0 or 1 Conditionals per Option * There are three types of Conditionals implemented. 1.) * Conditional on a previous Option, this option may be * available 2.) Conditional on input for this option, a * sub-option may be available 3.) Conditional on the presence * of keywords, this option may be available */ if (conditionalList != null) { conditional = (Element) conditionalList.item(0); } else { conditional = null; } // Get the command line flag String flag = option.getAttribute("flag").trim(); // Get the description String optionDescript = option.getAttribute("description"); JTextArea optionTextArea = new JTextArea(" " + optionDescript.trim()); optionTextArea.setEditable(false); optionTextArea.setLineWrap(true); optionTextArea.setWrapStyleWord(true); optionTextArea.setBorder(etchedBorder); // Get the default for this Option (if one exists) String defaultOption = option.getAttribute("default"); // Option Panel optionPanel = new JPanel(new BorderLayout()); optionPanel.add(optionTextArea, BorderLayout.NORTH); String swing = option.getAttribute("gui"); JPanel optionValuesPanel = new JPanel(new FlowLayout()); optionValuesPanel.setBorder(etchedBorder); ButtonGroup bg = null; if (swing.equalsIgnoreCase("CHECKBOXES")) { // CHECKBOXES allows selection of 1 or more values from a // predefined set (Analyze, for example) values = option.getElementsByTagName("Value"); for (int j = 0; j < values.getLength(); j++) { value = (Element) values.item(j); JCheckBox jcb = new JCheckBox(value.getAttribute("name")); jcb.addMouseListener(this); jcb.setName(flag); if (defaultOption != null && jcb.getActionCommand().equalsIgnoreCase(defaultOption)) { jcb.setSelected(true); } optionValuesPanel.add(jcb); } } else if (swing.equalsIgnoreCase("TEXTFIELD")) { // TEXTFIELD takes an arbitrary String as input JTextField jtf = new JTextField(20); jtf.addMouseListener(this); jtf.setName(flag); if (defaultOption != null && defaultOption.equals("ATOMS")) { FFXSystem sys = mainPanel.getHierarchy().getActive(); if (sys != null) { jtf.setText("" + sys.getAtomList().size()); } } else if (defaultOption != null) { jtf.setText(defaultOption); } optionValuesPanel.add(jtf); } else if (swing.equalsIgnoreCase("RADIOBUTTONS")) { // RADIOBUTTONS allows one choice from a set of predifined // values bg = new ButtonGroup(); values = option.getElementsByTagName("Value"); for (int j = 0; j < values.getLength(); j++) { value = (Element) values.item(j); JRadioButton jrb = new JRadioButton(value.getAttribute("name")); jrb.addMouseListener(this); jrb.setName(flag); bg.add(jrb); if (defaultOption != null && jrb.getActionCommand().equalsIgnoreCase(defaultOption)) { jrb.setSelected(true); } optionValuesPanel.add(jrb); } } else if (swing.equalsIgnoreCase("PROTEIN")) { // Protein allows selection of amino acids for the protein // builder optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS)); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(getAminoAcidPanel()); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidComboBox.removeAllItems(); JButton add = new JButton("Edit"); add.setActionCommand("PROTEIN"); add.addActionListener(this); add.setAlignmentX(Button.CENTER_ALIGNMENT); JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidTextField); comboPanel.add(add); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton remove = new JButton("Remove"); add.setMinimumSize(remove.getPreferredSize()); add.setPreferredSize(remove.getPreferredSize()); remove.setActionCommand("PROTEIN"); remove.addActionListener(this); remove.setAlignmentX(Button.CENTER_ALIGNMENT); comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidComboBox); comboPanel.add(remove); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(acidScrollPane); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton reset = new JButton("Reset"); reset.setActionCommand("PROTEIN"); reset.addActionListener(this); reset.setAlignmentX(Button.CENTER_ALIGNMENT); optionValuesPanel.add(reset); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidTextArea.setText(""); acidTextField.setText(""); } else if (swing.equalsIgnoreCase("NUCLEIC")) { // Nucleic allows selection of nucleic acids for the nucleic // acid builder optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS)); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(getNucleicAcidPanel()); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidComboBox.removeAllItems(); JButton add = new JButton("Edit"); add.setActionCommand("NUCLEIC"); add.addActionListener(this); add.setAlignmentX(Button.CENTER_ALIGNMENT); JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidTextField); comboPanel.add(add); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton remove = new JButton("Remove"); add.setMinimumSize(remove.getPreferredSize()); add.setPreferredSize(remove.getPreferredSize()); remove.setActionCommand("NUCLEIC"); remove.addActionListener(this); remove.setAlignmentX(Button.CENTER_ALIGNMENT); comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); comboPanel.add(acidComboBox); comboPanel.add(remove); optionValuesPanel.add(comboPanel); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); optionValuesPanel.add(acidScrollPane); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); JButton button = new JButton("Reset"); button.setActionCommand("NUCLEIC"); button.addActionListener(this); button.setAlignmentX(Button.CENTER_ALIGNMENT); optionValuesPanel.add(button); optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5))); acidTextArea.setText(""); acidTextField.setText(""); } else if (swing.equalsIgnoreCase("SYSTEMS")) { // SYSTEMS allows selection of an open system JComboBox<FFXSystem> jcb = new JComboBox<>(mainPanel.getHierarchy().getNonActiveSystems()); jcb.setSize(jcb.getMaximumSize()); jcb.addActionListener(this); optionValuesPanel.add(jcb); } // Set up a Conditional for this Option if (conditional != null) { isEnabled = false; String conditionalName = conditional.getAttribute("name"); String conditionalValues = conditional.getAttribute("value"); String cDescription = conditional.getAttribute("description"); String cpostProcess = conditional.getAttribute("postProcess"); if (conditionalName.toUpperCase().startsWith("KEYWORD")) { optionPanel.setName(conditionalName); String keywords[] = conditionalValues.split(" +"); if (activeSystem != null) { Hashtable<String, Keyword> systemKeywords = activeSystem.getKeywords(); for (String key : keywords) { if (systemKeywords.containsKey(key.toUpperCase())) { isEnabled = true; } } } } else if (conditionalName.toUpperCase().startsWith("VALUE")) { isEnabled = true; // Add listeners to the values of this option so // the conditional options can be disabled/enabled. for (int j = 0; j < optionValuesPanel.getComponentCount(); j++) { JToggleButton jtb = (JToggleButton) optionValuesPanel.getComponent(j); jtb.addActionListener(this); jtb.setActionCommand("Conditional"); } JPanel condpanel = new JPanel(); condpanel.setBorder(etchedBorder); JLabel condlabel = new JLabel(cDescription); condlabel.setEnabled(false); condlabel.setName(conditionalValues); JTextField condtext = new JTextField(10); condlabel.setLabelFor(condtext); if (cpostProcess != null) { condtext.setName(cpostProcess); } condtext.setEnabled(false); condpanel.add(condlabel); condpanel.add(condtext); conditionals.add(condlabel); optionPanel.add(condpanel, BorderLayout.SOUTH); } else if (conditionalName.toUpperCase().startsWith("REFLECTION")) { String[] condModifiers; if (conditionalValues.equalsIgnoreCase("AltLoc")) { condModifiers = activeSystem.getAltLocations(); if (condModifiers != null && condModifiers.length > 1) { isEnabled = true; bg = new ButtonGroup(); for (int j = 0; j < condModifiers.length; j++) { JRadioButton jrbmi = new JRadioButton(condModifiers[j]); jrbmi.addMouseListener(this); bg.add(jrbmi); optionValuesPanel.add(jrbmi); if (j == 0) { jrbmi.setSelected(true); } } } } else if (conditionalValues.equalsIgnoreCase("Chains")) { condModifiers = activeSystem.getChainNames(); if (condModifiers != null && condModifiers.length > 0) { isEnabled = true; for (int j = 0; j < condModifiers.length; j++) { JRadioButton jrbmi = new JRadioButton(condModifiers[j]); jrbmi.addMouseListener(this); bg.add(jrbmi); optionValuesPanel.add(jrbmi, j); } } } } } optionPanel.add(optionValuesPanel, BorderLayout.CENTER); optionPanel.setPreferredSize(optionPanel.getPreferredSize()); optionsTabbedPane.addTab(option.getAttribute("name"), optionPanel); optionsTabbedPane.setEnabledAt(optionsTabbedPane.getTabCount() - 1, isEnabled); } } optionsTabbedPane.setPreferredSize(optionsTabbedPane.getPreferredSize()); commandPanel.setLayout(borderLayout); commandPanel.add(optionsTabbedPane, BorderLayout.CENTER); commandPanel.validate(); commandPanel.repaint(); loadLogSettings(); statusLabel.setText(" " + createCommandInput()); }