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 |
* $RCSfile: DAM3DViewer.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.3 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/05/02 16:56:57 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev.cluster.gui.impl.dam; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Component; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
19 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.JCheckBoxMenuItem; |
2 |
26 Feb 07 |
jari |
22 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
23 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
24 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
25 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
import org.tigr.microarray.mev.cluster.clusterUtil.Cluster; |
2 |
26 Feb 07 |
jari |
28 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
29 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
30 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
32 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentUtil; |
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.impl.ViewerAdapter; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
public class DAM3DViewer extends ViewerAdapter implements IViewer { |
2 |
26 Feb 07 |
jari |
38 |
|
2 |
26 Feb 07 |
jari |
39 |
private static final String RESET_CMD = "reset-cmd"; |
2 |
26 Feb 07 |
jari |
40 |
private static final String OPTIONS_CMD = "options-cmd"; |
2 |
26 Feb 07 |
jari |
41 |
private static final String SELECTION_AREA_CMD = "select-cmd"; |
2 |
26 Feb 07 |
jari |
42 |
private static final String SAVE_CMD = "save-cmd"; |
2 |
26 Feb 07 |
jari |
43 |
private static final String SHOW_SELECTION_CMD = "show-selection-cmd"; |
2 |
26 Feb 07 |
jari |
44 |
private static final String HIDE_SELECTION_BOX_CMD = "hide-selection-box-cmd"; |
2 |
26 Feb 07 |
jari |
45 |
private static final String SHOW_SPHERES_CMD = "show-spheres-cmd"; |
2 |
26 Feb 07 |
jari |
46 |
private static final String SHOW_TEXT_CMD = "show-text-cmd"; |
2 |
26 Feb 07 |
jari |
47 |
private static final String WHITE_CMD = "white-cmd"; |
2 |
26 Feb 07 |
jari |
48 |
private static final String STORE_CLUSTER_CMD = "store-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
49 |
private static final String LAUNCH_NEW_SESSION_CMD = "launch-new-session-cmd"; |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
private IData data; |
2 |
26 Feb 07 |
jari |
52 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
53 |
private Content3D content; |
2 |
26 Feb 07 |
jari |
54 |
private JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
55 |
private Frame frame; |
2 |
26 Feb 07 |
jari |
56 |
private boolean geneViewer; |
2 |
26 Feb 07 |
jari |
57 |
private IFramework framework; |
2 |
26 Feb 07 |
jari |
58 |
|
2 |
26 Feb 07 |
jari |
59 |
private FloatMatrix matrix3D; |
2 |
26 Feb 07 |
jari |
60 |
private int mode; |
2 |
26 Feb 07 |
jari |
61 |
private int exptID = 0; |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
63 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>DAM3DViewer</code> with specified mode, |
2 |
26 Feb 07 |
jari |
* U-matrix and an experiment data. |
2 |
26 Feb 07 |
jari |
66 |
*/ |
2 |
26 Feb 07 |
jari |
67 |
public DAM3DViewer(Frame frame, int mode, FloatMatrix matrix3D, Experiment experiment, boolean geneViewer) { |
2 |
26 Feb 07 |
jari |
68 |
this.frame = frame; |
2 |
26 Feb 07 |
jari |
69 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
70 |
this.exptID = experiment.getId(); |
2 |
26 Feb 07 |
jari |
71 |
this.geneViewer = geneViewer; |
2 |
26 Feb 07 |
jari |
72 |
this.mode = mode; |
2 |
26 Feb 07 |
jari |
73 |
this.matrix3D = matrix3D; |
2 |
26 Feb 07 |
jari |
74 |
content = createContent(mode, matrix3D, experiment, geneViewer); |
2 |
26 Feb 07 |
jari |
75 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
76 |
} |
2 |
26 Feb 07 |
jari |
77 |
|
2 |
26 Feb 07 |
jari |
78 |
public DAM3DViewer(int mode, FloatMatrix matrix3D, boolean geneViewer, Experiment e) { |
2 |
26 Feb 07 |
jari |
79 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
80 |
this.mode = mode; |
2 |
26 Feb 07 |
jari |
81 |
this.geneViewer = geneViewer; |
2 |
26 Feb 07 |
jari |
82 |
this.matrix3D = matrix3D; |
2 |
26 Feb 07 |
jari |
83 |
this.content = createContent(mode, matrix3D, experiment, geneViewer); |
2 |
26 Feb 07 |
jari |
84 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
85 |
} |
2 |
26 Feb 07 |
jari |
86 |
public Expression getExpression(){ |
2 |
26 Feb 07 |
jari |
87 |
return new Expression(this, this.getClass(), "new", |
2 |
26 Feb 07 |
jari |
88 |
new Object[]{new Integer(this.mode), matrix3D, new Boolean(geneViewer), this.experiment}); |
2 |
26 Feb 07 |
jari |
89 |
} |
2 |
26 Feb 07 |
jari |
90 |
public void setExperiment(Experiment e){ |
2 |
26 Feb 07 |
jari |
91 |
this.experiment = e; |
2 |
26 Feb 07 |
jari |
92 |
this.exptID = e.getId(); |
2 |
26 Feb 07 |
jari |
93 |
this.content = createContent(mode, matrix3D, experiment, geneViewer); |
2 |
26 Feb 07 |
jari |
94 |
popup = createJPopupMenu(); |
2 |
26 Feb 07 |
jari |
95 |
} |
2 |
26 Feb 07 |
jari |
96 |
public int getExperimentID(){return exptID;} |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
|
2 |
26 Feb 07 |
jari |
101 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer data and its content. |
2 |
26 Feb 07 |
jari |
103 |
*/ |
2 |
26 Feb 07 |
jari |
104 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
105 |
this.framework = framework; |
2 |
26 Feb 07 |
jari |
106 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
107 |
content.setData(this.data); |
2 |
26 Feb 07 |
jari |
108 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
109 |
} |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
/** |
2 |
26 Feb 07 |
jari |
* Updates the viewer data and its content. |
2 |
26 Feb 07 |
jari |
113 |
*/ |
2 |
26 Feb 07 |
jari |
114 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
115 |
this.data = data; |
2 |
26 Feb 07 |
jari |
116 |
content.setData(data); |
2 |
26 Feb 07 |
jari |
117 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
118 |
} |
2 |
26 Feb 07 |
jari |
119 |
|
2 |
26 Feb 07 |
jari |
120 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a content of the viewer. |
2 |
26 Feb 07 |
jari |
122 |
*/ |
2 |
26 Feb 07 |
jari |
123 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
124 |
return content; |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a content image. |
2 |
26 Feb 07 |
jari |
129 |
*/ |
2 |
26 Feb 07 |
jari |
130 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
131 |
return content.createImage(); |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a 3D content with specified mode, u-matrix and experiment. |
2 |
26 Feb 07 |
jari |
136 |
*/ |
2 |
26 Feb 07 |
jari |
137 |
private Content3D createContent(int mode, FloatMatrix matrix3D, Experiment experiment, boolean geneViewer) { |
2 |
26 Feb 07 |
jari |
138 |
return new Content3D(mode, matrix3D, experiment, geneViewer); |
2 |
26 Feb 07 |
jari |
139 |
} |
2 |
26 Feb 07 |
jari |
140 |
|
2 |
26 Feb 07 |
jari |
141 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the viewer popup menu. |
2 |
26 Feb 07 |
jari |
143 |
*/ |
2 |
26 Feb 07 |
jari |
144 |
public JPopupMenu getJPopupMenu() { |
2 |
26 Feb 07 |
jari |
145 |
return popup; |
2 |
26 Feb 07 |
jari |
146 |
} |
2 |
26 Feb 07 |
jari |
147 |
|
2 |
26 Feb 07 |
jari |
148 |
/** |
2 |
26 Feb 07 |
jari |
* Creates the viewer popup menu. |
2 |
26 Feb 07 |
jari |
150 |
*/ |
2 |
26 Feb 07 |
jari |
151 |
private JPopupMenu createJPopupMenu() { |
2 |
26 Feb 07 |
jari |
152 |
JPopupMenu popup = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
153 |
addMenuItems(popup); |
2 |
26 Feb 07 |
jari |
154 |
return popup; |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
/** |
2 |
26 Feb 07 |
jari |
* Adds the viewer specific menu items. |
2 |
26 Feb 07 |
jari |
159 |
*/ |
2 |
26 Feb 07 |
jari |
160 |
private void addMenuItems(JPopupMenu menu) { |
2 |
26 Feb 07 |
jari |
161 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
162 |
JMenuItem menuItem; |
2 |
26 Feb 07 |
jari |
163 |
menuItem = new JMenuItem("Reset", GUIFactory.getIcon("refresh16.gif")); |
2 |
26 Feb 07 |
jari |
164 |
menuItem.setActionCommand(RESET_CMD); |
2 |
26 Feb 07 |
jari |
165 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
166 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
167 |
|
2 |
26 Feb 07 |
jari |
168 |
menuItem = new JMenuItem("Options...", GUIFactory.getIcon("edit16.gif")); |
2 |
26 Feb 07 |
jari |
169 |
menuItem.setActionCommand(OPTIONS_CMD); |
2 |
26 Feb 07 |
jari |
170 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
171 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
menuItem = new JMenuItem("Selection area...", GUIFactory.getIcon("edit16.gif")); |
2 |
26 Feb 07 |
jari |
176 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
177 |
menuItem.setActionCommand(SELECTION_AREA_CMD); |
2 |
26 Feb 07 |
jari |
178 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
179 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
180 |
|
2 |
26 Feb 07 |
jari |
181 |
menuItem = new JMenuItem("Store cluster...", GUIFactory.getIcon("new16.gif")); |
2 |
26 Feb 07 |
jari |
182 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
183 |
menuItem.setActionCommand(STORE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
184 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
185 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
186 |
|
2 |
26 Feb 07 |
jari |
187 |
menuItem = new JMenuItem("Launch new session", GUIFactory.getIcon("launch_new_mav.gif")); |
2 |
26 Feb 07 |
jari |
188 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
189 |
menuItem.setActionCommand(LAUNCH_NEW_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
190 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
191 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
192 |
|
2 |
26 Feb 07 |
jari |
193 |
menuItem = new JMenuItem("Save cluster...", GUIFactory.getIcon("save16.gif")); |
2 |
26 Feb 07 |
jari |
194 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
195 |
menuItem.setActionCommand(SAVE_CMD); |
2 |
26 Feb 07 |
jari |
196 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
197 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
198 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
199 |
|
2 |
26 Feb 07 |
jari |
200 |
menuItem = new JCheckBoxMenuItem("Show selection area"); |
2 |
26 Feb 07 |
jari |
201 |
menuItem.setActionCommand(SHOW_SELECTION_CMD); |
2 |
26 Feb 07 |
jari |
202 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
203 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
204 |
|
2 |
26 Feb 07 |
jari |
205 |
menuItem = new JCheckBoxMenuItem("Hide selection box"); |
2 |
26 Feb 07 |
jari |
206 |
menuItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
207 |
menuItem.setActionCommand(HIDE_SELECTION_BOX_CMD); |
2 |
26 Feb 07 |
jari |
208 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
209 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
210 |
|
2 |
26 Feb 07 |
jari |
211 |
menuItem = new JCheckBoxMenuItem("Show spheres"); |
2 |
26 Feb 07 |
jari |
212 |
menuItem.setActionCommand(SHOW_SPHERES_CMD); |
2 |
26 Feb 07 |
jari |
213 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
214 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
216 |
menuItem = new JCheckBoxMenuItem("Show text"); |
2 |
26 Feb 07 |
jari |
217 |
menuItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
218 |
menuItem.setActionCommand(SHOW_TEXT_CMD); |
2 |
26 Feb 07 |
jari |
219 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
220 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
221 |
|
2 |
26 Feb 07 |
jari |
222 |
menuItem = new JCheckBoxMenuItem("White background"); |
2 |
26 Feb 07 |
jari |
223 |
menuItem.setActionCommand(WHITE_CMD); |
2 |
26 Feb 07 |
jari |
224 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
225 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
226 |
} |
2 |
26 Feb 07 |
jari |
227 |
|
2 |
26 Feb 07 |
jari |
228 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a menu item by specified action command. |
2 |
26 Feb 07 |
jari |
230 |
*/ |
2 |
26 Feb 07 |
jari |
231 |
private JMenuItem getJMenuItem(String command) { |
2 |
26 Feb 07 |
jari |
232 |
JMenuItem item; |
2 |
26 Feb 07 |
jari |
233 |
Component[] components = popup.getComponents(); |
2 |
26 Feb 07 |
jari |
234 |
for (int i=0; i<components.length; i++) { |
2 |
26 Feb 07 |
jari |
235 |
if (components[i] instanceof JMenuItem) { |
2 |
26 Feb 07 |
jari |
236 |
if (((JMenuItem)components[i]).getActionCommand().equals(command)) |
2 |
26 Feb 07 |
jari |
237 |
return(JMenuItem)components[i]; |
2 |
26 Feb 07 |
jari |
238 |
} |
2 |
26 Feb 07 |
jari |
239 |
} |
2 |
26 Feb 07 |
jari |
240 |
return null; |
2 |
26 Feb 07 |
jari |
241 |
} |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a menu item state. |
2 |
26 Feb 07 |
jari |
245 |
*/ |
2 |
26 Feb 07 |
jari |
246 |
private void setEnableMenuItem(String command, boolean enable) { |
2 |
26 Feb 07 |
jari |
247 |
JMenuItem item = getJMenuItem(command); |
2 |
26 Feb 07 |
jari |
248 |
if (item == null) { |
2 |
26 Feb 07 |
jari |
249 |
return; |
2 |
26 Feb 07 |
jari |
250 |
} |
2 |
26 Feb 07 |
jari |
251 |
item.setEnabled(enable); |
2 |
26 Feb 07 |
jari |
252 |
} |
2 |
26 Feb 07 |
jari |
253 |
|
2 |
26 Feb 07 |
jari |
254 |
/** |
2 |
26 Feb 07 |
jari |
* Reset the viewer content. |
2 |
26 Feb 07 |
jari |
256 |
*/ |
2 |
26 Feb 07 |
jari |
257 |
private void onReset() { |
2 |
26 Feb 07 |
jari |
258 |
content.reset(); |
2 |
26 Feb 07 |
jari |
259 |
} |
2 |
26 Feb 07 |
jari |
260 |
|
2 |
26 Feb 07 |
jari |
261 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the user specified content parameters. |
2 |
26 Feb 07 |
jari |
263 |
*/ |
2 |
26 Feb 07 |
jari |
264 |
private void onOptions() { |
2 |
26 Feb 07 |
jari |
265 |
DAMResultConfigDialog dlg = new DAMResultConfigDialog(frame, |
2 |
26 Feb 07 |
jari |
266 |
content.getPointSize(), content.getSelectedPointSize(), |
2 |
26 Feb 07 |
jari |
267 |
content.getScaleAxisX(), content.getScaleAxisY(), content.getScaleAxisZ()); |
2 |
26 Feb 07 |
jari |
268 |
if (dlg.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
269 |
content.setPointSize(dlg.getPointSize()); |
2 |
26 Feb 07 |
jari |
270 |
content.setSelectedPointSize(dlg.getSelectedPointSize()); |
2 |
26 Feb 07 |
jari |
271 |
content.setScale(dlg.getScaleAxisX(), dlg.getScaleAxisY(), dlg.getScaleAxisZ()); |
2 |
26 Feb 07 |
jari |
272 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
273 |
} |
2 |
26 Feb 07 |
jari |
274 |
} |
2 |
26 Feb 07 |
jari |
275 |
|
2 |
26 Feb 07 |
jari |
276 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the user specified selection area parameters. |
2 |
26 Feb 07 |
jari |
278 |
*/ |
2 |
26 Feb 07 |
jari |
279 |
private void onSelectionArea() { |
2 |
26 Feb 07 |
jari |
280 |
DAMSelectionAreaDialog dlg = new DAMSelectionAreaDialog(frame, |
2 |
26 Feb 07 |
jari |
281 |
content.getPositionX(), content.getPositionY(), content.getPositionZ(), |
2 |
26 Feb 07 |
jari |
282 |
content.getSizeX(), content.getSizeY(), content.getSizeZ()); |
2 |
26 Feb 07 |
jari |
283 |
if (dlg.showModal() == JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
284 |
content.setBoxPosition(dlg.getPositionX(), dlg.getPositionY(), dlg.getPositionZ()); |
2 |
26 Feb 07 |
jari |
285 |
content.setBoxSize(dlg.getSizeX(), dlg.getSizeY(), dlg.getSizeZ()); |
2 |
26 Feb 07 |
jari |
286 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
287 |
} |
2 |
26 Feb 07 |
jari |
288 |
} |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
/** |
2 |
26 Feb 07 |
jari |
* Saves selected genes. |
2 |
26 Feb 07 |
jari |
292 |
*/ |
2 |
26 Feb 07 |
jari |
293 |
private void onSave() { |
2 |
26 Feb 07 |
jari |
294 |
try { |
2 |
26 Feb 07 |
jari |
295 |
if(geneViewer) |
2 |
26 Feb 07 |
jari |
296 |
ExperimentUtil.saveExperiment(frame, experiment, data, content.getSelectedGenes()); |
2 |
26 Feb 07 |
jari |
297 |
else |
2 |
26 Feb 07 |
jari |
298 |
ExperimentUtil.saveExperimentCluster(frame, experiment, data, content.getSelectedGenes()); |
2 |
26 Feb 07 |
jari |
299 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
300 |
JOptionPane.showMessageDialog(frame, "Can not save matrix!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
301 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
302 |
} |
2 |
26 Feb 07 |
jari |
303 |
} |
2 |
26 Feb 07 |
jari |
304 |
|
2 |
26 Feb 07 |
jari |
305 |
/** |
2 |
26 Feb 07 |
jari |
* Stores the selected cluster |
2 |
26 Feb 07 |
jari |
307 |
*/ |
2 |
26 Feb 07 |
jari |
308 |
private void storeCluster(){ |
2 |
26 Feb 07 |
jari |
309 |
if(geneViewer) |
2 |
26 Feb 07 |
jari |
310 |
framework.storeCluster( content.getSelectedGenes(), experiment, Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
311 |
else |
2 |
26 Feb 07 |
jari |
312 |
framework.storeCluster( content.getSelectedGenes(), experiment, Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
313 |
content.setSelection(false); |
2 |
26 Feb 07 |
jari |
314 |
onHideSelection(); |
2 |
26 Feb 07 |
jari |
315 |
this.onDataChanged(this.data); |
2 |
26 Feb 07 |
jari |
316 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
317 |
|
2 |
26 Feb 07 |
jari |
318 |
} |
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
|
2 |
26 Feb 07 |
jari |
321 |
/** |
2 |
26 Feb 07 |
jari |
* Launches a new MultipleArrayViewer using selected elements |
2 |
26 Feb 07 |
jari |
323 |
*/ |
2 |
26 Feb 07 |
jari |
324 |
private void launchNewSession(){ |
2 |
26 Feb 07 |
jari |
325 |
if(geneViewer) |
2 |
26 Feb 07 |
jari |
326 |
framework.launchNewMAV(content.getSelectedGenes(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.GENE_CLUSTER); |
2 |
26 Feb 07 |
jari |
327 |
else |
2 |
26 Feb 07 |
jari |
328 |
framework.launchNewMAV(content.getSelectedGenes(), this.experiment, "Multiple Experiment Viewer - Cluster Viewer", Cluster.EXPERIMENT_CLUSTER); |
2 |
26 Feb 07 |
jari |
329 |
} |
2 |
26 Feb 07 |
jari |
330 |
|
2 |
26 Feb 07 |
jari |
331 |
/** |
2 |
26 Feb 07 |
jari |
* Handles the selection box state. |
2 |
26 Feb 07 |
jari |
333 |
*/ |
2 |
26 Feb 07 |
jari |
334 |
private void onShowSelection() { |
2 |
26 Feb 07 |
jari |
335 |
JMenuItem selectionItem = getJMenuItem(SHOW_SELECTION_CMD); |
2 |
26 Feb 07 |
jari |
336 |
JMenuItem hideBoxItem = getJMenuItem(HIDE_SELECTION_BOX_CMD); |
2 |
26 Feb 07 |
jari |
337 |
JMenuItem selectionAreaItem = getJMenuItem(SELECTION_AREA_CMD); |
2 |
26 Feb 07 |
jari |
338 |
JMenuItem saveClusterItem = getJMenuItem(SAVE_CMD); |
2 |
26 Feb 07 |
jari |
339 |
JMenuItem storeClusterItem = getJMenuItem(STORE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
340 |
JMenuItem launchNewItem = getJMenuItem(LAUNCH_NEW_SESSION_CMD); |
2 |
26 Feb 07 |
jari |
341 |
if (selectionItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
342 |
content.setSelection(true); |
2 |
26 Feb 07 |
jari |
343 |
content.setSelectionBox(!hideBoxItem.isSelected()); |
2 |
26 Feb 07 |
jari |
344 |
selectionAreaItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
345 |
saveClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
346 |
hideBoxItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
347 |
storeClusterItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
348 |
launchNewItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
349 |
} else { |
2 |
26 Feb 07 |
jari |
350 |
content.setSelection(false); |
2 |
26 Feb 07 |
jari |
351 |
content.setSelectionBox(false); |
2 |
26 Feb 07 |
jari |
352 |
selectionAreaItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
353 |
saveClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
354 |
hideBoxItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
355 |
storeClusterItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
356 |
launchNewItem.setEnabled(false); |
2 |
26 Feb 07 |
jari |
357 |
} |
2 |
26 Feb 07 |
jari |
358 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
359 |
} |
2 |
26 Feb 07 |
jari |
360 |
|
2 |
26 Feb 07 |
jari |
361 |
/** |
2 |
26 Feb 07 |
jari |
* Hides a content selection box. |
2 |
26 Feb 07 |
jari |
363 |
*/ |
2 |
26 Feb 07 |
jari |
364 |
private void onHideSelection() { |
2 |
26 Feb 07 |
jari |
365 |
content.setSelectionBox(!content.isSelectionBox()); |
2 |
26 Feb 07 |
jari |
366 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
367 |
} |
2 |
26 Feb 07 |
jari |
368 |
|
2 |
26 Feb 07 |
jari |
369 |
/** |
2 |
26 Feb 07 |
jari |
* Shows or hides spheres. |
2 |
26 Feb 07 |
jari |
371 |
*/ |
2 |
26 Feb 07 |
jari |
372 |
private void onShowSphere() { |
2 |
26 Feb 07 |
jari |
373 |
content.setShowSpheres(!content.isShowSpheres()); |
2 |
26 Feb 07 |
jari |
374 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
375 |
|
2 |
26 Feb 07 |
jari |
376 |
JMenuItem sphereItem = getJMenuItem(SHOW_SPHERES_CMD); |
2 |
26 Feb 07 |
jari |
377 |
JMenuItem textItem = getJMenuItem(SHOW_TEXT_CMD); |
2 |
26 Feb 07 |
jari |
378 |
if (sphereItem.isSelected()) { |
2 |
26 Feb 07 |
jari |
379 |
content.setShowSpheres(true); |
2 |
26 Feb 07 |
jari |
380 |
content.setShowText(textItem.isSelected()); |
2 |
26 Feb 07 |
jari |
381 |
textItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
382 |
} else { |
2 |
26 Feb 07 |
jari |
383 |
content.setShowSpheres(false); |
2 |
26 Feb 07 |
jari |
384 |
content.setShowText(false); |
2 |
26 Feb 07 |
jari |
385 |
textItem.setEnabled(true); |
2 |
26 Feb 07 |
jari |
386 |
} |
2 |
26 Feb 07 |
jari |
387 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
388 |
} |
2 |
26 Feb 07 |
jari |
389 |
|
2 |
26 Feb 07 |
jari |
390 |
/** |
2 |
26 Feb 07 |
jari |
* Shows or hide content text. |
2 |
26 Feb 07 |
jari |
392 |
*/ |
2 |
26 Feb 07 |
jari |
393 |
private void onShowText() { |
2 |
26 Feb 07 |
jari |
394 |
content.setShowText(!content.isShowText()); |
2 |
26 Feb 07 |
jari |
395 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
396 |
} |
2 |
26 Feb 07 |
jari |
397 |
|
2 |
26 Feb 07 |
jari |
398 |
/** |
2 |
26 Feb 07 |
jari |
* Sets content background. |
2 |
26 Feb 07 |
jari |
400 |
*/ |
2 |
26 Feb 07 |
jari |
401 |
private void onWhiteBackground() { |
2 |
26 Feb 07 |
jari |
402 |
content.setWhiteBackround(!content.isWhiteBackground()); |
2 |
26 Feb 07 |
jari |
403 |
content.updateScene(); |
2 |
26 Feb 07 |
jari |
404 |
} |
2 |
26 Feb 07 |
jari |
405 |
|
2 |
26 Feb 07 |
jari |
406 |
/** |
2 |
26 Feb 07 |
jari |
* The listener to listen to menu items events. |
2 |
26 Feb 07 |
jari |
408 |
*/ |
2 |
26 Feb 07 |
jari |
409 |
private class Listener implements ActionListener { |
2 |
26 Feb 07 |
jari |
410 |
public void actionPerformed(ActionEvent event) { |
2 |
26 Feb 07 |
jari |
411 |
String command = event.getActionCommand(); |
2 |
26 Feb 07 |
jari |
412 |
if (command.equals(RESET_CMD)) { |
2 |
26 Feb 07 |
jari |
413 |
onReset(); |
2 |
26 Feb 07 |
jari |
414 |
} else if (command.equals(OPTIONS_CMD)) { |
2 |
26 Feb 07 |
jari |
415 |
onOptions(); |
2 |
26 Feb 07 |
jari |
416 |
} else if (command.equals(SELECTION_AREA_CMD)) { |
2 |
26 Feb 07 |
jari |
417 |
onSelectionArea(); |
2 |
26 Feb 07 |
jari |
418 |
} else if (command.equals(SAVE_CMD)) { |
2 |
26 Feb 07 |
jari |
419 |
onSave(); |
2 |
26 Feb 07 |
jari |
420 |
} else if (command.equals(SHOW_SELECTION_CMD)) { |
2 |
26 Feb 07 |
jari |
421 |
onShowSelection(); |
2 |
26 Feb 07 |
jari |
422 |
} else if (command.equals(HIDE_SELECTION_BOX_CMD)) { |
2 |
26 Feb 07 |
jari |
423 |
onHideSelection(); |
2 |
26 Feb 07 |
jari |
424 |
} else if (command.equals(SHOW_SPHERES_CMD)) { |
2 |
26 Feb 07 |
jari |
425 |
onShowSphere(); |
2 |
26 Feb 07 |
jari |
426 |
} else if (command.equals(SHOW_TEXT_CMD)) { |
2 |
26 Feb 07 |
jari |
427 |
onShowText(); |
2 |
26 Feb 07 |
jari |
428 |
} else if (command.equals(WHITE_CMD)) { |
2 |
26 Feb 07 |
jari |
429 |
onWhiteBackground(); |
2 |
26 Feb 07 |
jari |
430 |
} else if (command.equals(STORE_CLUSTER_CMD)){ |
2 |
26 Feb 07 |
jari |
431 |
storeCluster(); |
2 |
26 Feb 07 |
jari |
432 |
} else if (command.equals(LAUNCH_NEW_SESSION_CMD)){ |
2 |
26 Feb 07 |
jari |
433 |
launchNewSession(); |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
435 |
} |
2 |
26 Feb 07 |
jari |
436 |
} |
2 |
26 Feb 07 |
jari |
437 |
} |