001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint.google.chart;
020
021 import echopoint.google.chart.internal.SimpleChart;
022 import echopoint.google.chart.model.VennDiagramModel;
023 import echopoint.google.chart.model.ChartData;
024
025 import java.util.ArrayList;
026
027 /**
028 * Component wrapper for a
029 * <a href='http://code.google.com/apis/chart/#venn'>Venn Diagram</a>
030 * provided by <a href='http://code.google.com/apis/chart/'>Google Chart
031 * API</a>.
032 *
033 * <p>The following code shows sample use of this component:</p>
034 * <pre>
035 * import echopoint.google.chart.VennDiagram;
036 *
037 * ...
038 * final VennDiagram chart = new VennDiagram();
039 * final VennDiagramModel model = new VennDiagramModel( 100, 80, 60, 30, 30, 30, 10 );
040 * chart.setData( model );
041 * </pre>
042 *
043 * @author Rakesh Vidyadharan 2008-08-22
044 * @version $Id: VennDiagram.java 64 2008-09-01 11:28:02Z sptrakesh $
045 */
046 public class VennDiagram extends SimpleChart<Integer>
047 {
048 private static final long serialVersionUID = 1l;
049
050 /**
051 * Set the data for the venn diagram using the custom model object.
052 *
053 * @see #setData( ChartData )
054 * @param model The model object to use to set the data for the diagram.
055 */
056 public void setData( final VennDiagramModel model )
057 {
058 final ArrayList<Integer> list = new ArrayList<Integer>( 7 );
059 list.add( 0, model.circleA );
060 list.add( 1, model.circleB );
061 list.add( 2, model.circleC );
062 list.add( 3, model.intersectAB );
063 list.add( 4, model.intersectAC );
064 list.add( 5, model.intersectBC );
065 list.add( 6, model.intersectABC );
066
067 final ChartData<Integer> data = new ChartData<Integer>();
068 data.setXdata( list );
069 setData( data );
070 }
071 }