J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

Processing

Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production. (Source: processing.org)
Processing


J2ME Polish supports Processing visualizations in following ways:
 


The supported feature set is largely equivalent with the now defunct mobile Processing project. While this excludes some complex rendering mechanism, it allows you to easily port over existing Processing visualizations.

ProcessingContext

For integrating Processing code you should extend de.enough.polish.processing.ProcessingContext (for documentation compareProcessingInterface).
Override the public void setup() method to initialize your painting data.
The most important method is public void draw() in which you paint your area (defined by the instance fields this.width and this.height). Here you can the various available draw methods such as:

  • use stroke(color) and fill(color) to specify the color of lines and filled areas.
  • with line(int,int,int,int), curve(int..) and bezier(int..) you can paint (curved) lines.
  • paint rectangles, cycles and ellipses with ellipse(int, int, int, int), rect(int, int, int, int), and quad(int..).

You can react to events by overriding one of the signal methods, e.g. signalKeyPressed(int keycode), signalHasFocus(), signalLostFocus(), signalSizeChange(int width, int height).

ProcessingBackground

With ProcessingBackground you can use a ProcessingContext for backgrounds of screens, items, etc. To implement a ProcessingBackground first create a ProcessingContext and register this with the background:

// create a sample ProcessingContext:
ProcessingContext context = new ProcessingTreeContext();
// and attach it to a ProcessingBackground:
ProcessingBackground background = new ProcessingBackground( context );
// append the background to a style:
Style style = StyleSheet.getStyle("myform");
style.background = background;
// or apply the background directly to a screen:
UiAccess.setBackground( myForm, background );

ProcessingScreen

With ProcessingScreen you can use a ProcessingContext as a standalone screen (or use that screen in a TabbedPane). To implement a ProcessingScreen first create a ProcessingContext and register this with the screen:

// create a sample ProcessingContext:
ProcessingContext context = new ProcessingTreeContext();
// and attach it to a ProcessingScreen:
//#style screenTree
ProcessingScreen screen = new ProcessingScreen("Hello World", context);
// show the screen:
display.setCurrent( screen );

ProcessingItem

With ProcessingItem you can use a ProcessingContext within a Form, FramedForm, Alert, etc. To implement a ProcessingItem first create a ProcessingContext and register this with the item:

// create a sample ProcessingContext:
ProcessingContext context = new ProcessingTreeContext();
// and attach it to a ProcessingItem:
ProcessingItem item = new ProcessingItem(context);
// append the item to a Form:
//#style treeItem
myForm.append( treeItem );

Sample App


Please refer to the "processing-tree" sample application to see the processing support in action.

back to top