From: Cliff H. <xl...@da...> - 2009-08-18 23:45:21
|
Well, continuing on with my efforts, I've gotten the basics set up for an old standard program I'd write to learn a new language... Simple program (and right now, not completely functioning) that merely creates an array of sequential integers (array = range(100)), shuffles the array, and sorts it. All in a graphical representation. Nothing too fancy... but I'm playing around with GAE/J, GWT, and Jython... so this now is written using those three technologies together. The UI is written using GWT, the display is a table with dimensions 100x100. The individual cells are then used as pixels, and I use CSS styles to turn the pixels on or off. The Start button currently simply runs a bubble sort routine. I'll be adding to this later. Upon pressing Start: - a GWT-RPC async call is submitted to the Jython servlet that does the actual processing. - The servlet returns an array of updates for the GWT display to work with. These are objects I made that handle inserting, removing, swapping, or moving an element. - The update objects are created through the use of Jython generators which loads up the Jython list which is returned (and received as an array in GWT). - The actual sorting function is stored in the datastore, as source code, which Jython compiles and uses to sort the array. My thought here is to have a way for people to be able to see the actual sorting code in the UI, I want to minimize the ShowSort specific code and be able to have a text-parser remove it so the end result is a clean, crisp, and reusable code for those who desire it... - The status line updates whenever the actual Update object is processed. The name of the function in Jython which is running when the Update object was created will show in the status line. The result is I have a clear separation of processing (Jython) from user interface (GWT). I even have a separation between data & style by using XHTML 1.1 strict and a CSS stylesheet. Getting all of this to work has been educational, to be sure. I'm rather impressed with how Jython gracefully interacts with Java, even in a web application environment. The demo app is at: http://showsort.appspot.com I still have a number of "to do" bits in the code to finish up, like getting the system working with multiple sorting algorithms, loading them into the datastore, and building an admin interface for managing the sorting algorithms. I might even try and make the CSS be generated dynamically so I can hand-configure the settings of the application to suit my needs, without needing to recompile the system. Oh, some caveats: Currently, this seems to run fastest on Firefox, Safari, and Opera. It runs slower on Chrome, and I pity the person who dares to run this in Internet Explorer (eye-bleedingly slow!). Both Internet Explorer and Opera don't quite create the display's table properly... so I'd recommend skipping those two browsers... IE more than Opera though because it takes *forever* to run there (actually, it takes almost as long to run it in the hosted browser as well, which makes development a little annoying). Chrome is also slower, and not recommended (yes, I've tried Chrome 2 and 3 with the same result -- so much for Chrome being superior in speed to the others...) Your best bet, if you want to see this run, is to use Firefox or Safari. -- "I'm not responcabel fer my computer's spleling errnors" - Xlorep DarkHelm Website: http://darkhelm.org Sent from Santa Maria, California, United States |