1/*
2 * Copyright 2013 AndroidPlot.com
3 *
4 *    Licensed under the Apache License, Version 2.0 (the "License");
5 *    you may not use this file except in compliance with the License.
6 *    You may obtain a copy of the License at
7 *
8 *        http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *    Unless required by applicable law or agreed to in writing, software
11 *    distributed under the License is distributed on an "AS IS" BASIS,
12 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 *    See the License for the specific language governing permissions and
14 *    limitations under the License.
15 */
16
17package com.androidplot.pie;
18
19import android.graphics.*;
20import com.androidplot.exception.PlotRenderException;
21import com.androidplot.ui.LayoutManager;
22import com.androidplot.ui.SizeMetrics;
23import com.androidplot.ui.widget.Widget;
24
25import java.util.ArrayList;
26import java.util.Set;
27
28/**
29 * Visualizes data as a pie chart.
30 */
31public class PieWidget extends Widget {
32
33    private PieChart pieChart;
34
35    public PieWidget(LayoutManager layoutManager, PieChart pieChart, SizeMetrics metrics) {
36        super(layoutManager, metrics);
37        this.pieChart = pieChart;
38    }
39
40    @Override
41    protected void doOnDraw(Canvas canvas, RectF widgetRect) throws PlotRenderException {
42
43        for(PieRenderer renderer : pieChart.getRendererList()) {
44            renderer.render(canvas, widgetRect);
45        }
46    }
47}
48