KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > dso > ClassesTreeMap


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc;
15 import java.awt.Color JavaDoc;
16 import java.awt.Paint JavaDoc;
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 JavaDoc());
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.setCushion(true);
40
//algorithm.setBorderOnCushion(true);
41
algorithm.setBorderSize(14);
42
43     add(view);
44   }
45
46   class ClassesModelSize extends TMComputeSizeAdapter {
47     public boolean isCompatibleWithObject(Object JavaDoc node) {
48       return true;
49     }
50
51     public float getSizeOfObject(Object JavaDoc 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 JavaDoc fillColor = new Color JavaDoc(255, 238, 105);
62
63     public boolean isCompatibleWithObject(Object JavaDoc node) {
64       return true;
65     }
66     
67     public Paint JavaDoc getFillingOfObject(Object JavaDoc node) {
68       return fillColor;
69     }
70
71     public String JavaDoc getTooltipOfObject(Object JavaDoc 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 JavaDoc getTitleOfObject(Object JavaDoc node) {
83       if(node instanceof ClassTreeNode) {
84         return ((ClassTreeNode)node).getName();
85       }
86
87       return "";
88     }
89
90     public Paint JavaDoc getColorTitleOfObject(Object JavaDoc node) {
91       return Color.black;
92     }
93   }
94 }
95
Popular Tags