2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* Created on Nov 9, 2005 |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
* Creates an XMLEncoder and sets persistence delegates such that the encoder can |
2 |
26 Feb 07 |
jari |
* save the viewers and other attendant classes required for MeV state-saving. |
2 |
26 Feb 07 |
jari |
6 |
*/ |
2 |
26 Feb 07 |
jari |
7 |
package org.tigr.microarray.mev.persistence; |
2 |
26 Feb 07 |
jari |
8 |
|
2 |
26 Feb 07 |
jari |
9 |
import java.beans.DefaultPersistenceDelegate; |
2 |
26 Feb 07 |
jari |
10 |
import java.beans.XMLEncoder; |
2 |
26 Feb 07 |
jari |
11 |
import java.util.Enumeration; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
import org.tigr.graph.GraphViewer; |
2 |
26 Feb 07 |
jari |
16 |
import org.tigr.microarray.mev.FloatSlideData; |
2 |
26 Feb 07 |
jari |
17 |
import org.tigr.microarray.mev.HistoryViewer; |
2 |
26 Feb 07 |
jari |
18 |
import org.tigr.microarray.mev.MultipleArrayData; |
2 |
26 Feb 07 |
jari |
19 |
import org.tigr.microarray.mev.ResultTree; |
2 |
26 Feb 07 |
jari |
20 |
import org.tigr.microarray.mev.SlideData; |
2 |
26 Feb 07 |
jari |
21 |
import org.tigr.microarray.mev.cluster.clusterUtil.*; |
2 |
26 Feb 07 |
jari |
22 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
23 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
24 |
import org.tigr.microarray.mev.cluster.gui.helpers.*; |
2 |
26 Feb 07 |
jari |
25 |
import org.tigr.microarray.mev.cluster.gui.impl.fom.*; |
2 |
26 Feb 07 |
jari |
26 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLTree; |
2 |
26 Feb 07 |
jari |
27 |
import org.tigr.microarray.mev.cluster.gui.impl.ptm.PTMExperimentHeader; |
2 |
26 Feb 07 |
jari |
28 |
import org.tigr.microarray.mev.cluster.gui.impl.sota.*; |
2 |
26 Feb 07 |
jari |
29 |
import org.tigr.microarray.mev.cluster.gui.impl.st.HCLSupportTree; |
2 |
26 Feb 07 |
jari |
30 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.util.awt.Viewer; |
2 |
26 Feb 07 |
jari |
32 |
|
2 |
26 Feb 07 |
jari |
//import com.sun.j3d.utils.universe.Viewer; |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
/** |
2 |
26 Feb 07 |
jari |
* Factory class for (@link java.beans.XMLEncoder}. |
2 |
26 Feb 07 |
jari |
37 |
* |
2 |
26 Feb 07 |
jari |
* @author eleanora |
2 |
26 Feb 07 |
jari |
39 |
* |
2 |
26 Feb 07 |
jari |
40 |
*/ |
2 |
26 Feb 07 |
jari |
41 |
public abstract class XMLEncoderFactory { |
2 |
26 Feb 07 |
jari |
42 |
|
2 |
26 Feb 07 |
jari |
43 |
/** |
2 |
26 Feb 07 |
jari |
* Creates an XMLEncoder to be used for saving the state of a MultipleArrayViewer. |
2 |
26 Feb 07 |
jari |
* Sets persistence delegates such that the encoder can |
2 |
26 Feb 07 |
jari |
* save the viewers and other attendant classes required for MeV state-saving. |
2 |
26 Feb 07 |
jari |
* PersistenceDelegates for implementations of IViewer are found in |
2 |
26 Feb 07 |
jari |
* {@link IViewerPersistenceDelegate}. |
2 |
26 Feb 07 |
jari |
49 |
*/ |
2 |
26 Feb 07 |
jari |
50 |
public static XMLEncoder getMAVEncoder(XMLEncoder oos, ResultTree tree){ |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
52 |
DefaultMutableTreeNode analysisNode = tree.getAnalysisNode(); |
2 |
26 Feb 07 |
jari |
53 |
Enumeration allNodes = analysisNode.breadthFirstEnumeration(); |
2 |
26 Feb 07 |
jari |
54 |
DefaultMutableTreeNode dmtn; |
2 |
26 Feb 07 |
jari |
55 |
IViewerPersistenceDelegate ivpd = new IViewerPersistenceDelegate(); |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
//Checks the ResultTree for IViewers and assigns a PersistenceDelegate |
2 |
26 Feb 07 |
jari |
//for each different type found. All PersistenceDelegate Expression objects |
2 |
26 Feb 07 |
jari |
//for classes extending IViewer are found in the IViewerPersistenceDelegate class. |
2 |
26 Feb 07 |
jari |
60 |
while(allNodes.hasMoreElements()){ |
2 |
26 Feb 07 |
jari |
61 |
dmtn = (DefaultMutableTreeNode)allNodes.nextElement(); |
2 |
26 Feb 07 |
jari |
62 |
Object o = dmtn.getUserObject(); |
2 |
26 Feb 07 |
jari |
63 |
if(o instanceof LeafInfo) { |
2 |
26 Feb 07 |
jari |
64 |
LeafInfo l = (LeafInfo)o; |
2 |
26 Feb 07 |
jari |
65 |
if(l.getViewer() != null) { |
2 |
26 Feb 07 |
jari |
66 |
Object aViewer = l.getViewer(); |
2 |
26 Feb 07 |
jari |
//System.out.println(aViewer.getClass().toString()); |
2 |
26 Feb 07 |
jari |
68 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
69 |
aViewer.getClass(), |
2 |
26 Feb 07 |
jari |
70 |
ivpd |
2 |
26 Feb 07 |
jari |
71 |
); |
2 |
26 Feb 07 |
jari |
72 |
} |
2 |
26 Feb 07 |
jari |
73 |
} |
2 |
26 Feb 07 |
jari |
74 |
} |
2 |
26 Feb 07 |
jari |
75 |
|
2 |
26 Feb 07 |
jari |
//HistoryViewer is an IViewer but is not found in the analysisNode |
2 |
26 Feb 07 |
jari |
77 |
oos.setPersistenceDelegate(HistoryViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
78 |
|
2 |
26 Feb 07 |
jari |
//The classes below are not normally included in the resultTree, but still |
2 |
26 Feb 07 |
jari |
//need to have PersistenceDelegates assigned to them if one of their descendant |
2 |
26 Feb 07 |
jari |
//classes are in the resultTree. Therefore they are always assigned here. |
2 |
26 Feb 07 |
jari |
//Any new IViewer parent classes would also need to be included below. |
2 |
26 Feb 07 |
jari |
83 |
oos.setPersistenceDelegate(ExperimentClusterViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
84 |
oos.setPersistenceDelegate(ExperimentViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
85 |
oos.setPersistenceDelegate(CentroidViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
86 |
oos.setPersistenceDelegate(CentroidsViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
87 |
oos.setPersistenceDelegate(ClusterTableViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
88 |
oos.setPersistenceDelegate(ClusterTableViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
89 |
oos.setPersistenceDelegate(ExperimentClusterTableViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
90 |
oos.setPersistenceDelegate(ExperimentClusterCentroidViewer.class, ivpd); |
2 |
26 Feb 07 |
jari |
91 |
oos.setPersistenceDelegate(ClusterRepository.class, new ClusterRepositoryPersistenceDelegate()); |
2 |
26 Feb 07 |
jari |
92 |
oos.setPersistenceDelegate(GraphViewer.class, new ViewerPersistenceDelegate()); |
2 |
26 Feb 07 |
jari |
93 |
oos.setPersistenceDelegate(Viewer.class, new ViewerPersistenceDelegate()); |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
|
2 |
26 Feb 07 |
jari |
//Below are other miscellaneous classes that need custom PersistenceDelegates to be |
2 |
26 Feb 07 |
jari |
//properly saved. |
2 |
26 Feb 07 |
jari |
98 |
|
2 |
26 Feb 07 |
jari |
99 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
100 |
BufferedImageWrapper.class, |
2 |
26 Feb 07 |
jari |
101 |
new BufferedImagePersistenceDelegate() |
2 |
26 Feb 07 |
jari |
102 |
); |
2 |
26 Feb 07 |
jari |
103 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
104 |
LeafInfo.class, |
2 |
26 Feb 07 |
jari |
105 |
new DefaultPersistenceDelegate(LeafInfo.getPersistenceDelegateArgs()) |
2 |
26 Feb 07 |
jari |
106 |
); |
2 |
26 Feb 07 |
jari |
107 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
108 |
FloatMatrix.class, |
2 |
26 Feb 07 |
jari |
109 |
new FloatMatrixPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
110 |
); |
2 |
26 Feb 07 |
jari |
111 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
112 |
ClusterList.class, |
2 |
26 Feb 07 |
jari |
113 |
new DefaultPersistenceDelegate(ClusterList.getPersistenceDelegateArgs()) |
2 |
26 Feb 07 |
jari |
114 |
); |
2 |
26 Feb 07 |
jari |
115 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
116 |
Cluster.class, |
2 |
26 Feb 07 |
jari |
117 |
Cluster.getPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
118 |
); |
2 |
26 Feb 07 |
jari |
119 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
120 |
MultipleArrayData.class, |
2 |
26 Feb 07 |
jari |
121 |
new MultipleArrayDataPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
122 |
); |
2 |
26 Feb 07 |
jari |
123 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
124 |
SlideData.class, |
2 |
26 Feb 07 |
jari |
125 |
new ISlideDataPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
126 |
); |
2 |
26 Feb 07 |
jari |
127 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
128 |
FloatSlideData.class, |
2 |
26 Feb 07 |
jari |
129 |
new ISlideDataPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
130 |
); |
2 |
26 Feb 07 |
jari |
131 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
132 |
ExperimentHeader.class, |
2 |
26 Feb 07 |
jari |
133 |
new ExperimentHeaderPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
134 |
); |
2 |
26 Feb 07 |
jari |
135 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
136 |
Experiment.class, |
2 |
26 Feb 07 |
jari |
137 |
new ExperimentPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
138 |
); |
2 |
26 Feb 07 |
jari |
139 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
140 |
HCLTree.class, |
2 |
26 Feb 07 |
jari |
141 |
HCLTree.getPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
142 |
); |
2 |
26 Feb 07 |
jari |
143 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
144 |
org.tigr.microarray.mev.cluster.gui.impl.tease.HCLTree.class, |
2 |
26 Feb 07 |
jari |
145 |
org.tigr.microarray.mev.cluster.gui.impl.tease.HCLTree.getPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
146 |
); |
2 |
26 Feb 07 |
jari |
147 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
148 |
HCLSupportTree.class, |
2 |
26 Feb 07 |
jari |
149 |
HCLSupportTree.getPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
150 |
); |
2 |
26 Feb 07 |
jari |
151 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
152 |
ExperimentClusterHeader.class, |
2 |
26 Feb 07 |
jari |
153 |
new DefaultPersistenceDelegate(ExperimentClusterHeader.getPersistenceDelegateArgs()) |
2 |
26 Feb 07 |
jari |
154 |
); |
2 |
26 Feb 07 |
jari |
155 |
|
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
158 |
FOMContentComponent.class, |
2 |
26 Feb 07 |
jari |
159 |
new DefaultPersistenceDelegate(FOMContentComponent.getPersistenceDelegateArgs()) |
2 |
26 Feb 07 |
jari |
160 |
); |
2 |
26 Feb 07 |
jari |
161 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
162 |
CastFOMContentComponentB.class, |
2 |
26 Feb 07 |
jari |
163 |
new DefaultPersistenceDelegate(CastFOMContentComponentB.getPersistenceDelegateArgs()) |
2 |
26 Feb 07 |
jari |
164 |
); |
2 |
26 Feb 07 |
jari |
165 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
166 |
CastFOMContentComponentA.class, |
2 |
26 Feb 07 |
jari |
167 |
new DefaultPersistenceDelegate(CastFOMContentComponentA.getPersistenceDelegateArgs()) |
2 |
26 Feb 07 |
jari |
168 |
); |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
171 |
PTMExperimentHeader.class, |
2 |
26 Feb 07 |
jari |
172 |
PTMExperimentHeader.getPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
173 |
); |
2 |
26 Feb 07 |
jari |
174 |
|
2 |
26 Feb 07 |
jari |
175 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
176 |
SOTATreeData.class, |
2 |
26 Feb 07 |
jari |
177 |
new SOTATreeDataPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
178 |
); |
2 |
26 Feb 07 |
jari |
179 |
|
2 |
26 Feb 07 |
jari |
180 |
oos.setPersistenceDelegate( |
2 |
26 Feb 07 |
jari |
181 |
CentroidExperimentHeader.class, |
2 |
26 Feb 07 |
jari |
182 |
CentroidExperimentHeader.getPersistenceDelegate() |
2 |
26 Feb 07 |
jari |
183 |
); |
2 |
26 Feb 07 |
jari |
184 |
return oos; |
2 |
26 Feb 07 |
jari |
185 |
} |
2 |
26 Feb 07 |
jari |
186 |
} |