source: trunk/gsdl3/packages/vishnu/src/vishnu/testvis/dendro/ClusterObj.java@ 8189

Last change on this file since 8189 was 8189, checked in by kjdon, 20 years ago

first version of Imperial College's Visualiser code

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1package vishnu.testvis.dendro;
2
3import java.awt.*;
4import vishnu.testvis.object.*;
5import java.util.Vector;
6
7public class ClusterObj
8
9{
10 Cluster cluster;
11 Point position;
12 int radius;
13 boolean inSubCluster;
14 private boolean orderStatus;
15 private boolean keywordStatus;
16 private String[] freqWords;
17
18 DocObj[] _docs; // list of DocObj ref
19 String _label; // (top 3-5? related words)
20 DataManager _data;
21
22 public ClusterObj(Cluster c, Point P, int r, DataManager data)
23 {
24 cluster = c;
25 position = P;
26 radius = r;
27 inSubCluster = false;
28 _data = data;
29 orderStatus = false;
30 keywordStatus = false;
31 }
32
33
34 public void setPosition(Point p)
35 {
36 position = p;
37 }
38
39 public void setOrderStatus(boolean b)
40 {
41 orderStatus = b;
42 }
43
44 public boolean getOrderStatus()
45 {
46 return orderStatus;
47 }
48
49 public void setFreqWords(String[] str)
50 {
51 freqWords = str;
52 keywordStatus = true;
53 }
54
55 public String[] getFreqWords()
56 {
57 return freqWords;
58 }
59
60 public boolean getKeywordStatus()
61 {
62 return keywordStatus;
63 }
64
65 public void setIsSubset(boolean b)
66 {
67 inSubCluster = b;
68 }
69
70 public boolean getIsSubset()
71 {
72 return inSubCluster;
73 }
74
75 public boolean inCircle(int x, int y)
76 {
77 double dist_sqr = (x-position.x)*(x-position.x) + (y-position.y)*(y-position.y);
78 return (dist_sqr <= (4*radius*radius)) ? true : false;
79 }
80
81
82 public void setDocObjs(DocObj[] docArray)
83 {
84 _docs = docArray;
85 }
86
87
88 public int getX()
89 {
90 return position.x;
91 }
92
93 public int getY()
94 {
95 return position.y;
96 }
97
98 public int getRad()
99 {
100 return radius;
101 }
102
103
104 public ClusterObj(DocObj[] d, String t, DataManager dm)
105 {
106 _docs=d; _label=t;
107 _data = dm;
108 }
109
110
111 public int getDocsSize(){return _docs.length;}
112
113 public String getLabel(){return _label;}
114
115 public String getLabel1(){return getDocsSize() + " documents found";}
116 public String getLabel2(){return getLabel();}
117
118
119 public String getInfo(){
120 return getDocsSize() + " documents found\n" + getLabel();
121 }
122
123
124
125 /**
126 * This returns a list of list of documents. The inner list of documents represents
127 * which documents have the corresponding related word
128 * pre: _docs can't be null
129 * @return a vector (same length as the related words) of
130 * vectors (arbitrary length)
131 *
132 */
133 public Vector getHitDocFreq()
134 {
135 int s = _data.getWordCount();
136
137 Vector rwVec = new Vector(s);
138
139 for(int i=0;i<s;i++)
140 {
141 rwVec.addElement(new Vector(0));
142 for(int j=0;j<_docs.length;j++)
143 {
144 if ( _docs[j].getWeights(i) > 0 )
145 ((Vector) rwVec.elementAt(i)).addElement(_docs[j]);
146 }
147 }
148 return rwVec;
149 }
150
151
152 public int getDocSize()
153 {
154 return cluster._items;
155 }
156
157
158 public String formatDocs()
159 {
160 int l = getDocsSize();
161 String s = "<html><font face=Arial size=-1> "+ l +" documents found\n";
162 for(int i=0;i<l;i++)
163 {
164 s += _docs[i].format4Fields();
165 }
166 s += "</font></html>\n";
167 return s;
168 }
169
170
171}
Note: See TracBrowser for help on using the repository browser.