Normand Briere
2019-06-11 d0dc7ff35d71919d503ae35592478b173cf3cfd3
ObjEditor.java
....@@ -3214,6 +3214,47 @@
32143214 objEditor.refreshContents();
32153215 }
32163216
3217
+ static public byte[] Compress(Object o)
3218
+ {
3219
+ try
3220
+ {
3221
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3224
+
3225
+ out.writeObject(o);
3226
+
3227
+ out.flush();
3228
+
3229
+ zstream.close();
3230
+ out.close();
3231
+
3232
+ return baos.toByteArray();
3233
+ } catch (Exception e)
3234
+ {
3235
+ System.err.println(e);
3236
+ return null;
3237
+ }
3238
+ }
3239
+
3240
+ static public Object Uncompress(byte[] bytes)
3241
+ {
3242
+ try
3243
+ {
3244
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3245
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3246
+ ObjectInputStream in = new ObjectInputStream(istream);
3247
+ Object obj = in.readObject();
3248
+ in.close();
3249
+
3250
+ return obj;
3251
+ } catch (Exception e)
3252
+ {
3253
+ System.err.println(e);
3254
+ return null;
3255
+ }
3256
+ }
3257
+
32173258 static public Object clone(Object o)
32183259 {
32193260 try
....@@ -3222,12 +3263,19 @@
32223263 ObjectOutputStream out = new ObjectOutputStream(baos);
32233264
32243265 out.writeObject(o);
3266
+
3267
+ out.flush();
3268
+ out.close();
3269
+
3270
+ byte[] bytes = baos.toByteArray();
3271
+
3272
+ System.out.println("clone = " + bytes.length);
32253273
3226
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3274
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
32273275 ObjectInputStream in = new ObjectInputStream(bais);
32283276 Object obj = in.readObject();
32293277 in.close();
3230
- out.close();
3278
+
32313279 return obj;
32323280 } catch (Exception e)
32333281 {
....@@ -3251,13 +3299,21 @@
32513299 return null;
32523300 }
32533301
3302
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3303
+
32543304 public void Save()
32553305 {
32563306 cRadio tab = GetCurrentTab();
32573307
3308
+ copy.ExtractBigData(hashtable);
3309
+
32583310 //EditorFrame.m_MainFrame.requestFocusInWindow();
32593311 tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
32603312
3313
+ copy.RestoreBigData(hashtable);
3314
+
3315
+ //assert(hashtable.isEmpty());
3316
+
32613317 for (int i = tab.undoindex; i < tab.graphs.length; i++)
32623318 {
32633319 tab.graphs[i] = null;
....@@ -3285,12 +3341,18 @@
32853341
32863342 void CopyChanged(Object3D obj)
32873343 {
3344
+ copy.ExtractBigData(hashtable);
3345
+
32883346 copy.clear();
32893347
32903348 for (int i=0; i<obj.Size(); i++)
32913349 {
32923350 copy.add(obj.get(i));
32933351 }
3352
+
3353
+ copy.RestoreBigData(hashtable);
3354
+
3355
+ //assert(hashtable.isEmpty());
32943356
32953357 copy.Touch();
32963358
....@@ -4295,6 +4357,7 @@
42954357
42964358 if (readobj != null)
42974359 {
4360
+ Save();
42984361 try
42994362 {
43004363 //readobj.deepCopySelf(copy);