def addCourse(): global tfCourseName global tfCourseId global tfCourseFee global frame global btnEnter frame = JFrame("Add Course ") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setSize(450, 450) frame.setLocation(200, 200) frame.setLayout(None) frame.setVisible(True) panel = JPanel() panel.setSize(450, 450) panel.setLocation(0, 0) panel.setLayout(None) panel.setVisible(True) panel.setBackground(Color.LIGHT_GRAY) heading = JLabel("ADD COURSE") heading.setBounds(200, 30, 150, 40) lbCourseName = JLabel("Course Name ") lbCourseId = JLabel("Course Id") lbCourseFee = JLabel(" Course Fee") tfCourseName = JTextField() tfCourseId = JTextField() tfCourseFee = JTextField() lbCourseName.setBounds(70, 120, 130, 30) lbCourseId.setBounds(70, 170, 130, 30) lbCourseFee.setBounds(70, 220, 130, 30) tfCourseName.setBounds(220, 120, 150, 30) tfCourseId.setBounds(220, 170, 150, 30) tfCourseFee.setBounds(220, 220, 150, 30) btnEnter = JButton("Enter", actionPerformed=clickAddCourseFee) btnEnter.setBounds(300, 300, 100, 40) btnCancel = JButton("Cancel", actionPerformed=clickCancel) btnCancel.setBounds(70, 300, 100, 40) panel.add(heading) panel.add(lbCourseName) panel.add(lbCourseId) panel.add(lbCourseFee) panel.add(tfCourseFee) panel.add(tfCourseName) panel.add(tfCourseId) panel.add(tfCourseFee) panel.add(btnEnter) panel.add(btnCancel) frame.add(panel)
def showLoginIdPassword(data): global frame frame = JFrame("Show Id Password ") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setSize(500,350) frame.setLocation(200,200) frame.setLayout(None) frame.setVisible(True) panel = JPanel() panel.setSize(500,350) panel.setLocation(0,0) panel.setLayout(None) panel.setVisible(True) panel.setBackground(Color.LIGHT_GRAY) heading = JLabel("LoginId AND Password") heading.setBounds(200,30,150,40) lbLoginId = JLabel("LoginId") lbPassword = JLabel("password") tfLoginId = JTextField(data[0].encode('ascii')) tfPassword = JTextField(data[1].encode('ascii')) tfLoginId.setEditable(False) tfPassword.setEditable(False) lbLoginId.setBounds(50,100,150,30) lbPassword.setBounds(50,150,150,30) tfLoginId.setBounds(220,100,150,30) tfPassword.setBounds(220,150,150,30) btnOk = JButton("Ok",actionPerformed=clickOk) btnOk.setBounds(250,220,100,30) panel.add(heading) panel.add(lbLoginId) panel.add(lbPassword) panel.add(tfLoginId) panel.add(tfPassword) panel.add(btnOk) frame.add(panel)
def __init__(self): # Panel for Measurements self.setLayout(BorderLayout()) # LINE_START p3= JPanel() p3.setLayout(GridLayout(3,1)) button1= JButton('Mode Estimation', actionPerformed= self.modeComputation) button2= JButton('button2', actionPerformed= self.modeComputation) button3= JButton('button3', actionPerformed= self.modeComputation) p3.add(button1) p3.add(button2) p3.add(button3) self.add(p3, BorderLayout.LINE_START) # LINE_END reportMeas= JPanel() reportMeas.setSize(Dimension(800,640)) self.add(reportMeas, BorderLayout.CENTER)
def doall(locations, fileobs,filerun1,filerun2,stime,etime,imageDir='d:/temp',weights=None,filter_type="AVE",normalize=False): obs=HecDss.open(fileobs,True) obs.setTimeWindow(stime,etime) run1=HecDss.open(filerun1,True) run1.setTimeWindow(stime,etime) if filerun2 != None: run2=HecDss.open(filerun2,True) run2.setTimeWindow(stime,etime) else: run2=None rms1=0 rms1_min,rms1_max=0,0 rms2=0 rms2_min,rms2_max=0,0 rmsmap={} #run2=None sumwts=0 average_interval=None; for l in locations: data1=get_matching(obs,'A=%s C=%s E=15MIN'%(l,type)) if data1 == None: data1=get_matching(obs,'A=%s C=%s E=1DAY'%(l,type)) if data1 == None: data1=get_matching(obs,'A=%s C=%s E=IR-DAY'%(l,type)) if data1 == None: data1=get_matching(obs,'A=%s C=%s E=1HOUR'%(l,type)) drun1=get_matching(run1,'B=%s C=%s'%(l,type)) if run2 != None: drun2=get_matching(run2, 'B=%s C=%s'%(l,type)) else: drun2=None avg_intvl="1DAY" if data1 != None: if average_interval != None: dobsd=TimeSeriesMath(data1).transformTimeSeries(average_interval, None, filter_type, 0) else: dobsd=TimeSeriesMath(data1) if normalize: dobsd=dobsd.divide(TimeSeriesMath(data1).mean()) dobsm=TimeSeriesMath(data1).transformTimeSeries(avg_intvl, None, filter_type, 0) dobsm_max=TimeSeriesMath(data1).transformTimeSeries(avg_intvl, None, "MAX", 0) dobsm_max.data.fullName=dobsm_max.data.fullName+"MAX" dobsm_min=TimeSeriesMath(data1).transformTimeSeries(avg_intvl, None, "MIN", 0) dobsm_min.data.fullName=dobsm_min.data.fullName+"MIN" if normalize: dobsm=dobsm.divide(TimeSeriesMath(data1).mean()) if drun1==None: continue; else: if average_interval != None: drun1d=TimeSeriesMath(drun1).transformTimeSeries(average_interval, None, filter_type, 0) else: drun1d=TimeSeriesMath(drun1) if normalize: drun1d=drun1d.divide(TimeSeriesMath(drun1).mean()) if drun2 != None: if average_interval != None: drun2d=TimeSeriesMath(drun2).transformTimeSeries(average_interval, None, filter_type, 0) else: drun2d=TimeSeriesMath(drun2) if normalize: drun2d=drun2d.divide(TimeSeriesMath(drun2).mean()) drun1m=TimeSeriesMath(drun1).transformTimeSeries(avg_intvl, None, filter_type, 0) drun1m_max=TimeSeriesMath(drun1).transformTimeSeries(avg_intvl, None, "MAX", 0) drun1m_min=TimeSeriesMath(drun1).transformTimeSeries(avg_intvl, None, "MIN", 0) if normalize: drun1m=drun1m.divide(TimeSeriesMath(drun1).mean()) if drun2 != None: drun2m=TimeSeriesMath(drun2).transformTimeSeries(avg_intvl, None, filter_type, 0) drun2m_max=TimeSeriesMath(drun2).transformTimeSeries(avg_intvl, None, "MAX", 0) drun2m_min=TimeSeriesMath(drun2).transformTimeSeries(avg_intvl, None, "MIN", 0) if normalize: drun2m=drun2m.divide(TimeSeriesMath(drun2).mean()) else: drun2m=None if weights != None: sumwts=sumwts+weights[l] lrms1 = calculate_rms(drun1m.data, dobsm.data)*weights[l] lrms1_min=calculate_rms(drun1m_min.data,dobsm_min.data)*weights[l] lrms1_max=calculate_rms(drun1m_max.data,dobsm_max.data)*weights[l] rms1=rms1+lrms1 rms1_min=rms1_min+lrms1_min rms1_max=rms1_max+lrms1_max lrms2 = calculate_rms(drun2m.data,dobsm.data)*weights[l] lrms2_min=calculate_rms(drun2m_min.data,dobsm_min.data)*weights[l] lrms2_max=calculate_rms(drun2m_max.data,dobsm_max.data)*weights[l] rmsmap[l] = lrms1,lrms2,lrms1_min,lrms2_min,lrms1_max,lrms2_max rms2=rms2+lrms2 rms2_min=rms2_min+lrms2_min rms2_max=rms2_max+lrms2_max plotd = newPlot("Hist vs New Geom [%s]"%l) if data1 != None: plotd.addData(dobsd.data) plotd.addData(drun1d.data) if drun2 != None: plotd.addData(drun2d.data) plotd.showPlot() legend_label = plotd.getLegendLabel(drun1d.data) legend_label.setText(legend_label.getText()+" ["+str(int(lrms1*100)/100.)+","+str(int(lrms1_min*100)/100.)+","+str(int(lrms1_max*100)/100.)+"]") legend_label = plotd.getLegendLabel(drun2d.data) legend_label.setText(legend_label.getText()+" ["+str(int(lrms2*100)/100.)+","+str(int(lrms2_min*100)/100.)+","+str(int(lrms2_max*100)/100.)+"]") plotd.setVisible(False) xaxis=plotd.getViewport(0).getAxis("x1") vmin =xaxis.getViewMin()+261500. # hardwired to around july 1, 2008 xaxis.setViewLimits(vmin,vmin+10000.) if data1 != None: pline = plotd.getCurve(dobsd.data) pline.setLineVisible(1) pline.setLineColor("blue") pline.setSymbolType(Symbol.SYMBOL_CIRCLE) pline.setSymbolsVisible(0) pline.setSymbolSize(3) pline.setSymbolSkipCount(0) pline.setSymbolFillColor(pline.getLineColorString()) pline.setSymbolLineColor(pline.getLineColorString()) g2dPanel = plotd.getPlotpanel() g2dPanel.revalidate(); g2dPanel.paintGfx(); plotm = newPlot("Hist vs New Geom Monthly [%s]"%l) plotm.setSize(1800,1200) if data1 != None: plotm.addData(dobsm.data) #plotm.addData(dobsm_max.data) #plotm.addData(dobsm_min.data) plotm.addData(drun1m.data) #plotm.addData(drun1m_max.data) #plotm.addData(drun1m_min.data) if drun2 != None: plotm.addData(drun2m.data) #plotm.addData(drun2m_max.data) #plotm.addData(drun2m_min.data) plotm.showPlot() if data1 != None: pline = plotm.getCurve(dobsm.data) pline.setLineVisible(1) pline.setLineColor("blue") pline.setSymbolType(Symbol.SYMBOL_CIRCLE) pline.setSymbolsVisible(0) pline.setSymbolSize(3) pline.setSymbolSkipCount(0) pline.setSymbolFillColor(pline.getLineColorString()) pline.setSymbolLineColor(pline.getLineColorString()) plotm.setVisible(False) if data1 != None: plots=do_regression_plots(dobsm,drun1m,drun2m) if plots != None: spanel = plots.getPlotpanel() removeToolbar(spanel) mpanel = plotm.getPlotpanel() removeToolbar(mpanel) dpanel = plotd.getPlotpanel() removeToolbar(dpanel) from javax.swing import JPanel,JFrame from java.awt import GridBagLayout, GridBagConstraints mainPanel = JPanel() mainPanel.setLayout(GridBagLayout()) c=GridBagConstraints() c.fill=c.BOTH c.weightx,c.weighty=0.5,1 c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4 if data1 != None: if plots != None: pass #mainPanel.add(spanel,c) c.gridx,c.gridy,c.gridwidth,c.gridheight=0,0,10,4 c.weightx,c.weighty=1,1 mainPanel.add(mpanel,c) c.gridx,c.gridy,c.gridwidth,c.gridheight=0,4,10,6 mainPanel.add(dpanel,c) fr=JFrame() fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) fr.getContentPane().add(mainPanel) fr.setSize(1100,850); fr.show(); mainPanel.setSize(1100,850); mainPanel.setBackground(Color.WHITE); #import time; time.sleep(5) saveToPNG(mainPanel,imageDir+l+".png") if weights != None: rms1=(rms1+rms1_min+rms1_max)/sumwts rms2=(rms2+rms2_min+rms2_max)/sumwts print 'RMS Run 1: %f'%rms1 print 'RMS Run 2: %f'%rms2 for loc in rmsmap.keys(): print loc, rmsmap[loc]
compression = float(line[0:line.index('\t')]) stringpart = line[line.index("for") + 3:].strip() oldstring, newstring = stringpart.split(" <=> ") record = Record(compression, oldstring, newstring) records.append(record) numberOfStringPairs = len(records) frame = JFrame("test") frame.setSize(600, 400) panel = JPanel(GridLayout(numberOfStringPairs, 2)) size = Dimension(600, 200 * numberOfStringPairs) panel.setSize(size) panel.setPreferredSize(size) records.sort() for record in records: try: oldname, oldVertices, oldEdges = record.oldstring.split(' ') newname, newVertices, newEdges = record.newstring.split(' ') oldPanel = LinearViewPanel(300, 200) oldPanel.renderVertices(oldVertices) oldPanel.renderEdges(oldEdges) oldPanel.setToolTipText(oldname) panel.add(oldPanel) newPanel = LinearViewPanel(300, 200)
def doall(locations, fileobs, filerun1, filerun2, stime, etime, imageDir='d:/temp', weights=None, filter_type="AVE", normalize=False): obs = HecDss.open(fileobs, True) obs.setTimeWindow(stime, etime) run1 = HecDss.open(filerun1, True) run1.setTimeWindow(stime, etime) if filerun2 != None: run2 = HecDss.open(filerun2, True) run2.setTimeWindow(stime, etime) else: run2 = None rms1 = 0 rms1_min, rms1_max = 0, 0 rms2 = 0 rms2_min, rms2_max = 0, 0 rmsmap = {} #run2=None sumwts = 0 average_interval = None for l in locations: data1 = get_matching(obs, 'A=%s C=%s E=15MIN' % (l, type)) if data1 == None: data1 = get_matching(obs, 'A=%s C=%s E=1DAY' % (l, type)) if data1 == None: data1 = get_matching(obs, 'A=%s C=%s E=IR-DAY' % (l, type)) if data1 == None: data1 = get_matching(obs, 'A=%s C=%s E=1HOUR' % (l, type)) drun1 = get_matching(run1, 'B=%s C=%s' % (l, type)) if run2 != None: drun2 = get_matching(run2, 'B=%s C=%s' % (l, type)) else: drun2 = None avg_intvl = "1DAY" if data1 != None: if average_interval != None: dobsd = TimeSeriesMath(data1).transformTimeSeries( average_interval, None, filter_type, 0) else: dobsd = TimeSeriesMath(data1) if normalize: dobsd = dobsd.divide(TimeSeriesMath(data1).mean()) dobsm = TimeSeriesMath(data1).transformTimeSeries( avg_intvl, None, filter_type, 0) dobsm_max = TimeSeriesMath(data1).transformTimeSeries( avg_intvl, None, "MAX", 0) dobsm_max.data.fullName = dobsm_max.data.fullName + "MAX" dobsm_min = TimeSeriesMath(data1).transformTimeSeries( avg_intvl, None, "MIN", 0) dobsm_min.data.fullName = dobsm_min.data.fullName + "MIN" if normalize: dobsm = dobsm.divide(TimeSeriesMath(data1).mean()) if drun1 == None: continue else: if average_interval != None: drun1d = TimeSeriesMath(drun1).transformTimeSeries( average_interval, None, filter_type, 0) else: drun1d = TimeSeriesMath(drun1) if normalize: drun1d = drun1d.divide(TimeSeriesMath(drun1).mean()) if drun2 != None: if average_interval != None: drun2d = TimeSeriesMath(drun2).transformTimeSeries( average_interval, None, filter_type, 0) else: drun2d = TimeSeriesMath(drun2) if normalize: drun2d = drun2d.divide(TimeSeriesMath(drun2).mean()) drun1m = TimeSeriesMath(drun1).transformTimeSeries( avg_intvl, None, filter_type, 0) drun1m_max = TimeSeriesMath(drun1).transformTimeSeries( avg_intvl, None, "MAX", 0) drun1m_min = TimeSeriesMath(drun1).transformTimeSeries( avg_intvl, None, "MIN", 0) if normalize: drun1m = drun1m.divide(TimeSeriesMath(drun1).mean()) if drun2 != None: drun2m = TimeSeriesMath(drun2).transformTimeSeries( avg_intvl, None, filter_type, 0) drun2m_max = TimeSeriesMath(drun2).transformTimeSeries( avg_intvl, None, "MAX", 0) drun2m_min = TimeSeriesMath(drun2).transformTimeSeries( avg_intvl, None, "MIN", 0) if normalize: drun2m = drun2m.divide(TimeSeriesMath(drun2).mean()) else: drun2m = None if weights != None: sumwts = sumwts + weights[l] lrms1 = calculate_rms(drun1m.data, dobsm.data) * weights[l] lrms1_min = calculate_rms(drun1m_min.data, dobsm_min.data) * weights[l] lrms1_max = calculate_rms(drun1m_max.data, dobsm_max.data) * weights[l] rms1 = rms1 + lrms1 rms1_min = rms1_min + lrms1_min rms1_max = rms1_max + lrms1_max lrms2 = calculate_rms(drun2m.data, dobsm.data) * weights[l] lrms2_min = calculate_rms(drun2m_min.data, dobsm_min.data) * weights[l] lrms2_max = calculate_rms(drun2m_max.data, dobsm_max.data) * weights[l] rmsmap[ l] = lrms1, lrms2, lrms1_min, lrms2_min, lrms1_max, lrms2_max rms2 = rms2 + lrms2 rms2_min = rms2_min + lrms2_min rms2_max = rms2_max + lrms2_max plotd = newPlot("Hist vs New Geom [%s]" % l) if data1 != None: plotd.addData(dobsd.data) plotd.addData(drun1d.data) if drun2 != None: plotd.addData(drun2d.data) plotd.showPlot() legend_label = plotd.getLegendLabel(drun1d.data) legend_label.setText(legend_label.getText() + " [" + str(int(lrms1 * 100) / 100.) + "," + str(int(lrms1_min * 100) / 100.) + "," + str(int(lrms1_max * 100) / 100.) + "]") legend_label = plotd.getLegendLabel(drun2d.data) legend_label.setText(legend_label.getText() + " [" + str(int(lrms2 * 100) / 100.) + "," + str(int(lrms2_min * 100) / 100.) + "," + str(int(lrms2_max * 100) / 100.) + "]") plotd.setVisible(False) xaxis = plotd.getViewport(0).getAxis("x1") vmin = xaxis.getViewMin() + 261500. # hardwired to around july 1, 2008 xaxis.setViewLimits(vmin, vmin + 10000.) if data1 != None: pline = plotd.getCurve(dobsd.data) pline.setLineVisible(1) pline.setLineColor("blue") pline.setSymbolType(Symbol.SYMBOL_CIRCLE) pline.setSymbolsVisible(0) pline.setSymbolSize(3) pline.setSymbolSkipCount(0) pline.setSymbolFillColor(pline.getLineColorString()) pline.setSymbolLineColor(pline.getLineColorString()) g2dPanel = plotd.getPlotpanel() g2dPanel.revalidate() g2dPanel.paintGfx() plotm = newPlot("Hist vs New Geom Monthly [%s]" % l) plotm.setSize(1800, 1200) if data1 != None: plotm.addData(dobsm.data) #plotm.addData(dobsm_max.data) #plotm.addData(dobsm_min.data) plotm.addData(drun1m.data) #plotm.addData(drun1m_max.data) #plotm.addData(drun1m_min.data) if drun2 != None: plotm.addData(drun2m.data) #plotm.addData(drun2m_max.data) #plotm.addData(drun2m_min.data) plotm.showPlot() if data1 != None: pline = plotm.getCurve(dobsm.data) pline.setLineVisible(1) pline.setLineColor("blue") pline.setSymbolType(Symbol.SYMBOL_CIRCLE) pline.setSymbolsVisible(0) pline.setSymbolSize(3) pline.setSymbolSkipCount(0) pline.setSymbolFillColor(pline.getLineColorString()) pline.setSymbolLineColor(pline.getLineColorString()) plotm.setVisible(False) if data1 != None: plots = do_regression_plots(dobsm, drun1m, drun2m) if plots != None: spanel = plots.getPlotpanel() removeToolbar(spanel) mpanel = plotm.getPlotpanel() removeToolbar(mpanel) dpanel = plotd.getPlotpanel() removeToolbar(dpanel) from javax.swing import JPanel, JFrame from java.awt import GridBagLayout, GridBagConstraints mainPanel = JPanel() mainPanel.setLayout(GridBagLayout()) c = GridBagConstraints() c.fill = c.BOTH c.weightx, c.weighty = 0.5, 1 c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 0, 10, 4 if data1 != None: if plots != None: pass #mainPanel.add(spanel,c) c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 0, 10, 4 c.weightx, c.weighty = 1, 1 mainPanel.add(mpanel, c) c.gridx, c.gridy, c.gridwidth, c.gridheight = 0, 4, 10, 6 mainPanel.add(dpanel, c) fr = JFrame() fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) fr.getContentPane().add(mainPanel) fr.setSize(1100, 850) fr.show() mainPanel.setSize(1100, 850) mainPanel.setBackground(Color.WHITE) #import time; time.sleep(5) saveToPNG(mainPanel, imageDir + l + ".png") if weights != None: rms1 = (rms1 + rms1_min + rms1_max) / sumwts rms2 = (rms2 + rms2_min + rms2_max) / sumwts print 'RMS Run 1: %f' % rms1 print 'RMS Run 2: %f' % rms2 for loc in rmsmap.keys(): print loc, rmsmap[loc]
#tabbed pane enkripsi dan dekripsi myTabbedPane = JTabbedPane() myTabbedPane.setSize(310, 214) myTabbedPane.setLocation(21, 299) #global regFont #regFont = awt.Font("Arial", Font.PLAIN, 13) #panel1 panel1 = JPanel() panel1.setOpaque(True) panel1.setBackground(Color.WHITE) panel1.setLayout(None) myTabbedPane.addTab("Enkripsi", panel1) panel1.setSize(393, 214) panel1.setLocation(0, 0) plainTextLabel = JLabel("Pesan asli") plainTextLabel.setSize(140, 15) plainTextLabel.setLocation(13, 13) plainTextLabel.setFont(regFont) cariPesanButton = JButton("cari pesan", actionPerformed=searchFile) cariPesanButton.setSize(100, 20) cariPesanButton.setLocation(166, 13) #y=308 cariPesanButton.setFont(regFont) plainTextFile = JLabel("n/a") plainTextFile.setSize(143, 15) plainTextFile.setLocation(166, 41)
informasiPane = JPanel() informasiTabbedPane = JTabbedPane() informasiTabbedPane.setSize(610, 600) informasiTabbedPane.setLocation(0, 0) #global regFont #regFont = awt.Font("Arial", Font.PLAIN, 13) #panel1 mainFormHelper = JPanel() mainFormHelper.setOpaque(True) mainFormHelper.setLayout(None) informasiTabbedPane.addTab("Halaman Utama", mainFormHelper) mainFormHelper.setSize(610, 599) mainFormHelper.setLocation(0, 0) naiveFormHelper = JPanel() naiveFormHelper.setOpaque(True) naiveFormHelper.setLayout(None) informasiTabbedPane.addTab("Naive Form", naiveFormHelper) naiveFormHelper.setSize(610, 599) naiveFormHelper.setSize(0, 0) hackerFormHelper = JPanel() hackerFormHelper.setOpaque(True) hackerFormHelper.setLayout(None) informasiTabbedPane.addTab("Hacker Form", hackerFormHelper) hackerFormHelper.setSize(610, 599) hackerFormHelper.setSize(0, 0)