Datascapes Workshop Notes, including assignments, tips, and so on

(note: most recent things are at the TOP of this page... like a blog or something...)

Contents





CLASS 8: Final notes...


Error Handling

You could say there are three main families of errors/problems you may encounter:
1. Syntax errors -- your code literally won't compile. These are usually easy to resolve by looking carefully at your code. Frequently you've just forgotten a semi-colon or a squiggly-bracket.

2. Data-handling errors: these are most typically errors such as "null pointer exceptions" that happen when you refer to (i.e. index into) an array at a point in the array that doesn't exist. E.g. you declare the following array:
String[] my_array;
And then, without initializing it with the "new" keyword, you try to use it:
my_array[2] = "Some string";
You'll get a big error from that, because my_array[2] doesn't exist. But even if you do properly initialize your array, e.g.:
my_array = new String[24]; // new array of 24 strings
for (int i=0; i < 24; i++) {
 my_array[i] = "the number is" + i;
}
you can still run into problems by referring to an element off the end of the array. This is very common, and will give you a "null pointer" error from java.

3. Design-level errors:
These are much more pernicious because they don't involve rights or wrongs, necessarily. It may be that you are storing all kinds of data in a format that just doesn't work. This kind of error is usually the result of not fully understanding what you are doing, and of having not thought/sketched enough before you started coding (or, of not taking enough breaks to ask yourself "what am I doing?").

Design-level errors happen all the time, to everybody at all levels, but try to use your sketchbook to think through your project as much as possible before you just start writing code, and use comments to mark out 'territory' in your code. E.g.
// global data structures
String some_array[];
My_Object structure[];
 
void setup() {
 
 // read in the initial data
 read_data_into_structure(); //(some function defined below)
}
 
void draw() {
 // update your 'engine'... maybe move things around, search the internet, change the colors, play the video forward...
 update_my_stuff(); // (some function defined below)
 
 // display the changes
 display_my_stuff(); // (some function defined below)
}
 
class My_Object
{
 // data paramters
 int x;
 int y;
 My_sub_object K[];
 String name;
 // etc.
 
 // constructor... set all the parameters
 My_Object(int a, int b, String c, int d ) {
 x = a;
 y = b;
 // etc.
}
 
 // methods of this object
 void update() {
 // change position and size of object based on...
}
 
 void display() {
 // code to draw the object
}
}

Roughly, what have we covered in the class?


Control structures:
- "For" loops, conditionals, etc.

Data structures:
- arrays
- linked lists (e.g. ArrayList)
- tree structures

Variables:
- declaring
- casting from one type to another (e.g. int to float, generic "Object" to your specific object)
- "instantiating" with the 'new' operator
- defining their "scope" (global or local...)

Coding practices:
- commenting your code
- debugging with println() calls

Object-oriented programming
- classes and objects (instances of classes)
- interface vs. implementation
- the "new" operator and constructors

Functions
- passing arguments
- returning values
- recursive functions

Text parsing:
- formatted text files
- Regular Expressions

Drawing with code:
- color and alpha values
- drawing shapes with an openGL-style Matrix

internet protocols
- SMTP, HTTP, RSS, etc.
- establishing network connections with Processing's network library
- APIs provided by certain websites
- ideas and examples of 'scraping' data from the web

Google Earth:
- overlaying and updating images
- outputting KML





CLASS 7: Various things ...


1. Recap of recursion
The tree example from last class used recursive techniques to draw branches composed of an inter-connected hierarchy of other branches. Recursion as a concept is nicely (if somewhat long-windedly) defined in the wikipedia entry. There is another entry more focused on computer science (i.e. programming) applications of recursion, too.

Basically, a recursive algorithm or function is one which, at some point in its code, calls itself. This leads to a kind of crazy, seemingly infinite looping. The key to avoiding the infinite part of it is to put in some kind of terminating condition. In the tree code from class 6 (linked as text files below), the terminating condition is when the current branch has no more children.

But my Branch code introduces more than just recursion. To understand recursion in its purest form, try this nice example from Daniel Shiffman. The key to the recursion is when the "branch()" function actually calls the "branch()" function, near the end of the code. When will the code actually stop calling itself? There must be a branch count or something, because we're only seeing five or so levels of branching.

MINI-TUTORIAL: TRY TO CREATE A FIBONACCI SEQUENCE USING A RECURSIVE FUNCTION.

2. The "Browser" object from the switchboard library
The switchboard library, to which you were introduced in Session 2, has an object in it called "Browser". The only official documentation for it, other than the painful JavaDoc (which you may find useful), is here. This includes a great example, which you should try! This is a very handy and powerful object: basically it's a full web-browser, driven by your Processing code. When you 'open' a webpage with the Browser object, it actually reads and parses (i.e. "makes sense of", "analyzes") the webpage and stores its contents as a whole bunch of parameters inside the Browser object. You can then reference those parameters by using the various methods of the Browser.

One of the interesting bits of code that the Browser object uses is the "XPath" library (this link is to a tutorial). This basically lets you refer to bits of any XML document using a path-like structure, e.g. "root/tag1/sub-tag2/sub-tag3". If you have tried parsing XML in other ways you will see immediately how incredibly useful this is.

The Browser automatically formats webpages in this way for you, so you can use its "query()" function to access any tag using a path-like search string. For example, here is some code that rips through a blog and grabs all the actual blog entries as text:
import org.switchboard.util.*;
import org.switchboard.browser.*;
 
Browser browser = new Browser();
 
 browser.open("http://speedbird.wordpress.com/");
 
 
 // use the funky XPath construction
 //String[] q = browser.query("//div[@class='post']/h2");
 
 // this gets the text of the entries
 String[] q = browser.query("//div[@class='entry']");
 
 for(int i=0; i<q.length; i++) {
 println("Query result " + q[i]);
 }
To understand how this query works, it really helps to View Source for the webpage you are trying to rip from, obviously!


3. Regular Expressions -- master your text parsing
Anybody who has ever searched for files on a computer probably knows about wildcard characters, such as the * when you search for all the text files in your computer: "*.txt" . This wildcard is a very simple example or pre-cursor to the wild world of Regular Expressions, which are basically a mini-scripting-language for filtering/parsing text.

Processing now has a "match()" function which will let you use regular expressions to make very careful conditional searches of text. It is officially still undocumented, but it uses very similar syntax to other (non-Processing) regular expression libraries. Here is one good example of how to use Processing's match() function.

It turns out that Processing's "split()" function, which almost all of you have already been using, also supports regular expressions. So here is an example of grabbing all the text, and ignoring all the tags (e.g. "<a href=....>"), from a string of html:
String[] snippets = split(some_html_string, "<.+?>");

Here is a good, relatively clear site on regular expressions. It has tutorials, useful examples for ripping HTML tags, and other reference material, including a downloadable program for working with regular expressions. But be careful: without proper documentation from the Processing people, you may run into issues you don't expect when you use the match() function.

In addition to being remarkably powerful, regular expressions can be extremely confusing and frustrating. To really work with them deeply, you should get a book (link pending), and you might want to learn enough Perl to use it for your text-parsing needs. Perl has the best reg-ex support of any language, arguably.

4. Databases...
So far we have been working with 'flatfiles' for our data storage needs -- i.e. text files that store a bunch of data in them, organized with simple tricks like tab- or comma-separation. This is perfectly adequate for most of your needs.

For those of you who have prior database programming experience, or who have so much data that you are finding flatfiles cumbersome to use, the best option will probably be install a MySQL database on your computer. Good, easy-to-install and to use database packages include WAMP and XAMPP. These include PHP, a server-side scripting language, and Apache, a web server.

For help with this please see me separately.







CLASS 6: Coding and Data Structure Charrette

These are the code for the 'full' version of my code, as pictured below.





tree_01.jpg
Step 1: Make a basic twig
- define a branch object, which remembers its start and end points and knows how to draw itself as a line
- draw a bunch of branches (e.g. 20) in a row (use an array to store them, and limit their length somehow!)
- (extra) make it restart when you click the mouse
- (extra) make the branch width (strokeweight) decrease as you move along the branch
- (extra) tweak your randomness so the branch doesn’t just draw over itself all the time.

Step2: Add new branches with the mouse
- now add the ability to add new branches with the mouse: every time the right mouse button clicks, add a branch going to that point of the mouse
o you will need to keep track of where the last branch ended.
o you will need to use the “append()” function to add to your array

Step 3: Try to split the branches
- now we want to split branches.
- add code to insert two branches every time you click the right mouse button
o use “mouseButton == RIGHT” to test for right button
- PROBLEM: how do we keep track of the ‘last branch’ point, now that we have two branches?
o you could use a new array[ ] of growth points. Ugh.
o you could only grow from one point... but this is a pretty lame tree

Step 4: Make the data work like a tree
What if now we wanted to use the UP and DOWN arrows to select different ‘generations’ of branches? What if we wanted each branch to know its level in the tree? These things become difficult to do using our current data structure (basically Branch objects kept in arrays).
Trees (literally, wooden trees) do not operate on an array-like principle. There is no ‘master list’ of branches. Instead, each branch pumps nutrients to and from the adjacent branches, to its ‘children’ and back up to its ‘parent’...
- So, add a “children[ ]” array to the Branch class
- add a “grow()” or “split()” function to the Branch class, which makes new Branches for its children (you can randomly generate their orientations...
- Get rid of your global array of branches. Instead, declare one Branch as your ‘root’
- You’ll need to re-think the draw() function

Step 5: Further tree exploration
Try using the UP and DOWN keys to ‘walk’ up and down the tree hierarchy, but highlighting whichever level of the tree you are at. You will have to add the notion of ‘level’ to the Branch class, and the notion of being selected (e.g. a variable called “boolean isSelected”).
Try making the growth of the tree sensitive to some kind of outside data. E.g. read in temperature data and have the tree grow or shrink based on the values read. Since the tree is not a purely linear data structure, its behaviour will not be purely dependent on the data you feed it.
What would a “bloom()” function look like, and do?
data_structures_01.jpg





CLASS 5: Features and Tips


Image manipulation in Processing:


Drawing vectors in Processing:

  • In addition to basic geometry (line(), triangle(), arc(), etc.), Processing has curve functions. Check them out under "Curves" in the extended reference (link above).
  • You can make more complex shapes by just laying down point after point, like a polyline. To do this, use the beginShape() and endShape() functions, as defined here: http://processing.org/reference/beginShape_.html
  • Remember the difference between vector graphics and raster graphics -- you can work with Processing in raster AND vector at once:
    • raster: go through the pixels one-by-one or use the image manipulation functions above
    • vector: use the various shape commands as seen in the extended reference under "2D Primitives" and "Curves"
  • But remember, while the pixels are all stored in an array by default, your vector points and the lines they define will have to be stored in some way by you... you need to create your own arrays or other data structures to store them
  • Color: to control the color of your geometry, you need to use the fill() and stroke() functions, among others. See under "Color" in the extended reference. Remember the alpha channel whenever you draw shapes! The best way to get overlapping lines and shapes to read clearly is to give them an alpha value. Typically this is just the fourth value in any color definition (e.g. stroke(red, green, blue, alpha).

3D drawing in Processing:

  • Unfortunately the Processing book doesn't document 3D stuff very well (though it has an interesting article about it). The best starting place for figuring this stuff out is here: http://processing.org/learning/3d/index.html
  • To get 3D to work at all: You can add a z-coordinate to almost any geometric operation in Processing, BUT first you must add a parameter to the size() command that you normally use to set your window size. Instead of just saying "size(200, 200)", you must now say "size(200,200,P3D)". This just tells Processing that you're going to be doing some work in 3D. (note: you could also try "OPENGL" instead of "P3D", but you probably don't need that yet).
  • Drawing shapes: To draw shapes other than simple "primitives" like cubes and spheres, you can use beginShape() and endShape() as you would in 2D. See this example: http://processing.org/learning/3d/vertices.html
  • Transformations: Once you've drawn shapes, you frequently want to move them around. Look at the examples under "Transform" in the main 3D page (linked above). You can move ("translate()"), rotate, and scale the objects.
  • More advanced transformations: You will need to master "pushMatrix()" and "popMatrix()". This gets conceptually a little complicated. Check out this examples as a first step: http://processing.org/learning/3d/bird.html . The pushMatrix() is used to draw the bird's wings in different orientations from its body.
  • OPENGL and fancier stuff: Processing's 3D stuff works in the way that OpenGL does (this is a 3D standard maintained by a large non-profit consortium of non-Microsoft companies). So if you want to get into 3D programming in a serious way, you should explore this further. There are books about OpenGL, you should probably pick one up if you want to really get into it. There are several concepts (such as the transformation matrices, etc.) that you might learn better from the book. But in general the OpenGL community is full of very fluent programmers, so most of the books out there are aimed at people who already know a lot about programming. Thus, enter at your own risk... (Just Amazon "OpenGL" to find the main books). put out by Not only is this a good book about OpenGL, but it is a great book for just understanding the issues with 3D programming in general. Highly recommended.

DXF export


Posting an applet

  • Not child's play, on the wiki... I will provide this info shortly (Mirella can help, maybe...?)

Interface code

  • The "controlP5" library: http://www.sojamo.de/iv/index.php?n=12
    • Check out the "controlp5 basics" file, which gives you an example of how to use every kind of control. The important thing to figure out are:
      1. How to make a control (i.e. a button, a slider, etc.) (tip: look in the setup() function)
      2. How to attach the value from that control to one of your variables (tip: almost every control has its own function, like the "mousePressed()" we've seen before)








CLASS 4

Going Live:


  • What is an "API"? It's an "Application Programming Interface", a set of code functions provided by a third party for you to use to access their data.
  • Recently, web-based APIs have really taken off. These APIs provide function-like features within the constraints of the HTTP protocol (i.e. web browsers requesting data of web servers).
  • Examples of web-based APIs include:
  • The switchboard library for Processing -- fantastic and apparently friendly 'wrapper' for accessing all kinds of web APIs.
    • Be sure to try out the switchboard library! The walkthrough tutorial is excellent and easy.
  • Another nice API tool for processing is this Google API wrapper. But switchboard seems to offer wrappers for EVERYTHING, so you probably don't need this.
  • Again, switchboard basically does everything, but if you are looking for other ways to do this you could also check out this example of using the del.icio.us API in processing: http://www.processinghacks.com/hacks/delicious




CLASS 3

Abstraction and Mapping:

  • To what degree do the original data manifest themselves in a map? I.e. how 'abstract' is the map?
  • How do we make value judgments about the degree of abstraction?
  • If the map is 'abstract', what brings in the abstraction? Other data? A new medium?
  • How 'legible' is the map... could abstraction actually bring a different scale or kind of legibility?
  • Does the map have any sense of history, or is it simply a snapshot? (it turns out lines/edges/connections are important to show history)
  • Is the map read for answers to direct questions, or, at the other extreme, treated as 'art' -- which tends to make it monolithic (we start to talk about 'affect' vs. 'effect')
  • Could the zone between these two extremes produce a richer sense of context and intuition about data?
  • Could somebody who didn't make the map still develop 'expertise' or intuition about it?


How text drives the internet:


You can use the 'telnet' program to hack around with this, by typing your own requests... BE the browser!
http://www.hackerthreads.org/phpbb/viewtopic.php?t=724

Important text parsing notions:
  • escape sequences: frequently "\"
  • tokens or delimiters: for example, the commas in a comma-separated file. Spaces are very frequent too.
  • regular expressions: the most powerful way to manipulate text. Read about them here: http://etext.lib.virginia.edu/services/helpsheets/unix/regex.html (note: Processing has just added reg-exp support with the "match()" function, which isn't even documented yet)

Displaying text in Processing is easy. Use the PFont object, etc.
Examples:

Object Oriented Programming:


(see Processing text, p395 to 407 or so)
You already use Object-oriented code when you use some of the built-in objects in Processing, such as String, PImage, PFont, etc.

Crude examples:
// Not object-oriented
 
// declare variables
String dog_name = "Bowser";
int amt_food = 12;
int amt_affection = 45;
 
// call functions
feed_dog( dog_name, amt_food);
pet_dog( dog_name, amt_affection);
 

 // OOPs... this is Object Oriented code
// declare variables, include a new Dog object
Dog d = new Dog("Bowser");
int amt_food = 12;
 int amt_affection = 45;
 
// call 'methods' "on" the object
d.feed( amt_food);
d.pet( amt_affection);

So OOP is just a way of using code, a paradigm... you never actually NEED to use it, but it frequently feels more intuitive to write things this way, once you get into the mentality of it. In many ways, it's just a way of grouping various functions together, to simplify your code and clarify "who is doing what to whom"...

So how do we define "dog?" Let's do some examples... (Processing book, pgs. 397 to 407 or so)

TUTORIAL: Can you make a Class that holds your data?
// Global declaration...
Spot sp;
Spot sp2;
Spot[] spots_array; // array of spots
 
void setup() {
 size(100,100);
 smooth();
 noStroke();
 
 // Create the object using "new"
 sp = new Spot(33, 50, 30, 0.1);
 sp2 = new Spot(33, 50, 30, 2.3);
}
 
void draw() {
 background(0);
 sp.display();
 sp.move();
 sp2.display();
 sp2.move();
}
 
class Spot {
 // data fields
 float x, y, diameter;
 float speed;
 int direction = 1; // Direction goes up or down
 
 // constructor
 Spot(float xpos, float ypos, float dia, float newspeed) {
 x = xpos;
 y = ypos;
 diameter = dia;
 speed = newspeed;
 }
 
 // methods
 void display() {
 ellipse(x,y,diameter,diameter);
 }
 
 // move the spot a certain distance
 void move() {
 y = y + (speed * direction);
 
 
 }
 
}

Basic Networking with Processing:


To establish a network connection, you take advantage of another internet protocol, TCP/IP. Unlike the ones listed above, TCP/IP is not text-based... it is the next layer 'down', below the level of text. Basically TCP/IP determines how big the chunks of data will be that different programs pass back and forth over the internet. It also takes care of addressing (i.e. where does this chunk of data go?)... hence the prevalent use of "IP addresses". You can read a lot about TCP/IP on wikipedia, etc. There's no real need, though, because Processing offers a set of 'wrapper functions' (i.e. a simplified interface) to make and use network connections:
http://www.processing.org/reference/libraries/net/index.html

This library is built in to Processing, so no need to download anything. Check out the examples...

The great thing about TCP/IP connections is that they are completely generic -- ALL internet traffic uses this protocol. In fact, TCP/IP is basically what defines what the boundaries of the 'internet' are. When you get into areas that don't use TCP/IP, you are usually in a remote college research laboratory, or perhaps on a wireless device (but then there are translations to TCP/IP).

So if you know how to make servers and clients (as shown clearly in the examples), you can start to connect radically different programs. E.g. Max/MSP and Processing, Processing and game engines, Processing and the International Go Servers, etc.

Key concepts for TCP/IP:
  • IP Addresses
  • DNS... how 'domain names' get translated into IP addresses
  • "Port numbers" -- every computer's network card has thousands of possible port numbers. So once you've got that computer's IP address, you still need to specify a port number. And if the server on that computer is listening on one port, and you try to connect to another, you'll get nothing.





Remote Notes 1


I will be putting all kinds of information related to the project work you should be doing over the next few weeks, in preparation for our next session on Saturday, October 13th. I will be flagging this information with either "EVERYBODY", "BEGINNER" or "ADVANCED" so that you can find the information most relevant to your situation.

Basic Next Steps (EVERYBODY):
In the next two weeks (due date for sending me SOMETHING will be Sunday, Sept. 29th at midnight):


- find a source of data you want to investigate (see below for notes about what might be a "source of data")
- try to 'format' this data in a way that you can read it easily into Processing (i.e. could you turn it into formatted text of some kind?)
- work towards reading this into Processing and in some way 'visualizing' it
- create your own page on this wiki
- post some results to that page, and post an image or whatever is appropriate (applet, etc.) to the Student Work page
by next Monday (10/01/2007) at 6 pm (this will be 9 pm my time in NYC).
- in general, post your code and comments to your personal page on the wiki, and post images to the Student Work page
- if you ever send me images by email (which you shouldn't need to thanks to this wiki), please keep them fairly small (preferably < 2 MB)

Using this wiki (EVERYBODY):
This wiki can do a lot, once you figure out how to make it work. Here are some first steps:
1. I'm creating an "FAQ" page under the Datascapes heading on the left. Use this to post questions, and I (or another student!) will post answers. If we all use this it will save us all a lot of time, because each question will only need to be answered once. Also, you may see another student asking the same question you are asking, and you can work on the solution together.
2. If you click "help" at the top right, you can quickly get info on using the wiki. The basic text editing is a no-brainer, but then there are a few basic skills that will help you make things nicer. The main "help" page tells you how to upload images, link to "anchors", etc.
Especially of interest are the following:
Format your code when you post it to the wiki.
Access the wiki like a folder from your OS file browser (e.g. Windows Explorer or whatever)

How to interact with me (EVERYBODY):
- I am online most evenings for a few hours, you can find me on skype as gshowman . But if you have a specific question, it would be best to start with an email! Then I could skype YOU once I've thought about it a bit.
- Remember that my "evenings" go from about 8 pm to 11 pm my time, which is 5 pm to 8 pm your time (sorry about your dinner...).
- If you have heavy technical problems, you might want to install a VNC client and server (e.g. TightVNC: www.tightvnc.org) -- this will let us see each other's desktops.

What is a data source? (EVERYBODY):
"Data sources" are everywhere! You should have no problem finding something interesting and relevant to issues you want to investigate.

Data sources don't need to be live:
- old market data
- casualty counts from violence in Israel over the last ten years
- observations you make of, say, behavioral patterns at SCI-arc
- the DNA sequence of a fruit fly
- a word-frequency analysis of the Bible
- statistics from the Black Plague
- historical figures about all the American presidents
- your monthly expenditures for the past year
- a collection of photos from the trenches of WWI
- your mom -- but how to get reliable data out of her? Record her phone calls?
- etc.

All of these contain fascinating structures worth pursuing through code.

But with the wonders of the internet, especially "web 2.0", your data could be live. Of course "live" doesn't always mean 100% live, it may mean "updated once a day", etc. Very few things on the internet are REALLY live. YOU are the most live signal here...:
- many websites now give access to live or quasi-live data ("quasi" in this case means that whenever the website updates its data, it sends you those updates 'live'). Examples include:
- flickr API
- Google Finance
- "Argo", a deep sea climate change sensor network that shares its data
- Live Satellite tracking
- many others that I simply don't have time to add right now. Please add to this list, people! Also you can check out my del.icio.us links -- look for things tagged "mediascapes_datasource", "data_visualization", and/or "mapping".
- some cheap sensors are available to actually pick up motion, etc. 'in real time'. Webcams are perhaps the most obvious of these. But if this is your hope, then you should start with some 'fake' data that simulates the way the sensor will eventually act. Otherwise you will have too many things to deal with at once as you get started.
- live input from the 'user' of your Processing script, of course: i.e. the mousePressed(), keyPressed() functions, etc. But this data probably won't say much about the "real world" other than your particular little corner of it.

How to really get rolling with Processing (BEGINNERS:)
While the Processing website is really full of great information, it (amazingly) lacks any basic "tutorials" per se. The expectation is that beginners will learn by reading through examples. I think this is not as easy as the good people who developed Processing think it is, however, so I will try to give you a bit of tutorial content here.

First of all, you should really buy the Processing book, as it's a great introduction to the language and to thinking about programming.

Next, try this tutorial I just wrote for you.

Some more tips on the general practice of programming (BEGINNERS):
Incremental change is the key to programming; if you change too many things at once in your code, you will almost certainly "break" it -- i.e. introduce some error that will be very hard to track down. So, try these practices to control yourself a little:
- break down your problem into manageable parts
- make a list in english point-form of the things you need to do
- do these things one at a time (whenever possible -- some things must be done all at once) in your code
- run the code between each significant change to make sure it works
- backup your code frequently by copying the file or saving as a different Sketch name


Further steps (ADVANCED:)
Those of you who are rolling forward... you may want to know how to:
1. Load an external library into Processing.
This is very straightforward. Just download whatever library you want, then unzip it (and keep the directory tree!) into the "libraries" folder of wherever you installed Processing on your computer (i.e. inside your "processing-0125-expert\libraries" folders). Once you've done that, you can access the features of that library by just "importing" it into your code. In Processing this is done by writing a line like this at the top of your code:
// example: IMPORT THE XML LIBRARY
import proxml.*;
 
// (now anywhere after that line I can use the features of the proXML library, e.g.:
XMLInOut xmlInOut;

2. Find useful libraries:
Browse the processing site's libraries page. Obviously useful ones include Vector3D, various export libraries like DXF, maybe proMIDI or oscP5 which would let you communicate with a program like Max/MSP, maybe proXML (but I am skeptical of this thing now).

3. How to make an applet from your processing code and post it here in wikispaces (or elsewhere). See this discussion on the processing site.

4. Load NASA Worldwind in Processing with ten lines of code:
Yes. Check this out:
An example and notes from a Processing expert: http://i.document.m05.de/?p=313
The actual development kit from NASA: http://worldwind.arc.nasa.gov/java/

What else? Start sending questions on the FAQ.




Class 2 (9/17/2007)

Some programming fundamentals:
- statements vs. comments
- declaring variables of different types
- data types: int, float, String, etc.
- assignment to variables
- conditionals and operators used to test the value of a variable
- arrays of variables
- loops: for and while
- calling functions -- arguments, return values
- the value of a good programming environment
- necessity vs. habits:
- commenting
- indentation
- logging where you are at with println()
- other clarity issues (naming variables, using functions to bundle code, etc.)
-

Text processing in Processing: input and output
(note: see "input", "output", and "String functions" on this Processing reference page)
- static writing and loading of files: saveStrings(), loadStrings() functions
- split() function
- the backslash character ... escape sequences
- WHITESPACE
- streaming your files: the PrintWriter class
- createWriter(), println(), etc.
- casting data


(note: I didn't cover this XML stuff in a lot of detail -- beginners should just use plain text files. More advanced folk are free to try out the proXML library -- I'm not convinced it's all that helpful for the kind of one-off data storage we are doing)
Review of XML
- install a code editor (e.g. Komodo Edit)
- the <?xml ...>
tag
- nesting of
tags
- no need for a
schema

The proXML library
- two objects: XMLInOut and XMLElement
- necessary TODO to get it working:
-
declare an XMLInOut and an XMLElement as global variables
-
implement the XMLEvent() function, and deal with the loaded data in there
- assign the data that you loaded to whatever specific variables in your code you want to make dependent on that data



Larger Topics we've just touched upon:
- scope of variables
- coding practices
- object oriented code