def __init__(self, chartFun, isTemporal = False): self.isTemporal = isTemporal JPanel() #self.setBackground(Color.LIGHT_GRAY) self.chartFun = chartFun self.enableChartFun = False self.setLayout(GridLayout(6,2)) self.add(JLabel('CPU Cores')) nprocs = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors() procvals = sorted(set([nprocs, 1, 2, 4, 8, 16, 32, 64, 128])) cores = JComboBox(procvals) cores.setSelectedIndex(procvals.index(nprocs)) cores.setMaximumSize(cores.getPreferredSize()) self.cores = cores self.add(self.cores) self.add(JLabel('# of sims (x1000) ')) numSims = JComboBox( map(lambda x: str((10+x)*5), range(10)) + map(lambda x: str(x*100), range(1,11)) ) numSims.setMaximumSize(numSims.getPreferredSize()) self.numSims = numSims self.add(self.numSims) if isTemporal: self.add(JLabel('"Neutral" Ne')) self.neutral = JCheckBox() self.neutral.addActionListener(self) self.add(self.neutral) else: self.add(JLabel('"Neutral" mean Fst')) self.neutral = JCheckBox() self.neutral.addActionListener(self) self.add(self.neutral) self.add(JLabel('Force mean Fst')) self.force = JCheckBox() self.force.addActionListener(self) self.add(self.force) self.add(JLabel('Confidence interval ')) ci = JComboBox(['0.95', '0.99', '0.995']) ci.addItemListener(self) ci.setMaximumSize(cores.getPreferredSize()) self.ci = ci self.add(self.ci) self.add(JLabel('False Disc. Rate')) fdr = JFormattedTextField( NumberFormat.getNumberInstance(Locale.US)) fdr.setValue(0.1) fdr.addPropertyChangeListener(self) self.add(fdr) self.fdr = fdr
def __init__(self, chartFun, isTemporal = False): self.isTemporal = isTemporal JPanel() #self.setBackground(Color.LIGHT_GRAY) self.chartFun = chartFun self.enableChartFun = False self.setLayout(GridLayout(6,2)) self.add(JLabel('CPU Cores')) cores = JComboBox(['1', '2', '4', '8', '16', '32', '64', '128']) nprocs = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors() pos = min([7, log(ceil(nprocs)) / log(2)]) cores.setSelectedIndex(int(pos)) cores.setMaximumSize(cores.getPreferredSize()) self.cores = cores self.add(self.cores) self.add(JLabel('# of sims (x1000) ')) numSims = JComboBox( map(lambda x: str((10+x)*5), range(10)) + map(lambda x: str(x*100), range(1,11)) ) numSims.setMaximumSize(numSims.getPreferredSize()) self.numSims = numSims self.add(self.numSims) if isTemporal: self.add(JLabel('"Neutral" Ne')) self.neutral = JCheckBox() self.neutral.addActionListener(self) self.add(self.neutral) else: self.add(JLabel('"Neutral" mean Fst')) self.neutral = JCheckBox() self.neutral.addActionListener(self) self.add(self.neutral) self.add(JLabel('Force mean Fst')) self.force = JCheckBox() self.force.addActionListener(self) self.add(self.force) self.add(JLabel('Confidence interval ')) ci = JComboBox(['0.95', '0.99', '0.995']) ci.addItemListener(self) ci.setMaximumSize(cores.getPreferredSize()) self.ci = ci self.add(self.ci) self.add(JLabel('False Disc. Rate')) fdr = JFormattedTextField( NumberFormat.getNumberInstance(Locale.US)) fdr.setValue(0.1) fdr.addPropertyChangeListener(self) self.add(fdr) self.fdr = fdr
def __init__(self, currency, noDecimals): import java.lang.Double as Double import java.text.NumberFormat as NumberFormat import javax.swing.table.DefaultTableCellRenderer as DefaultTableCellRenderer import com.infinitekind.moneydance.model.CurrencyType as CurrencyType super(DefaultTableCellRenderer, self).__init__() self.noDecimals = noDecimals ct = currency.getTable() relativeToName = currency.getParameter(CurrencyType.TAG_RELATIVE_TO_CURR) if relativeToName != None: self.relativeTo = ct.getCurrencyByIDString(relativeToName) else: self.relativeTo = ct.getBaseType() self.noDecimalFormatter = NumberFormat.getNumberInstance() self.noDecimalFormatter.setMinimumFractionDigits(0) self.noDecimalFormatter.setMaximumFractionDigits(0)
def readGrinderOutFile(self, summaryData, reportDir): # reset the test directory # TODO this logic does not belong in a method named 'readGrinderOutFile' ! if path.isdir(reportDir): logger.warn("Deleting previous report directory '" + reportDir + "'.") shutil.rmtree(reportDir) if path.isfile(reportDir): logger.warn("Pre-existing file '" + reportDir + "' collides with report dir name. Deleting.") os.remove(reportDir) os.mkdir(reportDir) templates = MavenUtilities.getCurrentDir() + os.sep + classpathtool.GA_NAME + os.sep + "templates" shutil.copytree(templates, reportDir + os.sep + "templates") analyzerPlugin = ga.constants.VORPAL.getPlugin("analyzer") # add the configured response time thresholds to the analyzer columns if CONFIG.useThresholds and len(CONFIG.rtimeThresholds) > 0: numberFormat = NumberFormat.getNumberInstance() list = CONFIG.rtimeThresholds thresholds = list[:len(list) - 1] # the first group colName = "under %s sec" % numberFormat.format(thresholds[0]) analyzerPlugin.addColumnName(colName) # the middle groups if len(thresholds) > 1: for i in range(len(thresholds) - 1): colName = "%s to %s sec" % (numberFormat.format(thresholds[i]), numberFormat.format(thresholds[i + 1])) analyzerPlugin.addColumnName(colName) # the last group name = "over %s sec" % numberFormat.format(thresholds[len(thresholds) - 1]) analyzerPlugin.addColumnName(name) logger.warn("Starting log analysis.") for line in summaryData.getTestDataLines(): if CONFIG.isShowTransactionData(): if line.startswith("Test") or line.startswith("(Test"): row = self.getRow(line) logger.debug("Adding row name %s" % row.getTxName()) analyzerPlugin.addDataRow(row) if line.startswith("Totals"): analyzerPlugin.setTotalsRow(self.getRow(line, True))
def __init__(self, menuHandles, manager, isDominant, systemPanel, isTemporal=False): self.systemPanel = systemPanel self.knownPops = 0 self.ignoreChanges = True JPanel() self.menuHandles = menuHandles self.isDominant = isDominant self.isTemporal = isTemporal if isDominant: self.setLayout(GridLayout(8, 2)) else: self.setLayout(GridLayout(5, 2)) if isTemporal: self.add(JLabel("Ne")) ne = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) ne.addPropertyChangeListener(self) self.ne = ne self.add(ne) else: self.add(JLabel("Attempted Fst")) fst = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) fst.addPropertyChangeListener(self) self.fst = fst self.add(fst) self.add(JLabel("Expected total pops")) pops = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US)) pops.addPropertyChangeListener(self) # self.pops = JComboBox(['1', '2', '4', '8', '12', '16']) self.pops = pops self.add(self.pops) if not isDominant and not isTemporal: self.add(JLabel("Mutation model")) self.mut = JComboBox(["Infinite Alleles", "Stepwise"]) self.mut.addItemListener(self) self.add(self.mut) self.add(JLabel("Subsample size")) sampleSize = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US)) sampleSize.addPropertyChangeListener(self) self.sampleSize = sampleSize self.add(self.sampleSize) if isDominant: self.add(JLabel("Theta")) theta = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) theta.addPropertyChangeListener(self) self.theta = theta self.add(theta) theta.setValue(0.1) self.add(JLabel("Beta-a")) beta1 = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) beta1.addPropertyChangeListener(self) self.beta1 = beta1 self.add(beta1) beta1.setValue(0.25) self.add(JLabel("Beta-b")) beta2 = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) beta2.addPropertyChangeListener(self) self.beta2 = beta2 self.add(beta2) beta2.setValue(0.25) self.add(JLabel("Critical frequency")) crit = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) crit.addPropertyChangeListener(self) self.crit = crit self.add(crit) crit.setValue(0.99) run = JButton("Run!") run.addActionListener(manager) run.setActionCommand("RunFDist") self.run = run self.add(run) cancel = JButton("Stop") cancel.addActionListener(manager) cancel.setActionCommand("CancelFDist") self.cancel = cancel
def __init__(self, menuHandles, manager, isDominant, systemPanel, isTemporal=False): self.systemPanel = systemPanel self.knownPops = 0 self.ignoreChanges = True JPanel() self.menuHandles = menuHandles self.isDominant = isDominant self.isTemporal = isTemporal if isDominant: self.setLayout(GridLayout(8, 2)) else: self.setLayout(GridLayout(5, 2)) if isTemporal: self.add(JLabel('Ne')) ne = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US)) ne.addPropertyChangeListener(self) self.ne = ne self.add(ne) self.add(JLabel('Expected total samples')) else: self.add(JLabel('Attempted Fst')) fst = JFormattedTextField(NumberFormat.getNumberInstance( Locale.US)) fst.addPropertyChangeListener(self) self.fst = fst self.add(fst) self.add(JLabel('Expected total pops')) pops = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US)) pops.addPropertyChangeListener(self) # self.pops = JComboBox(['1', '2', '4', '8', '12', '16']) self.pops = pops self.add(self.pops) if not isDominant and not isTemporal: self.add(JLabel('Mutation model')) self.mut = JComboBox(['Infinite Alleles', 'Stepwise']) self.mut.addItemListener(self) self.add(self.mut) else: self.mut = None self.add(JLabel('Subsample size')) sampleSize = JFormattedTextField( NumberFormat.getIntegerInstance(Locale.US)) sampleSize.addPropertyChangeListener(self) self.sampleSize = sampleSize self.add(self.sampleSize) if isDominant: self.add(JLabel('Theta')) theta = JFormattedTextField( NumberFormat.getNumberInstance(Locale.US)) theta.addPropertyChangeListener(self) self.theta = theta self.add(theta) theta.setValue(0.1) self.add(JLabel('Beta-a')) beta1 = JFormattedTextField( NumberFormat.getNumberInstance(Locale.US)) beta1.addPropertyChangeListener(self) self.beta1 = beta1 self.add(beta1) beta1.setValue(0.25) self.add(JLabel('Beta-b')) beta2 = JFormattedTextField( NumberFormat.getNumberInstance(Locale.US)) beta2.addPropertyChangeListener(self) self.beta2 = beta2 self.add(beta2) beta2.setValue(0.25) self.add(JLabel('Critical frequency')) crit = JFormattedTextField( NumberFormat.getNumberInstance(Locale.US)) crit.addPropertyChangeListener(self) self.crit = crit self.add(crit) crit.setValue(0.99) run = JButton('Run!') run.addActionListener(manager) run.setActionCommand('RunFDist') self.run = run self.add(run)
def run( self ) : #--------------------------------------------------------------------------- # Name: label() # Role: Instantiate a Right aligned label with the specified text #--------------------------------------------------------------------------- def label( text ) : return JLabel( text + ' ', horizontalAlignment = SwingConstants.RIGHT ) frame = JFrame( 'PropertyListener', layout = BorderLayout(), locationRelativeTo = None, size = ( 400, 300 ), defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) pane = JPanel( layout = GridLayout( 0, 2 ) ) pane.add( label( 'Number:' ) ) pane.add( JFormattedTextField( NumberFormat.getNumberInstance(), value = 12345.67890, columns = 10, propertyChange = self.changed ) ) pane.add( label( 'Currency:' ) ) pane.add( JFormattedTextField( NumberFormat.getCurrencyInstance(), value = 12345.67890, columns = 10, propertyChange = self.changed ) ) frame.add( JSplitPane( JSplitPane.HORIZONTAL_SPLIT, pane, JButton( 'Clear', actionPerformed = self.clear ), ), BorderLayout.NORTH ) self.textArea = JTextArea( rows = 10, columns = 40, editable = 0, focusable = 0, font = Font( 'Courier' , Font.BOLD, 12 ) ) frame.add( JScrollPane( self.textArea ), BorderLayout.CENTER ) frame.setVisible( 1 )