2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
* Created on Jul 11, 2005 |
2 |
26 Feb 07 |
jari |
3 |
* |
2 |
26 Feb 07 |
jari |
* TODO To change the template for this generated file go to |
2 |
26 Feb 07 |
jari |
* Window - Preferences - Java - Code Style - Code Templates |
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.*; |
2 |
26 Feb 07 |
jari |
10 |
import java.io.DataOutputStream; |
2 |
26 Feb 07 |
jari |
11 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
12 |
import java.io.FileOutputStream; |
2 |
26 Feb 07 |
jari |
13 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
import org.tigr.microarray.mev.*; |
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
/** |
2 |
26 Feb 07 |
jari |
* @author eleanora |
2 |
26 Feb 07 |
jari |
19 |
* |
2 |
26 Feb 07 |
jari |
* TODO To change the template for this generated type comment go to |
2 |
26 Feb 07 |
jari |
* Window - Preferences - Java - Code Style - Code Templates |
2 |
26 Feb 07 |
jari |
22 |
*/ |
2 |
26 Feb 07 |
jari |
23 |
public class ISlideDataPersistenceDelegate extends |
2 |
26 Feb 07 |
jari |
24 |
PersistenceDelegate { |
2 |
26 Feb 07 |
jari |
25 |
|
2 |
26 Feb 07 |
jari |
/* (non-Javadoc) |
2 |
26 Feb 07 |
jari |
* @see java.beans.PersistenceDelegate#instantiate(java.lang.Object, java.beans.Encoder) |
2 |
26 Feb 07 |
jari |
28 |
*/ |
2 |
26 Feb 07 |
jari |
29 |
protected Expression instantiate(Object oldInstance, Encoder encoder) { |
2 |
26 Feb 07 |
jari |
30 |
Expression e; |
2 |
26 Feb 07 |
jari |
31 |
try { |
2 |
26 Feb 07 |
jari |
32 |
if(oldInstance instanceof FloatSlideData){ |
2 |
26 Feb 07 |
jari |
33 |
FloatSlideData fsd = (FloatSlideData) oldInstance; |
2 |
26 Feb 07 |
jari |
34 |
|
2 |
26 Feb 07 |
jari |
35 |
File outputFile = File.createTempFile(MultipleArrayViewer.CURRENT_TEMP_DIR + System.getProperty("file.separator") + "floatslidedata", ".bin"); |
2 |
26 Feb 07 |
jari |
36 |
outputFile.deleteOnExit(); |
2 |
26 Feb 07 |
jari |
37 |
DataOutputStream dos = new DataOutputStream(new FileOutputStream(outputFile)); |
2 |
26 Feb 07 |
jari |
38 |
PersistenceObjectFactory.writeFloatSlideDataIntensities(dos, fsd); |
2 |
26 Feb 07 |
jari |
39 |
dos.close(); |
2 |
26 Feb 07 |
jari |
40 |
|
2 |
26 Feb 07 |
jari |
41 |
e = new Expression((FloatSlideData) oldInstance, new PersistenceObjectFactory().getClass(), "makeFloatSlideData", |
2 |
26 Feb 07 |
jari |
42 |
new Object[]{fsd.getSlideDataKeys(), fsd.getSlideDataLabels(), fsd.getFullSlideFileName(), |
2 |
26 Feb 07 |
jari |
43 |
fsd.getSlideDataName(), new Boolean(fsd.getIsNonZero()), new Integer(fsd.getNormalizedState()), |
2 |
26 Feb 07 |
jari |
44 |
new Integer(fsd.getSortState()), fsd.getSpotInformationData(), new Integer(fsd.getDataType()), fsd.getSlideMetaData(), |
2 |
26 Feb 07 |
jari |
45 |
outputFile.getName()}); |
2 |
26 Feb 07 |
jari |
46 |
} else { |
2 |
26 Feb 07 |
jari |
47 |
SlideData sd = (SlideData) oldInstance; |
2 |
26 Feb 07 |
jari |
48 |
|
2 |
26 Feb 07 |
jari |
49 |
File annotationFile = File.createTempFile(MultipleArrayViewer.CURRENT_TEMP_DIR + System.getProperty("file.separator") + "slidedataannotation", ".bin"); |
2 |
26 Feb 07 |
jari |
50 |
annotationFile.deleteOnExit(); |
2 |
26 Feb 07 |
jari |
51 |
DataOutputStream dos = new DataOutputStream(new FileOutputStream(annotationFile)); |
2 |
26 Feb 07 |
jari |
52 |
PersistenceObjectFactory.writeSlideDataAnnotation(dos, sd); |
2 |
26 Feb 07 |
jari |
53 |
dos.close(); |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
File outputFile = File.createTempFile(MultipleArrayViewer.CURRENT_TEMP_DIR + System.getProperty("file.separator") + "slidedata", ".bin"); |
2 |
26 Feb 07 |
jari |
56 |
outputFile.deleteOnExit(); |
2 |
26 Feb 07 |
jari |
57 |
dos = new DataOutputStream(new FileOutputStream(outputFile)); |
2 |
26 Feb 07 |
jari |
58 |
PersistenceObjectFactory.writeSlideDataIntensities(dos, sd); |
2 |
26 Feb 07 |
jari |
59 |
dos.close(); |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
e = new Expression((SlideData)oldInstance, new PersistenceObjectFactory().getClass(), "makeSlideData", |
2 |
26 Feb 07 |
jari |
62 |
new Object[]{sd.getSlideDataName(), sd.getSlideDataKeys(), sd.getSampleLabelKey(), |
2 |
26 Feb 07 |
jari |
63 |
sd.getSlideDataLabels(), sd.getSlideFileName(), new Boolean(sd.isNonZero()), new Integer(sd.getRows()), new Integer(sd.getColumns()), |
2 |
26 Feb 07 |
jari |
64 |
new Integer(sd.getNormalizedState()), new Integer(sd.getSortState()), sd.getSpotInformationData(), sd.getFieldNames(), new Integer(sd.getDataType()), |
2 |
26 Feb 07 |
jari |
65 |
annotationFile.getName(), outputFile.getName()/*, progBar*/}); |
2 |
26 Feb 07 |
jari |
66 |
|
2 |
26 Feb 07 |
jari |
67 |
} |
2 |
26 Feb 07 |
jari |
68 |
} catch (IOException ioe){ |
2 |
26 Feb 07 |
jari |
69 |
System.out.println("Can't write to file to save FloatMatrix"); |
2 |
26 Feb 07 |
jari |
70 |
return null; |
2 |
26 Feb 07 |
jari |
71 |
} |
2 |
26 Feb 07 |
jari |
72 |
return e; |
2 |
26 Feb 07 |
jari |
73 |
} |
2 |
26 Feb 07 |
jari |
74 |
public void initialize(Class type, Object oldInstance, Object newInstance, Encoder encoder) { |
2 |
26 Feb 07 |
jari |
75 |
return; |
2 |
26 Feb 07 |
jari |
76 |
} |
2 |
26 Feb 07 |
jari |
77 |
} |