]> rtime.felk.cvut.cz Git - orte.git/blob - orte/contrib/shape_android/src/org/ocera/orte/shape_android/SubscriberView.java
Simplified approach to write application.
[orte.git] / orte / contrib / shape_android / src / org / ocera / orte / shape_android / SubscriberView.java
1 /**
2  * 
3  *      This file is part of shape_android.
4  *
5  *  shape_android is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  shape_android is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with shape_android.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 package org.ocera.orte.shape_android;
20
21 import java.util.ArrayList;
22
23 import android.content.Context;
24 import android.graphics.Canvas;
25 import android.util.AttributeSet;
26 import android.view.View;
27
28 import org.ocera.orte.DomainApp;
29
30 /**
31  * View, where subscriber objects are drawn.
32  * 
33  * @author jiri hubacek <jiri.hubacek@gmail.com>
34  * @version %I%, %G%
35  * @since 1.0
36  */
37 public class SubscriberView extends View {
38         public ArrayList<SubscriberElement> elements = new ArrayList<SubscriberElement>();
39         
40         /**
41          * Default constructor.
42          * 
43          * @param context
44          * @param attrs
45          */
46         public SubscriberView(Context context, AttributeSet attrs) {
47                 super(context, attrs);
48         }
49         
50         /**
51          * When drawing, draw all subscribers shapes.
52          * 
53          * @param canvas
54          */
55         @Override
56         protected void onDraw(Canvas canvas)
57         {
58                 for (SubscriberElement element : elements) {
59                         if (element.getReceiving() && element.getEnabled()) element.drawMe(canvas);
60                 }
61         }
62         
63         /**
64          * Make objects of all colors ready to subscribe.
65          * 
66          * @param appDomain
67          */
68         public void addElements(DomainApp appDomain)
69         {
70                 for (int i = 0; i < 5; i++) {
71                         this.elements.add(new SubscriberElement(appDomain, i, this));
72                 }
73         }
74 }