1 13 package com.tonbeller.jpivot.test.olap; 14 15 import java.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 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 pl = new ArrayList (); 35 36 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 [] arrows = new String [] { "down", "none", "up" }; 47 pl.add(new PropertyImpl("arrow", arrows[index % 3])); 48 49 String [] styles = new String [] { "red", "yellow", "green" }; 50 pl.add(new PropertyImpl("style", styles[index % 3])); 51 52 59 60 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 it = member.getChildMember().iterator(); it.hasNext();) 78 addProperties(((TestMember) it.next()), level + 1, index++); 79 } 80 81 } 82 | Popular Tags |