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.
J2ME Polish supports Processing visualizations in following ways:
- ProcessingItem displays a Processing visualization within a Form, FramedForm, etc.
- ProcessingScreen allows you to use a visualization for a complete screen.
- ProcessingBackground enables you to use a Processing in the background of any item or screen.
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.
For integrating Processing code you should extend de.enough.polish.processing.ProcessingContext
(for documentation compareProcessingInterface).
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
Here you can the various available draw methods such as:
fill(color)to specify the color of lines and filled areas.
bezier(int..)you can paint (curved) lines.
- paint rectangles, cycles and ellipses with
ellipse(int, int, int, int),
rect(int, int, int, int), and
You can react to events by overriding one of the
signalSizeChange(int width, int height).
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 );
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 );
// 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 );
Please refer to the "processing-tree" sample application to see the processing support in action.