2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2005, 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 |
* COAContent3D.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on September 21, 2004, 1:04 PM |
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.coa; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.BorderLayout; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Dimension; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Font; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.FontMetrics; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.GraphicsConfiguration; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
20 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
21 |
|
2 |
26 Feb 07 |
jari |
22 |
import javax.media.j3d.AmbientLight; |
2 |
26 Feb 07 |
jari |
23 |
import javax.media.j3d.Appearance; |
2 |
26 Feb 07 |
jari |
24 |
import javax.media.j3d.Background; |
2 |
26 Feb 07 |
jari |
25 |
import javax.media.j3d.BoundingSphere; |
2 |
26 Feb 07 |
jari |
26 |
import javax.media.j3d.BranchGroup; |
2 |
26 Feb 07 |
jari |
27 |
import javax.media.j3d.Canvas3D; |
2 |
26 Feb 07 |
jari |
28 |
import javax.media.j3d.ColoringAttributes; |
2 |
26 Feb 07 |
jari |
29 |
import javax.media.j3d.Font3D; |
2 |
26 Feb 07 |
jari |
30 |
import javax.media.j3d.FontExtrusion; |
2 |
26 Feb 07 |
jari |
31 |
import javax.media.j3d.ImageComponent; |
2 |
26 Feb 07 |
jari |
32 |
import javax.media.j3d.ImageComponent2D; |
2 |
26 Feb 07 |
jari |
33 |
import javax.media.j3d.Light; |
2 |
26 Feb 07 |
jari |
34 |
import javax.media.j3d.LineAttributes; |
2 |
26 Feb 07 |
jari |
35 |
import javax.media.j3d.Material; |
2 |
26 Feb 07 |
jari |
36 |
import javax.media.j3d.PointArray; |
2 |
26 Feb 07 |
jari |
37 |
import javax.media.j3d.PointAttributes; |
2 |
26 Feb 07 |
jari |
38 |
import javax.media.j3d.PointLight; |
2 |
26 Feb 07 |
jari |
39 |
import javax.media.j3d.Screen3D; |
2 |
26 Feb 07 |
jari |
40 |
import javax.media.j3d.Shape3D; |
2 |
26 Feb 07 |
jari |
41 |
import javax.media.j3d.Text3D; |
2 |
26 Feb 07 |
jari |
42 |
import javax.media.j3d.Transform3D; |
2 |
26 Feb 07 |
jari |
43 |
import javax.media.j3d.TransformGroup; |
2 |
26 Feb 07 |
jari |
44 |
import javax.media.j3d.TransparencyAttributes; |
2 |
26 Feb 07 |
jari |
45 |
import javax.swing.JPanel; |
2 |
26 Feb 07 |
jari |
46 |
import javax.vecmath.Color3f; |
2 |
26 Feb 07 |
jari |
47 |
import javax.vecmath.Point3d; |
2 |
26 Feb 07 |
jari |
48 |
import javax.vecmath.Point3f; |
2 |
26 Feb 07 |
jari |
49 |
import javax.vecmath.Vector3d; |
2 |
26 Feb 07 |
jari |
50 |
import javax.vecmath.Vector3f; |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
53 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
54 |
import org.tigr.microarray.mev.cluster.gui.impl.pca.OpenBehavior; |
2 |
26 Feb 07 |
jari |
55 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
import com.sun.j3d.utils.geometry.Box; |
2 |
26 Feb 07 |
jari |
58 |
import com.sun.j3d.utils.geometry.Cone; |
2 |
26 Feb 07 |
jari |
59 |
import com.sun.j3d.utils.geometry.Cylinder; |
2 |
26 Feb 07 |
jari |
60 |
import com.sun.j3d.utils.geometry.Sphere; |
2 |
26 Feb 07 |
jari |
61 |
import com.sun.j3d.utils.picking.behaviors.PickRotateBehavior; |
2 |
26 Feb 07 |
jari |
62 |
import com.sun.j3d.utils.picking.behaviors.PickTranslateBehavior; |
2 |
26 Feb 07 |
jari |
63 |
import com.sun.j3d.utils.picking.behaviors.PickZoomBehavior; |
2 |
26 Feb 07 |
jari |
64 |
import com.sun.j3d.utils.universe.SimpleUniverse; |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
/** |
2 |
26 Feb 07 |
jari |
68 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
70 |
*/ |
2 |
26 Feb 07 |
jari |
71 |
public class COAContent3D extends JPanel { |
2 |
26 Feb 07 |
jari |
72 |
|
2 |
26 Feb 07 |
jari |
73 |
private IData data; |
2 |
26 Feb 07 |
jari |
74 |
private int geneOrExpt; |
2 |
26 Feb 07 |
jari |
75 |
private int xAxis, yAxis, zAxis; |
2 |
26 Feb 07 |
jari |
76 |
private int geneLabelIndex; |
2 |
26 Feb 07 |
jari |
77 |
private FloatMatrix U, geneUMatrix, exptUMatrix, scaledGeneUMatrix, scaledExptUMatrix; |
2 |
26 Feb 07 |
jari |
78 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
79 |
private SimpleUniverse universe; |
2 |
26 Feb 07 |
jari |
80 |
private Canvas3D onScreenCanvas; |
2 |
26 Feb 07 |
jari |
81 |
private Canvas3D offScreenCanvas; |
2 |
26 Feb 07 |
jari |
82 |
private BranchGroup scene; |
2 |
26 Feb 07 |
jari |
83 |
private TransformGroup spinGroup; |
2 |
26 Feb 07 |
jari |
84 |
private boolean whiteBackground = false; |
2 |
26 Feb 07 |
jari |
85 |
private boolean selection = false; |
2 |
26 Feb 07 |
jari |
86 |
private boolean selectionBox = false; |
2 |
26 Feb 07 |
jari |
87 |
private boolean showSpheres = false; |
2 |
26 Feb 07 |
jari |
88 |
private boolean showText = false; |
2 |
26 Feb 07 |
jari |
89 |
private boolean showGeneTextFromBoth = false; |
2 |
26 Feb 07 |
jari |
90 |
private boolean showExptTextFromBoth = false; |
2 |
26 Feb 07 |
jari |
//private boolean geneViewer = true; |
2 |
26 Feb 07 |
jari |
92 |
private float scaleAxisX = 3f; |
2 |
26 Feb 07 |
jari |
93 |
private float scaleAxisY = 3f; |
2 |
26 Feb 07 |
jari |
94 |
private float scaleAxisZ = 3f; |
2 |
26 Feb 07 |
jari |
95 |
private float boxSizeX = 5f; |
2 |
26 Feb 07 |
jari |
96 |
private float boxSizeY = 5f; |
2 |
26 Feb 07 |
jari |
97 |
private float boxSizeZ = 5f; |
2 |
26 Feb 07 |
jari |
98 |
private float boxPositionX = 0f; |
2 |
26 Feb 07 |
jari |
99 |
private float boxPositionY = 0f; |
2 |
26 Feb 07 |
jari |
100 |
private float boxPositionZ = 0f; |
2 |
26 Feb 07 |
jari |
101 |
private float pointSize = 1.0f; |
2 |
26 Feb 07 |
jari |
102 |
private float selectedPointSize = 1.0f; |
2 |
26 Feb 07 |
jari |
103 |
private Color3f blackColor = new Color3f(0f, 0f, 0f); |
2 |
26 Feb 07 |
jari |
// private Color3f whiteColor = new Color3f(0.8f, 0.8f, 0.8f); |
2 |
26 Feb 07 |
jari |
//private Color3f whiteColor = new Color3f(0.98f, 0.98f, 0.98f); |
2 |
26 Feb 07 |
jari |
106 |
private Color3f whiteColor = new Color3f(1f, 1f, 1f); |
2 |
26 Feb 07 |
jari |
107 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of COAContent3D */ |
2 |
26 Feb 07 |
jari |
109 |
public COAContent3D(FloatMatrix U, Experiment experiment, int geneOrExpt) { |
2 |
26 Feb 07 |
jari |
110 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
111 |
this.U = U; |
2 |
26 Feb 07 |
jari |
112 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
113 |
initScales(U); |
2 |
26 Feb 07 |
jari |
114 |
setLayout(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
115 |
setPreferredSize(new Dimension(10, 10)); |
2 |
26 Feb 07 |
jari |
116 |
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); |
2 |
26 Feb 07 |
jari |
117 |
this.onScreenCanvas = new Canvas3D(config); |
2 |
26 Feb 07 |
jari |
118 |
this.universe = new SimpleUniverse(onScreenCanvas); |
2 |
26 Feb 07 |
jari |
119 |
universe.getViewingPlatform().setNominalViewingTransform(); |
2 |
26 Feb 07 |
jari |
120 |
|
2 |
26 Feb 07 |
jari |
121 |
boxSizeX = (float)(scaleAxisX/5f); |
2 |
26 Feb 07 |
jari |
122 |
boxSizeY = (float)(scaleAxisY/5f); |
2 |
26 Feb 07 |
jari |
123 |
boxSizeZ = (float)(scaleAxisZ/5f); |
2 |
26 Feb 07 |
jari |
124 |
|
2 |
26 Feb 07 |
jari |
125 |
offScreenCanvas = new Canvas3D(config, true); |
2 |
26 Feb 07 |
jari |
126 |
Screen3D sOn = onScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
127 |
Screen3D sOff = offScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
128 |
sOff.setSize(sOn.getSize()); |
2 |
26 Feb 07 |
jari |
129 |
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth()); |
2 |
26 Feb 07 |
jari |
130 |
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight()); |
2 |
26 Feb 07 |
jari |
// attach the offscreen canvas to the view |
2 |
26 Feb 07 |
jari |
132 |
universe.getViewer().getView().addCanvas3D(offScreenCanvas); |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
add(onScreenCanvas, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
135 |
} |
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
public COAContent3D(FloatMatrix U, Experiment experiment, int geneOrExpt, int xAxis, int yAxis, int zAxis) { |
2 |
26 Feb 07 |
jari |
138 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
139 |
this.xAxis = xAxis; |
2 |
26 Feb 07 |
jari |
140 |
this.yAxis = yAxis; |
2 |
26 Feb 07 |
jari |
141 |
this.zAxis = zAxis; |
2 |
26 Feb 07 |
jari |
142 |
this.U = U; |
2 |
26 Feb 07 |
jari |
143 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
144 |
initScales(U); |
2 |
26 Feb 07 |
jari |
145 |
setLayout(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
146 |
setPreferredSize(new Dimension(10, 10)); |
2 |
26 Feb 07 |
jari |
147 |
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); |
2 |
26 Feb 07 |
jari |
148 |
this.onScreenCanvas = new Canvas3D(config); |
2 |
26 Feb 07 |
jari |
149 |
this.universe = new SimpleUniverse(onScreenCanvas); |
2 |
26 Feb 07 |
jari |
150 |
universe.getViewingPlatform().setNominalViewingTransform(); |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
boxSizeX = (float)(scaleAxisX/5f); |
2 |
26 Feb 07 |
jari |
153 |
boxSizeY = (float)(scaleAxisY/5f); |
2 |
26 Feb 07 |
jari |
154 |
boxSizeZ = (float)(scaleAxisZ/5f); |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
offScreenCanvas = new Canvas3D(config, true); |
2 |
26 Feb 07 |
jari |
157 |
Screen3D sOn = onScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
158 |
Screen3D sOff = offScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
159 |
sOff.setSize(sOn.getSize()); |
2 |
26 Feb 07 |
jari |
160 |
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth()); |
2 |
26 Feb 07 |
jari |
161 |
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight()); |
2 |
26 Feb 07 |
jari |
// attach the offscreen canvas to the view |
2 |
26 Feb 07 |
jari |
163 |
universe.getViewer().getView().addCanvas3D(offScreenCanvas); |
2 |
26 Feb 07 |
jari |
164 |
|
2 |
26 Feb 07 |
jari |
165 |
add(onScreenCanvas, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
166 |
} |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
168 |
/* |
2 |
26 Feb 07 |
jari |
public COAContent3D(FloatMatrix geneUMatrix, FloatMatrix exptUMatrix, Experiment experiment, int geneOrExpt) { |
2 |
26 Feb 07 |
jari |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
this.geneUMatrix = geneUMatrix; |
2 |
26 Feb 07 |
jari |
this.exptUMatrix = exptUMatrix; |
2 |
26 Feb 07 |
jari |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
scaleMatrices(geneUMatrix, exptUMatrix); |
2 |
26 Feb 07 |
jari |
combineMatrices(scaledGeneUMatrix, scaledExptUMatrix); |
2 |
26 Feb 07 |
jari |
initScales(scaledGeneUMatrix, scaledExptUMatrix); |
2 |
26 Feb 07 |
jari |
setLayout(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
setPreferredSize(new Dimension(10, 10)); |
2 |
26 Feb 07 |
jari |
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); |
2 |
26 Feb 07 |
jari |
this.onScreenCanvas = new Canvas3D(config); |
2 |
26 Feb 07 |
jari |
this.universe = new SimpleUniverse(onScreenCanvas); |
2 |
26 Feb 07 |
jari |
universe.getViewingPlatform().setNominalViewingTransform(); |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
offScreenCanvas = new Canvas3D(config, true); |
2 |
26 Feb 07 |
jari |
Screen3D sOn = onScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
Screen3D sOff = offScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
sOff.setSize(sOn.getSize()); |
2 |
26 Feb 07 |
jari |
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth()); |
2 |
26 Feb 07 |
jari |
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight()); |
2 |
26 Feb 07 |
jari |
// attach the offscreen canvas to the view |
2 |
26 Feb 07 |
jari |
universe.getViewer().getView().addCanvas3D(offScreenCanvas); |
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
add(onScreenCanvas, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
194 |
} |
2 |
26 Feb 07 |
jari |
195 |
*/ |
2 |
26 Feb 07 |
jari |
196 |
|
2 |
26 Feb 07 |
jari |
197 |
public COAContent3D(FloatMatrix geneUMatrix, FloatMatrix exptUMatrix, Experiment experiment, int geneOrExpt) { |
2 |
26 Feb 07 |
jari |
198 |
this.geneUMatrix = geneUMatrix; |
2 |
26 Feb 07 |
jari |
199 |
this.exptUMatrix = exptUMatrix; |
2 |
26 Feb 07 |
jari |
//scaleMatrices(geneUMatrix, exptUMatrix); |
2 |
26 Feb 07 |
jari |
201 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
202 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
203 |
this.U = combineMatrices(scaledGeneUMatrix, scaledExptUMatrix); |
2 |
26 Feb 07 |
jari |
204 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
//this.U = U; |
2 |
26 Feb 07 |
jari |
206 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
207 |
initScales(U); |
2 |
26 Feb 07 |
jari |
208 |
setLayout(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
209 |
setPreferredSize(new Dimension(10, 10)); |
2 |
26 Feb 07 |
jari |
210 |
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); |
2 |
26 Feb 07 |
jari |
211 |
this.onScreenCanvas = new Canvas3D(config); |
2 |
26 Feb 07 |
jari |
212 |
this.universe = new SimpleUniverse(onScreenCanvas); |
2 |
26 Feb 07 |
jari |
213 |
universe.getViewingPlatform().setNominalViewingTransform(); |
2 |
26 Feb 07 |
jari |
214 |
|
2 |
26 Feb 07 |
jari |
215 |
boxSizeX = (float)(scaleAxisX/5f); |
2 |
26 Feb 07 |
jari |
216 |
boxSizeY = (float)(scaleAxisY/5f); |
2 |
26 Feb 07 |
jari |
217 |
boxSizeZ = (float)(scaleAxisZ/5f); |
2 |
26 Feb 07 |
jari |
218 |
|
2 |
26 Feb 07 |
jari |
219 |
offScreenCanvas = new Canvas3D(config, true); |
2 |
26 Feb 07 |
jari |
220 |
Screen3D sOn = onScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
221 |
Screen3D sOff = offScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
222 |
sOff.setSize(sOn.getSize()); |
2 |
26 Feb 07 |
jari |
223 |
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth()); |
2 |
26 Feb 07 |
jari |
224 |
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight()); |
2 |
26 Feb 07 |
jari |
// attach the offscreen canvas to the view |
2 |
26 Feb 07 |
jari |
226 |
universe.getViewer().getView().addCanvas3D(offScreenCanvas); |
2 |
26 Feb 07 |
jari |
227 |
|
2 |
26 Feb 07 |
jari |
228 |
add(onScreenCanvas, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
229 |
} |
2 |
26 Feb 07 |
jari |
230 |
|
2 |
26 Feb 07 |
jari |
231 |
public COAContent3D(FloatMatrix geneUMatrix, FloatMatrix exptUMatrix, Experiment experiment, int geneOrExpt, int xAxis, int yAxis, int zAxis) { |
2 |
26 Feb 07 |
jari |
232 |
this.geneUMatrix = geneUMatrix; |
2 |
26 Feb 07 |
jari |
233 |
this.exptUMatrix = exptUMatrix; |
2 |
26 Feb 07 |
jari |
//scaleMatrices(geneUMatrix, exptUMatrix); |
2 |
26 Feb 07 |
jari |
235 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
236 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
237 |
this.U = combineMatrices(scaledGeneUMatrix, scaledExptUMatrix); |
2 |
26 Feb 07 |
jari |
238 |
this.geneOrExpt = geneOrExpt; |
2 |
26 Feb 07 |
jari |
239 |
this.xAxis = xAxis; |
2 |
26 Feb 07 |
jari |
240 |
this.yAxis = yAxis; |
2 |
26 Feb 07 |
jari |
241 |
this.zAxis = zAxis; |
2 |
26 Feb 07 |
jari |
//this.U = U; |
2 |
26 Feb 07 |
jari |
243 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
244 |
initScales(U); |
2 |
26 Feb 07 |
jari |
245 |
setLayout(new BorderLayout()); |
2 |
26 Feb 07 |
jari |
246 |
setPreferredSize(new Dimension(10, 10)); |
2 |
26 Feb 07 |
jari |
247 |
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); |
2 |
26 Feb 07 |
jari |
248 |
this.onScreenCanvas = new Canvas3D(config); |
2 |
26 Feb 07 |
jari |
249 |
this.universe = new SimpleUniverse(onScreenCanvas); |
2 |
26 Feb 07 |
jari |
250 |
universe.getViewingPlatform().setNominalViewingTransform(); |
2 |
26 Feb 07 |
jari |
251 |
|
2 |
26 Feb 07 |
jari |
252 |
boxSizeX = (float)(scaleAxisX/5f); |
2 |
26 Feb 07 |
jari |
253 |
boxSizeY = (float)(scaleAxisY/5f); |
2 |
26 Feb 07 |
jari |
254 |
boxSizeZ = (float)(scaleAxisZ/5f); |
2 |
26 Feb 07 |
jari |
255 |
|
2 |
26 Feb 07 |
jari |
256 |
offScreenCanvas = new Canvas3D(config, true); |
2 |
26 Feb 07 |
jari |
257 |
Screen3D sOn = onScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
258 |
Screen3D sOff = offScreenCanvas.getScreen3D(); |
2 |
26 Feb 07 |
jari |
259 |
sOff.setSize(sOn.getSize()); |
2 |
26 Feb 07 |
jari |
260 |
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth()); |
2 |
26 Feb 07 |
jari |
261 |
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight()); |
2 |
26 Feb 07 |
jari |
// attach the offscreen canvas to the view |
2 |
26 Feb 07 |
jari |
263 |
universe.getViewer().getView().addCanvas3D(offScreenCanvas); |
2 |
26 Feb 07 |
jari |
264 |
|
2 |
26 Feb 07 |
jari |
265 |
add(onScreenCanvas, BorderLayout.CENTER); |
2 |
26 Feb 07 |
jari |
266 |
} |
2 |
26 Feb 07 |
jari |
267 |
|
2 |
26 Feb 07 |
jari |
268 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the content data. |
2 |
26 Feb 07 |
jari |
270 |
*/ |
2 |
26 Feb 07 |
jari |
271 |
public void setData(IData data) { |
2 |
26 Feb 07 |
jari |
272 |
this.data = data; |
2 |
26 Feb 07 |
jari |
273 |
} |
2 |
26 Feb 07 |
jari |
274 |
|
2 |
26 Feb 07 |
jari |
275 |
/** |
2 |
26 Feb 07 |
jari |
* Returns x coordinate of the selection box. |
2 |
26 Feb 07 |
jari |
277 |
*/ |
2 |
26 Feb 07 |
jari |
278 |
public float getPositionX() { |
2 |
26 Feb 07 |
jari |
279 |
return boxPositionX; |
2 |
26 Feb 07 |
jari |
280 |
} |
2 |
26 Feb 07 |
jari |
281 |
|
2 |
26 Feb 07 |
jari |
282 |
/** |
2 |
26 Feb 07 |
jari |
* Returns y coordinate of the selection box. |
2 |
26 Feb 07 |
jari |
284 |
*/ |
2 |
26 Feb 07 |
jari |
285 |
public float getPositionY() { |
2 |
26 Feb 07 |
jari |
286 |
return boxPositionY; |
2 |
26 Feb 07 |
jari |
287 |
} |
2 |
26 Feb 07 |
jari |
288 |
|
2 |
26 Feb 07 |
jari |
289 |
/** |
2 |
26 Feb 07 |
jari |
* Returns z coordinate of the selection box. |
2 |
26 Feb 07 |
jari |
291 |
*/ |
2 |
26 Feb 07 |
jari |
292 |
public float getPositionZ() { |
2 |
26 Feb 07 |
jari |
293 |
return boxPositionZ; |
2 |
26 Feb 07 |
jari |
294 |
} |
2 |
26 Feb 07 |
jari |
295 |
|
2 |
26 Feb 07 |
jari |
296 |
public void setGeneLabelIndex(int index){ |
2 |
26 Feb 07 |
jari |
297 |
geneLabelIndex = index; |
2 |
26 Feb 07 |
jari |
298 |
} |
2 |
26 Feb 07 |
jari |
299 |
|
2 |
26 Feb 07 |
jari |
300 |
/** |
2 |
26 Feb 07 |
jari |
* Returns x size of the selection box. |
2 |
26 Feb 07 |
jari |
302 |
*/ |
2 |
26 Feb 07 |
jari |
303 |
public float getSizeX() { |
2 |
26 Feb 07 |
jari |
304 |
return boxSizeX; |
2 |
26 Feb 07 |
jari |
305 |
} |
2 |
26 Feb 07 |
jari |
306 |
|
2 |
26 Feb 07 |
jari |
307 |
/** |
2 |
26 Feb 07 |
jari |
* Returns y size of the selection box. |
2 |
26 Feb 07 |
jari |
309 |
*/ |
2 |
26 Feb 07 |
jari |
310 |
public float getSizeY() { |
2 |
26 Feb 07 |
jari |
311 |
return boxSizeY; |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
|
2 |
26 Feb 07 |
jari |
314 |
/** |
2 |
26 Feb 07 |
jari |
* Returns z size of the selection box. |
2 |
26 Feb 07 |
jari |
316 |
*/ |
2 |
26 Feb 07 |
jari |
317 |
public float getSizeZ() { |
2 |
26 Feb 07 |
jari |
318 |
return boxSizeZ; |
2 |
26 Feb 07 |
jari |
319 |
} |
2 |
26 Feb 07 |
jari |
320 |
|
2 |
26 Feb 07 |
jari |
321 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the selection box position. |
2 |
26 Feb 07 |
jari |
323 |
*/ |
2 |
26 Feb 07 |
jari |
324 |
public void setBoxPosition(float dimX, float dimY, float dimZ) { |
2 |
26 Feb 07 |
jari |
325 |
boxPositionX = dimX; |
2 |
26 Feb 07 |
jari |
326 |
boxPositionY = dimY; |
2 |
26 Feb 07 |
jari |
327 |
boxPositionZ = dimZ; |
2 |
26 Feb 07 |
jari |
328 |
} |
2 |
26 Feb 07 |
jari |
329 |
|
2 |
26 Feb 07 |
jari |
330 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the selection box size. |
2 |
26 Feb 07 |
jari |
332 |
*/ |
2 |
26 Feb 07 |
jari |
333 |
public void setBoxSize(float dimX, float dimY, float dimZ) { |
2 |
26 Feb 07 |
jari |
334 |
boxSizeX = dimX; |
2 |
26 Feb 07 |
jari |
335 |
boxSizeY = dimY; |
2 |
26 Feb 07 |
jari |
336 |
boxSizeZ = dimZ; |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
|
2 |
26 Feb 07 |
jari |
339 |
/** |
2 |
26 Feb 07 |
jari |
* Returns size of a selected point. |
2 |
26 Feb 07 |
jari |
341 |
*/ |
2 |
26 Feb 07 |
jari |
342 |
public float getSelectedPointSize() { |
2 |
26 Feb 07 |
jari |
343 |
return selectedPointSize; |
2 |
26 Feb 07 |
jari |
344 |
} |
2 |
26 Feb 07 |
jari |
345 |
|
2 |
26 Feb 07 |
jari |
346 |
/** |
2 |
26 Feb 07 |
jari |
* Sets size of a selected point. |
2 |
26 Feb 07 |
jari |
348 |
*/ |
2 |
26 Feb 07 |
jari |
349 |
public void setSelectedPointSize(float size) { |
2 |
26 Feb 07 |
jari |
350 |
selectedPointSize = size; |
2 |
26 Feb 07 |
jari |
351 |
} |
2 |
26 Feb 07 |
jari |
352 |
|
2 |
26 Feb 07 |
jari |
353 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a point size. |
2 |
26 Feb 07 |
jari |
355 |
*/ |
2 |
26 Feb 07 |
jari |
356 |
public float getPointSize() { |
2 |
26 Feb 07 |
jari |
357 |
return pointSize; |
2 |
26 Feb 07 |
jari |
358 |
} |
2 |
26 Feb 07 |
jari |
359 |
|
2 |
26 Feb 07 |
jari |
360 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a specified point size. |
2 |
26 Feb 07 |
jari |
362 |
*/ |
2 |
26 Feb 07 |
jari |
363 |
private float getPointSize(boolean selected) { |
2 |
26 Feb 07 |
jari |
364 |
return selected ? getSelectedPointSize() : getPointSize(); |
2 |
26 Feb 07 |
jari |
365 |
} |
2 |
26 Feb 07 |
jari |
366 |
|
2 |
26 Feb 07 |
jari |
367 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a point size. |
2 |
26 Feb 07 |
jari |
369 |
*/ |
2 |
26 Feb 07 |
jari |
370 |
public void setPointSize(float size) { |
2 |
26 Feb 07 |
jari |
371 |
pointSize = size; |
2 |
26 Feb 07 |
jari |
372 |
} |
2 |
26 Feb 07 |
jari |
373 |
|
2 |
26 Feb 07 |
jari |
374 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a scale of the x axis. |
2 |
26 Feb 07 |
jari |
376 |
*/ |
2 |
26 Feb 07 |
jari |
377 |
public float getScaleAxisX() { |
2 |
26 Feb 07 |
jari |
378 |
return scaleAxisX; |
2 |
26 Feb 07 |
jari |
379 |
} |
2 |
26 Feb 07 |
jari |
380 |
|
2 |
26 Feb 07 |
jari |
381 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a scale of the y axis. |
2 |
26 Feb 07 |
jari |
383 |
*/ |
2 |
26 Feb 07 |
jari |
384 |
public float getScaleAxisY() { |
2 |
26 Feb 07 |
jari |
385 |
return scaleAxisY; |
2 |
26 Feb 07 |
jari |
386 |
} |
2 |
26 Feb 07 |
jari |
387 |
|
2 |
26 Feb 07 |
jari |
388 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a scale of the z axis. |
2 |
26 Feb 07 |
jari |
390 |
*/ |
2 |
26 Feb 07 |
jari |
391 |
public float getScaleAxisZ() { |
2 |
26 Feb 07 |
jari |
392 |
return scaleAxisZ; |
2 |
26 Feb 07 |
jari |
393 |
} |
2 |
26 Feb 07 |
jari |
394 |
|
2 |
26 Feb 07 |
jari |
395 |
/** |
2 |
26 Feb 07 |
jari |
* Sets scales. |
2 |
26 Feb 07 |
jari |
397 |
*/ |
2 |
26 Feb 07 |
jari |
398 |
public void setScale(float dimX, float dimY, float dimZ) { |
2 |
26 Feb 07 |
jari |
399 |
scaleAxisX = dimX; |
2 |
26 Feb 07 |
jari |
400 |
scaleAxisY = dimY; |
2 |
26 Feb 07 |
jari |
401 |
scaleAxisZ = dimZ; |
2 |
26 Feb 07 |
jari |
402 |
} |
2 |
26 Feb 07 |
jari |
403 |
|
2 |
26 Feb 07 |
jari |
404 |
public float getMaxValue() { |
2 |
26 Feb 07 |
jari |
405 |
return Math.max(scaleAxisX, Math.max(scaleAxisY, scaleAxisZ)); |
2 |
26 Feb 07 |
jari |
406 |
} |
2 |
26 Feb 07 |
jari |
407 |
|
2 |
26 Feb 07 |
jari |
408 |
/** |
2 |
26 Feb 07 |
jari |
* Sets white background attribute. |
2 |
26 Feb 07 |
jari |
410 |
*/ |
2 |
26 Feb 07 |
jari |
411 |
public void setWhiteBackround(boolean value) { |
2 |
26 Feb 07 |
jari |
412 |
whiteBackground = value; |
2 |
26 Feb 07 |
jari |
413 |
} |
2 |
26 Feb 07 |
jari |
414 |
|
2 |
26 Feb 07 |
jari |
415 |
/** |
2 |
26 Feb 07 |
jari |
* @return true, if background is white. |
2 |
26 Feb 07 |
jari |
417 |
*/ |
2 |
26 Feb 07 |
jari |
418 |
public boolean isWhiteBackground() { |
2 |
26 Feb 07 |
jari |
419 |
return whiteBackground; |
2 |
26 Feb 07 |
jari |
420 |
} |
2 |
26 Feb 07 |
jari |
421 |
|
2 |
26 Feb 07 |
jari |
422 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the selection attribute. |
2 |
26 Feb 07 |
jari |
424 |
*/ |
2 |
26 Feb 07 |
jari |
425 |
public void setSelection(boolean value) { |
2 |
26 Feb 07 |
jari |
426 |
selection = value; |
2 |
26 Feb 07 |
jari |
427 |
} |
2 |
26 Feb 07 |
jari |
428 |
|
2 |
26 Feb 07 |
jari |
429 |
/** |
2 |
26 Feb 07 |
jari |
* Returns value of the selection attribute. |
2 |
26 Feb 07 |
jari |
431 |
*/ |
2 |
26 Feb 07 |
jari |
432 |
public boolean isSelection() { |
2 |
26 Feb 07 |
jari |
433 |
return selection; |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
435 |
|
2 |
26 Feb 07 |
jari |
436 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the selection box attribute. |
2 |
26 Feb 07 |
jari |
438 |
*/ |
2 |
26 Feb 07 |
jari |
439 |
public void setSelectionBox(boolean value) { |
2 |
26 Feb 07 |
jari |
440 |
selectionBox = value; |
2 |
26 Feb 07 |
jari |
441 |
} |
2 |
26 Feb 07 |
jari |
442 |
|
2 |
26 Feb 07 |
jari |
443 |
/** |
2 |
26 Feb 07 |
jari |
* Returns value of the selection box attribute. |
2 |
26 Feb 07 |
jari |
445 |
*/ |
2 |
26 Feb 07 |
jari |
446 |
public boolean isSelectionBox() { |
2 |
26 Feb 07 |
jari |
447 |
return selectionBox; |
2 |
26 Feb 07 |
jari |
448 |
} |
2 |
26 Feb 07 |
jari |
449 |
|
2 |
26 Feb 07 |
jari |
450 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the show spheres attribute. |
2 |
26 Feb 07 |
jari |
452 |
*/ |
2 |
26 Feb 07 |
jari |
453 |
public void setShowSpheres(boolean value) { |
2 |
26 Feb 07 |
jari |
454 |
showSpheres = value; |
2 |
26 Feb 07 |
jari |
455 |
} |
2 |
26 Feb 07 |
jari |
456 |
|
2 |
26 Feb 07 |
jari |
457 |
/** |
2 |
26 Feb 07 |
jari |
* Returns value of the show spheres attribute. |
2 |
26 Feb 07 |
jari |
459 |
*/ |
2 |
26 Feb 07 |
jari |
460 |
public boolean isShowSpheres() { |
2 |
26 Feb 07 |
jari |
461 |
return showSpheres; |
2 |
26 Feb 07 |
jari |
462 |
} |
2 |
26 Feb 07 |
jari |
463 |
|
2 |
26 Feb 07 |
jari |
464 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the show text attribute. |
2 |
26 Feb 07 |
jari |
466 |
*/ |
2 |
26 Feb 07 |
jari |
467 |
public void setShowText(boolean value) { |
2 |
26 Feb 07 |
jari |
468 |
showText = value; |
2 |
26 Feb 07 |
jari |
469 |
} |
2 |
26 Feb 07 |
jari |
470 |
|
2 |
26 Feb 07 |
jari |
471 |
public void setShowGeneTextFromBoth(boolean value) { |
2 |
26 Feb 07 |
jari |
472 |
showGeneTextFromBoth = value; |
2 |
26 Feb 07 |
jari |
473 |
} |
2 |
26 Feb 07 |
jari |
474 |
|
2 |
26 Feb 07 |
jari |
475 |
public void setShowExptTextFromBoth(boolean value) { |
2 |
26 Feb 07 |
jari |
476 |
showExptTextFromBoth = value; |
2 |
26 Feb 07 |
jari |
477 |
} |
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
479 |
/** |
2 |
26 Feb 07 |
jari |
* Returns value of the show text attribute. |
2 |
26 Feb 07 |
jari |
481 |
*/ |
2 |
26 Feb 07 |
jari |
482 |
public boolean isShowText() { |
2 |
26 Feb 07 |
jari |
483 |
return showText; |
2 |
26 Feb 07 |
jari |
484 |
} |
2 |
26 Feb 07 |
jari |
485 |
|
2 |
26 Feb 07 |
jari |
486 |
public boolean isShowGeneTextFromBoth() { |
2 |
26 Feb 07 |
jari |
487 |
return showGeneTextFromBoth; |
2 |
26 Feb 07 |
jari |
488 |
} |
2 |
26 Feb 07 |
jari |
489 |
|
2 |
26 Feb 07 |
jari |
490 |
public boolean isShowExptTextFromBoth() { |
2 |
26 Feb 07 |
jari |
491 |
return showExptTextFromBoth; |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
|
2 |
26 Feb 07 |
jari |
494 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the content image. |
2 |
26 Feb 07 |
jari |
496 |
*/ |
2 |
26 Feb 07 |
jari |
497 |
public BufferedImage createImage() { |
2 |
26 Feb 07 |
jari |
// ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGB, (BufferedImage)this.createImage(onScreenCanvas.getWidth(), onScreenCanvas.getHeight())); |
2 |
26 Feb 07 |
jari |
499 |
ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGB, (BufferedImage)java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(onScreenCanvas.getWidth(), onScreenCanvas.getHeight())); |
2 |
26 Feb 07 |
jari |
500 |
offScreenCanvas.setOffScreenLocation(onScreenCanvas.getLocationOnScreen()); |
2 |
26 Feb 07 |
jari |
501 |
offScreenCanvas.setOffScreenBuffer(buffer); |
2 |
26 Feb 07 |
jari |
502 |
offScreenCanvas.renderOffScreenBuffer(); |
2 |
26 Feb 07 |
jari |
503 |
offScreenCanvas.waitForOffScreenRendering(); |
2 |
26 Feb 07 |
jari |
504 |
BufferedImage offImage = offScreenCanvas.getOffScreenBuffer().getImage(); |
2 |
26 Feb 07 |
jari |
505 |
BufferedImage image = new BufferedImage(offImage.getWidth(), offImage.getHeight(), BufferedImage.TYPE_3BYTE_BGR); |
2 |
26 Feb 07 |
jari |
//BufferedImage image = (BufferedImage)this.createImage(offImage.getWidth(), offImage.getHeight()); |
2 |
26 Feb 07 |
jari |
//BufferedImage image = (BufferedImage)java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(offImage.getWidth(), offImage.getHeight()); |
2 |
26 Feb 07 |
jari |
508 |
image.setData(offImage.getData()); |
2 |
26 Feb 07 |
jari |
509 |
return image; |
2 |
26 Feb 07 |
jari |
510 |
} |
2 |
26 Feb 07 |
jari |
511 |
|
2 |
26 Feb 07 |
jari |
512 |
/** |
2 |
26 Feb 07 |
jari |
* Resets spin coordinaties. |
2 |
26 Feb 07 |
jari |
514 |
*/ |
2 |
26 Feb 07 |
jari |
515 |
public void reset() { |
2 |
26 Feb 07 |
jari |
516 |
spinGroup.setTransform(new Transform3D()); |
2 |
26 Feb 07 |
jari |
517 |
} |
2 |
26 Feb 07 |
jari |
518 |
|
2 |
26 Feb 07 |
jari |
519 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the universe scene. |
2 |
26 Feb 07 |
jari |
521 |
*/ |
2 |
26 Feb 07 |
jari |
522 |
protected void updateScene() { |
2 |
26 Feb 07 |
jari |
523 |
Transform3D spinTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
524 |
if (scene != null) { |
2 |
26 Feb 07 |
jari |
525 |
spinGroup.getTransform(spinTransform); |
2 |
26 Feb 07 |
jari |
526 |
scene.detach(); |
2 |
26 Feb 07 |
jari |
527 |
} |
2 |
26 Feb 07 |
jari |
528 |
this.scene = createSceneGraph(onScreenCanvas, spinTransform); |
2 |
26 Feb 07 |
jari |
529 |
universe.addBranchGraph(scene); |
2 |
26 Feb 07 |
jari |
530 |
} |
2 |
26 Feb 07 |
jari |
531 |
|
2 |
26 Feb 07 |
jari |
532 |
/** |
2 |
26 Feb 07 |
jari |
* Sets scales according to U-matrix values. |
2 |
26 Feb 07 |
jari |
534 |
*/ |
2 |
26 Feb 07 |
jari |
535 |
private void initScales(FloatMatrix U) { |
2 |
26 Feb 07 |
jari |
536 |
float max = 0f; |
2 |
26 Feb 07 |
jari |
537 |
final int rows = U.getRowDimension(); |
2 |
26 Feb 07 |
jari |
538 |
for (int i = rows; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
//max = Math.max(max, Math.max(Math.max(Math.abs(U.get(i, 0)), Math.abs(U.get(i, 1))), Math.abs(U.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
540 |
max = Math.max(max, Math.max(Math.max(Math.abs(U.get(i, xAxis)), Math.abs(U.get(i, yAxis))), Math.abs(U.get(i, zAxis)))); |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
setScale(max, max, max); |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
private FloatMatrix combineMatrices(FloatMatrix U1, FloatMatrix U2) { |
2 |
26 Feb 07 |
jari |
546 |
FloatMatrix combinedMatrix = new FloatMatrix(U1.getRowDimension() + U2.getRowDimension(), U1.getColumnDimension()); |
2 |
26 Feb 07 |
jari |
547 |
|
2 |
26 Feb 07 |
jari |
548 |
for (int i = 0; i < U1.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
549 |
for (int j = 0; j < U1.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
550 |
combinedMatrix.A[i][j] =U1.A[i][j]; |
2 |
26 Feb 07 |
jari |
551 |
} |
2 |
26 Feb 07 |
jari |
552 |
} |
2 |
26 Feb 07 |
jari |
553 |
int counter = U1.getRowDimension(); |
2 |
26 Feb 07 |
jari |
554 |
for (int i = 0; i < U2.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
555 |
for (int j = 0; j < U2.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
556 |
combinedMatrix.A[counter + i][j] = U2.A[i][j]; |
2 |
26 Feb 07 |
jari |
557 |
} |
2 |
26 Feb 07 |
jari |
558 |
} |
2 |
26 Feb 07 |
jari |
559 |
return combinedMatrix; |
2 |
26 Feb 07 |
jari |
560 |
} |
2 |
26 Feb 07 |
jari |
561 |
|
2 |
26 Feb 07 |
jari |
562 |
private void scaleMatrices(FloatMatrix U1, FloatMatrix U2) { //brings them both to the same scale for plotting |
2 |
26 Feb 07 |
jari |
563 |
float max1 = 0f; |
2 |
26 Feb 07 |
jari |
564 |
float max2 = 0f; |
2 |
26 Feb 07 |
jari |
565 |
final int rows1 = U1.getRowDimension(); |
2 |
26 Feb 07 |
jari |
566 |
final int rows2 = U2.getRowDimension(); |
2 |
26 Feb 07 |
jari |
567 |
for (int i = rows1; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
//max1 = Math.max(max1, Math.max(Math.max(Math.abs(U1.get(i, 0)), Math.abs(U1.get(i, 1))), Math.abs(U1.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
569 |
max1 = Math.max(max1, Math.max(Math.max(Math.abs(U1.get(i, xAxis)), Math.abs(U1.get(i, yAxis))), Math.abs(U1.get(i, zAxis)))); |
2 |
26 Feb 07 |
jari |
570 |
} |
2 |
26 Feb 07 |
jari |
571 |
for (int i = rows2; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
//max2 = Math.max(max2, Math.max(Math.max(Math.abs(U2.get(i, 0)), Math.abs(U2.get(i, 1))), Math.abs(U2.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
573 |
max1 = Math.max(max1, Math.max(Math.max(Math.abs(U1.get(i, xAxis)), Math.abs(U1.get(i, yAxis))), Math.abs(U1.get(i, zAxis)))); |
2 |
26 Feb 07 |
jari |
574 |
} |
2 |
26 Feb 07 |
jari |
575 |
|
2 |
26 Feb 07 |
jari |
576 |
float max = Math.max(max1, max2); |
2 |
26 Feb 07 |
jari |
577 |
|
2 |
26 Feb 07 |
jari |
578 |
if (max1 == max2) { |
2 |
26 Feb 07 |
jari |
579 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
580 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
581 |
} else if (max1 > max2) { |
2 |
26 Feb 07 |
jari |
582 |
scaledGeneUMatrix = (FloatMatrix)(geneUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
583 |
float scalingFactor = (float)(max1/max2); |
2 |
26 Feb 07 |
jari |
584 |
scaledExptUMatrix = exptUMatrix.times(scalingFactor); |
2 |
26 Feb 07 |
jari |
585 |
} else { |
2 |
26 Feb 07 |
jari |
586 |
scaledExptUMatrix = (FloatMatrix)(exptUMatrix.clone()); |
2 |
26 Feb 07 |
jari |
587 |
float scalingFactor = (float)(max2/max1); |
2 |
26 Feb 07 |
jari |
588 |
scaledGeneUMatrix = geneUMatrix.times(scalingFactor); |
2 |
26 Feb 07 |
jari |
589 |
} |
2 |
26 Feb 07 |
jari |
590 |
} |
2 |
26 Feb 07 |
jari |
591 |
|
2 |
26 Feb 07 |
jari |
592 |
private void initScales(FloatMatrix U1, FloatMatrix U2) { |
2 |
26 Feb 07 |
jari |
593 |
float max1 = 0f; |
2 |
26 Feb 07 |
jari |
594 |
float max2 = 0f; |
2 |
26 Feb 07 |
jari |
595 |
final int rows1 = U1.getRowDimension(); |
2 |
26 Feb 07 |
jari |
596 |
final int rows2 = U2.getRowDimension(); |
2 |
26 Feb 07 |
jari |
597 |
for (int i = rows1; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
//max1 = Math.max(max1, Math.max(Math.max(Math.abs(U1.get(i, 0)), Math.abs(U1.get(i, 1))), Math.abs(U1.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
599 |
max1 = Math.max(max1, Math.max(Math.max(Math.abs(U1.get(i, xAxis)), Math.abs(U1.get(i, yAxis))), Math.abs(U1.get(i, zAxis)))); |
2 |
26 Feb 07 |
jari |
600 |
} |
2 |
26 Feb 07 |
jari |
601 |
for (int i = rows2; --i >= 0;) { |
2 |
26 Feb 07 |
jari |
//max2 = Math.max(max2, Math.max(Math.max(Math.abs(U2.get(i, 0)), Math.abs(U2.get(i, 1))), Math.abs(U2.get(i, 2)))); |
2 |
26 Feb 07 |
jari |
603 |
max2 = Math.max(max2, Math.max(Math.max(Math.abs(U2.get(i, xAxis)), Math.abs(U2.get(i, yAxis))), Math.abs(U2.get(i, zAxis)))); |
2 |
26 Feb 07 |
jari |
604 |
} |
2 |
26 Feb 07 |
jari |
605 |
|
2 |
26 Feb 07 |
jari |
606 |
float max = Math.max(max1, max2); |
2 |
26 Feb 07 |
jari |
607 |
setScale(max, max, max); |
2 |
26 Feb 07 |
jari |
608 |
} |
2 |
26 Feb 07 |
jari |
609 |
|
2 |
26 Feb 07 |
jari |
610 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a branch group with specified canvas. |
2 |
26 Feb 07 |
jari |
612 |
*/ |
2 |
26 Feb 07 |
jari |
613 |
private BranchGroup createSceneGraph(Canvas3D canvas) { |
2 |
26 Feb 07 |
jari |
614 |
return createSceneGraph(canvas, null); |
2 |
26 Feb 07 |
jari |
615 |
} |
2 |
26 Feb 07 |
jari |
616 |
|
2 |
26 Feb 07 |
jari |
617 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a branch group with specified canvas and transformation object. |
2 |
26 Feb 07 |
jari |
619 |
*/ |
2 |
26 Feb 07 |
jari |
620 |
private BranchGroup createSceneGraph(Canvas3D canvas, Transform3D spinTransform) { |
2 |
26 Feb 07 |
jari |
621 |
BranchGroup objRoot = new BranchGroup(); |
2 |
26 Feb 07 |
jari |
622 |
objRoot.setCapability(BranchGroup.ALLOW_DETACH); |
2 |
26 Feb 07 |
jari |
623 |
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); |
2 |
26 Feb 07 |
jari |
624 |
|
2 |
26 Feb 07 |
jari |
625 |
this.spinGroup = createCoordinateSystem(bounds); |
2 |
26 Feb 07 |
jari |
626 |
if (spinTransform != null) { |
2 |
26 Feb 07 |
jari |
627 |
spinGroup.setTransform(spinTransform); |
2 |
26 Feb 07 |
jari |
628 |
} |
2 |
26 Feb 07 |
jari |
629 |
TransformGroup objScale = createScaleTransformGroup(bounds); |
2 |
26 Feb 07 |
jari |
630 |
objScale.addChild(spinGroup); |
2 |
26 Feb 07 |
jari |
631 |
objRoot.addChild(objScale); |
2 |
26 Feb 07 |
jari |
632 |
|
2 |
26 Feb 07 |
jari |
633 |
PickRotateBehavior rotateBehavior = new PickRotateBehavior(objRoot, canvas, bounds); |
2 |
26 Feb 07 |
jari |
634 |
objRoot.addChild(rotateBehavior); |
2 |
26 Feb 07 |
jari |
635 |
PickZoomBehavior zoomBehavior = new PickZoomBehavior(objRoot, canvas, bounds); |
2 |
26 Feb 07 |
jari |
636 |
objRoot.addChild(zoomBehavior); |
2 |
26 Feb 07 |
jari |
637 |
PickTranslateBehavior translateBehavior = new PickTranslateBehavior(objRoot, canvas, bounds); |
2 |
26 Feb 07 |
jari |
638 |
objRoot.addChild(translateBehavior); |
2 |
26 Feb 07 |
jari |
639 |
|
2 |
26 Feb 07 |
jari |
640 |
objRoot.compile(); |
2 |
26 Feb 07 |
jari |
641 |
return objRoot; |
2 |
26 Feb 07 |
jari |
642 |
} |
2 |
26 Feb 07 |
jari |
643 |
|
2 |
26 Feb 07 |
jari |
644 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a scale transform group. |
2 |
26 Feb 07 |
jari |
646 |
*/ |
2 |
26 Feb 07 |
jari |
647 |
private TransformGroup createScaleTransformGroup(BoundingSphere bounds) { |
2 |
26 Feb 07 |
jari |
648 |
Transform3D t = new Transform3D(); |
2 |
26 Feb 07 |
jari |
649 |
t.setScale(0.22); |
2 |
26 Feb 07 |
jari |
650 |
TransformGroup scale = new TransformGroup(t); |
2 |
26 Feb 07 |
jari |
651 |
|
2 |
26 Feb 07 |
jari |
652 |
Color3f bgColor = isWhiteBackground() ? whiteColor : blackColor; |
2 |
26 Feb 07 |
jari |
653 |
Background bg = new Background(bgColor); |
2 |
26 Feb 07 |
jari |
654 |
bg.setApplicationBounds(bounds); |
2 |
26 Feb 07 |
jari |
655 |
scale.addChild(bg); |
2 |
26 Feb 07 |
jari |
656 |
|
2 |
26 Feb 07 |
jari |
657 |
scale.addChild(createAmbientLight(bounds)); |
2 |
26 Feb 07 |
jari |
658 |
scale.addChild(createLight(bounds, new Vector3d(0.0, 0.0, 3.0))); |
2 |
26 Feb 07 |
jari |
659 |
scale.addChild(createLight(bounds, new Vector3d(0.0, 0.0, 10.0))); |
2 |
26 Feb 07 |
jari |
660 |
return scale; |
2 |
26 Feb 07 |
jari |
661 |
} |
2 |
26 Feb 07 |
jari |
662 |
|
2 |
26 Feb 07 |
jari |
663 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a coordinate system transform group. |
2 |
26 Feb 07 |
jari |
665 |
*/ |
2 |
26 Feb 07 |
jari |
666 |
private TransformGroup createCoordinateSystem(BoundingSphere bounds) { |
2 |
26 Feb 07 |
jari |
667 |
TransformGroup group = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
668 |
group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); |
2 |
26 Feb 07 |
jari |
669 |
group.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); |
2 |
26 Feb 07 |
jari |
670 |
group.setCapability(TransformGroup.ENABLE_PICK_REPORTING); |
2 |
26 Feb 07 |
jari |
// add axises |
2 |
26 Feb 07 |
jari |
672 |
group.addChild(createXAxis()); |
2 |
26 Feb 07 |
jari |
673 |
group.addChild(createYAxis()); |
2 |
26 Feb 07 |
jari |
674 |
group.addChild(createZAxis()); |
2 |
26 Feb 07 |
jari |
675 |
|
2 |
26 Feb 07 |
jari |
676 |
if (isShowSpheres()) { |
2 |
26 Feb 07 |
jari |
// add spheres |
2 |
26 Feb 07 |
jari |
678 |
group.addChild(createSpheres()); |
2 |
26 Feb 07 |
jari |
679 |
} else { |
2 |
26 Feb 07 |
jari |
// add selected and not selected points |
2 |
26 Feb 07 |
jari |
681 |
if (getPointSize() > 0) { |
2 |
26 Feb 07 |
jari |
682 |
Shape3D[] pointShapes = createUsualPoints(); |
2 |
26 Feb 07 |
jari |
683 |
if (pointShapes != null) { |
2 |
26 Feb 07 |
jari |
684 |
for (int i=0; i<pointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
685 |
group.addChild(pointShapes[i]); |
2 |
26 Feb 07 |
jari |
686 |
} |
2 |
26 Feb 07 |
jari |
687 |
} |
2 |
26 Feb 07 |
jari |
688 |
if ((geneOrExpt == COAGUI.GENES) || (geneOrExpt == COAGUI.EXPTS)) { |
2 |
26 Feb 07 |
jari |
689 |
Shape3D points = createSelectedPoints(); |
2 |
26 Feb 07 |
jari |
690 |
if (points != null) { |
2 |
26 Feb 07 |
jari |
691 |
group.addChild(points); |
2 |
26 Feb 07 |
jari |
692 |
} |
2 |
26 Feb 07 |
jari |
693 |
} else { |
2 |
26 Feb 07 |
jari |
694 |
Shape3D[] points = createSelectedPointsFromBoth(); |
2 |
26 Feb 07 |
jari |
695 |
if (points != null) { |
2 |
26 Feb 07 |
jari |
696 |
for (int i = 0; i < points.length; i++) { |
2 |
26 Feb 07 |
jari |
697 |
group.addChild(points[i]); |
2 |
26 Feb 07 |
jari |
698 |
} |
2 |
26 Feb 07 |
jari |
699 |
} |
2 |
26 Feb 07 |
jari |
700 |
} |
2 |
26 Feb 07 |
jari |
701 |
} |
2 |
26 Feb 07 |
jari |
702 |
} |
2 |
26 Feb 07 |
jari |
703 |
if (isSelectionBox()) { |
2 |
26 Feb 07 |
jari |
704 |
group.addChild(createSelectionBox()); |
2 |
26 Feb 07 |
jari |
705 |
} |
2 |
26 Feb 07 |
jari |
706 |
if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
707 |
if (isShowGeneTextFromBoth()) { |
2 |
26 Feb 07 |
jari |
708 |
group.addChild(createGeneTextFromBoth()); |
2 |
26 Feb 07 |
jari |
709 |
} |
2 |
26 Feb 07 |
jari |
710 |
if (isShowExptTextFromBoth()) { |
2 |
26 Feb 07 |
jari |
711 |
group.addChild(createSampleTextFromBoth()); |
2 |
26 Feb 07 |
jari |
712 |
} |
2 |
26 Feb 07 |
jari |
713 |
} else { |
2 |
26 Feb 07 |
jari |
714 |
if (isShowText()) { |
2 |
26 Feb 07 |
jari |
715 |
group.addChild(createText()); |
2 |
26 Feb 07 |
jari |
716 |
} |
2 |
26 Feb 07 |
jari |
717 |
} |
2 |
26 Feb 07 |
jari |
718 |
OpenBehavior openObject = new OpenBehavior(group); |
2 |
26 Feb 07 |
jari |
719 |
openObject.setSchedulingBounds(bounds); |
2 |
26 Feb 07 |
jari |
720 |
group.addChild(openObject); |
2 |
26 Feb 07 |
jari |
721 |
return group; |
2 |
26 Feb 07 |
jari |
722 |
} |
2 |
26 Feb 07 |
jari |
723 |
|
2 |
26 Feb 07 |
jari |
724 |
|
2 |
26 Feb 07 |
jari |
725 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a light transform group. |
2 |
26 Feb 07 |
jari |
727 |
*/ |
2 |
26 Feb 07 |
jari |
728 |
private TransformGroup createLight(BoundingSphere bounds, Vector3d vector) { |
2 |
26 Feb 07 |
jari |
729 |
Transform3D t = new Transform3D(); |
2 |
26 Feb 07 |
jari |
730 |
t.set(vector); |
2 |
26 Feb 07 |
jari |
731 |
TransformGroup lightGroup = new TransformGroup(t); |
2 |
26 Feb 07 |
jari |
732 |
lightGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); |
2 |
26 Feb 07 |
jari |
733 |
lightGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); |
2 |
26 Feb 07 |
jari |
734 |
lightGroup.setCapability(TransformGroup.ENABLE_PICK_REPORTING); |
2 |
26 Feb 07 |
jari |
735 |
|
2 |
26 Feb 07 |
jari |
736 |
ColoringAttributes attr = new ColoringAttributes(); |
2 |
26 Feb 07 |
jari |
737 |
Color3f color = new Color3f(1.0f, 1.0f, 1.0f); |
2 |
26 Feb 07 |
jari |
738 |
attr.setColor(color); |
2 |
26 Feb 07 |
jari |
739 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
740 |
appearance.setColoringAttributes(attr); |
2 |
26 Feb 07 |
jari |
741 |
lightGroup.addChild(new Sphere(0.01f, Sphere.GENERATE_NORMALS, 15, appearance)); |
2 |
26 Feb 07 |
jari |
742 |
Light light = new PointLight(color, new Point3f(0.0f, 0.0f, 0.0f), new Point3f(1.0f, 0.0f, 0.0f)); |
2 |
26 Feb 07 |
jari |
743 |
light.setInfluencingBounds(bounds); |
2 |
26 Feb 07 |
jari |
744 |
lightGroup.addChild(light); |
2 |
26 Feb 07 |
jari |
745 |
return lightGroup; |
2 |
26 Feb 07 |
jari |
746 |
} |
2 |
26 Feb 07 |
jari |
747 |
|
2 |
26 Feb 07 |
jari |
748 |
|
2 |
26 Feb 07 |
jari |
749 |
/** |
2 |
26 Feb 07 |
jari |
* Creates an ambient light. |
2 |
26 Feb 07 |
jari |
751 |
*/ |
2 |
26 Feb 07 |
jari |
752 |
private AmbientLight createAmbientLight(BoundingSphere bounds) { |
2 |
26 Feb 07 |
jari |
753 |
AmbientLight light = new AmbientLight(new Color3f(0.2f, 0.2f, 0.2f)); |
2 |
26 Feb 07 |
jari |
754 |
light.setInfluencingBounds(bounds); |
2 |
26 Feb 07 |
jari |
755 |
return light; |
2 |
26 Feb 07 |
jari |
756 |
} |
2 |
26 Feb 07 |
jari |
757 |
|
2 |
26 Feb 07 |
jari |
758 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a cone shape. |
2 |
26 Feb 07 |
jari |
760 |
*/ |
2 |
26 Feb 07 |
jari |
761 |
private Cone createCone() { |
2 |
26 Feb 07 |
jari |
762 |
return new Cone(0.05f, 0.2f); |
2 |
26 Feb 07 |
jari |
763 |
} |
2 |
26 Feb 07 |
jari |
764 |
|
2 |
26 Feb 07 |
jari |
765 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a cylinder shape with specified color. |
2 |
26 Feb 07 |
jari |
767 |
*/ |
2 |
26 Feb 07 |
jari |
768 |
private Cylinder createCylinder(Color3f color) { |
2 |
26 Feb 07 |
jari |
769 |
Material material = new Material(color, blackColor, color, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
770 |
if (isWhiteBackground()) { |
2 |
26 Feb 07 |
jari |
771 |
material.setEmissiveColor(new Color3f(0.0f, 0.0f, 1.0f)); |
2 |
26 Feb 07 |
jari |
772 |
} |
2 |
26 Feb 07 |
jari |
773 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
774 |
appearance.setLineAttributes(new LineAttributes(10, LineAttributes.PATTERN_SOLID, true)); |
2 |
26 Feb 07 |
jari |
775 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
776 |
return new Cylinder(0.025f, 6f, appearance); |
2 |
26 Feb 07 |
jari |
777 |
} |
2 |
26 Feb 07 |
jari |
778 |
|
2 |
26 Feb 07 |
jari |
779 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a selection box transform group. |
2 |
26 Feb 07 |
jari |
781 |
*/ |
2 |
26 Feb 07 |
jari |
782 |
private TransformGroup createSelectionBox() { |
2 |
26 Feb 07 |
jari |
783 |
Material material = new Material(new Color3f(0.5f, 0.5f, 0.5f), blackColor, new Color3f(0.5f, 0.5f, 0.5f), blackColor, 100.0f); |
2 |
26 Feb 07 |
jari |
784 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
785 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
786 |
TransparencyAttributes ta = new TransparencyAttributes(); |
2 |
26 Feb 07 |
jari |
787 |
ta.setTransparency(0.5f); |
2 |
26 Feb 07 |
jari |
788 |
ta.setTransparencyMode(TransparencyAttributes.BLENDED); |
2 |
26 Feb 07 |
jari |
789 |
appearance.setTransparencyAttributes(ta); |
2 |
26 Feb 07 |
jari |
790 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
791 |
Transform3D transform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
792 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
793 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
794 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
795 |
Vector3f vector = new Vector3f(boxPositionX*factorX, boxPositionY*factorY, boxPositionZ*factorZ); |
2 |
26 Feb 07 |
jari |
796 |
transform.set(vector); |
2 |
26 Feb 07 |
jari |
797 |
TransformGroup selectionBox = new TransformGroup(transform); |
2 |
26 Feb 07 |
jari |
798 |
selectionBox.addChild(new Box(boxSizeX*factorX/2f, boxSizeY*factorY/2f, boxSizeZ*factorZ/2f, appearance)); |
2 |
26 Feb 07 |
jari |
799 |
return selectionBox; |
2 |
26 Feb 07 |
jari |
800 |
} |
2 |
26 Feb 07 |
jari |
801 |
|
2 |
26 Feb 07 |
jari |
802 |
/** |
2 |
26 Feb 07 |
jari |
* Checkes if specified point is selected. |
2 |
26 Feb 07 |
jari |
804 |
*/ |
2 |
26 Feb 07 |
jari |
805 |
private boolean isPointSelected(float x, float y, float z) { |
2 |
26 Feb 07 |
jari |
806 |
float X1 = boxPositionX-boxSizeX/2f; |
2 |
26 Feb 07 |
jari |
807 |
float X2 = boxPositionX+boxSizeX/2f; |
2 |
26 Feb 07 |
jari |
808 |
float Y1 = boxPositionY-boxSizeY/2f; |
2 |
26 Feb 07 |
jari |
809 |
float Y2 = boxPositionY+boxSizeY/2f; |
2 |
26 Feb 07 |
jari |
810 |
float Z1 = boxPositionZ-boxSizeZ/2f; |
2 |
26 Feb 07 |
jari |
811 |
float Z2 = boxPositionZ+boxSizeZ/2f; |
2 |
26 Feb 07 |
jari |
812 |
return x>=X1 && x<=X2 && y>=Y1 && y<=Y2 && z>=Z1 && z<=Z2; |
2 |
26 Feb 07 |
jari |
813 |
} |
2 |
26 Feb 07 |
jari |
814 |
|
2 |
26 Feb 07 |
jari |
815 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an array of selected genes. |
2 |
26 Feb 07 |
jari |
817 |
*/ |
2 |
26 Feb 07 |
jari |
818 |
protected int[] getSelectedGenes() { |
2 |
26 Feb 07 |
jari |
819 |
int[] genes = new int[getPointsCount(true)]; |
2 |
26 Feb 07 |
jari |
820 |
int pos = 0; |
2 |
26 Feb 07 |
jari |
821 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//if (isPointSelected(U.get(i,0), U.get(i,1), U.get(i,2))) { |
2 |
26 Feb 07 |
jari |
823 |
if (isPointSelected(U.get(i,xAxis), U.get(i,yAxis), U.get(i,zAxis))) { |
2 |
26 Feb 07 |
jari |
824 |
if (geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
825 |
genes[pos] = experiment.getGeneIndexMappedToData(i); |
2 |
26 Feb 07 |
jari |
826 |
} else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
827 |
genes[pos] = experiment.getSampleIndex(i); |
2 |
26 Feb 07 |
jari |
828 |
} |
2 |
26 Feb 07 |
jari |
829 |
pos++; |
2 |
26 Feb 07 |
jari |
830 |
} |
2 |
26 Feb 07 |
jari |
831 |
} |
2 |
26 Feb 07 |
jari |
832 |
return genes; |
2 |
26 Feb 07 |
jari |
833 |
} |
2 |
26 Feb 07 |
jari |
834 |
|
2 |
26 Feb 07 |
jari |
835 |
protected int[] getSelectedGenesFromBoth() { |
2 |
26 Feb 07 |
jari |
836 |
Vector selectedPointsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
837 |
for (int i = 0; i < geneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//if (isPointSelected(U.get(i,0), U.get(i,1), U.get(i,2))) { |
2 |
26 Feb 07 |
jari |
839 |
if (isPointSelected(U.get(i,xAxis), U.get(i,yAxis), U.get(i,zAxis))) { |
2 |
26 Feb 07 |
jari |
840 |
selectedPointsVector.add(new Integer(experiment.getGeneIndexMappedToData(i))); |
2 |
26 Feb 07 |
jari |
841 |
} |
2 |
26 Feb 07 |
jari |
842 |
} |
2 |
26 Feb 07 |
jari |
843 |
|
2 |
26 Feb 07 |
jari |
844 |
int[] selPoints = new int[selectedPointsVector.size()]; |
2 |
26 Feb 07 |
jari |
845 |
for (int i = 0; i < selectedPointsVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
846 |
selPoints[i] = ((Integer)(selectedPointsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
847 |
} |
2 |
26 Feb 07 |
jari |
848 |
return selPoints; |
2 |
26 Feb 07 |
jari |
849 |
} |
2 |
26 Feb 07 |
jari |
850 |
|
2 |
26 Feb 07 |
jari |
851 |
protected int[] getSelectedExptsFromBoth() { |
2 |
26 Feb 07 |
jari |
852 |
Vector selectedPointsVector = new Vector(); |
2 |
26 Feb 07 |
jari |
853 |
for (int i = geneUMatrix.getRowDimension(); i < U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//if (isPointSelected(U.get(i,0), U.get(i,1), U.get(i,2))) { |
2 |
26 Feb 07 |
jari |
855 |
if (isPointSelected(U.get(i,xAxis), U.get(i,yAxis), U.get(i,zAxis))) { |
2 |
26 Feb 07 |
jari |
856 |
selectedPointsVector.add(new Integer(experiment.getSampleIndex(i - geneUMatrix.getRowDimension()))); |
2 |
26 Feb 07 |
jari |
857 |
} |
2 |
26 Feb 07 |
jari |
858 |
} |
2 |
26 Feb 07 |
jari |
859 |
|
2 |
26 Feb 07 |
jari |
860 |
int[] selPoints = new int[selectedPointsVector.size()]; |
2 |
26 Feb 07 |
jari |
861 |
for (int i = 0; i < selectedPointsVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
862 |
selPoints[i] = ((Integer)(selectedPointsVector.get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
863 |
} |
2 |
26 Feb 07 |
jari |
864 |
return selPoints; |
2 |
26 Feb 07 |
jari |
865 |
} |
2 |
26 Feb 07 |
jari |
866 |
|
2 |
26 Feb 07 |
jari |
867 |
/** |
2 |
26 Feb 07 |
jari |
* @param selected true if we need number of the selected points. |
2 |
26 Feb 07 |
jari |
869 |
*/ |
2 |
26 Feb 07 |
jari |
870 |
private int getPointsCount(boolean selected) { |
2 |
26 Feb 07 |
jari |
871 |
int count = 0; |
2 |
26 Feb 07 |
jari |
872 |
int selCount = 0; |
2 |
26 Feb 07 |
jari |
873 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//if (isPointSelected(U.get(i,0), U.get(i,1), U.get(i,2))) { |
2 |
26 Feb 07 |
jari |
875 |
if (isPointSelected(U.get(i,xAxis), U.get(i,yAxis), U.get(i,zAxis))) { |
2 |
26 Feb 07 |
jari |
876 |
selCount++; |
2 |
26 Feb 07 |
jari |
877 |
} else { |
2 |
26 Feb 07 |
jari |
878 |
count++; |
2 |
26 Feb 07 |
jari |
879 |
} |
2 |
26 Feb 07 |
jari |
880 |
} |
2 |
26 Feb 07 |
jari |
881 |
return selected ? selCount : count; |
2 |
26 Feb 07 |
jari |
882 |
} |
2 |
26 Feb 07 |
jari |
883 |
|
2 |
26 Feb 07 |
jari |
884 |
/** |
2 |
26 Feb 07 |
jari |
* Returns number of unselected points. |
2 |
26 Feb 07 |
jari |
886 |
*/ |
2 |
26 Feb 07 |
jari |
887 |
private int getUsualPointsCount() { |
2 |
26 Feb 07 |
jari |
888 |
if (isSelection()) { |
2 |
26 Feb 07 |
jari |
889 |
return getPointsCount(false); |
2 |
26 Feb 07 |
jari |
890 |
} |
2 |
26 Feb 07 |
jari |
891 |
return U.getRowDimension(); |
2 |
26 Feb 07 |
jari |
892 |
} |
2 |
26 Feb 07 |
jari |
893 |
|
2 |
26 Feb 07 |
jari |
894 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a 3D shape which is set of selected points. |
2 |
26 Feb 07 |
jari |
896 |
*/ |
2 |
26 Feb 07 |
jari |
897 |
private Shape3D createSelectedPoints() { |
2 |
26 Feb 07 |
jari |
898 |
if (!isSelection()) { |
2 |
26 Feb 07 |
jari |
899 |
return null; |
2 |
26 Feb 07 |
jari |
900 |
} |
2 |
26 Feb 07 |
jari |
901 |
int count = getPointsCount(true); |
2 |
26 Feb 07 |
jari |
902 |
if (count < 1) { |
2 |
26 Feb 07 |
jari |
903 |
return null; |
2 |
26 Feb 07 |
jari |
904 |
} |
2 |
26 Feb 07 |
jari |
905 |
Color3f color = new Color3f(1.0f, 0.3f, 1.0f); |
2 |
26 Feb 07 |
jari |
906 |
Material material = new Material(color, color, color, color, 100.0f); |
2 |
26 Feb 07 |
jari |
907 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
908 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
909 |
appearance.setPointAttributes(new PointAttributes(getSelectedPointSize(), false)); |
2 |
26 Feb 07 |
jari |
910 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
911 |
|
2 |
26 Feb 07 |
jari |
912 |
PointArray points = new PointArray(count, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
913 |
|
2 |
26 Feb 07 |
jari |
914 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
915 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
916 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
917 |
|
2 |
26 Feb 07 |
jari |
918 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
919 |
int index = 0; |
2 |
26 Feb 07 |
jari |
920 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
924 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
925 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
926 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
927 |
if (isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
928 |
points.setCoordinate(index, new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
929 |
index++; |
2 |
26 Feb 07 |
jari |
930 |
} |
2 |
26 Feb 07 |
jari |
931 |
} |
2 |
26 Feb 07 |
jari |
932 |
Shape3D pointsShape = new Shape3D(); |
2 |
26 Feb 07 |
jari |
933 |
pointsShape.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
934 |
pointsShape.setGeometry(points); |
2 |
26 Feb 07 |
jari |
935 |
return pointsShape; |
2 |
26 Feb 07 |
jari |
936 |
} |
2 |
26 Feb 07 |
jari |
937 |
|
2 |
26 Feb 07 |
jari |
938 |
private Shape3D[] createSelectedPointsFromBoth() { |
2 |
26 Feb 07 |
jari |
939 |
if (!isSelection()) { |
2 |
26 Feb 07 |
jari |
940 |
return null; |
2 |
26 Feb 07 |
jari |
941 |
} |
2 |
26 Feb 07 |
jari |
942 |
int count = getPointsCount(true); |
2 |
26 Feb 07 |
jari |
943 |
if (count < 1) { |
2 |
26 Feb 07 |
jari |
944 |
return null; |
2 |
26 Feb 07 |
jari |
945 |
} |
2 |
26 Feb 07 |
jari |
946 |
Shape3D[] selectedPoints = new Shape3D[2]; |
2 |
26 Feb 07 |
jari |
947 |
boolean drawGenes = true; |
2 |
26 Feb 07 |
jari |
948 |
if (drawGenes) { |
2 |
26 Feb 07 |
jari |
949 |
Color3f color = new Color3f(1.0f, 0.3f, 1.0f); |
2 |
26 Feb 07 |
jari |
950 |
Material material = new Material(color, color, color, color, 100.0f); |
2 |
26 Feb 07 |
jari |
951 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
952 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
953 |
appearance.setPointAttributes(new PointAttributes(getSelectedPointSize(), false)); |
2 |
26 Feb 07 |
jari |
954 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
955 |
|
2 |
26 Feb 07 |
jari |
956 |
PointArray points = new PointArray(count, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
957 |
|
2 |
26 Feb 07 |
jari |
958 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
959 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
960 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
961 |
|
2 |
26 Feb 07 |
jari |
962 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
963 |
int index = 0; |
2 |
26 Feb 07 |
jari |
964 |
for (int i=0; i<geneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
968 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
969 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
970 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
971 |
if (isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
972 |
points.setCoordinate(index, new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
973 |
index++; |
2 |
26 Feb 07 |
jari |
974 |
} |
2 |
26 Feb 07 |
jari |
975 |
} |
2 |
26 Feb 07 |
jari |
976 |
Shape3D pointsShape = new Shape3D(); |
2 |
26 Feb 07 |
jari |
977 |
pointsShape.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
978 |
pointsShape.setGeometry(points); |
2 |
26 Feb 07 |
jari |
979 |
selectedPoints[0] = pointsShape; |
2 |
26 Feb 07 |
jari |
980 |
} |
2 |
26 Feb 07 |
jari |
981 |
|
2 |
26 Feb 07 |
jari |
982 |
drawGenes = false; |
2 |
26 Feb 07 |
jari |
983 |
|
2 |
26 Feb 07 |
jari |
984 |
if (!drawGenes) { |
2 |
26 Feb 07 |
jari |
985 |
Color3f color = new Color3f(1.0f, 0.3f, 1.0f); |
2 |
26 Feb 07 |
jari |
986 |
Material material = new Material(color, color, color, color, 100.0f); |
2 |
26 Feb 07 |
jari |
987 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
988 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
989 |
float exptSelectedPointSize = getSelectedPointSize(); |
2 |
26 Feb 07 |
jari |
990 |
if (exptSelectedPointSize < 5.0f) exptSelectedPointSize = 5.0f; |
2 |
26 Feb 07 |
jari |
991 |
appearance.setPointAttributes(new PointAttributes(exptSelectedPointSize, false)); |
2 |
26 Feb 07 |
jari |
992 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
993 |
|
2 |
26 Feb 07 |
jari |
994 |
PointArray points = new PointArray(count, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
995 |
|
2 |
26 Feb 07 |
jari |
996 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
997 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
998 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
999 |
|
2 |
26 Feb 07 |
jari |
1000 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1001 |
int index = 0; |
2 |
26 Feb 07 |
jari |
1002 |
for (int i=geneUMatrix.getRowDimension(); i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1006 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1007 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1008 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1009 |
if (isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
1010 |
points.setCoordinate(index, new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1011 |
index++; |
2 |
26 Feb 07 |
jari |
1012 |
} |
2 |
26 Feb 07 |
jari |
1013 |
} |
2 |
26 Feb 07 |
jari |
1014 |
Shape3D pointsShape = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1015 |
pointsShape.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
1016 |
pointsShape.setGeometry(points); |
2 |
26 Feb 07 |
jari |
1017 |
selectedPoints[1] = pointsShape; |
2 |
26 Feb 07 |
jari |
1018 |
} |
2 |
26 Feb 07 |
jari |
1019 |
|
2 |
26 Feb 07 |
jari |
1020 |
return selectedPoints; |
2 |
26 Feb 07 |
jari |
1021 |
} |
2 |
26 Feb 07 |
jari |
1022 |
|
2 |
26 Feb 07 |
jari |
1023 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a point appearance with specified color. |
2 |
26 Feb 07 |
jari |
1025 |
*/ |
2 |
26 Feb 07 |
jari |
1026 |
private Appearance createPointAppearance(Color3f color) { |
2 |
26 Feb 07 |
jari |
1027 |
Material material = new Material(color, color, color, color, 100.0f); |
2 |
26 Feb 07 |
jari |
1028 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
1029 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1030 |
appearance.setPointAttributes(new PointAttributes(getPointSize(), false)); |
2 |
26 Feb 07 |
jari |
1031 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1032 |
return appearance; |
2 |
26 Feb 07 |
jari |
1033 |
} |
2 |
26 Feb 07 |
jari |
1034 |
|
2 |
26 Feb 07 |
jari |
1035 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a point appearance with specified colorand point size. |
2 |
26 Feb 07 |
jari |
1037 |
*/ |
2 |
26 Feb 07 |
jari |
1038 |
private Appearance createPointAppearance(Color3f color, float pSize) { |
2 |
26 Feb 07 |
jari |
1039 |
Material material = new Material(color, color, color, color, 100.0f); |
2 |
26 Feb 07 |
jari |
1040 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
1041 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1042 |
appearance.setPointAttributes(new PointAttributes(pSize, false)); |
2 |
26 Feb 07 |
jari |
1043 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1044 |
return appearance; |
2 |
26 Feb 07 |
jari |
1045 |
} |
2 |
26 Feb 07 |
jari |
1046 |
|
2 |
26 Feb 07 |
jari |
/** Creates an array of 3D shapes which are sets of not selected points. |
2 |
26 Feb 07 |
jari |
1048 |
*/ |
2 |
26 Feb 07 |
jari |
1049 |
private Shape3D[] createUsualPoints() { |
2 |
26 Feb 07 |
jari |
1050 |
Shape3D[] pointShapes = new Shape3D[1]; |
2 |
26 Feb 07 |
jari |
1051 |
Shape3D[] genePointShapes = new Shape3D[1]; |
2 |
26 Feb 07 |
jari |
1052 |
Shape3D[] exptPointShapes = new Shape3D[1]; |
2 |
26 Feb 07 |
jari |
1053 |
|
2 |
26 Feb 07 |
jari |
1054 |
if ((geneOrExpt == COAGUI.GENES) || (geneOrExpt == COAGUI.EXPTS)) { |
2 |
26 Feb 07 |
jari |
1055 |
|
2 |
26 Feb 07 |
jari |
1056 |
int count = getUsualPointsCount(); |
2 |
26 Feb 07 |
jari |
1057 |
if (count < 1) { |
2 |
26 Feb 07 |
jari |
1058 |
return null; |
2 |
26 Feb 07 |
jari |
1059 |
} |
2 |
26 Feb 07 |
jari |
1060 |
|
2 |
26 Feb 07 |
jari |
1061 |
int uncoloredCount; |
2 |
26 Feb 07 |
jari |
1062 |
|
2 |
26 Feb 07 |
jari |
1063 |
if (geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
1064 |
uncoloredCount = data.getColoredProbesCount(-1); |
2 |
26 Feb 07 |
jari |
1065 |
} else { |
2 |
26 Feb 07 |
jari |
1066 |
uncoloredCount = data.getColoredExperimentsCount(-1); |
2 |
26 Feb 07 |
jari |
1067 |
} |
2 |
26 Feb 07 |
jari |
1068 |
|
2 |
26 Feb 07 |
jari |
1069 |
int delta = uncoloredCount == 0 ? 0 : 1; |
2 |
26 Feb 07 |
jari |
1070 |
|
2 |
26 Feb 07 |
jari |
1071 |
Color[] colors = new Color[1]; |
2 |
26 Feb 07 |
jari |
1072 |
if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
1073 |
colors = data.getColors(); // get colored gene clusters |
2 |
26 Feb 07 |
jari |
1074 |
else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
1075 |
colors = data.getExperimentColors(); |
2 |
26 Feb 07 |
jari |
1076 |
|
2 |
26 Feb 07 |
jari |
1077 |
PointArray[] pointArrays = new PointArray[colors.length+delta]; |
2 |
26 Feb 07 |
jari |
1078 |
Appearance[] appearances = new Appearance[colors.length+delta]; |
2 |
26 Feb 07 |
jari |
1079 |
int[] counters = new int[colors.length+delta]; |
2 |
26 Feb 07 |
jari |
1080 |
Color3f color; |
2 |
26 Feb 07 |
jari |
1081 |
|
2 |
26 Feb 07 |
jari |
// not published probes |
2 |
26 Feb 07 |
jari |
1083 |
if (uncoloredCount > 0) { |
2 |
26 Feb 07 |
jari |
1084 |
appearances[0] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor); |
2 |
26 Feb 07 |
jari |
1085 |
pointArrays[0] = new PointArray(uncoloredCount, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1086 |
counters[0] = 0; |
2 |
26 Feb 07 |
jari |
1087 |
} |
2 |
26 Feb 07 |
jari |
1088 |
if(geneOrExpt == COAGUI.GENES){ |
2 |
26 Feb 07 |
jari |
// published ones |
2 |
26 Feb 07 |
jari |
1090 |
for (int i=0; i<colors.length; i++) { |
2 |
26 Feb 07 |
jari |
1091 |
color = new Color3f(colors[i]); |
2 |
26 Feb 07 |
jari |
1092 |
appearances[i+delta] = createPointAppearance(color); |
2 |
26 Feb 07 |
jari |
1093 |
pointArrays[i+delta] = new PointArray(data.getColoredProbesCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1094 |
counters[i+delta] = 0; |
2 |
26 Feb 07 |
jari |
1095 |
} |
2 |
26 Feb 07 |
jari |
1096 |
} else if (geneOrExpt == COAGUI.EXPTS){ //Experiment Viewer |
2 |
26 Feb 07 |
jari |
1097 |
for (int i=0; i<colors.length; i++) { |
2 |
26 Feb 07 |
jari |
1098 |
color = new Color3f(colors[i]); |
2 |
26 Feb 07 |
jari |
1099 |
appearances[i+delta] = createPointAppearance(color); |
2 |
26 Feb 07 |
jari |
1100 |
pointArrays[i+delta] = new PointArray(data.getColoredExperimentsCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1101 |
counters[i+delta] = 0; |
2 |
26 Feb 07 |
jari |
1102 |
} |
2 |
26 Feb 07 |
jari |
1103 |
} |
2 |
26 Feb 07 |
jari |
1104 |
|
2 |
26 Feb 07 |
jari |
1105 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1106 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1107 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1108 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1109 |
int index = 0; |
2 |
26 Feb 07 |
jari |
1110 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1114 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1115 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1116 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1117 |
if (!isSelection() || !isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
1118 |
if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
1119 |
index = data.getProbeColorIndex(experiment.getGeneIndexMappedToData(i))+delta; |
2 |
26 Feb 07 |
jari |
1120 |
else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
1121 |
index = data.getExperimentColorIndex(i)+delta; |
2 |
26 Feb 07 |
jari |
1122 |
|
2 |
26 Feb 07 |
jari |
1123 |
pointArrays[index].setCoordinate(counters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1124 |
counters[index]++; |
2 |
26 Feb 07 |
jari |
1125 |
} |
2 |
26 Feb 07 |
jari |
1126 |
} |
2 |
26 Feb 07 |
jari |
1127 |
|
2 |
26 Feb 07 |
jari |
1128 |
pointShapes = new Shape3D[pointArrays.length]; |
2 |
26 Feb 07 |
jari |
1129 |
for (int i=0; i<pointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
1130 |
pointShapes[i] = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1131 |
pointShapes[i].setAppearance(appearances[i]); |
2 |
26 Feb 07 |
jari |
1132 |
pointShapes[i].setGeometry(pointArrays[i]); |
2 |
26 Feb 07 |
jari |
1133 |
} |
2 |
26 Feb 07 |
jari |
1134 |
|
2 |
26 Feb 07 |
jari |
1135 |
} else { // if (geneOrExpt == COAGUI.BOTH) |
2 |
26 Feb 07 |
jari |
1136 |
int count = getUsualPointsCount(); |
2 |
26 Feb 07 |
jari |
1137 |
if (count < 1) { |
2 |
26 Feb 07 |
jari |
1138 |
return null; |
2 |
26 Feb 07 |
jari |
1139 |
} |
2 |
26 Feb 07 |
jari |
1140 |
|
2 |
26 Feb 07 |
jari |
1141 |
boolean createGenePoints = true; |
2 |
26 Feb 07 |
jari |
1142 |
|
2 |
26 Feb 07 |
jari |
1143 |
if (createGenePoints) { |
2 |
26 Feb 07 |
jari |
1144 |
int geneUncoloredCount = data.getColoredProbesCount(-1); |
2 |
26 Feb 07 |
jari |
1145 |
int geneDelta = geneUncoloredCount == 0 ? 0 : 1; |
2 |
26 Feb 07 |
jari |
1146 |
|
2 |
26 Feb 07 |
jari |
1147 |
Color[] geneColors = data.getColors(); |
2 |
26 Feb 07 |
jari |
1148 |
|
2 |
26 Feb 07 |
jari |
1149 |
PointArray[] genePointArrays = new PointArray[geneColors.length+geneDelta]; |
2 |
26 Feb 07 |
jari |
1150 |
Appearance[] geneAppearances = new Appearance[geneColors.length+geneDelta]; |
2 |
26 Feb 07 |
jari |
1151 |
int[] geneCounters = new int[geneColors.length+geneDelta]; |
2 |
26 Feb 07 |
jari |
1152 |
Color3f geneColor; |
2 |
26 Feb 07 |
jari |
1153 |
|
2 |
26 Feb 07 |
jari |
1154 |
if (geneUncoloredCount > 0) { |
2 |
26 Feb 07 |
jari |
1155 |
geneAppearances[0] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor); |
2 |
26 Feb 07 |
jari |
1156 |
genePointArrays[0] = new PointArray(geneUncoloredCount, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1157 |
geneCounters[0] = 0; |
2 |
26 Feb 07 |
jari |
1158 |
} |
2 |
26 Feb 07 |
jari |
1159 |
|
2 |
26 Feb 07 |
jari |
1160 |
for (int i=0; i<geneColors.length; i++) { |
2 |
26 Feb 07 |
jari |
1161 |
geneColor = new Color3f(geneColors[i]); |
2 |
26 Feb 07 |
jari |
1162 |
geneAppearances[i+geneDelta] = createPointAppearance(geneColor); |
2 |
26 Feb 07 |
jari |
1163 |
genePointArrays[i+geneDelta] = new PointArray(data.getColoredProbesCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1164 |
geneCounters[i+geneDelta] = 0; |
2 |
26 Feb 07 |
jari |
1165 |
} |
2 |
26 Feb 07 |
jari |
1166 |
|
2 |
26 Feb 07 |
jari |
1167 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1168 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1169 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1170 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1171 |
int index = 0; |
2 |
26 Feb 07 |
jari |
1172 |
|
2 |
26 Feb 07 |
jari |
1173 |
for (int i=0; i<scaledGeneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = scaledGeneUMatrix.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = scaledGeneUMatrix.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = scaledGeneUMatrix.get(i,2); |
2 |
26 Feb 07 |
jari |
1177 |
x = scaledGeneUMatrix.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1178 |
y = scaledGeneUMatrix.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1179 |
z = scaledGeneUMatrix.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1180 |
if (!isSelection() || !isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
//if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
1182 |
index = data.getProbeColorIndex(experiment.getGeneIndexMappedToData(i))+geneDelta; |
2 |
26 Feb 07 |
jari |
//else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
//index = data.getExperimentColorIndex(i)+delta; |
2 |
26 Feb 07 |
jari |
1185 |
|
2 |
26 Feb 07 |
jari |
1186 |
genePointArrays[index].setCoordinate(geneCounters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1187 |
geneCounters[index]++; |
2 |
26 Feb 07 |
jari |
1188 |
} |
2 |
26 Feb 07 |
jari |
1189 |
} |
2 |
26 Feb 07 |
jari |
1190 |
|
2 |
26 Feb 07 |
jari |
1191 |
genePointShapes = new Shape3D[genePointArrays.length]; |
2 |
26 Feb 07 |
jari |
1192 |
for (int i=0; i<genePointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
1193 |
genePointShapes[i] = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1194 |
genePointShapes[i].setAppearance(geneAppearances[i]); |
2 |
26 Feb 07 |
jari |
1195 |
genePointShapes[i].setGeometry(genePointArrays[i]); |
2 |
26 Feb 07 |
jari |
1196 |
} |
2 |
26 Feb 07 |
jari |
1197 |
|
2 |
26 Feb 07 |
jari |
1198 |
} // end if (createGenePoints) |
2 |
26 Feb 07 |
jari |
1199 |
|
2 |
26 Feb 07 |
jari |
1200 |
createGenePoints = false; |
2 |
26 Feb 07 |
jari |
1201 |
|
2 |
26 Feb 07 |
jari |
1202 |
if (!createGenePoints) { // i.e., create expt points |
2 |
26 Feb 07 |
jari |
1203 |
int exptUncoloredCount = data.getColoredExperimentsCount(-1); |
2 |
26 Feb 07 |
jari |
1204 |
int exptDelta = exptUncoloredCount == 0 ? 0 : 1; |
2 |
26 Feb 07 |
jari |
1205 |
|
2 |
26 Feb 07 |
jari |
1206 |
Color[] exptColors = data.getExperimentColors(); |
2 |
26 Feb 07 |
jari |
1207 |
|
2 |
26 Feb 07 |
jari |
1208 |
PointArray[] exptPointArrays = new PointArray[exptColors.length+ exptDelta]; |
2 |
26 Feb 07 |
jari |
1209 |
Appearance[] exptAppearances = new Appearance[exptColors.length+ exptDelta]; |
2 |
26 Feb 07 |
jari |
1210 |
int[] exptCounters = new int[exptColors.length+ exptDelta]; |
2 |
26 Feb 07 |
jari |
1211 |
Color3f exptColor; |
2 |
26 Feb 07 |
jari |
1212 |
|
2 |
26 Feb 07 |
jari |
// not published probes |
2 |
26 Feb 07 |
jari |
1214 |
if (exptUncoloredCount > 0) { |
2 |
26 Feb 07 |
jari |
1215 |
if (getPointSize() < 10.0f) { |
2 |
26 Feb 07 |
jari |
1216 |
exptAppearances[0] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor, 10.0f); |
2 |
26 Feb 07 |
jari |
1217 |
} else { |
2 |
26 Feb 07 |
jari |
1218 |
exptAppearances[0] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor); |
2 |
26 Feb 07 |
jari |
1219 |
} |
2 |
26 Feb 07 |
jari |
1220 |
exptPointArrays[0] = new PointArray(exptUncoloredCount, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1221 |
exptCounters[0] = 0; |
2 |
26 Feb 07 |
jari |
1222 |
} |
2 |
26 Feb 07 |
jari |
1223 |
|
2 |
26 Feb 07 |
jari |
1224 |
for (int i=0; i<exptColors.length; i++) { |
2 |
26 Feb 07 |
jari |
1225 |
exptColor = new Color3f(exptColors[i]); |
2 |
26 Feb 07 |
jari |
1226 |
if (getPointSize() < 10.0f) { |
2 |
26 Feb 07 |
jari |
1227 |
exptAppearances[i+exptDelta] = createPointAppearance(exptColor, 10.0f); |
2 |
26 Feb 07 |
jari |
1228 |
} else { |
2 |
26 Feb 07 |
jari |
1229 |
exptAppearances[i+exptDelta] = createPointAppearance(exptColor); |
2 |
26 Feb 07 |
jari |
1230 |
} |
2 |
26 Feb 07 |
jari |
1231 |
exptPointArrays[i+exptDelta] = new PointArray(data.getColoredExperimentsCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1232 |
exptCounters[i+exptDelta] = 0; |
2 |
26 Feb 07 |
jari |
1233 |
} |
2 |
26 Feb 07 |
jari |
1234 |
|
2 |
26 Feb 07 |
jari |
1235 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1236 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1237 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1238 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1239 |
int index = 0; |
2 |
26 Feb 07 |
jari |
1240 |
|
2 |
26 Feb 07 |
jari |
1241 |
for (int i=0; i<scaledExptUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = scaledExptUMatrix.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = scaledExptUMatrix.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = scaledExptUMatrix.get(i,2); |
2 |
26 Feb 07 |
jari |
1245 |
x = scaledExptUMatrix.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1246 |
y = scaledExptUMatrix.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1247 |
z = scaledExptUMatrix.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1248 |
if (!isSelection() || !isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
//if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
//index = data.getProbeColorIndex(experiment.getGeneIndexMappedToData(i))+delta; |
2 |
26 Feb 07 |
jari |
// else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
1252 |
index = data.getExperimentColorIndex(i)+exptDelta; |
2 |
26 Feb 07 |
jari |
1253 |
|
2 |
26 Feb 07 |
jari |
1254 |
exptPointArrays[index].setCoordinate(exptCounters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1255 |
exptCounters[index]++; |
2 |
26 Feb 07 |
jari |
1256 |
} |
2 |
26 Feb 07 |
jari |
1257 |
} |
2 |
26 Feb 07 |
jari |
1258 |
|
2 |
26 Feb 07 |
jari |
1259 |
exptPointShapes = new Shape3D[exptPointArrays.length]; |
2 |
26 Feb 07 |
jari |
1260 |
for (int i=0; i<exptPointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
1261 |
exptPointShapes[i] = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1262 |
exptPointShapes[i].setAppearance(exptAppearances[i]); |
2 |
26 Feb 07 |
jari |
1263 |
exptPointShapes[i].setGeometry(exptPointArrays[i]); |
2 |
26 Feb 07 |
jari |
1264 |
} |
2 |
26 Feb 07 |
jari |
1265 |
|
2 |
26 Feb 07 |
jari |
1266 |
} // end if (!createGenePoints) |
2 |
26 Feb 07 |
jari |
1267 |
|
2 |
26 Feb 07 |
jari |
1268 |
pointShapes = new Shape3D[genePointShapes.length + exptPointShapes.length]; |
2 |
26 Feb 07 |
jari |
1269 |
for (int i = 0; i < genePointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
1270 |
pointShapes[i] = genePointShapes[i]; |
2 |
26 Feb 07 |
jari |
1271 |
} |
2 |
26 Feb 07 |
jari |
1272 |
for (int i = 0; i < exptPointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
1273 |
pointShapes[genePointShapes.length + i] = exptPointShapes[i]; |
2 |
26 Feb 07 |
jari |
1274 |
} |
2 |
26 Feb 07 |
jari |
1275 |
|
2 |
26 Feb 07 |
jari |
1276 |
} // end if (geneOrExpt == COAGUI.BOTH) |
2 |
26 Feb 07 |
jari |
1277 |
|
2 |
26 Feb 07 |
jari |
1278 |
return pointShapes; |
2 |
26 Feb 07 |
jari |
1279 |
} |
2 |
26 Feb 07 |
jari |
1280 |
|
2 |
26 Feb 07 |
jari |
1281 |
/** |
2 |
26 Feb 07 |
jari |
* Creates an array of 3D shapes which are sets of not selected points. |
2 |
26 Feb 07 |
jari |
1283 |
*/ |
2 |
26 Feb 07 |
jari |
1284 |
private Shape3D[] createUsualPointsOld() { |
2 |
26 Feb 07 |
jari |
1285 |
int count = getUsualPointsCount(); |
2 |
26 Feb 07 |
jari |
//System.out.println("count = " + count); |
2 |
26 Feb 07 |
jari |
1287 |
if (count < 1) { |
2 |
26 Feb 07 |
jari |
1288 |
return null; |
2 |
26 Feb 07 |
jari |
1289 |
} |
2 |
26 Feb 07 |
jari |
//int uncoloredCount = data.getColoredProbesCount(-1); |
2 |
26 Feb 07 |
jari |
1291 |
int uncoloredCount; |
2 |
26 Feb 07 |
jari |
1292 |
if (geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
1293 |
uncoloredCount = data.getColoredProbesCount(-1); |
2 |
26 Feb 07 |
jari |
1294 |
} else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
1295 |
uncoloredCount = data.getColoredExperimentsCount(-1); |
2 |
26 Feb 07 |
jari |
1296 |
} else { |
2 |
26 Feb 07 |
jari |
1297 |
uncoloredCount = data.getColoredProbesCount(-1) + data.getColoredExperimentsCount(-1); |
2 |
26 Feb 07 |
jari |
1298 |
} |
2 |
26 Feb 07 |
jari |
1299 |
System.out.println("unColoredCount = " + uncoloredCount); |
2 |
26 Feb 07 |
jari |
1300 |
int delta = uncoloredCount == 0 ? 0 : 1; |
2 |
26 Feb 07 |
jari |
1301 |
int geneDelta = data.getColoredProbesCount(-1) == 0 ? 0 : 1; |
2 |
26 Feb 07 |
jari |
1302 |
int exptDelta = data.getColoredExperimentsCount(-1) == 0 ? 0 : 1; |
2 |
26 Feb 07 |
jari |
//System.out.println("delta = " + delta); |
2 |
26 Feb 07 |
jari |
1304 |
|
2 |
26 Feb 07 |
jari |
1305 |
Color[] colors = new Color[1]; |
2 |
26 Feb 07 |
jari |
1306 |
Color[] geneColors = new Color[1]; |
2 |
26 Feb 07 |
jari |
1307 |
Color[] exptColors = new Color[1]; |
2 |
26 Feb 07 |
jari |
1308 |
int[] bothColorCounts = new int[1]; |
2 |
26 Feb 07 |
jari |
1309 |
if(geneOrExpt == COAGUI.GENES) |
2 |
26 Feb 07 |
jari |
1310 |
colors = data.getColors(); // get colored gene clusters |
2 |
26 Feb 07 |
jari |
1311 |
else if (geneOrExpt == COAGUI.EXPTS) |
2 |
26 Feb 07 |
jari |
1312 |
colors = data.getExperimentColors(); |
2 |
26 Feb 07 |
jari |
1313 |
else if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1314 |
geneColors = data.getColors(); |
2 |
26 Feb 07 |
jari |
1315 |
exptColors = data.getExperimentColors(); |
2 |
26 Feb 07 |
jari |
1316 |
|
2 |
26 Feb 07 |
jari |
1317 |
System.out.println("geneColors.length = " + geneColors.length + ", exptColors.length = " + exptColors.length + ", colors.length = " + colors.length + ", bothColorCounts.length = " + bothColorCounts.length); |
2 |
26 Feb 07 |
jari |
1318 |
|
2 |
26 Feb 07 |
jari |
1319 |
colors = new Color[geneColors.length + exptColors.length]; |
2 |
26 Feb 07 |
jari |
1320 |
for (int i = 0; i < geneColors.length; i++) { |
2 |
26 Feb 07 |
jari |
1321 |
colors[i] = geneColors[i]; |
2 |
26 Feb 07 |
jari |
1322 |
} |
2 |
26 Feb 07 |
jari |
1323 |
for (int i = 0; i < exptColors.length; i++) { |
2 |
26 Feb 07 |
jari |
1324 |
colors[geneColors.length + i] = exptColors[i]; |
2 |
26 Feb 07 |
jari |
1325 |
} |
2 |
26 Feb 07 |
jari |
1326 |
|
2 |
26 Feb 07 |
jari |
1327 |
|
2 |
26 Feb 07 |
jari |
1328 |
} |
2 |
26 Feb 07 |
jari |
1329 |
|
2 |
26 Feb 07 |
jari |
1330 |
PointArray[] pointArrays = new PointArray[colors.length+delta]; |
2 |
26 Feb 07 |
jari |
1331 |
Appearance[] appearances = new Appearance[colors.length+delta]; |
2 |
26 Feb 07 |
jari |
1332 |
int[] counters = new int[colors.length+delta]; |
2 |
26 Feb 07 |
jari |
1333 |
int[] exptCounters = new int[colors.length + delta]; |
2 |
26 Feb 07 |
jari |
1334 |
|
2 |
26 Feb 07 |
jari |
1335 |
if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1336 |
pointArrays = new PointArray[colors.length+geneDelta + exptDelta]; |
2 |
26 Feb 07 |
jari |
1337 |
appearances = new Appearance[colors.length+ geneDelta + exptDelta]; |
2 |
26 Feb 07 |
jari |
1338 |
counters = new int[colors.length+ geneDelta + exptDelta]; |
2 |
26 Feb 07 |
jari |
1339 |
exptCounters = new int[colors.length + geneDelta + exptDelta]; |
2 |
26 Feb 07 |
jari |
1340 |
} |
2 |
26 Feb 07 |
jari |
1341 |
|
2 |
26 Feb 07 |
jari |
1342 |
Color3f color; |
2 |
26 Feb 07 |
jari |
1343 |
|
2 |
26 Feb 07 |
jari |
1344 |
if ((geneOrExpt == COAGUI.GENES) || (geneOrExpt == COAGUI.EXPTS)) { |
2 |
26 Feb 07 |
jari |
// not published probes |
2 |
26 Feb 07 |
jari |
1346 |
if (uncoloredCount > 0) { |
2 |
26 Feb 07 |
jari |
1347 |
appearances[0] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor); |
2 |
26 Feb 07 |
jari |
1348 |
pointArrays[0] = new PointArray(uncoloredCount, PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1349 |
counters[0] = 0; |
2 |
26 Feb 07 |
jari |
1350 |
exptCounters[0] = 0; |
2 |
26 Feb 07 |
jari |
1351 |
} |
2 |
26 Feb 07 |
jari |
1352 |
} else { |
2 |
26 Feb 07 |
jari |
1353 |
if (data.getColoredProbesCount(-1) > 0) { |
2 |
26 Feb 07 |
jari |
1354 |
appearances[0] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor); |
2 |
26 Feb 07 |
jari |
1355 |
pointArrays[0] = new PointArray(data.getColoredProbesCount(-1), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1356 |
counters[0] = 0; |
2 |
26 Feb 07 |
jari |
1357 |
exptCounters[0] = 0; |
2 |
26 Feb 07 |
jari |
1358 |
} |
2 |
26 Feb 07 |
jari |
1359 |
if (data.getColoredExperimentsCount(-1) > 0) { |
2 |
26 Feb 07 |
jari |
1360 |
appearances[geneColors.length + geneDelta] = createPointAppearance(isWhiteBackground() ? blackColor : whiteColor); |
2 |
26 Feb 07 |
jari |
1361 |
pointArrays[geneColors.length + geneDelta] = new PointArray(data.getColoredExperimentsCount(-1), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1362 |
counters[geneColors.length + geneDelta] = 0; |
2 |
26 Feb 07 |
jari |
1363 |
exptCounters[geneColors.length + geneDelta] = 0; |
2 |
26 Feb 07 |
jari |
1364 |
} |
2 |
26 Feb 07 |
jari |
1365 |
} |
2 |
26 Feb 07 |
jari |
1366 |
if(geneOrExpt == COAGUI.GENES){ |
2 |
26 Feb 07 |
jari |
// published ones |
2 |
26 Feb 07 |
jari |
1368 |
for (int i=0; i<colors.length; i++) { |
2 |
26 Feb 07 |
jari |
1369 |
color = new Color3f(colors[i]); |
2 |
26 Feb 07 |
jari |
1370 |
appearances[i+delta] = createPointAppearance(color); |
2 |
26 Feb 07 |
jari |
1371 |
pointArrays[i+delta] = new PointArray(data.getColoredProbesCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1372 |
counters[i+delta] = 0; |
2 |
26 Feb 07 |
jari |
1373 |
} |
2 |
26 Feb 07 |
jari |
1374 |
} else if (geneOrExpt == COAGUI.EXPTS) { //Experiment Viewer |
2 |
26 Feb 07 |
jari |
1375 |
for (int i=0; i<colors.length; i++) { |
2 |
26 Feb 07 |
jari |
1376 |
color = new Color3f(colors[i]); |
2 |
26 Feb 07 |
jari |
1377 |
appearances[i+delta] = createPointAppearance(color); |
2 |
26 Feb 07 |
jari |
1378 |
pointArrays[i+delta] = new PointArray(data.getColoredExperimentsCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1379 |
counters[i+delta] = 0; |
2 |
26 Feb 07 |
jari |
1380 |
} |
2 |
26 Feb 07 |
jari |
1381 |
} else if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1382 |
System.out.println("colors.length = " + colors.length); |
2 |
26 Feb 07 |
jari |
1383 |
|
2 |
26 Feb 07 |
jari |
1384 |
for (int i=0; i<geneColors.length; i++) { |
2 |
26 Feb 07 |
jari |
1385 |
color = new Color3f(colors[i]); |
2 |
26 Feb 07 |
jari |
1386 |
appearances[i+geneDelta] = createPointAppearance(color); |
2 |
26 Feb 07 |
jari |
1387 |
pointArrays[i+geneDelta] = new PointArray(data.getColoredProbesCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1388 |
counters[i+geneDelta] = 0; |
2 |
26 Feb 07 |
jari |
1389 |
} |
2 |
26 Feb 07 |
jari |
1390 |
for (int i=0; i<exptColors.length; i++) { |
2 |
26 Feb 07 |
jari |
1391 |
color = new Color3f(colors[geneColors.length + i]); |
2 |
26 Feb 07 |
jari |
1392 |
appearances[geneColors.length + geneDelta + i + exptDelta] = createPointAppearance(color); |
2 |
26 Feb 07 |
jari |
1393 |
pointArrays[geneColors.length + geneDelta + i + exptDelta] = new PointArray(data.getColoredExperimentsCount(i), PointArray.COORDINATES | PointArray.COLOR_3 | PointArray.NORMALS); |
2 |
26 Feb 07 |
jari |
1394 |
counters[geneColors.length + geneDelta + i + exptDelta] = 0; |
2 |
26 Feb 07 |
jari |
1395 |
exptCounters[geneColors.length + geneDelta + i + exptDelta] = 0; |
2 |
26 Feb 07 |
jari |
//exptCounters[geneColors.length + geneDelta + i + exptDelta] = 0; |
2 |
26 Feb 07 |
jari |
1397 |
} |
2 |
26 Feb 07 |
jari |
1398 |
} |
2 |
26 Feb 07 |
jari |
1399 |
|
2 |
26 Feb 07 |
jari |
1400 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1401 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1402 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1403 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1404 |
int index = 0; |
2 |
26 Feb 07 |
jari |
//int exptIndex = 0; |
2 |
26 Feb 07 |
jari |
1406 |
|
2 |
26 Feb 07 |
jari |
1407 |
System.out.println("U.getRowDimension() = " + U.getRowDimension()); |
2 |
26 Feb 07 |
jari |
1408 |
|
2 |
26 Feb 07 |
jari |
1409 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1413 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1414 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1415 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1416 |
if (!isSelection() || !isPointSelected(x, y, z)) { |
2 |
26 Feb 07 |
jari |
1417 |
if(geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
1418 |
index = data.getProbeColorIndex(experiment.getGeneIndexMappedToData(i))+delta; |
2 |
26 Feb 07 |
jari |
1419 |
System.out.println("i = " + i+ ", index = " + index + ", counters[index] = " + counters[index]); |
2 |
26 Feb 07 |
jari |
1420 |
pointArrays[index].setCoordinate(counters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1421 |
counters[index]++; |
2 |
26 Feb 07 |
jari |
1422 |
} |
2 |
26 Feb 07 |
jari |
1423 |
else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
1424 |
index = data.getExperimentColorIndex(i)+delta; |
2 |
26 Feb 07 |
jari |
1425 |
System.out.println("i = " + i+ ", index = " + index + ", counters[index] = " + counters[index]); |
2 |
26 Feb 07 |
jari |
1426 |
pointArrays[index].setCoordinate(counters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1427 |
counters[index]++; |
2 |
26 Feb 07 |
jari |
1428 |
} |
2 |
26 Feb 07 |
jari |
1429 |
else if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1430 |
if (i < geneUMatrix.getRowDimension()) { |
2 |
26 Feb 07 |
jari |
1431 |
index = data.getProbeColorIndex(experiment.getGeneIndexMappedToData(i))+ geneDelta; |
2 |
26 Feb 07 |
jari |
1432 |
System.out.println("i < geneUMatrix.getRowDimension(): i = " + i+ ", index = " + index + ", counters[index] = " + counters[index]); |
2 |
26 Feb 07 |
jari |
1433 |
pointArrays[index].setCoordinate(counters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1434 |
counters[index]++; |
2 |
26 Feb 07 |
jari |
1435 |
} |
2 |
26 Feb 07 |
jari |
1436 |
else { |
2 |
26 Feb 07 |
jari |
//index = geneColors.length + data.getExperimentColorIndex(i - geneUMatrix.getRowDimension())+delta; |
2 |
26 Feb 07 |
jari |
//System.out.println("data.getExperimentColorIndex(i - geneUMatrix.getRowDimension()) = " + data.getExperimentColorIndex(i - geneUMatrix.getRowDimension())); |
2 |
26 Feb 07 |
jari |
//System.out.println("geneDelta = " + geneDelta + ", exptDelta = " + exptDelta); |
2 |
26 Feb 07 |
jari |
1440 |
int initExptIndex = data.getExperimentColorIndex(i - geneUMatrix.getRowDimension()) + exptDelta; |
2 |
26 Feb 07 |
jari |
1441 |
if (initExptIndex == 0){ |
2 |
26 Feb 07 |
jari |
1442 |
index = 0; |
2 |
26 Feb 07 |
jari |
1443 |
} else { |
2 |
26 Feb 07 |
jari |
1444 |
index = data.getExperimentColorIndex(i - geneUMatrix.getRowDimension()) + exptDelta + (data.getColors()).length; |
2 |
26 Feb 07 |
jari |
1445 |
} |
2 |
26 Feb 07 |
jari |
1446 |
System.out.println("i >= geneUMatrix.getRowDimension(): i = " + i+ ", index = " + index + ", exptCounters[index] = " + exptCounters[index]); |
2 |
26 Feb 07 |
jari |
1447 |
pointArrays[index].setCoordinate(exptCounters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
1448 |
exptCounters[index]++; |
2 |
26 Feb 07 |
jari |
//pointArrays[geneColors.length+ index].setCoordinate(counters[geneColors.length + index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
//counters[geneColors.length + index]++; |
2 |
26 Feb 07 |
jari |
1451 |
} |
2 |
26 Feb 07 |
jari |
1452 |
} |
2 |
26 Feb 07 |
jari |
//System.out.println("counters.length = " + counters.length); |
2 |
26 Feb 07 |
jari |
//System.out.println("i = " + i+ ", index = " + index + ", counters[index] = " + counters[index]); |
2 |
26 Feb 07 |
jari |
//pointArrays[index].setCoordinate(counters[index], new Point3f(x*factorX, y*factorY, z*factorZ)); |
2 |
26 Feb 07 |
jari |
//counters[index]++; |
2 |
26 Feb 07 |
jari |
1457 |
} |
2 |
26 Feb 07 |
jari |
1458 |
} |
2 |
26 Feb 07 |
jari |
1459 |
|
2 |
26 Feb 07 |
jari |
1460 |
Shape3D[] pointShapes = new Shape3D[pointArrays.length]; |
2 |
26 Feb 07 |
jari |
1461 |
|
2 |
26 Feb 07 |
jari |
1462 |
for (int i=0; i<pointShapes.length; i++) { |
2 |
26 Feb 07 |
jari |
1463 |
pointShapes[i] = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1464 |
pointShapes[i].setAppearance(appearances[i]); |
2 |
26 Feb 07 |
jari |
1465 |
pointShapes[i].setGeometry(pointArrays[i]); |
2 |
26 Feb 07 |
jari |
1466 |
} |
2 |
26 Feb 07 |
jari |
1467 |
|
2 |
26 Feb 07 |
jari |
1468 |
|
2 |
26 Feb 07 |
jari |
1469 |
System.out.println("Reached end of createUsualPoints"); |
2 |
26 Feb 07 |
jari |
1470 |
return pointShapes; |
2 |
26 Feb 07 |
jari |
1471 |
} |
2 |
26 Feb 07 |
jari |
1472 |
|
2 |
26 Feb 07 |
jari |
1473 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a point appearance with specified color. |
2 |
26 Feb 07 |
jari |
1475 |
*/ |
2 |
26 Feb 07 |
jari |
1476 |
private Appearance createSphereAppearance(Color3f color) { |
2 |
26 Feb 07 |
jari |
1477 |
Material material = new Material(color, this.blackColor, color, this.whiteColor, 100.0f); |
2 |
26 Feb 07 |
jari |
1478 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
1479 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1480 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1481 |
return appearance; |
2 |
26 Feb 07 |
jari |
1482 |
} |
2 |
26 Feb 07 |
jari |
1483 |
|
2 |
26 Feb 07 |
jari |
1484 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a spheres transform group. |
2 |
26 Feb 07 |
jari |
1486 |
*/ |
2 |
26 Feb 07 |
jari |
1487 |
private TransformGroup createSpheres() { |
2 |
26 Feb 07 |
jari |
1488 |
TransformGroup spheres = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1489 |
|
2 |
26 Feb 07 |
jari |
1490 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1491 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1492 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1493 |
|
2 |
26 Feb 07 |
jari |
// usual material |
2 |
26 Feb 07 |
jari |
1495 |
Color3f uColor = isWhiteBackground() ? blackColor : whiteColor; |
2 |
26 Feb 07 |
jari |
1496 |
Appearance uAppearance = createSphereAppearance(uColor); |
2 |
26 Feb 07 |
jari |
1497 |
|
2 |
26 Feb 07 |
jari |
// selected material |
2 |
26 Feb 07 |
jari |
1499 |
Color3f sColor = isSelection() ? new Color3f(1.0f, 0.3f, 1.0f) : uColor; |
2 |
26 Feb 07 |
jari |
1500 |
Appearance sAppearance = createSphereAppearance(sColor); |
2 |
26 Feb 07 |
jari |
1501 |
|
2 |
26 Feb 07 |
jari |
1502 |
Transform3D transform; |
2 |
26 Feb 07 |
jari |
1503 |
Vector3d vector3d; |
2 |
26 Feb 07 |
jari |
1504 |
TransformGroup sphere; |
2 |
26 Feb 07 |
jari |
1505 |
boolean selected; |
2 |
26 Feb 07 |
jari |
1506 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1507 |
|
2 |
26 Feb 07 |
jari |
1508 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1512 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1513 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1514 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1515 |
transform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1516 |
vector3d = new Vector3d(x*factorX, y*factorY, z*factorZ); |
2 |
26 Feb 07 |
jari |
1517 |
transform.set(vector3d); |
2 |
26 Feb 07 |
jari |
1518 |
sphere = new TransformGroup(transform); |
2 |
26 Feb 07 |
jari |
1519 |
selected = (isSelection() && isPointSelected(x, y, z)); |
2 |
26 Feb 07 |
jari |
1520 |
if (geneOrExpt == COAGUI.GENES){ |
2 |
26 Feb 07 |
jari |
1521 |
if (data.getProbeColor(experiment.getGeneIndexMappedToData(i)) == null) { |
2 |
26 Feb 07 |
jari |
1522 |
sphere.addChild(new Sphere(getPointSize(selected)/20f, (selected ? sAppearance : uAppearance))); |
2 |
26 Feb 07 |
jari |
1523 |
} else { |
2 |
26 Feb 07 |
jari |
1524 |
sphere.addChild(new Sphere(getPointSize(selected)/20f, (selected ? sAppearance : createSphereAppearance(new Color3f(data.getProbeColor(experiment.getGeneIndexMappedToData(i))))))); |
2 |
26 Feb 07 |
jari |
1525 |
} |
2 |
26 Feb 07 |
jari |
1526 |
} |
2 |
26 Feb 07 |
jari |
1527 |
else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
1528 |
if (data.getExperimentColor(i) == null) { |
2 |
26 Feb 07 |
jari |
1529 |
sphere.addChild(new Sphere(getPointSize(selected)/20f, (selected ? sAppearance : uAppearance))); |
2 |
26 Feb 07 |
jari |
1530 |
} else { |
2 |
26 Feb 07 |
jari |
1531 |
sphere.addChild(new Sphere(getPointSize(selected)/20f, (selected ? sAppearance : createSphereAppearance(new Color3f(data.getExperimentColor(i)))))); |
2 |
26 Feb 07 |
jari |
1532 |
} |
2 |
26 Feb 07 |
jari |
1533 |
} else if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1534 |
if (i < geneUMatrix.getRowDimension()) { |
2 |
26 Feb 07 |
jari |
1535 |
if (data.getProbeColor(experiment.getGeneIndexMappedToData(i)) == null) { |
2 |
26 Feb 07 |
jari |
1536 |
sphere.addChild(new Sphere(getPointSize(selected)/20f, (selected ? sAppearance : uAppearance))); |
2 |
26 Feb 07 |
jari |
1537 |
} else { |
2 |
26 Feb 07 |
jari |
1538 |
sphere.addChild(new Sphere(getPointSize(selected)/20f, (selected ? sAppearance : createSphereAppearance(new Color3f(data.getProbeColor(experiment.getGeneIndexMappedToData(i))))))); |
2 |
26 Feb 07 |
jari |
1539 |
} |
2 |
26 Feb 07 |
jari |
1540 |
|
2 |
26 Feb 07 |
jari |
1541 |
} else { |
2 |
26 Feb 07 |
jari |
1542 |
if (data.getExperimentColor(i - geneUMatrix.getRowDimension()) == null) { |
2 |
26 Feb 07 |
jari |
1543 |
sphere.addChild(new Sphere((float)(2f*getPointSize(selected)/20f), (selected ? sAppearance : uAppearance))); |
2 |
26 Feb 07 |
jari |
1544 |
} else { |
2 |
26 Feb 07 |
jari |
1545 |
sphere.addChild(new Sphere((float)(2f*getPointSize(selected)/20f), (selected ? sAppearance : createSphereAppearance(new Color3f(data.getExperimentColor(i - geneUMatrix.getRowDimension())))))); |
2 |
26 Feb 07 |
jari |
1546 |
} |
2 |
26 Feb 07 |
jari |
1547 |
} |
2 |
26 Feb 07 |
jari |
1548 |
} |
2 |
26 Feb 07 |
jari |
1549 |
spheres.addChild(sphere); |
2 |
26 Feb 07 |
jari |
1550 |
} |
2 |
26 Feb 07 |
jari |
1551 |
return spheres; |
2 |
26 Feb 07 |
jari |
1552 |
} |
2 |
26 Feb 07 |
jari |
1553 |
|
2 |
26 Feb 07 |
jari |
1554 |
|
2 |
26 Feb 07 |
jari |
1555 |
|
2 |
26 Feb 07 |
jari |
1556 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a text transform group. |
2 |
26 Feb 07 |
jari |
1558 |
*/ |
2 |
26 Feb 07 |
jari |
1559 |
private TransformGroup createText() { |
2 |
26 Feb 07 |
jari |
1560 |
TransformGroup textGroup = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1561 |
|
2 |
26 Feb 07 |
jari |
1562 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1563 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1564 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1565 |
|
2 |
26 Feb 07 |
jari |
//Font3D font = new Font3D(new Font("TestFont", Font.BOLD, 1), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1567 |
Font3D font = new Font3D(new Font("TestFont", Font.BOLD, (int)(Math.round(getPointSize(false)))), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1568 |
Font origFont = font.getFont(); |
2 |
26 Feb 07 |
jari |
1569 |
|
2 |
26 Feb 07 |
jari |
1570 |
FontMetrics fMet = onScreenCanvas.getFontMetrics(origFont); |
2 |
26 Feb 07 |
jari |
1571 |
int ascent = fMet.getAscent(); |
2 |
26 Feb 07 |
jari |
1572 |
|
2 |
26 Feb 07 |
jari |
1573 |
Color3f color3f; |
2 |
26 Feb 07 |
jari |
1574 |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
1575 |
color3f = new Color3f(1.0f, 1.0f, 1.0f); |
2 |
26 Feb 07 |
jari |
1576 |
else |
2 |
26 Feb 07 |
jari |
1577 |
color3f = new Color3f(0.0f, 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
1578 |
|
2 |
26 Feb 07 |
jari |
1579 |
Material material; |
2 |
26 Feb 07 |
jari |
1580 |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
1581 |
material = new Material(color3f, whiteColor, color3f, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
1582 |
else |
2 |
26 Feb 07 |
jari |
1583 |
material = new Material(color3f, blackColor, color3f, blackColor, 100f); |
2 |
26 Feb 07 |
jari |
1584 |
|
2 |
26 Feb 07 |
jari |
1585 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
//material.setLightingEnable(false); |
2 |
26 Feb 07 |
jari |
1587 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1588 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1589 |
|
2 |
26 Feb 07 |
jari |
1590 |
Transform3D fontTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1591 |
fontTransform.setScale(0.1); |
2 |
26 Feb 07 |
jari |
1592 |
|
2 |
26 Feb 07 |
jari |
1593 |
TransformGroup tempGroup; |
2 |
26 Feb 07 |
jari |
1594 |
Text3D text3d; |
2 |
26 Feb 07 |
jari |
1595 |
Shape3D shape3d; |
2 |
26 Feb 07 |
jari |
1596 |
String text; |
2 |
26 Feb 07 |
jari |
1597 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1598 |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1602 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1603 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1604 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1605 |
tempGroup = new TransformGroup(fontTransform); |
2 |
26 Feb 07 |
jari |
1606 |
text = ""; |
2 |
26 Feb 07 |
jari |
1607 |
if (geneOrExpt == COAGUI.GENES) { |
2 |
26 Feb 07 |
jari |
//text = data.getUniqueId(i) |
2 |
26 Feb 07 |
jari |
1609 |
text = data.getElementAttribute(experiment.getGeneIndexMappedToData(i), geneLabelIndex); |
2 |
26 Feb 07 |
jari |
1610 |
} else if (geneOrExpt == COAGUI.EXPTS) { |
2 |
26 Feb 07 |
jari |
1611 |
text = data.getSampleName(experiment.getSampleIndex(i)); |
2 |
26 Feb 07 |
jari |
1612 |
} else if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1613 |
if (i < geneUMatrix.getRowDimension()) { |
2 |
26 Feb 07 |
jari |
1614 |
text = data.getElementAttribute(experiment.getGeneIndexMappedToData(i), geneLabelIndex); |
2 |
26 Feb 07 |
jari |
1615 |
} else { |
2 |
26 Feb 07 |
jari |
1616 |
text = data.getSampleName(experiment.getSampleIndex(i - geneUMatrix.getRowDimension())); |
2 |
26 Feb 07 |
jari |
1617 |
} |
2 |
26 Feb 07 |
jari |
1618 |
} |
2 |
26 Feb 07 |
jari |
//text = (mode == 1) ? data.getUniqueId(i) : data.getSampleName(experiment.getSampleIndex(i)); |
2 |
26 Feb 07 |
jari |
//text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (y-0.035f)*factorY*10f, z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
1621 |
text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (float)(y*factorY*10f - (float)ascent/2f), z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
1622 |
shape3d = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1623 |
shape3d.setGeometry(text3d); |
2 |
26 Feb 07 |
jari |
1624 |
shape3d.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
1625 |
tempGroup.addChild(shape3d); |
2 |
26 Feb 07 |
jari |
1626 |
textGroup.addChild(tempGroup); |
2 |
26 Feb 07 |
jari |
1627 |
} |
2 |
26 Feb 07 |
jari |
1628 |
return textGroup; |
2 |
26 Feb 07 |
jari |
1629 |
} |
2 |
26 Feb 07 |
jari |
1630 |
/* |
2 |
26 Feb 07 |
jari |
private TransformGroup createGeneTextFromBoth() { |
2 |
26 Feb 07 |
jari |
TransformGroup textGroup = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1633 |
|
2 |
26 Feb 07 |
jari |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1637 |
|
2 |
26 Feb 07 |
jari |
//Font3D font = new Font3D(new Font("TestFont", Font.BOLD, 1), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
Font3D font = new Font3D(new Font("TestFont", Font.BOLD, (int)(Math.round(getPointSize(false)))), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
Font origFont = font.getFont(); |
2 |
26 Feb 07 |
jari |
1641 |
|
2 |
26 Feb 07 |
jari |
FontMetrics fMet = onScreenCanvas.getFontMetrics(origFont); |
2 |
26 Feb 07 |
jari |
int ascent = fMet.getAscent(); |
2 |
26 Feb 07 |
jari |
1644 |
|
2 |
26 Feb 07 |
jari |
Color3f color3f; |
2 |
26 Feb 07 |
jari |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
color3f = new Color3f(1.0f, 1.0f, 1.0f); |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
color3f = new Color3f(0.0f, 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
1650 |
|
2 |
26 Feb 07 |
jari |
Material material; |
2 |
26 Feb 07 |
jari |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
material = new Material(color3f, whiteColor, color3f, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
material = new Material(color3f, blackColor, color3f, blackColor, 100f); |
2 |
26 Feb 07 |
jari |
1656 |
|
2 |
26 Feb 07 |
jari |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
//material.setLightingEnable(false); |
2 |
26 Feb 07 |
jari |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1661 |
|
2 |
26 Feb 07 |
jari |
Transform3D fontTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
fontTransform.setScale(0.1); |
2 |
26 Feb 07 |
jari |
1664 |
|
2 |
26 Feb 07 |
jari |
TransformGroup tempGroup; |
2 |
26 Feb 07 |
jari |
Text3D text3d; |
2 |
26 Feb 07 |
jari |
Shape3D shape3d; |
2 |
26 Feb 07 |
jari |
String text; |
2 |
26 Feb 07 |
jari |
float x, y, z; |
2 |
26 Feb 07 |
jari |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
tempGroup = new TransformGroup(fontTransform); |
2 |
26 Feb 07 |
jari |
text = ""; |
2 |
26 Feb 07 |
jari |
if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
if (i < geneUMatrix.getRowDimension()) { |
2 |
26 Feb 07 |
jari |
text = data.getElementAttribute(experiment.getGeneIndexMappedToData(i), geneLabelIndex); |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
text = ""; |
2 |
26 Feb 07 |
jari |
1684 |
} |
2 |
26 Feb 07 |
jari |
1685 |
} |
2 |
26 Feb 07 |
jari |
//text = (mode == 1) ? data.getUniqueId(i) : data.getSampleName(experiment.getSampleIndex(i)); |
2 |
26 Feb 07 |
jari |
//text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (y-0.035f)*factorY*10f, z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (float)(y*factorY*10f - (float)ascent/2f), z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
shape3d = new Shape3D(); |
2 |
26 Feb 07 |
jari |
shape3d.setGeometry(text3d); |
2 |
26 Feb 07 |
jari |
shape3d.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
tempGroup.addChild(shape3d); |
2 |
26 Feb 07 |
jari |
textGroup.addChild(tempGroup); |
2 |
26 Feb 07 |
jari |
1694 |
} |
2 |
26 Feb 07 |
jari |
return textGroup; |
2 |
26 Feb 07 |
jari |
1696 |
} |
2 |
26 Feb 07 |
jari |
1697 |
*/ |
2 |
26 Feb 07 |
jari |
1698 |
|
2 |
26 Feb 07 |
jari |
1699 |
/* |
2 |
26 Feb 07 |
jari |
private TransformGroup createSampleTextFromBoth() { |
2 |
26 Feb 07 |
jari |
TransformGroup textGroup = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1702 |
|
2 |
26 Feb 07 |
jari |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1706 |
|
2 |
26 Feb 07 |
jari |
//Font3D font = new Font3D(new Font("TestFont", Font.BOLD, 1), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
Font3D font = new Font3D(new Font("TestFont", Font.BOLD, (int)(Math.round(getPointSize(false)))), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
Font origFont = font.getFont(); |
2 |
26 Feb 07 |
jari |
1710 |
|
2 |
26 Feb 07 |
jari |
FontMetrics fMet = onScreenCanvas.getFontMetrics(origFont); |
2 |
26 Feb 07 |
jari |
int ascent = fMet.getAscent(); |
2 |
26 Feb 07 |
jari |
1713 |
|
2 |
26 Feb 07 |
jari |
Color3f color3f; |
2 |
26 Feb 07 |
jari |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
color3f = new Color3f(1.0f, 1.0f, 1.0f); |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
color3f = new Color3f(0.0f, 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
1719 |
|
2 |
26 Feb 07 |
jari |
Material material; |
2 |
26 Feb 07 |
jari |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
material = new Material(color3f, whiteColor, color3f, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
else |
2 |
26 Feb 07 |
jari |
material = new Material(color3f, blackColor, color3f, blackColor, 100f); |
2 |
26 Feb 07 |
jari |
1725 |
|
2 |
26 Feb 07 |
jari |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
//material.setLightingEnable(false); |
2 |
26 Feb 07 |
jari |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1730 |
|
2 |
26 Feb 07 |
jari |
Transform3D fontTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
fontTransform.setScale(0.1); |
2 |
26 Feb 07 |
jari |
1733 |
|
2 |
26 Feb 07 |
jari |
TransformGroup tempGroup; |
2 |
26 Feb 07 |
jari |
Text3D text3d; |
2 |
26 Feb 07 |
jari |
Shape3D shape3d; |
2 |
26 Feb 07 |
jari |
String text; |
2 |
26 Feb 07 |
jari |
float x, y, z; |
2 |
26 Feb 07 |
jari |
for (int i=0; i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
tempGroup = new TransformGroup(fontTransform); |
2 |
26 Feb 07 |
jari |
text = ""; |
2 |
26 Feb 07 |
jari |
if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
if (i < geneUMatrix.getRowDimension()) { |
2 |
26 Feb 07 |
jari |
text = ""; |
2 |
26 Feb 07 |
jari |
} else { |
2 |
26 Feb 07 |
jari |
text = data.getSampleName(experiment.getSampleIndex(i - geneUMatrix.getRowDimension())); |
2 |
26 Feb 07 |
jari |
1753 |
} |
2 |
26 Feb 07 |
jari |
1754 |
} |
2 |
26 Feb 07 |
jari |
//text = (mode == 1) ? data.getUniqueId(i) : data.getSampleName(experiment.getSampleIndex(i)); |
2 |
26 Feb 07 |
jari |
//text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (y-0.035f)*factorY*10f, z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (float)(y*factorY*10f - (float)ascent/2f), z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
shape3d = new Shape3D(); |
2 |
26 Feb 07 |
jari |
shape3d.setGeometry(text3d); |
2 |
26 Feb 07 |
jari |
shape3d.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
tempGroup.addChild(shape3d); |
2 |
26 Feb 07 |
jari |
textGroup.addChild(tempGroup); |
2 |
26 Feb 07 |
jari |
1763 |
} |
2 |
26 Feb 07 |
jari |
return textGroup; |
2 |
26 Feb 07 |
jari |
1765 |
} |
2 |
26 Feb 07 |
jari |
1766 |
*/ |
2 |
26 Feb 07 |
jari |
1767 |
|
2 |
26 Feb 07 |
jari |
1768 |
private TransformGroup createGeneTextFromBoth() { |
2 |
26 Feb 07 |
jari |
1769 |
TransformGroup textGroup = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1770 |
|
2 |
26 Feb 07 |
jari |
1771 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1772 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1773 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1774 |
|
2 |
26 Feb 07 |
jari |
//Font3D font = new Font3D(new Font("TestFont", Font.BOLD, 1), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1776 |
Font3D font = new Font3D(new Font("TestFont", Font.BOLD, (int)(Math.round(getPointSize(false)))), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1777 |
Font origFont = font.getFont(); |
2 |
26 Feb 07 |
jari |
1778 |
|
2 |
26 Feb 07 |
jari |
1779 |
FontMetrics fMet = onScreenCanvas.getFontMetrics(origFont); |
2 |
26 Feb 07 |
jari |
1780 |
int ascent = fMet.getAscent(); |
2 |
26 Feb 07 |
jari |
1781 |
|
2 |
26 Feb 07 |
jari |
1782 |
Color3f color3f; |
2 |
26 Feb 07 |
jari |
1783 |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
1784 |
color3f = new Color3f(1.0f, 1.0f, 1.0f); |
2 |
26 Feb 07 |
jari |
1785 |
else |
2 |
26 Feb 07 |
jari |
1786 |
color3f = new Color3f(0.0f, 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
1787 |
|
2 |
26 Feb 07 |
jari |
1788 |
Material material; |
2 |
26 Feb 07 |
jari |
1789 |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
1790 |
material = new Material(color3f, whiteColor, color3f, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
1791 |
else |
2 |
26 Feb 07 |
jari |
1792 |
material = new Material(color3f, blackColor, color3f, blackColor, 100f); |
2 |
26 Feb 07 |
jari |
1793 |
|
2 |
26 Feb 07 |
jari |
1794 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
//material.setLightingEnable(false); |
2 |
26 Feb 07 |
jari |
1796 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1797 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1798 |
|
2 |
26 Feb 07 |
jari |
1799 |
Transform3D fontTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1800 |
fontTransform.setScale(0.1); |
2 |
26 Feb 07 |
jari |
1801 |
|
2 |
26 Feb 07 |
jari |
1802 |
TransformGroup tempGroup; |
2 |
26 Feb 07 |
jari |
1803 |
Text3D text3d; |
2 |
26 Feb 07 |
jari |
1804 |
Shape3D shape3d; |
2 |
26 Feb 07 |
jari |
1805 |
String text; |
2 |
26 Feb 07 |
jari |
1806 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1807 |
for (int i=0; i<geneUMatrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1811 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1812 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1813 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1814 |
tempGroup = new TransformGroup(fontTransform); |
2 |
26 Feb 07 |
jari |
1815 |
text = ""; |
2 |
26 Feb 07 |
jari |
1816 |
if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1817 |
text = data.getElementAttribute(experiment.getGeneIndexMappedToData(i), geneLabelIndex); |
2 |
26 Feb 07 |
jari |
1818 |
} |
2 |
26 Feb 07 |
jari |
//text = (mode == 1) ? data.getUniqueId(i) : data.getSampleName(experiment.getSampleIndex(i)); |
2 |
26 Feb 07 |
jari |
//text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (y-0.035f)*factorY*10f, z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
1821 |
text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (float)(y*factorY*10f - (float)ascent/2f), z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
1822 |
shape3d = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1823 |
shape3d.setGeometry(text3d); |
2 |
26 Feb 07 |
jari |
1824 |
shape3d.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
1825 |
tempGroup.addChild(shape3d); |
2 |
26 Feb 07 |
jari |
1826 |
textGroup.addChild(tempGroup); |
2 |
26 Feb 07 |
jari |
1827 |
} |
2 |
26 Feb 07 |
jari |
1828 |
return textGroup; |
2 |
26 Feb 07 |
jari |
1829 |
} |
2 |
26 Feb 07 |
jari |
1830 |
|
2 |
26 Feb 07 |
jari |
1831 |
private TransformGroup createSampleTextFromBoth() { |
2 |
26 Feb 07 |
jari |
1832 |
TransformGroup textGroup = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1833 |
|
2 |
26 Feb 07 |
jari |
1834 |
float factorX = 3f/scaleAxisX; |
2 |
26 Feb 07 |
jari |
1835 |
float factorY = 3f/scaleAxisY; |
2 |
26 Feb 07 |
jari |
1836 |
float factorZ = 3f/scaleAxisZ; |
2 |
26 Feb 07 |
jari |
1837 |
|
2 |
26 Feb 07 |
jari |
//Font3D font = new Font3D(new Font("TestFont", Font.BOLD, 1), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1839 |
Font3D font = new Font3D(new Font("TestFont", Font.BOLD, (int)(Math.round(getPointSize(false)))), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1840 |
Font origFont = font.getFont(); |
2 |
26 Feb 07 |
jari |
1841 |
|
2 |
26 Feb 07 |
jari |
1842 |
FontMetrics fMet = onScreenCanvas.getFontMetrics(origFont); |
2 |
26 Feb 07 |
jari |
1843 |
int ascent = fMet.getAscent(); |
2 |
26 Feb 07 |
jari |
1844 |
|
2 |
26 Feb 07 |
jari |
1845 |
Color3f color3f; |
2 |
26 Feb 07 |
jari |
1846 |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
1847 |
color3f = new Color3f(1.0f, 1.0f, 1.0f); |
2 |
26 Feb 07 |
jari |
1848 |
else |
2 |
26 Feb 07 |
jari |
1849 |
color3f = new Color3f(0.0f, 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
1850 |
|
2 |
26 Feb 07 |
jari |
1851 |
Material material; |
2 |
26 Feb 07 |
jari |
1852 |
if(!this.whiteBackground) |
2 |
26 Feb 07 |
jari |
1853 |
material = new Material(color3f, whiteColor, color3f, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
1854 |
else |
2 |
26 Feb 07 |
jari |
1855 |
material = new Material(color3f, blackColor, color3f, blackColor, 100f); |
2 |
26 Feb 07 |
jari |
1856 |
|
2 |
26 Feb 07 |
jari |
1857 |
material.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
//material.setLightingEnable(false); |
2 |
26 Feb 07 |
jari |
1859 |
Appearance appearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1860 |
appearance.setMaterial(material); |
2 |
26 Feb 07 |
jari |
1861 |
|
2 |
26 Feb 07 |
jari |
1862 |
Transform3D fontTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1863 |
fontTransform.setScale(0.1); |
2 |
26 Feb 07 |
jari |
1864 |
|
2 |
26 Feb 07 |
jari |
1865 |
TransformGroup tempGroup; |
2 |
26 Feb 07 |
jari |
1866 |
Text3D text3d; |
2 |
26 Feb 07 |
jari |
1867 |
Shape3D shape3d; |
2 |
26 Feb 07 |
jari |
1868 |
String text; |
2 |
26 Feb 07 |
jari |
1869 |
float x, y, z; |
2 |
26 Feb 07 |
jari |
1870 |
for (int i=geneUMatrix.getRowDimension(); i<U.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
//x = U.get(i,0); |
2 |
26 Feb 07 |
jari |
//y = U.get(i,1); |
2 |
26 Feb 07 |
jari |
//z = U.get(i,2); |
2 |
26 Feb 07 |
jari |
1874 |
x = U.get(i,xAxis); |
2 |
26 Feb 07 |
jari |
1875 |
y = U.get(i,yAxis); |
2 |
26 Feb 07 |
jari |
1876 |
z = U.get(i,zAxis); |
2 |
26 Feb 07 |
jari |
1877 |
tempGroup = new TransformGroup(fontTransform); |
2 |
26 Feb 07 |
jari |
1878 |
text = ""; |
2 |
26 Feb 07 |
jari |
1879 |
if (geneOrExpt == COAGUI.BOTH) { |
2 |
26 Feb 07 |
jari |
1880 |
text = data.getSampleName(experiment.getSampleIndex(i - geneUMatrix.getRowDimension())); |
2 |
26 Feb 07 |
jari |
1881 |
} |
2 |
26 Feb 07 |
jari |
//text = (mode == 1) ? data.getUniqueId(i) : data.getSampleName(experiment.getSampleIndex(i)); |
2 |
26 Feb 07 |
jari |
//text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (y-0.035f)*factorY*10f, z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
1884 |
text3d = new Text3D(font, text, new Point3f(x*factorX*10f+getPointSize(isPointSelected(x, y, z)), (float)(y*factorY*10f - (float)ascent/2f), z*factorZ*10f)); |
2 |
26 Feb 07 |
jari |
1885 |
shape3d = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1886 |
shape3d.setGeometry(text3d); |
2 |
26 Feb 07 |
jari |
1887 |
shape3d.setAppearance(appearance); |
2 |
26 Feb 07 |
jari |
1888 |
tempGroup.addChild(shape3d); |
2 |
26 Feb 07 |
jari |
1889 |
textGroup.addChild(tempGroup); |
2 |
26 Feb 07 |
jari |
1890 |
} |
2 |
26 Feb 07 |
jari |
1891 |
return textGroup; |
2 |
26 Feb 07 |
jari |
1892 |
} |
2 |
26 Feb 07 |
jari |
1893 |
|
2 |
26 Feb 07 |
jari |
1894 |
/** |
2 |
26 Feb 07 |
jari |
* Creates 3D shape for specified string. |
2 |
26 Feb 07 |
jari |
1896 |
*/ |
2 |
26 Feb 07 |
jari |
1897 |
private Shape3D createTextShape3D(String text) { |
2 |
26 Feb 07 |
jari |
1898 |
Font3D axisFont = new Font3D(new Font("TestFont", Font.BOLD, 1), new FontExtrusion()); |
2 |
26 Feb 07 |
jari |
1899 |
Text3D text3D = new Text3D(axisFont, text); |
2 |
26 Feb 07 |
jari |
1900 |
Shape3D shape = new Shape3D(); |
2 |
26 Feb 07 |
jari |
1901 |
shape.setGeometry(text3D); |
2 |
26 Feb 07 |
jari |
1902 |
Color3f color3f; |
2 |
26 Feb 07 |
jari |
1903 |
Material axisFontMaterial; |
2 |
26 Feb 07 |
jari |
1904 |
if(!whiteBackground){ |
2 |
26 Feb 07 |
jari |
1905 |
color3f = new Color3f(0.5f, 0.5f, 0.5f); |
2 |
26 Feb 07 |
jari |
1906 |
axisFontMaterial = new Material(color3f, blackColor, color3f, whiteColor, 100f); |
2 |
26 Feb 07 |
jari |
1907 |
} |
2 |
26 Feb 07 |
jari |
1908 |
else{ |
2 |
26 Feb 07 |
jari |
1909 |
color3f = new Color3f(0.0f, 0.0f, 0.0f); |
2 |
26 Feb 07 |
jari |
1910 |
axisFontMaterial = new Material(color3f, blackColor, color3f, blackColor, 100f); |
2 |
26 Feb 07 |
jari |
1911 |
} |
2 |
26 Feb 07 |
jari |
1912 |
axisFontMaterial.setLightingEnable(true); |
2 |
26 Feb 07 |
jari |
1913 |
Appearance axisFontAppearance = new Appearance(); |
2 |
26 Feb 07 |
jari |
1914 |
axisFontAppearance.setMaterial(axisFontMaterial); |
2 |
26 Feb 07 |
jari |
1915 |
shape.setAppearance(axisFontAppearance); |
2 |
26 Feb 07 |
jari |
1916 |
return shape; |
2 |
26 Feb 07 |
jari |
1917 |
} |
2 |
26 Feb 07 |
jari |
1918 |
|
2 |
26 Feb 07 |
jari |
1919 |
/** |
2 |
26 Feb 07 |
jari |
* Creates x-axis transform group. |
2 |
26 Feb 07 |
jari |
1921 |
*/ |
2 |
26 Feb 07 |
jari |
1922 |
private TransformGroup createXAxis() { |
2 |
26 Feb 07 |
jari |
1923 |
Transform3D axisTrans = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1924 |
axisTrans.rotZ(-Math.PI/2.0d); |
2 |
26 Feb 07 |
jari |
1925 |
Transform3D fontTrans = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1926 |
fontTrans.rotZ(Math.PI/2.0d); |
2 |
26 Feb 07 |
jari |
1927 |
|
2 |
26 Feb 07 |
jari |
1928 |
if(!whiteBackground) |
2 |
26 Feb 07 |
jari |
1929 |
return createAxis("" + (xAxis + 1), new Color3f(0.5f, 0.5f, 0.5f), axisTrans, fontTrans); |
2 |
26 Feb 07 |
jari |
1930 |
else |
2 |
26 Feb 07 |
jari |
1931 |
return createAxis("" + (xAxis + 1), new Color3f(0.0f, 0.0f, 0.0f), axisTrans, fontTrans); |
2 |
26 Feb 07 |
jari |
1932 |
} |
2 |
26 Feb 07 |
jari |
1933 |
|
2 |
26 Feb 07 |
jari |
1934 |
/** |
2 |
26 Feb 07 |
jari |
* Creates y-axis transform group. |
2 |
26 Feb 07 |
jari |
1936 |
*/ |
2 |
26 Feb 07 |
jari |
1937 |
private TransformGroup createYAxis() { |
2 |
26 Feb 07 |
jari |
1938 |
|
2 |
26 Feb 07 |
jari |
1939 |
if(!whiteBackground) |
2 |
26 Feb 07 |
jari |
1940 |
return createAxis("" + (yAxis + 1), new Color3f(0.3f, 0.3f, 1f), null, null); |
2 |
26 Feb 07 |
jari |
1941 |
else |
2 |
26 Feb 07 |
jari |
1942 |
return createAxis("" + (yAxis + 1), new Color3f(0.0f, 0.0f, 0.0f), null, null); |
2 |
26 Feb 07 |
jari |
1943 |
} |
2 |
26 Feb 07 |
jari |
1944 |
|
2 |
26 Feb 07 |
jari |
1945 |
/** |
2 |
26 Feb 07 |
jari |
* Creates z-axis transform group. |
2 |
26 Feb 07 |
jari |
1947 |
*/ |
2 |
26 Feb 07 |
jari |
1948 |
private TransformGroup createZAxis() { |
2 |
26 Feb 07 |
jari |
1949 |
Transform3D axisTrans = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1950 |
axisTrans.rotX(-Math.PI/2.0d); |
2 |
26 Feb 07 |
jari |
1951 |
Transform3D zTrans = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1952 |
zTrans.rotY(Math.PI/2.0d); |
2 |
26 Feb 07 |
jari |
1953 |
axisTrans.mul(zTrans); |
2 |
26 Feb 07 |
jari |
1954 |
Transform3D fontTrans = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1955 |
fontTrans.rotZ(Math.PI/2.0d); |
2 |
26 Feb 07 |
jari |
1956 |
if(!whiteBackground) |
2 |
26 Feb 07 |
jari |
1957 |
return createAxis("" + (zAxis + 1), new Color3f(1f, 0.3f, 1f), axisTrans, fontTrans); |
2 |
26 Feb 07 |
jari |
1958 |
else |
2 |
26 Feb 07 |
jari |
1959 |
return createAxis("" + (zAxis + 1), new Color3f(0.0f, 0.0f, 0.0f), axisTrans, fontTrans); |
2 |
26 Feb 07 |
jari |
1960 |
} |
2 |
26 Feb 07 |
jari |
1961 |
|
2 |
26 Feb 07 |
jari |
1962 |
/** |
2 |
26 Feb 07 |
jari |
* Creates an axis transform group. |
2 |
26 Feb 07 |
jari |
1964 |
*/ |
2 |
26 Feb 07 |
jari |
1965 |
private TransformGroup createAxis(String name, Color3f color, Transform3D axisTrans, Transform3D fontTrans) { |
2 |
26 Feb 07 |
jari |
1966 |
TransformGroup axis = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1967 |
if (axisTrans != null) { |
2 |
26 Feb 07 |
jari |
1968 |
axis.setTransform(axisTrans); |
2 |
26 Feb 07 |
jari |
1969 |
} |
2 |
26 Feb 07 |
jari |
1970 |
axis.addChild(createCylinder(color)); |
2 |
26 Feb 07 |
jari |
// Axis Positive End |
2 |
26 Feb 07 |
jari |
1972 |
Transform3D posTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1973 |
posTransform.set(new Vector3d(0.0, 3.1, 0.0)); |
2 |
26 Feb 07 |
jari |
1974 |
TransformGroup posEnd = new TransformGroup(posTransform); |
2 |
26 Feb 07 |
jari |
1975 |
posEnd.addChild(createCone()); |
2 |
26 Feb 07 |
jari |
// Axis Negative End |
2 |
26 Feb 07 |
jari |
1977 |
Transform3D negTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1978 |
negTransform.set(new Vector3d(0.0, -3.1, 0.0)); |
2 |
26 Feb 07 |
jari |
1979 |
Transform3D rotate180X = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1980 |
rotate180X.rotX(Math.PI); |
2 |
26 Feb 07 |
jari |
1981 |
negTransform.mul(rotate180X); |
2 |
26 Feb 07 |
jari |
1982 |
TransformGroup negEnd = new TransformGroup(negTransform); |
2 |
26 Feb 07 |
jari |
1983 |
negEnd.addChild(createCone()); |
2 |
26 Feb 07 |
jari |
// Font |
2 |
26 Feb 07 |
jari |
1985 |
Transform3D fontTransform = new Transform3D(); |
2 |
26 Feb 07 |
jari |
1986 |
fontTransform.set(0.22, new Vector3d(0.25, 2.75, -0.0125)); |
2 |
26 Feb 07 |
jari |
1987 |
TransformGroup fontGroup = new TransformGroup(fontTransform); |
2 |
26 Feb 07 |
jari |
1988 |
|
2 |
26 Feb 07 |
jari |
1989 |
TransformGroup rotFontGroup = new TransformGroup(); |
2 |
26 Feb 07 |
jari |
1990 |
if (fontTrans != null) { |
2 |
26 Feb 07 |
jari |
1991 |
rotFontGroup.setTransform(fontTrans); |
2 |
26 Feb 07 |
jari |
1992 |
} |
2 |
26 Feb 07 |
jari |
1993 |
|
2 |
26 Feb 07 |
jari |
1994 |
Shape3D shape3D = createTextShape3D(name); |
2 |
26 Feb 07 |
jari |
1995 |
rotFontGroup.addChild(shape3D); |
2 |
26 Feb 07 |
jari |
1996 |
|
2 |
26 Feb 07 |
jari |
1997 |
fontGroup.addChild(rotFontGroup); |
2 |
26 Feb 07 |
jari |
1998 |
|
2 |
26 Feb 07 |
jari |
1999 |
axis.addChild(fontGroup); |
2 |
26 Feb 07 |
jari |
2000 |
axis.addChild(posEnd); |
2 |
26 Feb 07 |
jari |
2001 |
axis.addChild(negEnd); |
2 |
26 Feb 07 |
jari |
2002 |
return axis; |
2 |
26 Feb 07 |
jari |
2003 |
} |
2 |
26 Feb 07 |
jari |
2004 |
|
2 |
26 Feb 07 |
jari |
2005 |
} |