2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2004, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: SOMExperimentViewer.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.10 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/05/02 16:57:04 $ |
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.som; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.awt.Color; |
2 |
26 Feb 07 |
jari |
15 |
import java.awt.Frame; |
2 |
26 Feb 07 |
jari |
16 |
import java.awt.Insets; |
2 |
26 Feb 07 |
jari |
17 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
18 |
import java.awt.event.ActionListener; |
2 |
26 Feb 07 |
jari |
19 |
import java.awt.event.MouseAdapter; |
2 |
26 Feb 07 |
jari |
20 |
import java.awt.event.MouseEvent; |
2 |
26 Feb 07 |
jari |
21 |
import java.awt.image.BufferedImage; |
2 |
26 Feb 07 |
jari |
22 |
import java.beans.Expression; |
2 |
26 Feb 07 |
jari |
23 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
24 |
import java.io.ObjectInputStream; |
2 |
26 Feb 07 |
jari |
25 |
import java.io.ObjectOutputStream; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
27 |
import javax.swing.JColorChooser; |
2 |
26 Feb 07 |
jari |
28 |
import javax.swing.JComponent; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JMenuItem; |
2 |
26 Feb 07 |
jari |
30 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
31 |
import javax.swing.JPopupMenu; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.microarray.mev.cluster.gui.IDisplayMenu; |
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.gui.helpers.CentroidExperimentHeader; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.microarray.mev.cluster.gui.helpers.CentroidViewer; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentHeader; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentViewer; |
2 |
26 Feb 07 |
jari |
42 |
import org.tigr.microarray.mev.cluster.gui.impl.GUIFactory; |
2 |
26 Feb 07 |
jari |
43 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
44 |
|
2 |
26 Feb 07 |
jari |
45 |
public class SOMExperimentViewer implements IViewer { |
2 |
26 Feb 07 |
jari |
46 |
|
2 |
26 Feb 07 |
jari |
47 |
private JPopupMenu popup; |
2 |
26 Feb 07 |
jari |
48 |
private ExperimentViewer expViewer; |
2 |
26 Feb 07 |
jari |
49 |
private CentroidExperimentHeader header; |
2 |
26 Feb 07 |
jari |
50 |
|
2 |
26 Feb 07 |
jari |
51 |
protected static final String STORE_CLUSTER_CMD = "store-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
52 |
protected static final String SET_DEF_COLOR_CMD = "set-def-color-cmd"; |
2 |
26 Feb 07 |
jari |
53 |
protected static final String SAVE_CLUSTER_CMD = "save-cluster-cmd"; |
2 |
26 Feb 07 |
jari |
54 |
protected static final String SAVE_ALL_CLUSTERS_CMD = "save-all-clusters-cmd"; |
2 |
26 Feb 07 |
jari |
55 |
protected static final String LAUNCH_NEW_SESSION_CMD = "launch-new-session-cmd"; |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
//EH stored for state-saving |
2 |
26 Feb 07 |
jari |
58 |
private FloatMatrix codes; |
2 |
26 Feb 07 |
jari |
59 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SOMExperimentViewer</code> with specified |
2 |
26 Feb 07 |
jari |
* experiment, clusters and codes. |
2 |
26 Feb 07 |
jari |
64 |
*/ |
2 |
26 Feb 07 |
jari |
65 |
public SOMExperimentViewer(Experiment experiment, int[][] clusters, FloatMatrix codes) { |
2 |
26 Feb 07 |
jari |
66 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
67 |
this.popup = createJPopupMenu(listener); |
2 |
26 Feb 07 |
jari |
68 |
|
2 |
26 Feb 07 |
jari |
69 |
this.expViewer = new ExperimentViewer(experiment, clusters); |
2 |
26 Feb 07 |
jari |
70 |
this.expViewer.getContentComponent().addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
71 |
|
2 |
26 Feb 07 |
jari |
72 |
this.header = new CentroidExperimentHeader(this.expViewer.getHeaderComponent(), codes, clusters, "SOM Vector"); |
2 |
26 Feb 07 |
jari |
73 |
this.codes = codes; |
2 |
26 Feb 07 |
jari |
74 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
//this.header = new SOMExperimentHeader(expViewer.getHeaderComponent(), codes, clusters); |
2 |
26 Feb 07 |
jari |
//this.header.setColorImages(expViewer.getPosColorImage(), expViewer.getNegColorImage()); |
2 |
26 Feb 07 |
jari |
78 |
this.header.setNegAndPosColorImages(expViewer.getPosColorImage(), expViewer.getNegColorImage()); |
2 |
26 Feb 07 |
jari |
79 |
this.header.setMissingColor(expViewer.getMissingColor()); |
2 |
26 Feb 07 |
jari |
80 |
this.header.addMouseListener(listener); |
2 |
26 Feb 07 |
jari |
81 |
this.header.setBackground(Color.white); |
2 |
26 Feb 07 |
jari |
82 |
|
2 |
26 Feb 07 |
jari |
83 |
} |
2 |
26 Feb 07 |
jari |
84 |
|
2 |
26 Feb 07 |
jari |
85 |
public Expression getExpression(){ |
2 |
26 Feb 07 |
jari |
86 |
return new Expression(this, this.getClass(), "new", |
2 |
26 Feb 07 |
jari |
87 |
new Object[]{this.experiment, this.getClusters(), this.codes}); |
2 |
26 Feb 07 |
jari |
88 |
} |
2 |
26 Feb 07 |
jari |
89 |
|
2 |
26 Feb 07 |
jari |
90 |
public void setExperiment(Experiment e){ |
2 |
26 Feb 07 |
jari |
91 |
expViewer.setExperiment(e); |
2 |
26 Feb 07 |
jari |
92 |
} |
2 |
26 Feb 07 |
jari |
93 |
public void setExperimentID(int id){ |
2 |
26 Feb 07 |
jari |
94 |
expViewer.setExperimentID(id); |
2 |
26 Feb 07 |
jari |
95 |
} |
2 |
26 Feb 07 |
jari |
96 |
public int getExperimentID(){return expViewer.getExperimentID();} |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the header component. |
2 |
26 Feb 07 |
jari |
101 |
*/ |
2 |
26 Feb 07 |
jari |
102 |
public JComponent getHeaderComponent() { |
2 |
26 Feb 07 |
jari |
103 |
return header; |
2 |
26 Feb 07 |
jari |
104 |
} |
2 |
26 Feb 07 |
jari |
105 |
|
2 |
26 Feb 07 |
jari |
106 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the wrapped experiment viewer. |
2 |
26 Feb 07 |
jari |
108 |
*/ |
2 |
26 Feb 07 |
jari |
109 |
public JComponent getContentComponent() { |
2 |
26 Feb 07 |
jari |
110 |
return expViewer.getContentComponent(); |
2 |
26 Feb 07 |
jari |
111 |
} |
2 |
26 Feb 07 |
jari |
112 |
|
2 |
26 Feb 07 |
jari |
113 |
public BufferedImage getImage() { |
2 |
26 Feb 07 |
jari |
114 |
return expViewer.getImage(); |
2 |
26 Feb 07 |
jari |
115 |
} |
2 |
26 Feb 07 |
jari |
116 |
|
2 |
26 Feb 07 |
jari |
117 |
/** |
2 |
26 Feb 07 |
jari |
* Updates header and contents attributes when the viewer is selected. |
2 |
26 Feb 07 |
jari |
119 |
*/ |
2 |
26 Feb 07 |
jari |
120 |
public void onSelected(IFramework framework) { |
2 |
26 Feb 07 |
jari |
121 |
expViewer.onSelected(framework); |
2 |
26 Feb 07 |
jari |
122 |
header.setCurrentCluster(((Integer)framework.getUserObject()).intValue()); |
2 |
26 Feb 07 |
jari |
123 |
IDisplayMenu menu = framework.getDisplayMenu(); |
2 |
26 Feb 07 |
jari |
124 |
header.setUseDoubleGradient(menu.getUseDoubleGradient()); |
2 |
26 Feb 07 |
jari |
125 |
header.setNegAndPosColorImages(menu.getNegativeGradientImage(), menu.getPositiveGradientImage()); |
2 |
26 Feb 07 |
jari |
126 |
header.setValues(menu.getMinRatioScale(), menu.getMidRatioValue(), menu.getMaxRatioScale()); |
2 |
26 Feb 07 |
jari |
127 |
header.setAntiAliasing(menu.isAntiAliasing()); |
2 |
26 Feb 07 |
jari |
128 |
header.setDrawBorders(menu.isDrawingBorder()); |
2 |
26 Feb 07 |
jari |
129 |
header.updateSize(menu.getElementSize()); |
2 |
26 Feb 07 |
jari |
130 |
} |
2 |
26 Feb 07 |
jari |
131 |
|
2 |
26 Feb 07 |
jari |
132 |
/** |
2 |
26 Feb 07 |
jari |
* Updates experiment data. |
2 |
26 Feb 07 |
jari |
134 |
*/ |
2 |
26 Feb 07 |
jari |
135 |
public void onDataChanged(IData data) { |
2 |
26 Feb 07 |
jari |
136 |
expViewer.onDataChanged(data); |
2 |
26 Feb 07 |
jari |
137 |
} |
2 |
26 Feb 07 |
jari |
138 |
|
2 |
26 Feb 07 |
jari |
139 |
/** |
2 |
26 Feb 07 |
jari |
* Updates header and contents attributes when the display menu is changed. |
2 |
26 Feb 07 |
jari |
141 |
*/ |
2 |
26 Feb 07 |
jari |
142 |
public void onMenuChanged(IDisplayMenu menu) { |
2 |
26 Feb 07 |
jari |
143 |
expViewer.onMenuChanged(menu); |
2 |
26 Feb 07 |
jari |
144 |
header.setUseDoubleGradient(menu.getUseDoubleGradient()); |
2 |
26 Feb 07 |
jari |
145 |
header.setNegAndPosColorImages(menu.getNegativeGradientImage(), menu.getPositiveGradientImage()); |
2 |
26 Feb 07 |
jari |
146 |
header.setValues(menu.getMinRatioScale(), menu.getMidRatioValue() ,menu.getMaxRatioScale()); |
2 |
26 Feb 07 |
jari |
147 |
header.setAntiAliasing(menu.isAntiAliasing()); |
2 |
26 Feb 07 |
jari |
148 |
header.setDrawBorders(menu.isDrawingBorder()); |
2 |
26 Feb 07 |
jari |
149 |
header.updateSize(menu.getElementSize()); |
2 |
26 Feb 07 |
jari |
150 |
} |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
public void onDeselected() {} |
2 |
26 Feb 07 |
jari |
153 |
public void onClosed() {} |
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a popup menu. |
2 |
26 Feb 07 |
jari |
157 |
*/ |
2 |
26 Feb 07 |
jari |
158 |
private JPopupMenu createJPopupMenu(Listener listener) { |
2 |
26 Feb 07 |
jari |
159 |
JPopupMenu popup = new JPopupMenu(); |
2 |
26 Feb 07 |
jari |
160 |
addMenuItems(popup, listener); |
2 |
26 Feb 07 |
jari |
161 |
return popup; |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
/** |
2 |
26 Feb 07 |
jari |
* Adds viewer specific menu items. |
2 |
26 Feb 07 |
jari |
166 |
*/ |
2 |
26 Feb 07 |
jari |
167 |
protected void addMenuItems(JPopupMenu menu, ActionListener listener) { |
2 |
26 Feb 07 |
jari |
168 |
JMenuItem menuItem; |
2 |
26 Feb 07 |
jari |
169 |
menuItem = new JMenuItem("Store cluster", GUIFactory.getIcon("new16.gif")); |
2 |
26 Feb 07 |
jari |
170 |
menuItem.setActionCommand(STORE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
171 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
172 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
173 |
|
2 |
26 Feb 07 |
jari |
174 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
175 |
|
2 |
26 Feb 07 |
jari |
176 |
menuItem = new JMenuItem("Launch new session", GUIFactory.getIcon("analysis16.gif")); |
2 |
26 Feb 07 |
jari |
177 |
menuItem.setActionCommand(LAUNCH_NEW_SESSION_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 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
182 |
|
2 |
26 Feb 07 |
jari |
183 |
menuItem = new JMenuItem("Delete public cluster", GUIFactory.getIcon("delete16.gif")); |
2 |
26 Feb 07 |
jari |
184 |
menuItem.setActionCommand(SET_DEF_COLOR_CMD); |
2 |
26 Feb 07 |
jari |
185 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
186 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
187 |
|
2 |
26 Feb 07 |
jari |
188 |
menu.addSeparator(); |
2 |
26 Feb 07 |
jari |
189 |
|
2 |
26 Feb 07 |
jari |
190 |
menuItem = new JMenuItem("Save cluster...", GUIFactory.getIcon("save16.gif")); |
2 |
26 Feb 07 |
jari |
191 |
menuItem.setActionCommand(SAVE_CLUSTER_CMD); |
2 |
26 Feb 07 |
jari |
192 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
193 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
menuItem = new JMenuItem("Save all clusters...", GUIFactory.getIcon("save16.gif")); |
2 |
26 Feb 07 |
jari |
196 |
menuItem.setActionCommand(SAVE_ALL_CLUSTERS_CMD); |
2 |
26 Feb 07 |
jari |
197 |
menuItem.addActionListener(listener); |
2 |
26 Feb 07 |
jari |
198 |
menu.add(menuItem); |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
|
2 |
26 Feb 07 |
jari |
201 |
/** |
2 |
26 Feb 07 |
jari |
* Saves clusters. |
2 |
26 Feb 07 |
jari |
203 |
*/ |
2 |
26 Feb 07 |
jari |
204 |
private void onSaveClusters() { |
2 |
26 Feb 07 |
jari |
205 |
Frame frame = JOptionPane.getFrameForComponent(getContentComponent()); |
2 |
26 Feb 07 |
jari |
206 |
try { |
2 |
26 Feb 07 |
jari |
207 |
expViewer.saveClusters(frame); |
2 |
26 Feb 07 |
jari |
208 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
209 |
JOptionPane.showMessageDialog(frame, "Can not save clusters!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
210 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
211 |
} |
2 |
26 Feb 07 |
jari |
212 |
} |
2 |
26 Feb 07 |
jari |
213 |
|
2 |
26 Feb 07 |
jari |
214 |
/** |
2 |
26 Feb 07 |
jari |
* Save the viewer cluster. |
2 |
26 Feb 07 |
jari |
216 |
*/ |
2 |
26 Feb 07 |
jari |
217 |
private void onSaveCluster() { |
2 |
26 Feb 07 |
jari |
218 |
Frame frame = JOptionPane.getFrameForComponent(getContentComponent()); |
2 |
26 Feb 07 |
jari |
219 |
try { |
2 |
26 Feb 07 |
jari |
220 |
expViewer.saveCluster(frame); |
2 |
26 Feb 07 |
jari |
221 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
222 |
JOptionPane.showMessageDialog(frame, "Can not save cluster!", e.toString(), JOptionPane.ERROR_MESSAGE); |
2 |
26 Feb 07 |
jari |
223 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
224 |
} |
2 |
26 Feb 07 |
jari |
225 |
} |
2 |
26 Feb 07 |
jari |
226 |
|
2 |
26 Feb 07 |
jari |
227 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a public color. |
2 |
26 Feb 07 |
jari |
229 |
*/ |
2 |
26 Feb 07 |
jari |
230 |
private void onSetColor() { |
2 |
26 Feb 07 |
jari |
231 |
Frame frame = JOptionPane.getFrameForComponent(getContentComponent()); |
2 |
26 Feb 07 |
jari |
232 |
Color newColor = JColorChooser.showDialog(frame, "Choose color", CentroidViewer.DEF_CLUSTER_COLOR); |
2 |
26 Feb 07 |
jari |
233 |
if (newColor != null) { |
2 |
26 Feb 07 |
jari |
234 |
expViewer.setClusterColor(newColor); |
2 |
26 Feb 07 |
jari |
235 |
} |
2 |
26 Feb 07 |
jari |
236 |
} |
2 |
26 Feb 07 |
jari |
237 |
|
2 |
26 Feb 07 |
jari |
238 |
/** |
2 |
26 Feb 07 |
jari |
* Removes a public color. |
2 |
26 Feb 07 |
jari |
240 |
*/ |
2 |
26 Feb 07 |
jari |
241 |
private void onSetDefaultColor() { |
2 |
26 Feb 07 |
jari |
242 |
expViewer.setClusterColor(null); |
2 |
26 Feb 07 |
jari |
243 |
} |
2 |
26 Feb 07 |
jari |
244 |
|
2 |
26 Feb 07 |
jari |
/** Returns a component to be inserted into the scroll pane row header |
2 |
26 Feb 07 |
jari |
246 |
*/ |
2 |
26 Feb 07 |
jari |
247 |
public JComponent getRowHeaderComponent() { |
2 |
26 Feb 07 |
jari |
248 |
return null; |
2 |
26 Feb 07 |
jari |
249 |
} |
2 |
26 Feb 07 |
jari |
250 |
|
2 |
26 Feb 07 |
jari |
/** Returns the corner component corresponding to the indicated corner, |
2 |
26 Feb 07 |
jari |
* posibly null |
2 |
26 Feb 07 |
jari |
253 |
*/ |
2 |
26 Feb 07 |
jari |
254 |
public JComponent getCornerComponent(int cornerIndex) { |
2 |
26 Feb 07 |
jari |
255 |
return null; |
2 |
26 Feb 07 |
jari |
256 |
} |
2 |
26 Feb 07 |
jari |
257 |
|
2 |
26 Feb 07 |
jari |
/** Returns the viewer's clusters or null |
2 |
26 Feb 07 |
jari |
259 |
*/ |
2 |
26 Feb 07 |
jari |
260 |
public int[][] getClusters() { |
2 |
26 Feb 07 |
jari |
261 |
return expViewer.getClusters(); |
2 |
26 Feb 07 |
jari |
262 |
} |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
/** Returns the viewer's experiment or null |
2 |
26 Feb 07 |
jari |
265 |
*/ |
2 |
26 Feb 07 |
jari |
266 |
public Experiment getExperiment() { |
2 |
26 Feb 07 |
jari |
267 |
return expViewer.getExperiment(); |
2 |
26 Feb 07 |
jari |
268 |
} |
2 |
26 Feb 07 |
jari |
269 |
|
2 |
26 Feb 07 |
jari |
/** Returns int value indicating viewer type |
2 |
26 Feb 07 |
jari |
* Cluster.GENE_CLUSTER, Cluster.EXPERIMENT_CLUSTER, or -1 for both or unspecified |
2 |
26 Feb 07 |
jari |
272 |
*/ |
2 |
26 Feb 07 |
jari |
273 |
public int getViewerType() { |
2 |
26 Feb 07 |
jari |
274 |
return expViewer.getViewerType(); |
2 |
26 Feb 07 |
jari |
275 |
} |
2 |
26 Feb 07 |
jari |
276 |
|
2 |
26 Feb 07 |
jari |
277 |
|
2 |
26 Feb 07 |
jari |
278 |
/** |
2 |
26 Feb 07 |
jari |
* The class to listen to mouse and action events. |
2 |
26 Feb 07 |
jari |
280 |
*/ |
2 |
26 Feb 07 |
jari |
281 |
private class Listener extends MouseAdapter implements ActionListener { |
2 |
26 Feb 07 |
jari |
282 |
|
2 |
26 Feb 07 |
jari |
283 |
public void actionPerformed(ActionEvent e) { |
2 |
26 Feb 07 |
jari |
284 |
String command = e.getActionCommand(); |
2 |
26 Feb 07 |
jari |
285 |
if (command.equals(SAVE_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
286 |
onSaveCluster(); |
2 |
26 Feb 07 |
jari |
287 |
} else if (command.equals(SAVE_ALL_CLUSTERS_CMD)) { |
2 |
26 Feb 07 |
jari |
288 |
onSaveClusters(); |
2 |
26 Feb 07 |
jari |
289 |
} else if (command.equals(SET_DEF_COLOR_CMD)) { |
2 |
26 Feb 07 |
jari |
290 |
onSetDefaultColor(); |
2 |
26 Feb 07 |
jari |
291 |
} else if (command.equals(STORE_CLUSTER_CMD)) { |
2 |
26 Feb 07 |
jari |
292 |
expViewer.storeCluster(); |
2 |
26 Feb 07 |
jari |
293 |
} else if(command.equals(LAUNCH_NEW_SESSION_CMD)){ |
2 |
26 Feb 07 |
jari |
294 |
expViewer.launchNewSession(); |
2 |
26 Feb 07 |
jari |
295 |
} |
2 |
26 Feb 07 |
jari |
296 |
} |
2 |
26 Feb 07 |
jari |
297 |
|
2 |
26 Feb 07 |
jari |
298 |
public void mouseReleased(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
299 |
maybeShowPopup(event); |
2 |
26 Feb 07 |
jari |
300 |
} |
2 |
26 Feb 07 |
jari |
301 |
|
2 |
26 Feb 07 |
jari |
302 |
public void mousePressed(MouseEvent event) { |
2 |
26 Feb 07 |
jari |
303 |
maybeShowPopup(event); |
2 |
26 Feb 07 |
jari |
304 |
} |
2 |
26 Feb 07 |
jari |
305 |
|
2 |
26 Feb 07 |
jari |
306 |
private void maybeShowPopup(MouseEvent e) { |
2 |
26 Feb 07 |
jari |
307 |
|
2 |
26 Feb 07 |
jari |
308 |
if (!e.isPopupTrigger() || expViewer.getCluster() == null || expViewer.getCluster().length == 0) { |
2 |
26 Feb 07 |
jari |
309 |
return; |
2 |
26 Feb 07 |
jari |
310 |
} |
2 |
26 Feb 07 |
jari |
311 |
popup.show(e.getComponent(), e.getX(), e.getY()); |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
} |
2 |
26 Feb 07 |
jari |
314 |
} |