In this example, java classes are used to calculate the area and perimeter of shapes. Various Java classes are instantiated and used from Flow.

Start the example here.

## The sitemap

There's nothing new in the sitemap, our use of variables allows the exact same sitemap to be reused for both our Flow examples.

The only specific thing is the importing of the java-shapes.js flowscript, but this was already present for the previous example:

## Java code

The java code (interface Shape, classes Rectangular, Square, Circle) is fairly trivial, and the computations could easily be done in javascript for such a simple case.

However, our goal is to show interactions between Flow and java classes, so you shouldn't pay too much attention to the java code, except to note that it has no knowledge of Avalon - our java objects are just POJOs: Plain Old Java Objects.

## Flowscript code

Here's the Flowscript which has three steps.

1. Get the selected shape from user and prepare the next page.
2. Get shape's informations (width, height or radius) and instantiate the correct java class for the selected shape.
3. Use java class to calculate area and perimeter and display the results

## JXTemplate view

Shape selection

Here the user can select a shape.