def run(self): frame = JFrame('cbEdit3', size=(200, 125), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) table = JTable(tm(), rowHeight=20) table.setDefaultRenderer(JComboBox, cbRenderer()) table.setDefaultEditor(JComboBox, cbEditor()) frame.add(JScrollPane(table)) frame.setVisible(1)
def done(self): table = JTable(methodTableModel( self.data, ['Method', 'Description / Abstract'], ), font=monoFont, autoResizeMode=JTable.AUTO_RESIZE_LAST_COLUMN, selectionMode=ListSelectionModel.SINGLE_SELECTION) table.setDefaultRenderer(String, methRenderer()) table.getTableHeader().setReorderingAllowed(0) self.tPanes.extend(self.getTableInfo(table)) self.splitPane.setBottomComponent(JScrollPane(table))
def run(self): frame = JFrame( 'SpinEdit3', size=(200, 106), # size = ( 200, 116 ), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) table = JTable(tm(), rowHeight=20) # table = JTable( tm(), rowHeight = 25 ) table.setDefaultRenderer(JSpinner, sRenderer()) table.setDefaultEditor(JSpinner, editor()) frame.add(JScrollPane(table)) frame.setVisible(1)
def run(self): frame = JFrame('SecConfigReport_03', size=(300, 300), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) data = [] text = AdminTask.generateSecConfigReport() for line in text.splitlines()[2:]: data.append([info.strip() for info in line[:-2].split(';')]) table = JTable(reportTableModel( data, ';;;'.split(';'), ), selectionMode=ListSelectionModel.SINGLE_SELECTION) table.setDefaultRenderer(String, reportRenderer()) frame.add(JScrollPane(table)) frame.pack() frame.setVisible(1)
def addTabs(self, container): head = 'Row,Col,Cell'.split(',') junk = 'False,True'.split(',') data = [[0, 1], [0, 1]] info = JTable( # Used to get default attributes data, head, selectionMode=LSM.SINGLE_SELECTION) bTable = JTable(booleanTM(self.settings(info), head)) bTable.setDefaultRenderer(Boolean, boolRenderer()) tab1 = JPanel() tab1.add(JScrollPane(bTable)) info = JTable(data, head, selectionMode=LSM.SINGLE_INTERVAL_SELECTION) bTable = JTable(booleanTM(self.settings(info), head)) bTable.setDefaultRenderer(Boolean, boolRenderer()) tab2 = JPanel() tab2.add(JScrollPane(bTable)) info = JTable(data, head, selectionMode=LSM.MULTIPLE_INTERVAL_SELECTION) bTable = JTable(booleanTM(self.settings(info), head)) bTable.setDefaultRenderer(Boolean, boolRenderer()) tab3 = JPanel() tab3.add(JScrollPane(bTable)) tabs = JTabbedPane() tabs.addTab('Single', tab1) tabs.addTab('One Group', tab2) tabs.addTab('Multi-Group', tab3) container.add(tabs)
class SelPanel(JDialog, ActionListener): def actionPerformed(self, event): option = event.getActionCommand() if option == 'Close': self.dispose() elif option == 'SCI': chooser = JFileChooser() returnVal = chooser.showSaveDialog(self) if returnVal == JFileChooser.APPROVE_OPTION: fileName = chooser.getSelectedFile().getPath() f = open(fileName, 'w') f.write("\t".join([ "Het", "Fst", "0.5(1-pval)quantile", "median", "0.5(1+pval)quantile" ]) + "\n") for line in self.confLines: f.write('\t'.join(map(lambda x: str(x), line)) + "\n") f.close() elif option == 'SLL': chooser = JFileChooser() returnVal = chooser.showSaveDialog(self) if returnVal == JFileChooser.APPROVE_OPTION: fileName = chooser.getSelectedFile().getPath() f = open(fileName, 'w') f.write("\t".join( ["Locus", "Het", "Fst", "P(Simul Fst<sample Fst)"]) + "\n") for i in range(self.data.size()): line = self.data.elementAt(i) lineList = [str(line.elementAt(0))] lineList.append(str(line.elementAt(1))) lineList.append(str(line.elementAt(2))) lineList.append(str(line.elementAt(3))) f.write("\t".join(lineList) + "\n") f.close() def getP(self, pvLine): #there is a copy of this on Main if self.isDominant: p1 = pvLine[2] p2 = pvLine[3] p3 = pvLine[4] p = p1 - 0.5 * (p1 + p2 - 1) return p else: return pvLine[3] def calcFalsePositives(self, pv, ci, fdr): falses = [] pys = [] for i in range(len(pv)): p = self.getP(pv[i]) py = 1 - 2 * abs(p - 0.5) pys.append(py) #if p > ci or p<1-ci: # pys.append(py) pys.append(0.0) pys.sort() rate = [] maxRank = 0 for i in range(len(pys)): if pys[i] <= fdr * i / len(pys): maxRank = i #print maxRank falseReports = [] for pvLine in pv: p = self.getP(pvLine) py = 1 - 2 * abs(p - 0.5) if py in pys: if pys.index(py) <= maxRank: falseReports.append("Outlier") else: falseReports.append("--") else: falseReports.append("NA") return falseReports def initTable(self, lociNames, pv, ci, locusFst): colNames = Vector() colNames.add('Locus') colNames.add('Het') colNames.add('Fst') colNames.add('P(simulated Fst < sample Fst)') colNames.add('FDR') data = Vector() self.data = data falses = self.calcFalsePositives(pv, ci, self.fdr) currentPos = 0 for i in range(len(lociNames)): line = Vector() locus = lociNames[i] line.add(locus) if not locusFst[i]: line.add("NA") line.add("NA") line.add("NA") line.add("NA") else: line.add(str(pv[currentPos][0])) line.add(str(pv[currentPos][1])) line.add(str(self.getP(pv[currentPos]))) line.add(str(falses[currentPos])) currentPos += 1 data.add(line) self.table = JTable(data, colNames) self.table.setDefaultRenderer( Class.forName("java.lang.Object"), ColorRenderer(data, ci, self.chart.neuColor, self.chart.balColor, self.chart.posColor)) def __init__(self, frame, chart, lociNames, pv, ci, confLines, locusFst, isDominant, fdr): JDialog(frame) self.chart = chart self.frame = frame self.confLines = confLines self.isDominant = isDominant self.fdr = fdr pane = self.getRootPane().getContentPane() pane.setLayout(BorderLayout()) self.initTable(lociNames, pv, ci, locusFst) scrollPane = JScrollPane(self.table) osName = System.getProperty('os.name').lower() if not System.getProperty('java.specification.version')[-1] == '5': self.table.setFillsViewportHeight(True) pane.add(scrollPane, BorderLayout.CENTER) buttonPane = JPanel() sll = JButton('Save loci list') sll.addActionListener(self) sll.setActionCommand('SLL') buttonPane.add(sll) sci = JButton('Save confidence intervals') sci.addActionListener(self) sci.setActionCommand('SCI') buttonPane.add(sci) close = JButton('Close') close.addActionListener(self) close.setActionCommand('Close') buttonPane.add(close) pane.add(buttonPane, BorderLayout.PAGE_END) self.pack()
class SelPanel(JDialog, ActionListener): def actionPerformed(self, event): option = event.getActionCommand() if option == 'Close': self.dispose() elif option == 'SCI': chooser = JFileChooser() returnVal = chooser.showSaveDialog(self) if returnVal == JFileChooser.APPROVE_OPTION: fileName = chooser.getSelectedFile().getPath() f = open(fileName, 'w') f.write("\t".join(["Het", "Fst", "0.5(1-pval)quantile", "median", "0.5(1+pval)quantile"]) + "\n") for line in self.confLines: f.write('\t'.join(map(lambda x: str(x), line)) + "\n") f.close() elif option == 'SLL': chooser = JFileChooser() returnVal = chooser.showSaveDialog(self) if returnVal == JFileChooser.APPROVE_OPTION: fileName = chooser.getSelectedFile().getPath() f = open(fileName, 'w') f.write("\t".join(["Locus", "Het", "Fst", "P(Simul Fst<sample Fst)"]) + "\n") for i in range(self.data.size()): line = self.data.elementAt(i) lineList = [str(line.elementAt(0))] lineList.append(str(line.elementAt(1))) lineList.append(str(line.elementAt(2))) lineList.append(str(line.elementAt(3))) f.write("\t".join(lineList) + "\n") f.close() def getP(self, pvLine): #there is a copy of this on Main if self.isDominant: p1 = pvLine[2] p2 = pvLine[3] p3 = pvLine[4] p = p1 - 0.5 * (p1+p2-1) return p else: return pvLine[3] def calcFalsePositives(self, pv, ci, fdr): falses = [] pys = [] for i in range(len(pv)): p = self.getP(pv[i]) py = 1-2*abs(p-0.5) pys.append(py) #if p > ci or p<1-ci: # pys.append(py) pys.append(0.0) pys.sort() rate = [] maxRank=0 for i in range(len(pys)): if pys[i]<=fdr*i/len(pys): maxRank = i #print maxRank falseReports = [] for pvLine in pv: p = self.getP(pvLine) py = 1-2*abs(p-0.5) if py in pys: if pys.index(py)<=maxRank: falseReports.append("Outlier") else: falseReports.append("--") else: falseReports.append("NA") return falseReports def initTable(self, lociNames, pv, ci, locusFst): colNames = Vector() colNames.add('Locus') colNames.add('Het') colNames.add('Fst') colNames.add('P(simulated Fst < sample Fst)') colNames.add('FDR') data = Vector() self.data = data falses = self.calcFalsePositives(pv, ci, self.fdr) currentPos = 0 for i in range(len(lociNames)): line = Vector() locus = lociNames[i] line.add(locus) if not locusFst[i]: line.add("NA") line.add("NA") line.add("NA") line.add("NA") else: line.add(str(pv[currentPos][0])) line.add(str(pv[currentPos][1])) line.add(str(self.getP(pv[currentPos]))) line.add(str(falses[currentPos])) currentPos += 1 data.add(line) self.table = JTable(data, colNames) self.table.setDefaultRenderer(Class.forName("java.lang.Object"), ColorRenderer(data, ci, self.chart.neuColor, self.chart.balColor, self.chart.posColor)) def __init__(self, frame, chart, lociNames, pv, ci, confLines, locusFst, isDominant, fdr): JDialog(frame) self.chart = chart self.frame = frame self.confLines = confLines self.isDominant = isDominant self.fdr = fdr pane = self.getRootPane().getContentPane() pane.setLayout(BorderLayout()) self.initTable(lociNames, pv, ci, locusFst) scrollPane = JScrollPane(self.table) osName = System.getProperty('os.name').lower() if not System.getProperty('java.specification.version')[-1] == '5': self.table.setFillsViewportHeight(True) pane.add(scrollPane, BorderLayout.CENTER) buttonPane = JPanel() sll = JButton('Save loci list') sll.addActionListener(self) sll.setActionCommand('SLL') buttonPane.add(sll) sci = JButton('Save confidence intervals') sci.addActionListener(self) sci.setActionCommand('SCI') buttonPane.add(sci) close = JButton('Close') close.addActionListener(self) close.setActionCommand('Close') buttonPane.add(close) pane.add(buttonPane, BorderLayout.PAGE_END) self.pack()