Fruity V1.00

This is the first public release of the fruity framework. It allows Java developers to easily add zoom/pan rendering for java.awt.Shape objects. All objects are manipulated in a world view which may use whatever coordinates range that it wants. This is then mapped to device (screen/printer) coordinates automatically.

The framework provides the ability to add images (which are also scaled), as well as compound shapes (may be used for layers) that contain other graphical objects. Attributes may be specified that are inherited by the contained objects which may override them for drawing. The attributes defined currently are for color, line thickness, line style and fill color.

Take a look here to see how you can use it.

Download Fruity as a .tar.gz or a .zip file.

Unpack the release, and run 'ant' to build. Run 'runtest.sh' to run the example.


In addition to the test code (provided, with a snippet listed below), Fruity has been used to create a web based CGM viewer.

Download CGMViewer as a .tar.gz or a .zip file.

The CGM viewer requires a browser that supports Java 1.3 or later, some examples may be accessed from:

  • Map of Africa
  • CAD Drawing
  • Mechanical Drawing
  • Space Shuttle
  • Technical Drawing

  • 
            // 
            // Set up a list of colors to use for the compounds. 
            // Create the root holder 
            // 
            Color colorList[] = new Color[] 
                {   Color.black, 
                    Color.red, 
                    Color.blue, 
                    Color.green, 
                    Color.orange 
                }; 
            CompoundShape root = new CompoundShape(); 
            // 
            for (int i = 0; i < 5; i++) { 
                CompoundShape sub = new CompoundShape(); 
                for (int j = 0; j < 5; j++) { 
                    double x1 = r.nextDouble() * 100.0; 
                    double y1 = r.nextDouble() * 100.0; 
                    double x2 = r.nextDouble() * 100.0; 
                    double y2 = r.nextDouble() * 100.0; 
                    Line2D l = new Line2D.Double(x1, y1, x2, y2); 
                    sub.addObject(l); 
                } 
                // 
                // Set the line attributes 
                // - the area and edges are not set (so the children 
                // will inherit the values from the parent). 
                // 
                sub.setAttributes(new AttributeCollector( 
                        new LineAttribute(i*2, colorList[i]), 
                        null, null)); 
     
                root.addObject(sub); 
            } 
            // 
            // Create the view box, and add it to the container. 
            // 
            ViewBox view = new ViewBox(root); 
    

    © Andy Wilcock, 2003.