2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* GONode.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on August 11, 2004, 10:33 AM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
package org.tigr.microarray.mev.cluster.gui.impl.ease.gotree; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.AlphaComposite; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Composite; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.Graphics2D; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.RenderingHints; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.font.FontRenderContext; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.font.LineBreakMeasurer; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.font.TextAttribute; |
2 |
26 Feb 07 |
jari |
22 |
import java.awt.font.TextLayout; |
2 |
26 Feb 07 |
jari |
23 |
import java.awt.geom.Point2D; |
2 |
26 Feb 07 |
jari |
24 |
import java.io.Serializable; |
2 |
26 Feb 07 |
jari |
25 |
import java.text.AttributedCharacterIterator; |
2 |
26 Feb 07 |
jari |
26 |
import java.text.AttributedString; |
2 |
26 Feb 07 |
jari |
27 |
import java.text.DecimalFormat; |
2 |
26 Feb 07 |
jari |
28 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
29 |
|
2 |
26 Feb 07 |
jari |
30 |
import org.tigr.microarray.mev.cluster.gui.helpers.ktree.ITreeNode; |
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.microarray.mev.cluster.gui.helpers.ktree.ITreeNodeRenderer; |
2 |
26 Feb 07 |
jari |
32 |
import org.tigr.microarray.mev.cluster.gui.helpers.ktree.KNodeImpl; |
2 |
26 Feb 07 |
jari |
33 |
|
2 |
26 Feb 07 |
jari |
34 |
/** |
2 |
26 Feb 07 |
jari |
35 |
* |
2 |
26 Feb 07 |
jari |
* @author braisted |
2 |
26 Feb 07 |
jari |
37 |
*/ |
2 |
26 Feb 07 |
jari |
38 |
public class GONode extends KNodeImpl implements ITreeNodeRenderer { |
2 |
26 Feb 07 |
jari |
/** GO ID |
2 |
26 Feb 07 |
jari |
40 |
*/ |
2 |
26 Feb 07 |
jari |
41 |
private String goID; |
2 |
26 Feb 07 |
jari |
/** GO Term |
2 |
26 Feb 07 |
jari |
43 |
*/ |
2 |
26 Feb 07 |
jari |
44 |
private String goTerm; |
2 |
26 Feb 07 |
jari |
/** GO Category |
2 |
26 Feb 07 |
jari |
46 |
*/ |
2 |
26 Feb 07 |
jari |
47 |
private String goCategory; |
2 |
26 Feb 07 |
jari |
/** p-value |
2 |
26 Feb 07 |
jari |
49 |
*/ |
2 |
26 Feb 07 |
jari |
50 |
private double pValue; |
2 |
26 Feb 07 |
jari |
/** number of list hits |
2 |
26 Feb 07 |
jari |
52 |
*/ |
2 |
26 Feb 07 |
jari |
53 |
private int listHits; |
2 |
26 Feb 07 |
jari |
/** number of population hits |
2 |
26 Feb 07 |
jari |
55 |
*/ |
2 |
26 Feb 07 |
jari |
56 |
private int listSize; |
2 |
26 Feb 07 |
jari |
/** list size |
2 |
26 Feb 07 |
jari |
58 |
*/ |
2 |
26 Feb 07 |
jari |
59 |
private int popHits; |
2 |
26 Feb 07 |
jari |
/** population size |
2 |
26 Feb 07 |
jari |
61 |
*/ |
2 |
26 Feb 07 |
jari |
62 |
private int popSize; |
2 |
26 Feb 07 |
jari |
/** lower p-value threshold |
2 |
26 Feb 07 |
jari |
64 |
*/ |
2 |
26 Feb 07 |
jari |
65 |
private double lowerThr; |
2 |
26 Feb 07 |
jari |
/** upper p-value threshold |
2 |
26 Feb 07 |
jari |
67 |
*/ |
2 |
26 Feb 07 |
jari |
68 |
private double upperThr; |
2 |
26 Feb 07 |
jari |
/** cluster index |
2 |
26 Feb 07 |
jari |
70 |
*/ |
2 |
26 Feb 07 |
jari |
71 |
private int clusterIndex = -1; |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
|
2 |
26 Feb 07 |
jari |
//Rendering fields |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
76 |
private int renderingHint; |
2 |
26 Feb 07 |
jari |
77 |
private int VERBOSE_HEIGHT = 130; |
2 |
26 Feb 07 |
jari |
78 |
private int VERBOSE_WIDTH = 125; |
2 |
26 Feb 07 |
jari |
79 |
private int NON_VERBOSE_HEIGHT = 15; |
2 |
26 Feb 07 |
jari |
80 |
private int NON_VERBOSE_WIDTH = 15; |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
82 |
private int GO_ID_HEIGHT = 20; |
2 |
26 Feb 07 |
jari |
83 |
private int GO_TERM_HEIGHT = 70; |
2 |
26 Feb 07 |
jari |
84 |
private int GO_STAT_HEIGHT = 20; |
2 |
26 Feb 07 |
jari |
85 |
private int GO_POP_HEIGHT = 20; |
2 |
26 Feb 07 |
jari |
86 |
|
2 |
26 Feb 07 |
jari |
87 |
public void setParents(ITreeNode[] p){ |
2 |
26 Feb 07 |
jari |
88 |
Vector v = new Vector(p.length); |
2 |
26 Feb 07 |
jari |
89 |
for(int i=0; i<p.length; i++){ |
2 |
26 Feb 07 |
jari |
90 |
v.add(p[i]); |
2 |
26 Feb 07 |
jari |
91 |
} |
2 |
26 Feb 07 |
jari |
92 |
this.setParents(v); |
2 |
26 Feb 07 |
jari |
93 |
} |
2 |
26 Feb 07 |
jari |
94 |
public void setChildren(ITreeNode[] c){ |
2 |
26 Feb 07 |
jari |
95 |
Vector v = new Vector(c.length); |
2 |
26 Feb 07 |
jari |
96 |
for(int i=0; i<c.length; i++){ |
2 |
26 Feb 07 |
jari |
97 |
v.add(c[i]); |
2 |
26 Feb 07 |
jari |
98 |
} |
2 |
26 Feb 07 |
jari |
99 |
this.setChildren(v); |
2 |
26 Feb 07 |
jari |
100 |
} |
2 |
26 Feb 07 |
jari |
101 |
public GONode(){super();} |
2 |
26 Feb 07 |
jari |
102 |
public GONode(String goID, String goTerm, String goCategory, double pValue, int clusterHits, int clusterSize, |
2 |
26 Feb 07 |
jari |
103 |
int popHits, int popSize, int clusterIndex) { |
2 |
26 Feb 07 |
jari |
104 |
super(); |
2 |
26 Feb 07 |
jari |
105 |
this.goID = goID; |
2 |
26 Feb 07 |
jari |
106 |
this.goTerm = goTerm; |
2 |
26 Feb 07 |
jari |
107 |
this.goCategory = goCategory; |
2 |
26 Feb 07 |
jari |
108 |
this.pValue = pValue; |
2 |
26 Feb 07 |
jari |
109 |
this.listHits = clusterHits; |
2 |
26 Feb 07 |
jari |
110 |
this.listSize = clusterSize; |
2 |
26 Feb 07 |
jari |
111 |
this.popHits = popHits; |
2 |
26 Feb 07 |
jari |
112 |
this.popSize = popSize; |
2 |
26 Feb 07 |
jari |
113 |
this.clusterIndex = clusterIndex; |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
public GONode(GONode origNode) { |
2 |
26 Feb 07 |
jari |
117 |
super(); |
2 |
26 Feb 07 |
jari |
118 |
this.goID = origNode.getGOID(); |
2 |
26 Feb 07 |
jari |
119 |
this.goTerm = origNode.getTerm(); |
2 |
26 Feb 07 |
jari |
120 |
this.goCategory = origNode.getCategory(); |
2 |
26 Feb 07 |
jari |
121 |
this.pValue = origNode.getPValue(); |
2 |
26 Feb 07 |
jari |
122 |
this.listHits = origNode.getListHits(); |
2 |
26 Feb 07 |
jari |
123 |
this.listSize = origNode.getListSize(); |
2 |
26 Feb 07 |
jari |
124 |
this.popHits = origNode.getPopHits(); |
2 |
26 Feb 07 |
jari |
125 |
this.popSize = origNode.getPopSize(); |
2 |
26 Feb 07 |
jari |
126 |
this.upperThr = origNode.getUpperThr(); |
2 |
26 Feb 07 |
jari |
127 |
this.lowerThr = origNode.getLowerThr(); |
2 |
26 Feb 07 |
jari |
128 |
this.children = origNode.getChildren(); |
2 |
26 Feb 07 |
jari |
129 |
this.parents = origNode.getParents(); |
2 |
26 Feb 07 |
jari |
130 |
this.level = origNode.getLevel(); |
2 |
26 Feb 07 |
jari |
131 |
this.verboseRendering = origNode.isVerboseRendering(); |
2 |
26 Feb 07 |
jari |
132 |
this.clusterIndex = origNode.getClusterIndex(); |
2 |
26 Feb 07 |
jari |
133 |
} |
2 |
26 Feb 07 |
jari |
134 |
|
2 |
26 Feb 07 |
jari |
135 |
public String getTerm() { |
2 |
26 Feb 07 |
jari |
136 |
return goTerm; |
2 |
26 Feb 07 |
jari |
137 |
} |
2 |
26 Feb 07 |
jari |
138 |
|
2 |
26 Feb 07 |
jari |
139 |
public String getGOID() { |
2 |
26 Feb 07 |
jari |
140 |
return goID; |
2 |
26 Feb 07 |
jari |
141 |
} |
2 |
26 Feb 07 |
jari |
142 |
|
2 |
26 Feb 07 |
jari |
143 |
public double getPValue() { |
2 |
26 Feb 07 |
jari |
144 |
return pValue; |
2 |
26 Feb 07 |
jari |
145 |
} |
2 |
26 Feb 07 |
jari |
146 |
|
2 |
26 Feb 07 |
jari |
147 |
public String getCategory() { |
2 |
26 Feb 07 |
jari |
148 |
return this.goCategory; |
2 |
26 Feb 07 |
jari |
149 |
} |
2 |
26 Feb 07 |
jari |
150 |
|
2 |
26 Feb 07 |
jari |
151 |
public int getListHits() { |
2 |
26 Feb 07 |
jari |
152 |
return listHits; |
2 |
26 Feb 07 |
jari |
153 |
} |
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
public int getListSize() { |
2 |
26 Feb 07 |
jari |
156 |
return listSize; |
2 |
26 Feb 07 |
jari |
157 |
} |
2 |
26 Feb 07 |
jari |
158 |
|
2 |
26 Feb 07 |
jari |
159 |
public int getPopHits() { |
2 |
26 Feb 07 |
jari |
160 |
return popHits; |
2 |
26 Feb 07 |
jari |
161 |
} |
2 |
26 Feb 07 |
jari |
162 |
|
2 |
26 Feb 07 |
jari |
163 |
public int getPopSize() { |
2 |
26 Feb 07 |
jari |
164 |
return popSize; |
2 |
26 Feb 07 |
jari |
165 |
} |
2 |
26 Feb 07 |
jari |
166 |
|
2 |
26 Feb 07 |
jari |
167 |
public void setTerm(String term) { |
2 |
26 Feb 07 |
jari |
168 |
this.goTerm = term; |
2 |
26 Feb 07 |
jari |
169 |
} |
2 |
26 Feb 07 |
jari |
170 |
|
2 |
26 Feb 07 |
jari |
171 |
public void setListHits(int hits) { |
2 |
26 Feb 07 |
jari |
172 |
this.listHits = hits; |
2 |
26 Feb 07 |
jari |
173 |
} |
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
public void setListSize(int size) { |
2 |
26 Feb 07 |
jari |
176 |
this.listSize = size; |
2 |
26 Feb 07 |
jari |
177 |
} |
2 |
26 Feb 07 |
jari |
178 |
|
2 |
26 Feb 07 |
jari |
179 |
public void setPopHits(int hits) { |
2 |
26 Feb 07 |
jari |
180 |
this.popHits = hits; |
2 |
26 Feb 07 |
jari |
181 |
} |
2 |
26 Feb 07 |
jari |
182 |
|
2 |
26 Feb 07 |
jari |
183 |
public void setPopSize(int size) { |
2 |
26 Feb 07 |
jari |
184 |
this.popSize = size; |
2 |
26 Feb 07 |
jari |
185 |
} |
2 |
26 Feb 07 |
jari |
186 |
|
2 |
26 Feb 07 |
jari |
187 |
public void setLowerThr(double lower) { |
2 |
26 Feb 07 |
jari |
188 |
lowerThr = lower; |
2 |
26 Feb 07 |
jari |
189 |
} |
2 |
26 Feb 07 |
jari |
190 |
|
2 |
26 Feb 07 |
jari |
191 |
public void setUpperThr(double upper) { |
2 |
26 Feb 07 |
jari |
192 |
upperThr = upper; |
2 |
26 Feb 07 |
jari |
193 |
} |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
public double getLowerThr() { |
2 |
26 Feb 07 |
jari |
196 |
return lowerThr; |
2 |
26 Feb 07 |
jari |
197 |
} |
2 |
26 Feb 07 |
jari |
198 |
|
2 |
26 Feb 07 |
jari |
199 |
public double getUpperThr() { |
2 |
26 Feb 07 |
jari |
200 |
return upperThr; |
2 |
26 Feb 07 |
jari |
201 |
} |
2 |
26 Feb 07 |
jari |
202 |
|
2 |
26 Feb 07 |
jari |
203 |
public int getClusterIndex() { |
2 |
26 Feb 07 |
jari |
204 |
return clusterIndex; |
2 |
26 Feb 07 |
jari |
205 |
} |
2 |
26 Feb 07 |
jari |
206 |
|
2 |
26 Feb 07 |
jari |
207 |
public void addChild(GONode node) { |
2 |
26 Feb 07 |
jari |
208 |
super.addChild(node); |
2 |
26 Feb 07 |
jari |
209 |
} |
2 |
26 Feb 07 |
jari |
210 |
|
2 |
26 Feb 07 |
jari |
211 |
public void addParent(GONode node) { |
2 |
26 Feb 07 |
jari |
212 |
super.addParent(node); |
2 |
26 Feb 07 |
jari |
213 |
} |
2 |
26 Feb 07 |
jari |
214 |
|
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
//Rendering methods |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the rendering hint |
2 |
26 Feb 07 |
jari |
220 |
*/ |
2 |
26 Feb 07 |
jari |
221 |
public void setRenderingHint(int hint) { |
2 |
26 Feb 07 |
jari |
222 |
renderingHint = hint; |
2 |
26 Feb 07 |
jari |
223 |
setDimensions(); |
2 |
26 Feb 07 |
jari |
224 |
} |
2 |
26 Feb 07 |
jari |
225 |
|
2 |
26 Feb 07 |
jari |
226 |
/** |
2 |
26 Feb 07 |
jari |
* Renderer menthod to display a GONode |
2 |
26 Feb 07 |
jari |
228 |
*/ |
2 |
26 Feb 07 |
jari |
229 |
public void renderNode(Graphics2D g2, int x, int y, int modifier) { |
2 |
26 Feb 07 |
jari |
230 |
Color origColor = g2.getColor(); |
2 |
26 Feb 07 |
jari |
231 |
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
2 |
26 Feb 07 |
jari |
232 |
Composite composite = g2.getComposite(); |
2 |
26 Feb 07 |
jari |
233 |
|
2 |
26 Feb 07 |
jari |
234 |
if(modifier == ITreeNodeRenderer.NON_PATH_NODE) { |
2 |
26 Feb 07 |
jari |
235 |
AlphaComposite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f); |
2 |
26 Feb 07 |
jari |
236 |
g2.setComposite(alphaComp); |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
|
2 |
26 Feb 07 |
jari |
239 |
int yOffset = 0; |
2 |
26 Feb 07 |
jari |
240 |
this.x = x; |
2 |
26 Feb 07 |
jari |
241 |
this.y = y; |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
if(verboseRendering) { |
2 |
26 Feb 07 |
jari |
244 |
this.x = x; |
2 |
26 Feb 07 |
jari |
245 |
this.y = y; |
2 |
26 Feb 07 |
jari |
246 |
|
2 |
26 Feb 07 |
jari |
//draw 2 pixel border |
2 |
26 Feb 07 |
jari |
248 |
g2.drawRect(x,y,w,h); |
2 |
26 Feb 07 |
jari |
249 |
yOffset += 1; |
2 |
26 Feb 07 |
jari |
250 |
g2.drawRect(x+1, y+yOffset, w-2, h-2); |
2 |
26 Feb 07 |
jari |
251 |
|
2 |
26 Feb 07 |
jari |
//render go id area according to pValue |
2 |
26 Feb 07 |
jari |
253 |
if(pValue > upperThr) |
2 |
26 Feb 07 |
jari |
254 |
g2.setColor(Color.green); |
2 |
26 Feb 07 |
jari |
255 |
else if(pValue <= upperThr && pValue > lowerThr) |
2 |
26 Feb 07 |
jari |
256 |
g2.setColor(Color.orange); |
2 |
26 Feb 07 |
jari |
257 |
else |
2 |
26 Feb 07 |
jari |
258 |
g2.setColor(Color.red); |
2 |
26 Feb 07 |
jari |
259 |
|
2 |
26 Feb 07 |
jari |
260 |
yOffset += 1; |
2 |
26 Feb 07 |
jari |
261 |
g2.fillRect(x+2, y+yOffset, w-3, GO_ID_HEIGHT); |
2 |
26 Feb 07 |
jari |
262 |
yOffset += GO_ID_HEIGHT; |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
//reset color |
2 |
26 Feb 07 |
jari |
265 |
g2.setColor(origColor); |
2 |
26 Feb 07 |
jari |
266 |
|
2 |
26 Feb 07 |
jari |
//render go id text |
2 |
26 Feb 07 |
jari |
268 |
TextLayout layout = new TextLayout(goID, g2.getFont(), g2.getFontRenderContext()); |
2 |
26 Feb 07 |
jari |
269 |
layout.draw(g2, x + (w - layout.getAdvance())/2, y + layout.getAscent() + (this.GO_ID_HEIGHT - layout.getAscent())/2); |
2 |
26 Feb 07 |
jari |
270 |
|
2 |
26 Feb 07 |
jari |
//render go id divider |
2 |
26 Feb 07 |
jari |
272 |
g2.drawLine(x, y + yOffset, x+w, y + yOffset); |
2 |
26 Feb 07 |
jari |
273 |
|
2 |
26 Feb 07 |
jari |
//render go term text |
2 |
26 Feb 07 |
jari |
275 |
int yLoc = y + yOffset +2; |
2 |
26 Feb 07 |
jari |
276 |
int marginLoc = x + 6; |
2 |
26 Feb 07 |
jari |
277 |
renderGoTermText(g2, marginLoc, yLoc); |
2 |
26 Feb 07 |
jari |
278 |
|
2 |
26 Feb 07 |
jari |
//render go term divider |
2 |
26 Feb 07 |
jari |
280 |
g2.drawLine(x, y + GO_TERM_HEIGHT + yOffset, x+w, y + GO_TERM_HEIGHT + yOffset); |
2 |
26 Feb 07 |
jari |
281 |
yOffset += GO_TERM_HEIGHT; |
2 |
26 Feb 07 |
jari |
282 |
|
2 |
26 Feb 07 |
jari |
//render p-value |
2 |
26 Feb 07 |
jari |
//renderPVaue(g2, yOffset); |
2 |
26 Feb 07 |
jari |
285 |
DecimalFormat format; |
2 |
26 Feb 07 |
jari |
286 |
|
2 |
26 Feb 07 |
jari |
287 |
String pStr; |
2 |
26 Feb 07 |
jari |
288 |
if (pValue < 0.0001){ |
2 |
26 Feb 07 |
jari |
289 |
format = new DecimalFormat("0.#####E00"); |
2 |
26 Feb 07 |
jari |
290 |
pStr = format.format(pValue); |
2 |
26 Feb 07 |
jari |
291 |
} else { |
2 |
26 Feb 07 |
jari |
292 |
format = new DecimalFormat("0.#####"); |
2 |
26 Feb 07 |
jari |
293 |
pStr = format.format(pValue); |
2 |
26 Feb 07 |
jari |
294 |
} |
2 |
26 Feb 07 |
jari |
295 |
|
2 |
26 Feb 07 |
jari |
296 |
layout = new TextLayout("p = "+pStr, g2.getFont(), g2.getFontRenderContext()); |
2 |
26 Feb 07 |
jari |
297 |
layout.draw(g2, x + (w - layout.getAdvance())/2, y + yOffset + layout.getAscent() + (this.GO_STAT_HEIGHT - layout.getAscent())/2); |
2 |
26 Feb 07 |
jari |
298 |
|
2 |
26 Feb 07 |
jari |
299 |
g2.drawLine(x, y + GO_STAT_HEIGHT + yOffset, x+w, y + GO_STAT_HEIGHT + yOffset); |
2 |
26 Feb 07 |
jari |
300 |
yOffset += GO_STAT_HEIGHT; |
2 |
26 Feb 07 |
jari |
301 |
|
2 |
26 Feb 07 |
jari |
302 |
layout = new TextLayout("("+String.valueOf(listHits)+") ("+String.valueOf(popHits)+")", g2.getFont(), g2.getFontRenderContext()); |
2 |
26 Feb 07 |
jari |
303 |
layout.draw(g2, x + (w - layout.getAdvance())/2, y + yOffset + layout.getAscent() + (this.GO_POP_HEIGHT - layout.getAscent())/2 - 2); |
2 |
26 Feb 07 |
jari |
304 |
|
2 |
26 Feb 07 |
jari |
305 |
if(modifier == ITreeNodeRenderer.SELECTED_NODE) { |
2 |
26 Feb 07 |
jari |
306 |
g2.setColor(Color.red); |
2 |
26 Feb 07 |
jari |
307 |
g2.drawRect(x-3, y-3, w+6, h+6); |
2 |
26 Feb 07 |
jari |
308 |
g2.drawRect(x-2, y-2, w+4, h+4); |
2 |
26 Feb 07 |
jari |
309 |
g2.setColor(origColor); |
2 |
26 Feb 07 |
jari |
310 |
} else if(modifier == ITreeNodeRenderer.PATH_NODE) { |
2 |
26 Feb 07 |
jari |
311 |
g2.setColor(Color.blue); |
2 |
26 Feb 07 |
jari |
312 |
g2.drawRect(x-3, y-3, w+6, h+6); |
2 |
26 Feb 07 |
jari |
313 |
g2.drawRect(x-2, y-2, w+4, h+4); |
2 |
26 Feb 07 |
jari |
314 |
g2.setColor(origColor); |
2 |
26 Feb 07 |
jari |
315 |
} |
2 |
26 Feb 07 |
jari |
316 |
|
2 |
26 Feb 07 |
jari |
317 |
} else { |
2 |
26 Feb 07 |
jari |
318 |
|
2 |
26 Feb 07 |
jari |
//render go id area according to pValue |
2 |
26 Feb 07 |
jari |
320 |
if(pValue > upperThr) |
2 |
26 Feb 07 |
jari |
321 |
g2.setColor(Color.green); |
2 |
26 Feb 07 |
jari |
322 |
else if(pValue <= upperThr && pValue > lowerThr) |
2 |
26 Feb 07 |
jari |
323 |
g2.setColor(Color.orange); |
2 |
26 Feb 07 |
jari |
324 |
else |
2 |
26 Feb 07 |
jari |
325 |
g2.setColor(Color.red); |
2 |
26 Feb 07 |
jari |
326 |
|
2 |
26 Feb 07 |
jari |
327 |
g2.fillOval(x,y,w,h); |
2 |
26 Feb 07 |
jari |
328 |
g2.setColor(Color.black); |
2 |
26 Feb 07 |
jari |
329 |
g2.drawOval(x,y,w,h); |
2 |
26 Feb 07 |
jari |
330 |
g2.setColor(origColor); |
2 |
26 Feb 07 |
jari |
331 |
|
2 |
26 Feb 07 |
jari |
332 |
if(modifier == ITreeNodeRenderer.SELECTED_NODE) { |
2 |
26 Feb 07 |
jari |
333 |
g2.setColor(Color.red); |
2 |
26 Feb 07 |
jari |
334 |
g2.drawOval(x-3, y-3, w+6, h+6); |
2 |
26 Feb 07 |
jari |
335 |
g2.drawOval(x-2, y-2, w+4, h+4); |
2 |
26 Feb 07 |
jari |
336 |
g2.setColor(origColor); |
2 |
26 Feb 07 |
jari |
337 |
} else if(modifier == ITreeNodeRenderer.PATH_NODE) { |
2 |
26 Feb 07 |
jari |
338 |
g2.setColor(Color.blue); |
2 |
26 Feb 07 |
jari |
339 |
g2.drawOval(x-3, y-3, w+6, h+6); |
2 |
26 Feb 07 |
jari |
340 |
g2.drawOval(x-2, y-2, w+4, h+4); |
2 |
26 Feb 07 |
jari |
341 |
g2.setColor(origColor); |
2 |
26 Feb 07 |
jari |
342 |
} |
2 |
26 Feb 07 |
jari |
343 |
} |
2 |
26 Feb 07 |
jari |
344 |
g2.setComposite(composite); |
2 |
26 Feb 07 |
jari |
345 |
} |
2 |
26 Feb 07 |
jari |
346 |
|
2 |
26 Feb 07 |
jari |
347 |
private void renderPVaue(Graphics2D g2, int yOffset) { |
2 |
26 Feb 07 |
jari |
348 |
DecimalFormat format = new DecimalFormat(); |
2 |
26 Feb 07 |
jari |
349 |
format.setMaximumFractionDigits(5); |
2 |
26 Feb 07 |
jari |
350 |
format.setMaximumIntegerDigits(1); |
2 |
26 Feb 07 |
jari |
351 |
format.setMinimumIntegerDigits(1); |
2 |
26 Feb 07 |
jari |
352 |
format.setMinimumFractionDigits(4); |
2 |
26 Feb 07 |
jari |
353 |
String pStr = format.format(pValue); |
2 |
26 Feb 07 |
jari |
354 |
TextLayout layout = new TextLayout("p = "+pStr, g2.getFont(), g2.getFontRenderContext()); |
2 |
26 Feb 07 |
jari |
355 |
layout.draw(g2, x + (w - layout.getAdvance())/2, y + yOffset + layout.getAscent() + (this.GO_STAT_HEIGHT - layout.getAscent())/2); |
2 |
26 Feb 07 |
jari |
356 |
} |
2 |
26 Feb 07 |
jari |
357 |
|
2 |
26 Feb 07 |
jari |
358 |
private void renderGoTermText(Graphics2D g2, int marginLoc, int yLoc) { |
2 |
26 Feb 07 |
jari |
359 |
TextLayout layout; |
2 |
26 Feb 07 |
jari |
360 |
|
2 |
26 Feb 07 |
jari |
361 |
AttributedString goTermAttStr = new AttributedString(goTerm); |
2 |
26 Feb 07 |
jari |
362 |
goTermAttStr.addAttribute(TextAttribute.JUSTIFICATION, TextAttribute.JUSTIFICATION_NONE); |
2 |
26 Feb 07 |
jari |
363 |
goTermAttStr.addAttribute(TextAttribute.FONT, new Font("Arial", Font.PLAIN, 12)); |
2 |
26 Feb 07 |
jari |
364 |
|
2 |
26 Feb 07 |
jari |
365 |
int width = g2.getFontMetrics().stringWidth(goTerm); |
2 |
26 Feb 07 |
jari |
366 |
if(width > 4 * w) |
2 |
26 Feb 07 |
jari |
367 |
goTermAttStr.addAttribute(TextAttribute.FONT, new Font("Arial", Font.PLAIN, 11)); |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
369 |
AttributedCharacterIterator iter = goTermAttStr.getIterator(); |
2 |
26 Feb 07 |
jari |
370 |
FontRenderContext frc = new FontRenderContext(null, true, true); |
2 |
26 Feb 07 |
jari |
371 |
LineBreakMeasurer lbm = new LineBreakMeasurer(iter, frc); |
2 |
26 Feb 07 |
jari |
372 |
|
2 |
26 Feb 07 |
jari |
373 |
Vector layouts = new Vector(); |
2 |
26 Feb 07 |
jari |
374 |
Vector penPos = new Vector(); |
2 |
26 Feb 07 |
jari |
375 |
Point2D.Float penPoint; |
2 |
26 Feb 07 |
jari |
376 |
while(lbm.getPosition() < iter.getEndIndex()) { |
2 |
26 Feb 07 |
jari |
377 |
layout = lbm.nextLayout(w - 2*5); |
2 |
26 Feb 07 |
jari |
378 |
yLoc += layout.getAscent(); |
2 |
26 Feb 07 |
jari |
379 |
|
2 |
26 Feb 07 |
jari |
380 |
penPoint = new Point2D.Float(marginLoc, yLoc); |
2 |
26 Feb 07 |
jari |
381 |
|
2 |
26 Feb 07 |
jari |
382 |
if(layouts.size() > 0) { |
2 |
26 Feb 07 |
jari |
383 |
TextLayout prevLine = (TextLayout)layouts.elementAt(layouts.size()-1); |
2 |
26 Feb 07 |
jari |
384 |
prevLine = prevLine.getJustifiedLayout((w-2*5)); |
2 |
26 Feb 07 |
jari |
385 |
layouts.setElementAt(prevLine, layouts.size()-1); |
2 |
26 Feb 07 |
jari |
386 |
} |
2 |
26 Feb 07 |
jari |
387 |
|
2 |
26 Feb 07 |
jari |
388 |
penPos.addElement(penPoint); |
2 |
26 Feb 07 |
jari |
389 |
layouts.addElement(layout); |
2 |
26 Feb 07 |
jari |
390 |
yLoc += layout.getDescent() + layout.getLeading(); |
2 |
26 Feb 07 |
jari |
391 |
} |
2 |
26 Feb 07 |
jari |
392 |
|
2 |
26 Feb 07 |
jari |
//have layouts and pen positions |
2 |
26 Feb 07 |
jari |
394 |
for(int i = 0; i < layouts.size(); i++) { |
2 |
26 Feb 07 |
jari |
395 |
layout = (TextLayout)(layouts.elementAt(i)); |
2 |
26 Feb 07 |
jari |
396 |
penPoint = (Point2D.Float)(penPos.elementAt(i)); |
2 |
26 Feb 07 |
jari |
397 |
layout.draw(g2, penPoint.x, penPoint.y); |
2 |
26 Feb 07 |
jari |
398 |
} |
2 |
26 Feb 07 |
jari |
399 |
} |
2 |
26 Feb 07 |
jari |
400 |
|
2 |
26 Feb 07 |
jari |
401 |
private void setDimensions() { |
2 |
26 Feb 07 |
jari |
402 |
if(renderingHint == ITreeNodeRenderer.RENDERING_HINT_VERBOSE) { |
2 |
26 Feb 07 |
jari |
403 |
w = VERBOSE_WIDTH; |
2 |
26 Feb 07 |
jari |
404 |
h = VERBOSE_HEIGHT; |
2 |
26 Feb 07 |
jari |
405 |
verboseRendering = true; |
2 |
26 Feb 07 |
jari |
406 |
} else { |
2 |
26 Feb 07 |
jari |
407 |
w = NON_VERBOSE_WIDTH; |
2 |
26 Feb 07 |
jari |
408 |
h = NON_VERBOSE_HEIGHT; |
2 |
26 Feb 07 |
jari |
409 |
verboseRendering = false; |
2 |
26 Feb 07 |
jari |
410 |
} |
2 |
26 Feb 07 |
jari |
411 |
} |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
|
2 |
26 Feb 07 |
jari |
414 |
/** |
2 |
26 Feb 07 |
jari |
* @return Returns the goCategory. |
2 |
26 Feb 07 |
jari |
416 |
*/ |
2 |
26 Feb 07 |
jari |
417 |
public String getGoCategory() { |
2 |
26 Feb 07 |
jari |
418 |
return goCategory; |
2 |
26 Feb 07 |
jari |
419 |
} |
2 |
26 Feb 07 |
jari |
420 |
/** |
2 |
26 Feb 07 |
jari |
* @param goCategory The goCategory to set. |
2 |
26 Feb 07 |
jari |
422 |
*/ |
2 |
26 Feb 07 |
jari |
423 |
public void setGoCategory(String goCategory) { |
2 |
26 Feb 07 |
jari |
424 |
this.goCategory = goCategory; |
2 |
26 Feb 07 |
jari |
425 |
} |
2 |
26 Feb 07 |
jari |
426 |
/** |
2 |
26 Feb 07 |
jari |
* @return Returns the goID. |
2 |
26 Feb 07 |
jari |
428 |
*/ |
2 |
26 Feb 07 |
jari |
429 |
public String getGoID() { |
2 |
26 Feb 07 |
jari |
430 |
return goID; |
2 |
26 Feb 07 |
jari |
431 |
} |
2 |
26 Feb 07 |
jari |
432 |
/** |
2 |
26 Feb 07 |
jari |
* @param goID The goID to set. |
2 |
26 Feb 07 |
jari |
434 |
*/ |
2 |
26 Feb 07 |
jari |
435 |
public void setGoID(String goID) { |
2 |
26 Feb 07 |
jari |
436 |
this.goID = goID; |
2 |
26 Feb 07 |
jari |
437 |
} |
2 |
26 Feb 07 |
jari |
438 |
/** |
2 |
26 Feb 07 |
jari |
* @return Returns the goTerm. |
2 |
26 Feb 07 |
jari |
440 |
*/ |
2 |
26 Feb 07 |
jari |
441 |
public String getGoTerm() { |
2 |
26 Feb 07 |
jari |
442 |
return goTerm; |
2 |
26 Feb 07 |
jari |
443 |
} |
2 |
26 Feb 07 |
jari |
444 |
/** |
2 |
26 Feb 07 |
jari |
* @param goTerm The goTerm to set. |
2 |
26 Feb 07 |
jari |
446 |
*/ |
2 |
26 Feb 07 |
jari |
447 |
public void setGoTerm(String goTerm) { |
2 |
26 Feb 07 |
jari |
448 |
this.goTerm = goTerm; |
2 |
26 Feb 07 |
jari |
449 |
} |
2 |
26 Feb 07 |
jari |
450 |
/** |
2 |
26 Feb 07 |
jari |
* @param clusterIndex The clusterIndex to set. |
2 |
26 Feb 07 |
jari |
452 |
*/ |
2 |
26 Feb 07 |
jari |
453 |
public void setClusterIndex(int clusterIndex) { |
2 |
26 Feb 07 |
jari |
454 |
this.clusterIndex = clusterIndex; |
2 |
26 Feb 07 |
jari |
455 |
} |
2 |
26 Feb 07 |
jari |
456 |
/** |
2 |
26 Feb 07 |
jari |
* @param value The pValue to set. |
2 |
26 Feb 07 |
jari |
458 |
*/ |
2 |
26 Feb 07 |
jari |
459 |
public void setPValue(double value) { |
2 |
26 Feb 07 |
jari |
460 |
pValue = value; |
2 |
26 Feb 07 |
jari |
461 |
} |
2 |
26 Feb 07 |
jari |
462 |
} |