Beispiel #1
0
 def handle(self):
     print 'connection from', self.client_address
     conn = self.request
     while 1:
         msg = conn.recv(20)
         if msg == "keymap":
             print "keymapping!"
             keymapFrame = JFrame('Key Mapping Configuration',
                            defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                            size = (300, 500)
                            )
             keyButton = JButton('Press any key in iPhone')
             keymapFrame.add(keyButton)
             keymapFrame.visible = True
             while 1:
                 recvKey = conn.recv(20)
                 keyButton.setLabel("%s?" % recvKey)
                 keyInput = raw_input()
                 keynum[recvKey] = keyInput
                 keyButton.setText('Press any key in iPhone')
                 if recvKey == "keymap":
                     keymapFrame.visible = False
                     break
         if msg == "quit()":
             conn.close()
             print self.client_address, 'disconnected'
             break
         print self.client_address, msg
Beispiel #2
0
    def run(self):
        frame = JFrame('MainFrame', defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE)
        self.addButtons(frame.getContentPane())
        frame.size = (300, 175)
        frame.visible = 1 

        self.frame = frame
        self.startTimerTask()
Beispiel #3
0
def cachedBPROM(genome, fileName, frame):
  """
  genome: Genome as a string.
  fileName: File to save the BPROM results in.
  swing: A JFrame or None.  If this is None then messages will be printed, if it isn't then
         they will also be put in a dialog box.

  return: Results of the BPROM prediction stored in a list of Promoter objects.

  If the file Specified by fileName already exists then this function simply parses the file
  already there.  Also, if a request is made to BPROM and nothing is returned, no file is
  created, the user is warned, and an empty list is returned.
  """
  offset = 25 if ".forward.bprom" in fileName else 50
  direction = "forward" if offset == 50 else "reverse"
    
  def getPromoters():
    input = open(fileName, "r")
    results = parseBPROM(input.read())
    input.close()
    return results

  if not os.path.isfile(fileName):
    results = urllib.urlopen("http://linux1.softberry.com/cgi-bin/programs/gfindb/bprom.pl",
                             urllib.urlencode({"DATA" : genome}))
    resultString = results.read()
    results.close()
    resultString = resultString[resultString.find("<pre>"):resultString.find("</pre>")]
    resultString = re.sub("<+.+>+", "", resultString).strip()
    if resultString:
      output = open(fileName, "w")
      output.write(resultString)
      output.close()
      return getPromoters()
    else:
      if frame:
        messageFrame = JFrame("BPROM Error",
                              defaultCloseOperation = WindowConstants.DISPOSE_ON_CLOSE)
        messageFrame.setLocation(frame.location().x + offset, frame.location().y + offset)
        messageFrame.contentPane.layout = GridBagLayout()
        constraints = GridBagConstraints()
        constraints.gridx, constraints.gridy = 0, 0
        constraints.gridwidth, constraints.gridheight = 1, 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.weightx, constraints.weighty = 1, 1
        messageFrame.contentPane.add(JLabel("<html>The pipeline will continue to run but BPROM<br/>did not process the request for promoters on the<br/>" + direction + " strand.  Try again tomorrow.</html>"), constraints)
        constraints.gridx, constraints.gridy = 0, 1
        constraints.fill = GridBagConstraints.NONE
        constraints.weightx, constraints.weighty = 1, 1
        constraints.anchor = GridBagConstraints.LINE_END
        messageFrame.contentPane.add(JButton("Ok", actionPerformed = lambda e: messageFrame.dispose()), constraints)
        messageFrame.pack()
        messageFrame.visible = True
      print "BPROM Error:", "The pipeline will continue to run but BPROM did not process the request for promoters on the " + direction + " strand.  Try again tomorrow"
      return []
  else:
    return getPromoters()
Beispiel #4
0
def run(sketch):
    from javax.swing import JFrame
    from processing.core import PApplet

    class Main(PApplet):

        def __init__(self, sketch):
            self.sketch = sketch
            P5_set_instance(self)

        def setup(self):
            self.sketch['setup']()

        def draw(self):
            self.sketch['draw']()

        def mousePressed(self, evt):
            P5_register_mouse_event(evt)
            self.sketch['mousePressed']()

        def mouseReleased(self, evt):
            P5_register_mouse_event(evt)

        def mouseClicked(self, evt):
            P5_register_mouse_event(evt)
            self.sketch['mouseClicked']()

        def mouseEntered(self, evt):
            P5_register_mouse_event(evt)

        def mouseExited(self, evt):
            P5_register_mouse_event(evt)

        def mouseDragged(self, evt):
            P5_register_mouse_event(evt)
            self.sketch['mouseDragged'](evt)

        def mouseMoved(self, evt):
            P5_register_mouse_event(evt)
            self.sketch['mouseMoved'](evt)

        def getField(self, name):
            # rqd due to PApplet's using frameRate and frameRate(n) etc.
            return self.class.superclass.getDeclaredField(name).get(self)

    if __name__ == '__main__' or True:
        frame = JFrame(title="Processing",
            resizable=0,
            defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
        panel = Main(sketch)
        frame.add(panel)
        panel.init()
        while panel.defaultSize and not panel.finished:
            pass
        frame.pack()
        frame.visible = 1
Beispiel #5
0
 def __init__(self):
     w = JFrame("Settler-o-matic", size = (120,680))
     w.setAlwaysOnTop(True)
     
     pause = JButton("Pause", actionPerformed = self.pause)
     w.add(pause, SOUTH)
     
     w.visible = True
     self.window = w
     self.pause = pause
Beispiel #6
0
    def run(self, query, print_urls = True, pr_weight =0.4, verbose = False):
        """this function basically runs a query""" 
        self.query = parse_query(query, self.reader)
        start_time = time.clock()
        
        self.n_show = 10
        
        if self.ah_flag is True:
            doc_ids, score, auth_ids, auth_score, hub_ids, hub_score = self.retrieve(verbose = verbose)
        elif self.pr_flag is True:
            doc_ids, score, pr_ids, pr = self.retrieve(pr_weight = pr_weight, verbose = verbose)
        else:
            doc_ids, score = self.retrieve(verbose = verbose)		

        end_time = time.clock()
        frame = JFrame('Ragav\'s Search Engine',
                        defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                        size = (100, 200)
                        )  
        panel = JPanel(GridLayout(0,1))
        frame.add(panel)                           

        print "in total  " + str(end_time - start_time) + " seconds for retrieval"
        
        if print_urls is True:
            # panel.add ( JLabel("vector space retreival" ) )
            for i in xrange(self.n_show):
                d = self.reader.document(doc_ids[i])			
                panel.add ( JLabel (d.getFieldable("path").stringValue().replace("%%", "/") ) )
                print "doc: [" + str(doc_ids[i]) + "], score: [" + str(score[doc_ids[i]]) +  "], url: " + d.getFieldable("path").stringValue().replace("%%", "/")

            if self.ah_flag is True:
                # panel.add ( Jlabel("authorities based retreival" ) )
                for i in xrange(self.n_show):
                    d = self.reader.document(auth_ids[i])			
                    panel.add (  JLabel (d.getFieldable("path").stringValue().replace("%%", "/") ) )

                # panel.add ( JLabel("hubs based retreival" ) )
                for i in xrange(self.n_show):
                    d = self.reader.document(hub_ids[i])			
                    panel.add (  JLabel  ( d.getFieldable("path").stringValue().replace("%%", "/") ) )


            elif self.pr_flag is True:
                # panel.add ( JLabel("page rank based retreival" ) )
                for i in xrange(self.n_Show):
                    d = self.reader.document(pr_ids[i])			
                    panel.add ( JLabel ( d.getFieldable("path").stringValue().replace("%%", "/") ) )


        print  "retrieval complete. "
        print  "..........................................................................."
        frame.pack() 
        frame.visible = True            
        return d 
Beispiel #7
0
def _open():
    frame = JFrame('Galahad',
                   defaultCloseOperation=WindowConstants.EXIT_ON_CLOSE)
    panel = JPanel(GridLayout(5, 2))
    frame.add(panel)

    chosen_values = {}
    def create_file_choice_button(name, label_text):
        button = JButton('Click to select')
        label = JLabel(label_text)
        file_chooser = JFileChooser()
        
        def choose_file(event):
            user_did_choose_file = (file_chooser.showOpenDialog(frame) ==
                                   JFileChooser.APPROVE_OPTION)
            if user_did_choose_file:
                file_ = file_chooser.getSelectedFile();
                button.text = chosen_values[name] = str(file_)
        button.actionPerformed = choose_file

        panel.add(label)
        panel.add(button)

    create_file_choice_button('binary',     'Binary archive:')
    create_file_choice_button('source',     'Source archive:')
    create_file_choice_button('output_dir', 'Output directory:')

    panel.add(JLabel(''))
    panel.add(JLabel(''))

    def run_fn(event):
        log_window = JFrame('Galahad Log')
        log_text_area = JTextArea()
        log_text_area.editable = False
        log_window.setSize(400, 500)
        log_window.add(log_text_area)
        log_window.show()
        log_text_area.append('sdfsdfsdfsdfsd %d' % 3)
        
    panel.add(JButton('Run analysis', actionPerformed=run_fn))
    panel.add(JButton('Quit', actionPerformed=lambda e: sys.exit(0)))

    frame.setSize(300, 160)
    frame.visible = True
Beispiel #8
0
 def startGui(self):
     frame = JFrame("Life", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     (R, C) = (self.numRows, self.numCols)
     gridPanel = JPanel(GridLayout(R, C))
     self.checkBoxes = [[JCheckBox() for c in range(C)] for r in range(R)]
     self.grid = [[False for c in range(C)] for r in range(R)]
     for r in range(R):
         for c in range(C):
             gridPanel.add(self.checkBoxes[r][c])
     frame.add(gridPanel)
     buttonPanel = JPanel(FlowLayout())
     stepButton = JButton("Step", actionPerformed=self._step)
     runButton = JToggleButton("Run", actionPerformed=self._run)
     buttonPanel.add(stepButton)
     buttonPanel.add(runButton)
     frame.add(buttonPanel, SOUTH)
     frame.pack()
     frame.locationRelativeTo = None
     frame.visible = True
def createMainWindow():
	# Create window
	frame = JFrame('Epiphany Core Visualisation',
		defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
		size = (660,675)
	)

	# Main layout
	mainLayout = JPanel()
	frame.add(mainLayout)

	# Title
	#title = JLabel('hello', JLabel.CENTER)
	#mainLayout.add(title)

	# Cores
	corepanel = JPanel(GridLayout(8,8))
	global cores
	cores = []
	for i in range(0,64):
		core = JPanel(GridLayout(2,1))
		core.setPreferredSize(Dimension(80,80))
		corename = '(' + str(i%8) + ',' + str(i/8) + ')'
                namelabel = JLabel(corename, JLabel.CENTER)
		namelabel.setFont(Font("Dialog", Font.PLAIN, 18))
		portname = str(i+MINPORT)
		portlabel = JLabel(portname, JLabel.CENTER)
	        portlabel.setFont(Font("Dialog", Font.PLAIN, 16))
		core.add(namelabel)
		core.add(portlabel)
		core.setBackground(Color.BLACK)
		corepanel.add(core)
		cores.append(core)
	mainLayout.add(corepanel)

	frame.visible = True
Beispiel #10
0
    def menuItemClicked(self, caption, messageInfo):
        response = messageInfo[0].getResponse()
        strResponse = ''.join([chr(c%256) for c in response])
        frame = JFrame('DOM XSS',size = (300,300))
        parentPanel = JPanel()


        #printedCode = JTextPane(text = strResponse)
        #'''
        #colored code
        printedCode = JTextPane()
        styledDoc = printedCode.getStyledDocument()
        style = printedCode.addStyle('ColoredCode',None)
        self.filter2(strResponse,styledDoc,style)
        #'''
        #Scroll Bar
        scrollPanel = JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
        scrollPanel.preferredSize = 1500,800
        scrollPanel.viewport.view = printedCode

        #Final Inclusion of Panels
        parentPanel.add(scrollPanel)
        frame.add(parentPanel)
        frame.visible = True
vdata = mdi.getGridData('V')

#---- Create wind vector layer from the U/V grid data
layer = DrawMeteoData.createGridVectorLayer(udata, vdata,  'UV_Vector', True)
#layer = DrawMeteoData.createGridBarbLayer(udata, vdata,  'UV_Barb', True)
#layer = DrawMeteoData.createStreamlineLayer(udata, vdata, 'Z_Streamline', True)

#---- Add layer
mapFrame.addLayer(layer)

#--- Move pressure layer to bottom
mapFrame.moveLayer(layer, 0)

#---- Add title
title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)

#---- Add wind arrow
windArrow = mapLayout.addWindArrow(660, 420)

#---- Zoom layout map
print 'Zoom layout map...'
mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(70, 140, 15, 55))

#---- Set mapframe
mapFrame.setGridXDelt(10)
mapFrame.setGridYDelt(10)

frame = JFrame('MeteoInfo Script Sample', size = (800, 600))
frame.add(mapLayout)
frame.visible = True
print 'Finished!'
Beispiel #12
0
def main():
	
	binNaviProxy = StandAlone.getPluginInterface()
	binNaviProxy.databaseManager.addDatabase("","com.mysql.jdbc.Driver","localhost","BINNAVI1","binnavi","binnavi",False,False)
	db=binNaviProxy.databaseManager.databases[0]
	db.connect()
	db.load()
	mods=db.getModules()
	
	### initiate dialogBox to setect the module that should be used.
	
	######################################################
	
	
	frame = JFrame('BinNavi Module Selector',layout=BorderLayout(),		
				defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
				size = (1500, 800)
			)
	frame2 = JFrame('Function Selector',layout=BorderLayout(),		
				defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
				size = (30, 30)
			)
			
	frame2.setFocusableWindowState(False)
	frame2.setFocusable(False)
	frame2.setAlwaysOnTop(False)
	#convert the module list into the string to be used in the TextBox.
	textTemp = map((lambda x,y:"[%d]%s"%(x,y)),range(len(mods)),mods) 
	textStr=''.join(textTemp)

	tx=JTextArea(textStr)
	tx.setLineWrap(True);
	tx.setWrapStyleWord(True);
	frame.add(tx,BorderLayout.PAGE_START)
	frame.visible = True
	modInd = JOptionPane.showInputDialog(frame2, "Enter the index of the chosen module", 
			 "Module selector");
	
	#Open the module returned by the index 
	bfname=mods[int(modInd)] # this modules correxponds to the chosen module
	bfname.load()
	funcViews=bfname.views
	#textTemp2 = ["[%d]%s"%(i,j) for i in range(len(funcViews)) for j in funcViews]
	textTemp2=map((lambda x,y:"[%d]%s"%(x,y.toString()[5:18])),range(len(funcViews)),funcViews)
	textStr1=''.join(textTemp2)
	## remove the older text from the frame view
	frame.remove(tx)
	frame.update(frame.getGraphics())
	frame.visible = False
	## create a new textArea with the string made from all the functions' name
	txStr=JTextArea(textStr1)
	#tx.setsrcollOffset(20)
	txStr.setLineWrap(True);
	txStr.setWrapStyleWord(True);
	frame.add(txStr,BorderLayout.PAGE_START)
	frame.update(frame.getGraphics())
	frame.visible = True
	funcInd = JOptionPane.showInputDialog(frame2, "Enter the index of the function", 
			 "Function selector");
   
 ######################################################
	
	
	bffunc=bfname.views[int(funcInd)] #this is the view of the buildfname function
	bffunc.load()
	
	frame2.setVisible(False)
	dispose(frame2)
	
	bfReil=bffunc.getReilCode() # this is the REIL code of the function
	bfReilGraph=bfReil.getGraph()
			
	instGraph = InstructionGraph.create(bfReilGraph)
	time.clock()
	results=doAnalysis(instGraph)
	totalTime=time.clock()
	#print "resultsLen", len([r for r in results])
			
	print "**** printing results *******\n"
	print "Total time:", totalTime, '\n'
	numNode=0
	for n in instGraph:
		numNode+=numNode
		
		nIn=list(results.getState(n).inVal)
		nIn.sort(key=itemgetter(0))
		nOut=list(results.getState(n).out)
		nOut.sort(key=itemgetter(0))
		print '@@ ',n.getInstruction(),'\n'
		print '\t In', nIn, '\n'
		print '\t OUT', nOut, '\n'
		print '\t memory: ',results.getState(n).memoryWritten, '\n'
	print "++++ Total instructions: %d +++++\n"%numNode		 
	#finally close the view of the function
	bffunc.close()
	#print bffunc.isLoaded()
	#junky=raw_input("function closed. enter any charater")
	


	print "Done! Closing the module selector window"
	frame.setVisible(False)
	dispose(frame)
def main():
    '''
    Main function that implements main algorithm
    
    '''
    # a file where some log will be created which says how many functions are discovered etc.
    logFile=raw_input("Enter the name of log file")
    # this is provided as an extra file which is a pickled file comtains a list of functions
    # that are found to be BOP. Its main purpose is: if you want to use these functions for some
    # other analysis, just load this file and viola!!!
    fileBOP=raw_input("Enter the file name (full path) to store (Pickled) BOP function's name: ")
    
    interestingFuncs={} # dictionary of interesting functions
    interestingFuncsLOC={} # dictionary of LOC in interesting functions

    binNaviProxy = StandAlone.getPluginInterface()
    
    ################## place to set database connectivity parameter ######### 
    binNaviProxy.databaseManager.addDatabase("","org.postgresql.Driver","localhost","DataBase_name","user","password",False,False)
    ########################################################################
    db=binNaviProxy.databaseManager.databases[0]
    db.connect()
    db.load()
    mods=db.getModules()

    ### initiate dialogBox to setect the module that should be used.

    ######################################################


    frame = JFrame('BinNavi Module Selector',layout=BorderLayout(),
                defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                size = (500, 500)
            )
    frame2 = JFrame('Function Selector',layout=BorderLayout(),
                defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                size = (30, 30)
            )


    #convert the module list into the string to be used in the TextBox.
    ## This gives a very ugly box to select the required function (yes, I am bit lazy to learn Java Swing!!). 
    textTemp = map((lambda x,y:"[%d]%s"%(x,y)),range(len(mods)),mods)
    textStr=''.join(textTemp)

    tx=JTextArea(textStr)
    tx.setLineWrap(True);
    tx.setWrapStyleWord(True);
    frame.add(tx,BorderLayout.PAGE_START)
    frame.visible = True
    modInd = JOptionPane.showInputDialog(frame2, "Enter the index of the chosen module",
             "Module selector");

    #Open the module returned by the index
    bfname=mods[int(modInd)] # this modules correxponds to the chosen module
    bfname.load()
    funcViews=bfname.views

    frame2.setVisible(False)
    dispose(frame2)

 ######################################################
    analyzedFunctions = 0
    totalDiscoveredLoops=0
    totalInterestingLoops=0
    time.clock()
    for funcInd in range(1,len(funcViews)):
        
        BBnum=funcViews[funcInd].getNodeCount()
        
        if BBnum <4:
            print "skipped"
            continue #do not analyse function if num of BB less than 4
        
        print 'analyzing %s'%funcViews[funcInd].getName()

        dominatingSets={}#dictionary to keep dominating nodes of a node

        bffunc=bfname.views[int(funcInd)] #this is the view of the buildfname function
        bffunc.load()
        try:
            bfReil=bffunc.getReilCode() # this is the REIL code of the function
        except:
            print "error in getReilCode()"
            bffunc.close()
            gc.collect()
            continue

        bfReilGraph=bfReil.getGraph()
        try:
            #dominatorTree = GraphAlgorithms.getDominatorTree(bfReilGraph, findRoot(bfReilGraph.getNodes())) #only for BinNavi v 3.0
            dominatorTree = GraphAlgorithms.getDominatorTree(bfReilGraph, findRoot(bfReilGraph.getNodes()),None)
        except:
            print "dominator tree problem.. continue with the next function"
            bffunc.close()
            gc.collect()
            continue

        fillDominatingSets(dominatorTree.getRootNode(), dominatingSets, None)

        # let us find loops in this function
        finalLoops=findLoops(bfReilGraph,dominatingSets)
        if finalLoops ==None:
            bffunc.close()
            gc.collect()
            continue
        analyzedFunctions = analyzedFunctions +1
        totalDiscoveredLoops = totalDiscoveredLoops + len(finalLoops)
        # check if the loops are potential candidates for being interesting.
        # this is done by checking if there are atleast 2 STM statements in each loop.
        #print "privious length", len(finalLoops)
        if len(finalLoops)== 0:
            bffunc.close()
            gc.collect()
            continue
        for lp in finalLoops.keys():
            countSTM=0
            for lpn in finalLoops[lp]:
                inst=lpn.getInstructions()
                for i in inst:

                    if i.getMnemonic() == 'stm':
                        countSTM=countSTM+1
                if countSTM >0:
                    break


            if countSTM <= 0:
                del finalLoops[lp]

        #print "latest length", len(finalLoops)

        if len(finalLoops)== 0:
            bffunc.close()
            gc.collect()
            continue


        instGraph = InstructionGraph.create(bfReilGraph)
        
        interestingFuncs[funcViews[funcInd].getName()]=[]
        
        for k in finalLoops.keys():
            print 'analysing loop at %s-%s'%(k[0],k[1])
            if k[0] == k[1]:
                print "skipping this loop as src= dest"
                continue
            #check to skip very big loops i.e. loops having 100 BB
            if len(finalLoops[k]) > 100:
                print "very big loop, skipping!"
                continue
            if isInteresting(finalLoops[k],instGraph) ==True:
                totalInterestingLoops = totalInterestingLoops + 1
                interestingFuncs[funcViews[funcInd].getName()].append(k)
                interestingFuncsLOC[str(funcViews[funcInd].getName())]=sum([len(x.getInstructions()) for x in (getCodeNodes(bffunc.getGraph()))])
                print 'loop at %s IS interesting.'%k[0]
            else:
                print 'loop at %s is NOT interesting.'%k[0]

        #finally close the view of the function
        bffunc.close()
        gc.collect()
        #print bffunc.isLoaded()
        #junky=raw_input("function closed. enter any charater")
    totalTime=time.clock()

# remove the function entries that do not have any interesting loops
    for ky in interestingFuncs.keys():
        if len(interestingFuncs[ky]) == 0:
            del interestingFuncs[ky]

    # write the results in a file
    #


    outFile=open(logFile,'w')
    outFile.write('########## Global Results ###########\n')
    outFile.write('Total Functions in the module: ')
    outFile.write(str(len(funcViews)))
    outFile.write('\nTotal Analyzed Functions in the module: ')
    outFile.write(str(analyzedFunctions))
    outFile.write('\nTotal Interesting Functions in the module: ')
    outFile.write(str(len(interestingFuncs)))
    outFile.write('\nTotal loops discovered in the module: ')
    outFile.write(str(totalDiscoveredLoops))
    outFile.write('\nTotal INTERESTING loops discovered in the module: ')
    outFile.write(str(totalInterestingLoops))
    outFile.write('\nTotal Time: ')
    outFile.write(str(totalTime))
    outFile.write('\n')
    outFile.write('########## Global Results ###########\n')
    for k in interestingFuncs.keys():
        outFile.write("%s: %s: %d"%(str(k), "LOC", interestingFuncsLOC[k]))
        outFile.write('\n')
        for l in interestingFuncs[k]:
            outFile.write('\t')
            outFile.write(str(l))
            outFile.write('\n')
    outFile.close()
    # before we save these BOPS, we include few widely known BOPs which are given int eh following list

    knownBOPs = ['strcpy', 'strncpy', 'memcpy','wcscpy']
    for fn in knownBOPs:
        interestingFuncs[fn] = []


    # save the function name as pickled objects
    fileBOPFd=open(fileBOP+'.pkl', 'w')
    pickle.dump(interestingFuncs.keys(), fileBOPFd)
    fileBOPFd.close()
    print "[*] Pickled in the file %s"%fileBOP+'.pkl'
    print "Done! Closing the module selector window"
    frame.setVisible(False)
    dispose(frame)
Beispiel #14
0
        try:
            x, y = county_to_coordinates(county)
        except Exception:
            return
        TREE, updated = insert(TREE, x, y)
        
        p.noStroke()
        p.rectMode(p.CORNER)
        drawT(updated)
        
        p.stroke(0)
        p.fill(255)
        p.rectMode(p.CORNERS)
        p.rect(0, p.height, 150, p.height - 20)
        
        p.fill(0)
        p.text(date, 5, p.height - 5)


if __name__ == '__main__':
    frame = JFrame(title="Processing",
                   resizable=0,
                   defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
    panel = HelloProcessing()
    frame.add(panel)
    panel.init()
    while panel.defaultSize and not panel.finished:
        pass
    frame.pack()
    frame.visible = 1
Beispiel #15
0
mainForm = JFrame("Halaman Utama", size=(987,610), )
myPanel = JPanel()
myPanel.setOpaque(True)
myPanel.setBackground(Color.WHITE)
myPanel.setLayout(None)

message = JLabel("<html><center>Teknik Pemecahan Kunci Algoritma ElGamal <br>Dengan Metode Index Calculus<html>", JLabel.CENTER)
message.setSize(987, 144)

message.setFont(myFont)
#message.setAlignmentX(433)
message.setAlignmentY(34)
mainForm.setContentPane(myPanel)
#mainForm.setSize(310, 125)
mainForm.locationByPlatform=True
mainForm.visible=True



#buttons creation
button1 = JButton("Naive User", actionPerformed=naiveButton)
button1.setSize(233,145)
button1.setLocation(226, 233)
button1.setFont(myFont)

button2 = JButton("Hacker", actionPerformed=hackerButton)
button2.setSize(233,145)
button2.setLocation(527, 233)
button2.setFont(myFont)

button3 = JButton("Tentang", actionPerformed = aboutButton)
Beispiel #16
0
    def __init__(self):
        """ setting up flags in this section """
        verbose = False					# if true prints a lot of stuff.. if false goes a little quiter
        create_lexicon_flag = True  	# if true will rebuild lexicon from scratch, if false will load a pre-created one as supplied in sys_arg[1]
        create_page_rank_flag = False    # same as for create page rank... default load file is 'page_rank' with loader extension
        normalize = True 				# will use document norms and normalized tf-idf, false will not.
        n_retrieves = 50   				# number of documents to retreive
        root_set_size = 50
        tf_idf_flag = True 		    # True retrieves based on Tf/idf, False retrieves based on only Tf. 
        directory = '../index'			# directory of index
        linksFile = "../index/IntLinks.txt"
        citationsFile = "../index/IntCitations.txt"    
        maxIter = 100    

        ah_flag = False
        pr_flag = False

        saver = json_down
        loader = json_up

        cluster_results = False
        num_clusters = 3


        if len(sys.argv) < 2:
            filename = 'temp'
        else:
            filename = sys.argv[1]

        frame = JFrame('Ragav\'s Search Engine',
                defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                size = (100, 100)
            )        
        panel = JPanel(GridLayout(0,2)) 
        frame.add(panel)           
        panel.add (JLabel("Loading please wait ... "))    
        frame.pack()
        frame.visible = True 
            
        start_time = time.clock()

        self.engine = search_gui ( 
                            filename = filename,
                            create_lexicon_flag = create_lexicon_flag, 
                            normalize = normalize,
                            directory = directory,
                            n_retrieves = n_retrieves,
                            cluster_results = cluster_results,
                            num_clusters = num_clusters,
                            maxIter = maxIter,
                            root_set_size = root_set_size,
                            tf_idf_flag = tf_idf_flag,
                            ah_flag = ah_flag,
                            pr_flag = pr_flag,
                            linksFile = linksFile,
                            create_page_rank_flag = create_page_rank_flag,
                            citationsFile = citationsFile,
                            saver = saver,
                            loader = loader,
                            verbose = verbose )
        end_time = time.clock()

        frame.visible = False
        if (end_time - start_time) > 60:
            message =  "finished loading in " + str((end_time - start_time)/60.) + " minutes" + "\n"
        else:
            message =  "finished loading in " + str(end_time - start_time) + " seconds" + "\n"
        
        print message
        
        frame = JFrame('Ragav\'s Search Engine',
                defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                size = (500, 50)
            )  
        panel = JPanel(GridLayout(0,2))
        frame.add(panel)                           
        self.query = JTextField('', 30)
        panel.add(self.query)       
        searchButton = JButton('Search', actionPerformed = self.run)
        panel.add(searchButton)    
        frame.visible = True   
# Put Objects Altogether on Panel
naiveFormPanel.add(naiveHeader, BorderLayout.CENTER)
naiveForm.add(myTabbedPane)
naiveFormPanel.add(primaLabel)
naiveFormPanel.add(aphaLabel)
naiveFormPanel.add(bitPrimaLabel)
naiveFormPanel.add(label1)
naiveFormPanel.add(betaLabel)
naiveFormPanel.add(bitPrima)
naiveFormPanel.add(genPrima)
naiveFormPanel.add(alpha)

alpha.text = "20135"
beta.text = "17096"
genPrima.text = "90059"

naiveFormPanel.add(beta)
naiveFormPanel.add(genKeyButton)
naiveFormPanel.add(kunciPrivatLabel)
naiveFormPanel.add(kunciPrivatTextBox)
naiveFormPanel.add(label3)
naiveFormPanel.add(label4)
naiveFormPanel.add(pesanAsli)
naiveFormPanel.add(scrollPanePTx)
naiveFormPanel.add(pesanTerenkripsi)
naiveFormPanel.add(scrollPaneCTx)

naiveForm.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE)
naiveForm.visible = True
naiveFormPanel.visible = True
Beispiel #18
0
 def show_data(self, event):
     frame = JFrame('%s Data' % self.view.network.name)
     frame.visible = True
     frame.add(timeview.data.DataPanel(self.view))
     frame.size = (500, 600)
Beispiel #19
0
# http://www.jython.org/jythonbook/en/1.0/GUIApplications.html
from java.awt import Component
from javax.swing import JTextArea, JFrame

import time

frame = JFrame('Message',
            defaultCloseOperation = JFrame.DO_NOTHING_ON_CLOSE,
            size = (300, 300)
        )

t = JTextArea(text = 'Hello\nworld',
              editable = False,
              wrapStyleWord = True,
              lineWrap = True,
              alignmentX = Component.LEFT_ALIGNMENT,
              size = (300, 1)
             )
frame.add(t)
frame.visible = True
sleep(2)
frame.visible = False
sleep(0.5)
t.text = "{}\n{}".format("Hello",time.asctime())
frame.visible = True
sleep(2)
frame.visible = False
frame.dispose()
frame = None
fn = os.path.join(dataDir, 'MICAPS/10101414.000')
mdi.openMICAPSData(fn)

#---- Get wind direction/speed station data
windDir = mdi.getStationData('WindDirection')
windSpeed = mdi.getStationData('WindSpeed')

#---- Create barb and vector wind layers
bLayer = DrawMeteoData.createSTBarbLayer(windDir, windSpeed, 'WindBarb_Point', False)
vLayer = DrawMeteoData.createSTVectorLayer(windDir, windSpeed, 'WindVector_Point', False)

#---- Add layers
mapFrame.addLayer(bLayer)
mapFrame.addLayer(vLayer)

#---- Add title
title = mapLayout.addText('MeteoInfo script demo', 350, 30, 'Arial', 16)

#---- Set layout map
print 'Set layout map...'
mapLayout.getActiveLayoutMap().setWidth(580)
mapLayout.getActiveLayoutMap().zoomToExtentLonLatEx(Extent(70, 140, 15, 55))

#---- Set mapframe
mapFrame.setGridXDelt(10)
mapFrame.setGridYDelt(10)

frame = JFrame('MeteoInfo Script Sample', size = (800, 600))
frame.add(mapLayout)
frame.visible = True
print 'Finished!'