Normand Briere
2019-06-11 4113164b3be1e50251ac40d6fd65660f0a6c2e63
ObjEditor.java
....@@ -2927,7 +2927,7 @@
29272927 return;
29282928 } else if (event.getSource() == toggleSwitchItem)
29292929 {
2930
- cameraView.ToggleRandom();
2930
+ cameraView.ToggleSwitch();
29312931 cameraView.repaint();
29322932 return;
29332933 } else if (event.getSource() == toggleHandleItem)
....@@ -3214,6 +3214,48 @@
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
+ System.out.println("#bytes = " + bytes.length);
3243
+ try
3244
+ {
3245
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3246
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3247
+ ObjectInputStream in = new ObjectInputStream(istream);
3248
+ Object obj = in.readObject();
3249
+ in.close();
3250
+
3251
+ return obj;
3252
+ } catch (Exception e)
3253
+ {
3254
+ System.err.println(e);
3255
+ return null;
3256
+ }
3257
+ }
3258
+
32173259 static public Object clone(Object o)
32183260 {
32193261 try
....@@ -3222,12 +3264,19 @@
32223264 ObjectOutputStream out = new ObjectOutputStream(baos);
32233265
32243266 out.writeObject(o);
3267
+
3268
+ out.flush();
3269
+ out.close();
3270
+
3271
+ byte[] bytes = baos.toByteArray();
3272
+
3273
+ System.out.println("clone = " + bytes.length);
32253274
3226
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3275
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
32273276 ObjectInputStream in = new ObjectInputStream(bais);
32283277 Object obj = in.readObject();
32293278 in.close();
3230
- out.close();
3279
+
32313280 return obj;
32323281 } catch (Exception e)
32333282 {
....@@ -3251,13 +3300,21 @@
32513300 return null;
32523301 }
32533302
3303
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3304
+
32543305 public void Save()
32553306 {
32563307 cRadio tab = GetCurrentTab();
32573308
3309
+ copy.ExtractBigData(hashtable);
3310
+
32583311 //EditorFrame.m_MainFrame.requestFocusInWindow();
3259
- tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3312
+ tab.graphs[tab.undoindex++] = Compress(copy);
32603313
3314
+ copy.RestoreBigData(hashtable);
3315
+
3316
+ //assert(hashtable.isEmpty());
3317
+
32613318 for (int i = tab.undoindex; i < tab.graphs.length; i++)
32623319 {
32633320 tab.graphs[i] = null;
....@@ -3285,12 +3342,18 @@
32853342
32863343 void CopyChanged(Object3D obj)
32873344 {
3345
+ copy.ExtractBigData(hashtable);
3346
+
32883347 copy.clear();
32893348
32903349 for (int i=0; i<obj.Size(); i++)
32913350 {
32923351 copy.add(obj.get(i));
32933352 }
3353
+
3354
+ copy.RestoreBigData(hashtable);
3355
+
3356
+ //assert(hashtable.isEmpty());
32943357
32953358 copy.Touch();
32963359
....@@ -3331,7 +3394,7 @@
33313394
33323395 tab.undoindex -= 1;
33333396
3334
- CopyChanged(tab.graphs[tab.undoindex]);
3397
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33353398 }
33363399
33373400 public void Redo()
....@@ -3346,7 +3409,7 @@
33463409
33473410 tab.undoindex += 1;
33483411
3349
- CopyChanged(tab.graphs[tab.undoindex]);
3412
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
33503413 }
33513414
33523415 void ImportGFD()
....@@ -4295,6 +4358,7 @@
42954358
42964359 if (readobj != null)
42974360 {
4361
+ Save();
42984362 try
42994363 {
43004364 //readobj.deepCopySelf(copy);