1 4 package com.tc.admin.dso; 5 6 import treemap.TMAlgorithm; 7 import treemap.TMComputeDrawAdapter; 8 import treemap.TMComputeSizeAdapter; 9 import treemap.TMView; 10 import treemap.TreeMap; 11 12 import com.tc.admin.common.XContainer; 13 14 import java.awt.BorderLayout ; 15 import java.awt.Color ; 16 import java.awt.Paint ; 17 18 public class ClassesTreeMap extends XContainer { 19 private TreeMap m_treeMap; 20 private ClassesModelNode m_model; 21 22 public ClassesTreeMap() { 23 super(new BorderLayout ()); 24 } 25 26 public void setModel(ClassTreeModel treeModel) { 27 removeAll(); 28 29 m_model = new ClassesModelNode(treeModel); 30 m_treeMap = new TreeMap(m_model); 31 32 ClassesModelSize fSize = new ClassesModelSize(); 33 ClassesModelDraw fDraw = new ClassesModelDraw(); 34 TMView view = m_treeMap.getView(fSize, fDraw); 35 36 view.setAlgorithm(TMView.SQUARIFIED); 37 38 TMAlgorithm algorithm = view.getAlgorithm(); 39 algorithm.setBorderSize(14); 42 43 add(view); 44 } 45 46 class ClassesModelSize extends TMComputeSizeAdapter { 47 public boolean isCompatibleWithObject(Object node) { 48 return true; 49 } 50 51 public float getSizeOfObject(Object node) { 52 if(node instanceof ClassTreeNode) { 53 return ((ClassTreeNode)node).getInstanceCount(); 54 } 55 56 return 0.0f; 57 } 58 } 59 60 class ClassesModelDraw extends TMComputeDrawAdapter { 61 private Color fillColor = new Color (255, 238, 105); 62 63 public boolean isCompatibleWithObject(Object node) { 64 return true; 65 } 66 67 public Paint getFillingOfObject(Object node) { 68 return fillColor; 69 } 70 71 public String getTooltipOfObject(Object node) { 72 if(node instanceof ClassTreeNode) { 73 ClassTreeNode ctn = (ClassTreeNode)node; 74 75 return "<html>" + ctn.getFullName() + "<p>" + 76 ctn.getInstanceCount() + " instances"; 77 } 78 79 return ""; 80 } 81 82 public String getTitleOfObject(Object node) { 83 if(node instanceof ClassTreeNode) { 84 return ((ClassTreeNode)node).getName(); 85 } 86 87 return ""; 88 } 89 90 public Paint getColorTitleOfObject(Object node) { 91 return Color.black; 92 } 93 } 94 } 95 | Popular Tags |