KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > test > olap > PropertyBuilder


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.test.olap;
14
15 import java.util.ArrayList JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19 import com.tonbeller.jpivot.olap.model.Alignable;
20 import com.tonbeller.jpivot.olap.model.Property;
21 import com.tonbeller.jpivot.olap.model.impl.PropertyImpl;
22
23 class PropertyBuilder {
24
25   void build(TestDimension dim) {
26     TestHierarchy hier = (TestHierarchy) dim.getHierarchies()[0];
27     TestMember[] roots = hier.getRootMembers();
28     for (int i = 0; i < roots.length; i++)
29       addProperties(roots[i], 0, i);
30   }
31
32   private void addProperties(TestMember member, int level, int index) {
33
34     List JavaDoc pl = new ArrayList JavaDoc();
35
36     // to test right alignment, we construct a "big" number together with "small" ones
37
pl.add(new PropertyImpl("P", "" + ((index == 1) ? 10000 : index), Alignable.Alignment.RIGHT));
38     pl.add(new PropertyImpl("P" + level, "V" + level + index));
39
40     if (level == 1) {
41       pl.add(new PropertyImpl("link", "http://www.tonbeller.com"));
42     }
43
44     if (level == 2) {
45
46       String JavaDoc[] arrows = new String JavaDoc[] { "down", "none", "up" };
47       pl.add(new PropertyImpl("arrow", arrows[index % 3]));
48
49       String JavaDoc[] styles = new String JavaDoc[] { "red", "yellow", "green" };
50       pl.add(new PropertyImpl("style", styles[index % 3]));
51
52       /*
53       String[] arrows = new String[] { "auf", "ohne", "ab" };
54       pl.add(new PropertyImpl("pfeil", arrows[index % 3]));
55
56       String[] styles = new String[] { "rot", "gelb", "gruen" };
57       pl.add(new PropertyImpl("stil", styles[index % 3]));
58       */

59
60       //pl.add(new PropertyImpl("My Image", "TONBELLER"));
61
pl.add(new PropertyImpl("My Image.image", "/wcf/form/ok.png"));
62       pl.add(new PropertyImpl("My Image.link", "http://www.tonbeller.com"));
63       
64     }
65
66     if (level == 3) {
67       pl.add(new PropertyImpl("MyLabel", "MyValue " + index));
68       pl.add(new PropertyImpl("MyLabel.link", "http://jpivot.sourceforge.net"));
69       pl.add(new PropertyImpl("MyLabel.arrow", "up"));
70       pl.add(new PropertyImpl("MyLabel.image", "http://sourceforge.net/sflogo.php?group_id=58645&type=4"));
71     }
72
73     Property[] p = (Property[]) pl.toArray(new Property[0]);
74     member.setProperties(p);
75
76     index = 0;
77     for (Iterator JavaDoc it = member.getChildMember().iterator(); it.hasNext();)
78       addProperties(((TestMember) it.next()), level + 1, index++);
79   }
80
81 }
82
Popular Tags